Improve Registry
This commit is contained in:
@@ -184,6 +184,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
|
||||
private final Class<?> bukkitClass; // Paper - relax preload class
|
||||
private final Map<NamespacedKey, B> cache = new HashMap<>();
|
||||
private final Map<B, NamespacedKey> byValue = new java.util.IdentityHashMap<>(); // Paper - improve Registry
|
||||
private final net.minecraft.core.Registry<M> minecraftRegistry;
|
||||
private final io.papermc.paper.registry.entry.RegistryTypeMapper<M, B> minecraftToBukkit; // Paper - switch to Holder
|
||||
private final BiFunction<NamespacedKey, ApiVersion, NamespacedKey> serializationUpdater; // Paper - rename to make it *clear* what it is *only* for
|
||||
@@ -237,6 +238,7 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
}
|
||||
|
||||
this.cache.put(namespacedKey, bukkit);
|
||||
this.byValue.put(bukkit, namespacedKey); // Paper - improve Registry
|
||||
|
||||
return bukkit;
|
||||
}
|
||||
@@ -279,4 +281,11 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
return this.minecraftToBukkit.convertDirectHolder(holder);
|
||||
}
|
||||
// Paper end - support Direct Holders
|
||||
|
||||
// Paper start - improve Registry
|
||||
@Override
|
||||
public NamespacedKey getKey(final B value) {
|
||||
return this.byValue.get(value);
|
||||
}
|
||||
// Paper end - improve Registry
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user