SBPrime / AsyncWorldEdit-Premium

Async WorldEdit - Edit millions of blocks without lag! (Premium version)
Other
19 stars 4 forks source link

[Question] How to paste schematics using AWE? #21

Closed kpalang closed 8 years ago

kpalang commented 8 years ago

Now to the Premium part Non premium issue can be found here So this is basically a copy of this issue, but I'd really like a bit more explanation on how to do it. I feel like my pasting code is not async because the server freezes on every paste. Also my code is now a copy of your and rlf's. Like class declarations or variables etc. Here is my current class that should paste schematics, but I believe it is not using AWE.

Note: Mister rlf was far more advanced than I am.

SBPrime commented 8 years ago
  1. Use the edit session factory to obtain the Editsession instead of doing new EditSession (WorldEdit.getEditSessionFactory().createEditSession(...))
  2. Obtain a copy of IBlockPlacer from AWE
  3. Use the IBlockPlacer.performAsAsyncJob to run your method (the executeSpawn)
  4. Do not create an EditSession inside "thing" that you are running inside performAsAsyncJob, use the Edit sessioin provided by IFuncParamEx<Integer, ICancelabeEditSession, MaxChangedBlocksException>
kpalang commented 8 years ago

This is my current progress. I've gotten an EditSessionFactory, but the IBlocksPlacer declaration in the code you provided to rlf is much cleaner than mine. Why is that?

SBPrime commented 8 years ago

You should not implement the IBlockPlacer, you need to get it from the AWE plugin.

  1. Get instance of the AWE plugin
  2. Get IBlockPlacer using (IBlockPlacer IAsyncWorldEdit.getBlockPlacer())
kpalang commented 8 years ago

I can't extend Interface from PasteAction class. Repo Also what is the String in performAsAsyncJob needed for?

SBPrime commented 8 years ago

I have no idea what you mean.

kpalang commented 8 years ago

I mean that when I want to extend IFuncParamEx in PasteAction, IDE gives me an error saying "Interface nit expected here"

SBPrime commented 8 years ago

It looks like you need to brush up on the basics of java and object oriented programing:

https://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html https://docs.oracle.com/javase/tutorial/java/IandI/usinginterface.html

kpalang commented 8 years ago

Right, I've fiddled around with it for a while now and I think I've figured the code out. Atleast there are no red lines under the code :) But, now I have problems setting maven dependency. In IDE everything works as it should, but when maven starts compiling, every import related to AWE returns Failed to execute goal.

SBPrime commented 8 years ago

Sorry can't help you with that. If you have questions regarding AWE, and AWE API I'm more then happy to help. If it comes to java, maven and stuff you need to teach yourself how to do what you need.

kpalang commented 8 years ago

Alright, I understand. But as hopefully the last thing, if there is a maven repo for AWE, could you tell me it's url? Or is github usable?

SBPrime commented 8 years ago

Its on the "maven artifact" branch. I never used it therefore I can't tell you the exact url. Try googling for: github maven repo.

kpalang commented 8 years ago

Now I get this error, but the schematic pastes properly (Haven't noticed any problems yet)

[18:08:37] [Craft Scheduler Thread - 2/INFO]: Running s in full async mode.
[18:08:38] [Server thread/INFO]: Job [0] s - placing blocks
[18:08:42] [Craft Scheduler Thread - 2/WARN]: Exception in thread "Craft Scheduler Thread - 2" 
[18:08:42] [Craft Scheduler Thread - 2/WARN]: org.apache.commons.lang.UnhandledException: Plugin AsyncWorldEdit v3.2.2 generated an exception while executing task 7
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at org.primesoft.asyncworldedit.blockPlacer.BlockPlacer$2.task(BlockPlacer.java:1191)
    at org.primesoft.asyncworldedit.worldedit.AsyncTask.doRun(AsyncTask.java:63)
    at org.primesoft.asyncworldedit.worldedit.BaseTask.run(BaseTask.java:141)
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    ... 3 more
SBPrime commented 8 years ago

Send the actual code that caused the error.

kpalang commented 8 years ago

Here

SBPrime commented 8 years ago

Well it looks like the action that you provide is set to null are you 100% sure this is the code that you are using?

kpalang commented 8 years ago

I am 100% sure, That null was there because it was easy to write... Anyway, i replaced it with editSession.getBlockChangeCount() and no errors now.

kpalang commented 8 years ago

Thank you for bearing with me good sir! First part of my project is complete. I will soon be back with new simple problems :)

SBPrime commented 8 years ago

No problem. So what exactly caused the problem?

kpalang commented 8 years ago

That return null in execute.