From b8c99862d57752ca130fd0b906ebd8260b32e86e Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 15 Jun 2023 19:54:20 +0200 Subject: [PATCH 1/5] Dump to 4.1.1-SNAPSHOT --- Core/src/main/resources/fabric.mod.json | 4 ++-- Database/src/main/resources/fabric.mod.json | 7 ++++--- Pagination/src/main/resources/fabric.mod.json | 2 +- Tasks/src/main/resources/fabric.mod.json | 2 +- gradle.properties | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Core/src/main/resources/fabric.mod.json b/Core/src/main/resources/fabric.mod.json index 65236f7..2701d84 100644 --- a/Core/src/main/resources/fabric.mod.json +++ b/Core/src/main/resources/fabric.mod.json @@ -2,8 +2,8 @@ "schemaVersion": 1, "id": "toolbox-core", "version": "${version}", - "name": "Core", - "description": "", + "name": "Altarik Toolbox Core", + "description": "Dependency of some of altarik toolbox mods", "authors": [ "Altarik" ], diff --git a/Database/src/main/resources/fabric.mod.json b/Database/src/main/resources/fabric.mod.json index 6f9451d..586895e 100644 --- a/Database/src/main/resources/fabric.mod.json +++ b/Database/src/main/resources/fabric.mod.json @@ -2,8 +2,8 @@ "schemaVersion": 1, "id": "toolbox-database", "version": "${version}", - "name": "Database", - "description": "", + "name": "Altarik Toolbox Database", + "description": "A set of sql tools", "authors": [ "Altarik" ], @@ -24,6 +24,7 @@ "fabricloader": "^0.14.12", "fabric-api": "*", "minecraft": "1.19.3", - "java": ">=17" + "java": ">=17", + "toolbox-core": "${version}" } } diff --git a/Pagination/src/main/resources/fabric.mod.json b/Pagination/src/main/resources/fabric.mod.json index 68cc742..99cc965 100644 --- a/Pagination/src/main/resources/fabric.mod.json +++ b/Pagination/src/main/resources/fabric.mod.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "toolbox-pagination", "version": "${version}", - "name": "Pagination", + "name": "Altarik Toolbox Pagination", "description": "A mod to use to paginate long result to player in chat", "authors": [ "Altarik" diff --git a/Tasks/src/main/resources/fabric.mod.json b/Tasks/src/main/resources/fabric.mod.json index 217672b..853c737 100644 --- a/Tasks/src/main/resources/fabric.mod.json +++ b/Tasks/src/main/resources/fabric.mod.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "toolbox-task", "version": "${version}", - "name": "Task", + "name": "Altarik Toolbox Task", "description": "A mod to use as a dependency for others to schedule tasks", "authors": [ "Altarik" diff --git a/gradle.properties b/gradle.properties index edaf432..fcb90ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -org.gradle.jvmargs=-Xmx2G +org.gradle.jvmargs=-Xmx3G junit_version=5.9.0 @@ -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.1.0-SNAPSHOT +maven_version=4.1.1-SNAPSHOT repo_username=Altarik From 9049926a8387b61e0c5101639e65d6701e433c44 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 15 Jun 2023 21:28:53 +0200 Subject: [PATCH 2/5] Added getTrackedDataIterator --- .../java/fr/altarik/toolbox/core/data/DataTracker.java | 9 +++------ gradle.properties | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java b/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java index aa9bcb9..b5e0099 100644 --- a/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java +++ b/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java @@ -1,8 +1,6 @@ package fr.altarik.toolbox.core.data; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; public class DataTracker { @@ -30,8 +28,7 @@ public class DataTracker { } - public void saveToDb() { - + public Iterator getTrackedDataIterator() { + return trackedData.keySet().iterator(); } - } diff --git a/gradle.properties b/gradle.properties index fcb90ff..c093845 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.1.1-SNAPSHOT +maven_version=4.2.0-SNAPSHOT repo_username=Altarik From 3ab417ec459ed81c3bcaa7bd9e5b11459ea0ab63 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 15 Jun 2023 21:36:50 +0200 Subject: [PATCH 3/5] Added getTrackedDataValueIterator --- .../main/java/fr/altarik/toolbox/core/data/DataTracker.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java b/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java index b5e0099..a655928 100644 --- a/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java +++ b/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java @@ -31,4 +31,8 @@ public class DataTracker { public Iterator getTrackedDataIterator() { return trackedData.keySet().iterator(); } + + public Iterator getTrackedDataValueIterator() { + return trackedData.values().iterator(); + } } From 285e36e801e48bd3b8eee71734d42f1dc8faf260 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Thu, 15 Jun 2023 22:08:39 +0200 Subject: [PATCH 4/5] If startTracking and set --- .../java/fr/altarik/toolbox/core/data/DataTracker.java | 10 ++++++++-- gradle.properties | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java b/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java index a655928..2e625c5 100644 --- a/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java +++ b/Core/src/main/java/fr/altarik/toolbox/core/data/DataTracker.java @@ -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"); } diff --git a/gradle.properties b/gradle.properties index c093845..f7f7fb2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 From c74ae48156da0b19e4c9bfd6f1147b867eafd036 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Wed, 21 Jun 2023 18:15:12 +0200 Subject: [PATCH 5/5] Add Registry --- .../fr/altarik/toolbox/core/Registry.java | 51 +++++++++++++++++++ gradle.properties | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Core/src/main/java/fr/altarik/toolbox/core/Registry.java diff --git a/Core/src/main/java/fr/altarik/toolbox/core/Registry.java b/Core/src/main/java/fr/altarik/toolbox/core/Registry.java new file mode 100644 index 0000000..85d37ac --- /dev/null +++ b/Core/src/main/java/fr/altarik/toolbox/core/Registry.java @@ -0,0 +1,51 @@ +package fr.altarik.toolbox.core; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Objects; + +public abstract class Registry { + + protected final HashMap registry = new HashMap<>(); + + /** + * Return a set view of the keys contained in the registry. + * @return An iterator view of the keys contained in the registry + */ + public Iterator keySet() { + return registry.keySet().iterator(); + } + + /** + * Returns true if this registry contains the key. + * @param key the key whose presence in the registry is to be tested + * @return Returns true if this registry contains the key, false otherwise + */ + public boolean containsKey(T key) { + return registry.containsKey(key); + } + + /** + * Returns the containing value represented by a specific key, or {@code null} if the registry do not contain the key + * @param key the key whose associated value is to be returned + * @return The value to which the specified key is represented, or {@code null} if the registry do not contain the key + */ + public @Nullable U getValue(T key) { + return registry.get(key); + } + + /** + * If the specified key is not already associated with a value, associate it with the given value. + * @param key Key to which the specified value is to be associated + * @param value value to be associated with the specified key + * @throws NullPointerException if key or value is null + */ + public void register(@NotNull T key, @NotNull U value) { + registry.putIfAbsent(Objects.requireNonNull(key), Objects.requireNonNull(value)); + } + +} + diff --git a/gradle.properties b/gradle.properties index f7f7fb2..9dcf69e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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.1-SNAPSHOT +maven_version=4.3.0-SNAPSHOT repo_username=Altarik