Improved DataTracker, added registry #19
@ -11,7 +11,13 @@ public class DataTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startTracking(TrackedData data) {
|
public void startTracking(TrackedData data) {
|
||||||
|
String v = trackedData.get(data);
|
||||||
|
if(v == null) {
|
||||||
trackedData.put(data, data.defaultValue());
|
trackedData.put(data, data.defaultValue());
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Data " + data.name() + " has already been initialized");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrDefault(TrackedData data) {
|
public String getOrDefault(TrackedData data) {
|
||||||
@ -21,7 +27,7 @@ public class DataTracker {
|
|||||||
public void set(TrackedData data, String value) {
|
public void set(TrackedData data, String value) {
|
||||||
String v = trackedData.get(data);
|
String v = trackedData.get(data);
|
||||||
if(v != null) {
|
if(v != null) {
|
||||||
trackedData.putIfAbsent(data, value);
|
trackedData.put(data, value);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Data " + data.name() + " is not tracked, please initialize it with DataTracker#startTracking(TrackedData, String) first");
|
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
|
fabric_version=0.75.1+1.19.3
|
||||||
|
|
||||||
maven_group=fr.altarik.toolbox
|
maven_group=fr.altarik.toolbox
|
||||||
maven_version=4.2.0-SNAPSHOT
|
maven_version=4.2.1-SNAPSHOT
|
||||||
repo_username=Altarik
|
repo_username=Altarik
|
||||||
|
Loading…
Reference in New Issue
Block a user