Add RegistryType#getByKey

This commit is contained in:
KennyTV 2020-12-16 19:50:49 +01:00
parent 6622b7dcff
commit 823ac0e173
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -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<String, RegistryType> 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;