Some docs
This commit is contained in:
parent
2f0b59a032
commit
ecd8b3b0c9
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<MinecraftVersionList>, JsonDeserializer<MinecraftVersionList> {
|
||||
/**
|
||||
* Gson adapter factory for {@link MinecraftVersionList}.
|
||||
*/
|
||||
public static final TypeAdapterFactory FACTORY = TreeTypeAdapter.newTypeHierarchyFactory(MinecraftVersionList.class, new MinecraftVersionListAdapter());
|
||||
|
||||
private static final TypeToken<Map<String, Integer>> MAP_STR_INT_TYPE = new TypeToken<>() { };
|
||||
|
@ -216,10 +216,18 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
|
||||
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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user