If startTracking and set
Some checks failed
/ build (17, ubuntu-latest) (push) Failing after 12m7s
/ deploy (17, ubuntu-latest) (push) Has been skipped

This commit is contained in:
Quentin Legot 2023-06-15 22:08:39 +02:00
parent 3ab417ec45
commit 285e36e801
2 changed files with 9 additions and 3 deletions

View File

@ -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");
}

View File

@ -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