Rewrite Adventure Book calls to BookMeta - #14081
Conversation
after removal in adventure 5.0
…ng re obfuscation
|
I would like to know if the version check should be dropped (the method with a different signature can't be compiled against 26.2 anyways) and if the added code should be at the start or end of the method. I tried to figure it from the changes but it did not lead me to a fixed result. I also hope that the removal of the remnant method is ok and if I should also remove the methods which now just call super. |
|
Wouldn't this break if
|
Here is my test with the branch:@Override
public boolean execute(final CommandSender sender, final String commandLabel, final String[] args) {
final ItemStack book = ItemStack.of(Material.WRITTEN_BOOK);
final BookMeta meta = (BookMeta) book.getItemMeta();
eval("getter", () -> meta.pages());
eval("workingChain", () -> meta.author(Component.empty()).title(Component.empty()).pages(List.of()));
eval("setterL", () -> meta.pages(List.of()));
eval("setterL2", () -> meta.pages(List.of()).pages());
eval("setterA", () -> meta.pages(Component.empty()));
eval("setterA2", () -> meta.pages(Component.empty()).author());
eval("doubleSetter", () -> meta.pages(Component.empty()).pages(Component.empty()));
eval("doubleSetter2", () -> meta.pages(List.of()).pages(List.of()));
eval("title", () -> meta.title(Component.empty()).pages(List.of()));
eval("title2", () -> meta.title(Component.empty()).pages(List.of()).title());
eval("author", () -> meta.author(Component.empty()).pages(List.of()));
eval("author2", () -> meta.author(Component.empty()).pages(List.of()).author());
sender.sendMessage(Component.text("Executed book meta test"));
return true;
}
private void eval(final String name, final Runnable runnable) {
try {
runnable.run();
getLogger().info(name + " executed");
} catch (final Error error) {
getLogger().severe(name + " failed: " + error.getMessage());
}
}
|
|
Yeah those are harder to fix, that's why in the original issue I mentioned redirecting instead the calls to an internal class with static methods that take the book meta + the arguments and returns an adventure book, this way nothing further should be affected as it's continuing to expect the Book instance |
|
Your suggestion works like a charm! |
|
In my opinion that is fine, lots of deprecated methods become no-op in new version releases without a warning period (and this one had a bit of warning period), while the plugin at least loads. But better wait for a team member to decide |
|
if that breakage isn't related to this then a separate PR is preferred, prevents one thing blocking the other needlessly |
kennytv
left a comment
There was a problem hiding this comment.
The two Craft* changes don't belong here, but the commodore changes look reasonable
As already wrote to mbax in the DC I made these changes to retain the behavior to before the adventure 5 change. After that the Writable Book no longer had colorful pages and the WrittenBook no longer had neither title nor author. For that reason I see that as required part of the fix to maintain backwards compatibility/have consistent behavior. Edit: Also, with that comment being an approve and not a change request I thought of it more of a "well, it should not be here but I guess I don't care enough". |
|
On suggestion of @masmc05 I added a second issue with reasoning for the Craft changes done in this PR and edited the description. |

Fixes #14030 with re-routing the
pagessetter calls to the Book to the BookMeta and then returning the newasBook, rightfully returing an adventure Book instance to work with.In the process of testing the result I discovered and fixed #14135, which also got broken in the adventure 5 update process. I decided to fix both in the same PR since both issues break the expected result/usage of the methods.