From 5edd8cdfec514dd88842a0400911eb893ce785db Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Tue, 20 Jun 2023 00:15:46 +0200 Subject: [PATCH] Various code simplification/fixes and a lot of typo/grammar fixes (may brake some stuff) --- Readme.md | 4 +- .../lib/bungee/backup/BungeeBackupConfig.java | 3 +- .../bungee/backup/BungeeWorkdirProcess.java | 15 +-- .../commands/BungeeBrigadierCommand.java | 4 +- .../commands/BungeeBrigadierDispatcher.java | 4 +- .../bungee/players/BungeeOnlinePlayer.java | 11 -- .../util/BungeeDailyLogRotateFileHandler.java | 9 +- .../main/java/fr/pandacube/lib/chat/Chat.java | 75 ++++++----- .../pandacube/lib/chat/ChatColorGradient.java | 2 +- .../fr/pandacube/lib/chat/ChatColorUtil.java | 8 +- .../fr/pandacube/lib/chat/ChatConfig.java | 9 +- .../fr/pandacube/lib/chat/ChatFilledLine.java | 2 +- .../fr/pandacube/lib/chat/ChatStatic.java | 40 +++--- .../fr/pandacube/lib/chat/ChatTreeNode.java | 4 +- .../java/fr/pandacube/lib/chat/ChatUtil.java | 24 ++-- .../main/java/fr/pandacube/lib/cli/CLI.java | 4 +- .../fr/pandacube/lib/cli/CLIApplication.java | 1 + .../lib/cli/commands/CLIBrigadierCommand.java | 2 +- .../cli/commands/CLIBrigadierDispatcher.java | 2 +- .../lib/cli/commands/CLICommandSender.java | 3 +- .../cli/commands/CLIConsoleCommandSender.java | 3 +- .../lib/cli/commands/CommandAdmin.java | 10 +- .../fr/pandacube/lib/cli/log/CLILogger.java | 2 +- .../lib/commands/BrigadierCommand.java | 8 +- .../lib/commands/BrigadierDispatcher.java | 4 +- .../commands/BrigadierSuggestionsUtil.java | 2 +- .../lib/commands/SuggestionsSupplier.java | 6 +- .../lib/core/backup/BackupCleaner.java | 10 +- .../lib/core/backup/BackupManager.java | 2 +- .../lib/core/backup/BackupProcess.java | 16 +-- .../fr/pandacube/lib/core/backup/Persist.java | 2 +- .../core/backup/RotatedLogsBackupProcess.java | 3 +- .../lib/core/backup/ZipCompressor.java | 4 +- .../lib/core/config/AbstractConfig.java | 18 +-- .../core/config/AbstractConfigManager.java | 4 +- .../lib/core/cron/CronScheduler.java | 2 +- .../java/fr/pandacube/lib/core/json/Json.java | 10 +- .../lib/core/json/ThrowableAdapter.java | 14 +- .../lib/core/json/TypeConverter.java | 60 ++++----- .../core/mc_version/MinecraftVersionList.java | 2 - .../core/mc_version/MinecraftVersionUtil.java | 26 ++-- .../lib/core/mc_version/ProtocolVersion.java | 25 ++-- .../lib/core/search/SearchEngine.java | 2 +- .../src/main/java/fr/pandacube/lib/db/DB.java | 32 ++--- .../java/fr/pandacube/lib/db/DBException.java | 2 +- .../lib/db/DBInitTableException.java | 2 +- .../java/fr/pandacube/lib/db/SQLElement.java | 32 ++--- .../fr/pandacube/lib/db/SQLElementList.java | 20 +-- .../java/fr/pandacube/lib/db/SQLFKField.java | 4 +- .../java/fr/pandacube/lib/db/SQLField.java | 8 +- .../lib/netapi/client/ResponseAnalyser.java | 2 +- .../server/AbstractRequestExecutor.java | 9 +- .../lib/netapi/server/NetworkAPIListener.java | 5 +- .../lib/netapi/server/PacketExecutor.java | 4 +- .../lib/netapi/server/RequestAnalyser.java | 12 +- pandalib-paper-permissions/pom.xml | 6 +- .../permissions/PandalibPaperPermissions.java | 2 +- .../PermissionsInjectorBukkit.java | 127 ++++++++---------- .../lib/paper/backup/PaperBackupConfig.java | 3 +- .../lib/paper/backup/PaperWorkdirProcess.java | 23 ++-- .../lib/paper/backup/PaperWorldProcess.java | 1 - .../paper/commands/PaperBrigadierCommand.java | 34 ++--- .../fr/pandacube/lib/paper/gui/GUIHotBar.java | 36 ++--- .../pandacube/lib/paper/gui/GUIInventory.java | 12 +- .../lib/paper/json/ItemStackAdapter.java | 3 +- .../modules/PerformanceAnalysisManager.java | 11 +- .../lib/paper/players/PaperOffPlayer.java | 34 ++--- .../lib/paper/players/PaperOnlinePlayer.java | 4 +- .../players/PaperPlayerConfigStorage.java | 12 +- .../players/PlayerNonPersistentConfig.java | 2 +- .../lib/paper/reflect/NMSReflect.java | 12 +- .../lib/paper/reflect/OBCReflect.java | 2 +- .../paper/reflect/PandalibPaperReflect.java | 8 +- .../util/BedrockBambooCollisionFixer.java | 2 +- .../wrapper/craftbukkit/CraftItemStack.java | 4 - .../craftbukkit/VanillaCommandWrapper.java | 4 +- .../dataconverter/MCDataConverter.java | 1 - .../wrapper/minecraft/nbt/CompoundTag.java | 4 +- .../wrapper/minecraft/nbt/ListTag.java | 3 +- .../minecraft/network/FriendlyByteBuf.java | 2 +- .../ClientboundCustomPayloadPacket.java | 2 +- .../protocol/ClientboundGameEventPacket.java | 2 +- .../minecraft/server/DedicatedPlayerList.java | 1 - .../reflect/wrapper/minecraft/world/AABB.java | 2 +- .../wrapper/minecraft/world/ChunkPos.java | 2 +- .../wrapper/minecraft/world/DamageSource.java | 2 - .../minecraft/world/DamageSources.java | 2 - .../minecraft/world/PlayerDataStorage.java | 2 - .../reflect/wrapper/paper/AABBVoxelShape.java | 2 +- .../lib/paper/scheduler/PandalibRunnable.java | 14 +- .../lib/paper/scheduler/SchedulerUtil.java | 2 +- .../pandacube/lib/paper/util/AABBBlock.java | 14 +- .../lib/paper/util/AutoUpdatedBossBar.java | 16 +-- .../lib/paper/util/BukkitChatColorUtil.java | 6 +- .../pandacube/lib/paper/util/BukkitEvent.java | 2 +- .../lib/paper/util/EntityStackUtil.java | 19 ++- .../lib/paper/util/GameWorldUtils.java | 3 + .../lib/paper/util/GeometryUtil.java | 63 ++++----- .../lib/paper/util/ItemStackBuilder.java | 10 +- .../lib/paper/util/LocationUtil.java | 16 +-- .../lib/paper/util/PlayerDataWrapper.java | 59 ++++---- .../lib/paper/util/ScoreboardUtil.java | 15 ++- .../fr/pandacube/lib/paper/util/Skull.java | 36 ++--- .../pandacube/lib/paper/util/WorldUtil.java | 10 +- .../pandacube/lib/permissions/PermEntity.java | 66 ++++----- .../pandacube/lib/permissions/PermGroup.java | 8 +- .../pandacube/lib/permissions/PermPlayer.java | 12 +- .../PermissionExpressionParser.java | 6 +- .../lib/permissions/Permissions.java | 4 +- .../PermissionsCachedBackendReader.java | 4 +- .../lib/permissions/PermissionsResolver.java | 32 ++--- .../lib/permissions/SQLPermissions.java | 2 +- .../PermissionExpressionParserTest.java | 10 +- .../permissible/PermissibleOffPlayer.java | 10 +- pandalib-players/pom.xml | 4 +- .../players/standalone/AbstractOffPlayer.java | 2 +- .../standalone/AbstractOnlinePlayer.java | 12 +- .../standalone/AbstractPlayerManager.java | 16 +-- .../fr/pandacube/lib/reflect/Reflect.java | 2 +- .../pandacube/lib/reflect/ReflectClass.java | 13 +- .../lib/reflect/ReflectConstructor.java | 2 +- .../pandacube/lib/reflect/ReflectField.java | 4 +- .../reflect/wrapper/ReflectListWrapper.java | 31 ++--- .../lib/reflect/wrapper/ReflectWrapper.java | 44 +++--- .../reflect/wrapper/ReflectWrapperTyped.java | 2 +- .../lib/reflect/wrapper/package-info.java | 2 +- .../java/fr/pandacube/lib/util/BiMap.java | 38 +++--- .../fr/pandacube/lib/util/DistanceUtil.java | 22 +-- .../java/fr/pandacube/lib/util/EnumUtil.java | 2 +- .../java/fr/pandacube/lib/util/FileUtils.java | 8 +- .../lib/util/LevenshteinDistance.java | 4 +- .../java/fr/pandacube/lib/util/ListUtil.java | 2 +- .../fr/pandacube/lib/util/MappedListView.java | 22 +-- .../fr/pandacube/lib/util/MemoryUtil.java | 16 +-- .../pandacube/lib/util/MinecraftVersion.java | 26 ++-- .../pandacube/lib/util/MinecraftWebUtil.java | 14 +- .../fr/pandacube/lib/util/OfflineUUID.java | 6 +- .../fr/pandacube/lib/util/RandomUtil.java | 44 +++--- .../fr/pandacube/lib/util/StringUtil.java | 28 ++-- .../lib/util/ThrowableAccumulator.java | 10 +- .../fr/pandacube/lib/util/ThrowableUtil.java | 4 +- .../java/fr/pandacube/lib/util/TimeUtil.java | 74 +++++----- .../lib/ws/client/AbstractClientWS.java | 4 +- .../lib/ws/client/KeyProtectedClientWS.java | 2 +- .../lib/ws/server/AbstractServerWS.java | 6 +- .../lib/ws/server/KeyProtectedServerWS.java | 2 +- .../java/fr/pandacube/lib/ws/AbstractWS.java | 15 ++- .../fr/pandacube/lib/ws/PayloadRegistry.java | 2 +- .../lib/ws/payloads/LoginPayload.java | 2 +- .../lib/ws/payloads/LoginSucceedPayload.java | 2 +- .../lib/ws/payloads/MessagePayload.java | 2 +- 151 files changed, 909 insertions(+), 983 deletions(-) diff --git a/Readme.md b/Readme.md index 6425169..aa7f57f 100644 --- a/Readme.md +++ b/Readme.md @@ -3,7 +3,7 @@ ### Development library for Minecraft server applications and plugins This repository contains a collection of maven modules that are used for the development of our Minecraft server. Those -modules are made open source so they can be used by other developpers. Each of them provides different functionalities +modules are made open source, so they can be used by other developers. Each of them provides different functionalities that are detailed in their respective Readme file (if any). - `pandalib-util` General purpose utility and helper classes; @@ -20,7 +20,7 @@ that are detailed in their respective Readme file (if any). - `pandalib-netapi` A poorly designed, but working TCP network library; - `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-core` A catch-all module for some helper classes that didn’t have their own module yet; +- `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-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeBackupConfig.java b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeBackupConfig.java index ef108e0..ed6861a 100644 --- a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeBackupConfig.java +++ b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeBackupConfig.java @@ -6,10 +6,11 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +@SuppressWarnings("CanBeFinal") public class BungeeBackupConfig { public boolean workdirBackupEnabled = true; public boolean logsBackupEnabled = true; - public String scheduling = "0 2 * * *"; // cron format, here is everyday at 2am + public String scheduling = "0 2 * * *"; // cron format, here is every day at 2am public File backupDirectory = null; public BackupCleaner workdirBackupCleaner = BackupCleaner.KEEPING_1_EVERY_N_MONTH(3).merge(BackupCleaner.KEEPING_N_LAST(5)); public List workdirIgnoreList = new ArrayList<>(); diff --git a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeWorkdirProcess.java b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeWorkdirProcess.java index 3bdfd6e..0a4a59e 100644 --- a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeWorkdirProcess.java +++ b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/backup/BungeeWorkdirProcess.java @@ -18,15 +18,12 @@ public class BungeeWorkdirProcess extends BackupProcess { public BiPredicate getFilenameFilter() { - return new BiPredicate<>() { - @Override - public boolean test(File file, String path) { - if (new File(getSourceDir(), "logs").equals(file)) - return false; - if (file.isFile() && file.getName().endsWith(".lck")) - return false; - return BungeeWorkdirProcess.super.getFilenameFilter().test(file, path); - } + return (file, path) -> { + if (new File(getSourceDir(), "logs").equals(file)) + return false; + if (file.isFile() && file.getName().endsWith(".lck")) + return false; + return BungeeWorkdirProcess.super.getFilenameFilter().test(file, path); }; } diff --git a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierCommand.java b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierCommand.java index 1ee44c7..1cb1e50 100644 --- a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierCommand.java +++ b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierCommand.java @@ -28,10 +28,10 @@ public abstract class BungeeBrigadierCommand extends BrigadierCommand commandNode; diff --git a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierDispatcher.java b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierDispatcher.java index 40845ab..f0cee97 100644 --- a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierDispatcher.java +++ b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/commands/BungeeBrigadierDispatcher.java @@ -39,7 +39,7 @@ public class BungeeBrigadierDispatcher extends BrigadierDispatcher InitialHandler has connected")) return false; - if (formattedRecord.contains("<-> InitialHandler has pinged")) return false; - return true; + return !( + formattedRecord.contains("<-> InitialHandler has connected") + || formattedRecord.contains("<-> InitialHandler has pinged") + ); } } 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 623a266..0f6b315 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 @@ -23,6 +23,7 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; +import org.jetbrains.annotations.NotNull; /** * A builder for chat components. @@ -30,10 +31,10 @@ import net.md_5.bungee.api.chat.BaseComponent; * Use one of the provided static methods to create a new instance. *

* This class implements {@link ComponentLike} and {@link HoverEventSource} so they can be used directly in - * Adventure API and its implentation without using the final methods of this builder. + * Adventure API and its implementation without using the final methods of this builder. *

- * The unique possible concrete subclass of this class, {@link FormatableChat}, takes care of the formating of the - * builded component. The rationale for this design is explained in the documentation of {@link FormatableChat}. + * The unique possible concrete subclass of this class, {@link FormatableChat}, takes care of the formatting of the + * built component. The rationale for this design is explained in the documentation of {@link FormatableChat}. */ public abstract sealed class Chat extends ChatStatic implements HoverEventSource, ComponentLike { @@ -60,7 +61,7 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource /** * Builds the component into Adventure Component instance. - * @return the {@link Component} builded from this {@link Chat} component. + * @return the {@link Component} built from this {@link Chat} component. */ public Component getAdv() { return builder.build(); @@ -68,7 +69,7 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource /** * Builds the component into BungeeCord {@link BaseComponent} instance. - * @return the {@link BaseComponent} builded from this {@link Chat} component. + * @return the {@link BaseComponent} built from this {@link Chat} component. */ public BaseComponent get() { return toBungee(getAdv()); @@ -76,27 +77,27 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource /** * Builds the component into BungeeCord {@link BaseComponent} array. - * @return the {@link BaseComponent} array builded from this {@link Chat} component. + * @return the {@link BaseComponent} array built from this {@link Chat} component. */ public BaseComponent[] getAsArray() { return toBungeeArray(getAdv()); } - private static final LegacyComponentSerializer LEGACY_SERIALIZER_BUNGEE_FIENDLY = LegacyComponentSerializer.builder() + private static final LegacyComponentSerializer LEGACY_SERIALIZER_BUNGEE_FRIENDLY = LegacyComponentSerializer.builder() .hexColors() .useUnusualXRepeatedCharacterHexFormat() .build(); /** - * Converts the builded component into legacy text. + * Converts the built component into legacy text. * @return the legacy text. RGB colors are in BungeeCord format. */ public String getLegacyText() { - return LEGACY_SERIALIZER_BUNGEE_FIENDLY.serialize(getAdv()); + return LEGACY_SERIALIZER_BUNGEE_FRIENDLY.serialize(getAdv()); } /** - * Converts the builded component into plain text. + * Converts the built component into plain text. * @return the plain text of this component. */ public String getPlainText() { @@ -104,16 +105,16 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource } @Override - public HoverEvent asHoverEvent(UnaryOperator op) { + public @NotNull HoverEvent asHoverEvent(@NotNull UnaryOperator op) { return HoverEvent.showText(op.apply(getAdv())); } /** * Builds the component into Adventure Component instance. - * @return the {@link Component} builded from this {@link Chat} component. + * @return the {@link Component} built from this {@link Chat} component. */ @Override - public Component asComponent() { + public @NotNull Component asComponent() { return getAdv(); } @@ -284,8 +285,8 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource public Chat thenTranslation(String key, Object... with) { return then(translation(key, with)); } /** - * Appends a component with the provided keybind. - * @param key the keybind to display. + * Appends a component with the provided keybinding. + * @param key the keybinding to display. * @return this. */ public Chat thenKeyBind(String key) { return then(keybind(key)); } @@ -443,19 +444,19 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource /** - * Appends a component filling a line of chat (or console) with the configured decoration character and + * Appends a component filling a chat line with the configured decoration character and * color and a left-aligned text. * @param leftText the text aligned to the left. - * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character + * @return a new {@link FormatableChat} filling a chat line with the configured decoration character * and color and a left-aligned text. */ public Chat thenLeftText(ComponentLike leftText) { return then(leftText(leftText, console)); } /** - * Appends a component filling a line of chat (or console) with the configured decoration character and + * Appends a component filling a chat line with the configured decoration character and * color and a left-aligned text. * @param leftText the text aligned to the left. - * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character + * @return a new {@link FormatableChat} filling a chat line with the configured decoration character * and color and a left-aligned text. * @deprecated uses Bungeecord chat API. */ @@ -463,19 +464,19 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource public Chat thenLeftText(BaseComponent leftText) { return thenLeftText(chatComponent(leftText)); } /** - * Appends a component filling a line of chat (or console) with the configured decoration character and + * Appends a component filling a chat line with the configured decoration character and * color and a right-aligned text. * @param rightText the text aligned to the right. - * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character + * @return a new {@link FormatableChat} filling a chat line with the configured decoration character * and color and a right-aligned text. */ public Chat thenRightText(ComponentLike rightText) { return then(rightText(rightText, console)); } /** - * Appends a component filling a line of chat (or console) with the configured decoration character and + * Appends a component filling a chat line with the configured decoration character and * color and a right-aligned text. * @param rightText the text aligned to the right. - * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character + * @return a new {@link FormatableChat} filling a chat line with the configured decoration character * and color and a right-aligned text. * @deprecated uses Bungeecord chat API. */ @@ -483,10 +484,10 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource public Chat thenRightText(BaseComponent rightText) { return thenRightText(chatComponent(rightText)); } /** - * Appends a component filling a line of chat (or console) with the configured decoration character and + * Appends a component filling a chat line with the configured decoration character and * color and a centered text. * @param centerText the text aligned to the center. - * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character + * @return a new {@link FormatableChat} filling a chat line with the configured decoration character * and color and a centered text. */ public Chat thenCenterText(ComponentLike centerText) { @@ -494,10 +495,10 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource } /** - * Appends a component filling a line of chat (or console) with the configured decoration character and + * Appends a component filling a chat line with the configured decoration character and * color and a centered text. * @param centerText the text aligned to the center. - * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character + * @return a new {@link FormatableChat} filling a chat line with the configured decoration character * and color and a centered text. * @deprecated uses Bungeecord chat API. */ @@ -507,8 +508,8 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource } /** - * Appends a component filling a line of chat (or console) with the configured decoration character and color. - * @return a new {@link FormatableChat} filling a line of chat (or console) with a decoration character and color. + * Appends a component filling a chat line with the configured decoration character and color. + * @return a new {@link FormatableChat} filling a chat line with a decoration character and color. */ public Chat thenFilledLine() { return then(filledLine(console)); } @@ -534,11 +535,11 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource * .append("!").color(ChatColor.RED) * .create(); * } - * Here, when you call a formating method (like {@code bold(boolean)} or {@code color(ChatColor)}) after the - * {@code append(String)} method, the formating apply to the last sub-component appended. + * Here, when you call a formatting method (like {@code bold(boolean)} or {@code color(ChatColor)}) after the + * {@code append(String)} method, the formatting apply to the last subcomponent appended. *

- * In our design, we want the formating to apply to the currently builded component, not the last appended one. - * The purpose is to make the component structure clearer and have better control of the formating over the + * In our design, we want the formatting to apply to the currently built component, not the last appended one. + * The purpose is to make the component structure clearer and have better control of the formatting over the * component hierarchy. * Here is the equivalent of the above code, with the {@link Chat} API: *

{@code
@@ -547,9 +548,9 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
      *         .thenText("!"); // short for .then(Chat.text("!"))
      *         // the red color for "!" is not needed because the parent component is already red.
      * }
- * When calling {@link #then(Component) #then(...)} on a {@link FormatableChat}, the method returns itself, casted - * to {@link Chat}, to prevent future formating (that the programmer would think it formats the previously appended - * sub-component). If the formatting of the currently builded component is needed, since {@link Chat} is a sealed + * When calling {@link #then(Component) #then(...)} on a {@link FormatableChat}, the method returns itself, cast + * to {@link Chat}, to prevent future formatting (that the programmer would think it formats the previously appended + * subcomponent). If the formatting of the currently built component is needed, since {@link Chat} is a sealed * class which only subclass is {@link FormatableChat}, you can cast the builder, and use the format methods again. *
{@code
      * Chat component = Chat.text("Hello ").red()
@@ -986,7 +987,7 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
     }
 
     /**
-     * Force the italic formating to be set to false if it is not explicitely set in the component.
+     * Force the italic formatting to be set to false if it is not explicitly set in the component.
      * This is useful for item lores that defaults to italic in the game UI.
      * @param c the {@link Chat} in which to set the italic property if needed.
      * @return the provided {@link Chat} instance.
diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorGradient.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorGradient.java
index 933f74c..c303ac2 100644
--- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorGradient.java
+++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorGradient.java
@@ -6,7 +6,7 @@ import java.util.List;
 import net.kyori.adventure.text.format.TextColor;
 
 /**
- * A custom gradient with a least 2 colors in it.
+ * A custom gradient with at least 2 colors in it.
  */
 public class ChatColorGradient {
     private record GradientColor(float location, TextColor color) { }
diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorUtil.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorUtil.java
index 3d00a9f..38355c2 100644
--- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorUtil.java
+++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatColorUtil.java
@@ -14,7 +14,7 @@ public class ChatColorUtil {
 
 
     /**
-     * All characters that represent a colorcode.
+     * All characters that represent a color code.
      */
     public static final String ALL_COLORS = "0123456789AaBbCcDdEeFf";
     /**
@@ -30,7 +30,7 @@ public class ChatColorUtil {
      * Returns the legacy format needed to reproduce the format at the end of the provided legacy text.
      * Supports standard chat colors and formats, BungeeCord Chat rgb format and EssentialsX rgb format.
      * The RGB value from EssentialsX format is converted to BungeeCord Chat when included in the returned value.
-     * @param legacyText the legacy formated text.
+     * @param legacyText the legacy formatted text.
      * @return the active format at the end of the provided text.
      */
     public static String getLastColors(String legacyText) {
@@ -84,8 +84,8 @@ public class ChatColorUtil {
     }
 
     /**
-     * Returns the {@link ChatColor} associated with the provided char, case insensitive.
-     * @param code the case insensitive char code.
+     * Returns the {@link ChatColor} associated with the provided char, case-insensitive.
+     * @param code the case-insensitive char code.
      * @return the corresponding {@link ChatColor}.
      */
     public static ChatColor getChatColorByChar(char code) {
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 c479371..502bfe7 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
@@ -8,6 +8,7 @@ import net.kyori.adventure.text.format.TextColor;
 /**
  * Class holding static configuration values for chat component rendering.
  */
+@SuppressWarnings("CanBeFinal")
 public class ChatConfig {
 
     /**
@@ -29,7 +30,7 @@ public class ChatConfig {
     /**
      * The color used for successful messages.
      */
-    public static TextColor successColor = PandaTheme.CHAT_GREEN_SATMAX;
+    public static TextColor successColor = PandaTheme.CHAT_GREEN_MAX_SAT;
 
     /**
      * The color used for error/failure messages.
@@ -67,14 +68,14 @@ public class ChatConfig {
     public static TextColor highlightedCommandColor = NamedTextColor.WHITE;
 
     /**
-     * The color used for broadcasted messages.
+     * The color used for broadcast messages.
      * It is often used in combination with {@link #prefix}.
      */
     public static TextColor broadcastColor = NamedTextColor.YELLOW;
     
     /**
      * The prefix used for prefixed messages.
-     * It can be a sylized name of the server, like {@code "[Pandacube] "}.
+     * It can be a stylized name of the server, like {@code "[Pandacube] "}.
      * It is often used in combination with {@link #broadcastColor}.
      */
     public static Supplier prefix = PandaTheme::CHAT_MESSAGE_PREFIX;
@@ -104,7 +105,7 @@ public class ChatConfig {
         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
+        public static final TextColor CHAT_GREEN_MAX_SAT = 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. */
diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java
index 39527fc..0ba9700 100644
--- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java
+++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatFilledLine.java
@@ -140,7 +140,7 @@ public class ChatFilledLine implements ComponentLike {
 
     /**
      * Renders this line to a {@link FormatableChat}.
-     * @return a new {@link FormatableChat} builded by this {@link ChatFilledLine}.
+     * @return a new {@link FormatableChat} built by this {@link ChatFilledLine}.
      */
     public FormatableChat toChat() {
         int maxWidth = (this.maxWidth != null)
diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatStatic.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatStatic.java
index 92b0107..6e3fd3e 100644
--- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatStatic.java
+++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatStatic.java
@@ -227,9 +227,9 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} with the provided keybind.
-     * @param key the keybind to display.
-     * @return a new {@link FormatableChat} with the provided keybind.
+     * Creates a {@link FormatableChat} with the provided keybinding.
+     * @param key the keybinding to display.
+     * @return a new {@link FormatableChat} with the provided keybinding.
      */
     public static FormatableChat keybind(String key) {
         return new FormatableChat(Component.keybind().keybind(key));
@@ -451,12 +451,12 @@ public abstract class ChatStatic {
 
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with decoration and a left-aligned text.
+     * Creates a {@link FormatableChat} filling a chat line with decoration and a left-aligned text.
      * @param text the text aligned to the left.
      * @param decorationChar the character used for decoration around the text.
      * @param decorationColor the color used for the decoration characters.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with decoration and a left-aligned text.
+     * @return a new {@link FormatableChat} filling a chat line with decoration and a left-aligned text.
      * @see ChatFilledLine#leftText(ComponentLike)
      */
     public static FormatableChat leftText(ComponentLike text, char decorationChar, TextColor decorationColor, boolean console) {
@@ -464,11 +464,11 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with the configured decoration character and
+     * Creates a {@link FormatableChat} filling a chat line with the configured decoration character and
      * color and a left-aligned text.
      * @param text the text aligned to the left.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character
+     * @return a new {@link FormatableChat} filling a chat line with the configured decoration character
      *         and color and a left-aligned text.
      * @see ChatFilledLine#leftText(ComponentLike)
      * @see ChatConfig#decorationChar
@@ -479,12 +479,12 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with decoration and a right-aligned text.
+     * Creates a {@link FormatableChat} filling a chat line with decoration and a right-aligned text.
      * @param text the text aligned to the right.
      * @param decorationChar the character used for decoration around the text.
      * @param decorationColor the color used for the decoration characters.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with decoration and a right-aligned
+     * @return a new {@link FormatableChat} filling a chat line with decoration and a right-aligned
      *         text.
      * @see ChatFilledLine#rightText(ComponentLike)
      */
@@ -493,11 +493,11 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with the configured decoration character and
+     * Creates a {@link FormatableChat} filling a chat line with the configured decoration character and
      * color and a right-aligned text.
      * @param text the text aligned to the right.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character
+     * @return a new {@link FormatableChat} filling a chat line with the configured decoration character
      *         and color and a right-aligned text.
      * @see ChatFilledLine#rightText(ComponentLike)
      * @see ChatConfig#decorationChar
@@ -508,12 +508,12 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with decoration and a centered text.
+     * Creates a {@link FormatableChat} filling a chat line with decoration and a centered text.
      * @param text the text aligned to the center.
      * @param decorationChar the character used for decoration around the text.
      * @param decorationColor the color used for the decoration characters.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with decoration and a centered text.
+     * @return a new {@link FormatableChat} filling a chat line with decoration and a centered text.
      * @see ChatFilledLine#centerText(ComponentLike)
      */
     public static FormatableChat centerText(ComponentLike text, char decorationChar, TextColor decorationColor, boolean console) {
@@ -521,11 +521,11 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with the configured decoration character and
+     * Creates a {@link FormatableChat} filling a chat line with the configured decoration character and
      * color and a centered text.
      * @param text the text aligned to the center.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with the configured decoration character
+     * @return a new {@link FormatableChat} filling a chat line with the configured decoration character
      *         and color and a centered text.
      * @see ChatFilledLine#centerText(ComponentLike)
      * @see ChatConfig#decorationChar
@@ -536,11 +536,11 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with a decoration character and color.
+     * Creates a {@link FormatableChat} filling a chat line with a decoration character and color.
      * @param decorationChar the character used for decoration.
      * @param decorationColor the color used for the decoration characters.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with a decoration character and color.
+     * @return a new {@link FormatableChat} filling a chat line with a decoration character and color.
      * @see ChatFilledLine#filled()
      */
     public static FormatableChat filledLine(char decorationChar, TextColor decorationColor, boolean console) {
@@ -548,10 +548,10 @@ public abstract class ChatStatic {
     }
 
     /**
-     * Creates a {@link FormatableChat} filling a line of chat (or console) with the configured decoration character and
+     * Creates a {@link FormatableChat} filling a chat line with the configured decoration character and
      * color.
      * @param console if the line is rendered on console (true) or IG (false).
-     * @return a new {@link FormatableChat} filling a line of chat (or console) with a decoration character and color.
+     * @return a new {@link FormatableChat} filling a chat line with a decoration character and color.
      * @see ChatFilledLine#filled()
      * @see ChatConfig#decorationChar
      * @see ChatConfig#decorationColor
@@ -633,7 +633,7 @@ public abstract class ChatStatic {
                     .storage(((StorageNBTComponent) c).storage());
         }
         else {
-            throw new IllegalArgumentException("Unknows component type " + c.getClass());
+            throw new IllegalArgumentException("Unknown component type " + c.getClass());
         }
         return builder.style(c.style()).append(c.children());
     }
diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatTreeNode.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatTreeNode.java
index a7dbfc7..ca0df66 100644
--- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatTreeNode.java
+++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatTreeNode.java
@@ -27,7 +27,7 @@ public class ChatTreeNode {
     public final List children = new ArrayList<>();
 
     /**
-     * Construct an new {@link ChatTreeNode}.
+     * Construct a new {@link ChatTreeNode}.
      * @param cmp the component for the current node.
      */
     public ChatTreeNode(Chat cmp) {
@@ -48,7 +48,7 @@ public class ChatTreeNode {
      * Generate a tree view based on this tree structure.
      * 

* Each element in the returned list represent 1 line of this tree view. - * Thus, the caller may send each line separately or at once depending of the quantity of data. + * Thus, the caller may send each line separately or at once, depending on the quantity of data. * @param console true to render for console, false otherwise. * @return an array of component, each element being a single line. */ diff --git a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatUtil.java b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatUtil.java index 2a25c19..0e33152 100644 --- a/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatUtil.java +++ b/pandalib-chat/src/main/java/fr/pandacube/lib/chat/ChatUtil.java @@ -22,7 +22,7 @@ import net.md_5.bungee.api.ChatColor; import fr.pandacube.lib.chat.Chat.FormatableChat; /** - * Provides various methods and properties to manipulate text displayed in chat an other parts of the game. + * Provides various methods and properties to manipulate text displayed in chat and other parts of the game. */ public class ChatUtil { @@ -48,7 +48,7 @@ public class ChatUtil { /** * Mapping indicating the text pixel with for specific characters in the default Minecraft font. - * If a character doesn’t have a mapping in this map, then its width is {@link #DEFAULT_CHAR_SIZE}. + * If a character doesn't have a mapping in this map, then its width is {@link #DEFAULT_CHAR_SIZE}. */ public static final Map CHAR_SIZES; static { @@ -112,7 +112,7 @@ public class ChatUtil { * @param nbPages the number of pages. * @param nbPagesToDisplay the number of pages to display around the first page, the last page and the * {@code currentPage}. - * @return a {@link Chat} containging the created page navigator. + * @return a {@link Chat} containing the created page navigator. */ public static Chat createPagination(String prefix, String cmdFormat, int currentPage, int nbPages, int nbPagesToDisplay) { Set pagesToDisplay = new TreeSet<>(); @@ -149,11 +149,11 @@ public class ChatUtil { else first = false; - FormatableChat pDisp = Chat.clickableCommand(Chat.text(page), String.format(cmdFormat, page), Chat.text("Aller à la page " + page)); + FormatableChat pDisplay = Chat.clickableCommand(Chat.text(page), String.format(cmdFormat, page), Chat.text("Aller à la page " + page)); if (page == currentPage) { - pDisp.highlightedCommandColor(); + pDisplay.highlightedCommandColor(); } - d.then(pDisp); + d.then(pDisplay); previous = page; } @@ -258,7 +258,7 @@ public class ChatUtil { /** - * Wraps the provided text in multiple lines, taking into account the legacy formating. + * Wraps the provided text in multiple lines, taking into account the legacy formatting. *

* This method only takes into account IG text width. Use a regular text-wrapper for console instead. * @param legacyText the text to wrap. @@ -272,7 +272,7 @@ public class ChatUtil { } /** - * Wraps the provided text in multiple lines, taking into account the legacy formating. + * Wraps the provided text in multiple lines, taking into account the legacy formatting. *

* This method only takes into account IG text width. Use a regular text-wrapper for console instead. * @param legacyText the text to wrap. @@ -369,7 +369,7 @@ public class ChatUtil { /** * Try to render a matrix of {@link Chat} components into a table in the chat or console. - * @param data the component, in the form of {@link List} of {@link List} of {@link Chat}. The englobing list holds + * @param data the component, in the form of {@link List} of {@link List} of {@link Chat}. The parent list holds * the table lines (line 0 being the top line). Each sublist holds the cells content (element 0 is the * leftText one). The row lengths can be different. * @param space a spacer to put between columns. @@ -392,7 +392,7 @@ public class ChatUtil { /** * Try to render a matrix of {@link Component} components into a table in the chat or console. - * @param data the component, in the form of {@link List} of {@link List} of {@link Component}. The englobing list holds + * @param data the component, in the form of {@link List} of {@link List} of {@link Component}. The parent list holds * the table lines (line 0 being the top line). Each sublist holds the cells content (element 0 is the * leftText one). The row lengths can be different. * @param space a spacer to put between columns. @@ -505,9 +505,9 @@ public class ChatUtil { private static final char PROGRESS_BAR_FULL_CHAR = '|'; /** - * Generate a (eventually multi-part) progress bar using text. + * Generate a (eventually multipart) progress bar using text. * @param values the values to render in the progress bar. - * @param colors the colors attributed to each values. + * @param colors the colors attributed to each value. * @param total the total value of the progress bar. * @param width the width in which the progress bar should fit (in pixel for IG, in character count for console) * @param console true if the progress bar is intended to be displayed on the console, false if it’s in game chat. diff --git a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLI.java b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLI.java index 699ff94..b7e38f9 100644 --- a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLI.java +++ b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/CLI.java @@ -11,7 +11,7 @@ import org.fusesource.jansi.AnsiConsole; import fr.pandacube.lib.util.Log; /** - * Class to hangle general standard IO operation for a CLI application. It uses Jline’s {@link ConsoleReader} for the + * Class to handle general standard IO operation for a CLI application. It uses Jline’s {@link ConsoleReader} for the * console rendering, a JUL {@link Logger} for logging, and Brigadier to handle commands. */ public class CLI extends Thread { @@ -33,7 +33,7 @@ public class CLI extends Thread { reader.setPrompt(">"); reader.addCompleter(CLIBrigadierDispatcher.instance); - // configuration du formatteur pour le logger + // configure logger's formatter System.setProperty("net.md_5.bungee.log-date-format", "yyyy-MM-dd HH:mm:ss"); logger = CLILogger.getLogger(this); } 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 a63ce29..7670680 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 @@ -64,6 +64,7 @@ public abstract class CLIApplication { private final Object stopLock = new Object(); private final AtomicBoolean stopping = new AtomicBoolean(false); + @SuppressWarnings("finally") public final void stop() { synchronized (stopLock) { synchronized (stopping) { diff --git a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierCommand.java b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierCommand.java index a715fd9..cf7c3fc 100644 --- a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierCommand.java +++ b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierCommand.java @@ -15,7 +15,7 @@ import java.util.function.Predicate; public abstract class CLIBrigadierCommand extends BrigadierCommand { /** - * Instanciate this command instance. + * Instantiate this command instance. */ public CLIBrigadierCommand() { LiteralCommandNode commandNode = buildCommand().build(); diff --git a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierDispatcher.java b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierDispatcher.java index dd1806b..82e4642 100644 --- a/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierDispatcher.java +++ b/pandalib-cli/src/main/java/fr/pandacube/lib/cli/commands/CLIBrigadierDispatcher.java @@ -27,7 +27,7 @@ public class CLIBrigadierDispatcher extends BrigadierDispatcher> nodes = new ArrayList<>(); - List children = new ArrayList<>(); + final List> nodes = new ArrayList<>(); + final List children = new ArrayList<>(); void addInline(CommandNode node) { nodes.add(node); 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 672a658..82f350e 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 @@ -25,7 +25,7 @@ public class CLILogger { /** * Initialize and return the logger for this application. * @param cli the CLI instance to use - * @return the logger of this application. + * @return the logger for this application. */ public static synchronized Logger getLogger(CLI cli) { if (logger == null) { diff --git a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java index 5e79859..b73e117 100644 --- a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java +++ b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java @@ -29,7 +29,7 @@ public abstract class BrigadierCommand { * Returns a builder for this command. * Concrete class should include any element in the builder that is needed to build the command (sub-commands and * arguments, requirements, redirection, ...). - * If any of the sub-commands and arguments needs to know the {@link LiteralCommandNode} builded from the returned + * If any of the sub-commands and arguments needs to know the {@link LiteralCommandNode} built from the returned * {@link LiteralArgumentBuilder}, this can be done by overriding {@link #postBuildCommand(LiteralCommandNode)}. * @return a builder for this command. */ @@ -37,16 +37,16 @@ public abstract class BrigadierCommand { /** * Method to override if the reference to the command node has to be known when building the subcommands. - * @param commandNode the command node builded from {@link #buildCommand()}. + * @param commandNode the command node built from {@link #buildCommand()}. */ protected void postBuildCommand(LiteralCommandNode commandNode) { // default implementation does nothing. } /** - * Method to override if this command have any aliases. + * Method to override if this command has any aliases. * @return an array of string corresponding to the aliases. This must not include the orignal command name (that - * is the name of the literal command node builded from {@link #buildCommand()}). + * is the name of the literal command node built from {@link #buildCommand()}). */ protected String[] getAliases() { return new String[0]; diff --git a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierDispatcher.java b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierDispatcher.java index 0692f59..d45ea55 100644 --- a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierDispatcher.java +++ b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierDispatcher.java @@ -13,7 +13,7 @@ import java.util.concurrent.CompletableFuture; /** * Abstract class that holds a Brigadier {@link CommandDispatcher} instance. - * Subclasses contains logic to integrate this commands dispatcher into their environment (like Bungee or CLI app). + * Subclasses contain logic to integrate this commands dispatcher into their environment (like Bungee or CLI app). * @param the command source (or command sender) type. */ public abstract class BrigadierDispatcher { @@ -43,7 +43,7 @@ public abstract class BrigadierDispatcher { /** * Executes the provided command as the provided sender. * @param sender the command sender. - * @param commandWithoutSlash the command, without the eventual slash at the begining. + * @param commandWithoutSlash the command, without the eventual slash at the beginning. * @return the value returned by the executed command. */ public int execute(S sender, String commandWithoutSlash) { diff --git a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierSuggestionsUtil.java b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierSuggestionsUtil.java index b6b3ee2..af5adf1 100644 --- a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierSuggestionsUtil.java +++ b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierSuggestionsUtil.java @@ -18,7 +18,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; /** - * Utility methods to replace some functionalities of Brigadier, especialy suggestion sorting that we don’t like. + * Utility methods to replace some functionalities of Brigadier, especially suggestion sorting that we don’t like. */ public class BrigadierSuggestionsUtil { diff --git a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/SuggestionsSupplier.java b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/SuggestionsSupplier.java index d8aa706..0a638dc 100644 --- a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/SuggestionsSupplier.java +++ b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/SuggestionsSupplier.java @@ -14,7 +14,7 @@ import java.util.stream.LongStream; import java.util.stream.Stream; /** - * Functionnal interface providing suggestions for an argument of a command. + * Functional interface providing suggestions for an argument of a command. * @param the type of the command sender. */ @FunctionalInterface @@ -66,7 +66,7 @@ public interface SuggestionsSupplier { * Filter the provided {@link Stream} of string according to the provided token, using the filter returned by {@link #filter(String)}, * then returns the strings collected into a {@link List}. *

- * This methods consume the provided stream, so will not be usable anymore. + * This method consume the provided stream, so will not be usable anymore. * @param stream the stream to filter and collet. * @param token the token to consider for filtering. * @return the stream, filtered and collected into a {@link List}. @@ -505,7 +505,7 @@ public interface SuggestionsSupplier { /** * Creates a new {@link SuggestionsSupplier} containing all the suggestions of this instance, * but if this list is still empty, returns the suggestions from the provided one. - * @param other another {@link SuggestionsSupplier} to fallback to. + * @param other another {@link SuggestionsSupplier} to fall back to. * @return a new {@link SuggestionsSupplier}. */ default SuggestionsSupplier orIfEmpty(SuggestionsSupplier other) { diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/BackupCleaner.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/BackupCleaner.java index d14c5aa..9ede9f8 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/BackupCleaner.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/BackupCleaner.java @@ -18,7 +18,7 @@ import static fr.pandacube.lib.chat.ChatStatic.text; /** * Cleanup a backup directory (i.e. removes old backup archives). - * It is possible to combine differents instances to affect which archive to keep or delete. + * It is possible to combine different instances to affect which archive to keep or delete. */ public abstract class BackupCleaner implements UnaryOperator> { @@ -48,7 +48,7 @@ public abstract class BackupCleaner implements UnaryOperatorYEAR * (12 / n) + MONTH / n. It then keeps the first archive * found in each section. * - * @param n the interval in month between each kept archives. Must be a dividor of 12 (1, 2, 3, 4, 6 or 12). + * @param n the interval in month between each kept archives. Must be a divider of 12 (1, 2, 3, 4, 6 or 12). * @return a {@link BackupCleaner} that keeps one archive every n month. */ public static BackupCleaner KEEPING_1_EVERY_N_MONTH(int n) { @@ -94,11 +94,13 @@ public abstract class BackupCleaner implements UnaryOperator, Runnab private boolean enabled = true; - private String scheduling = "0 2 * * *"; // cron format, here is everyday at 2am + private String scheduling = "0 2 * * *"; // cron format, here is every day at 2am private BackupCleaner backupCleaner = null; private List ignoreList = new ArrayList<>(); /** - * Instanciates a new backup process. + * Instantiates a new backup process. * @param bm the associated backup manager. * @param n the process identifier. */ @@ -66,9 +66,9 @@ public abstract class BackupProcess implements Comparable, Runnab } /** - * Gets the displayname of this process. + * Gets the display name of this process. * Default implementation returns {@link #getIdentifier()}. - * @return the displayname of this process. + * @return the display name of this process. */ protected String getDisplayName() { return getIdentifier(); @@ -105,8 +105,8 @@ public abstract class BackupProcess implements Comparable, Runnab } /** - * Gets the source directory to backup. - * @return the source directory to backup. + * Gets the source directory to back up. + * @return the source directory to back up. */ public abstract File getSourceDir(); @@ -123,7 +123,7 @@ public abstract class BackupProcess implements Comparable, Runnab /** * Called when the backup ends. - * @param success true if the backup ended successfuly. + * @param success true if the backup ended successfully. */ protected abstract void onBackupEnd(boolean success); @@ -209,7 +209,7 @@ public abstract class BackupProcess implements Comparable, Runnab File sourceDir = getSourceDir(); if (!sourceDir.exists()) { - Log.warning("[Backup] Unable to compress " + ChatColor.GRAY + getDisplayName() + ChatColor.RESET + ": source directory " + sourceDir + " doesn’t exist"); + Log.warning("[Backup] Unable to compress " + ChatColor.GRAY + getDisplayName() + ChatColor.RESET + ": source directory " + sourceDir + " doesn't exist"); return; } 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 372b702..ee01fba 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 @@ -26,7 +26,7 @@ public class Persist { // private final Set dirtyWorldsSave = new HashSet<>(); /** - * Creates a new instance, immediatly loading the data from the file if it exists, or creating an empty one if not. + * Creates a new instance, immediately loading the data from the file if it exists, or creating an empty one if not. * @param bm the associated backup manager. */ public Persist(BackupManager bm) { 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 7c2f073..6e648d7 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 @@ -24,7 +24,8 @@ public class RotatedLogsBackupProcess extends BackupProcess { * @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). + * @param logFileRegexPattern the pattern to match the rotated log files (usually dated log files, excluding the + * current log file). */ public RotatedLogsBackupProcess(BackupManager bm, boolean inNewThread, File sourceLogDir, String logFileRegexPattern) { super(bm, "logs"); diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/ZipCompressor.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/ZipCompressor.java index 0c10437..693ff3a 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/ZipCompressor.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/backup/ZipCompressor.java @@ -158,8 +158,8 @@ public class ZipCompressor { } private class Entry { - File file; - String entry; + final File file; + final String entry; Entry(File f, String e) { file = f; entry = e; diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java index 2d7ab4b..8b016b2 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfig.java @@ -1,23 +1,22 @@ package fr.pandacube.lib.core.config; +import fr.pandacube.lib.chat.ChatColorUtil; +import fr.pandacube.lib.util.Log; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import fr.pandacube.lib.chat.ChatColorUtil; -import fr.pandacube.lib.util.Log; - /** * Class that loads a specific config file or directory. */ public abstract class AbstractConfig { /** - * The {@link File} corresponging to this config file or directory. + * The {@link File} corresponding to this config file or directory. */ protected final File configFile; @@ -94,7 +93,8 @@ public abstract class AbstractConfig { * @return the list of files in the config directory, or null if this config is not a directory. */ protected List getFileList() { - return configFile.isDirectory() ? Arrays.asList(configFile.listFiles()) : null; + File[] arr = configFile.listFiles(); + return arr != null ? List.of(arr) : null; } @@ -105,7 +105,7 @@ public abstract class AbstractConfig { * Splits the provided string into a list of permission nodes. * The permission nodes must be separated by {@code ";"}. * @param perms one or more permissions nodes, separated by {@code ";"}. - * @return {@code null} if the parameter is null or is equal to {@code "*"}, or the string splitted using {@code ";"}. + * @return {@code null} if the parameter is null or is equal to {@code "*"}, or the string split using {@code ";"}. */ public static List splitPermissionsString(String perms) { if (perms == null || perms.equals("*")) @@ -115,9 +115,9 @@ public abstract class AbstractConfig { /** - * Utility method to that translate the {@code '&'} formated string to the legacy format. + * Utility method to that translate the {@code '&'} formatted string to the legacy format. * @param string the string to convert. - * @return a legacy formated string (using {@code '§'}). + * @return a legacy formatted string (using {@code '§'}). */ public static String getTranslatedColorCode(String string) { return ChatColorUtil.translateAlternateColorCodes('&', string); diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java index 35ece54..bbd48bf 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/config/AbstractConfigManager.java @@ -5,13 +5,13 @@ import java.io.IOException; /** * An abstract manager for a set of configuration files and folders. - * Its uses is to manage the loading/reloading of the configuration of a plugin. + * It's uses to manage the loading/reloading of the configuration of a plugin. */ public abstract class AbstractConfigManager { /** * The global configuration directory. - * May be the one provided by the environmenet API (like Plugin.getPluginFolder() in Bukkit). + * It may be the one provided by the environment API (like Plugin.getPluginFolder() in Bukkit). */ protected final File configDir; diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/cron/CronScheduler.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/cron/CronScheduler.java index 32d1ead..6e4b709 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/cron/CronScheduler.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/cron/CronScheduler.java @@ -102,7 +102,7 @@ public class CronScheduler { /** * Cancel a scheduled task. - * Will not stop a current execution of the task. If the task does not exists, it will not do anything. + * Will not stop a current execution of the task. If the task does not exist, it will not do anything. * @param taskId the id of the task to cancel. */ public static void unSchedule(String taskId) { diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java index 30fd33c..495f4cb 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/Json.java @@ -12,34 +12,34 @@ import java.util.List; import java.util.function.Function; /** - * Provides pre-instanciated {@link Gson} instances, all with support for Java records and additionnal + * Provides pre-instanced {@link Gson} objects, all with support for Java records and additional * {@link TypeAdapterFactory} provided with {@link #registerTypeAdapterFactory(TypeAdapterFactory)}. */ public class Json { /** - * {@link Gson} instance with {@link GsonBuilder#setLenient()} and support for Java records and additionnal + * {@link Gson} instance with {@link GsonBuilder#setLenient()} and support for Java records and additional * {@link TypeAdapterFactory} provided with {@link #registerTypeAdapterFactory(TypeAdapterFactory)}. */ public static final Gson gson = build(Function.identity()); /** * {@link Gson} instance with {@link GsonBuilder#setLenient()}, {@link GsonBuilder#setPrettyPrinting()} and support - * for Java records and additionnal {@link TypeAdapterFactory} provided with + * for Java records and additional {@link TypeAdapterFactory} provided with * {@link #registerTypeAdapterFactory(TypeAdapterFactory)}. */ public static final Gson gsonPrettyPrinting = build(GsonBuilder::setPrettyPrinting); /** * {@link Gson} instance with {@link GsonBuilder#setLenient()}, {@link GsonBuilder#serializeNulls()} and support for - * Java records and additionnal {@link TypeAdapterFactory} provided with + * Java records and additional {@link TypeAdapterFactory} provided with * {@link #registerTypeAdapterFactory(TypeAdapterFactory)}. */ public static final Gson gsonSerializeNulls = build(GsonBuilder::serializeNulls); /** * {@link Gson} instance with {@link GsonBuilder#setLenient()}, {@link GsonBuilder#serializeNulls()}, - * {@link GsonBuilder#setPrettyPrinting()} and support for Java records and additionnal {@link TypeAdapterFactory} + * {@link GsonBuilder#setPrettyPrinting()} and support for Java records and additional {@link TypeAdapterFactory} * provided with {@link #registerTypeAdapterFactory(TypeAdapterFactory)}. */ public static final Gson gsonSerializeNullsPrettyPrinting = build(b -> b.serializeNulls().setPrettyPrinting()); diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/ThrowableAdapter.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/ThrowableAdapter.java index 55b6de9..20e600f 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/ThrowableAdapter.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/ThrowableAdapter.java @@ -43,7 +43,7 @@ public class ThrowableAdapter implements JsonSerializer, JsonDeserial // handle types Throwable t = null; if (obj.has("types") && obj.get("types").isJsonArray()) { - t = instanciate(obj.getAsJsonArray("types"), message, cause); + t = instantiate(obj.getAsJsonArray("types"), message, cause); } if (t == null) { t = new Throwable(message, cause); @@ -53,8 +53,8 @@ public class ThrowableAdapter implements JsonSerializer, JsonDeserial JsonArray suppressed = obj.has("suppressed") && !obj.get("suppressed").isJsonNull() ? obj.get("suppressed").getAsJsonArray() : null; if (suppressed != null) { - for (JsonElement jsonel : suppressed) { - t.addSuppressed(context.deserialize(jsonel, Throwable.class)); + for (JsonElement jsonEl : suppressed) { + t.addSuppressed(context.deserialize(jsonEl, Throwable.class)); } } @@ -63,8 +63,8 @@ public class ThrowableAdapter implements JsonSerializer, JsonDeserial ? obj.get("stacktrace").getAsJsonArray() : null; if (stacktrace != null) { List els = new ArrayList<>(); - for (JsonElement jsonel : stacktrace) { - els.add(context.deserialize(jsonel, StackTraceElement.class)); + for (JsonElement jsonEl : stacktrace) { + els.add(context.deserialize(jsonEl, StackTraceElement.class)); } t.setStackTrace(els.toArray(new StackTraceElement[0])); } @@ -159,7 +159,7 @@ public class ThrowableAdapter implements JsonSerializer, JsonDeserial } - private Throwable instanciate(JsonArray types, String message, Throwable cause) { + private Throwable instantiate(JsonArray types, String message, Throwable cause) { Throwable t = null; for (JsonElement clNameEl : types) { String clName = clNameEl.getAsString(); @@ -196,7 +196,7 @@ public class ThrowableAdapter implements JsonSerializer, JsonDeserial } /** - * Utiliy method to use on {@link Throwable} class that only have a message (no cause) constructor. + * Utility method to use on {@link Throwable} class that only have a message (no cause) constructor. * @param constructorWithMessage function that will construct a new throwable, with prefilled message. * @return a function that will construct a throwable using the provided function, then will try to init the cause of the throwable. * @param the type of the constructed {@link Throwable}. diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/TypeConverter.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/TypeConverter.java index 765b61c..b9dd000 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/json/TypeConverter.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/json/TypeConverter.java @@ -15,8 +15,8 @@ public class TypeConverter { /** * Converts the provided object to an {@link Integer}. * @param o the object to convert. - * @return a the object converted to an {@link Integer}. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to an {@link Integer}. + * @throws ConversionException is a conversion error occurs. */ public static Integer toInteger(Object o) { if (o == null) { @@ -27,7 +27,7 @@ public class TypeConverter { try { return ((JsonElement)o).getAsInt(); } catch(UnsupportedOperationException e) { - throw new ConvertionException(e); + throw new ConversionException(e); } } @@ -38,34 +38,34 @@ public class TypeConverter { try { return Integer.parseInt((String)o); } catch (NumberFormatException e) { - throw new ConvertionException(e); + throw new ConversionException(e); } } if (o instanceof Boolean) { return ((Boolean)o) ? 1 : 0; } - throw new ConvertionException("No integer convertion available for an instance of "+o.getClass()); + throw new ConversionException("No integer conversion available for an instance of "+o.getClass()); } /** * Converts the provided object to a primitive int. * @param o the object to convert. - * @return a the object converted to a primitive int. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to a primitive int. + * @throws ConversionException is a conversion error occurs. */ public static int toPrimInt(Object o) { Integer val = toInteger(o); if (val == null) - throw new ConvertionException("null values can't be converted to primitive int"); + throw new ConversionException("null values can't be converted to primitive int"); return val; } /** * Converts the provided object to a {@link Double}. * @param o the object to convert. - * @return a the object converted to a {@link Double}. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to a {@link Double}. + * @throws ConversionException is a conversion error occurs. */ public static Double toDouble(Object o) { if (o == null) { @@ -76,7 +76,7 @@ public class TypeConverter { try { return ((JsonElement)o).getAsDouble(); } catch(UnsupportedOperationException e) { - throw new ConvertionException(e); + throw new ConversionException(e); } } @@ -87,35 +87,35 @@ public class TypeConverter { try { return Double.parseDouble((String)o); } catch (NumberFormatException e) { - throw new ConvertionException(e); + throw new ConversionException(e); } } if (o instanceof Boolean) { return ((Boolean)o) ? 1d : 0d; } - throw new ConvertionException("No double convertion available for an instance of "+o.getClass()); + throw new ConversionException("No double conversion available for an instance of "+o.getClass()); } /** * Converts the provided object to a primitive double. * @param o the object to convert. - * @return a the object converted to a primitive double. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to a primitive double. + * @throws ConversionException is a conversion error occurs. */ public static double toPrimDouble(Object o) { Double val = toDouble(o); if (val == null) - throw new ConvertionException("null values can't converted to primitive int"); + throw new ConversionException("null values can't converted to primitive int"); return val; } /** * Converts the provided object to a {@link String}. * @param o the object to convert. - * @return a the object converted to a {@link String}. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to a {@link String}. + * @throws ConversionException is a conversion error occurs. */ public static String toString(Object o) { if (o == null) { @@ -126,7 +126,7 @@ public class TypeConverter { try { return ((JsonElement)o).getAsString(); } catch(UnsupportedOperationException e) { - throw new ConvertionException(e); + throw new ConversionException(e); } } @@ -134,7 +134,7 @@ public class TypeConverter { return o.toString(); } - throw new ConvertionException("No string convertion available for an instance of "+o.getClass()); + throw new ConversionException("No string conversion available for an instance of "+o.getClass()); } @@ -144,8 +144,8 @@ public class TypeConverter { * @param mapIntKeys if the String key representing an int should be duplicated as integer type, * which map to the same value as the original String key. For example, if a key is "12" and map * to the object o, an integer key 12 will be added and map to the same object o. - * @return a the object converted to a {@link Map}. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to a {@link Map}. + * @throws ConversionException is a conversion error occurs. */ @SuppressWarnings("unchecked") public static Map toMap(Object o, boolean mapIntKeys) { @@ -186,15 +186,15 @@ public class TypeConverter { return map; } - throw new ConvertionException("No Map convertion available for an instance of "+o.getClass()); + throw new ConversionException("No Map conversion available for an instance of "+o.getClass()); } /** * Converts the provided object to a {@link List}. * @param o the object to convert. - * @return a the object converted to a {@link List}. - * @throws ConvertionException is a conversion error occurs. + * @return the object converted to a {@link List}. + * @throws ConversionException is a conversion error occurs. */ @SuppressWarnings("unchecked") public static List toList(Object o) { @@ -217,7 +217,7 @@ public class TypeConverter { } - throw new ConvertionException("No Map convertion available for an instance of "+o.getClass()); + throw new ConversionException("No Map conversion available for an instance of "+o.getClass()); @@ -225,14 +225,14 @@ public class TypeConverter { /** - * Thrown when a convertion error occurs. + * Thrown when a conversion error occurs. */ - public static class ConvertionException extends RuntimeException { + public static class ConversionException extends RuntimeException { - private ConvertionException(String m) { + private ConversionException(String m) { super(m); } - private ConvertionException(Throwable t) { + private ConversionException(Throwable t) { super(t); } 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 1f7e442..1367ec9 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 @@ -1,8 +1,6 @@ package fr.pandacube.lib.core.mc_version; -import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionUtil.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionUtil.java index 8cb3e62..06c0473 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionUtil.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/MinecraftVersionUtil.java @@ -16,7 +16,7 @@ public class MinecraftVersionUtil { /** * Compare two Minecraft version strings. It uses the rules of semantic - * versionning to compare the versions. + * versioning to compare the versions. * @param v1 the first version to compare. * @param v2 the second version to compare. * @return 0 if they are equal, <0 if v1<v2 and vice-versa. @@ -49,20 +49,20 @@ public class MinecraftVersionUtil { } /** - * Tells if the two provided Minecraft versions are consecutives. + * Tells if the two provided Minecraft versions are consecutive. *

- * Two versions are consecutives if (considering {@code 1.X[.Y]}): + * Two versions are consecutive if (considering {@code 1.X[.Y]}): *

    *
  • They are part of the same main version (X value)
  • *
  • v1 has no Y value, and v2 has Y = 1 (eg. 1.19 and 1.19.1) OR - * both v1 and v2 has a Y value and those values are consecutives. + * both v1 and v2 has a Y value and those values are consecutive. *
  • *
* @param v1 the first version. * @param v2 the second version. * @return thue if the second version is consecutive to the first one. */ - public static boolean areConsecutives(String v1, String v2) { + public static boolean areConsecutive(String v1, String v2) { int[] v1Int = decomposedVersion(v1); int[] v2Int = decomposedVersion(v2); @@ -105,21 +105,21 @@ public class MinecraftVersionUtil { versions = new ArrayList<>(toOrderedSet(versions)); List keptVersions = new ArrayList<>(versions.size()); - for (int i = 0, firstConsec = 0; i < versions.size(); i++) { - if (i == versions.size() - 1 || !areConsecutives(versions.get(i), versions.get(i + 1))) { - if (firstConsec == i) { + for (int i = 0, firstConsecutive = 0; i < versions.size(); i++) { + if (i == versions.size() - 1 || !areConsecutive(versions.get(i), versions.get(i + 1))) { + if (firstConsecutive == i) { keptVersions.add(versions.get(i)); - firstConsec++; + firstConsecutive++; } else { // merge - if (i - firstConsec > 1) - keptVersions.add(versions.get(firstConsec) + "-" + versions.get(i)); + if (i - firstConsecutive > 1) + keptVersions.add(versions.get(firstConsecutive) + "-" + versions.get(i)); else { - keptVersions.add(versions.get(firstConsec)); + keptVersions.add(versions.get(firstConsecutive)); keptVersions.add(versions.get(i)); } - firstConsec = i + 1; + firstConsecutive = i + 1; } } } 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 705c867..5d56754 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 @@ -23,8 +23,8 @@ import java.util.concurrent.atomic.AtomicReference; * The data if fetch updated data from an external API on startup. If it fails, * it uses the data stored in the current package at build time. *

- * The public static methos are used to fetch an instance of {@link ProtocolVersion} - * based on the provided protocol version (eg. 763) or Minecraft version (eg. "1.20.1"). + * The public static methods are used to fetch an instance of {@link ProtocolVersion} + * based on the provided protocol version (e.g. 763) or Minecraft version (e.g. "1.20.1"). * An instance of this class provides information related to a protocol version * (the protocol version number and all the corresponding Minecraft versions). */ @@ -89,15 +89,24 @@ public class ProtocolVersion implements Comparable { Log.warning("Unable to get minecraft version data from API. Using local data instead."); // try local source - try (InputStream is = ProtocolVersion.class.getResourceAsStream("mcversion.json"); - InputStreamReader isr = new InputStreamReader(is)) { - MinecraftVersionList data = Json.gson.fromJson(isr, MinecraftVersionList.class); - versionList.set(data); + try (InputStream is = ProtocolVersion.class.getResourceAsStream("mcversion.json")) { + if (is != null) { + try (InputStreamReader isr = new InputStreamReader(is)) { + MinecraftVersionList data = Json.gson.fromJson(isr, MinecraftVersionList.class); + versionList.set(data); + } + } } catch (Exception e) { - Log.severe("Unable to get Minecraft versions data from classpath. Using empty data instead."); - versionList.set(new MinecraftVersionList()); + Log.warning(e); } + if (versionList.get() != null) { + return; + } + + Log.severe("Unable to get Minecraft versions data from classpath. Using empty data instead."); + + versionList.set(new MinecraftVersionList()); } diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/search/SearchEngine.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/search/SearchEngine.java index 26d7027..888934a 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/search/SearchEngine.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/search/SearchEngine.java @@ -15,7 +15,7 @@ import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; /** - * Utility class to manage searching among a set of {@link SearchResult} instances, using case insensitive keywords. + * Utility class to manage searching among a set of {@link SearchResult} instances, using case-insensitive keywords. * The search engine is responsible for storing a database of entries ({@link SearchResult}) that can be searched using * keywords. This class provides methods to returns a list of results for provided keywords, a list of keyword * suggestions based on pre-typed keywords. diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/DB.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/DB.java index 1dbf94f..db8815e 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/DB.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/DB.java @@ -52,10 +52,10 @@ public final class DB { } /** - * Initialialize the table represented by the provided class. + * Initialize the table represented by the provided class. * @param elemClass the class representing a table. * @param the type representing the table. - * @throws DBInitTableException if the table failed to initialized. + * @throws DBInitTableException if the table failed to initialize. */ public static synchronized > void initTable(Class elemClass) throws DBInitTableException { if (connection == null) { @@ -111,7 +111,7 @@ public final class DB { * @param elemClass the class representing a table. * @return a table name. * @param the type representing the table. - * @throws DBInitTableException if the provided table had to be initialized and it failed to do so. + * @throws DBInitTableException if the provided table had to be initialized and failed to do so. */ public static > String getTableName(Class elemClass) throws DBInitTableException { initTable(elemClass); @@ -130,7 +130,7 @@ public final class DB { * @param elemClass the class representing a table. * @return the {@code id} field of the provided table. * @param the type representing the table. - * @throws DBInitTableException if the provided table had to be initialized and it failed to do so. + * @throws DBInitTableException if the provided table had to be initialized and failed to do so. */ @SuppressWarnings("unchecked") public static > SQLField getSQLIdField(Class elemClass) throws DBInitTableException { @@ -226,8 +226,8 @@ public final class DB { * @throws DBException if an error occurs when interacting with the database. */ public static > E getFirst(Class elemClass, SQLWhere where, SQLOrderBy orderBy, Integer offset) throws DBException { - SQLElementList elts = getAll(elemClass, where, orderBy, 1, offset); - return (elts.size() == 0) ? null : elts.get(0); + SQLElementList elements = getAll(elemClass, where, orderBy, 1, offset); + return (elements.size() == 0) ? null : elements.get(0); } /** @@ -294,15 +294,15 @@ public final class DB { * @throws DBException if an error occurs when interacting with the database. */ public static > SQLElementList getAll(Class elemClass, SQLWhere where, SQLOrderBy orderBy, Integer limit, Integer offset) throws DBException { - SQLElementList elmts = new SQLElementList<>(); - forEach(elemClass, where, orderBy, limit, offset, elmts::add); - return elmts; + SQLElementList elements = new SQLElementList<>(); + forEach(elemClass, where, orderBy, limit, offset, elements::add); + return elements; } /** * Iterate through all the entries from the provided table. * @param elemClass the class representing a table. - * @param action the action to perform on each entries. + * @param action the action to perform on each entry. * @param the type representing the table. * @throws DBException if an error occurs when interacting with the database. */ @@ -314,7 +314,7 @@ public final class DB { * Iterate through the entries from the provided table, using the provided {@code WHERE} clause. * @param elemClass the class representing a table. * @param where the {@code WHERE} clause of the query. - * @param action the action to perform on each entries. + * @param action the action to perform on each entry. * @param the type representing the table. * @throws DBException if an error occurs when interacting with the database. */ @@ -328,7 +328,7 @@ public final class DB { * @param elemClass the class representing a table. * @param where the {@code WHERE} clause of the query. * @param orderBy the {@code ORDER BY} clause of the query. - * @param action the action to perform on each entries. + * @param action the action to perform on each entry. * @param the type representing the table. * @throws DBException if an error occurs when interacting with the database. */ @@ -343,7 +343,7 @@ public final class DB { * @param where the {@code WHERE} clause of the query. * @param orderBy the {@code ORDER BY} clause of the query. * @param limit the {@code LIMIT} clause of the query. - * @param action the action to perform on each entries. + * @param action the action to perform on each entry. * @param the type representing the table. * @throws DBException if an error occurs when interacting with the database. */ @@ -359,7 +359,7 @@ public final class DB { * @param orderBy the {@code ORDER BY} clause of the query. * @param limit the {@code LIMIT} clause of the query. * @param offset the {@code OFFSET} clause of the query. - * @param action the action to perform on each entries. + * @param action the action to perform on each entry. * @param the type representing the table. * @throws DBException if an error occurs when interacting with the database. */ @@ -577,7 +577,7 @@ public final class DB { @SuppressWarnings("unchecked") private static > E getElementInstance(ResultSet set, Class elemClass) throws DBException { try { - E instance = Reflect.ofClass(elemClass).constructor(int.class).instanciate(set.getInt("id")); + E instance = Reflect.ofClass(elemClass).constructor(int.class).instantiate(set.getInt("id")); int fieldCount = set.getMetaData().getColumnCount(); @@ -623,7 +623,7 @@ public final class DB { return instance; } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException | SQLException e) { - throw new DBException("Can't instanciate " + elemClass.getName(), e); + throw new DBException("Can't instantiate " + elemClass.getName(), e); } } diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/DBException.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/DBException.java index 2bbbe70..10a1329 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/DBException.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/DBException.java @@ -1,7 +1,7 @@ package fr.pandacube.lib.db; /** - * Exception thrown when something bad happends when using the {@link DB} API. + * Exception thrown when something bad happens when using the {@link DB} API. */ public class DBException extends Exception { diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/DBInitTableException.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/DBInitTableException.java index 03c6052..a9640e5 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/DBInitTableException.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/DBInitTableException.java @@ -1,7 +1,7 @@ package fr.pandacube.lib.db; /** - * Exception thrown when something bad happends when initializing a new table using {@link DB#initTable(Class)}. + * Exception thrown when something bad happens when initializing a new table using {@link DB#initTable(Class)}. */ public class DBInitTableException extends DBException { diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElement.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElement.java index 5109f4b..cae4a98 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElement.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElement.java @@ -119,7 +119,7 @@ public abstract class SQLElement> { /** * Gets the name of the table in the database, without the prefix defined by {@link DB#init(DBConnection, String)}. - * @return The unprefixed name of the table in the database. + * @return The non-prefixed name of the table in the database. */ protected abstract String tableName(); @@ -133,7 +133,7 @@ public abstract class SQLElement> { } /** - * Fills the values of this entry that are known to be nullable or have a default value. + * Fills the entries values that are known to be nullable or have a default value. */ @SuppressWarnings("unchecked") private void initDefaultValues() { @@ -193,7 +193,7 @@ public abstract class SQLElement> { /** * Sets a value in this entry. *

- * This is not good practice to set the {@code id} field of any entry, because it’s an unique auto-incremented + * This is not good practice to set the {@code id} field of any entry, because it’s a unique auto-incremented * value. Use {@link #save()} and {@link #delete()} to set or unset the {@code id} instead, in consistence with the * database. * @param field the field to set. @@ -255,11 +255,11 @@ public abstract class SQLElement> { } /** - * Gets the foreign table entry targeted by the provided foreignkey of this table. - * @param field a foreignkey of this table. - * @param the type of the foreignkey field. + * Gets the foreign table entry targeted by the provided foreign key of this table. + * @param field a foreign key of this table. + * @param the type of the foreign key field. * @param

the targeted foreign table type. - * @return the foreign table entry targeted by the provided foreignkey of this table. + * @return the foreign table entry targeted by the provided foreign key of this table. * @throws DBException if an error occurs when interacting with the database. */ public > P getReferencedEntry(SQLFKField field) throws DBException { @@ -271,11 +271,11 @@ public abstract class SQLElement> { /** * Gets the original table entry which the provided foreign key is targeting this entry, and following the provided * {@code ORDER BY}, {@code LIMIT} and {@code OFFSET} clauses. - * @param field a foreignkey in the original table. + * @param field a foreign key in the original table. * @param orderBy the {@code ORDER BY} clause of the query. * @param limit the {@code LIMIT} clause of the query. * @param offset the {@code OFFSET} clause of the query. - * @param the type of the foreignkey field. + * @param the type of the foreign key field. * @param the table class of the foreign key that reference a field of this entry. * @return the original table entry which the provided foreign key is targeting this entry. * @throws DBException if an error occurs when interacting with the database. @@ -314,7 +314,7 @@ public abstract class SQLElement> { /** * Saves this entry into the database, either by updating the already existing entry in it, or by creating a new - * entry if it doesn’t exist yet. + * entry if it doesn't exist yet. * @return this. * @throws DBException if an error occurs when interacting with the database. */ @@ -474,14 +474,14 @@ public abstract class SQLElement> { * Creates a new SQL field. * @param type the type of the field. * @param nullable true if nullable, false if {@code NOT NULL}. - * @param autoIncr if {@code AUTO_INCREMENT}. + * @param autoIncrement if {@code AUTO_INCREMENT}. * @param deflt a default value for this field. A null value indicate that this has no default value. * @return the new SQL field. * @param the table type. * @param the Java type of this field. */ - protected static , T> SQLField field(SQLType type, boolean nullable, boolean autoIncr, T deflt) { - return new SQLField<>(type, nullable, autoIncr, deflt); + protected static , T> SQLField field(SQLType type, boolean nullable, boolean autoIncrement, T deflt) { + return new SQLField<>(type, nullable, autoIncrement, deflt); } /** @@ -500,13 +500,13 @@ public abstract class SQLElement> { * Creates a new SQL field. * @param type the type of the field. * @param nullable true if nullable, false if {@code NOT NULL}. - * @param autoIncr if {@code AUTO_INCREMENT}. + * @param autoIncrement if {@code AUTO_INCREMENT}. * @return the new SQL field. * @param the table type. * @param the Java type of this field. */ - protected static , T> SQLField field(SQLType type, boolean nullable, boolean autoIncr) { - return new SQLField<>(type, nullable, autoIncr); + protected static , T> SQLField field(SQLType type, boolean nullable, boolean autoIncrement) { + return new SQLField<>(type, nullable, autoIncrement); } /** diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java index 889b101..a20252d 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java @@ -46,7 +46,7 @@ public class SQLElementList> extends ArrayList { E emptyElement = elemClass.getConstructor().newInstance(); emptyElement.set(field, value, false); } catch (Exception e) { - throw new IllegalArgumentException("Illegal field or value or can't instanciante an empty instance of " + throw new IllegalArgumentException("Illegal field or value or can't instantiate an empty instance of " + elemClass.getName() + ". (the instance is only created to test validity of field and value)", e); } @@ -83,7 +83,7 @@ public class SQLElementList> extends ArrayList { @SuppressWarnings("unchecked") private void applyNewValuesToElements(List storedEl) { - // applique les valeurs dans chaques objets de la liste + // applique les valeurs dans chaque objet de la liste for (E el : storedEl) { for (@SuppressWarnings("rawtypes") SQLField entry : modifiedValues.keySet()) { if (!el.isModified(entry)) { @@ -100,7 +100,7 @@ public class SQLElementList> extends ArrayList { /** * Removes all the entries of this list from the database. * This method has the same effect as calling the {@link SQLElement#delete()} method individually on each element, - * but with only one SQL query to delete all of the entries. + * but with only one SQL query to delete all the entries. *

* If you intend to remove the entries from the database just after fetching them, call directly the * {@link DB#delete(Class, SQLWhere)} method instead. @@ -124,9 +124,9 @@ public class SQLElementList> extends ArrayList { /** * Get all the entries targeted by the foreign key of all the entries in this list. - * @param foreignKey a foreignkey of this table. + * @param foreignKey a foreign key of this table. * @param orderBy the {@code ORDER BY} clause of the query. - * @return a list of foreign table entries targeted by the provided foreignkey of this table. + * @return a list of foreign table entries targeted by the provided foreign key of this table. * @param the field’s Java type. * @param

the target table type. * @throws DBException if an error occurs when interacting with the database. @@ -144,7 +144,7 @@ public class SQLElementList> extends ArrayList { /** * Get all the entries targeted by the foreign key of all the entries in this list, mapped from the foreign key value. - * @param foreignKey a foreignkey of this table. + * @param foreignKey a foreign key of this table. * @return a map of the foreign key values, mapped to the foreign table’s entries. * @param the field’s Java type. * @param

the target table type. @@ -163,11 +163,11 @@ public class SQLElementList> extends ArrayList { /** * Gets all the original table’s entries which the provided foreign key is targeting the entries of this list, and * following the provided {@code ORDER BY}, {@code LIMIT} and {@code OFFSET} clauses. - * @param foreignKey a foreignkey in the original table. + * @param foreignKey a foreign key in the original table. * @param orderBy the {@code ORDER BY} clause of the query. * @param limit the {@code LIMIT} clause of the query. * @param offset the {@code OFFSET} clause of the query. - * @param the type of the foreignkey field. + * @param the type of the foreign key field. * @param the table class of the foreign key that reference a field of this entry. * @return the original table’s entries which the provided foreign key is targeting the entries of this list. * @throws DBException if an error occurs when interacting with the database. @@ -187,11 +187,11 @@ public class SQLElementList> extends ArrayList { * Gets all the original table’s entries which the provided foreign key is targeting the entries of this list, * following the provided {@code ORDER BY}, {@code LIMIT} and {@code OFFSET} clauses, and mapped from the foreign * key value. - * @param foreignKey a foreignkey in the original table. + * @param foreignKey a foreign key in the original table. * @param orderBy the {@code ORDER BY} clause of the query. * @param limit the {@code LIMIT} clause of the query. * @param offset the {@code OFFSET} clause of the query. - * @param the type of the foreignkey field. + * @param the type of the foreign key field. * @param the table class of the foreign key that reference a field of this entry. * @return a map of the foreign key values, mapped to the orignal table’s entries. * @throws DBException if an error occurs when interacting with the database. diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLFKField.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLFKField.java index 87d2d87..5f49458 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLFKField.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLFKField.java @@ -28,7 +28,7 @@ public class SQLFKField, T, P extends SQLElement

> ext SQLField f = DB.getSQLIdField(fkEl); return new SQLFKField<>(f.type, nul, deflt, fkEl, f); } catch (DBInitTableException e) { - Log.severe("Can't create Foreign key Field targetting id field of '"+fkEl+"'", e); + Log.severe("Can't create Foreign key Field targeting id field of '"+fkEl+"'", e); return null; } } @@ -51,7 +51,7 @@ public class SQLFKField, T, P extends SQLElement

> ext } if (fkF.getSQLElementType() == null) - throw new RuntimeException("Can't initialize foreign key. The primary key in the table " + fkEl.getName() + " is not properly initialized and can't be targetted by a forein key"); + throw new RuntimeException("Can't initialize foreign key. The primary key in the table " + fkEl.getName() + " is not properly initialized and can't be targeted by a foreign key"); sqlPrimaryKeyField = fkF; sqlForeignKeyElemClass = fkEl; } diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLField.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLField.java index ee923e6..061dc1a 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLField.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLField.java @@ -24,10 +24,10 @@ public class SQLField, T> { /* package */ final boolean autoIncrement; /* package */ final T defaultValue; - /* package */ SQLField(SQLType type, boolean nullable, boolean autoIncr, T deflt) { + /* package */ SQLField(SQLType type, boolean nullable, boolean autoIncrement, T deflt) { this.type = type; this.nullable = nullable; - autoIncrement = autoIncr; + this.autoIncrement = autoIncrement; defaultValue = deflt; } @@ -35,8 +35,8 @@ public class SQLField, T> { this(type, nullable, false, null); } - /* package */ SQLField(SQLType type, boolean nullable, boolean autoIncr) { - this(type, nullable, autoIncr, null); + /* package */ SQLField(SQLType type, boolean nullable, boolean autoIncrement) { + this(type, nullable, autoIncrement, null); } /* package */ SQLField(SQLType type, boolean nullable, T deflt) { diff --git a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/client/ResponseAnalyser.java b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/client/ResponseAnalyser.java index 1ab5f99..36f2c6a 100644 --- a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/client/ResponseAnalyser.java +++ b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/client/ResponseAnalyser.java @@ -18,7 +18,7 @@ public class ResponseAnalyser { if (socket == null || socket.isClosed() || socket.isInputShutdown()) throw new IllegalArgumentException("le socket doit être non null et doit être ouvert sur le flux d'entrée"); - // on lis la réponse + // on lit la réponse BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String line; diff --git a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/AbstractRequestExecutor.java b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/AbstractRequestExecutor.java index bfb81b0..b52acad 100644 --- a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/AbstractRequestExecutor.java +++ b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/AbstractRequestExecutor.java @@ -11,9 +11,9 @@ public abstract class AbstractRequestExecutor { public final String command; - public AbstractRequestExecutor(String cmd, NetworkAPIListener napiListener) { + public AbstractRequestExecutor(String cmd, NetworkAPIListener nAPIListener) { command = cmd.toLowerCase(); - napiListener.registerRequestExecutor(command, this); + nAPIListener.registerRequestExecutor(command, this); } public void execute(String data, Socket socket) throws IOException { @@ -34,9 +34,8 @@ public abstract class AbstractRequestExecutor { /** * - * @param data La représentation sous forme de String des données envoyés - * dans la requête - * @return La réponse à retourner au client + * @param data The String representation of the request data. + * @return The response to send back to the client. */ protected abstract Response run(InetAddress source, String data); diff --git a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/NetworkAPIListener.java b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/NetworkAPIListener.java index db853d0..697ebae 100644 --- a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/NetworkAPIListener.java +++ b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/NetworkAPIListener.java @@ -18,7 +18,7 @@ public class NetworkAPIListener implements Runnable { private final String name; /** - * Instencie le côté serveur du NetworkAPI. + * Instancie le côté serveur du NetworkAPI. * * @param n nom du networkAPI (permet l'identification dans les logs) * @param p le port d'écoute @@ -29,7 +29,7 @@ public class NetworkAPIListener implements Runnable { } /** - * Instencie le côté serveur du NetworkAPI. + * Instancie le côté serveur du NetworkAPI. * * @param n nom du networkAPI (permet l'identification dans les logs) * @param p le port d'écoute @@ -56,7 +56,6 @@ public class NetworkAPIListener implements Runnable { Log.info("NetworkAPI '" + name + "' à l'écoute sur le socket " + serverSocket.getLocalSocketAddress()); try { - // réception des connexion client while (!serverSocket.isClosed()) { Thread t = new Thread(new PacketExecutor(serverSocket.accept(), this)); t.setDaemon(true); diff --git a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/PacketExecutor.java b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/PacketExecutor.java index 4005d60..85cb8c3 100644 --- a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/PacketExecutor.java +++ b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/PacketExecutor.java @@ -20,9 +20,9 @@ public class PacketExecutor implements Runnable { private final Socket socket; private final NetworkAPIListener networkAPIListener; - public PacketExecutor(Socket s, NetworkAPIListener napiListener) { + public PacketExecutor(Socket s, NetworkAPIListener nAPIListener) { socket = s; - networkAPIListener = napiListener; + networkAPIListener = nAPIListener; } @Override diff --git a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/RequestAnalyser.java b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/RequestAnalyser.java index 65a74f1..51c29d5 100644 --- a/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/RequestAnalyser.java +++ b/pandalib-netapi/src/main/java/fr/pandacube/lib/netapi/server/RequestAnalyser.java @@ -10,23 +10,23 @@ public class RequestAnalyser { public final String command; public final String data; - public RequestAnalyser(Socket socket, NetworkAPIListener napiListener) throws IOException, BadRequestException { - if (socket == null || socket.isClosed() || socket.isInputShutdown() || napiListener == null) + public RequestAnalyser(Socket socket, NetworkAPIListener nAPIListener) throws IOException, BadRequestException { + if (socket == null || socket.isClosed() || socket.isInputShutdown() || nAPIListener == null) throw new IllegalArgumentException( - "le socket doit être non null et doit être ouvert sur le flux d'entrée et napiListener ne doit pas être null"); + "le socket doit être non null et doit être ouvert sur le flux d'entrée et nAPIListener ne doit pas être null"); - // on lis la réponse + // on lit la réponse BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String line; // lecture de la première ligne line = in.readLine(); - if (line == null || !line.equals(napiListener.pass)) throw new BadRequestException("wrong_password"); + if (line == null || !line.equals(nAPIListener.pass)) throw new BadRequestException("wrong_password"); // lecture de la deuxième ligne line = in.readLine(); - if (line == null || napiListener.getRequestExecutor(line) == null) + if (line == null || nAPIListener.getRequestExecutor(line) == null) throw new BadRequestException("command_not_exists"); command = line; diff --git a/pandalib-paper-permissions/pom.xml b/pandalib-paper-permissions/pom.xml index 35d89c4..8580be0 100644 --- a/pandalib-paper-permissions/pom.xml +++ b/pandalib-paper-permissions/pom.xml @@ -25,7 +25,7 @@ https://maven.enginehub.org/repo/ - + jitpack.io https://jitpack.io @@ -33,12 +33,12 @@ - + fr.pandacube.lib pandalib-permissions diff --git a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java index cd7e0f4..5db68d5 100644 --- a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java +++ b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java @@ -42,7 +42,7 @@ public class PandalibPaperPermissions implements Listener { * Integrates the {@code pandalib-permissions} system into the Bukkit server. * @param plugin a Bukkit plugin. * @param serverName the name of the current server, used to fetch server specific permissions. Cannot be null. - * If this server in not in a multi-server configuration, use a dummy server name, like + * If this server in not in a multiserver configuration, use a dummy server name, like * {@code ""} (empty string). */ public static void init(JavaPlugin plugin, String serverName) { diff --git a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java index 44d78ae..5bf5b1a 100644 --- a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java +++ b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java @@ -1,5 +1,23 @@ package fr.pandacube.lib.paper.permissions; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import fr.pandacube.lib.permissions.Permissions; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.util.Log; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.entity.Player; +import org.bukkit.permissions.Permissible; +import org.bukkit.permissions.PermissibleBase; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + import java.lang.reflect.Field; import java.util.HashMap; import java.util.LinkedHashSet; @@ -11,24 +29,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Collectors; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.entity.Player; -import org.bukkit.permissions.Permissible; -import org.bukkit.permissions.PermissibleBase; -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; -import org.bukkit.plugin.Plugin; - -import fr.pandacube.lib.permissions.Permissions; -import fr.pandacube.lib.reflect.Reflect; -import fr.pandacube.lib.util.Log; - /* package */ class PermissionsInjectorBukkit { @@ -58,26 +58,24 @@ import fr.pandacube.lib.util.Log; } } - private static void setPermissible(CommandSender sender, Permissible newpermissible) + private static void setPermissible(CommandSender sender, Permissible newPermissible) { try { Field perm = getPermField(sender); if (perm == null) return; perm.setAccessible(true); - perm.set(sender, newpermissible); + perm.set(sender, newPermissible); } catch (Exception e) { - Log.severe(e); + throw new RuntimeException(e); } } /* package */ static Permissible getPermissible(CommandSender sender) { - Field perm = getPermField(sender); - if (perm == null) - return null; try { + Field perm = getPermField(sender); perm.setAccessible(true); Permissible p = (Permissible) perm.get(sender); if (p == null) { @@ -86,26 +84,19 @@ import fr.pandacube.lib.util.Log; return p; } catch (Exception e) { - Log.severe(e); + throw new RuntimeException(e); } - return null; } - private static Field getPermField(CommandSender sender) - { + private static Field getPermField(CommandSender sender) throws NoSuchFieldException { if (sender == null) { throw new IllegalArgumentException("sender cannot be null"); } - try { - if (sender instanceof Player || sender instanceof ConsoleCommandSender) - return Reflect.ofClassOfInstance(sender).field("perm").get(); - else - throw new IllegalArgumentException("Unsupported type for sender: " + sender.getClass()); - } - catch (Exception e) { - Log.severe(e); - } - return null; + if (sender instanceof Player || sender instanceof ConsoleCommandSender) + return Reflect.ofClassOfInstance(sender).field("perm").get(); + else + throw new IllegalArgumentException("Unsupported type for sender: " + sender.getClass()); + } /* package */ static class PandaPermissible extends PermissibleBase @@ -118,7 +109,7 @@ import fr.pandacube.lib.util.Log; @SuppressWarnings("UnusedAssignment") private boolean init = false; - /* assigment to false is necessary because of super class constructor calling the method recalculatePermission() + /* assignment to false is necessary because of super class constructor calling the method recalculatePermission() * and we don’t want that. */ @@ -143,7 +134,7 @@ import fr.pandacube.lib.util.Log; public boolean hasPermission(String permission) { /* - * WARNING: don’t call PermissibleOnlinePlayer#hasPermission(String) here or it will result on a stack overflow + * WARNING: don’t call PermissibleOnlinePlayer#hasPermission(String) here, or it will result on a stack overflow */ if (permission.toLowerCase().startsWith("minecraft.command.")) @@ -180,7 +171,7 @@ import fr.pandacube.lib.util.Log; if (res != null) return res; - return oldPermissible.hasPermission(permission); // doesn’t need to manage negative permission (should not happend) + return oldPermissible.hasPermission(permission); // doesn't need to manage negative permission (should not happen) } @Override @@ -214,36 +205,34 @@ import fr.pandacube.lib.util.Log; .build(); @Override - public Set getEffectivePermissions() + public @NotNull Set getEffectivePermissions() { // PlotSquared uses this method to optimize permission range (plots.limit.10 for example) // MobArena uses this method when a player leave the arena // LibsDisguises uses this method (and only this one) to parse all the permissions - - //Log.warning("There is a plugin calling CommandSender#getEffectivePermissions(). See the stacktrace to understand the reason for that.", new Throwable()); - String world = null; if (sender instanceof Player player) { - world = player.getWorld().getName(); + String world = player.getWorld().getName(); + try { + return effectivePermissionsListCache.get(world, () -> { + // first get the superperms effective permissions (that take isOp into account) + Map perms = oldPermissible.getEffectivePermissions().stream() + .collect(Collectors.toMap(PermissionAttachmentInfo::getPermission, Function.identity())); + + // then override them with the permissions from our permission system (that has priority, and take current world into account) + for (Map.Entry permE : getEffectivePermissionsOnServerInWorld().entrySet()) { + perms.put(permE.getKey(), new PermissionAttachmentInfo(this, permE.getKey(), null, permE.getValue())); + } + + return new LinkedHashSet<>(perms.values()); + }); + } catch (ExecutionException e) { + Log.severe(e); + } } - try { - return effectivePermissionsListCache.get(world, () -> { - // first get the superperms effective permissions (taht take isOp into accound) - Map perms = oldPermissible.getEffectivePermissions().stream() - .collect(Collectors.toMap(PermissionAttachmentInfo::getPermission, Function.identity())); - - // then override them with the permissions from our permission system (that has priority, and take current world into account) - for (Map.Entry permE : getEffectivePermissionsOnServerInWorld().entrySet()) { - perms.put(permE.getKey(), new PermissionAttachmentInfo(this, permE.getKey(), null, permE.getValue())); - } - - return new LinkedHashSet<>(perms.values()); - }); - } catch (ExecutionException e) { - Log.severe(e); - return oldPermissible.getEffectivePermissions(); - } + + return oldPermissible.getEffectivePermissions(); } @@ -260,7 +249,7 @@ import fr.pandacube.lib.util.Log; } @Override - public boolean isPermissionSet(String permission) + public boolean isPermissionSet(@NotNull String permission) { Boolean res = hasPermissionOnServerInWorld(permission); if (res != null) @@ -278,31 +267,31 @@ import fr.pandacube.lib.util.Log; } @Override - public PermissionAttachment addAttachment(Plugin plugin) + public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin) { return oldPermissible.addAttachment(plugin); } @Override - public PermissionAttachment addAttachment(Plugin plugin, int ticks) + public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { return oldPermissible.addAttachment(plugin, ticks); } @Override - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) + public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { return oldPermissible.addAttachment(plugin, name, value); } @Override - public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) + public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { return oldPermissible.addAttachment(plugin, name, value, ticks); } @Override - public void removeAttachment(PermissionAttachment attachment) + public void removeAttachment(@NotNull PermissionAttachment attachment) { oldPermissible.removeAttachment(attachment); } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperBackupConfig.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperBackupConfig.java index 5912444..20aeb9d 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperBackupConfig.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperBackupConfig.java @@ -6,11 +6,12 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +@SuppressWarnings("CanBeFinal") public class PaperBackupConfig { public boolean worldBackupEnabled = true; public boolean workdirBackupEnabled = true; public boolean logsBackupEnabled = true; - public String scheduling = "0 2 * * *"; // cron format, here is everyday at 2am + public String scheduling = "0 2 * * *"; // cron format, here is every day at 2am public File backupDirectory = null; public BackupCleaner worldBackupCleaner = BackupCleaner.KEEPING_1_EVERY_N_MONTH(3).merge(BackupCleaner.KEEPING_N_LAST(5)); public BackupCleaner workdirBackupCleaner = BackupCleaner.KEEPING_1_EVERY_N_MONTH(3).merge(BackupCleaner.KEEPING_N_LAST(5)); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorkdirProcess.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorkdirProcess.java index 397dbce..01c5155 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorkdirProcess.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorkdirProcess.java @@ -1,10 +1,6 @@ package fr.pandacube.lib.paper.backup; -import fr.pandacube.lib.util.Log; - import java.io.File; -import java.text.DateFormat; -import java.util.Date; import java.util.function.BiPredicate; public class PaperWorkdirProcess extends PaperBackupProcess { @@ -15,17 +11,14 @@ public class PaperWorkdirProcess extends PaperBackupProcess { public BiPredicate getFilenameFilter() { - return new BiPredicate() { - @Override - public boolean test(File file, String path) { - if (file.isDirectory() && new File(file, "level.dat").exists()) - return false; - if (new File(getSourceDir(), "logs").equals(file)) - return false; - if (file.isFile() && file.getName().endsWith(".lck")) - return false; - return PaperWorkdirProcess.super.getFilenameFilter().test(file, path); - } + return (file, path) -> { + if (file.isDirectory() && new File(file, "level.dat").exists()) + return false; + if (new File(getSourceDir(), "logs").equals(file)) + return false; + if (file.isFile() && file.getName().endsWith(".lck")) + return false; + return PaperWorkdirProcess.super.getFilenameFilter().test(file, path); }; } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorldProcess.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorldProcess.java index 724f59c..da18c34 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorldProcess.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/backup/PaperWorldProcess.java @@ -10,7 +10,6 @@ import org.bukkit.World; import java.io.File; import java.text.DateFormat; import java.util.Date; -import java.util.function.BiPredicate; public class PaperWorldProcess extends PaperBackupProcess { private final String worldName; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java index 504d0f9..99927d4 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java @@ -77,7 +77,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand registeredAliases; /** - * Instanciate this command instance. + * Instantiate this command instance. * * @param pl the plugin instance. * @param regPolicy the registration policy for this command. @@ -155,7 +155,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand nmsConflited = root.getChild(name); - if (nmsConflited != null) { + CommandNode nmsConflicted = root.getChild(name); + if (nmsConflicted != null) { - if (isFromThisCommand(nmsConflited)) { + if (isFromThisCommand(nmsConflicted)) { // this command is already registered in NMS. Don’t need to register again nmsRegistered = true; } @@ -221,7 +221,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand TAB_PLAYER_CURRENT_SERVER = (sender, ti, token, a) -> { @SuppressWarnings("unchecked") @@ -432,7 +432,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand TAB_WORLDS = SuggestionsSupplier.fromStreamSupplier(() -> Bukkit.getWorlds().stream().map(World::getName)); @@ -477,7 +477,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand context, String argument, BlockVector deflt) { - return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(), nmsCoord -> { - BlockPos bp = ReflectWrapper.wrap(nmsCoord, Coordinates.class).getBlockPos(context.getSource()); + return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(), nmsCoordinate -> { + BlockPos bp = ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getBlockPos(context.getSource()); return new BlockVector(bp.getX(), bp.getY(), bp.getZ()); }, deflt); } @@ -603,14 +603,14 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand context, String argument, Vector deflt) { return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(), - nmsCoord -> CraftVector.toBukkit( - ReflectWrapper.wrap(nmsCoord, Coordinates.class).getPosition(context.getSource()) + nmsCoordinate -> CraftVector.toBukkit( + ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getPosition(context.getSource()) ), deflt); } @@ -630,7 +630,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand context, diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIHotBar.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIHotBar.java index a5fcb72..6d58727 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIHotBar.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIHotBar.java @@ -24,36 +24,36 @@ import fr.pandacube.lib.util.Log; import fr.pandacube.lib.paper.util.BukkitEvent; /** - * Managed a « lobby » type hotbar menu/inventory. It represents items in the player inventory on which you can right click on it. + * Managed a "lobby" type hot bar menu/inventory. It represents items in the + * player inventory on which you can right-click on it. * The player can't move or drop these items. - * */ public class GUIHotBar implements Listener { private final Map> itemsAndSetters = new HashMap<>(); - private final Map> itemsAndRunnables = new HashMap<>(); + private final Map> itemsAndClickListeners = new HashMap<>(); - private final int defltSlot; + private final int defaultSlot; private final List currentPlayers = new ArrayList<>(); public GUIHotBar(int defaultSlot) { - defltSlot = Math.max(0, Math.min(8, defaultSlot)); + this.defaultSlot = Math.max(0, Math.min(8, defaultSlot)); BukkitEvent.register(this); } /** - * Add the item to this hotbar menu. if there is already players hooked to this hotbar, the item will be directly added to + * Add the item to this hot bar menu. if there is already players hooked to this hot bar, the item will be directly added to * their inventories. * @param i the item stack - * @param setter code executed to put the item in the inventory. Additionally check for permission before doing the addition. - * @param run the Runnable to run when the user right click on the item in the hotbar. + * @param setter code executed to put the item in the inventory. Additionally, check for permission before doing the addition. + * @param run the Runnable to run when the user right-click on the item in the hot bar. */ public GUIHotBar addItem(ItemStack i, BiConsumer setter, Consumer run) { itemsAndSetters.put(i, setter); - itemsAndRunnables.put(i, run); + itemsAndClickListeners.put(i, run); for (Player p : currentPlayers) addItemToPlayer(p, i); @@ -62,9 +62,9 @@ public class GUIHotBar implements Listener { } /** - * Add the hotbar elements to this player. + * Add the hot bar elements to this player. * - * The players is automatically removed when they quit. You can remove it before by calling {@link #removePlayer(Player)}. + * The player is automatically removed when they quit. You can remove it before by calling {@link #removePlayer(Player)}. */ public void addPlayer(Player p) { if (!currentPlayers.contains(p)) @@ -74,11 +74,11 @@ public class GUIHotBar implements Listener { addItemToPlayer(p, is); } - p.getInventory().setHeldItemSlot(defltSlot); + p.getInventory().setHeldItemSlot(defaultSlot); } /** - * Detach this player from this hotbar manager and removes the managed items from the players inventory. + * Detach this player from this hot bar manager and removes the managed items from the players inventory. */ public void removePlayer(Player p) { if (!currentPlayers.contains(p)) @@ -110,9 +110,9 @@ public class GUIHotBar implements Listener { public void addItemToPlayer(Player p, ItemStack is) { if (!itemsAndSetters.containsKey(is)) - throw new IllegalArgumentException("The provided ItemStack is not registered in this HotbarMenu"); + throw new IllegalArgumentException("The provided ItemStack is not registered in this GUIHotBar"); if (!currentPlayers.contains(p)) - throw new IllegalArgumentException("The provided Player is not registered in this HotbarMenu"); + throw new IllegalArgumentException("The provided Player is not registered in this GUIHotBar"); itemsAndSetters.get(is).accept(p.getInventory(), is.clone()); } @@ -153,10 +153,10 @@ public class GUIHotBar implements Listener { Player p = event.getPlayer(); - for (ItemStack is : itemsAndRunnables.keySet()) { + for (ItemStack is : itemsAndClickListeners.keySet()) { if (item.isSimilar(is)) { try { - itemsAndRunnables.get(is).accept(p); + itemsAndClickListeners.get(is).accept(p); } catch (Exception e) { Log.severe(e); } @@ -181,7 +181,7 @@ public class GUIHotBar implements Listener { for (ItemStack is : itemsAndSetters.keySet()) { if (item != null && item.isSimilar(is)) { try { - itemsAndRunnables.get(is).accept((Player) inv.getHolder()); + itemsAndClickListeners.get(is).accept((Player) inv.getHolder()); } catch (Exception e) { Log.severe(e); } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIInventory.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIInventory.java index 27d89cd..a453a6f 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIInventory.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/gui/GUIInventory.java @@ -31,7 +31,7 @@ public class GUIInventory implements Listener { /** * Used as parameter of {@link #buildButton(ItemStack, Integer, ComponentLike, List, Map)} to indicate that a button should - * shine like an enchanted object, without showing enchant informations in the hover text. + * shine like an enchanted object, without showing enchant information in the hover text. */ public static final Map FAKE_ENCHANT = ImmutableMap.of(Enchantment.DURABILITY, 1); @@ -44,7 +44,7 @@ public class GUIInventory implements Listener { /** * Create a new inventory based GUI. * @param p the player for which to create the GUI. - * @param nbLines the number of invotory lines for the interface. + * @param nbLines the number of inventory lines for the interface. * @param title the title of the GUI (title of the inventory) * @param closeEventAction the action to perform when the player closes the GUI inventory */ @@ -73,7 +73,7 @@ public class GUIInventory implements Listener { * @param p the slot index. * @param iStack the item to put in the slot. * @param clickEventActions the action to perform when the user clicks that button. The event passed as a parameter - * is already cancelled. It is possible to uncancel it if needed. + * is already cancelled. It is possible to un-cancel it if needed. */ public void setButtonIfEmpty(int p, ItemStack iStack, Consumer clickEventActions) { if (inv.getItem(p) == null) @@ -85,7 +85,7 @@ public class GUIInventory implements Listener { * @param p the slot index. * @param iStack the item to put in the slot. * @param clickEventActions the action to perform when the user clicks that button. The event passed as a parameter - * is already cancelled. It is possible to uncancel it if needed. + * is already cancelled. It is possible to un-cancel it if needed. */ public void setButton(int p, ItemStack iStack, Consumer clickEventActions) { inv.setItem(p, iStack); @@ -96,7 +96,7 @@ public class GUIInventory implements Listener { * Update/replace the action to perform for a specific slot. * @param p the slot index. * @param clickEventActions the action to perform when the user clicks that button. The event passed as a parameter - * is already cancelled. It is possible to uncancel it if needed. + * is already cancelled. It is possible to un-cancel it if needed. */ public void changeClickEventAction(int p, Consumer clickEventActions) { onClickEvents.put(p, clickEventActions); @@ -122,7 +122,7 @@ public class GUIInventory implements Listener { /** * Force this GUI to be closes, without the intervention of the player. - * The bukkit API will call the {@link InventoryCloseEvent}, trigerring eventual actions associated with this event. + * The bukkit API will call the {@link InventoryCloseEvent}, triggering eventual actions associated with this event. */ public void forceClose() { if (!isOpened) return; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/json/ItemStackAdapter.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/json/ItemStackAdapter.java index d8d3f58..a8f7a06 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/json/ItemStackAdapter.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/json/ItemStackAdapter.java @@ -28,10 +28,11 @@ import java.util.Map; Map deserializedMap = context.deserialize(json, MAP_STR_OBJ_TYPE.getType()); int itemStackVersion = deserializedMap.containsKey("v") ? ((Number)deserializedMap.get("v")).intValue() : -1; if (itemStackVersion >= 0) { + @SuppressWarnings("deprecation") int currentDataVersion = Bukkit.getUnsafe().getDataVersion(); if (itemStackVersion > currentDataVersion) { /* The itemStack we are deserializing is from a newer MC version, so Bukkit will refuse it. - * We decide to ignore the provided version and consider that the received itemstack is from current + * We decide to ignore the provided version and consider that the received item stack is from current * version. We let Bukkit handles the deserialization with the data it can interpret, throwing an error * only if it can't. */ diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/modules/PerformanceAnalysisManager.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/modules/PerformanceAnalysisManager.java index ef0bb77..11f2a63 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/modules/PerformanceAnalysisManager.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/modules/PerformanceAnalysisManager.java @@ -28,7 +28,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -57,7 +56,7 @@ public class PerformanceAnalysisManager implements Listener { } - private static final int NB_TICK_HISTORY = 20 * 60 * 60; // 60 secondes; + private static final int NB_TICK_HISTORY = 20 * 60 * 60; // 60 secondes ; private final Plugin plugin = PandaLibPaper.getPlugin(); private long firstRecord = 0; @@ -292,7 +291,7 @@ public class PerformanceAnalysisManager implements Listener { } else { - String tps1sDisp = Double.isNaN(tps1s) ? "N/A" : (Math.round(tps1s)) + ""; + String tps1sDisplay = Double.isNaN(tps1s) ? "N/A" : (Math.round(tps1s)) + ""; int[] tpsHistory = getTPSHistory(); @@ -319,7 +318,7 @@ public class PerformanceAnalysisManager implements Listener { // we have a lag spike, so we need to display the time since lagging long lagDurationSec = System.nanoTime() - tickEndNanoTime; timings = text("(") - .thenFailure("lag:" + dispRound10(lagDurationSec / (double) 1_000_000_000) + "s") + .thenFailure("lag:" + displayRound10(lagDurationSec / (double) 1_000_000_000) + "s") .thenText(")"); } else { @@ -359,7 +358,7 @@ public class PerformanceAnalysisManager implements Listener { title = infoText("TPS [") .thenLegacyText(s.toString()) .thenText("] ") - .then(text(tps1sDisp+"/20 ").color(tps1sGradient.pickColorAt(tps1s))) + .then(text(tps1sDisplay+"/20 ").color(tps1sGradient.pickColorAt(tps1s))) .then(timings); } @@ -469,7 +468,7 @@ public class PerformanceAnalysisManager implements Listener { Log.info(finalMessage.getLegacyText()); } - public static String dispRound10(double val) { + public static String displayRound10(double val) { long v = (long) Math.ceil(val * 10); return "" + (v / 10f); } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOffPlayer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOffPlayer.java index 2b17922..743f84f 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOffPlayer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOffPlayer.java @@ -1,6 +1,5 @@ package fr.pandacube.lib.paper.players; -import com.google.common.io.Files; import fr.pandacube.lib.paper.reflect.util.PrimaryWorlds; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer; import fr.pandacube.lib.paper.reflect.wrapper.dataconverter.MCDataConverter; @@ -21,6 +20,7 @@ import org.bukkit.scoreboard.Team; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.function.UnaryOperator; /** @@ -76,7 +76,7 @@ public interface PaperOffPlayer extends AbstractOffPlayer { * @return the display name of the player. * * @implNote This default implementation gets the display name from bukkit (if the player is online). - * If its different to the player name, it returns it. Otherwise, it tries to generate the team displayname with {@link #getTeamDisplayName()}. + * If it's different to the player name, it returns it. Otherwise, it tries to generate the team display name with {@link #getTeamDisplayName()}. * If the player is not in a team, then the player name is used. */ @Override @@ -84,16 +84,16 @@ public interface PaperOffPlayer extends AbstractOffPlayer { String name = getName(); Player p = getBukkitPlayer(); @SuppressWarnings("deprecation") - String bukkitDispName = p != null ? p.getDisplayName() : name; - if (!name.equals(bukkitDispName)) - return bukkitDispName; - String teamDispName = getTeamDisplayName(); - return teamDispName == null ? name : teamDispName; + String bukkitDisplayName = p != null ? p.getDisplayName() : name; + if (!name.equals(bukkitDisplayName)) + return bukkitDisplayName; + String teamDisplayName = getTeamDisplayName(); + return teamDisplayName == null ? name : teamDisplayName; } /** - * Computes and returns the the name of the player with the prefix, suffix and color of the team the player is in. - * @return The legacy formated player display name, if he is in a {@link Team}, or null otherwise. + * Computes and returns the name of the player with the prefix, suffix and color of the team the player is in. + * @return The legacy formatted player display name, if he is in a {@link Team}, or null otherwise. */ default String getTeamDisplayName() { String name = getName(); @@ -151,10 +151,10 @@ public interface PaperOffPlayer extends AbstractOffPlayer { */ /** - * Gets the NBT data from the playerdata file. + * Gets the NBT data from the player-data file. * It will not work if the player is online, because the data on the file are not synchronized with real-time values. * @param convertTag true to convert the data to the current MC version, false to keep the saved version - * @return the NBT data from the playerdata file. + * @return the NBT data from the player-data file. * @throws IllegalStateException if the player is online. */ default CompoundTag getPlayerData(boolean convertTag) { @@ -173,9 +173,9 @@ public interface PaperOffPlayer extends AbstractOffPlayer { } /** - * Gets a wrapper for the NBT data from the playerdata file. + * Gets a wrapper for the NBT data from the player-data file. * It will not work if the player is online, because the data on the file are not synchronized with real-time values. - * @return the NBT data from the playerdata file. + * @return the NBT data from the player-data file. * @throws IllegalStateException if the player is online. */ default PlayerDataWrapper getPlayerDataWrapper() { @@ -183,7 +183,7 @@ public interface PaperOffPlayer extends AbstractOffPlayer { } /** - * Saves the provided NBT data to the playerdata file. + * Saves the provided NBT data to the player-data file. * It will not work if the player is online, because the provided data will be lost when the player disconnects. * @param data the data to save. * @throws IllegalStateException if the player is online. @@ -195,14 +195,14 @@ public interface PaperOffPlayer extends AbstractOffPlayer { File file = getPlayerDataFile(false); File old = getPlayerDataFile(true); old.delete(); - Files.move(file, old); + Files.move(file.toPath(), old.toPath()); NbtIo.writeCompressed(data.data, file); } /** - * Gets the file where the playerdata is stored. + * Gets the file where the player-data is stored. * @param old true to return the path of old data, false to return the actual file. - * @return the file where the playerdata is stored. + * @return the file where the player-data is stored. */ default File getPlayerDataFile(boolean old) { File playerDataDir = new File(WorldUtil.worldDir(PrimaryWorlds.PRIMARY_WORLDS.get(0)), "playerdata"); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java index a8c38cf..4aec24e 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java @@ -97,7 +97,7 @@ public interface PaperOnlinePlayer extends PaperOffPlayer, AbstractOnlinePlayer * Play a sound on this player’s client, sourced at this player’s location. * @param sound the sound to play * @param volume the volume of the sound. - * @param pitch the pich in which the sound is played. + * @param pitch the pitch in which the sound is played. */ default void playSound(Sound sound, float volume, float pitch) { playSound(sound, getBukkitPlayer().getLocation(), volume, pitch); @@ -108,7 +108,7 @@ public interface PaperOnlinePlayer extends PaperOffPlayer, AbstractOnlinePlayer * @param sound the sound to play * @param location the source location of the sound. * @param volume the volume of the sound. - * @param pitch the pich in which the sound is played. + * @param pitch the pitch in which the sound is played. */ default void playSound(Sound sound, Location location, float volume, float pitch) { getBukkitPlayer().playSound(location, sound, volume, pitch); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperPlayerConfigStorage.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperPlayerConfigStorage.java index 65e50c7..443c886 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperPlayerConfigStorage.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperPlayerConfigStorage.java @@ -18,12 +18,12 @@ import java.util.stream.Collectors; public class PaperPlayerConfigStorage { - static File storageFile = new File(PandaLibPaper.getPlugin().getDataFolder(), "playerdata.yml"); + static final File storageFile = new File(PandaLibPaper.getPlugin().getDataFolder(), "playerdata.yml"); static boolean initialized = false; - static LinkedHashMap data = new LinkedHashMap<>(); - static LinkedHashMap> playerSortedData = new LinkedHashMap<>(); - static LinkedHashMap> keySortedData = new LinkedHashMap<>(); + static final LinkedHashMap data = new LinkedHashMap<>(); + static final LinkedHashMap> playerSortedData = new LinkedHashMap<>(); + static final LinkedHashMap> keySortedData = new LinkedHashMap<>(); static boolean changed = false; @@ -196,10 +196,6 @@ public class PaperPlayerConfigStorage { return value; } - private void setValue(String value) { - this.value = value; - } - @Override public int hashCode() { return Objects.hash(playerId, key); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PlayerNonPersistentConfig.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PlayerNonPersistentConfig.java index 0ed1f78..086997c 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PlayerNonPersistentConfig.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PlayerNonPersistentConfig.java @@ -79,7 +79,7 @@ public class PlayerNonPersistentConfig { } public static class ExpiresTick extends Expiration { - long expirationTick; + final long expirationTick; public ExpiresTick(long expirationDelayTick) { expirationTick = tick + expirationDelayTick; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java index 0193f70..72a1e8e 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java @@ -68,7 +68,7 @@ public class NMSReflect { OBF_NAMESPACE = (String) obfHelperClass.field("SPIGOT_NAMESPACE").getStaticValue(); MOJ_NAMESPACE = (String) obfHelperClass.field("MOJANG_PLUS_YARN_NAMESPACE").getStaticValue(); } catch (ReflectiveOperationException e) { - throw new ReflectiveOperationException("Unable to find the Paper ofbuscation mapping class or class members.", e); + throw new ReflectiveOperationException("Unable to find the Paper obfuscation mapping class or class members.", e); } List mappings = loadMappings(obfHelperClass); @@ -165,7 +165,7 @@ public class NMSReflect { private static List loadMappings(ReflectClass obfHelperClass) throws IOException { try (final InputStream mappingsInputStream = obfHelperClass.get().getClassLoader().getResourceAsStream("META-INF/mappings/reobf.tiny")) { if (mappingsInputStream == null) { - throw new RuntimeException("Unable to find the ofbuscation mapping file in the Paper jar."); + throw new RuntimeException("Unable to find the obfuscation mapping file in the Paper jar."); } MemoryMappingTree tree = new MemoryMappingTree(); @@ -290,7 +290,7 @@ public class NMSReflect { /** - * Represents the mapping between the obfuscated and mojang names of a class and all its members. + * Represents the mapping between the obfuscated and Mojang names of a class and all its members. */ public static class ClassMapping { private static int nextID = 0; @@ -463,9 +463,9 @@ public class NMSReflect { private List superInterfaces(boolean obf) { Class[] interfaces = runtimeClass().getInterfaces(); List types = new ArrayList<>(interfaces.length); - for (Class interfce : interfaces) { - ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(interfce.getName()); - types.add((cm != null) ? cm.toType(obf) : NMSTypeWrapper.of(interfce)); + for (Class i : interfaces) { + ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(i.getName()); + types.add((cm != null) ? cm.toType(obf) : NMSTypeWrapper.of(i)); } return types; } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java index b0c8076..67ee72b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java @@ -25,7 +25,7 @@ public class OBCReflect { /** * Returns the OBC class that has the provided name, wrapped into a {@link ReflectClass}. - * @param obcClass the name of the class, including the subpackage in whitch the requested class is. This parameter + * @param obcClass the name of the class, including the subpackage in which the requested class is. This parameter * will be prefixed with the {@code OBC} package and the current package version. * @return the OBC class that has the provided name, wrapped into a {@link ReflectClass}. * @throws ClassNotFoundException if the provided class was not found in {@code OBC} package. diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java index 7991317..dd3600f 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java @@ -79,14 +79,14 @@ import fr.pandacube.lib.util.ThrowableAccumulator; import static fr.pandacube.lib.reflect.wrapper.WrapperRegistry.initWrapper; /** - * Initializer for all the reflect tools in {@code pandalib-paper-reflect} module. + * Initializer for all the reflection tools in {@code pandalib-paper-reflect} module. */ public class PandalibPaperReflect { private static boolean isInit = false; /** - * Initializes the reflect tools in {@code pandalib-paper-reflect} module. + * Initializes the reflection tools in {@code pandalib-paper-reflect} module. * @throws Exception if a problem occurs when initializing wrapper classes. */ public static void init() throws Exception { @@ -117,7 +117,7 @@ public class PandalibPaperReflect { thAcc.catchThrowable(() -> initWrapper(RenderData.class, RenderData.REFLECT.get())); thAcc.catchThrowable(() -> initWrapper(VanillaCommandWrapper.class, VanillaCommandWrapper.REFLECT.get())); - // dataconverter + // data-converter thAcc.catchThrowable(() -> initWrapper(MCDataConverter.class, MCDataConverter.REFLECT.get())); thAcc.catchThrowable(() -> initWrapper(MCDataType.class, MCDataType.REFLECT.get())); thAcc.catchThrowable(() -> initWrapper(MCTypeRegistry.class, MCTypeRegistry.REFLECT.get())); @@ -204,7 +204,7 @@ public class PandalibPaperReflect { thAcc.catchThrowable(() -> initWrapper(QueuedChangesMapLong2Object.class, QueuedChangesMapLong2Object.REFLECT.get())); - thAcc.throwCatched(); + thAcc.throwCaught(); } } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/util/BedrockBambooCollisionFixer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/util/BedrockBambooCollisionFixer.java index c8b5932..112786a 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/util/BedrockBambooCollisionFixer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/util/BedrockBambooCollisionFixer.java @@ -22,7 +22,7 @@ public final class BedrockBambooCollisionFixer implements Listener { // Make the bamboo block have zero collision. try { BambooStalkBlock.COLLISION_SHAPE(new AABBVoxelShape(new AABB(0.5, 0, 0.5, 0.5, 0, 0.5))); - Log.info("Bamboo block collision box removed succesfully."); + Log.info("Bamboo block collision box removed successfully."); } catch (Exception e) { Log.severe("Unable to remove the collision box of the Bamboo block.", e); return; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java index 9496688..ae614a1 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java @@ -2,14 +2,10 @@ package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData; import fr.pandacube.lib.reflect.ReflectClass; -import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.map.MapView; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java index e9f56b3..85c5e6b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java @@ -19,12 +19,12 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class VanillaCommandWrapper extends ReflectWrapperTyped { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper")); - public static final ReflectConstructor CONSTRUTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class)); + public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class)); public static final ReflectField vanillaCommand = wrapEx(() -> REFLECT.field("vanillaCommand")); public static final ReflectMethod getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class)); public VanillaCommandWrapper(Commands dispatcher, CommandNode vanillaCommand) { - this(wrapReflectEx(() -> CONSTRUTOR.instanciate(unwrap(dispatcher), vanillaCommand))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(dispatcher), vanillaCommand))); } @SuppressWarnings("unchecked") diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java index 6f49aa9..9f01475 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java @@ -1,7 +1,6 @@ package fr.pandacube.lib.paper.reflect.wrapper.dataconverter; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component; import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java index 39d9849..4ca8979 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java @@ -57,7 +57,7 @@ public class CompoundTag extends ReflectWrapper implements Tag { private static final ReflectMethod containsStringInt = wrapEx(() -> MAPPING.mojMethod("contains", String.class, int.class)); public CompoundTag() { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate())); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate())); } protected CompoundTag(Object nms) { @@ -167,7 +167,7 @@ public class CompoundTag extends ReflectWrapper implements Tag { */ @SuppressWarnings("unchecked") public Map entries() { - // we cannot easily wrap every value of the map without being able to synch the returned map with the wrapped map + // we cannot easily wrap every value of the map without being able to synchronize the returned map with the wrapped map return (Map) wrapReflectEx(() -> entries.invoke(__getRuntimeInstance())); } public int size() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java index df67d0d..6bee944 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java @@ -4,7 +4,6 @@ import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectMethod; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; @@ -19,7 +18,7 @@ public class ListTag extends CollectionTag { } public ListTag() { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate())); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate())); } protected ListTag(Object nms) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java index 251d775..a220969 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java @@ -14,7 +14,7 @@ public class FriendlyByteBuf extends ByteBuf { private static final ReflectMethod writeUtf = wrapEx(() -> MAPPING.mojMethod("writeUtf", String.class)); public FriendlyByteBuf(ByteBuf parent) { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(parent)))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(parent)))); } public FriendlyByteBuf writeUtf(String string) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java index 91fa00b..79ae083 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java @@ -24,6 +24,6 @@ public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Pa } public ClientboundCustomPayloadPacket(ResourceLocation res, FriendlyByteBuf buff) { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(res), unwrap(buff)))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(res), unwrap(buff)))); } } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java index 461c5bf..905abd1 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java @@ -22,7 +22,7 @@ public class ClientboundGameEventPacket extends ReflectWrapper implements Packet } public ClientboundGameEventPacket(Type type, float value) { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(type), value))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(type), value))); } protected ClientboundGameEventPacket(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java index c98492d..4dae197 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java @@ -1,7 +1,6 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java index 16aac02..7d16569 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java @@ -12,7 +12,7 @@ public class AABB extends ReflectWrapper { private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(double.class, double.class, double.class, double.class, double.class, double.class)); public AABB(double x1, double y1, double z1, double x2, double y2, double z2) { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x1, y1, z1, x2, y2, z2))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x1, y1, z1, x2, y2, z2))); } protected AABB(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java index ebe497a..2e596da 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java @@ -12,7 +12,7 @@ public class ChunkPos extends ReflectWrapper { public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(int.class, int.class)); public ChunkPos(int x, int z) { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x, z))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x, z))); } protected ChunkPos(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java index e0fe945..aa1e88c 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSource.java @@ -2,10 +2,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; -import fr.pandacube.lib.reflect.ReflectField; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class DamageSource extends ReflectWrapper { public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource")); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java index c039930..8bb6434 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DamageSources.java @@ -1,11 +1,9 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class DamageSources extends ReflectWrapper { public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSources")); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java index 39c65c5..26ab073 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java @@ -2,8 +2,6 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; -import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration; -import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/AABBVoxelShape.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/AABBVoxelShape.java index 8d235db..5e65535 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/AABBVoxelShape.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/AABBVoxelShape.java @@ -14,7 +14,7 @@ public class AABBVoxelShape extends VoxelShape { private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(AABB.MAPPING.runtimeClass())); public AABBVoxelShape(AABB aabb) { - this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(aabb)))); + this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(aabb)))); } protected AABBVoxelShape(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/PandalibRunnable.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/PandalibRunnable.java index 729c8bc..58584cf 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/PandalibRunnable.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/PandalibRunnable.java @@ -1,15 +1,11 @@ package fr.pandacube.lib.paper.scheduler; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import org.bukkit.Bukkit; +import fr.pandacube.lib.paper.PandaLibPaper; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import fr.pandacube.lib.paper.PandaLibPaper; +import java.util.Objects; /** * An extension of {@link BukkitRunnable} that already integrates a reference to the Bukkit plugin. @@ -21,13 +17,13 @@ public class PandalibRunnable extends BukkitRunnable { /** - * Instanciate a {@link PandalibRunnable}, whose {@link #run()} method will be called by the server scheduler. - * When using this default constructor, the {@link #run()} method must be override to provides code to run. + * Instantiate a {@link PandalibRunnable}, whose {@link #run()} method will be called by the server scheduler. + * When using this default constructor, the {@link #run()} method must be overridden to provide code to run. */ protected PandalibRunnable() { } /** - * Instanciate a {@link PandalibRunnable}, with an {@code updater} that will be called by the server scheduler. + * Instantiate a {@link PandalibRunnable}, with an {@code updater} that will be called by the server scheduler. * @param updater the updater to run when this task is executed. */ public PandalibRunnable(Runnable updater) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java index 643962c..36b4291 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java @@ -16,7 +16,7 @@ public class SchedulerUtil { * Ensure that the provided runnable is run on the server thread. * If the current thread is the server thread, then the task is run right now, then this method returns. * If the current thread is another thread, it passes over the runnable to the Bukkit scheduler, then returns - * imediately. + * immediately. * @param task the task to run on the main thread. */ public static void runOnServerThread(Runnable task) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java index 4c00797..94e3c7b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AABBBlock.java @@ -14,7 +14,7 @@ import fr.pandacube.lib.util.RandomUtil; /** * Checkpoint represented as a 3D Axis and Block Aligned Bounding Box (sort of AABB). - * Represent the littelest cuboid selection of blocks that contains the bounding box + * Represent the littlest cuboid selection of blocks that contains the bounding box * passed to the constructor. */ public class AABBBlock implements Iterable, Cloneable { @@ -26,10 +26,10 @@ public class AABBBlock implements Iterable, Cloneable { private final long volume; private AABBBlock(AABBBlock original, int shiftX, int shiftY, int shiftZ) { - Vector shiftVect = new Vector(shiftX, shiftY, shiftZ); - pos1 = original.pos1.clone().add(shiftVect); - pos2 = original.pos2.clone().add(shiftVect); - center = original.center.clone().add(shiftVect); + Vector shiftVec = new Vector(shiftX, shiftY, shiftZ); + pos1 = original.pos1.clone().add(shiftVec); + pos2 = original.pos2.clone().add(shiftVec); + center = original.center.clone().add(shiftVec); volume = original.volume; } @@ -47,7 +47,7 @@ public class AABBBlock implements Iterable, Cloneable { public AABBBlock(int p1x, int p1y, int p1z, int p2x, int p2y, int p2z) { /* - * Prends les points extérieurs permettant de former un bouding box englobant + * Prends les points extérieurs permettant de former un bounding box englobant * celui représenté par v1 et v2, et étant aligné au quadrillage des blocs. */ int p1x_ = Math.min(p1x, p2x); @@ -70,7 +70,7 @@ public class AABBBlock implements Iterable, Cloneable { @SuppressWarnings("MethodDoesntCallSuperMethod") @Override - public AABBBlock clone() throws CloneNotSupportedException { + public AABBBlock clone() { return new AABBBlock(this, 0, 0, 0); } diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AutoUpdatedBossBar.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AutoUpdatedBossBar.java index 0afdffe..1382f81 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AutoUpdatedBossBar.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/AutoUpdatedBossBar.java @@ -41,7 +41,7 @@ public class AutoUpdatedBossBar implements Listener { /** - * Schedule the update of this bossbar with synchronisation with the system clock. + * Schedule the update of this boss bar with synchronisation with the system clock. * The underlying method called is {@link Timer#schedule(TimerTask, long, long)}. * The updater is executed in a separate Thread. * @param msDelay ms before running the first update of this bossbar @@ -49,7 +49,7 @@ public class AutoUpdatedBossBar implements Listener { */ public synchronized void scheduleUpdateTimeSyncThreadAsync(long msDelay, long msPeriod) { if (scheduled) - throw new IllegalStateException("Can't schedule an already scheduled bossbar update"); + throw new IllegalStateException("Can't schedule an already scheduled boss bar update"); scheduled = true; timer = new Timer("Panda BossBarUpdater - " + Chat.chatComponent(bar.name()).getPlainText()); @@ -66,16 +66,16 @@ public class AutoUpdatedBossBar implements Listener { } /** - * Schedule the update of this bossbar with synchronisation with the main Thread of the + * Schedule the update of this boss bar with synchronisation with the main Thread of the * current Minecraft server (follow the tick count progress). * The underlying method called is {@link BukkitScheduler#runTaskTimer(org.bukkit.plugin.Plugin, Runnable, long, long)}. * The updater is executed by the Server Thread. - * @param tickDelay number of server tick before running the first update of this bossbar + * @param tickDelay number of server tick before running the first update of this boss bar * @param tickPeriod number of server tick between each call of the updater */ public synchronized void scheduleUpdateTickSyncThreadSync(long tickDelay, long tickPeriod) { if (scheduled) - throw new IllegalStateException("Can't schedule an already scheduled bossbar update"); + throw new IllegalStateException("Can't schedule an already scheduled boss bar update"); scheduled = true; bukkitTask = Bukkit.getServer().getScheduler() @@ -164,7 +164,7 @@ public class AutoUpdatedBossBar implements Listener { /** - * Utility method to update the title of the bossbar without unnecessary packet. + * Utility method to update the title of the boss bar without unnecessary packet. */ public void setTitle(Chat title) { synchronized (bar) { @@ -173,7 +173,7 @@ public class AutoUpdatedBossBar implements Listener { } /** - * Utility method to update the color of the bossbar without unnecessary packet. + * Utility method to update the color of the boss bar without unnecessary packet. */ public void setColor(Color color) { synchronized (bar) { @@ -182,7 +182,7 @@ public class AutoUpdatedBossBar implements Listener { } /** - * Utility method to update the progress of the bossbar without unnecessary packet. + * Utility method to update the progress of the boss bar without unnecessary packet. */ public void setProgress(double progress) { synchronized (bar) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java index 4d65c0e..441952d 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitChatColorUtil.java @@ -19,11 +19,11 @@ public class BukkitChatColorUtil { * @return the closest chat color from {@code dye} */ public static TextColor fromDyeToSignColor(DyeColor dye) { + // following code invalid due to text color on sign does not use rgb value of dye color. //org.bukkit.Color col = dye.getColor(); //return ChatColor.of(new Color(col.asRGB())); - // hmmm this is not that simple, of course - - // black + + // the color values are extracted from IG screenshot of dyed text signs. return switch (dye) { case BLACK -> TextColor.fromHexString("#000000"); case RED -> TextColor.fromHexString("#650000"); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitEvent.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitEvent.java index c84cfeb..74e3953 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitEvent.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/BukkitEvent.java @@ -96,7 +96,7 @@ public class BukkitEvent { } /** - * Abstract implementation of {@link EventListener} that ensure as best as it can, + * Abstract implementation of {@link EventListener} that ensure as good as it can, * that it is the last listener called to handle the event. * * @param the type of the event diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/EntityStackUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/EntityStackUtil.java index a45f7a8..6938f79 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/EntityStackUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/EntityStackUtil.java @@ -4,22 +4,19 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; /** - * Permet de gérer les entités qui se transportent les uns les autres - * - * Ce groupement d'entité est appelé une "pile d'entité". - * - * Par exemple, un cheval et son monteur représente à eux deux une pile - * d'entité, dont - * l'élement tout en bas est le cheval + * Utility class to handle stacks of entities. A stack an entity is when an entity is mounting onto another one. + * For instance, a player mounting a horse. We also say that the horse is the vehicle of the player. */ public class EntityStackUtil { /** - * Déplace une pile d'entité vers l'endroit défini + * Teleport a stack of entity, all at once. * - * @param e Une entité faisant parti de la pile d'entité à téléporter - * @param l La position vers lequel envoyer toute la pile + * @param e An entity that is part of the stack to teleport. + * @param l The location where to send the entity stack. + * @deprecated This method has not been tested since a long time ago. */ + @Deprecated public static void teleportStack(Entity e, Location l) { // on se place sur l'entité tout en bas de la pile @@ -27,7 +24,7 @@ public class EntityStackUtil { while (entTemp.getVehicle() != null) entTemp = entTemp.getVehicle(); - /* la possibilité d'avoir plusieurs passagers sur un entité rend le code + /* La possibilité d'avoir plusieurs passagers sur une entité rend le code * commenté qui suit invalide. On le remplace temporairement (voire * définitivement si ça suffit) par le code encore en dessous List stack = new ArrayList<>(); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GameWorldUtils.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GameWorldUtils.java index 3e4afa9..3bb3500 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GameWorldUtils.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GameWorldUtils.java @@ -83,6 +83,9 @@ public class GameWorldUtils implements Listener { new File(destDir, "uid.dat").delete(); World w = Bukkit.createWorld(new WorldCreator(copiedName).environment(Environment.NORMAL)); + if (w == null) { + throw new RuntimeException("Unable to create the world " + copiedName + ": Bukkit.createWorld(...) returned null value."); + } w.setAutoSave(false); gameWorld.put(world, w); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "mvm set hidden true "+copiedName); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GeometryUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GeometryUtil.java index 065031d..e072da0 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GeometryUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/GeometryUtil.java @@ -33,7 +33,7 @@ public class GeometryUtil { /** * The visual height of a Minecraft player skin, when he is standing up and not sneaking, * from the ground where the player is standing on, to the above of the first layer of the head skin. - * It doesn't correspond to the player hitbox height.
+ * It doesn't correspond to the player hit box height.
*
* The value is provided in Minecraft Wiki. */ @@ -45,9 +45,9 @@ public class GeometryUtil { /** * The visual height of a Minecraft player skin, when he is standing up and sneaking, * from the ground where the player is standing on, to the above of the first layer of the head skin. - * It may not correspond to the player hitbox height.
+ * It may not correspond to the player hit box height.
*
- * The current value is the height of the player's hitbox when sneaking. Even if this + * The current value is the height of the player's hit box when sneaking. Even if this * is close to the real value (tested in game), this is not the exact value. */ public static final double PLAYER_SKIN_HEIGHT_SNEAK = 1.50; @@ -76,7 +76,7 @@ public class GeometryUtil { /** * Get the {@link Location}s of the 8 vertex of the player head
* This method only work if the player is standing up - * (not dead, not glyding, not sleeping). + * (not dead, not gliding, not sleeping). * @param playerLocation the location of the player, generally provided by {@link Player#getLocation()} * @param isSneaking if the player is sneaking. Generally {@link Player#isSneaking()} * @return an array of 8 {@link Location}s with x, y, and z values filled (yaw and pitch are ignored). @@ -140,32 +140,15 @@ public class GeometryUtil { ad.setX(Math.abs(ad.getX())); ad.setY(Math.abs(ad.getY())); ad.setZ(Math.abs(ad.getZ())); - - if (Math.abs(c.getX()) > e.getX() + ad.getX()){ - return false; - } - - if (Math.abs(c.getY()) > e.getY() + ad.getY()){ - return false; - } - - if (Math.abs(c.getZ()) > e.getX() + ad.getZ()){ - return false; - } - - if (Math.abs(d.getY() * c.getZ() - d.getZ() * c.getY()) > e.getY() * ad.getZ() + e.getZ() * ad.getY() + epsilon){ - return false; - } - - if (Math.abs(d.getZ() * c.getX() - d.getX() * c.getZ()) > e.getZ() * ad.getX() + e.getX() * ad.getZ() + epsilon){ - return false; - } - if (Math.abs(d.getX() * c.getY() - d.getY() * c.getX()) > e.getX() * ad.getY() + e.getY() * ad.getX() + epsilon){ - return false; - } - - return true; + return !( + Math.abs(c.getX()) > e.getX() + ad.getX() + || Math.abs(c.getY()) > e.getY() + ad.getY() + || Math.abs(c.getZ()) > e.getX() + ad.getZ() + || Math.abs(d.getY() * c.getZ() - d.getZ() * c.getY()) > e.getY() * ad.getZ() + e.getZ() * ad.getY() + epsilon + || Math.abs(d.getZ() * c.getX() - d.getX() * c.getZ()) > e.getZ() * ad.getX() + e.getX() * ad.getZ() + epsilon + || Math.abs(d.getX() * c.getY() - d.getY() * c.getX()) > e.getX() * ad.getY() + e.getY() * ad.getX() + epsilon + ); } @@ -181,7 +164,7 @@ public class GeometryUtil { /** - * This vector consider Minecraft X Y Z axis orientation, + * This vector considers Minecraft X Y Z axis orientation, * but consider standard (not Minecraft) radian values for yaw and pitch.
* The length of this Vector (based on {@link #x}, {@link #y} and {@link #z} values) * Is always 1. @@ -199,25 +182,25 @@ public class GeometryUtil { public static class DirectionalVector { /** * The X cartesian coordinate of this {@link DirectionalVector}. - * It correspond to the X (west to east) axis in a Minecraft world. + * It corresponds to the X (west to east) axis in a Minecraft world. */ public final double x; /** * The Y cartesian coordinate of this {@link DirectionalVector}. - * It correspond to the Y (bottom to top) axis in a Minecraft world. + * It corresponds to the Y (bottom to top) axis in a Minecraft world. */ public final double y; /** * The Z cartesian coordinate of this {@link DirectionalVector}. - * It correspond to the Z (north to south) axis in a Minecraft world. + * It corresponds to the Z (north to south) axis in a Minecraft world. */ public final double z; /** * The azimuthal angle φ (phi) of this {@link DirectionalVector}, in radian. - * It correspond with Minecraft world as follow : + * It corresponds with Minecraft world as follows : *

Yaw :
 		 * North (-z) = -PI/2
 		 * East  (+x) = 0
@@ -228,7 +211,7 @@ public class GeometryUtil {
 
 		/**
 		 * The polar angle θ (theta) of this {@link DirectionalVector}, in radian.
-		 * It correspond with Minecraft world as follow :
+		 * It corresponds with Minecraft world as follows :
 		 * 
Pitch :
 		 * Down (-y) = -PI/2
 		 * Up   (+y) = PI/2
@@ -258,7 +241,7 @@ public class GeometryUtil { /** * @param v the vector representing the direction. If v.getX() and v.getZ() are 0, - * the yaw will be 0. This may have inconsistence if the vector is calculated + * the yaw will be 0. This may have inconsistency if the vector is calculated * from a {@link Location}'s yaw and pitch. In this case, prefer using * {@link #DirectionalVector(Location)}. The {@link Vector} is * normalized if necessary (does not modify the provided {@link Vector}). @@ -271,10 +254,10 @@ public class GeometryUtil { private DirectionalVector(double x, double y, double z) { - double vectSize = Math.sqrt(x*x + y*y + z*z); - this.x = x/vectSize; - this.y = y/vectSize; - this.z = z/vectSize; + double vecSize = Math.sqrt(x*x + y*y + z*z); + this.x = x/vecSize; + this.y = y/vecSize; + this.z = z/vecSize; if (x == 0.0 && z == 0.0) { pitch = y > 0.0 ? PId2 : -PId2; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ItemStackBuilder.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ItemStackBuilder.java index a8bbfa1..0f785c2 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ItemStackBuilder.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ItemStackBuilder.java @@ -37,7 +37,7 @@ public class ItemStackBuilder { /** * Create a builder of a new ItemStack with the specified Material. - * @param mat the material of the new builded ItemStack + * @param mat the material of the new built ItemStack * @return the builder */ public static ItemStackBuilder of(Material mat) { @@ -50,8 +50,8 @@ public class ItemStackBuilder { * The {@link #build()} method of the returned builder will return the same instance * of ItemStack as the parameter of this method. *

- * To create a builder that doesn’t modify the provided ItemStack, use {@link #of(ItemStack)}. - * @param stack the wrapped itemstack. + * To create a builder that doesn't modify the provided ItemStack, use {@link #of(ItemStack)}. + * @param stack the wrapped item stack. * @return the builder */ public static ItemStackBuilder wrap(ItemStack stack) { @@ -149,8 +149,8 @@ public class ItemStackBuilder { return addLoreAfter(Arrays.asList(lores)); } - public ItemStackBuilder enchant(Enchantment ench, int level) { - return meta(m -> m.addEnchant(ench, level, true)); + public ItemStackBuilder enchant(Enchantment enchantment, int level) { + return meta(m -> m.addEnchant(enchantment, level, true)); } public ItemStackBuilder flags(ItemFlag... flags) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/LocationUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/LocationUtil.java index 82a29ae..40cdcec 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/LocationUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/LocationUtil.java @@ -77,13 +77,9 @@ public class LocationUtil { return; if (extraSecureCheck != null && !extraSecureCheck.test(ret)) - return; // extra checks didn’t validate the location - - //if (checkCubo && PandacubePaper.getPlugin().cuboManager != null) - // if (PandacubePaper.getPlugin().cuboManager.getCuboFromLocation(ret) != null) - // return; // il y a un cubo à l'endroit aléatoire sélectionnée + return; // extra checks didn't validate the location - // tout est bon + // all good future.complete(ret); t.get().cancel(); @@ -103,11 +99,11 @@ public class LocationUtil { * @return a secure location with the same X and Z coordinate as the * provided location, but Y modified to ensure security for player * who will be teleported to this location. - * May return null if it is impossible to securize find a secure location. + * May return null if it is impossible to find a secure location. */ public static Location getSecureLocationOrNull(Location l) { l = l.clone(); - l.setY(l.getWorld().getEnvironment() == Environment.NETHER ? 126 : 256); + l.setY(l.getWorld().getEnvironment() == Environment.NETHER ? 126 : l.getWorld().getMaxHeight()); Block b = l.getBlock(); while (b.getY() >= 0 && !currPosSafe(b)) @@ -147,7 +143,7 @@ public class LocationUtil { /** - * Check if the {@link Location} l is inside the cuboïd formed by the 2 others + * Check if the {@link Location} l is inside the cuboid formed by the 2 others * Locations min and max. * @return true if l is inside the cuboid min-max */ @@ -164,7 +160,7 @@ public class LocationUtil { /** * Return a new location based on the linear interpolation between p0 and p1, according to the value c. - * @param c between 0 and 1. If 0, it returns p0 and if 1, returns p1. Other finite numbers are allowed, but the returned location wont be part of the {@code [p0;p1]} segment. + * @param c between 0 and 1. If 0, it returns p0 and if 1, returns p1. Other finite numbers are allowed, but the returned location won't be part of the {@code [p0;p1]} segment. * @return The location, linearly interpolated between p0 and p1 with the value c. The yaw and pitch in the returned location are those of p0. * @throws IllegalArgumentException if the provided locations are not in the same world. */ diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/PlayerDataWrapper.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/PlayerDataWrapper.java index 0afa9bf..ada5c75 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/PlayerDataWrapper.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/PlayerDataWrapper.java @@ -26,8 +26,15 @@ import java.util.function.IntUnaryOperator; */ public class PlayerDataWrapper { + /** + * The data as they are stored in the player file. + */ public final CompoundTag data; + /** + * Creates a new wrapper for the provided player data. + * @param data the data to wrap. + */ public PlayerDataWrapper(CompoundTag data) { this.data = data == null ? new CompoundTag() : data; } @@ -44,10 +51,10 @@ public class PlayerDataWrapper { } private int fromNBTtoBukkitInventorySlot(int nbtSlot) { - // cat nbEl NBTslot bukkitSlot NBT->Bukkit - // items 36el 0-35 == - // armor 4el start 100 36-39 -100 + 36 - // offhnd 1el start 150 40 -150 + 40 + // cat nbEl NBTSlot bukkitSlot NBT->Bukkit + // items 36 0-35 == + // armor 4 starts at 100 36-39 -100 + 36 + // offhand 1 starts at 150 40 -150 + 40 if (nbtSlot >= 0 && nbtSlot < 36) { // regular inventory slots return nbtSlot; } @@ -92,7 +99,7 @@ public class PlayerDataWrapper { private Inventory getBukkitInventory(String nbtKey, InventoryType bukkitType, IntUnaryOperator nbtToBukkitSlotConverter) { - Map stacks = getRawInvontoryContent(nbtKey); + Map stacks = getRawInventoryContent(nbtKey); Inventory inv = Bukkit.createInventory(null, bukkitType); if (stacks.isEmpty()) return inv; @@ -102,7 +109,7 @@ public class PlayerDataWrapper { return inv; } - private Map getRawInvontoryContent(String key) { + private Map getRawInventoryContent(String key) { if (!data.contains(key, 9)) // type 9 is list return Map.of(); ListTag list = data.getList(key, 10); // type of list element 10 is CompoundTag @@ -125,16 +132,17 @@ public class PlayerDataWrapper { - private void setBukkitInventory(String nbtKey, Inventory inv, IntUnaryOperator bukkitToNBTSlotconverter) { + private void setBukkitInventory(String nbtKey, Inventory inv, IntUnaryOperator bukkitToNBTSlotConverter) { Map stacks = new TreeMap<>(); if (inv == null) { setRawInventoryContent(nbtKey, stacks); + return; } for (int bukkitSlot = 0; bukkitSlot < inv.getSize(); bukkitSlot++) { ItemStack is = filterStack(inv.getItem(bukkitSlot)); if (is == null) continue; - int nbtSlot = bukkitToNBTSlotconverter.applyAsInt(bukkitSlot); + int nbtSlot = bukkitToNBTSlotConverter.applyAsInt(bukkitSlot); stacks.put(nbtSlot, is); } setRawInventoryContent(nbtKey, stacks); @@ -309,33 +317,18 @@ public class PlayerDataWrapper { Preconditions.checkArgument(slot != null, "slot must not be null"); switch (slot) { - case HAND: - this.setItemInMainHand(item); - break; - case OFF_HAND: - this.setItemInOffHand(item); - break; - case FEET: - this.setBoots(item); - break; - case LEGS: - this.setLeggings(item); - break; - case CHEST: - this.setChestplate(item); - break; - case HEAD: - this.setHelmet(item); - break; - default: - throw new IllegalArgumentException("Not implemented. This is a bug"); + case HAND -> this.setItemInMainHand(item); + case OFF_HAND -> this.setItemInOffHand(item); + case FEET -> this.setBoots(item); + case LEGS -> this.setLeggings(item); + case CHEST -> this.setChestplate(item); + case HEAD -> this.setHelmet(item); + default -> throw new IllegalArgumentException("Not implemented. This is a bug"); } } @Override - public ItemStack getItem(EquipmentSlot slot) { - Preconditions.checkArgument(slot != null, "slot must not be null"); - + public @NotNull ItemStack getItem(@NotNull EquipmentSlot slot) { return switch (slot) { case HAND -> this.getItemInMainHand(); case OFF_HAND -> this.getItemInOffHand(); @@ -348,7 +341,7 @@ public class PlayerDataWrapper { @Override public @NotNull ItemStack getItemInMainHand() { - return getItem(heldItemSlot); + return Objects.requireNonNullElse(getItem(heldItemSlot), new ItemStack(Material.AIR)); } @Override @@ -358,7 +351,7 @@ public class PlayerDataWrapper { @Override public @NotNull ItemStack getItemInOffHand() { - return getItem(40); + return Objects.requireNonNullElse(getItem(40), new ItemStack(Material.AIR)); } @Override diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java index 86f36d0..e640df9 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java @@ -1,17 +1,20 @@ package fr.pandacube.lib.paper.util; -import java.util.List; - +import fr.pandacube.lib.chat.Chat; +import net.kyori.adventure.text.Component; import org.bukkit.ChatColor; +import org.bukkit.scoreboard.Criteria; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; -import fr.pandacube.lib.chat.Chat; -import net.kyori.adventure.text.Component; +import java.util.List; +/** + * Utility class to manipulate scoreboards. + */ public class ScoreboardUtil { @@ -29,7 +32,7 @@ public class ScoreboardUtil { public static void updateScoreboardSidebar(Scoreboard scBrd, Component title, Component[] lines) { Objective obj = scBrd.getObjective("sidebar_autogen"); - if (obj != null && !obj.getCriteria().equalsIgnoreCase("dummy")) { + if (obj != null && !obj.getTrackedCriteria().equals(Criteria.DUMMY)) { // objective present but with wrong criteria, removing it obj.unregister(); obj = null; @@ -37,7 +40,7 @@ public class ScoreboardUtil { if (obj == null) { - obj = scBrd.registerNewObjective("sidebar_autogen", "dummy", title); + obj = scBrd.registerNewObjective("sidebar_autogen", Criteria.DUMMY, title); obj.setDisplaySlot(DisplaySlot.SIDEBAR); } else { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/Skull.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/Skull.java index 3659ab8..fdd3f3b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/Skull.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/Skull.java @@ -69,7 +69,7 @@ public enum Skull { /** * Return the item based on this Skull enum. * - * @return itemstack + * @return item stack */ public ItemStack get() { return get(null, null); @@ -77,29 +77,29 @@ public enum Skull { /** * Return the item based on this Skull enum, with the provided display name and lore. * - * @return itemstack + * @return item stack */ - public ItemStack get(Chat dispName, List lore) { - return getFromPlayerName(name, dispName, lore); + public ItemStack get(Chat displayName, List lore) { + return getFromPlayerName(name, displayName, lore); } /** - * Return a skull of a player based on his name. + * Return a skull of a player based on their name. * * @param name player's name - * @return itemstack + * @return item stack */ - public static ItemStack getFromPlayerName(String name, Chat dispName, List lore) { + public static ItemStack getFromPlayerName(String name, Chat displayName, List lore) { ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta meta = (SkullMeta) itemStack.getItemMeta(); @SuppressWarnings({ "deprecation", "unused" }) boolean b = meta.setOwner(name); - if (dispName != null) - meta.displayName(dispName.getAdv()); + if (displayName != null) + meta.displayName(displayName.getAdv()); if (lore != null) meta.lore(lore.stream().map(Chat::getAdv).collect(Collectors.toList())); @@ -122,7 +122,7 @@ public enum Skull { * Return a skull that has a custom texture specified by url. * * @param url skin url - * @return itemstack + * @return item stack */ public static ItemStack getFromSkinURL(String url) { return getFromSkinURL(url, null, null); @@ -132,7 +132,7 @@ public enum Skull { * Return a skull that has a custom texture specified by url. * * @param url the skin full url - * @return itemstack + * @return item stack */ public static ItemStack getFromSkinURL(String url, Chat name, List lore) { return getFromBase64String(Base64.getEncoder().encodeToString(String.format("{\"textures\":{\"SKIN\":{\"url\":\"%s\"}}}", url).getBytes()), name, lore); @@ -148,8 +148,8 @@ public enum Skull { /** * Return a skull that has a custom texture specified by a base64 String. * - * @param str the base64 string from gameprofile informations - * @return itemstack + * @param str the base64 string from game profile information + * @return item stack */ public static ItemStack getFromBase64String(String str) { return getFromBase64String(str, null, null); @@ -159,10 +159,10 @@ public enum Skull { /** * Return a skull that has a custom texture specified by a base64 String. * - * @param str the base64 string from gameprofile informations - * @return itemstack + * @param str the base64 string from game profile information + * @return item stack */ - public static ItemStack getFromBase64String(String str, Chat dispName, List lore) { + public static ItemStack getFromBase64String(String str, Chat displayName, List lore) { ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta headMeta = (SkullMeta) head.getItemMeta(); @@ -171,8 +171,8 @@ public enum Skull { profile.setProperty(new ProfileProperty("textures", str)); headMeta.setPlayerProfile(profile); - if (dispName != null) - headMeta.displayName(dispName.getAdv()); + if (displayName != null) + headMeta.displayName(displayName.getAdv()); if (lore != null) headMeta.lore(lore.stream().map(Chat::getAdv).collect(Collectors.toList())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/WorldUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/WorldUtil.java index 84bc954..5c2350b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/WorldUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/WorldUtil.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.util; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.World.Environment; import java.io.File; @@ -14,8 +15,9 @@ public class WorldUtil { public static Environment determineEnvironment(String world) { - if (Bukkit.getWorld(world) != null) { - return Bukkit.getWorld(world).getEnvironment(); + World bWorld = Bukkit.getWorld(world); + if (bWorld != null) { + return bWorld.getEnvironment(); } File worldFolder = worldDir(world); @@ -43,7 +45,7 @@ public class WorldUtil { private static final List REGION_DATA_FILES = Arrays.asList("entities", "poi", "region", "DIM-1", "DIM1"); public static List regionDataFiles(String world) { - return onlyExistents(worldDir(world), REGION_DATA_FILES); + return onlyExisting(worldDir(world), REGION_DATA_FILES); } public static List mapFiles(String world) { @@ -51,7 +53,7 @@ public class WorldUtil { return List.of(dataDir(world).listFiles((dir, name) -> mapFilePattern.matcher(name).find() || "idcounts.dat".equals(name))); } - private static List onlyExistents(File worldDir, List searchList) { + private static List onlyExisting(File worldDir, List searchList) { return searchList.stream() .map(f -> new File(worldDir, f)) .filter(File::exists) diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermEntity.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermEntity.java index e604827..d8f01d9 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermEntity.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermEntity.java @@ -8,7 +8,7 @@ import java.util.Set; import java.util.stream.LongStream; import fr.pandacube.lib.chat.ChatTreeNode; -import fr.pandacube.lib.permissions.PermissionExpressionParser.LitteralPermissionTester; +import fr.pandacube.lib.permissions.PermissionExpressionParser.LiteralPermissionTester; import fr.pandacube.lib.permissions.PermissionsCachedBackendReader.CachedEntity; import fr.pandacube.lib.permissions.SQLPermissions.EntityType; import fr.pandacube.lib.util.Log; @@ -87,8 +87,8 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { } /** - * Provides informations on how the effective prefix of this entity is determined. - * @return a {@link ChatTreeNode} providing informations on how the effective prefix of this entity is determined. + * Provides information on how the effective prefix of this entity is determined. + * @return a {@link ChatTreeNode} providing information on how the effective prefix of this entity is determined. */ public ChatTreeNode debugPrefix() { return Permissions.resolver.debugPrefix(name, type); @@ -124,8 +124,8 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { } /** - * Provides informations on how the effective suffix of this entity is determined. - * @return a {@link ChatTreeNode} providing informations on how the effective suffix of this entity is determined. + * Provides information on how the effective suffix of this entity is determined. + * @return a {@link ChatTreeNode} providing information on how the effective suffix of this entity is determined. */ public ChatTreeNode debugSuffix() { return Permissions.resolver.debugSuffix(name, type); @@ -147,7 +147,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { /** * Gets the effective list of permissions that applies to this entity out of a specific server and world. * It is either the permissions defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @return the effective list of permissions that applies to this entity out of a specific server and world. */ public Map listEffectivePermissions() { @@ -157,7 +157,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { /** * Gets the effective list of permissions that applies to this entity on a specific server. * It is either the permissions defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param server the server where the returned permissions apply for this entity. * @return the effective list of permissions that applies to this entity on a specific server. */ @@ -168,7 +168,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { /** * Gets the effective list of permissions that applies to this entity on a specific server and world. * It is either the permissions defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param server the server containing the world where the returned permissions apply for this entity. * @param world the world in the server where the returned permissions apply for this entity. * @return the effective list of permissions that applies to this entity on a specific server and world. @@ -187,7 +187,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { * Gets the effective values of the provided permission range prefix that applies to this entity out of a specific * server and world. * It is either the range values defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param permissionPrefix the permission range prefix. * @return the effective values of the provided permission range prefix that applies to this entity out of a * specific server and world. @@ -200,7 +200,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { * Gets the effective values of the provided permission range prefix that applies to this entity on a specific * server. * It is either the range values defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param permissionPrefix the permission range prefix. * @param server the server where the returned values apply for this entity. * @return the effective values of the provided permission range prefix that applies to this entity on a specific @@ -214,7 +214,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { * Gets the effective values of the provided permission range prefix that applies to this entity on a specific * server and world. * It is either the range values defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param permissionPrefix the permission range prefix. * @param server the server containing the world where the returned values apply for this entity. * @param world the world in the server where the returned values apply for this entity. @@ -247,7 +247,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { * Gets the maximum effective value of the provided permission range prefix that applies to this entity out of a * specific server and world. * It is either the range values defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param permissionPrefix the permission range prefix. * @return the maximum effective value of the provided permission range prefix that applies to this entity out of a * specific server and world. @@ -260,7 +260,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { * Gets the maximum effective value of the provided permission range prefix that applies to this entity on a * specific server. * It is either the range values defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param permissionPrefix the permission range prefix. * @param server the server where the returned value applies for this entity. * @return the maximum effective value of the provided permission range prefix that applies to this entity on a @@ -274,7 +274,7 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { * Gets the maximum effective value of the provided permission range prefix that applies to this entity on a * specific server and world. * It is either the range values defined directly for this entity, or from inheritance as long as they are not - * overriden. + * overridden. * @param permissionPrefix the permission range prefix. * @param server the server containing the world where the returned value applies for this entity. * @param world the world in the server where the returned value applies for this entity. @@ -294,8 +294,8 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { /** * Tells if this entity has the provided permission out of a specific server and world. * It is either based on the permissions defined directly for this entity, or from inheritance as long as they are - * not overriden. - * @param permission the permission to ckeck on this entity. + * not overridden. + * @param permission the permission to check on this entity. * @return true if this entity has the permission, false if it is negated, or null if not known. */ public Boolean hasPermission(String permission) { @@ -303,10 +303,10 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { } /** - * Tells if this entity has the provided permission on a specitif server. + * Tells if this entity has the provided permission on a specific server. * It is either based on the permissions defined directly for this entity, or from inheritance as long as they are - * not overriden. It also consider permissions that apply on any server. - * @param permission the permission to ckeck on this entity. + * not overridden. It also considers permissions that apply on any server. + * @param permission the permission to check on this entity. * @param server the server in which to test the permission for this entity. * @return true if this entity has the permission, false if it is negated, or null if not known. */ @@ -315,10 +315,10 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { } /** - * Tells if this entity has the provided permission on a specitif server and world. + * Tells if this entity has the provided permission on a specific server and world. * It is either based on the permissions defined directly for this entity, or from inheritance as long as they are - * not overriden. It also consider permissions that apply on any world of that server, and then any server. - * @param permission the permission to ckeck on this entity. + * not overridden. It also considers permissions that apply on any world of that server, and then any server. + * @param permission the permission to check on this entity. * @param server the server in which to test the permission for this entity. * @param world the world in which to test the permission for this entity. * @return true if this entity has the permission, false if it is negated, or null if not known. @@ -330,10 +330,10 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { } /** - * Tells if this entity has the provided permission on a specitif server and world. + * Tells if this entity has the provided permission on a specific server and world. * It is either based on the permissions defined directly for this entity, or from inheritance as long as they are - * not overriden. - * @param permission the permission to ckeck on this entity. + * not overridden. + * @param permission the permission to check on this entity. * @param server the server in which to test the permission for this entity. * @param world the world in which to test the permission for this entity. * @param deflt the default value is the permission is undefined for this entity. @@ -347,12 +347,12 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { /** * Evaluates the provided permission expression for this entity. * It uses {@link #hasPermissionOr(String, String, String, boolean)} with {@code false} as a default value, to check - * each permission nodes individualy. + * each permission nodes individually. * @param permExpression the permission expression to evaluate on this entity. * @param server the server in which to test the permission expression for this entity. * @param world the world in which to test the permission expression for this entity. * @return true if this the permission expression evaluates to true, false otherwise. - * @see PermissionExpressionParser#evaluate(String, LitteralPermissionTester) + * @see PermissionExpressionParser#evaluate(String, LiteralPermissionTester) */ public boolean hasPermissionExpression(String permExpression, String server, String world) { return PermissionExpressionParser.evaluate(permExpression, p -> hasPermissionOr(p, server, world, false)); @@ -367,33 +367,33 @@ public sealed abstract class PermEntity permits PermPlayer, PermGroup { /** - * Provides informations on how the effective permission of this entity on the provided permission node is + * Provides information on how the effective permission of this entity on the provided permission node is * determined. * @param permission the permission node to debug on this entity. - * @return a {@link ChatTreeNode} providing informations on how the effective permission is determined. + * @return a {@link ChatTreeNode} providing information on how the effective permission is determined. */ public ChatTreeNode debugPermission(String permission) { return debugPermission(permission, null, null); } /** - * Provides informations on how the effective permission of this entity on the provided permission node is + * Provides information on how the effective permission of this entity on the provided permission node is * determined. * @param permission the permission node to debug on this entity. * @param server the server in which to test the permission for this entity. - * @return a {@link ChatTreeNode} providing informations on how the effective permission is determined. + * @return a {@link ChatTreeNode} providing information on how the effective permission is determined. */ public ChatTreeNode debugPermission(String permission, String server) { return debugPermission(permission, server, null); } /** - * Provides informations on how the effective permission of this entity on the provided permission node is + * Provides information on how the effective permission of this entity on the provided permission node is * determined. * @param permission the permission node to debug on this entity. * @param server the server in which to test the permission for this entity. * @param world the world in which to test the permission for this entity. - * @return a {@link ChatTreeNode} providing informations on how the effective permission is determined. + * @return a {@link ChatTreeNode} providing information on how the effective permission is determined. */ public ChatTreeNode debugPermission(String permission, String server, String world) { return Permissions.resolver.debugPermission(name, type, permission, server, world); diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java index 51b7bfe..e2b7d63 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermGroup.java @@ -11,7 +11,7 @@ import java.util.UUID; import java.util.stream.Collectors; /** - * Represents an group in the permission system. + * Represents a group in the permission system. */ public final class PermGroup extends PermEntity { /* package */ PermGroup(String name) { @@ -54,7 +54,7 @@ public final class PermGroup extends PermEntity { * Gets all the players that inherits from this group. * This method does not use cached data. * @param recursive true to include players that are in inherited groups. - * @return the players that inherits from this group. + * @return the players that inherit from this group. * @throws DBException if a database error occurs. */ public Set getInheritedPlayers(boolean recursive) throws DBException { @@ -69,7 +69,7 @@ public final class PermGroup extends PermEntity { /** * Tells if this group is a default group. - * A player inherits all default groups when they don’t explicitely inherit from at least one group. + * A player inherits all default groups when they don’t explicitly inherit from at least one group. * @return true if this group is a default group, false otherwise. */ public boolean isDefault() { @@ -78,7 +78,7 @@ public final class PermGroup extends PermEntity { /** * Sets this group as a default group or not. - * All players that don’t explicitely inherit from at least one group will either start or stop implicitely + * All players that don’t explicitly inherit from at least one group will either start or stop implicitly * inheriting from this group. * @param deflt true to set this group as default, false to set is as not default. */ diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermPlayer.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermPlayer.java index c12f554..9a6e628 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermPlayer.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermPlayer.java @@ -8,7 +8,7 @@ import fr.pandacube.lib.permissions.PermissionsCachedBackendReader.CachedPlayer; import fr.pandacube.lib.permissions.SQLPermissions.EntityType; /** - * Represents an player in the permission system. + * Represents a player in the permission system. */ public final class PermPlayer extends PermEntity { private final UUID playerId; @@ -84,7 +84,7 @@ public final class PermPlayer extends PermEntity { /** * Tells if this player has been assigned to the default groups. - * @return true if this player has been assigned to the default groups, or false if this player belongs explicitely + * @return true if this player has been assigned to the default groups, or false if this player belongs explicitly * to their groups. */ public boolean isUsingDefaultGroups() { @@ -92,7 +92,7 @@ public final class PermPlayer extends PermEntity { } /** - * Sets the group this player will now inheritate, removing all previously inherited groups. + * Sets the group this player will now inherit, removing all previously inherited groups. * To keep the other inherited groups, use {@link #addGroup(String)}. * @param group the name of the group to inherit from. */ @@ -101,7 +101,7 @@ public final class PermPlayer extends PermEntity { } /** - * Sets the group this player will now inheritate, removing all previously inherited groups. + * Sets the group this player will now inherit, removing all previously inherited groups. * To keep the other inherited groups, use {@link #addGroup(PermGroup)}. * @param group the group to inherit from. */ @@ -110,7 +110,7 @@ public final class PermPlayer extends PermEntity { } /** - * Makes this player inherit the provided group, keeping the other groups they already inherits from. + * Makes this player inherit the provided group, keeping the other groups they already inherit from. * @param group the name of the group to inherit from. */ public void addGroup(String group) { @@ -118,7 +118,7 @@ public final class PermPlayer extends PermEntity { } /** - * Makes this player inherit the provided group, keeping the other groups they already inherits from. + * Makes this player inherit the provided group, keeping the other groups they already inherit from. * @param group the group to inherit from. */ public void addGroup(PermGroup group) { diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java index 7f1341d..0dc903b 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java @@ -42,7 +42,7 @@ public class PermissionExpressionParser { * @throws IllegalArgumentException if the expression is not correct. * @return the result of the evaluation of the permission expression. */ - public static boolean evaluate(String permString, LitteralPermissionTester permTester) { + public static boolean evaluate(String permString, LiteralPermissionTester permTester) { try { return PERMISSION_EVALUATOR.evaluate(permString, permTester); } catch (IllegalArgumentException e) { @@ -53,7 +53,7 @@ public class PermissionExpressionParser { /** * Functional interface that converts a string into a boolean. */ - public interface LitteralPermissionTester extends Function { } + public interface LiteralPermissionTester extends Function { } @@ -90,7 +90,7 @@ public class PermissionExpressionParser { protected Boolean toValue(String literal, Object evaluationContext) { if (literal.contains(" ") || literal.contains("|") || literal.contains("&")) throw new IllegalArgumentException("Unable to parse the following part of permission expression as one permission node: '" + literal + "'"); - return evaluationContext instanceof LitteralPermissionTester pt ? pt.apply(literal) : false; + return evaluationContext instanceof LiteralPermissionTester pt ? pt.apply(literal) : false; } @Override diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/Permissions.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/Permissions.java index 331229f..070156d 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/Permissions.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/Permissions.java @@ -79,7 +79,7 @@ public class Permissions { } /** - * Clears all the cached data (players and groupds) and fetch all the groups data from the database. + * Clears all the cached data (players and groups) and fetch all the groups' data from the database. * The clearing and fetching of the data is made asynchronously in a new thread. * @param then the action to perform after the cache has been updated. * @throws IllegalStateException if the permission system was not initialized properly. @@ -105,7 +105,7 @@ public class Permissions { } /** - * Asks the permission system to preventively and asynchronoulsy cache the data of the provided player. + * Asks the permission system to preventively and asynchronously cache the data of the provided player. * This can be called as soon as possible when a player connects, so the permission data of the player are * accessible as soon as possible when they are needed. * @param playerId the UUID of the player. diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsCachedBackendReader.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsCachedBackendReader.java index 0de67c0..c65d1b4 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsCachedBackendReader.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsCachedBackendReader.java @@ -303,9 +303,9 @@ import fr.pandacube.lib.util.Log; public final boolean deflt; public final List inheritances = new ArrayList<>(); private CachedGroup(String n, String p, String s, - boolean dflt, Map> perms) { + boolean deflt, Map> perms) { super(n, p, s, perms); - deflt = dflt; + this.deflt = deflt; } diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java index b992e9e..9fd807f 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java @@ -173,8 +173,8 @@ import fr.pandacube.lib.util.Log; ChatTreeNode node = new ChatTreeNode(c); if (result == null && !conflict && !inheritances.isEmpty()) { - // there is nothing interesting to show on current or subnode - node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevety)").darkGray().italic())); + // there is nothing interesting to show on current or sub node + node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevity)").darkGray().italic())); return node; } @@ -364,9 +364,9 @@ import fr.pandacube.lib.util.Log; .collect(Collectors.toCollection(() -> EnumSet.noneOf(PermState.class))); boolean inheritancesGranted = inheritedPermissions.contains(PermState.GRANTED); - boolean inheritancesRevoqued = inheritedPermissions.contains(PermState.REVOQUED); - if (inheritancesGranted != inheritancesRevoqued) { - resolutionNode.result = inheritancesGranted ? PermState.GRANTED : PermState.REVOQUED; + boolean inheritancesRevoked = inheritedPermissions.contains(PermState.REVOKED); + if (inheritancesGranted != inheritancesRevoked) { + resolutionNode.result = inheritancesGranted ? PermState.GRANTED : PermState.REVOKED; } else if (inheritancesGranted) { resolutionNode.conflictMessage = (resolutionNode.conflictMessage == null ? "" : (resolutionNode.conflictMessage + " ; ")) @@ -435,28 +435,28 @@ import fr.pandacube.lib.util.Log; boolean explicitGranted = foundPerms.stream() .anyMatch(n -> n.type == PermType.EXPLICIT && n.result == Boolean.TRUE); - boolean explicitRevoqued = foundPerms.stream() + boolean explicitRevoked = foundPerms.stream() .anyMatch(n -> n.type == PermType.EXPLICIT && n.result == Boolean.FALSE); boolean wildcardGranted = foundPerms.stream() .anyMatch(n -> n.type == PermType.WILDCARD && n.result == Boolean.TRUE); - boolean wildcardRevoqued = foundPerms.stream() + boolean wildcardRevoked = foundPerms.stream() .anyMatch(n -> n.type == PermType.WILDCARD && n.result == Boolean.FALSE); - if (explicitGranted != explicitRevoqued) { + if (explicitGranted != explicitRevoked) { result = PermState.of(explicitGranted); - if (!wildcardGranted && !wildcardRevoqued) { } - else if (wildcardGranted && wildcardRevoqued) { + if (!wildcardGranted && !wildcardRevoked) { } + else if (wildcardGranted && wildcardRevoked) { conflict = "Self explicit permission defined but conflict between self wildcard permissions"; } else if (explicitGranted == wildcardGranted) { - conflict = "Unnecessary explicit permission already granted by self wildcard permissions"; // redundent explicit perm + conflict = "Unnecessary explicit permission already granted by self wildcard permissions"; // redundant explicit perm } } else if (explicitGranted) { conflict = "Unsolvable conflit between explicit permissions"; } - else if (wildcardGranted != wildcardRevoqued) { + else if (wildcardGranted != wildcardRevoked) { result = PermState.of(wildcardGranted); } else if (wildcardGranted) { @@ -500,8 +500,8 @@ import fr.pandacube.lib.util.Log; selfPermissions.forEach(p -> node.children.add(p.toDisplayTreeNode())); if (result == PermState.UNDEFINED && !conflict && !inheritances.isEmpty()) { - // there is nothing interesting to show on current or subnode - node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevety)").darkGray().italic())); + // there is nothing interesting to show on current or sub node + node.children.add(new ChatTreeNode(Chat.text("(Inheritances hidden for brevity)").darkGray().italic())); return node; } @@ -551,12 +551,12 @@ import fr.pandacube.lib.util.Log; private enum PermState { GRANTED(true), - REVOQUED(false), + REVOKED(false), UNDEFINED(null); final Boolean value; PermState(Boolean v) { value = v; } private static PermState of(Boolean v) { - return v == null ? UNDEFINED : v ? GRANTED : REVOQUED; + return v == null ? UNDEFINED : v ? GRANTED : REVOKED; } } diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/SQLPermissions.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/SQLPermissions.java index 070a064..b3907b0 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/SQLPermissions.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/SQLPermissions.java @@ -9,7 +9,7 @@ import fr.pandacube.lib.db.SQLField; public class SQLPermissions extends SQLElement { /** - * Instanciate a new entry in the table. + * Instantiate a new entry in the table. */ public SQLPermissions() { super(); diff --git a/pandalib-permissions/src/test/java/fr/pandacube/lib/permissions/PermissionExpressionParserTest.java b/pandalib-permissions/src/test/java/fr/pandacube/lib/permissions/PermissionExpressionParserTest.java index 0ead916..6c926f8 100644 --- a/pandalib-permissions/src/test/java/fr/pandacube/lib/permissions/PermissionExpressionParserTest.java +++ b/pandalib-permissions/src/test/java/fr/pandacube/lib/permissions/PermissionExpressionParserTest.java @@ -1,16 +1,16 @@ package fr.pandacube.lib.permissions; -import fr.pandacube.lib.permissions.PermissionExpressionParser.LitteralPermissionTester; -import org.junit.Before; +import fr.pandacube.lib.permissions.PermissionExpressionParser.LiteralPermissionTester; import org.junit.Test; import static fr.pandacube.lib.permissions.PermissionExpressionParser.evaluate; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class PermissionExpressionParserTest { - java.util.List pList = java.util.Arrays.asList("p1.cmd", "p1.toto", "p2.lol"); - LitteralPermissionTester tester = p -> pList.contains(p); + final java.util.List pList = java.util.Arrays.asList("p1.cmd", "p1.toto", "p2.lol"); + final LiteralPermissionTester tester = pList::contains; @Test public void evaluateTrue() { diff --git a/pandalib-players-permissible/src/main/java/fr/pandacube/lib/players/permissible/PermissibleOffPlayer.java b/pandalib-players-permissible/src/main/java/fr/pandacube/lib/players/permissible/PermissibleOffPlayer.java index 650020b..c149c9d 100644 --- a/pandalib-players-permissible/src/main/java/fr/pandacube/lib/players/permissible/PermissibleOffPlayer.java +++ b/pandalib-players-permissible/src/main/java/fr/pandacube/lib/players/permissible/PermissibleOffPlayer.java @@ -68,9 +68,9 @@ public interface PermissibleOffPlayer extends AbstractOffPlayer { * Tells if this player has the specified permission. * If the player is online, this will redirect the * method call to the {@link PermissibleOnlinePlayer} instance, - * that MUST override this current method to avoid recussive + * that MUST override this current method to avoid recursive * loop. - * If the player is offline, it just call the Pandacube + * If the player is offline, it just calls the Pandacube * permission system. * @param permission the permission node to test * @return whether this player has the provided permission @@ -89,9 +89,9 @@ public interface PermissibleOffPlayer extends AbstractOffPlayer { * Tells if this player has the permission resulted from the provided expression. * If the player is online, this will redirect the * method call to the {@link PermissibleOnlinePlayer} instance, - * that MUST override this current method to avoid recussive + * that MUST override this current method to avoid recursive * loop. - * If the player is offline, it just call the Pandacube + * If the player is offline, it just calls the Pandacube * permission system. * @param permissionExpression the permission node to test * @return whether this player has the provided permission @@ -145,7 +145,7 @@ public interface PermissibleOffPlayer extends AbstractOffPlayer { } /** - * Tells if the this player is part of the specified group. + * Tells if this player is part of the specified group. * @param group the permissions group * @return true if this player is part of the group, * false otherwise diff --git a/pandalib-players/pom.xml b/pandalib-players/pom.xml index 980b7af..1bbbd90 100644 --- a/pandalib-players/pom.xml +++ b/pandalib-players/pom.xml @@ -21,12 +21,12 @@ ${project.version} - + 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 f860204..b382e55 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 @@ -29,7 +29,7 @@ public interface AbstractOffPlayer { /** * Indicate if this player is connected to the current node (server or proxy, depending on interface implementation). - * @return wether the player is online or not. + * @return weather the player is online or not. */ boolean isOnline(); diff --git a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java index ea26cc9..fc47876 100644 --- a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java +++ b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java @@ -53,7 +53,7 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer { /** * Tells if this online player has the specified permission. * @param permission the permission to test on that player. - * @return weither this player has the specified permission or not. + * @return weather this player has the specified permission or not. * @implSpec Implementation of this method should call the permission system of their environment (paper/bungee), * so this method will work independently of the usage of the 'pandalib-permissions' module. */ @@ -90,7 +90,7 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer { *

* This method differs from {@link #sendMessage(ComponentLike)} with the fact that this method sends the message * only if {@link #canChat()} returns true. - * The message sent to the client is still a SYSTEM messge, due to CHAT messages required to be signed. + * The message sent to the client is still a SYSTEM message, due to CHAT messages required to be signed. * @param message the message to display as CHAT message. */ default void sendChatMessage(ComponentLike message) { @@ -203,13 +203,13 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer { /** * Tells if the client has configured the main hand on the left. - * @return true if the player’s character is left handed, false otherwise. + * @return true if the player’s character is left-handed, false otherwise. */ boolean isLeftHanded(); /** * Tells if the client has configured the main hand on the right. - * @return true if the player’s character is right handed, false otherwise. + * @return true if the player’s character is right-handed, false otherwise. */ boolean isRightHanded(); @@ -279,8 +279,8 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer { * Tells if the player can send chat messages or receive chat messages from other players, according to their client * configuration. *

- * Chat messages represent public communication between players. By default, it only include actual chat message. - * This method may be used in commands like /me, /afk or the login/logout broadcasted messages. + * Chat messages represent public communication between players. By default, it only includes actual chat message. + * This method may be used in commands like /me, /afk or the login/logout broadcast messages. * @return true if the player can send chat messages or receive chat messages from other players, false otherwise. */ default boolean canChat() { 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 b835d47..2e97553 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 @@ -258,7 +258,7 @@ public abstract class AbstractPlayerManager - * This method doesn’t restrict to a specific permission. To change this behaviour, use + * This method doesn't restrict to a specific permission. To change this behaviour, use * {@link #broadcast(ComponentLike, boolean, boolean, String, UUID)}. * * @param message the message to send. * @param prefix if the server prefix will be prepended to the message. * @param console if the message must be displayed in the console. - * @param sourcePlayer specifiy the eventual player that is the source of the message. + * @param sourcePlayer specify the eventual player that is the source of the message. * If null, the message will be sent as a SYSTEM chat message. * If not null, the message will be sent as a CHAT message, and will not be sent * to players ignoring the provided player (if implemented). @@ -354,7 +354,7 @@ public abstract class AbstractPlayerManager - * This method doesn’t restrict to a specific permission. To change this behaviour, use + * This method doesn't restrict to a specific permission. To change this behaviour, use * {@link #broadcast(ComponentLike, boolean, boolean, String)}. * * @param message the message to send. @@ -372,12 +372,12 @@ public abstract class AbstractPlayerManager - * This method doesn’t restrict to a specific permission. To change this behaviour, use + * This method doesn't restrict to a specific permission. To change this behaviour, use * {@link #broadcast(ComponentLike, boolean, String, UUID)}. * * @param message the message to send. * @param prefix if the server prefix will be prepended to the message. - * @param sourcePlayer specifiy the eventual player that is the source of the message. + * @param sourcePlayer specify the eventual player that is the source of the message. * If null, the message will be sent as a SYSTEM chat message. * If not null, the message will be sent as a CHAT message, and will not be sent * to players ignoring the provided player (if implemented). @@ -396,7 +396,7 @@ public abstract class AbstractPlayerManager - * This method doesn’t restrict to a specific permission. To change this behaviour, use + * This method doesn't restrict to a specific permission. To change this behaviour, use * {@link #broadcast(ComponentLike, boolean, String)}. * * @param message the message to send. diff --git a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/Reflect.java b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/Reflect.java index 54c030d..fb6c2d3 100644 --- a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/Reflect.java +++ b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/Reflect.java @@ -37,7 +37,7 @@ public class Reflect { /** * Wraps the class of the provided object into a {@link ReflectClass}. - * @param instance the object wrom which to get the class using {@link Object#getClass()}. + * @param instance the object from which to get the class using {@link Object#getClass()}. * @return a {@link ReflectClass} wrapping the provided object’s class. * @throws IllegalArgumentException if {@code instance} is null. */ diff --git a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectClass.java b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectClass.java index 1b24fe5..2de4da5 100644 --- a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectClass.java +++ b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectClass.java @@ -57,7 +57,7 @@ public class ReflectClass { * @param name the method name. * @param paramTypes the types of the method parameters. * @return a {@link ReflectMethod} wrapping the requested {@link Method}. - * @throws NoSuchMethodException if the requested method doesn’t exists in the wrapped class. + * @throws NoSuchMethodException if the requested method doesn't exist in the wrapped class. */ public ReflectMethod method(String name, Class... paramTypes) throws NoSuchMethodException { return method(new MethodIdentifier(name, paramTypes), false); @@ -69,7 +69,7 @@ public class ReflectClass { * @param name the method name. * @param paramTypes the types of the method parameters. * @return a {@link ReflectMethod} wrapping the requested {@link Method}. - * @throws NoSuchMethodException if the requested method doesn’t exists in the wrapped class. + * @throws NoSuchMethodException if the requested method doesn't exist in the wrapped class. */ public ReflectMethod filteredMethod(String name, Class... paramTypes) throws NoSuchMethodException { return method(new MethodIdentifier(name, paramTypes), true); @@ -93,7 +93,7 @@ public class ReflectClass { * Provides a {@link ReflectConstructor} wrapping the requested {@link Constructor}. * @param paramTypes the types of the constructor parameters. * @return a {@link ReflectConstructor} wrapping the requested {@link Constructor}. - * @throws NoSuchMethodException if the requested constructor doesn’t exists in the wrapped class. + * @throws NoSuchMethodException if the requested constructor doesn't exist in the wrapped class. */ public ReflectConstructor constructor(Class... paramTypes) throws NoSuchMethodException { return constructor(new ConstructorIdentifier(paramTypes), false); @@ -104,7 +104,7 @@ public class ReflectClass { * filtering in the {@link Class} implementation. * @param paramTypes the types of the constructor parameters. * @return a {@link ReflectConstructor} wrapping the requested {@link Constructor}. - * @throws NoSuchMethodException if the requested constructor doesn’t exists in the wrapped class. + * @throws NoSuchMethodException if the requested constructor doesn't exist in the wrapped class. */ public ReflectConstructor filteredConstructor(Class... paramTypes) throws NoSuchMethodException { return constructor(new ConstructorIdentifier(paramTypes), true); @@ -128,7 +128,7 @@ public class ReflectClass { * Provides a {@link ReflectField} wrapping the requested {@link Field}. * @param name the name of the field. * @return a {@link ReflectField} wrapping the requested {@link Field}. - * @throws NoSuchFieldException if the requested field doesn’t exists in the wrapped class. + * @throws NoSuchFieldException if the requested field doesn't exist in the wrapped class. */ public ReflectField field(String name) throws NoSuchFieldException { return field0(name, false); @@ -139,10 +139,11 @@ public class ReflectClass { * {@link Class} implementation. * @param name the name of the field. * @return a {@link ReflectField} wrapping the requested {@link Field}. - * @throws NoSuchFieldException if the requested field doesn’t exists in the wrapped class. + * @throws NoSuchFieldException if the requested field doesn't exist in the wrapped class. * @deprecated on Java 17, does not work due to module encapsulation, it is impossible to bypass the Java reflection * API internal filtering. */ + @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated(since = "Java 17") public ReflectField filteredField(String name) throws NoSuchFieldException { return field0(name, true); diff --git a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectConstructor.java b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectConstructor.java index 3e46103..59ea115 100644 --- a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectConstructor.java +++ b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/ReflectConstructor.java @@ -61,7 +61,7 @@ public final class ReflectConstructor extends ReflectMember extends ReflectMember { - /* Those fields are used to modify the value of a static variable. Depending of the current Java version, + /* Those fields are used to modify the value of a static variable. Depending on the current Java version, * one of them will be used for this purpose. */ private static sun.misc.Unsafe sunMiscUnsafeInstance; @@ -130,7 +130,7 @@ public final class ReflectField extends ReflectMember the type of the reflect wrapper for the elements of this list. + * @param the type of the reflection wrapper for the elements of this list. */ public class ReflectListWrapper extends MappedListView implements ReflectWrapperTypedI> { private final Class expectedWrapperClass; - /* package */ ReflectListWrapper(Class expectedWrapperClass) { - this(ArrayList::new, expectedWrapperClass); - } - - - @SuppressWarnings("unchecked") - /* package */ ReflectListWrapper(Supplier> listCreator, Class expectedWrapperClass) { - this((List) (listCreator == null ? new ArrayList<>() : listCreator.get()), expectedWrapperClass); - } - /* package */ ReflectListWrapper(List wrappedList, Class expectedWrapperClass) { super(wrappedList, el -> ReflectWrapper.wrap(el, expectedWrapperClass), ReflectWrapper::unwrap); this.expectedWrapperClass = expectedWrapperClass; @@ -45,4 +33,17 @@ public class ReflectListWrapper extends MappedListVie public List subList(int fromIndex, int toIndex) { return new ReflectListWrapper<>(backend.subList(fromIndex, toIndex), expectedWrapperClass); } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object o) { + return o instanceof List l && backend.equals(l instanceof ReflectListWrapper rw ? rw.backend : l); + } + + @Override + public int hashCode() { + return backend.hashCode(); + } } diff --git a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapper.java b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapper.java index 2af7d67..a0478fc 100644 --- a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapper.java +++ b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapper.java @@ -11,7 +11,7 @@ import java.util.Objects; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; /** - * Superclass of all reflect wrapper objects. + * Superclass of all reflection wrapper objects. */ public abstract class ReflectWrapper implements ReflectWrapperI { @@ -20,7 +20,7 @@ public abstract class ReflectWrapper implements ReflectWrapperI { /** * Unwraps the object from the provided reflect wrapper. - * @param wr the reflect wrapper from which to get the object. + * @param wr the reflection wrapper from which to get the object. * @return the object from the provided reflect wrapper. */ public static Object unwrap(ReflectWrapperI wr) { @@ -29,7 +29,7 @@ public abstract class ReflectWrapper implements ReflectWrapperI { /** * Unwraps the object from the provided reflect wrapper. - * @param wr the reflect wrapper from which to get the object. + * @param wr the reflection wrapper from which to get the object. * @param the type of the wrapped object. * @return the object from the provided reflect wrapper. */ @@ -38,11 +38,11 @@ public abstract class ReflectWrapper implements ReflectWrapperI { } /** - * Wraps the provided runtime object into a reflect wrapper. - * If a wrapper instance is already known, it will return it instead of instanciating a new one. + * Wraps the provided runtime object into a reflection wrapper. + * If a wrapper instance is already known, it will return it instead of instantiating a new one. * It is better to call {@link #wrap(Object, Class)} if you know the type of wrapper needed. * @param runtimeObj the object to wrap. - * @return the reflect wrapper wrapping the provided object. + * @return the reflection wrapper wrapping the provided object. * @throws ClassCastException if the runtime class of the object is not handled by the expected wrapper class or its * subclasses. * @throws IllegalArgumentException if the runtime class of the object is not handled by any of the registered @@ -53,14 +53,14 @@ public abstract class ReflectWrapper implements ReflectWrapperI { } /** - * Wraps the provided runtime object (with has a known type) into a reflect wrapper. - * If a wrapper instance is already known, it will return it instead of instanciating a new one. + * Wraps the provided runtime object (with has a known type) into a reflection wrapper. + * If a wrapper instance is already known, it will return it instead of instantiating a new one. * It is better to call {@link #wrap(Object, Class)} if you know the type of wrapper needed. * @param runtimeObj the object to wrap. - * @param expectedWrapperClass the reflect wrapper class expected to be returned. - * @param the type of the reflect wrapper. + * @param expectedWrapperClass the reflection wrapper class expected to be returned. + * @param the type of the reflection wrapper. * @param the type of the wrapped object. - * @return the reflect wrapper wrapping the provided object. + * @return the reflection wrapper wrapping the provided object. * @throws ClassCastException if the runtime class of the object is not handled by the expected wrapper class or its * subclasses. * @throws IllegalArgumentException if the runtime class of the object is not handled by any of the registered @@ -71,13 +71,13 @@ public abstract class ReflectWrapper implements ReflectWrapperI { } /** - * Wraps the provided runtime object into a reflect wrapper. - * If a wrapper instance is already known, it will return it instead of instanciating a new one. - * It is better to call {@link #wrap(Object, Class)} if you know the type of wrapper needed. + * Wraps the provided runtime object into a reflection wrapper. + * If a wrapper instance is already known, it will return it instead of instantiating a new one. + * It is better to call {@link #wrap(Object)} if you don't know the type of wrapper needed. * @param runtimeObj the object to wrap. - * @param expectedWrapperClass the reflect wrapper class expected to be returned. - * @param the type of the reflect wrapper. - * @return the reflect wrapper wrapping the provided object. + * @param expectedWrapperClass the reflection wrapper class expected to be returned. + * @param the type of the reflection wrapper. + * @return the reflection wrapper wrapping the provided object. * @throws ClassCastException if the runtime class of the object is not handled by the expected wrapper class or its * subclasses. * @throws IllegalArgumentException if the runtime class of the object is not handled by any of the registered @@ -117,9 +117,9 @@ public abstract class ReflectWrapper implements ReflectWrapperI { } ReflectConstructor constructor = WrapperRegistry.getWrapperConstructorOfWrapperClass(wrapperClass); if (constructor == null) { - throw new IllegalStateException("Unable to find a constructor to instanciate " + wrapperClass + " to wrap an instance of " + runtimeObj); + throw new IllegalStateException("Unable to find a constructor to instantiate " + wrapperClass + " to wrap an instance of " + runtimeObj); } - ReflectWrapperI wrapper = wrapEx(() -> constructor.instanciate(runtimeObj)); + ReflectWrapperI wrapper = wrapEx(() -> constructor.instantiate(runtimeObj)); // added to cache by constructor @SuppressWarnings("unchecked") W wr = (W) wrapper; @@ -128,11 +128,11 @@ public abstract class ReflectWrapper implements ReflectWrapperI { } /** - * Wraps the provided runtime list into a reflect list wrapper. + * Wraps the provided runtime list into a reflection list wrapper. * @param runtimeList the list of runtime object to wrap. * @param expectedWrapperClass the wrapper class of the objects in this list. * @param the type of reflect wrapper for the objects in this list. - * @return a reflect list wrapper wrapping the provided list. + * @return a reflection list wrapper wrapping the provided list. */ public static ReflectListWrapper wrapList(List runtimeList, Class expectedWrapperClass) { return new ReflectListWrapper<>(runtimeList, expectedWrapperClass); @@ -152,7 +152,7 @@ public abstract class ReflectWrapper implements ReflectWrapperI { private final Object reflectObject; /** - * Instanciate this Reflect Wrapper with the provided object. + * Instantiate this reflection wrapper with the provided object. * Any subclasses should not make their constructor public since the instanciation is managed by {@link #wrap(Object, Class) wrap(...)}. * @param obj the object to wrap. It must be an instance of the {@link #__getRuntimeClass() runtime class} of this * wrapper class. diff --git a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapperTyped.java b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapperTyped.java index fcc3067..1fdd676 100644 --- a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapperTyped.java +++ b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/ReflectWrapperTyped.java @@ -7,7 +7,7 @@ package fr.pandacube.lib.reflect.wrapper; public abstract class ReflectWrapperTyped extends ReflectWrapper implements ReflectWrapperTypedI { /** - * Instanciate this Reflect Wrapper with the provided object. + * Instantiate this reflection Wrapper with the provided object. * Any subclasses should not make their constructor public since the instanciation is managed by {@link #wrap(Object, Class) wrap(...)}. * @param obj the object to wrap. It must be an instance of the {@link #__getRuntimeClass() runtime class} of this * wrapper class. diff --git a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/package-info.java b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/package-info.java index 43dee25..8a950ad 100644 --- a/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/package-info.java +++ b/pandalib-reflect/src/main/java/fr/pandacube/lib/reflect/wrapper/package-info.java @@ -1,7 +1,7 @@ /** * Set of class allowing applications to implement almost transparent reflection classes. * The goal it to implement the class, methods and fields that the application have only access through reflection, and - * reflection call when these implementation are called. + * reflection call when these implementations are called. * Each of those reflection classes must extend {@link fr.pandacube.lib.reflect.wrapper.ReflectWrapper} (or, if it’s * an interface, must extend {@link fr.pandacube.lib.reflect.wrapper.ReflectWrapperI}). The implemented class wraps * the reflected object and redirects the method calls to them using reflection. diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/BiMap.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/BiMap.java index 7703baa..27116d4 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/BiMap.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/BiMap.java @@ -10,9 +10,9 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; /** - * A bi-direction map storing in a synchronized way a {@code forwardMap} that store the key to value mapping, and a + * A bidirectional map storing in a synchronized way a {@code forwardMap} that store the key to value mapping, and a * {@code backwardMap} that store the value to key mapping. - * All the keys and value are always unique in this bi-directional map. + * All the keys and value are always unique in this bidirectional map. * This class is fully thread safe. * @param the type of the "key" * @param the type of the "value" @@ -25,7 +25,7 @@ public class BiMap implements Iterable> { protected final Map forwardMap; /** - * The backend bawkward map + * The backend backward map */ protected final Map backwardMap; @@ -45,14 +45,14 @@ public class BiMap implements Iterable> { } /** - * Create a new bi-directional map with {@link HashMap} as the two backend maps. + * Create a new bidirectional map with {@link HashMap} as the two backend maps. */ public BiMap() { this(HashMap::new); } /** - * Create a new bi-directional map with {@link HashMap} as the two backend maps, and filled with the provided source + * Create a new bidirectional map with {@link HashMap} as the two backend maps, and filled with the provided source * {@link Map}. * @param source the source to fill the new {@link BiMap}. */ @@ -72,9 +72,9 @@ public class BiMap implements Iterable> { } /** - * Associate the provided key and value to each other in this bi-directional map. + * Associate the provided key and value to each other in this bidirectional map. * Since the {@link BiMap} cannot have duplicate keys or values: if a key is already present, the currently mapped - * value will be removed from the map. Also if a value is already present, the currently mapped key will also be + * value will be removed from the map. Also, if a value is already present, the currently mapped key will also be * removed. * @param k the key. * @param v the value. @@ -92,9 +92,9 @@ public class BiMap implements Iterable> { /** - * Associate the provided key and value to each other in this bi-directional map. + * Associate the provided key and value to each other in this bidirectional map. * Since the {@link BiMap} cannot have duplicate keys or values: if a key is already present, the currently mapped - * value will be removed from the map. Also if a value is already present, the currently mapped key will also be + * value will be removed from the map. Also, if a value is already present, the currently mapped key will also be * removed. * @param entry the entry with a key and value. */ @@ -103,8 +103,8 @@ public class BiMap implements Iterable> { } /** - * Put the content of the provided map into this bi-directional map. - * This methods will call the {@link #put(Entry)} method successively in the order of the provided Map’s iterator. + * Put the content of the provided map into this bidirectional map. + * This method will call the {@link #put(Entry)} method successively in the order of the provided Map’s iterator. * @param source the source map. */ public void putAll(Map source) { @@ -187,7 +187,7 @@ public class BiMap implements Iterable> { /** * Returns an unmodifiable {@link Set} view of this map. - * It’s iteration order will depends on the implementation of the {@code forwardMap}. + * It’s iteration order will depend on the implementation of the {@code forwardMap}. * @return an unmodifiable {@link Set} view of this map. * @see Map#entrySet() */ @@ -197,7 +197,7 @@ public class BiMap implements Iterable> { /** * Returns an iterator of this map. - * It’s iteration order will depends on the implementation of the {@code forwardMap}. + * It’s iteration order will depend on the implementation of the {@code forwardMap}. * @return an iterator of this map. * @see Map#entrySet() * @see Set#iterator() @@ -209,7 +209,7 @@ public class BiMap implements Iterable> { /** * Returns an unmodifiable {@link Set} view of the keys contained in this map. - * It’s iteration order will depends on the implementation of the {@code forwardMap}’s key set. + * It’s iteration order will depend on the implementation of the {@code forwardMap}’s key set. * @return an unmodifiable {@link Set} view of the keys contained in this map. * @see Map#keySet() */ @@ -219,7 +219,7 @@ public class BiMap implements Iterable> { /** * Returns an unmodifiable {@link Set} view of the values contained in this map. - * It’s iteration order will depends on the implementation of the {@code backwardMap}’s key set. + * It’s iteration order will depend on the implementation of the {@code backwardMap}’s key set. * @return an unmodifiable {@link Set} view of the values contained in this map. * @see Map#keySet() */ @@ -228,16 +228,16 @@ public class BiMap implements Iterable> { } /** - * Returns an unmodifiable {@link Map} view of the {@code forwardMap} of this bi-directional map. - * It’s iteration order will depends on the implementation of the {@code forwardMap}. - * @return an unmodifiable {@link Map} view of the {@code forwardMap} of this bi-directional map. + * Returns an unmodifiable {@link Map} view of the {@code forwardMap} of this bidirectional map. + * It’s iteration order will depend on the implementation of the {@code forwardMap}. + * @return an unmodifiable {@link Map} view of the {@code forwardMap} of this bidirectional map. */ public Map asMap() { return Collections.unmodifiableMap(forwardMap); } /** - * Create a reversed view of this bi-directional map. + * Create a reversed view of this bidirectional map. * Since the returned {@link BiMap} is a view of this {@link BiMap}, any change to either of those will affect both * of them. Also, calling {@code bimap.reversedView().reversedView()} will return the original instance * {@code bimap} since calling this method will cache each map into the respective reversed view. diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/DistanceUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/DistanceUtil.java index b28a2d9..c79c3cf 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/DistanceUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/DistanceUtil.java @@ -13,20 +13,20 @@ public class DistanceUtil { * specified metric prefix * @param meterDist the distance to display, in meter * @param precision the number of digit to display after the decimal separator - * @param desiredUnits the prefered unit prefix to use for convertion. + * @param desiredUnits the preferred unit prefix to use for conversion. * @return a string representation of the provided distance */ public static String distanceToString(double meterDist, int precision, DistanceUnit... desiredUnits) { Arrays.sort(desiredUnits); - DistanceUnit choosenUnit = desiredUnits[0]; // la plus petite unitée + DistanceUnit chosenUnit = desiredUnits[0]; // la plus petite unité for (DistanceUnit unit : desiredUnits) { - if (meterDist / unit.multiplicator < 1) continue; - choosenUnit = unit; + if (meterDist / unit.multiplier < 1) continue; + chosenUnit = unit; } - if (choosenUnit != desiredUnits[0] && precision <= 2) precision = 2; + if (chosenUnit != desiredUnits[0] && precision <= 2) precision = 2; String precisionFormat = "##0"; if (precision > 0) precisionFormat += "."; @@ -34,9 +34,9 @@ public class DistanceUtil { DecimalFormat df = new DecimalFormat(precisionFormat); - double dist = meterDist / choosenUnit.multiplicator; + double dist = meterDist / chosenUnit.multiplier; - return df.format(dist) + choosenUnit.unitStr; + return df.format(dist) + chosenUnit.unitStr; } /** @@ -54,7 +54,7 @@ public class DistanceUtil { } /** - * Enumeration of comonly used distance metric unit + * Enumeration of commonly used distance metric unit */ public enum DistanceUnit { @@ -91,15 +91,15 @@ public class DistanceUtil { /** * The value of this unit in meter. */ - public final double multiplicator; + public final double multiplier; /** * String representation of the unit symbol. */ public final String unitStr; - DistanceUnit(double mult, String s) { - multiplicator = mult; + DistanceUnit(double multiplier, String s) { + this.multiplier = multiplier; unitStr = s; } } diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/EnumUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/EnumUtil.java index 1f34a58..a52311a 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/EnumUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/EnumUtil.java @@ -60,7 +60,7 @@ public class EnumUtil { * * @param enumType the class of the enum in which to search * @param search the case-insensitive name of the enum value to return. - * @return the element found in the enum, or null if not found or if the provideid type is not an enum. + * @return the element found in the enum, or null if not found or if the provided type is not an enum. */ public static Enum searchUncheckedEnum(Class enumType, String search) { if (!enumType.isEnum()) diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/FileUtils.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/FileUtils.java index 1ca5a9d..f66d2f6 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/FileUtils.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/FileUtils.java @@ -28,17 +28,17 @@ public class FileUtils { * @param target the copy destination. * @throws IOException if an IO error occurs. * @throws IllegalStateException if the target destination already exists and is not a directory. - * @throws IllegalArgumentException if at least one of the parameter is null, or if the source doesn’t exists. + * @throws IllegalArgumentException if at least one of the parameter is null, or if the source doesn't exist. */ public static void copy(File source, File target) throws IOException { - if (source == null || !source.exists()) { - throw new IllegalArgumentException("source is null or doesn’t exists: " + source); + if (source == null || !source.exists() || !source.isDirectory()) { + throw new IllegalArgumentException("source is null or doesn't exist: " + source); } if (target == null) { throw new IllegalArgumentException("target cannot be null"); } if (target.exists() && !target.isDirectory()) { - throw new IllegalStateException("target file already exists: " + target); + throw new IllegalStateException("target file already exists but is not a directory: " + target); } BasicFileAttributes sourceAttr = Files.readAttributes(source.toPath(), BasicFileAttributes.class); if (sourceAttr.isDirectory()) { diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/LevenshteinDistance.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/LevenshteinDistance.java index 746a54c..5824b33 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/LevenshteinDistance.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/LevenshteinDistance.java @@ -7,7 +7,7 @@ import java.util.function.ToIntBiFunction; /** * Implementation of the Levenshtein distance algorithm * that operate on characters. Its purpose is to compute a "distance" between two strings of characters, that represents - * how many edition operations must be performed on the first string ({@code initialString}) to optain the second + * how many edition operations must be performed on the first string ({@code initialString}) to obtain the second * one ({@code finalString}). *

* All the parameters of the algorithm are configurable: @@ -23,7 +23,7 @@ import java.util.function.ToIntBiFunction; * between the two strings. *

* A more advanced usage offer the possibility to progressively compute a distance from a predefined - * {@code initialString} to a {@code finalString} that is feeded progressively using {@link #add(char)} or + * {@code initialString} to a {@code finalString} that is fed progressively using {@link #add(char)} or * {@link #add(String)}. This is useful if the {@code finalString} is an input that is currently being typed by the * user, so the application can progressively update a list of suggested words based on the distance. * For this usage, you can use those constructors to avoid initializing the {@code finalString}: diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/ListUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/ListUtil.java index 3298065..0be2d9e 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/ListUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/ListUtil.java @@ -3,7 +3,7 @@ package fr.pandacube.lib.util; import java.util.List; /** - * Provides utility methods related to lists. + * Provides utility methods for lists. */ public class ListUtil { diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/MappedListView.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/MappedListView.java index cf5b22e..767a5d2 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/MappedListView.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/MappedListView.java @@ -7,9 +7,9 @@ import java.util.ListIterator; import java.util.function.Function; /** - * A Wrapper list that provides a mapped view of the backend list. Every modification of this list will modify the bakend - * list. Each time a value is accessed or modified, the appropriate setter or getter is used to convert the value - * between the source {@code S} and the visible {@code T} type. + * A Wrapper list that provides a mapped view of the backend list. Every modification of this list will modify the + * backend list. Each time a value is accessed or modified, the appropriate setter or getter is used to convert the + * value between the source {@code S} and the visible {@code T} type. * @param the source (backend) type * @param the visible (mapped) type */ @@ -111,22 +111,6 @@ public class MappedListView extends AbstractList { backend.subList(fromIndex, toIndex).clear(); } - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object o) { - return backend.equals(o); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return backend.hashCode(); - } - /** * {@inheritDoc} */ diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/MemoryUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/MemoryUtil.java index e958a96..309f42f 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/MemoryUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/MemoryUtil.java @@ -36,19 +36,19 @@ public class MemoryUtil { break; } - String dispValue; + String displayValue; if (unit == roundTo) { - dispValue = "" + unit.toUnitRound(size, si); + displayValue = "" + unit.toUnitRound(size, si); } else { - dispValue = format.format(unit.toUnit(size, si)); + displayValue = format.format(unit.toUnit(size, si)); } - return (neg ? "-" : "") + dispValue + unit.unit(si); + return (neg ? "-" : "") + displayValue + unit.unit(si); } /** - * Generate a string representation of the provided memory amount, displayinh the value in byte (as is) and with the + * Generate a string representation of the provided memory amount, displaying the value in byte (as is) and with the * unit symbol {@code "o"}. *

* This method returns the unit symbol in French. @@ -62,7 +62,7 @@ public class MemoryUtil { /** - * Enumeration of comonly used unit of memory prefix. + * Enumeration of commonly used unit of memory prefix. */ public enum MemoryUnit { @@ -152,10 +152,10 @@ public class MemoryUtil { return unitMultiplier == null ? "o" : (unitMultiplier + (si ? "o" : "io")); } - MemoryUnit(long vTrad, long vSI, String uMult) { + MemoryUnit(long vTrad, long vSI, String uMultiplier) { valueTrad = vTrad; valueSI = vSI; - unitMultiplier = uMult; + unitMultiplier = uMultiplier; } } diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftVersion.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftVersion.java index e9c1d36..f84af55 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftVersion.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftVersion.java @@ -253,28 +253,28 @@ public enum MinecraftVersion { /** * Returns a string representation of all the Minecraft version of this enum value, using - * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "et" + * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "et" * ("and" in french). * * @return a string representation of this {@link MinecraftVersion}. - * @deprecated it uses the hardcoded french word "et" as the final word separator. + * @deprecated it uses the hardcoded French word "et" as the final word separator. * Use {@link #displayOptimizedListOfVersions(List, String)} with "et" as the last parameter instead. */ - @Deprecated + @Deprecated(forRemoval = true) public String toStringAnd() { return toString("et"); } /** * Returns a string representation of all the Minecraft version of this enum value, using - * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "ou" + * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "ou" * ("or" in french). * * @return a string representation of this {@link MinecraftVersion}. - * @deprecated it uses the hardcoded french word "ou" as the final word separator. + * @deprecated it uses the hardcoded French word "ou" as the final word separator. * Use {@link #displayOptimizedListOfVersions(List, String)} with "ou" as the last parameter instead. */ - @Deprecated + @Deprecated(forRemoval = true) public String toStringOr() { return toString("ou"); } @@ -316,30 +316,30 @@ public enum MinecraftVersion { /** * Generate a string representation of the provided list of version, using - * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "et" + * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "et" * ("and" in french). * * @param versions the minecraft versions to list * @return a string representation of the provided list of version. - * @deprecated it uses the hardcoded french word "et" as the final word separator. + * @deprecated it uses the hardcoded French word "et" as the final word separator. * Use {@link #displayOptimizedListOfVersions(List, String)} with "et" as the last parameter instead. */ - @Deprecated + @Deprecated(forRemoval = true) public static String displayOptimizedListOfVersionsAnd(List versions) { return displayOptimizedListOfVersions(versions, "et"); } /** * Generate a string representation of the provided list of version, using - * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the gramatical word "ou" + * {@link StringUtil#joinGrammatically(CharSequence, CharSequence, List)} with the grammatical word "ou" * ("or" in french). * * @param versions the minecraft versions to list * @return a string representation of the provided list of version. - * @deprecated it uses the hardcoded french word "ou" as the final word separator. + * @deprecated it uses the hardcoded French word "ou" as the final word separator. * Use {@link #displayOptimizedListOfVersions(List, String)} with "ou" as the last parameter instead. */ - @Deprecated + @Deprecated(forRemoval = true) public static String displayOptimizedListOfVersionsOr(List versions) { return displayOptimizedListOfVersions(versions, "ou"); } @@ -348,7 +348,7 @@ public enum MinecraftVersion { * Returns an optimized list of string representation of Minecraft version, that represent the provided list of * Minecraft version. *

- * This methods try to merge successive Minecraft version into a single string: for instance, all versions from 1.18 + * This method try to merge successive Minecraft version into a single string: for instance, all versions from 1.18 * to 1.18.2 are represented by the string "1.18.x"; all version from 1.14.1 to 1.14.4 are represented by the string * "1.14.1-1.14.4". *

diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftWebUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftWebUtil.java index f23e18e..0f88443 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftWebUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/MinecraftWebUtil.java @@ -10,17 +10,17 @@ public class MinecraftWebUtil { *

* Each colored part of the text will be contained in a {@code } tag with {@code class="cX"} where {@code X} * is the color code from 0 to F in uppercase. - * The bold, striked, underlined and italic parts will be contained in a {@code } tag with respectively the + * The bold, struck, underlined and italic parts will be contained in a {@code } tag with respectively the * classes {@code cL}, {@code cM}, {@code cN} and {@code cO}. * Some CSS properties are needed to apply the colors to the CSS classes. - * @param chatcolorPrefix the prefix used for the color codes + * @param chatColorPrefix the prefix used for the color codes * @param legacyText the legacy text to convert to HTML. - * @return The text formated in HTML. - * @implNote the current implementation does not yet supports the RGB colors. + * @return The text formatted in HTML. + * @implNote the current implementation does not yet support the RGB colors. */ // TODO update to support RGB colors (Bungee and Essentials notation). (see JS implementation at https://www.pandacube.fr/assets/js/global.js ) // TODO moves this to pandalib-chat and use Adventure API to help serializing to HTML - public static String fromMinecraftColorCodeToHTML(char chatcolorPrefix, String legacyText) + public static String fromMinecraftColorCodeToHTML(char chatColorPrefix, String legacyText) { String color_char = "0123456789abcdefr"; @@ -31,7 +31,7 @@ public class MinecraftWebUtil { for (int i=0; i - * You can generate the UUID programatically using {@link #getFromNickName(String)} and + * You can generate the UUID programmatically using {@link #getFromNickName(String)} and * {@link #getFromNickNames(String[])}. * * To use this class as a program, type @@ -23,7 +23,7 @@ public class OfflineUUID { /** * Generate the offline {@link UUID} of the provided player name. - * @param nickname the player name to optain the offline UUID from. + * @param nickname the player name to obtain the offline UUID from. * @return the offline {@link UUID} of the provided player name. */ public static UUID getFromNickName(String nickname) { @@ -33,7 +33,7 @@ public class OfflineUUID { /** * Generate the offline {@link UUID}s of the provided player names. - * @param nicknames an array of player name to optain the offline UUIDs from. + * @param nicknames an array of player name to obtain the offline UUIDs from. * @return the offline {@link UUID}s of the provided player name in an array, at the same order as the input. */ public static UUID[] getFromNickNames(String[] nicknames) { diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/RandomUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/RandomUtil.java index 2d5bc45..5a75f31 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/RandomUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/RandomUtil.java @@ -15,35 +15,35 @@ public class RandomUtil { public static final Random rand = new Random(); /** - * Returns a randomly generated integer between {@code minInclu} included and {@code maxExclu} excluded. + * Returns a randomly generated integer between {@code minInclusive} included and {@code maxExclusive} excluded. * This method is safer to use that Random#nextInt(int, int) because it does not check the validity of * the parameters. - * @param minInclu the minimum value, included. - * @param maxExclu the maximum value, excluded. - * @return a random number between {@code minInclu} included and {@code maxExclu} excluded. + * @param minInclusive the minimum value, included. + * @param maxExclusive the maximum value, excluded. + * @return a random number between {@code minInclusive} included and {@code maxExclusive} excluded. * @see Random#nextInt(int, int) - * @throws IllegalArgumentException if {@code minInclu} is greater than {@code maxExclu}. + * @throws IllegalArgumentException if {@code minInclusive} is greater than {@code maxExclusive}. */ - public static int nextIntBetween(int minInclu, int maxExclu) { - return minInclu + rand.nextInt(maxExclu - minInclu); + public static int nextIntBetween(int minInclusive, int maxExclusive) { + return minInclusive + rand.nextInt(maxExclusive - minInclusive); } /** - * Returns a randomly generated double between {@code minInclu} included and {@code maxExclu} excluded. + * Returns a randomly generated double between {@code minInclusive} included and {@code maxExclusive} excluded. * This method is safer to use that Random#nextDouble(double, double) because it does not check the validity of * the parameters - * @param minInclu the minimum value, included. - * @param maxExclu the maximum value, excluded. - * @return a random number between {@code minInclu} included and {@code maxExclu} excluded. + * @param minInclusive the minimum value, included. + * @param maxExclusive the maximum value, excluded. + * @return a random number between {@code minInclusive} included and {@code maxExclusive} excluded. * @see Random#nextDouble(double, double) */ - public static double nextDoubleBetween(double minInclu, double maxExclu) { - return minInclu + rand.nextDouble() * (maxExclu - minInclu); + public static double nextDoubleBetween(double minInclusive, double maxExclusive) { + return minInclusive + rand.nextDouble() * (maxExclusive - minInclusive); } /** * Returns a random element from the provided array. - * @param array the array in whith to pick a value randomly. + * @param array the array in which to pick a value randomly. * @return the value randomly picked from the array, or null if the array is null or empty. * @param the type of the array elements. * @see Random#nextInt(int) @@ -54,7 +54,7 @@ public class RandomUtil { /** * Returns a random element from the provided list. - * @param list the list in whith to pick a value randomly. + * @param list the list in which to pick a value randomly. * @return the value randomly picked from the list, or null if the array is null or empty. * @param the type of the list elements. * @see Random#nextInt(int) @@ -65,7 +65,7 @@ public class RandomUtil { /** * Returns a random character from the provided string. - * @param str the string in whith to pick a character randomly. + * @param str the string in which to pick a character randomly. * @return the character randomly picked from the string, or {@code '\0'} if the string is null or empty. * @see Random#nextInt(int) */ @@ -98,8 +98,8 @@ public class RandomUtil { /** * Return a value between 0 and the number of parameter minus 1, using the provided frequencies. *

- * The probability of each value to be returned depends of the frequencies provided. - * @param frequencies the frequencies of each entries + * The probability of each value to be returned depends on the frequencies provided. + * @param frequencies the frequencies of each entry * @return the index of an entry, or -1 if it is unable to pick anything (all the frequencies are 0 or there is no provided frequency) * @throws IllegalArgumentException if frequencies is null. */ @@ -144,18 +144,18 @@ public class RandomUtil { public static final String PASSWORD_CHARSET_SPECIAL = "@#+*/-;:,.?!='()[]{}&"; /** - * A set of characters representing uppercase and lowercase latin alphabet letters and digits, exclusing some that + * A set of characters representing uppercase and lowercase latin alphabet letters and digits, excluding some that * can be confusing to read (like {@code iIl1} or {@code oO0}). */ - public static final String PASSWORD_CHARSET_NO_ANBIGUITY = "abcdefghkmnpqrstwxyzACDEFGHKLMNPQRSTWXYZ2345679"; + public static final String PASSWORD_CHARSET_NO_AMBIGUITY = "abcdefghkmnpqrstwxyzACDEFGHKLMNPQRSTWXYZ2345679"; /** - * Generate a random password of the provided length, using the characters listed in {@link #PASSWORD_CHARSET_NO_ANBIGUITY}. + * Generate a random password of the provided length, using the characters listed in {@link #PASSWORD_CHARSET_NO_AMBIGUITY}. * @param length the length of the generated password. * @return the generated password. */ public static String randomPassword(int length) { - return randomPassword(length, PASSWORD_CHARSET_NO_ANBIGUITY); + return randomPassword(length, PASSWORD_CHARSET_NO_AMBIGUITY); } /** diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/StringUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/StringUtil.java index d87ef3c..a9afe10 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/StringUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/StringUtil.java @@ -24,24 +24,24 @@ public class StringUtil { } /** - * Counts the number of occurence of a speficied character in a string. + * Counts the number of occurrence of a specified character in a string. * @param string the character sequence to search into. * @param character the character to count. - * @return the number of occurence of - * @deprecated Because it uses snake_case naming convention. Use {@link #countOccurences(CharSequence, char)} instead. + * @return the number of occurrence of + * @deprecated Because it uses snake_case naming convention. Use {@link #countOccurrences(CharSequence, char)} instead. */ @Deprecated(forRemoval = true, since = "2022-07-26") public static int char_count(CharSequence string, char character) { - return countOccurences(string, character); + return countOccurrences(string, character); } /** - * Counts the number of occurence of a speficied character in a string. + * Counts the number of occurrence of a specified character in a string. * @param string the character sequence to search into. * @param character the character to count. - * @return the number of occurence of + * @return the number of occurrence of */ - public static int countOccurences(CharSequence string, char character) { + public static int countOccurrences(CharSequence string, char character) { int count = 0; for (char c : string.toString().toCharArray()) { if (c == character) { @@ -53,8 +53,8 @@ public class StringUtil { /** - * Do like {@link String#join(CharSequence, Iterable)}, but the last separator is different than the others. - * It is usedful when enumerating thins in a sentense, for instance : "a thing, a thing and a thing" + * Do like {@link String#join(CharSequence, Iterable)}, but the last separator is different from the others. + * It is useful when enumerating thins in a sentence, for instance : "a thing, a thing and a thing" * (the coma being the usual separator, and {@code " and "} being the final separator). * @param regularSeparator the separator used everywhere except between the two last strings to join. * @param finalSeparator the separator used between the two last strings to join. @@ -91,9 +91,9 @@ public class StringUtil { /** - * Generate a name based on the original name, but that does not conflit with anouther one, according to the + * Generate a name based on the original name, but that does not conflit with another one, according to the * provided predicate. - * It can be used to to add an entry in a map when the key already exists, and it is ok to modify the added key to + * It can be used to add an entry in a map when the key already exists, and it is ok to modify the added key to * not erase the previous data. * This situation can be compared to when a file is added to a directory but another file with the same name exists, * so the new file have a suffix number to make the file name different. @@ -141,17 +141,17 @@ public class StringUtil { /** - * Generate a {@link Pattern} with extra wrapping regex around the provided one to consider a sentense (like a chat + * Generate a {@link Pattern} with extra wrapping regex around the provided one to consider a sentence (like a chat * message). For instance, the returned pattern will only match the expression at the beginning or end of sentence, * or separated by the rest of it with space or another non-letter character. * @param wordPattern the regex pattern to wrap. * @param caseInsensitive if the pattern must match ignoring case. * @return a {@link Pattern}. The matching will match 3 groups. The first group is the eventual non-letter separator * before the matched word, the second one is the actual word, and the last one is the eventual non-letter separator - * after the matched word. Any additionnal pattern group between the 2nd and the last one are thoses provided in the + * after the matched word. Any additional pattern group between the 2nd and the last one are those provided in the * wordPattern. */ - public static Pattern asPatternInSentense(String wordPattern, boolean caseInsensitive) { + public static Pattern asPatternInSentence(String wordPattern, boolean caseInsensitive) { return Pattern.compile((caseInsensitive ? "(?i)" : "") + "(\\P{L}|^)(" + wordPattern + ")(\\P{L}|$)"); } diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableAccumulator.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableAccumulator.java index 9e44d73..37c66aa 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableAccumulator.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableAccumulator.java @@ -6,7 +6,7 @@ import fr.pandacube.lib.util.ThrowableUtil.SupplierException; import java.util.function.Supplier; /** - * A class that delay and accumulate thown exceptions, that can be thrown later using {@link #throwCatched()}. + * A class that delay and accumulate thrown exceptions, that can be thrown later using {@link #throwCaught()}. * @param the type of {@link Throwable} to accumulate. */ public class ThrowableAccumulator { @@ -81,13 +81,13 @@ public class ThrowableAccumulator { } /** - * Throws an exception if there is at least one catched by this accumulator. - * If multiple exception where catched, all the exception after the first one are added to the first one as + * Throws an exception if there is at least one caught by this accumulator. + * If multiple exception where caught, all the exception after the first one are added to the first one as * suppressed exceptions. - * If no exception were catched, this method does nothing. + * If no exception were caught, this method does nothing. * @throws Exception the first accumulated throwable, the other ones being suppressed. */ - public void throwCatched() throws Exception { + public void throwCaught() throws Exception { synchronized (this) { if (base != null) throwEx(base); diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableUtil.java index e338541..a868d10 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/ThrowableUtil.java @@ -15,7 +15,7 @@ public class ThrowableUtil { * Convert a {@link Throwable} into a {@link String} using the {@link Throwable#printStackTrace(PrintStream)} method, * so the returned string contains the full stack trace. * @param t the {@link Throwable} - * @return a {@link String} containing the full stack thace of the provided {@link Throwable}. + * @return a {@link String} containing the full stack trace of the provided {@link Throwable}. */ public static String stacktraceToString(Throwable t) { if (t == null) return null; @@ -97,7 +97,7 @@ public class ThrowableUtil { /** - * Makes the provided Throwable unckecked if necessary. + * Makes the provided Throwable unchecked if necessary. * @param t the throwable to eventually wrap into a {@link RuntimeException}. * @param convertReflectionExceptionToError true to convert reflection related exception to their error counterpart. * @return a {@link RuntimeException} diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/TimeUtil.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/TimeUtil.java index 60ada58..92c47f3 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/TimeUtil.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/TimeUtil.java @@ -17,8 +17,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; /** - * Utility class providing methods to display human readable time and duration, and parse duration strings. - * + * Utility class providing methods to display human-readable time and duration, and parse duration strings. + *

* The methods that return date and daytime are hardcoded in French. */ public class TimeUtil { @@ -37,17 +37,17 @@ public class TimeUtil { /** - * Provides a human readable date of the provided time, with ability to adapt the text relatively to the current + * Provides a human-readable date of the provided time, with ability to adapt the text relatively to the current * time (for instance "il y a 13 minutes" (french for "13 minutes ago")) *

* This method renders the text in French. * - * @param time the timestamp in milliseconds of the time to diplay. - * @param showSeconds if the returned string should includes seconds (true) or not (false). To have more control + * @param time the timestamp in milliseconds of the time to display. + * @param showSeconds if the returned string should include seconds (true) or not (false). To have more control * over the precision, call {@link #relativeDateFr(long, RelativePrecision, DisplayPrecision, * boolean)}. * @param compactWords true to use compact words, false to use full words. - * @return a human readable {@link String} representation of the provided time. + * @return a human-readable {@link String} representation of the provided time. */ public static String relativeDateFr(long time, boolean showSeconds, boolean compactWords) { return relativeDateFr(time, @@ -58,18 +58,18 @@ public class TimeUtil { /** - * Provides a human readable date of the provided time, with ability to adapt the text relatively to the current + * Provides a human-readable date of the provided time, with ability to adapt the text relatively to the current * time (for instance "il y a 13 minutes" (french for "13 minutes ago")) *

* This method renders the text in French. * - * @param time the timestamp in milliseconds of the time to diplay. + * @param time the timestamp in milliseconds of the time to display. * @param relPrecision the precision of the relative text. - * @param dispPrecision the precision of the full date and time. + * @param displayPrecision the precision of the full date and time. * @param compactWords true to use compact words, false to use full words. - * @return a human readable {@link String} representation of the provided time. + * @return a human-readable {@link String} representation of the provided time. */ - public static String relativeDateFr(long time, RelativePrecision relPrecision, DisplayPrecision dispPrecision, boolean compactWords) { + public static String relativeDateFr(long time, RelativePrecision relPrecision, DisplayPrecision displayPrecision, boolean compactWords) { long currentTime = System.currentTimeMillis(); @@ -91,27 +91,27 @@ public class TimeUtil { return compactWords ? "dans moins d’1min" : "dans moins d’une minute"; if (timeDiffSec > -60*2) // dans 2 min return compactWords ? "dans 1min" : "dans une minute"; - if (timeDiffSec > -3600) // dans moins d’1h + if (timeDiffSec > -3600) // dans moins d'1 h return "dans " + (-timeDiffSec/60) + (compactWords ? "min" : " minutes"); } if (relPrecision.ordinal() >= RelativePrecision.HOURS.ordinal()) { - if (timeDiffSec > -3600) // dans moins d’1h + if (timeDiffSec > -3600) // dans moins d'1 h return compactWords ? "dans moins d’1h" : "dans moins d’une heure"; - if (timeDiffSec > -3600*2) // dans moins de 2h + if (timeDiffSec > -3600*2) // dans moins de 2 h return compactWords ? "dans 1h" : "dans une heure"; - if (timeDiffSec > -3600*12) // dans moins de 12h + if (timeDiffSec > -3600*12) // dans moins de 12 h return "dans " + (-timeDiffSec/3600) + (compactWords ? "h" : " heures"); } if (relPrecision.ordinal() >= RelativePrecision.DAYS.ordinal()) { LocalDateTime nextMidnight = LocalDateTime.of(currentDateTime.getYear(), currentDateTime.getMonth(), currentDateTime.getDayOfMonth(), 0, 0).plusDays(1); if (displayDateTime.isBefore(nextMidnight)) // aujourd'hui - return "aujourd’hui à " + dayTimeFr(time, dispPrecision); + return "aujourd’hui à " + dayTimeFr(time, displayPrecision); if (displayDateTime.isBefore(nextMidnight.plusDays(1))) // demain - return "demain à " + dayTimeFr(time, dispPrecision); + return "demain à " + dayTimeFr(time, displayPrecision); if (displayDateTime.isBefore(nextMidnight.plusDays(5))) // dans moins d'1 semaine return (compactWords ? cmpDayOfWeekFormatter : dayOfWeekFormatter).format(displayDateTime) + " " + dayOfMonthFormatter.format(displayDateTime) + " à " - + dayTimeFr(time, dispPrecision); + + dayTimeFr(time, displayPrecision); } } @@ -121,43 +121,43 @@ public class TimeUtil { return "maintenant"; if (relPrecision == RelativePrecision.SECONDS) { - if (timeDiffSec < 60) // ya moins d'1 min + if (timeDiffSec < 60) // il y a moins d'1 min return "il y a " + timeDiffSec + (compactWords ? "s" : " secondes"); } if (relPrecision.ordinal() >= RelativePrecision.MINUTES.ordinal()) { - if (timeDiffSec < 60) // ya moins d'1 min + if (timeDiffSec < 60) // il y a moins d'1 min return compactWords ? "il y a moins d’1min" : "il y a moins d’une minute"; - if (timeDiffSec < 60*2) // ya moins de 2 min + if (timeDiffSec < 60*2) // il y a moins de 2 min return compactWords ? "il y a 1min" : "il y a une minute"; - if (timeDiffSec < 3600) // ya moins d'1h + if (timeDiffSec < 3600) // il y a moins d'1 h return "il y a " + (timeDiffSec/60) + (compactWords ? "min" : " minutes"); } if (relPrecision.ordinal() >= RelativePrecision.HOURS.ordinal()) { - if (timeDiffSec < 3600) // ya moins d'1h + if (timeDiffSec < 3600) // il y a moins d'1 h return "il y a moins d’une heure"; - if (timeDiffSec < 3600*2) // ya moins de 2h + if (timeDiffSec < 3600*2) // il y a moins de 2 h return "il y a une heure"; - if (timeDiffSec < 3600*12) // ya moins de 12h + if (timeDiffSec < 3600*12) // il y a moins de 12 h return "il y a " + (timeDiffSec/3600) + " heures"; } if (relPrecision.ordinal() >= RelativePrecision.DAYS.ordinal()) { LocalDateTime lastMidnight = LocalDateTime.of(currentDateTime.getYear(), currentDateTime.getMonth(), currentDateTime.getDayOfMonth(), 0, 0); if (!displayDateTime.isBefore(lastMidnight)) // aujourd'hui - return "aujourd’hui à " + dayTimeFr(time, dispPrecision); + return "aujourd’hui à " + dayTimeFr(time, displayPrecision); if (!displayDateTime.isBefore(lastMidnight.minusDays(1))) // hier - return "hier à " + dayTimeFr(time, dispPrecision); - if (!displayDateTime.isBefore(lastMidnight.minusDays(6))) // ya moins d'1 semaine + return "hier à " + dayTimeFr(time, displayPrecision); + if (!displayDateTime.isBefore(lastMidnight.minusDays(6))) // il y a moins d'1 semaine return (compactWords ? cmpDayOfWeekFormatter : dayOfWeekFormatter).format(displayDateTime) + " dernier à " - + dayTimeFr(time, dispPrecision); + + dayTimeFr(time, displayPrecision); } } - return fullDateFr(time, dispPrecision, true, compactWords); + return fullDateFr(time, displayPrecision, true, compactWords); } /** - * Enumaration of different level of precision to display a relative time. + * Enumeration of different level of precision to display a relative time. */ public enum RelativePrecision { /** @@ -183,7 +183,7 @@ public class TimeUtil { } /** - * Enumaration of different level of precision to display a date and daytime. + * Enumeration of different level of precision to display a date and daytime. */ public enum DisplayPrecision { /** @@ -195,11 +195,11 @@ public class TimeUtil { */ HOURS, /** - * Display the date and the time of the day up to the minute. + * Display the date and the time of the day with minute precision. */ MINUTES, /** - * Display the date and the time of the day up to the second. + * Display the date and the time of the day with second precision. */ SECONDS } @@ -211,7 +211,7 @@ public class TimeUtil { * This method renders the text in French. * * @param timestamp the time to represent in the returned string. - * @param showSeconds if the returned string should includes seconds (true) or not (false). To have more control + * @param showSeconds if the returned string should include seconds (true) or not (false). To have more control * over the precision, call {@link #fullDateFr(long, DisplayPrecision, boolean, boolean)}. * @param showWeekday true to show the week day, false otherwise. * @param compactWords true to use compact words, false to use full words. @@ -269,7 +269,7 @@ public class TimeUtil { /** - * Converts the provided duration into a human readable {@link String}. + * Converts the provided duration into a human-readable {@link String}. * @param msDuration the duration in millisecond. * @param hUnit the biggest unit of time to display. * @param lUnit the smallest unit of time to display. @@ -334,7 +334,7 @@ public class TimeUtil { /** * Indicate the 0-padded length of a number for the provided {@link TimeUnit}. - * Will returns 3 for below-second time units, 2 for seconds, munutes and hours and 1 otherwise. + * Will returns 3 for below-second time units, 2 for seconds, minutes and hours and 1 otherwise. * @param u the {@link TimeUnit} * @return the 0-padded length of a number for the provided {@link TimeUnit}. */ diff --git a/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/AbstractClientWS.java b/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/AbstractClientWS.java index 33be6b9..bff3134 100644 --- a/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/AbstractClientWS.java +++ b/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/AbstractClientWS.java @@ -188,9 +188,9 @@ public abstract class AbstractClientWS implements AbstractWS { } @Override - public final void sendClose(int code, String reason) throws IOException { + public final void sendClose(int code, String reason) { synchronized (socket) { - autoReconnect = false; // if we ask for closing connection, dont reconnect automatically + autoReconnect = false; // if we ask for closing connection, don't reconnect automatically WebSocket ws = socket.get(); if (ws != null) ws.sendClose(code, reason).join(); diff --git a/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/KeyProtectedClientWS.java b/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/KeyProtectedClientWS.java index 5b9ae06..86e3b98 100644 --- a/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/KeyProtectedClientWS.java +++ b/pandalib-ws-client/src/main/java/fr/pandacube/lib/ws/client/KeyProtectedClientWS.java @@ -70,7 +70,7 @@ public abstract class KeyProtectedClientWS extends AbstractClientWS { } /** - * Called when this Websocket is succesfully logged in to the server. + * Called when this Websocket is successfully logged in to the server. */ public abstract void onLoginSucceed(); diff --git a/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/AbstractServerWS.java b/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/AbstractServerWS.java index fd1a6f0..750a3fa 100644 --- a/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/AbstractServerWS.java +++ b/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/AbstractServerWS.java @@ -16,10 +16,10 @@ public abstract class AbstractServerWS extends WebSocketAdapter implements Abstr private boolean isClosed = false; @Override - public final void onWebSocketConnect(Session sess) + public final void onWebSocketConnect(Session session) { - super.onWebSocketConnect(sess); - sess.setIdleTimeout(Duration.ofDays(1000)); // practically infinite + super.onWebSocketConnect(session); + session.setIdleTimeout(Duration.ofDays(1000)); // practically infinite onConnect(); } diff --git a/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/KeyProtectedServerWS.java b/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/KeyProtectedServerWS.java index 56ef039..1e9cae7 100644 --- a/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/KeyProtectedServerWS.java +++ b/pandalib-ws-server/src/main/java/fr/pandacube/lib/ws/server/KeyProtectedServerWS.java @@ -69,7 +69,7 @@ public abstract class KeyProtectedServerWS extends AbstractServerWS { } /** - * Called when the client endpoint is succesfully logged in. + * Called when the client endpoint is successfully logged in. */ public abstract void onLoginSucceed(); diff --git a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/AbstractWS.java b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/AbstractWS.java index 3dfa0b1..e08b7bf 100644 --- a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/AbstractWS.java +++ b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/AbstractWS.java @@ -123,7 +123,7 @@ public interface AbstractWS { * {@link PayloadRegistry#arbitraryToString(String, Object, boolean)}. * @param type the type. * @param obj the object to Jsonify. - * @param serializeNulls if null propreties must be included in the json object. + * @param serializeNulls if null properties must be included in the json object. * @throws IOException if an IO error occurs when sending the data. * @throws JsonParseException if the json is invalid. * @see PayloadRegistry#arbitraryToString(String, Object, boolean) @@ -137,7 +137,7 @@ public interface AbstractWS { * {@link PayloadRegistry#arbitraryToString(String, Object, boolean)}. * @param type the type. * @param obj the object to Jsonify. - * @param serializeNulls if null propreties must be included in the json object. + * @param serializeNulls if null properties must be included in the json object. * @return true if the data is sent successfully, false if an IO error occurs. * @see PayloadRegistry#arbitraryToString(String, Object, boolean) */ @@ -225,7 +225,7 @@ public interface AbstractWS { * Utility method to wrap sending operation into a try-catch. * @param run the sending operation that may throw an {@link IOException}. * @param errorMessage the error message to log if the runnable throws an {@link IOException}. - * @return true if the data if the runnable is executed successfully, false if an IO error occurs. + * @return true if the runnable is executed successfully, false if an IO error occurs. */ default boolean trySend(RunnableException run, String errorMessage) { try { @@ -244,7 +244,7 @@ public interface AbstractWS { */ /** - * Logs the provided message with logger level {@link Level#INFO}, prefixed with infos avout this web-socket. + * Logs the provided message with logger level {@link Level#INFO}, prefixed with infos about this web-socket. * @param message the message to log. */ default void log(String message) { @@ -252,7 +252,7 @@ public interface AbstractWS { } /** - * Logs the provided message with logger level {@link Level#SEVERE}, prefixed with infos avout this web-socket. + * Logs the provided message with logger level {@link Level#SEVERE}, prefixed with infos about this web-socket. * @param message the message to log. */ default void logError(String message) { @@ -260,7 +260,7 @@ public interface AbstractWS { } /** - * Logs the provided message and {@link Throwable} with logger level {@link Level#SEVERE}, prefixed with infos avout this web-socket. + * Logs the provided message and {@link Throwable} with logger level {@link Level#SEVERE}, prefixed with infos about this web-socket. * @param message the message to log. * @param t the throwable to log. */ @@ -269,7 +269,8 @@ public interface AbstractWS { } /** - * Gets an identifier for this web-socket, used for logging. May be the remote IP:port or URI. + * Gets an identifier for this web-socket, used for logging. + * It may be the remote IP:port or URI. * @return an identifier for this web-socket. */ String getRemoteIdentifier(); diff --git a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/PayloadRegistry.java b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/PayloadRegistry.java index ad922a7..f63e926 100644 --- a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/PayloadRegistry.java +++ b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/PayloadRegistry.java @@ -83,7 +83,7 @@ public class PayloadRegistry { * to a Json string. * @param type the type * @param obj the object to Jsonify - * @param serializeNulls if null propreties must be included in the json object. + * @param serializeNulls if null properties must be included in the json object. * @return the String to send through the websocket * @throws JsonParseException if the json is invalid. */ diff --git a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginPayload.java b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginPayload.java index 12982b8..2d7784b 100644 --- a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginPayload.java +++ b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginPayload.java @@ -1,7 +1,7 @@ package fr.pandacube.lib.ws.payloads; /** - * Payload used by the client to login to key-protected websocket endpoint. + * Payload used by the client to log in to key-protected websocket endpoint. */ public class LoginPayload extends Payload { /** diff --git a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginSucceedPayload.java b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginSucceedPayload.java index 160dc8b..4f4de35 100644 --- a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginSucceedPayload.java +++ b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/LoginSucceedPayload.java @@ -1,7 +1,7 @@ package fr.pandacube.lib.ws.payloads; /** - * Payload used by the server in inform the client the login was successfull. + * Payload used by the server in inform the client the login was successful. */ public class LoginSucceedPayload extends Payload { } diff --git a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/MessagePayload.java b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/MessagePayload.java index 4130f1c..889a1cb 100644 --- a/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/MessagePayload.java +++ b/pandalib-ws/src/main/java/fr/pandacube/lib/ws/payloads/MessagePayload.java @@ -10,7 +10,7 @@ public class MessagePayload extends Payload { public String message; /** - * Initialite a new MessagePayload with the provided message. + * Initialize a new MessagePayload with the provided message. * @param message the message. */ public MessagePayload(String message) {