diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/Chat.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/Chat.java index 24e7a92..0d7cb4e 100644 --- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/Chat.java +++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/Chat.java @@ -120,15 +120,27 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource return getAdv(); } - public Component getAsDownsampledColorsComponent() { + /** + * Builds the component into Adventure Component instance, also down sampling the RGB colors to named colors. + * @return the {@link Component} built from this {@link Chat} component, with down-sampled colors. + */ + public Component getAsDownSampledColorsComponent() { String json = GsonComponentSerializer.colorDownsamplingGson().serialize(getAdv()); return GsonComponentSerializer.gson().deserialize(json); } - public Chat getAsDownsampledColors() { - return chatComponent(getAsDownsampledColorsComponent()); + /** + * Returns a new {@link Chat} consisting of this {@link Chat} instance, with the RGB colors down-sampled to named colors. + * @return a new {@link Chat} instance, with down-sampled colors. + */ + public Chat getAsDownSampledColors() { + return chatComponent(getAsDownSampledColorsComponent()); } + /** + * Returns a MiniMessage representation of this {@link Chat} component. + * @return the MiniMessage representation if this {@link Chat} component. + */ public String getMiniMessage() { return MiniMessage.miniMessage().serialize(getAdv()); } diff --git a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java index 91e34d5..dec6ab1 100644 --- a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java +++ b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLIApplication.java @@ -93,7 +93,7 @@ public abstract class CLIApplication { } finally { Log.info("Bye bye."); - CLILogger.ShutdownHookDelayerLogManager.resetFinally(); + CLILogger.actuallyResetLogManager(); if (!Thread.currentThread().equals(shutdownThread)) System.exit(0); } diff --git a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/log/CLILogger.java b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/log/CLILogger.java index 7b872c1..4c02c24 100644 --- a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/log/CLILogger.java +++ b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/log/CLILogger.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.cli.log; import fr.pandacube.lib.cli.CLI; +import fr.pandacube.lib.cli.CLIApplication; import fr.pandacube.lib.util.log.Log; import fr.pandacube.lib.util.ThrowableUtil; import fr.pandacube.lib.util.log.DailyLogRotateFileHandler; @@ -28,12 +29,21 @@ public class CLILogger { private static Logger logger = null; - public static class ShutdownHookDelayerLogManager extends LogManager { + private static class ShutdownHookDelayerLogManager extends LogManager { static ShutdownHookDelayerLogManager instance; public ShutdownHookDelayerLogManager() { instance = this; } @Override public void reset() { /* don't reset yet. */ } - private void reset0() { super.reset(); } - public static void resetFinally() { instance.reset0(); } + private void actuallyReset() { super.reset(); } + } + + /** + * Tells the LogManager to actually reset. + * + * This method is called by the shutdown hook of {@link CLIApplication}, because the {@link CLILogger} uses a custom + * {@link LogManager} that bypass the reset process during the shutdown of the process. + */ + public static void actuallyResetLogManager() { + ShutdownHookDelayerLogManager.instance.actuallyReset(); } diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionList.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionList.java index a79ee60..623dd5d 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionList.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionList.java @@ -51,6 +51,9 @@ public record MinecraftVersionList( * Gson Adapter that ensure the data in {@link MinecraftVersionList} is sorted correctly when deserializing. */ public static class MinecraftVersionListAdapter implements JsonSerializer, JsonDeserializer { + /** + * Gson adapter factory for {@link MinecraftVersionList}. + */ public static final TypeAdapterFactory FACTORY = TreeTypeAdapter.newTypeHierarchyFactory(MinecraftVersionList.class, new MinecraftVersionListAdapter()); private static final TypeToken> MAP_STR_INT_TYPE = new TypeToken<>() { }; diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java index 184c608..ee94058 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java @@ -216,10 +216,18 @@ public class ProtocolVersion implements Comparable { return displayOptimizedListOfVersions(List.of(this), finalWordSeparator); } + /** + * Gets the first (earliest) Minecraft version that supports this protocol version. + * @return the first (earliest) Minecraft version that supports this protocol version. + */ public String getFirstVersion() { return versions.get(0); } + /** + * Gets the last (latest) Minecraft version that supports this protocol version. + * @return the last (latest) Minecraft version that supports this protocol version. + */ public String getLastVersion() { return versions.get(versions.size() - 1); } diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java index 2546ece..daec951 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java @@ -5,8 +5,14 @@ package fr.pandacube.lib.util; */ public class Tick { + /** + * The number of Minecraft server ticks in a second. + */ public static final int TPS = 20; + /** + * The duration of a Minecraft server tick in millisecond. + */ public static final int MS_PER_TICK = 1000 / TPS;