blob: f4fd9b23e1a46f59dc7f64d14466ba6e3c9da9ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
}
}
|