Fix IDhApiConfigValue.clearValue() failing for some deprecated functions

This commit is contained in:
James Seibel
2025-02-17 21:16:22 -06:00
parent c296795280
commit 45c67d057a
2 changed files with 19 additions and 3 deletions
@@ -87,7 +87,20 @@ public class DhApiConfigValue<coreType, apiType> implements IDhApiConfigValue<ap
}
}
public boolean clearValue() { return this.setValue(null); }
public boolean clearValue()
{
if (this.configEntry.getAllowApiOverride())
{
// no converter should be used here since null objects may need to be handled differently
// TODO the API should just have a bool to keep track of whether the API value is in use instead of using NULL
this.configEntry.setApiValue(null);
return true;
}
else
{
return false;
}
}
public boolean getCanBeOverrodeByApi() { return this.configEntry.getAllowApiOverride(); }
@@ -26,6 +26,7 @@ import com.seibel.distanthorizons.core.config.listeners.IConfigListener;
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance;
import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryPerformance;
import com.seibel.distanthorizons.coreapi.interfaces.config.IConfigEntry;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -54,6 +55,8 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
* and any get() method calls will return the apiValue if it is set.
*/
public final boolean allowApiOverride;
/** Will be null if un-set */
@Nullable
private T apiValue;
@@ -132,9 +135,9 @@ public class ConfigEntry<T> extends AbstractConfigType<T, ConfigEntry<T>> implem
@Override
public T get()
{
if (allowApiOverride && apiValue != null)
if (this.allowApiOverride && this.apiValue != null)
{
return apiValue;
return this.apiValue;
}
return super.get();