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 |
Fixes #14030 with simply re-routing all calls to the BookMeta, which now itself has (or inherits) the relevant methods.
I have to admit that I think that could break some stuff when it does want to access it and research how to determine that in a better way than just re-rerouting everything (like checking just calls from BookMeta to Book like mentioned in the issue).I now understand how that works and check the owner for BookMeta and change just the return types to also BookMeta.