config invocation handler: don't set config values if already set
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user