mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-16 13:11:40 +01:00
return terminal
This commit is contained in:
parent
1cd68e0c3f
commit
5929b811ec
@ -64,6 +64,9 @@ dependencies {
|
||||
api(libs.bundles.hephaistos)
|
||||
implementation(libs.minestomData)
|
||||
|
||||
// Libraries required for the terminal
|
||||
implementation(libs.bundles.terminal)
|
||||
|
||||
// Performance/data structures
|
||||
implementation(libs.caffeine)
|
||||
api(libs.fastutil)
|
||||
|
@ -18,6 +18,9 @@ flare = "2.0.1"
|
||||
gson = "2.10.1"
|
||||
jcTools = "4.0.1"
|
||||
|
||||
# Terminal
|
||||
jline = "3.21.0"
|
||||
|
||||
# Quality
|
||||
junit-jupiter = "5.9.3"
|
||||
junit-platform = "1.9.3"
|
||||
@ -65,6 +68,10 @@ flare-fastutil = { group = "space.vectrix.flare", name = "flare-fastutil", versi
|
||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
||||
jcTools = { group = "org.jctools", name = "jctools-core", version.ref = "jcTools" }
|
||||
|
||||
# Terminal
|
||||
jline = { group = "org.jline", name = "jline", version.ref = "jline" }
|
||||
jline-jansi = { group = "org.jline", name = "jline-terminal-jansi", version.ref = "jline" }
|
||||
|
||||
# Code quality
|
||||
junit-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit-jupiter" }
|
||||
junit-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit-jupiter" }
|
||||
@ -90,6 +97,7 @@ adventure = ["adventure-api", "adventure-serializer-gson", "adventure-serializer
|
||||
junit = ["junit-api", "junit-engine", "junit-params", "junit-suite-api", "junit-suite-engine"]
|
||||
hephaistos = ["hephaistos-common", "hephaistos-gson"]
|
||||
logback = ["logback-core", "logback-classic"]
|
||||
terminal = ["jline", "jline-jansi"]
|
||||
|
||||
[plugins]
|
||||
|
||||
|
@ -148,9 +148,9 @@ final class CommandParserImpl implements CommandParser {
|
||||
}
|
||||
} else {
|
||||
// Nothing left, yet we're still being asked to parse? There must be defaults then
|
||||
Supplier<?> defaultSupplier = node.argument().getDefaultValue();
|
||||
Function<CommandSender, ?> defaultSupplier = node.argument().getDefaultValue();
|
||||
if (defaultSupplier != null) {
|
||||
Object value = defaultSupplier.get();
|
||||
Object value = defaultSupplier.apply(sender);
|
||||
ArgumentResult<Object> argumentResult = new ArgumentResult.Success<>(value, "");
|
||||
chain.append(new NodeResult(node, chain, argumentResult, argument.getSuggestionCallback()));
|
||||
// Add the default to the chain, and then carry on dealing with this node
|
||||
@ -170,7 +170,7 @@ final class CommandParserImpl implements CommandParser {
|
||||
|
||||
NodeResult error = null;
|
||||
for (Node child : node.next()) {
|
||||
NodeResult childResult = parseNode(child, chain, reader);
|
||||
NodeResult childResult = parseNode(sender, child, chain, reader);
|
||||
if (childResult.argumentResult instanceof ArgumentResult.Success<Object>) {
|
||||
// Assume that there is only one successful node for a given chain of arguments
|
||||
return childResult;
|
||||
|
@ -41,7 +41,7 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
public class Command {
|
||||
|
||||
public final static Logger LOGGER = LoggerFactory.getLogger(Command.class);
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(Command.class);
|
||||
|
||||
private final String name;
|
||||
private final String[] aliases;
|
||||
|
@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class PacketListenerManager {
|
||||
|
||||
public final static Logger LOGGER = LoggerFactory.getLogger(PacketListenerManager.class);
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(PacketListenerManager.class);
|
||||
private final ServerProcess serverProcess;
|
||||
|
||||
private final Map<Class<? extends ClientPacket>, PacketListenerConsumer> listeners = new ConcurrentHashMap<>();
|
||||
|
@ -1,36 +0,0 @@
|
||||
package net.minestom.server.terminal;
|
||||
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
import org.tinylog.core.LogEntry;
|
||||
import org.tinylog.writers.AbstractFormatPatternWriter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static net.minestom.server.terminal.MinestomTerminal.reader;
|
||||
|
||||
public final class MinestomConsoleWriter extends AbstractFormatPatternWriter {
|
||||
public MinestomConsoleWriter(Map<String, String> properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(LogEntry logEntry) throws Exception {
|
||||
String rendered = render(logEntry);
|
||||
String formatted = TerminalColorConverter.format(rendered);
|
||||
if (reader != null) {
|
||||
reader.printAbove(formatted);
|
||||
} else {
|
||||
AnsiConsole.out().print(formatted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// EMPTY
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||
public final class DebugUtils {
|
||||
public static boolean INSIDE_TEST = PropertyUtils.getBoolean("minestom.inside-test", false);
|
||||
|
||||
public final static Logger LOGGER = LoggerFactory.getLogger(DebugUtils.class);
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(DebugUtils.class);
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user