From 3930641fb69f9b2d1be688fd39b861849869fbb4 Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 6 Jun 2023 18:17:16 +0930 Subject: [PATCH] Added short to the debug config screen --- .../java/com/seibel/lod/core/config/Config.java | 8 ++++++-- .../com/seibel/lod/core/config/ConfigBase.java | 16 +++++++--------- .../main/resources/assets/lod/lang/en_us.json | 4 +++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/config/Config.java b/core/src/main/java/com/seibel/lod/core/config/Config.java index b3b272f8c..b4dd0be44 100644 --- a/core/src/main/java/com/seibel/lod/core/config/Config.java +++ b/core/src/main/java/com/seibel/lod/core/config/Config.java @@ -836,6 +836,10 @@ public class Config .set(420.69d) .build(); + public static ConfigEntry shortTest = new ConfigEntry.Builder() + .set((short) 42) + .build(); + public static ConfigEntry longTest = new ConfigEntry.Builder() .set(42069l) .build(); @@ -848,11 +852,11 @@ public class Config .set("Test input box") .build(); - public static ConfigEntry listTest = new ConfigEntry.Builder() + public static ConfigEntry> listTest = new ConfigEntry.Builder>() .set(new ArrayList()) .build(); - public static ConfigEntry> hashMapTest = new ConfigEntry.Builder>() + public static ConfigEntry> mapTest = new ConfigEntry.Builder>() .set(new HashMap<>()) .build(); } diff --git a/core/src/main/java/com/seibel/lod/core/config/ConfigBase.java b/core/src/main/java/com/seibel/lod/core/config/ConfigBase.java index f14afcd71..b94cf0653 100644 --- a/core/src/main/java/com/seibel/lod/core/config/ConfigBase.java +++ b/core/src/main/java/com/seibel/lod/core/config/ConfigBase.java @@ -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> acceptableInputs = new ArrayList>() {{ 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); } diff --git a/core/src/main/resources/assets/lod/lang/en_us.json b/core/src/main/resources/assets/lod/lang/en_us.json index 5c45beb30..f78db7672 100644 --- a/core/src/main/resources/assets/lod/lang/en_us.json +++ b/core/src/main/resources/assets/lod/lang/en_us.json @@ -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",