Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted API over to use new World.
This breaks backwards compatibility for all getWorld() methods, but shim methods were added for binary compatibility with method calls that use LocalWorld.
- Loading branch information
Showing
49 changed files
with
822 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
apologises for posting it here, but I am unofficially updating plugin called CreativeControl and the worldedit integration broken in the very recent snapshot. Can you please help me with updating these two classes?
https://github.com/kangarko/CreativeControl/tree/master/src/main/java/me/FurH/CreativeControl/integration/worldedit
Thanks very much!
Regards,
kangarko
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to get back to you later. Note that, if possible, I would prefer if I could make a change in WorldEdit so that existing calls don't break (by adding shim classes/deprecated methods/etc.), so I will see what can be done there.
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I can wait, I have made some non breaking changes (https://github.com/kangarko/CreativeControl/commit/67256af7ef718e755afa329e2c86ec7773d80c06).
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you could, replace EditSession with DelegateExtent and override setBlock(). To execute a block set, use super.setBlock()
And then register your new delegate extent with something like this: https://github.com/LogBlock/LogBlock/pull/542/files#diff-7aa28538d928ec2f63148c2ac7c5e031R31
You don't need EditSessionFactory anymore.
Please note that the old code assumes that the world is a BukkitWorld. It may or may not be the case, even if you run on Bukkit. This is because, for example, if you install Bukkit and Forge versions of WE in the future on the same server, it may use Bukkit for perms but actually use ForgeWorld to make the changes.
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
thank you very much for help. I tried editing it (https://github.com/kangarko/CreativeControl/commit/421be31d9d741b18a1a07cb58432a581e02a1038) but it gives me StackOverflowError. I am not really experienced with creativecontrol, plugin isn´t mine, I am only updating it since official version is broken with 3 plugins already.
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, you should no longer be calling block logging plugins. Since the change to extents, each plugin that registers with WE will independently get the changes.
As for the SOE, it would help if you could paste the error.
Edit: Also just saw that you just copied the logblock code. Since you're trying to prevent changes, rather than just log them, you don't need an AbstractLoggingExtent. Check this comment: #293 (comment)
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kangarko As wiz said, you should not be extending
AbstractLoggingExtent
. AbstractLoggingExtent is made for block loggers, and the code that it has forsetBlock
is below:As you see,
onBlockChange()
gets called but the block gets set anyway. If you callsuper.setBlock(...)
, you merely run the code above again, which calls your method again, which results in an infinite loop (and then a stack overflow).The Extent Interface
What you really want to do is implement the
Extent
interface. First, understand that extents are "stacked":HistoryExtent -> BlockReorderExtent -> BukkitWorld
Each extent handles the block placement attempt, and if it wants it to continue, it passes it onto the next
Extent
. The idea is that you inject your own extent:HistoryExtent -> BlockReorderExtent -> YourExtent -> BukkitWorld
Then when you want to prevent a block place, you don't pass it onto BukkitWorld:
HistoryExtent -> BlockReorderExtent -> YourExtent
If
BukkitWorld.setBlock()
never gets called, the block is not set.You Actually Want AbstractDelegateExtent
However, you should not directly implement
Extent
. UseAbstractDelegateExtent
, which, by default, implements all methods as merely a proxy to the next extent. Because it does that, you don't need to actually implement any methods to make your class compile:But since you want to explicitly override how blocks are placed, you override the
setBlock
method. You can callsuper.setBlock(...)
, which refers toAbstractDelegateExtent.setBlock(...)
, which merely passes the call onto the next extent (and thus setting the block). You can see that in the example below.Of course, if that was your
Extent
's code, then it would do nothing useful. Because it just passes the call onto the next extent, blocks get placed like normal.You would implement some condition:
By the way, the whole
WorldEdit.getInstance().getEventBus().register(new Object() { ...
basically makes a new anonymous class and registers it in one go. For code organization, you may want to make it a separate class (in a separate file), and then register an instance of that class:WorldEdit.getInstance().getEventBus().register(new CreativeControlExtent(this));
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
thank you so much for help. I have finally recoded entirely, just it by myself as I found myself being unable to fix it.
I found working code in section Sample Code at #293 (comment)
Thanks!
The changed file is here: https://github.com/kangarko/CreativeControl/blob/28837ef33fc7cb112e165b737f79ccf5ff0cd6e1/src/main/java/me/FurH/CreativeControl/integration/worldedit/CreativeEditSession.java
I would really appreciate if you can test it, I did and it worked but maybe I missed something.
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kangarko Use BEFORE_CHANGE rather than BEFORE_HISTORY. Some things skip history and therefore would skip your hook.
Also I don't think VERY_LATE is necessary. Keep it NORMAL.
VERY_LATE is better for purely-logging purposes.
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you suggest LogBlock's subscribe priority be changed to VERY_LATE?
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I´ll fix it.
Edit: Changes commited ;)
24f8fbc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DarkArc Possibly, though we might want have something like MONITOR.