config invocation handler: don't set config values if already set

This commit is contained in:
Adam
2018-07-14 16:39:02 -04:00
parent d5fc26f833
commit 3499efd6c1

View File

@@ -24,11 +24,11 @@
*/
package net.runelite.client.config;
import com.google.common.base.Objects;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@@ -104,11 +104,20 @@ class ConfigInvocationHandler implements InvocationHandler
Object newValue = args[0];
Class<?> type = method.getParameterTypes()[0];
Object oldValue = manager.getConfiguration(group.value(), item.keyName(), type);
if (Objects.equals(oldValue, newValue))
{
// nothing to do
return null;
}
if (method.isDefault())
{
Object defaultValue = callDefaultMethod(proxy, method, args);
if (Objects.equal(newValue, defaultValue))
if (Objects.equals(newValue, defaultValue))
{
// Just unset if it goes back to the default
manager.unsetConfiguration(group.value(), item.keyName());