From c2d7bf96b30683cf2bd47c4739035be98d8745b5 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 13 Jul 2024 12:27:36 +1200 Subject: [PATCH] Unfortunately can't compile locally atm --- .../disguise/utilities/params/ParamInfo.java | 11 +++++++++-- .../disguise/utilities/params/ParamInfoTypes.java | 2 +- .../utilities/params/types/ParamInfoEnum.java | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java index d47950b3..e262c11a 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfo.java @@ -2,6 +2,7 @@ package me.libraryaddict.disguise.utilities.params; import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; import me.libraryaddict.disguise.utilities.translations.TranslateType; +import org.bukkit.Keyed; import java.util.Arrays; import java.util.HashSet; @@ -44,8 +45,14 @@ public abstract class ParamInfo { this.possibleValues = new LinkedHashMap<>(); - for (T anEnum : possibleValues) { - this.getValues().put(((Enum) anEnum).name(), anEnum); + if (paramClass.isEnum()) { + for (T anEnum : possibleValues) { + this.getValues().put(((Enum) anEnum).name(), anEnum); + } + } else { + for (T anEnum : possibleValues) { + this.getValues().put(((Keyed) anEnum).getKey().getKey(), anEnum); + } } } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java index 21110c4b..e5d0e1c7 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java @@ -194,7 +194,7 @@ public class ParamInfoTypes { } if (NmsVersion.v1_20_R4.isSupported()) { - // paramInfos.add(new ParamInfoEnum(Wolf.Variant.class, "Wolf Variant", "The variant of a wolf")); + paramInfos.add(new ParamInfoEnum(Wolf.Variant.class, "Wolf Variant", "The variant of a wolf")); } if (NmsVersion.v1_21_R1.isSupported()) { diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/types/ParamInfoEnum.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/types/ParamInfoEnum.java index 54359975..7cd895a9 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/types/ParamInfoEnum.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/params/types/ParamInfoEnum.java @@ -2,6 +2,8 @@ package me.libraryaddict.disguise.utilities.params.types; import me.libraryaddict.disguise.utilities.params.ParamInfo; import me.libraryaddict.disguise.utilities.parser.DisguiseParseException; +import org.bukkit.Bukkit; +import org.bukkit.Keyed; import java.util.Map; @@ -10,7 +12,8 @@ import java.util.Map; */ public class ParamInfoEnum extends ParamInfo { public ParamInfoEnum(Class paramClass, String name, String description) { - super(paramClass, name, name, description, paramClass.getEnumConstants()); + super(paramClass, name, name, description, + paramClass.isEnum() ? paramClass.getEnumConstants() : (T[]) Bukkit.getRegistry((Class) paramClass).stream().toArray()); } public ParamInfoEnum(Class paramClass, String name, String valueType, String description, T[] possibleValues) {