Update src/main/java/com/seibel/lod/core/config/ConfigBase.java

This commit is contained in:
Ran
2022-02-20 13:17:35 +00:00
parent 83ec6f4da2
commit 081958db59
@@ -1,10 +1,5 @@
package com.seibel.lod.core.config;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.util.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@@ -13,9 +8,10 @@ import java.util.List;
* Indexes and sets everything up for the file handling and gui
*
* @author coolGi2007
* @author Ran
*/
public class ConfigBase {
public static final List<ConfigEntry> entries = new ArrayList<>();
public static final List<ConfigEntry<?>> entries = new ArrayList<ConfigEntry<?>>();
public static final List<String> categories = new ArrayList<>();
public static void init(Class<?> config) {
@@ -36,9 +32,13 @@ public class ConfigBase {
for (Field field : config.getFields())
{
if (ConfigEntry.class.isAssignableFrom(field.getType())) { // If item is type ConfigEntry
// entries.add(ConfigEntry.class.cast(field));
// entries.get(entries.size() - 1).category = (category.isEmpty() ? "" : category + ".");
// entries.get(entries.size() - 1).category = field.getName();
try {
entries.add((ConfigEntry<?>) field.get(field.getType())); // Add to entries
} catch (IllegalAccessException exception) {
exception.printStackTrace();
}
entries.get(entries.size() - 1).category = (category.isEmpty() ? "" : category + ".");
entries.get(entries.size() - 1).category = field.getName();
}
if (field.isAnnotationPresent(ConfigAnnotations.Category.class)) { // If it's a category then init the stuff inside it and put it in the category list