Added op command

This commit is contained in:
2023-09-30 22:31:07 +02:00
parent 61919b71b1
commit b836874b46
12 changed files with 28 additions and 1 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -18,7 +18,8 @@ public enum Commands {
GC(new GcCommand()),
LANGTEST(new LangTestCommand()),
ROOM(new RoomCommand()),
UPDATE(new UpdateCommand());
UPDATE(new UpdateCommand()),
OP(new OpCommand());
Commands(Command handler) {
MinecraftServer.getCommandManager().register(handler);
@@ -0,0 +1,25 @@
package eu.mhsl.minenet.minigames.command.privileged;
import eu.mhsl.minenet.minigames.message.Icon;
import eu.mhsl.minenet.minigames.message.type.ChatMessage;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command;
import net.minestom.server.command.builder.arguments.ArgumentType;
import net.minestom.server.entity.Player;
import net.minestom.server.permission.Permission;
public class OpCommand extends Command {
public OpCommand() {
super("op");
setCondition((sender, commandString) -> sender.hasPermission("admin"));
addSyntax((sender, context) -> {
Player target = MinecraftServer.getConnectionManager().getPlayer(context.getRaw("target"));
if(target != null)
target.addPermission(new Permission("admin"));
else
new ChatMessage(Icon.ERROR).appendStatic("Spieler nicht gefunden").send(sender);
}, ArgumentType.Entity("target").onlyPlayers(true));
}
}
@@ -30,6 +30,7 @@ public class LastWinsScore extends Score {
@Override
public void addResult(Player p) {
if(scores.contains(p)) return;
scores.add(0, p);
new TitleMessage(Duration.ofMillis(1000), Duration.ofSeconds(1)).appendTranslated("score#death").send(p);