From c9af5ad308127fa77ce5eeb0699726f72054901d Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 27 Dec 2024 23:15:37 +0100 Subject: [PATCH] New module pandalib-config --- Readme.md | 3 +- pandalib-cli/pom.xml | 46 ++++++++----------- pandalib-config/pom.xml | 33 +++++++++++++ .../pandacube/lib}/config/AbstractConfig.java | 26 +---------- .../lib}/config/AbstractConfigManager.java | 2 +- pom.xml | 1 + 6 files changed, 59 insertions(+), 52 deletions(-) create mode 100644 pandalib-config/pom.xml rename {pandalib-core/src/main/java/fr/pandacube/lib/core => pandalib-config/src/main/java/fr/pandacube/lib}/config/AbstractConfig.java (82%) rename {pandalib-core/src/main/java/fr/pandacube/lib/core => pandalib-config/src/main/java/fr/pandacube/lib}/config/AbstractConfigManager.java (97%) diff --git a/Readme.md b/Readme.md index aa7f57f..858bc6a 100644 --- a/Readme.md +++ b/Readme.md @@ -18,8 +18,9 @@ that are detailed in their respective Readme file (if any). - `pandalib-players` A library to handle classes representing online or offline players; - `pandalib-players-permissible` An extension of `pandalib-players` with support for the permission system `pandalib-permissions`; - `pandalib-netapi` A poorly designed, but working TCP network library; +- `pandalib-config` Utility and helper classes to handle configuration related files and folders; - `pandalib-commands` An abstract command manager working on top of [Brigadier](https://github.com/Mojang/brigadier); -- `pandalib-cli` Utility and helper classes for a standalone CLI Java application. +- `pandalib-cli` Utility and helper classes for a standalone CLI Java application; - `pandalib-core` A catch-all module for some helper classes that didn't have their own module yet; ### Use in your projects diff --git a/pandalib-cli/pom.xml b/pandalib-cli/pom.xml index 0d974e9..d512303 100644 --- a/pandalib-cli/pom.xml +++ b/pandalib-cli/pom.xml @@ -15,42 +15,36 @@ jar - - minecraft-libraries - Minecraft Libraries - https://libraries.minecraft.net - bungeecord-repo https://oss.sonatype.org/content/repositories/snapshots - - - fr.pandacube.lib - pandalib-core - ${project.version} - - - fr.pandacube.lib - pandalib-reflect - ${project.version} - - - fr.pandacube.lib - pandalib-commands - ${project.version} - - + - net.md-5 - bungeecord-log - ${bungeecord.version} + fr.pandacube.lib + pandalib-core + ${project.version} + + + fr.pandacube.lib + pandalib-reflect + ${project.version} + + + fr.pandacube.lib + pandalib-commands + ${project.version} + + + fr.pandacube.lib + pandalib-config + ${project.version} net.md-5 - bungeecord-config + bungeecord-log ${bungeecord.version} diff --git a/pandalib-config/pom.xml b/pandalib-config/pom.xml new file mode 100644 index 0000000..60e9f53 --- /dev/null +++ b/pandalib-config/pom.xml @@ -0,0 +1,33 @@ + + + + pandalib-parent + fr.pandacube.lib + 1.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + pandalib-config + jar + + + + bungeecord-repo + https://oss.sonatype.org/content/repositories/snapshots + + + + + + + net.md-5 + bungeecord-config + ${bungeecord.version} + + + + + \ No newline at end of file diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java b/pandalib-config/src/main/java/fr/pandacube/lib/config/AbstractConfig.java similarity index 82% rename from pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java rename to pandalib-config/src/main/java/fr/pandacube/lib/config/AbstractConfig.java index 888869c..acef790 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java +++ b/pandalib-config/src/main/java/fr/pandacube/lib/config/AbstractConfig.java @@ -1,7 +1,4 @@ -package fr.pandacube.lib.core.config; - -import fr.pandacube.lib.chat.ChatColorUtil; -import fr.pandacube.lib.util.log.Log; +package fr.pandacube.lib.config; import java.io.BufferedReader; import java.io.File; @@ -56,7 +53,7 @@ public abstract class AbstractConfig { while ((line = reader.readLine()) != null) { String trimmedLine = line.trim(); - if (ignoreEmpty && trimmedLine.equals("")) + if (ignoreEmpty && trimmedLine.isEmpty()) continue; if (ignoreHashtagComment && trimmedLine.startsWith("#")) @@ -114,25 +111,6 @@ public abstract class AbstractConfig { } - /** - * Utility method to that translate the {@code '&'} formatted string to the legacy format. - * @param string the string to convert. - * @return a legacy formatted string (using {@code 'ยง'}). - */ - public static String getTranslatedColorCode(String string) { - return ChatColorUtil.translateAlternateColorCodes('&', string); - } - - - /** - * Logs the message as a warning into console, prefixed with the context of this config. - * @param message the message to log. - */ - protected void warning(String message) { - Log.warning("Error in configuration '"+configFile.getName()+"': " + message); - } - - /** * The type of config. */ diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java b/pandalib-config/src/main/java/fr/pandacube/lib/config/AbstractConfigManager.java similarity index 97% rename from pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java rename to pandalib-config/src/main/java/fr/pandacube/lib/config/AbstractConfigManager.java index bbd48bf..5b66b22 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java +++ b/pandalib-config/src/main/java/fr/pandacube/lib/config/AbstractConfigManager.java @@ -1,4 +1,4 @@ -package fr.pandacube.lib.core.config; +package fr.pandacube.lib.config; import java.io.File; import java.io.IOException; diff --git a/pom.xml b/pom.xml index 0296f88..541ec22 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,7 @@ pandalib-chat pandalib-cli pandalib-commands + pandalib-config pandalib-core pandalib-db pandalib-netapi