diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/RegistryType.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/RegistryType.java index 4dff28697..1eb19fccc 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/RegistryType.java +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/RegistryType.java @@ -1,5 +1,10 @@ package us.myles.ViaVersion.api.rewriters; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + public enum RegistryType { BLOCK("block"), @@ -8,11 +13,23 @@ public enum RegistryType { ENTITY("entity_type"), GAME_EVENT("game_event"); + private static final Map MAP = new HashMap<>(); + private static final RegistryType[] VALUES = values(); + + static { + for (RegistryType type : getValues()) { + MAP.put(type.resourceLocation, type); + } + } + public static RegistryType[] getValues() { return VALUES; } - private static final RegistryType[] VALUES = values(); + @Nullable + public static RegistryType getByKey(String resourceKey) { + return MAP.get(resourceKey); + } private final String resourceLocation;