1
0
Fork 0
forked from mc/VTools

fix /server

This commit is contained in:
JerryXiao 2023-05-28 14:13:55 +08:00
parent 7cfb423c70
commit d1955da813
Signed by untrusted user: Jerry
GPG key ID: 22618F758B5BE2E5
3 changed files with 25 additions and 12 deletions

View file

@ -40,7 +40,7 @@ public class VTools {
server.getCommandManager().register("staffchat", new CommandStaffChat(server), "sc"); server.getCommandManager().register("staffchat", new CommandStaffChat(server), "sc");
server.getCommandManager().register("restart", new CommandRestart(server)); server.getCommandManager().register("restart", new CommandRestart(server));
server.getCommandManager().register("tps", new CommandTp(server), "jump"); server.getCommandManager().register("tps", new CommandTp(server), "jump");
server.getCommandManager().register("server", new CommandServer(server)); server.getCommandManager().register("server", new CommandServer(server), "serverv");
server.getCommandManager().register("servers", new CommandServers(server), "allservers"); server.getCommandManager().register("servers", new CommandServers(server), "allservers");
new TGBridge(this).register(); new TGBridge(this).register();
new PlayerStatus(this).register(); new PlayerStatus(this).register();

View file

@ -1,10 +1,12 @@
package de.strifel.VTools.commands; package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand; 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 de.strifel.VTools.commands.utils.ServerUtil; import de.strifel.VTools.commands.utils.ServerUtil;
import net.kyori.adventure.text.Component;
import static de.strifel.VTools.VTools.COLOR_RED;
public class CommandServer extends ServerUtil implements SimpleCommand { public class CommandServer extends ServerUtil implements SimpleCommand {
@ -16,15 +18,24 @@ public class CommandServer extends ServerUtil implements SimpleCommand {
} }
@Override @Override
public boolean hasPermission(Invocation commandInvocation) { public void execute(final SimpleCommand.Invocation invocation) {
CommandSource invocationSource = commandInvocation.source(); if (invocation.source() instanceof Player) {
if (invocationSource.hasPermission("vtools.servertp.auto") && invocationSource instanceof Player) { if (
Player player = (Player)invocationSource; invocation.source().hasPermission("velocity.command.server") ||
if (server.getAllPlayers().stream().anyMatch(p -> p.hasPermission("vtools.send") && p.hasPermission("vtools.send.revcmsg"))) { server.getAllPlayers().stream().anyMatch(p -> p.hasPermission("vtools.send") && p.hasPermission("vtools.send.recvmsg"))) {
return true; super.execute(invocation);
}
else {
invocation.source().sendMessage(Component.text("Supervisor offline.").color(COLOR_RED));
} }
return false;
} }
else return invocationSource.hasPermission("vtools.servertp"); else {
invocation.source().sendMessage(Component.text("Command is only for players.").color(COLOR_RED));
}
}
@Override
public boolean hasPermission(Invocation commandInvocation) {
return commandInvocation.source().hasPermission("vtools.server.auto");
} }
} }

View file

@ -54,10 +54,12 @@ public class GlistUtil {
TextComponent.Builder builder = Component.text() TextComponent.Builder builder = Component.text()
.append(Component.text("[" + server.getServerInfo().getName() + "] ", .append(Component.text("[" + server.getServerInfo().getName() + "] ",
NamedTextColor.DARK_AQUA)) NamedTextColor.DARK_AQUA)
.clickEvent(ClickEvent.runCommand("/server " + server.getServerInfo().getName()))
)
.append(Component.text("(" + onServer.size() + ")", NamedTextColor.GRAY)) .append(Component.text("(" + onServer.size() + ")", NamedTextColor.GRAY))
.append(Component.text(": ")) .append(Component.text(": "))
.clickEvent(ClickEvent.runCommand("/server " + server.getServerInfo().getName()))
.resetStyle(); .resetStyle();
for (int i = 0; i < onServer.size(); i++) { for (int i = 0; i < onServer.size(); i++) {