diff --git a/src/main/java/com/watschman/betterenhancement/config/ConfigEntry.java b/src/main/java/com/watschman/betterenhancement/config/ConfigEntry.java index dd8c497..6697c7e 100644 --- a/src/main/java/com/watschman/betterenhancement/config/ConfigEntry.java +++ b/src/main/java/com/watschman/betterenhancement/config/ConfigEntry.java @@ -9,6 +9,7 @@ private String identifier; private String category; private String comment; + private ConfigType configType; private Object defaultValue; public ConfigEntry(String identifier, Object defaultValue) { @@ -52,6 +53,11 @@ return this; } + public ConfigEntry setConfigType(ConfigType configType) { + this.configType = configType; + return this; + } + public Property getProperty() { return this.property; } @@ -72,10 +78,14 @@ return this.defaultValue; } + public ConfigType getConfigType() { + return this.configType; + } + public Object getCurrentValue() { try { - switch (this.property.getType()) { - case INTEGER: + switch (this.configType) { + case INT: return this.property.getInt(); case DOUBLE: return this.property.getDouble(); @@ -83,6 +93,14 @@ return this.property.getBoolean(); case STRING: return this.property.getString(); + case INT_ARRAY: + return this.property.getIntList(); + case DOUBLE_ARRAY: + return this.property.getDoubleList(); + case BOOLEAN_ARRAY: + return this.property.getBooleanList(); + case STRING_ARRAY: + return this.property.getStringList(); default: return null; } @@ -96,13 +114,29 @@ private void initializeProperty() { if(this.defaultValue instanceof Integer) { + this.configType = ConfigType.INT; this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveInteger(this.defaultValue), this.comment); } else if(this.defaultValue instanceof Double) { + this.configType = ConfigType.DOUBLE; this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveDouble(this.defaultValue), this.comment); } else if(this.defaultValue instanceof Boolean) { + this.configType = ConfigType.BOOLEAN; this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveBoolean(this.defaultValue), this.comment); } else if(this.defaultValue instanceof String) { + this.configType = ConfigType.STRING; this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveString(this.defaultValue), this.comment); + } else if(this.defaultValue instanceof Integer[]) { + this.configType = ConfigType.INT_ARRAY; + this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveBooleanArray(this.defaultValue), this.comment); + } else if(this.defaultValue instanceof Double[]) { + this.configType = ConfigType.DOUBLE_ARRAY; + this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveDoubleArray(this.defaultValue), this.comment); + } else if(this.defaultValue instanceof Boolean[]) { + this.configType = ConfigType.BOOLEAN_ARRAY; + this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveBooleanArray(this.defaultValue), this.comment); + } else if(this.defaultValue instanceof String[]) { + this.configType = ConfigType.STRING_ARRAY; + this.property = Reference.CONFIG_INSTANCE.configuration.get(this.category, this.identifier, ConfigUtil.getPrimitiveStringArray(this.defaultValue), this.comment); } else { Reference.MOD_LOGGER.error("Detected unknown PropertyValue... Not initializing it." + this.defaultValue.getClass().getSimpleName()); }