From 4b29e966867bfffb6d4a266d16505f73971c0984 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 4 Jun 2023 21:45:21 -0500 Subject: [PATCH] Revert "remove IConfigEntry.setWithoutSaving()" This reverts commit d992bd05f455d2d90f6d77d20b3a3651bd3e063d. --- .../lod/coreapi/interfaces/config/IConfigEntry.java | 3 +++ .../lod/core/config/file/ConfigFileHandling.java | 10 +++++----- .../com/seibel/lod/core/config/types/ConfigEntry.java | 8 +++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/com/seibel/lod/coreapi/interfaces/config/IConfigEntry.java b/api/src/main/java/com/seibel/lod/coreapi/interfaces/config/IConfigEntry.java index e1af75a93..1d70c9041 100644 --- a/api/src/main/java/com/seibel/lod/coreapi/interfaces/config/IConfigEntry.java +++ b/api/src/main/java/com/seibel/lod/coreapi/interfaces/config/IConfigEntry.java @@ -23,6 +23,9 @@ public interface IConfigEntry T get(); T getTrueValue(); + /** Sets the value without saving */ + void setWithoutSaving(T newValue); + /** Gets the min value */ T getMin(); /** Sets the min value */ diff --git a/core/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java b/core/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java index 322836e69..4ad9ed329 100644 --- a/core/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java +++ b/core/src/main/java/com/seibel/lod/core/config/file/ConfigFileHandling.java @@ -124,16 +124,16 @@ public class ConfigFileHandling { if (workConfig.contains(entry.getNameWCategory())) { try { if (entry.getType().isEnum()) { - entry.set((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class) entry.getType()) )); + entry.setWithoutSaving((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class) entry.getType()) )); } else if (ConfigTypeConverters.convertObjects.containsKey(entry.getType())) { - entry.set((T) ConfigTypeConverters.convertFromString(entry.getType(), workConfig.get(entry.getNameWCategory()))); + entry.setWithoutSaving((T) ConfigTypeConverters.convertFromString(entry.getType(), workConfig.get(entry.getNameWCategory()))); } else { if (entry.getType() == workConfig.get(entry.getNameWCategory()).getClass()) { // If the types are the same - entry.set((T) workConfig.get(entry.getNameWCategory())); + entry.setWithoutSaving((T) workConfig.get(entry.getNameWCategory())); if (entry.isValid() == 0) return; - else if (entry.isValid() == -1) entry.set(entry.getMin()); - else if (entry.isValid() == 1) entry.set(entry.getMax()); + else if (entry.isValid() == -1) entry.setWithoutSaving(entry.getMin()); + else if (entry.isValid() == 1) entry.setWithoutSaving(entry.getMax()); } else { LOGGER.warn("Entry ["+ entry.getNameWCategory() +"] is invalid. Expected " + entry.getType() + " but got " + workConfig.get(entry.getNameWCategory()).getClass() + ". Using default value."); saveEntry(entry, workConfig); diff --git a/core/src/main/java/com/seibel/lod/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/lod/core/config/types/ConfigEntry.java index b43fa1950..d2657a4e9 100644 --- a/core/src/main/java/com/seibel/lod/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/lod/core/config/types/ConfigEntry.java @@ -89,7 +89,13 @@ public class ConfigEntry extends AbstractConfigType> implem public T getTrueValue() { return super.get(); } - + + /** Sets the value without saving */ + @Override + public void setWithoutSaving(T newValue) { + super.set(newValue); + } + /** Gets the min value */ @Override public T getMin() {