Add new Lidded API, deprecating existing bukkit Lidded API. Adds PlayerLiddedOpenEvent#11814
Add new Lidded API, deprecating existing bukkit Lidded API. Adds PlayerLiddedOpenEvent#11814456dev wants to merge 5 commits into
Conversation
|
Fixed #11364 with new api |
| /** | ||
| * @deprecated Incomplete api. Use {@link io.papermc.paper.block.Lidded} instead. | ||
| */ | ||
| @Deprecated // Paper - Deprecate Bukkit's Lidded API |
There was a problem hiding this comment.
TODO: remove this lone // paper comment
| @Deprecated // Paper - Deprecate Bukkit's Lidded API | |
| @Deprecated |
| * Cancelling this event prevents the player from being considered in other {@link Lidded} methods: | ||
| * they will not contribute to the {@link Lidded#getTrueLidState()} and {@link Lidded#getEffectiveLidState()}. | ||
| * <p> | ||
| * This event is called twice for double chests, once for each half. |
There was a problem hiding this comment.
todo: fix global implementation for double chests.
iirc as well as this double-fire behaviour, modifying the state of the non-dominant half doesnt play a sound, but still keeps the animation open seperately.
| LidState getEffectiveLidState(); | ||
|
|
||
| /** | ||
| * Gets how the lid would be without any lidded mode, based on players interacting with the block. |
There was a problem hiding this comment.
TODO: replace with smth like
| * Gets how the lid would be without any lidded mode, based on players interacting with the block. | |
| * Gets how the lid would be with {@link LidMode.DEFAULT} | |
| * I.E. based on players interacting with the block. |
|
|
||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| @NullMarked |
There was a problem hiding this comment.
Is this actually needed, since its a very simple enum?
There was a problem hiding this comment.
This enum and LidMode don't have anything that would be affected by it, so I would say it's not needed.
- adds `/test_lidded_new <blockpos> query` to get the api's view of the block - adds `/test_lidded_new <blockpos> set <lidmode>` to change it. - adds `/test_lidded_old <blockpos> <is_open | close | toggle>` to use the implementation of the old api on top of the new api. - adds `LiddedTestListener` to test `PlayerLiddedOpenEvent`, which makes any lidded blocks open quietly (ie cancel the event), if done while holding any wool in your main hand. since it's not the easiest thing to test in-game without some api consumer/activator a seconds player might be useful to inspect state while it is open/closed with multiple people.
4a28d31 to
7bdba6c
Compare
|
|
||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| @NullMarked |
There was a problem hiding this comment.
This enum and LidMode don't have anything that would be affected by it, so I would say it's not needed.
| * @deprecated Misleading name. Use {@link io.papermc.paper.block.Lidded#getLidMode()} for the direct replacement, or {@link io.papermc.paper.block.Lidded#getEffectiveLidState()} to tell if the lid is visibly open to the player instead. | ||
| */ | ||
| @Deprecated | ||
| boolean isOpen(); |
There was a problem hiding this comment.
If these names are misleading, I think it would be better to fix the implementation rather than changing the javadoc and deprecating the methods.
I think it would also be better to add onto this class rather than creating a whole new interface.
There was a problem hiding this comment.
Just to confirm, it would be preferred to completely replace this API in 1 step?
I didn't want to create any breaking changes, and making it separate would allow for it to be cleanly removed separately at a later point.
There was a problem hiding this comment.
What I'd prefer would be to add the methods to the existing API and leave the old methods the same, and changing the impl of the old methods to use the new api impl.
I'll wait for others to respond with their thoughts in case I'm not making sense.
| @Override | ||
| public void open() { | ||
| public CraftBarrel copy() { | ||
| return new CraftBarrel(this, null); | ||
| } | ||
|
|
||
| @Override | ||
| public CraftBarrel copy(Location location) { | ||
| return new CraftBarrel(this, location); | ||
| } |
There was a problem hiding this comment.
The methods being moved around like this creates a lot of unnecessary diff.
|
This is the third of fourth time I am reading through this PR and I think the surface area of this is just too large for me to be confortable with merging this. The same can be said for the commented out craftbukkit diff. Just delete it, it makes the code feel even more duplicate.
But yea, I think the only sane way we will ever get a PR like this in is completely ripping out CB lidded diff in commit A and reintroducing a very much externalised lidded system into the affected types. As said, the giant diff in the CB types also does not help making this more reviewable but moving thins from patches into normal types to handle state would be a good start to this. |
|
Going to close this PR for now, feel free to reopen if / when you find time to heavily reduce / externalize the diff. |
replaces #11379, pre hard-fork pr
minimal changes from previous pr, mostly some variable renames + //paper comments, to be in-line with the new guidelines.
previous description below:
Featuring
This also deprecates Bukkits api because of the confusing and outright incorrect javadocs (so those now accurately represent the behaviour)
Testable with the included testplugin commands.
I'm not 100% sure if the PaperLidded interface is the best way of doing this, but it is working
Also, let me know if the naming needs to change.