Various code simplification/fixes and a lot of typo/grammar fixes (may brake some stuff)

This commit is contained in:
2023-06-20 00:15:46 +02:00
parent c984b63cee
commit 5edd8cdfec
151 changed files with 909 additions and 983 deletions

View File

@@ -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 Jlines {@link ConsoleReader} for the
* Class to handle general standard IO operation for a CLI application. It uses Jlines {@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);
}

View File

@@ -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) {

View File

@@ -15,7 +15,7 @@ import java.util.function.Predicate;
public abstract class CLIBrigadierCommand extends BrigadierCommand<CLICommandSender> {
/**
* Instanciate this command instance.
* Instantiate this command instance.
*/
public CLIBrigadierCommand() {
LiteralCommandNode<CLICommandSender> commandNode = buildCommand().build();

View File

@@ -27,7 +27,7 @@ public class CLIBrigadierDispatcher extends BrigadierDispatcher<CLICommandSender
/**
* Executes the provided command as the console.
* @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(String commandWithoutSlash) {

View File

@@ -4,6 +4,7 @@ import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
/**
* A command sender.
@@ -41,5 +42,5 @@ public interface CLICommandSender extends Audience {
void sendMessage(String message);
@Override // force implementation of super-interface default method
void sendMessage(Identity source, Component message, MessageType type);
void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type);
}

View File

@@ -5,6 +5,7 @@ import fr.pandacube.lib.util.Log;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
/**
* The console command sender.
@@ -31,7 +32,7 @@ public class CLIConsoleCommandSender implements CLICommandSender {
}
@Override
public void sendMessage(Identity source, Component message, MessageType type) {
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
sendMessage(Chat.chatComponent(message).getLegacyText());
}
}

View File

@@ -170,13 +170,13 @@ public class CommandAdmin extends CLIBrigadierCommand {
}
ChatTreeNode dispTree = new ChatTreeNode(d);
ChatTreeNode displayTree = new ChatTreeNode(d);
for (DisplayCommandNode child : displayNode.children) {
dispTree.addChild(buildDisplayTree(child, sender));
displayTree.addChild(buildDisplayTree(child, sender));
}
return dispTree;
return displayTree;
}
@@ -257,8 +257,8 @@ public class CommandAdmin extends CLIBrigadierCommand {
private static class DisplayCommandNode {
List<CommandNode<CLICommandSender>> nodes = new ArrayList<>();
List<DisplayCommandNode> children = new ArrayList<>();
final List<CommandNode<CLICommandSender>> nodes = new ArrayList<>();
final List<DisplayCommandNode> children = new ArrayList<>();
void addInline(CommandNode<CLICommandSender> node) {
nodes.add(node);

View File

@@ -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) {