Unfortunately can't compile locally atm

This commit is contained in:
libraryaddict 2024-07-13 12:27:36 +12:00
parent 0c0129a116
commit c2d7bf96b3
3 changed files with 14 additions and 4 deletions

View File

@ -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<T> {
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);
}
}
}

View File

@ -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()) {

View File

@ -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<T> extends ParamInfo<T> {
public ParamInfoEnum(Class<T> 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<Keyed>) paramClass).stream().toArray());
}
public ParamInfoEnum(Class paramClass, String name, String valueType, String description, T[] possibleValues) {