Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrie full API #29

Closed
SBPrime opened this issue Jun 18, 2014 · 13 comments
Closed

Wrie full API #29

SBPrime opened this issue Jun 18, 2014 · 13 comments

Comments

@SBPrime
Copy link
Owner

SBPrime commented Jun 18, 2014

No description provided.

@aaomidi
Copy link

aaomidi commented Jul 4, 2014

Can you please add a Callback method.

For example we use ASyncWorldEdit's EditSession for an edit, we can also provide an interface with an "execute" method so that code will be executed, in the main thread, by the plugin.

For example:

public interface Callback<T> {
    public void execute(T response);
}

The execute method will be called once the edit is done.

@ghost
Copy link

ghost commented Jul 15, 2014

I really need API for loading schematic, it lags a lot!

@SBPrime
Copy link
Owner Author

SBPrime commented Jul 18, 2014

@mbcx2 API or support for that command? I have seen other plugins load schematic in async thread then placed in the world either in main thread or using AWE.

@ghost
Copy link

ghost commented Jul 18, 2014

There is both.

@ghost
Copy link

ghost commented Jul 18, 2014

As far as I know the schematic loading consists of i/o operations only, so it should be good to do that in an async thread.

@SBPrime
Copy link
Owner Author

SBPrime commented Jul 19, 2014

@runky Exactly, you can do that in an async thread.
@mbcx2 If you want to use it as a plugin dev, you can do that already. If you want to use it as normal WorldEdit operation it needs to by written, but its not an API feature.

@TobyMellor
Copy link

I agree, there needs to be some way for developers to know when a job is finished, how long until it will be finished, and the current BPS... the same information the player is able to contain when using worldedit.

@SBPrime
Copy link
Owner Author

SBPrime commented Jan 11, 2015

@Intensearmadillo: As you can see all the features that you have mentioned are available.

To get BlockPlacer:

aweMain =AsyncWorldEditMain.getInstance()
bPlacer = aweMain.getBlockPlacer();

For job start/finish use:

bPlacer.addListener(myListener);

Then for job state change (in job added listener):

 job.addStateChangedListener(myJobStateListener);

For block placing speed use:

playerEntry = blockPlacer.getPlayerEvents(player);
playerEntry.getSpeed(); <--- current block placing speed
playerEntry.getQueue(); <--- current blocks queue = how many blocks there are to place, use to calculate the time.

@FormallyMyles
Copy link

@SBPrime
Hey thanks for the information above, I have a job being created entirely from code.

EditSession es = new AsyncEditSessionFactory(AsyncWorldEditMain.getInstance(), we.getWorldEdit().getEventBus()).getEditSession(new BukkitWorld(world), 99999999);

Which then uses it to paste, the issue I have is the player I use later on...

CuboidClipboard cc = new AsyncCuboidClipboard(PlayerEntry.UNKNOWN, CuboidClipboard.loadSchematic(f));

Is an anonymous player, and multiple of these may be setting off at once, meaning that I can't just use the player unknown name or what. Is there a way to turn an EditSession into the a Job ID so I can keep track of these?

I don't really want to make fake players as that's not very good practice, is there anything you would suggest for this sort of thing?

I'd also like to not rely on timing it to catch the job in the listener because it's possible that the jobs could have multiple added at a time and i'd never be able to work out which one belongs to which part of it.

I can't see any way to turn a job into more information such as block coordinates etc?

@SBPrime
Copy link
Owner Author

SBPrime commented Jan 11, 2015

@MylesIsCool First of all don't use new AsyncEditSession. Use getEditSessionFactory from WorldEdit. Regarding "Fake player" in AWE its simply a UUID, so its not a bad practice :)

You could use:

  • BlockPlacer.PerformAsAsyncJob(...)
  • AsyncEditSessionFactory.getThreadSafeEditSession(...) <--- Caste the EditSession factory from WorldEdit.getEditSessionFactory, don't use the getEditSession!
  • new AsyncCuboidClipboard(...) <--- that's what you used

Whan you use this, remember to add the jobAdded listener, and jobStateChanged listener.

For reference look at: #53

@TobyMellor
Copy link

Any way to get composition of certain blocks in a region asynchronously and return its percentage? It would be extremely useful for calculating the percentages of mines. Thanks.

@SBPrime
Copy link
Owner Author

SBPrime commented Jan 22, 2015

try using the standard WE function (getDistribution if i remember correctly) within PerformAsAsyncJob.

SBPrime added a commit that referenced this issue Feb 10, 2015
CHG: Code refactoring
CHG: Removed PlotMe dependency
ADD: Added PlotMeFix API
@SBPrime
Copy link
Owner Author

SBPrime commented Jul 9, 2016

Implemented premium API. Details available here:
https://github.com/SBPrime/AsyncWorldEdit-api

@SBPrime SBPrime closed this as completed Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants