config save bug fix
This commit is contained in:
@@ -137,25 +137,17 @@ public class ConfigManager {
|
|||||||
Map<String, Property<?>> nestedProperties = p.getNamespaceValue();
|
Map<String, Property<?>> nestedProperties = p.getNamespaceValue();
|
||||||
loadProperties(nestedConfig, nestedProperties);
|
loadProperties(nestedConfig, nestedProperties);
|
||||||
} else {
|
} else {
|
||||||
// Handle regular properties
|
if (p.value instanceof Integer) {
|
||||||
switch (p.getType()) {
|
|
||||||
case BOOLEAN:
|
|
||||||
((Property<Boolean>) p).value = c.getAsBoolean();
|
|
||||||
break;
|
|
||||||
case INTEGER:
|
|
||||||
((Property<Integer>) p).value = c.getAsInt();
|
((Property<Integer>) p).value = c.getAsInt();
|
||||||
break;
|
} else if (p.value instanceof String) {
|
||||||
case FLOAT:
|
|
||||||
((Property<Float>) p).value = c.getAsFloat();
|
|
||||||
break;
|
|
||||||
case STRING:
|
|
||||||
((Property<String>) p).value = c.getAsString();
|
((Property<String>) p).value = c.getAsString();
|
||||||
break;
|
} else if (p.value instanceof Float) {
|
||||||
case HEX:
|
((Property<Float>) p).value = c.getAsFloat();
|
||||||
((Property<Integer>) p).value = c.getAsInt();
|
} else if (p.value instanceof Boolean) {
|
||||||
break;
|
((Property<Boolean>) p).value = c.getAsBoolean();
|
||||||
default:
|
} else {
|
||||||
break;
|
SaturnClient.LOGGER.warn(
|
||||||
|
"Unknown property type for: " + propertyName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -201,36 +193,29 @@ public class ConfigManager {
|
|||||||
for (String propertyName : propertyMap.keySet()) {
|
for (String propertyName : propertyMap.keySet()) {
|
||||||
Property<?> property = propertyMap.get(propertyName);
|
Property<?> property = propertyMap.get(propertyName);
|
||||||
JsonElement propertyValue = null;
|
JsonElement propertyValue = null;
|
||||||
|
// Convert the property value based on its type
|
||||||
if (property.getType() == Property.PropertyType.NAMESPACE) {
|
switch (property.getType()) {
|
||||||
|
case NAMESPACE:
|
||||||
// Handle nested namespace
|
// Handle nested namespace
|
||||||
JsonObject nestedConfig = new JsonObject();
|
JsonObject nestedConfig = new JsonObject();
|
||||||
Map<String, Property<?>> nestedProperties = (Map<String, Property<?>>) property.value;
|
Map<String, Property<?>> nestedProperties = (Map<String, Property<?>>) property.value;
|
||||||
saveProperties(nestedConfig, nestedProperties);
|
saveProperties(nestedConfig, nestedProperties);
|
||||||
propertyValue = nestedConfig;
|
propertyValue = nestedConfig;
|
||||||
} else {
|
|
||||||
// Convert the property value based on its type
|
|
||||||
switch (property.getType()) {
|
|
||||||
case BOOLEAN:
|
|
||||||
propertyValue = new JsonPrimitive((Boolean) property.value);
|
|
||||||
break;
|
|
||||||
case INTEGER:
|
|
||||||
propertyValue = new JsonPrimitive((Integer) property.value);
|
|
||||||
break;
|
|
||||||
case FLOAT:
|
|
||||||
propertyValue = new JsonPrimitive((Float) property.value);
|
|
||||||
break;
|
|
||||||
case STRING:
|
|
||||||
propertyValue = new JsonPrimitive((String) property.value);
|
|
||||||
break;
|
|
||||||
case HEX:
|
|
||||||
propertyValue = new JsonPrimitive((Integer) property.value);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (property.value instanceof Integer) {
|
||||||
|
propertyValue = new JsonPrimitive((Integer) property.value);
|
||||||
|
} else if (property.value instanceof String) {
|
||||||
|
propertyValue = new JsonPrimitive((String) property.value);
|
||||||
|
} else if (property.value instanceof Float) {
|
||||||
|
propertyValue = new JsonPrimitive((Float) property.value);
|
||||||
|
} else if (property.value instanceof Boolean) {
|
||||||
|
propertyValue = new JsonPrimitive((Boolean) property.value);
|
||||||
|
} else {
|
||||||
SaturnClient.LOGGER.warn(
|
SaturnClient.LOGGER.warn(
|
||||||
"Unknown property type for: " + propertyName);
|
"Unknown property type for: " + propertyName);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propertyValue != null) {
|
if (propertyValue != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user