Added short to the debug config screen

This commit is contained in:
coolGi
2023-06-06 18:17:16 +09:30
parent a8682ec164
commit 3930641fb6
3 changed files with 16 additions and 12 deletions
@@ -836,6 +836,10 @@ public class Config
.set(420.69d)
.build();
public static ConfigEntry<Short> shortTest = new ConfigEntry.Builder<Short>()
.set((short) 42)
.build();
public static ConfigEntry<Long> longTest = new ConfigEntry.Builder<Long>()
.set(42069l)
.build();
@@ -848,11 +852,11 @@ public class Config
.set("Test input box")
.build();
public static ConfigEntry<List> listTest = new ConfigEntry.Builder<List>()
public static ConfigEntry<List<String>> listTest = new ConfigEntry.Builder<List<String>>()
.set(new ArrayList<String>())
.build();
public static ConfigEntry<HashMap<String, String>> hashMapTest = new ConfigEntry.Builder<HashMap<String, String>>()
public static ConfigEntry<Map<String, String>> mapTest = new ConfigEntry.Builder<Map<String, String>>()
.set(new HashMap<>())
.build();
}
@@ -39,6 +39,7 @@ public class ConfigBase
Byte
Integer
Double
Short
Long
Float
String
@@ -52,9 +53,9 @@ public class ConfigBase
public static final List<Class<?>> acceptableInputs = new ArrayList<Class<?>>() {{
add(Boolean.class);
add(Byte.class);
add(Short.class);
add(Integer.class);
add(Double.class);
add(Short.class);
add(Long.class);
add(Float.class);
add(String.class);
@@ -100,16 +101,17 @@ public class ConfigBase
entry.configBase = this;
if (ConfigEntry.class.isAssignableFrom(field.getType())) { // If item is type ConfigEntry
if (!isAcceptableType(((ConfigEntry<?>) entry).getType())) {
if (!isAcceptableType(entry.getType())) {
LOGGER.error("Invalid variable type at [" + (category.isEmpty() ? "" : category + ".") + field.getName() + "].");
LOGGER.error("Type [" + ((ConfigEntry<?>) entry).getType() + "] is not one of these types [" + acceptableInputs.toString() + "]");
LOGGER.error("Type [" + entry.getType() + "] is not one of these types [" + acceptableInputs.toString() + "]");
entries.remove(entries.size() -1); // Delete the entry if it is invalid so the game can still run
}
}
if (ConfigCategory.class.isAssignableFrom(field.getType())) { // If it's a category then init the stuff inside it and put it in the category list
assert entry instanceof ConfigCategory;
if (((ConfigCategory) entry).getDestination() == null)
((ConfigCategory) entry).destination = ((ConfigCategory) entry).getNameWCategory();
((ConfigCategory) entry).destination = entry.getNameWCategory();
if (entry.get() != null) {
initNestedClass(((ConfigCategory) entry).get(), ((ConfigCategory) entry).getDestination());
}
@@ -121,11 +123,7 @@ public class ConfigBase
private static boolean isAcceptableType(Class<?> Clazz) {
if (Clazz.isEnum())
return true;
for(Class<?> i: acceptableInputs) {
if(i == Clazz)
return true;
}
return false;
return acceptableInputs.contains(Clazz);
}
@@ -55,6 +55,8 @@
"Integer test",
"lod.config.client.advanced.debugging.debugConfigScreen.doubleTest":
"Double test",
"lod.config.client.advanced.debugging.debugConfigScreen.shortTest":
"Short test",
"lod.config.client.advanced.debugging.debugConfigScreen.longTest":
"Long test",
"lod.config.client.advanced.debugging.debugConfigScreen.floatTest":
@@ -63,7 +65,7 @@
"String test",
"lod.config.client.advanced.debugging.debugConfigScreen.listTest":
"List (ArrayList) test",
"lod.config.client.advanced.debugging.debugConfigScreen.hashMapTest":
"lod.config.client.advanced.debugging.debugConfigScreen.mapTest":
"Map (HashMap) test",