Phase out NamespacedKey and org.bukkit.Keyed while maintaining runtime compat #10568
Machine-Maker
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Regsitry
As I see it there are several steps to this process, the first of which is making
org.bukkit.Registry
's genericT
extendnet.kyori.adventure.key.Keyed
instead oforg.bukkit.Keyed
. That is done in #9009.The next step can be done with registries with types that are backed by a server impl type, like
Registry.STRUCTURE_TYPE
. I think this can be handled by making the API type (in this example the abstract classStructureType
) extend adventureKeyed
instead of bukkitKeyed
.That leaves 2 issues:
Keyed
StructureType#getKey()
The first can be handled by making the impl type still extend the obsolete bukkit
Keyed
. That will allow casts to still succeed. It also will allow fields typed bukkit Keyed to work stillThe second can be handled by rewriting
StructureType#getKey()
to first cast toCraftStructureType
and then call getKey on that.Other uses
most of the other uses can just have bytecode rewriting to change the parameter type to adventure
Key
. In places whereNamespacedKey
is the return type, the bytecode rewriting can just insert another static invoke to convert the returnedKey
to aNamespacedKey
if that's what the plugin expects.Beta Was this translation helpful? Give feedback.
All reactions