PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.39k stars 2.2k forks source link

[API] ItemMeta DestroyableKeys/PlaceableKeys methods are disappeared in Paper API 1.20.5+ #10818

Open Dymeth opened 1 month ago

Dymeth commented 1 month ago

Expected behavior

The problem:

The backward capability of there's methods was broken in Paper 1.20.5. No more there's methods exist on Paper API 1.20.5+:

ItemMeta#getDestroyableKeys()
ItemMeta#getPlaceableKeys()
ItemMeta#hasDestroyableKeys()
ItemMeta#hasPlaceableKeys()
ItemMeta#setDestroyableKeys(@NotNull Collection<Namespaced> canDestroy)
ItemMeta#setPlaceableKeys(@NotNull Collection<Namespaced> canPlaceOn)

Comparation: 1.20.4 API: https://jd.papermc.io/paper/1.20.4/org/bukkit/inventory/meta/ItemMeta.html 1.20.5 API: https://jd.papermc.io/paper/1.20.5/org/bukkit/inventory/meta/ItemMeta.html

Ways to solve i see:

Observed/Actual behavior

Paper 1.20.6 marked as stable for now, but still there's no methods. Methods wasn't marked as deprecated and alterative wasn't suggested. Now it looks like the methods just magically disappeared or never existed at all.

There's methods was removed too, but it was marked as deprecated earlier:

ItemMeta#getCanDestroy()
ItemMeta#getCanPlaceOn()
ItemMeta#setCanDestroy(Set<Material> canDestroy)
ItemMeta#setCanPlaceOn(Set<Material> canPlaceOn)
ItemMeta#setDisplayNameComponent(@Nullable net.md_5.bungee.api.chat.BaseComponent[] component)

Steps/models to reproduce

Just try to use listed methods in your plugin with Paper API 1.20.5 or newer

Plugin and Datapack List

-

Paper version

Paper version 1.20.6-115-master@9d6f2cc (2024-05-28T14:55:16Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)

Other

Also possibly related with #8128

electronicboy commented 1 month ago

Yes, this was noted in the release notes. That API was no longer able to represent the underlying data, and keeping it around as-is would just break itemstacks, basically

Dymeth commented 1 month ago

Yes, this was noted in the release notes. That API was no longer able to represent the underlying data, and keeping it around as-is would just break itemstacks, basically

Well, what's the workaround we have right now? Check if method exist before calling it (using reflection)? Also we need to tell plugins users on 1.20.5+ that some of the functionality doesn't work?