⬆️ Upgrade to Velocity 3.
This commit is contained in:
parent
151f95d7fa
commit
9eab9b0c53
10 changed files with 140 additions and 103 deletions
2
pom.xml
2
pom.xml
|
@ -31,7 +31,7 @@
|
|||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>3.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.strifel.VTools.commands.*;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -13,6 +14,9 @@ import javax.inject.Inject;
|
|||
public class VTools {
|
||||
private final ProxyServer server;
|
||||
|
||||
public static final TextColor COLOR_RED = TextColor.fromCSSHexString("FF5555");
|
||||
public static final TextColor COLOR_YELLOW = TextColor.fromCSSHexString("FFFF55");
|
||||
|
||||
@Inject
|
||||
public VTools(ProxyServer server, Logger logger) {
|
||||
this.server = server;
|
||||
|
@ -21,14 +25,14 @@ public class VTools {
|
|||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
server.getCommandManager().register(new CommandSend(server), "send");
|
||||
server.getCommandManager().register(new CommandSendall(server), "sendall");
|
||||
server.getCommandManager().register(new CommandBroadcast(server), "broadcast", "bc", "alert");
|
||||
server.getCommandManager().register(new CommandFind(server), "find", "search");
|
||||
server.getCommandManager().register(new CommandStaffChat(server), "staffchat", "sc");
|
||||
server.getCommandManager().register(new CommandRestart(server), "restart");
|
||||
server.getCommandManager().register(new CommandTp(server), "tps", "jump");
|
||||
server.getCommandManager().register(new CommandServers(server), "servers", "allservers");
|
||||
server.getCommandManager().register("send", new CommandSend(server));
|
||||
server.getCommandManager().register("sendall", new CommandSendall(server));
|
||||
server.getCommandManager().register("broadcast", new CommandBroadcast(server), "bc", "alert");
|
||||
server.getCommandManager().register("find", new CommandFind(server), "search");
|
||||
server.getCommandManager().register("staffchat", new CommandStaffChat(server), "sc");
|
||||
server.getCommandManager().register("restart", new CommandRestart(server));
|
||||
server.getCommandManager().register("tps", new CommandTp(server), "jump");
|
||||
server.getCommandManager().register("servers", new CommandServers(server), "allservers");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBroadcast implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_RED;
|
||||
|
||||
public class CommandBroadcast implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandBroadcast(ProxyServer server) {
|
||||
|
@ -19,24 +19,27 @@ public class CommandBroadcast implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
if (strings.length > 0) {
|
||||
String message = String.join(" ", strings).replace("&", "§");
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
player.sendMessage(TextComponent.of(message));
|
||||
player.sendMessage(Component.text(message));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Usage: /broadcast <message>").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Usage: /broadcast <message>").color(COLOR_RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.broadcast");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.broadcast");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CommandFind implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_RED;
|
||||
import static de.strifel.VTools.VTools.COLOR_YELLOW;
|
||||
|
||||
public class CommandFind implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandFind(ProxyServer server) {
|
||||
|
@ -21,23 +22,28 @@ public class CommandFind implements Command {
|
|||
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
if (strings.length == 1) {
|
||||
Optional<Player> player = server.getPlayer(strings[0]);
|
||||
if (player.isPresent() && player.get().getCurrentServer().isPresent()) {
|
||||
commandSource.sendMessage(TextComponent.of("Player " + strings[0] + " is on " + player.get().getCurrentServer().get().getServerInfo().getName() + "!").color(TextColor.YELLOW));
|
||||
commandSource.sendMessage(Component.text("Player " + strings[0] + " is on " + player.get().getCurrentServer().get().getServerInfo().getName() + "!").color(COLOR_YELLOW));
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("The player is not online!").color(TextColor.YELLOW));
|
||||
commandSource.sendMessage(Component.text("The player is not online!").color(COLOR_YELLOW));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Usage: /find <username>").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Usage: /find <username>").color(COLOR_RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
String[] currentArgs = invocation.arguments();
|
||||
|
||||
List<String> arg = new ArrayList<>();
|
||||
if (currentArgs.length == 1 && source.hasPermission("vtools.find.autocomplete")) {
|
||||
if (currentArgs.length == 1 && invocation.source().hasPermission("vtools.find.autocomplete")) {
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
arg.add(player.getUsername());
|
||||
}
|
||||
|
@ -46,7 +52,7 @@ public class CommandFind implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.find");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.find");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandRestart implements Command {
|
||||
public class CommandRestart implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandRestart(ProxyServer server) {
|
||||
|
@ -19,23 +18,26 @@ public class CommandRestart implements Command {
|
|||
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
if (strings.length > 0) {
|
||||
String message = String.join(" ", strings).replace("&", "§");
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
player.disconnect(TextComponent.of(message));
|
||||
player.disconnect(Component.text(message));
|
||||
}
|
||||
}
|
||||
server.getCommandManager().execute(server.getConsoleCommandSource(), "shutdown");
|
||||
server.getCommandManager().executeAsync(server.getConsoleCommandSource(), "shutdown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.shutdown");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.shutdown");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CommandSend implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_RED;
|
||||
import static de.strifel.VTools.VTools.COLOR_YELLOW;
|
||||
|
||||
public class CommandSend implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandSend(ProxyServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
if (strings.length == 2) {
|
||||
Optional<Player> oPlayer = server.getPlayer(strings[0]);
|
||||
Optional<RegisteredServer> oServer = server.getServer(strings[1]);
|
||||
|
@ -28,17 +32,19 @@ public class CommandSend implements Command {
|
|||
Player player = oPlayer.get();
|
||||
RegisteredServer server = oServer.get();
|
||||
player.createConnectionRequest(server).connect();
|
||||
commandSource.sendMessage(TextComponent.of("You send " + player.getUsername() + " to " + server.getServerInfo().getName()).color(TextColor.YELLOW));
|
||||
commandSource.sendMessage(TextComponent.of("You got send to " + server.getServerInfo().getName()).color(TextColor.YELLOW));
|
||||
commandSource.sendMessage(Component.text("You send " + player.getUsername() + " to " + server.getServerInfo().getName()).color(COLOR_YELLOW));
|
||||
commandSource.sendMessage(Component.text("You got send to " + server.getServerInfo().getName()).color(COLOR_YELLOW));
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("The server or user does not exists!").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("The server or user does not exists!").color(COLOR_RED));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Usage: /send <username> <server>").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Usage: /send <username> <server>").color(COLOR_RED));
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
String[] currentArgs = invocation.arguments();
|
||||
|
||||
List<String> arg = new ArrayList<String>();
|
||||
if (currentArgs.length == 1) {
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
|
@ -53,7 +59,7 @@ public class CommandSend implements Command {
|
|||
return arg;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.send");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.send");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CommandSendall implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_RED;
|
||||
import static de.strifel.VTools.VTools.COLOR_YELLOW;
|
||||
|
||||
public class CommandSendall implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandSendall(ProxyServer server) {
|
||||
|
@ -21,24 +22,29 @@ public class CommandSendall implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
if (strings.length == 1) {
|
||||
Optional<RegisteredServer> oServer = server.getServer(strings[0]);
|
||||
if (oServer.isPresent()) {
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
player.createConnectionRequest(oServer.get()).connect();
|
||||
player.sendMessage(TextComponent.of("You are being sent to " + strings[0]).color(TextColor.YELLOW));
|
||||
player.sendMessage(Component.text("You are being sent to " + strings[0]).color(COLOR_YELLOW));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("The server does not exists!").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("The server does not exists!").color(COLOR_RED));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Usage: /sendall <server>").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Usage: /sendall <server>").color(COLOR_RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
String[] currentArgs = invocation.arguments();
|
||||
|
||||
List<String> arg = new ArrayList<String>();
|
||||
if (currentArgs.length == 1) {
|
||||
for (RegisteredServer server : server.getAllServers()) {
|
||||
|
@ -49,7 +55,7 @@ public class CommandSendall implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.sendall");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.sendall");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandServers implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_YELLOW;
|
||||
|
||||
public class CommandServers implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandServers(ProxyServer server) {
|
||||
|
@ -20,22 +20,25 @@ public class CommandServers implements Command {
|
|||
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
StringBuilder servers = new StringBuilder();
|
||||
for (RegisteredServer server : server.getAllServers()) {
|
||||
servers.append(server.getServerInfo().getName());
|
||||
servers.append(" ");
|
||||
}
|
||||
commandSource.sendMessage(TextComponent.of(servers.toString()).color(TextColor.YELLOW));
|
||||
commandSource.sendMessage(Component.text(servers.toString()).color(COLOR_YELLOW));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.find");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.find");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandStaffChat implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_RED;
|
||||
|
||||
public class CommandStaffChat implements SimpleCommand {
|
||||
private final ProxyServer server;
|
||||
|
||||
public CommandStaffChat(ProxyServer server) {
|
||||
|
@ -21,27 +21,30 @@ public class CommandStaffChat implements Command {
|
|||
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(SimpleCommand.Invocation invocation) {
|
||||
CommandSource commandSource = invocation.source();
|
||||
String[] strings = invocation.arguments();
|
||||
|
||||
if (strings.length > 0) {
|
||||
String channel = strings[0].startsWith("c:") && !strings[0].equals("c:") ? strings[0].split(":")[1] : null;
|
||||
String message = "§4[Staff]§r " + (commandSource instanceof Player ? ((Player) commandSource).getUsername() : "Console") + (channel != null ? " (" + channel + ")" : "")+ " > " + String.join(" ", Arrays.copyOfRange(strings, channel == null ? 0 : 1, strings.length)).replace("&", "§");
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
if (player.hasPermission("vtools.staffchat" + (channel != null ? "." + channel : ""))) {
|
||||
player.sendMessage(TextComponent.of(message));
|
||||
player.sendMessage(Component.text(message));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Usage: /broadcast <message>").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Usage: /broadcast <message>").color(COLOR_RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(SimpleCommand.Invocation invocation) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("vtools.staffchat");
|
||||
public boolean hasPermission(SimpleCommand.Invocation invocation) {
|
||||
return invocation.source().hasPermission("vtools.staffchat");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package de.strifel.VTools.commands;
|
||||
|
||||
import com.velocitypowered.api.command.Command;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CommandTp implements Command {
|
||||
import static de.strifel.VTools.VTools.COLOR_RED;
|
||||
import static de.strifel.VTools.VTools.COLOR_YELLOW;
|
||||
|
||||
public class CommandTp implements SimpleCommand {
|
||||
|
||||
private final ProxyServer server;
|
||||
|
||||
|
@ -21,28 +22,31 @@ public class CommandTp implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource commandSource, @NonNull String[] strings) {
|
||||
public void execute(Invocation commandInvocation) {
|
||||
CommandSource commandSource = commandInvocation.source();
|
||||
String[] strings = commandInvocation.arguments();
|
||||
|
||||
if (commandSource instanceof Player) {
|
||||
if (strings.length == 1) {
|
||||
Optional<Player> player = server.getPlayer(strings[0]);
|
||||
if (player.isPresent()) {
|
||||
player.get().getCurrentServer().ifPresent(serverConnection -> ((Player) commandSource).createConnectionRequest(serverConnection.getServer()).fireAndForget());
|
||||
commandSource.sendMessage(TextComponent.of("Connecting to the server of " + strings[0]).color(TextColor.YELLOW));
|
||||
commandSource.sendMessage(Component.text("Connecting to the server of " + strings[0]).color(COLOR_YELLOW));
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Player does not exists.").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Player does not exists.").color(COLOR_RED));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Usage: /tps <username>").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Usage: /tps <username>").color(COLOR_RED));
|
||||
}
|
||||
} else {
|
||||
commandSource.sendMessage(TextComponent.of("Command is only for players.").color(TextColor.RED));
|
||||
commandSource.sendMessage(Component.text("Command is only for players.").color(COLOR_RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
|
||||
public List<String> suggest(Invocation commandInvocation) {
|
||||
List<String> arg = new ArrayList<>();
|
||||
if (currentArgs.length == 1) {
|
||||
if (commandInvocation.arguments().length == 1) {
|
||||
for (Player player : server.getAllPlayers()) {
|
||||
arg.add(player.getUsername());
|
||||
}
|
||||
|
@ -51,7 +55,7 @@ public class CommandTp implements Command {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
|
||||
return source.hasPermission("VTools.tps");
|
||||
public boolean hasPermission(Invocation commandInvocation) {
|
||||
return commandInvocation.source().hasPermission("VTools.tps");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue