Compare commits
2 commits
5a975a1195
...
d647b99465
Author | SHA1 | Date | |
---|---|---|---|
d647b99465 | |||
115364f202 |
3 changed files with 18 additions and 8 deletions
|
@ -5,6 +5,8 @@ import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,7 +31,12 @@ public class CommandFind implements SimpleCommand {
|
||||||
if (strings.length == 1) {
|
if (strings.length == 1) {
|
||||||
Optional<Player> player = server.getPlayer(strings[0]);
|
Optional<Player> player = server.getPlayer(strings[0]);
|
||||||
if (player.isPresent() && player.get().getCurrentServer().isPresent()) {
|
if (player.isPresent() && player.get().getCurrentServer().isPresent()) {
|
||||||
commandSource.sendMessage(Component.text("Player " + strings[0] + " is on " + player.get().getCurrentServer().get().getServerInfo().getName() + "!").color(COLOR_YELLOW));
|
String serverName = player.get().getCurrentServer().get().getServerInfo().getName();
|
||||||
|
commandSource.sendMessage(Component.empty()
|
||||||
|
.append(Component.text("Player " + strings[0] + " is on ").color(COLOR_YELLOW))
|
||||||
|
.append(Component.text(serverName).clickEvent(ClickEvent.runCommand("/server " + serverName)).color(NamedTextColor.GRAY))
|
||||||
|
.append(Component.text("!").color(COLOR_YELLOW))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
commandSource.sendMessage(Component.text("The player is not online!").color(COLOR_YELLOW));
|
commandSource.sendMessage(Component.text("The player is not online!").color(COLOR_YELLOW));
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,16 +104,19 @@ public class CommandSend implements SimpleCommand {
|
||||||
String[] currentArgs = invocation.arguments();
|
String[] currentArgs = invocation.arguments();
|
||||||
switch (currentArgs.length) {
|
switch (currentArgs.length) {
|
||||||
case 0, 1 -> {
|
case 0, 1 -> {
|
||||||
List<String> arg = new ArrayList<>(server.getPlayerCount() + 2);
|
List<String> args = new ArrayList<>(server.getPlayerCount() + 2);
|
||||||
arg.add("all");
|
args.add("all");
|
||||||
arg.add("current");
|
args.add("current");
|
||||||
for (Player player : server.getAllPlayers()) {
|
for (Player player : server.getAllPlayers()) {
|
||||||
arg.add(player.getUsername());
|
args.add(player.getUsername());
|
||||||
}
|
}
|
||||||
return arg;
|
return currentArgs.length==0?args:
|
||||||
|
args.stream().filter(arg->arg.regionMatches(true,0,currentArgs[0],0,currentArgs[0].length())).toList();
|
||||||
}
|
}
|
||||||
case 2 -> {
|
case 2 -> {
|
||||||
return server.getAllServers().stream().map(s -> s.getServerInfo().getName()).toList();
|
return server.getAllServers().stream().map(s -> s.getServerInfo().getName())
|
||||||
|
.filter(name -> name.regionMatches(true, 0, currentArgs[1], 0, currentArgs[1].length()))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return new ArrayList<>(0);
|
return new ArrayList<>(0);
|
||||||
|
|
|
@ -56,6 +56,6 @@ public class CommandTp implements SimpleCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(Invocation commandInvocation) {
|
public boolean hasPermission(Invocation commandInvocation) {
|
||||||
return commandInvocation.source().hasPermission("VTools.tps");
|
return commandInvocation.source().hasPermission("VTools.tps") || commandInvocation.source().hasPermission("vtools.server.auto");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue