diff options
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/impl/ImmutableStateManager.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl3/impl/ImmutableStateManager.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl3/impl/ImmutableStateManager.java b/src/main/java/dev/isxander/yacl3/impl/ImmutableStateManager.java new file mode 100644 index 0000000..f4fd9b2 --- /dev/null +++ b/src/main/java/dev/isxander/yacl3/impl/ImmutableStateManager.java @@ -0,0 +1,56 @@ +package dev.isxander.yacl3.impl; + +import dev.isxander.yacl3.api.StateManager; + +public class ImmutableStateManager<T> implements StateManager<T> { + private final T value; + + public ImmutableStateManager(T value) { + this.value = value; + } + + @Override + public void set(T value) { + throw new UnsupportedOperationException("Cannot set value of immutable state manager"); + } + + @Override + public T get() { + return value; + } + + @Override + public void apply() { + // no-op + } + + @Override + public void resetToDefault(ResetAction action) { + // always default + } + + @Override + public void sync() { + // always synced + } + + @Override + public boolean isSynced() { + return true; + } + + @Override + public boolean isAlwaysSynced() { + return true; + } + + @Override + public boolean isDefault() { + return true; + } + + @Override + public void addListener(StateListener<T> stateListener) { + // as the values never change, listeners are not needed and would never be called + } +} |