Fixed hundreds of small issues, code improvements, typos, ...

This commit is contained in:
2025-01-16 00:25:23 +01:00
parent ace34fc0e8
commit 0ffe3198e6
44 changed files with 331 additions and 351 deletions

View File

@@ -27,21 +27,11 @@
<artifactId>pandalib-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-reflect</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-commands</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-log</artifactId>

View File

@@ -66,7 +66,7 @@ public class CLI extends Thread {
String line;
try {
while((line = reader.readLine()) != null) {
if (line.trim().equals(""))
if (line.trim().isEmpty())
continue;
String cmdLine = line;
new Thread(() -> CLIBrigadierDispatcher.instance.execute(cmdLine), "CLICmdThread #"+(i++)).start();

View File

@@ -32,6 +32,7 @@ public abstract class CLIApplication {
/**
* Creates a new application instance.
*/
@SuppressWarnings("CallToPrintStackTrace")
protected CLIApplication() {
instance = this;
CLI tmpCLI = null;

View File

@@ -38,16 +38,9 @@ public abstract class CLIBrigadierCommand extends BrigadierCommand<CLICommandSen
}
protected abstract LiteralArgumentBuilder<CLICommandSender> buildCommand();
protected String[] getAliases() {
return new String[0];
}
public boolean isPlayer(CLICommandSender sender) {
public boolean isPlayer(CLICommandSender sender) {
return sender.isPlayer();
}

View File

@@ -41,6 +41,9 @@ public interface CLICommandSender extends Audience {
*/
void sendMessage(String message);
@SuppressWarnings({"UnstableApiUsage", "deprecation"})
@Override // force implementation of super-interface default method
void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type);
}

View File

@@ -38,7 +38,7 @@ public class CLIConsoleCommandSender implements CLICommandSender {
}
@Override
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
public void sendMessage(@NotNull Identity source, @NotNull Component message, @SuppressWarnings({"UnstableApiUsage", "deprecation"}) @NotNull MessageType type) {
sendMessage(Chat.chatComponent(message).getLegacyText());
}
}

View File

@@ -14,7 +14,7 @@ import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.chat.Chat.FormatableChat;
import fr.pandacube.lib.chat.Chat.FormattableChat;
import fr.pandacube.lib.chat.ChatTreeNode;
import fr.pandacube.lib.cli.CLIApplication;
import fr.pandacube.lib.util.log.Log;
@@ -195,13 +195,13 @@ public class CommandAdmin extends CLIBrigadierCommand {
private Component displayCurrentNode(CommandNode<CLICommandSender> node, boolean redirectTarget, CLICommandSender sender) {
if (node == null)
throw new IllegalArgumentException("node must not be null");
FormatableChat d;
FormattableChat d;
if (node instanceof RootCommandNode) {
d = text("(root)").italic()
.hover("Root command node");
}
else if (node instanceof ArgumentCommandNode) {
ArgumentType<?> type = ((ArgumentCommandNode<?, ?>) node).getType();
else if (node instanceof ArgumentCommandNode<?, ?> argNode) {
ArgumentType<?> type = argNode.getType();
String typeStr = type.getClass().getSimpleName();
if (type instanceof IntegerArgumentType
|| type instanceof LongArgumentType
@@ -260,10 +260,10 @@ public class CommandAdmin extends CLIBrigadierCommand {
return d.get();
}
private static class DisplayCommandNode {
final List<CommandNode<CLICommandSender>> nodes = new ArrayList<>();
final List<DisplayCommandNode> children = new ArrayList<>();