Improved DataTracker, added registry #19

Merged
quentinlegot merged 5 commits from dev into master 2023-06-21 18:39:49 +02:00
2 changed files with 9 additions and 3 deletions
Showing only changes of commit 285e36e801 - Show all commits

View File

@ -11,7 +11,13 @@ public class DataTracker {
}
public void startTracking(TrackedData data) {
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