2025-03-25 23:10:40 +01:00
|
|
|
package game.command.commands;
|
|
|
|
|
|
|
|
import game.command.CommandEnvironment;
|
|
|
|
import game.command.RunException;
|
|
|
|
import game.command.Command;
|
|
|
|
import game.command.Executor;
|
2025-03-26 12:22:32 +01:00
|
|
|
import game.network.Player;
|
2025-03-25 23:10:40 +01:00
|
|
|
|
|
|
|
public class CommandRevoke extends Command {
|
|
|
|
public CommandRevoke() {
|
|
|
|
super("revoke");
|
|
|
|
|
|
|
|
this.addPlayer("player", false);
|
|
|
|
}
|
|
|
|
|
2025-03-26 12:22:32 +01:00
|
|
|
public void exec(CommandEnvironment env, Executor exec, Player player) {
|
|
|
|
if(!(exec instanceof Player) || !((Player)exec).isLocal())
|
2025-03-25 23:10:40 +01:00
|
|
|
throw new RunException("Dieser Befehl kann nur vom Host-Spieler ausgeführt werden");
|
|
|
|
else if(player == exec)
|
|
|
|
throw new RunException("Du kannst nicht deinen eigenen Admin-Status entfernen");
|
|
|
|
else if(player.isLocal())
|
|
|
|
throw new RunException("%s ist der Host-Spieler", player.getUser());
|
|
|
|
else if(!player.getAdmin())
|
|
|
|
throw new RunException("%s ist kein Admin", player.getUser());
|
|
|
|
player.setAdmin(false);
|
|
|
|
player.logConsole("Der Host hat deine Administatorrechte entfernt");
|
|
|
|
exec.logConsole("%s ist jetzt kein Admin mehr", player.getUser());
|
|
|
|
}
|
|
|
|
}
|