From 2c154613a0ca0ff017ce833189eb6ae7d528ce51 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 7 Dec 2023 07:13:37 -0600 Subject: [PATCH] Add Config API methods getApiValue() and clearValue() --- .../interfaces/config/IDhApiConfigValue.java | 27 +++++++++++++------ .../api/objects/config/DhApiConfigValue.java | 2 ++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/IDhApiConfigValue.java b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/IDhApiConfigValue.java index 90b9d13aa..e7947349d 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/IDhApiConfigValue.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/config/IDhApiConfigValue.java @@ -26,7 +26,7 @@ import java.util.function.Consumer; * * @param The data type of this config. * @author James Seibel - * @version 2022-9-15 + * @version 2023-12-7 * @since API 1.0.0 */ public interface IDhApiConfigValue @@ -43,25 +43,36 @@ public interface IDhApiConfigValue * This is the value stored in the config file. */ T getTrueValue(); - /* + /** * Returns the value of the config if it was set by the API. - * Returns null if the config wasn't set by the API. + * Returns null if the config hasn't been set by the API. + * + * @since API 1.1.0 */ - //T getApiValue(); // not currently implemented + T getApiValue(); /** * Sets the config's value.
* If the newValue is set to null then the config - * will revert to using the True Value.
+ * will revert to using the True Value + * (IE the value visible in the config menu).
* If the config cannot be set via the API this method will return false.

* - * To unset the config's value pass in Null.
- * * @return true if the value was set, false otherwise. */ boolean setValue(T newValue); - /** Returns true if this config can be set via the API, false otherwise. */ + /** + * Un-sets the config's API value.
+ * After this method is called this config will + * use the value set in the config menu. + * + * @return true if the value was set, false otherwise. + * @since API 1.1.0 + */ + boolean clearValue(); + + /** @return true if this config can be set via the API, false otherwise. */ boolean getCanBeOverrodeByApi(); /** Returns the default value for this config. */ diff --git a/api/src/main/java/com/seibel/distanthorizons/api/objects/config/DhApiConfigValue.java b/api/src/main/java/com/seibel/distanthorizons/api/objects/config/DhApiConfigValue.java index eba9463f4..b82852b49 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/objects/config/DhApiConfigValue.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/objects/config/DhApiConfigValue.java @@ -87,6 +87,8 @@ public class DhApiConfigValue implements IDhApiConfigValue