If startTracking and set
This commit is contained in:
parent
3ab417ec45
commit
285e36e801
@ -11,7 +11,13 @@ public class DataTracker {
|
||||
}
|
||||
|
||||
public void startTracking(TrackedData data) {
|
||||
trackedData.put(data, data.defaultValue());
|
||||
String v = trackedData.get(data);
|
||||
if(v == null) {
|
||||
trackedData.put(data, data.defaultValue());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Data " + data.name() + " has already been initialized");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getOrDefault(TrackedData data) {
|
||||
@ -21,7 +27,7 @@ public class DataTracker {
|
||||
public void set(TrackedData data, String value) {
|
||||
String v = trackedData.get(data);
|
||||
if(v != null) {
|
||||
trackedData.putIfAbsent(data, value);
|
||||
trackedData.put(data, value);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Data " + data.name() + " is not tracked, please initialize it with DataTracker#startTracking(TrackedData, String) first");
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ loader_version=0.14.14
|
||||
fabric_version=0.75.1+1.19.3
|
||||
|
||||
maven_group=fr.altarik.toolbox
|
||||
maven_version=4.2.0-SNAPSHOT
|
||||
maven_version=4.2.1-SNAPSHOT
|
||||
repo_username=Altarik
|
||||
|
Loading…
Reference in New Issue
Block a user