Fixed issue when setting a config value in the file to a different type breaks game.
This commit is contained in:
@@ -121,14 +121,20 @@ public class ConfigFileHandling {
|
||||
} else if (ConfigTypeConverters.convertObjects.containsKey(entry.getType())) {
|
||||
entry.setWithoutSaving((T) ConfigTypeConverters.convertFromString(entry.getType(), workConfig.get(entry.getNameWCategory())));
|
||||
} else {
|
||||
entry.setWithoutSaving((T) workConfig.get(entry.getNameWCategory()));
|
||||
if (entry.isValid() == 0) return;
|
||||
else if (entry.isValid() == -1) entry.setWithoutSaving(entry.getMin());
|
||||
else if (entry.isValid() == 1) entry.setWithoutSaving(entry.getMax());
|
||||
if (entry.getType() == workConfig.get(entry.getNameWCategory()).getClass()) { // If the types are the same
|
||||
entry.setWithoutSaving((T) workConfig.get(entry.getNameWCategory()));
|
||||
|
||||
if (entry.isValid() == 0) return;
|
||||
else if (entry.isValid() == -1) entry.setWithoutSaving(entry.getMin());
|
||||
else if (entry.isValid() == 1) entry.setWithoutSaving(entry.getMax());
|
||||
} else {
|
||||
ClientApi.LOGGER.warn("Entry ["+ entry.getNameWCategory() +"] is invalid. Expected " + entry.getType() + " but got " + workConfig.get(entry.getNameWCategory()).getClass() + ". Using default value.");
|
||||
saveEntry(entry, workConfig);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ClientApi.LOGGER.warn("Entry ["+entry.getNameWCategory()+"] had an invalid value when loading the config");
|
||||
// e.printStackTrace();
|
||||
ClientApi.LOGGER.warn("Entry ["+entry.getNameWCategory()+"] had an invalid value when loading the config. Using default value.");
|
||||
saveEntry(entry, workConfig);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user