From a6bde9e191d456c408bd57f9e62816c581d7e42a Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Wed, 22 Feb 2023 16:40:08 +0100 Subject: [PATCH] Javadoc --- .../fr/pandacube/lib/chat/ChatConfig.java | 35 +++++++++++++++---- .../fr/pandacube/lib/core/backup/Persist.java | 13 +++++-- .../core/backup/RotatedLogsBackupProcess.java | 15 ++++++-- .../players/standalone/AbstractOffPlayer.java | 32 +++++++++++++++++ .../standalone/AbstractPlayerManager.java | 7 ++-- 5 files changed, 87 insertions(+), 15 deletions(-) diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatConfig.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatConfig.java index 97f32df..c479371 100644 --- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatConfig.java +++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatConfig.java @@ -90,44 +90,65 @@ public class ChatConfig { } - - - - + /** + * A set of predefined colors. + */ public static class PandaTheme { - + /** Green 1 color. */ public static final TextColor CHAT_GREEN_1_NORMAL = TextColor.fromHexString("#3db849"); // h=126 s=50 l=48 + /** Green 2 color. */ public static final TextColor CHAT_GREEN_2 = TextColor.fromHexString("#5ec969"); // h=126 s=50 l=58 + /** Green 3 color. */ public static final TextColor CHAT_GREEN_3 = TextColor.fromHexString("#85d68d"); // h=126 s=50 l=68 + /** Green 4 color. */ public static final TextColor CHAT_GREEN_4 = TextColor.fromHexString("#abe3b0"); // h=126 s=50 l=78 + /** Green max saturation color. */ public static final TextColor CHAT_GREEN_SATMAX = TextColor.fromHexString("#00ff19"); // h=126 s=100 l=50 + /** Green 1 saturated color. */ public static final TextColor CHAT_GREEN_1_SAT = TextColor.fromHexString("#20d532"); // h=126 s=50 l=48 + /** Green 2 saturated color. */ public static final TextColor CHAT_GREEN_2_SAT = TextColor.fromHexString("#45e354"); // h=126 s=50 l=58 + /** Green 3 saturated color. */ public static final TextColor CHAT_GREEN_3_SAT = TextColor.fromHexString("#71ea7d"); // h=126 s=50 l=68 + /** Green 4 saturated color. */ public static final TextColor CHAT_GREEN_4_SAT = TextColor.fromHexString("#9df0a6"); // h=126 s=50 l=78 + /** Brown 1 color. */ public static final TextColor CHAT_BROWN_1 = TextColor.fromHexString("#b26d3a"); // h=26 s=51 l=46 + /** Brown 2 color. */ public static final TextColor CHAT_BROWN_2 = TextColor.fromHexString("#cd9265"); // h=26 s=51 l=60 + /** Brown 3 color. */ public static final TextColor CHAT_BROWN_3 = TextColor.fromHexString("#e0bb9f"); // h=26 s=51 l=75 + /** Brown 1 saturated color. */ public static final TextColor CHAT_BROWN_1_SAT = TextColor.fromHexString("#b35c19"); // h=26 s=75 l=40 + /** Brown 2 saturated color. */ public static final TextColor CHAT_BROWN_2_SAT = TextColor.fromHexString("#e28136"); // h=26 s=51 l=55 + /** Brown 3 saturated color. */ public static final TextColor CHAT_BROWN_3_SAT = TextColor.fromHexString("#ecab79"); // h=26 s=51 l=70 + /** Gray medium color. */ public static final TextColor CHAT_GRAY_MID = TextColor.fromHexString("#888888"); + /** Red failure color. */ public static final TextColor CHAT_RED_FAILURE = TextColor.fromHexString("#ff3333"); + /** Color used for private message prefix decoration. */ public static final TextColor CHAT_PM_PREFIX_DECORATION = CHAT_BROWN_2_SAT; + /** Color used for sent message text. */ public static final TextColor CHAT_PM_SELF_MESSAGE = CHAT_GREEN_2; + /** Color used for received message text. */ public static final TextColor CHAT_PM_OTHER_MESSAGE = CHAT_GREEN_4; - + /** Discord color. */ public static final TextColor CHAT_DISCORD_LINK_COLOR = TextColor.fromHexString("#00aff4"); - + /** + * Generate a prefix for broadcast message. + * @return a prefix for broadcast message. + */ public static Chat CHAT_MESSAGE_PREFIX() { return Chat.text("[") .broadcastColor() diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/Persist.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/Persist.java index b27e5f4..372b702 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/Persist.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/Persist.java @@ -83,11 +83,20 @@ public class Persist { save(); } - + /** + * Tells if the backup process with the provided id is dirty. + * @param id the id of the backup process. + * @return true if the process is marked as dirty, false otherwise. + */ public synchronized boolean isDirty(String id) { return isDirtySince(id) != -1; } - + + /** + * Tells since when the backup process with the provided id is dirty. + * @param id the id of the backup process. + * @return the millis-timestamp of when the backup process has been marked dirty. + */ public synchronized long isDirtySince(String id) { if (!dirtySince.containsKey(id)) setDirtySinceNow(id); diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/RotatedLogsBackupProcess.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/RotatedLogsBackupProcess.java index d596856..7c2f073 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/RotatedLogsBackupProcess.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/RotatedLogsBackupProcess.java @@ -6,17 +6,26 @@ import net.md_5.bungee.api.ChatColor; import java.io.File; import java.io.IOException; -import java.text.DateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.function.BiPredicate; +/** + * A special backup process that handle the backup of rotated log files. + */ public class RotatedLogsBackupProcess extends BackupProcess { final String logFileRegexPattern; final File sourceLogDirectory; final boolean inNewThread; + /** + * Create a new instance of this backup process. + * @param bm the backup manager. + * @param inNewThread tells if this process should be run in a separate thread (true) or in the same thread handling + * the backup manager (false). + * @param sourceLogDir the directory where the rotated log files are stored, usually {@code ./logs/}. + * @param logFileRegexPattern the pattern to match the rotated log files (usually dated log files, excuding the current log file). + */ public RotatedLogsBackupProcess(BackupManager bm, boolean inNewThread, File sourceLogDir, String logFileRegexPattern) { super(bm, "logs"); this.logFileRegexPattern = logFileRegexPattern; @@ -84,7 +93,7 @@ public class RotatedLogsBackupProcess extends BackupProcess { - public List getFilesToMove() { + private List getFilesToMove() { List ret = new ArrayList<>(); for (File f : getSourceDir().listFiles()) { if (f.getName().matches(logFileRegexPattern)) diff --git a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOffPlayer.java b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOffPlayer.java index 864bcd5..f860204 100644 --- a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOffPlayer.java +++ b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOffPlayer.java @@ -74,14 +74,46 @@ public interface AbstractOffPlayer { * Player config */ + /** + * Gets the value of the provided configuration key of this player. + * @param key the configuration key. + * @return the value of the configuration, or null if the configuration is not set. + * @throws Exception if an error occurs fetching the configuration value. + */ String getConfig(String key) throws Exception; + /** + * Gets the value of the provided configuration key of this player. + * @param key the configuration key. + * @param deflt the default value if the configuration is not set. + * @return the value of the configuration, or {@code deflt} if the configuration is not set. + * @throws Exception if an error occurs fetching the configuration value. + */ String getConfig(String key, String deflt) throws Exception; + /** + * Sets the value of the provided configuration key for this player. + * @param key the configuration key to set. + * @param value the new value. + * @throws Exception if an error occurs updating the configuration value. + */ void setConfig(String key, String value) throws Exception; + /** + * Updates the value of the provided configuration key for this player, using the provided updater. + * @param key the configuration key to update. + * @param deflt the default value to use if the configuration is not already set. + * @param updater the unary operator to use to update th value. The old value is used as the parameter of the updater, + * and it returns the new value of the configuration. + * @throws Exception if an error occurs updating the configuration value. + */ void updateConfig(String key, String deflt, UnaryOperator updater) throws Exception; + /** + * Unsets the value of the provided configuration key for this player. + * @param key the configuration key to update. + * @throws Exception if an error occurs deleting the configuration value. + */ void unsetConfig(String key) throws Exception; diff --git a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java index 54d9016..84a8ca1 100644 --- a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java +++ b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java @@ -122,6 +122,7 @@ public abstract class AbstractPlayerManager getOnlyVisibleFor(OF viewer) { @@ -130,10 +131,10 @@ public abstract class AbstractPlayerManager getNamesOnlyVisible(OF viewer) { return getOnlyVisibleFor(viewer).stream()