CoreProtect

CoreProtect

1M Downloads

Replace Bukkit enum name usage by namespaced keys

MartijnMuijsers opened this issue ยท 2 comments

commented

CoreProtect currently uses Bukkit enum names to distinguish blocks. It simply adds and removes a "minecraft:" prefix to emulate namespaced keys, but doesn't actually use them.

Namespaced key support has been available for many years. Paper has already indicated in their latest update (https://forums.papermc.io/threads/paper-velocity-1-20-1.783/) that the use of these classes as enums will be retired. CoreProtect already has the correct keys stored in the database, so no changes would be required to the database at all (apart from possibly the strange case of EntityType.UNKNOWN which doesn't have a key, and is stored as "minecraft:unknown" currently).

This is a request to replace the current key-ish system with actual keys. For Material for example, the getKey method can be used to get a key, and the matchMaterial method can be used to get the Material for a key without any further manual work in the plugin.

This would also instantly make CoreProtect fully compatible with any hypothetical blocks that have a different namespace than "minecraft:", for example a hypothetical "realms:" (which is the namespace for Minecraft Realms specific resources) block.

Note that making this change would not fix issue #390, but is a helpful step in that direction (for example, CoreProtect could expose an API letting other plugins register listeners that can interpret blocks into their own exclusive namespaced keys).

Thank you for your consideration!

commented

Duplicate of #350

commented

It would be a great idea.