diff --git a/pom.xml b/pom.xml index 2ece3bc2..815aa840 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,7 @@ + org.apache.maven.plugins maven-surefire-plugin 2.22.2 diff --git a/velocity/pom.xml b/velocity/pom.xml index 65bb6e19..0ff459d8 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -32,7 +32,7 @@ com.velocitypowered velocity-api - 1.0.0-SNAPSHOT + 3.0.0 provided diff --git a/velocity/src/main/java/co/aikar/commands/ACFVelocityUtil.java b/velocity/src/main/java/co/aikar/commands/ACFVelocityUtil.java index 118bf243..2e9f960c 100644 --- a/velocity/src/main/java/co/aikar/commands/ACFVelocityUtil.java +++ b/velocity/src/main/java/co/aikar/commands/ACFVelocityUtil.java @@ -11,14 +11,13 @@ import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; -import net.kyori.text.TextComponent; -import net.kyori.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; public class ACFVelocityUtil { - @SuppressWarnings("deprecation") public static TextComponent color(String message) { - return LegacyComponentSerializer.legacy().deserialize(message); + return LegacyComponentSerializer.legacySection().deserialize(message); } public static Player findPlayerSmart(ProxyServer server, CommandIssuer issuer, String search) { diff --git a/velocity/src/main/java/co/aikar/commands/VelocityCommandCompletions.java b/velocity/src/main/java/co/aikar/commands/VelocityCommandCompletions.java index 3ece1af6..332013f1 100644 --- a/velocity/src/main/java/co/aikar/commands/VelocityCommandCompletions.java +++ b/velocity/src/main/java/co/aikar/commands/VelocityCommandCompletions.java @@ -34,16 +34,16 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import co.aikar.commands.apachecommonslang.ApacheCommonsLangUtil; -import net.kyori.text.format.TextColor; -import net.kyori.text.format.TextDecoration; -import net.kyori.text.format.TextFormat; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import net.kyori.adventure.text.format.TextFormat; public class VelocityCommandCompletions extends CommandCompletions { public VelocityCommandCompletions(ProxyServer server, CommandManager manager) { super(manager); registerAsyncCompletion("chatcolors", c -> { - Stream colors = Stream.of(TextColor.values()); + Stream colors = NamedTextColor.NAMES.values().stream().map(namedTextColor -> namedTextColor); if (!c.hasConfig("colorsonly")) { colors = Stream.concat(colors, Stream.of(TextDecoration.values())); } diff --git a/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java b/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java index d62f197a..ce4d1daa 100644 --- a/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java +++ b/velocity/src/main/java/co/aikar/commands/VelocityCommandContexts.java @@ -31,9 +31,10 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import co.aikar.commands.velocity.contexts.OnlinePlayer; -import net.kyori.text.format.TextColor; -import net.kyori.text.format.TextDecoration; -import net.kyori.text.format.TextFormat; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; +import net.kyori.adventure.text.format.TextDecoration; +import net.kyori.adventure.text.format.TextFormat; import org.jetbrains.annotations.Nullable; public class VelocityCommandContexts extends CommandContexts { @@ -56,7 +57,7 @@ public class VelocityCommandContexts extends CommandContexts { String first = c.popFirstArg(); - Stream colors = Stream.of(TextColor.values()); + Stream colors = NamedTextColor.NAMES.values().stream().map(namedTextColor -> namedTextColor); if (!c.hasFlag("colorsonly")) { colors = Stream.concat(colors, Stream.of(TextDecoration.values())); } @@ -67,7 +68,7 @@ public class VelocityCommandContexts extends CommandContexts finalFilter.equals(ACFUtil.simplifyString(color.toString()))); } - TextColor match = ACFUtil.simpleMatch(TextColor.class, first); + TextColor match = NamedTextColor.NAMES.value(ACFUtil.simplifyString(first)); if (match == null) { String valid = colors.map(color -> "" + ACFUtil.simplifyString(color.toString()) + "") .collect(Collectors.joining(", ")); diff --git a/velocity/src/main/java/co/aikar/commands/VelocityCommandManager.java b/velocity/src/main/java/co/aikar/commands/VelocityCommandManager.java index 3971cd45..592d9bef 100644 --- a/velocity/src/main/java/co/aikar/commands/VelocityCommandManager.java +++ b/velocity/src/main/java/co/aikar/commands/VelocityCommandManager.java @@ -41,10 +41,10 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil; -import net.kyori.text.format.TextColor; +import net.kyori.adventure.text.format.NamedTextColor; public class VelocityCommandManager extends - CommandManager { + CommandManager { protected final ProxyServer proxy; protected final PluginContainer plugin; @@ -56,10 +56,10 @@ public class VelocityCommandManager extends public VelocityCommandManager(ProxyServer proxy, Object plugin) { this.proxy = proxy; this.plugin = proxy.getPluginManager().getPlugin(plugin.getClass().getAnnotation(Plugin.class).id()).get(); - this.formatters.put(MessageType.ERROR, defaultFormatter = new VelocityMessageFormatter(TextColor.RED, TextColor.YELLOW, TextColor.RED)); - this.formatters.put(MessageType.SYNTAX, new VelocityMessageFormatter(TextColor.YELLOW, TextColor.GREEN, TextColor.WHITE)); - this.formatters.put(MessageType.INFO, new VelocityMessageFormatter(TextColor.BLUE, TextColor.DARK_GREEN, TextColor.GREEN)); - this.formatters.put(MessageType.HELP, new VelocityMessageFormatter(TextColor.AQUA, TextColor.GREEN, TextColor.YELLOW)); + this.formatters.put(MessageType.ERROR, defaultFormatter = new VelocityMessageFormatter(NamedTextColor.RED, NamedTextColor.YELLOW, NamedTextColor.RED)); + this.formatters.put(MessageType.SYNTAX, new VelocityMessageFormatter(NamedTextColor.YELLOW, NamedTextColor.GREEN, NamedTextColor.WHITE)); + this.formatters.put(MessageType.INFO, new VelocityMessageFormatter(NamedTextColor.BLUE, NamedTextColor.DARK_GREEN, NamedTextColor.GREEN)); + this.formatters.put(MessageType.HELP, new VelocityMessageFormatter(NamedTextColor.AQUA, NamedTextColor.GREEN, NamedTextColor.YELLOW)); getLocales(); @@ -129,7 +129,7 @@ public class VelocityCommandManager extends if (force) { proxy.getCommandManager().unregister(commandName); } - proxy.getCommandManager().register(velocityCommand, commandName); + proxy.getCommandManager().register(commandName, velocityCommand); } velocityCommand.isRegistered = true; registeredCommands.put(commandName, velocityCommand); diff --git a/velocity/src/main/java/co/aikar/commands/VelocityMessageFormatter.java b/velocity/src/main/java/co/aikar/commands/VelocityMessageFormatter.java index 28c8d0ef..982b7d57 100644 --- a/velocity/src/main/java/co/aikar/commands/VelocityMessageFormatter.java +++ b/velocity/src/main/java/co/aikar/commands/VelocityMessageFormatter.java @@ -1,17 +1,16 @@ package co.aikar.commands; -import net.kyori.text.format.TextColor; -import net.kyori.text.serializer.legacy.LegacyComponentSerializer; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -public class VelocityMessageFormatter extends MessageFormatter { +public class VelocityMessageFormatter extends MessageFormatter { - public VelocityMessageFormatter(TextColor... colors) { + public VelocityMessageFormatter(NamedTextColor... colors) { super(colors); } @Override - @SuppressWarnings("deprecation") - String format(TextColor color, String message) { - return LegacyComponentSerializer.legacy().serialize(LegacyComponentSerializer.legacy().deserialize(message).color(color)); + String format(NamedTextColor color, String message) { + return LegacyComponentSerializer.legacySection().serialize(LegacyComponentSerializer.legacySection().deserialize(message).color(color)); } } \ No newline at end of file diff --git a/velocity/src/main/java/co/aikar/commands/VelocityRootCommand.java b/velocity/src/main/java/co/aikar/commands/VelocityRootCommand.java index be17eab4..b9451b48 100644 --- a/velocity/src/main/java/co/aikar/commands/VelocityRootCommand.java +++ b/velocity/src/main/java/co/aikar/commands/VelocityRootCommand.java @@ -25,13 +25,15 @@ package co.aikar.commands; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; import com.google.common.collect.HashMultimap; import com.google.common.collect.SetMultimap; import com.velocitypowered.api.command.Command; import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.command.SimpleCommand; -public class VelocityRootCommand implements Command, RootCommand { +public class VelocityRootCommand implements SimpleCommand, RootCommand { private final VelocityCommandManager manager; private final String name; @@ -74,18 +76,23 @@ public class VelocityRootCommand implements Command, RootCommand { return children; } - @Override - public void execute(CommandSource source, String[] args) { - execute(manager.getCommandIssuer(source), getCommandName(), args); - } - - @Override - public List suggest(CommandSource source, String[] args) { - return getTabCompletions(manager.getCommandIssuer(source), getCommandName(), args); - } - @Override public BaseCommand getDefCommand() { return defCommand; } + + @Override + public void execute(Invocation invocation) { + execute(manager.getCommandIssuer(invocation.source()), getCommandName(), invocation.arguments()); + } + + @Override + public List suggest(Invocation invocation) { + return getTabCompletions(manager.getCommandIssuer(invocation.source()), getCommandName(), invocation.arguments()); + } + + @Override + public CompletableFuture> suggestAsync(Invocation invocation) { + return CompletableFuture.completedFuture(getTabCompletions(manager.getCommandIssuer(invocation.source()), getCommandName(), invocation.arguments())); + } }