2022-04-21 06:48:24 +08:00
|
|
|
package emu.grasscutter.command.commands;
|
|
|
|
|
|
|
|
import emu.grasscutter.command.Command;
|
|
|
|
import emu.grasscutter.command.CommandHandler;
|
2022-04-27 12:24:25 +08:00
|
|
|
import emu.grasscutter.game.player.Player;
|
2022-04-21 06:48:24 +08:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2022-05-06 12:57:45 +08:00
|
|
|
import static emu.grasscutter.utils.Language.translate;
|
|
|
|
|
2022-05-06 16:06:13 +08:00
|
|
|
@Command(label = "godmode", usage = "godmode [on|off|toggle]", permission = "player.godmode", permissionTargeted = "player.godmode.others", description = "commands.godmode.description")
|
2022-04-21 06:48:24 +08:00
|
|
|
public final class GodModeCommand implements CommandHandler {
|
|
|
|
|
|
|
|
@Override
|
2022-05-04 14:32:09 +08:00
|
|
|
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
2022-05-04 17:16:42 +08:00
|
|
|
if (targetPlayer == null) {
|
2022-05-06 12:57:45 +08:00
|
|
|
CommandHandler.sendMessage(sender, translate("commands.execution.need_target"));
|
2022-05-04 17:16:42 +08:00
|
|
|
return;
|
2022-04-21 06:48:24 +08:00
|
|
|
}
|
2022-04-24 11:40:10 +08:00
|
|
|
|
2022-05-04 17:16:42 +08:00
|
|
|
boolean enabled = !targetPlayer.inGodmode();
|
2022-04-24 11:40:10 +08:00
|
|
|
if (args.size() == 1) {
|
2022-05-04 17:16:42 +08:00
|
|
|
switch (args.get(0).toLowerCase()) {
|
|
|
|
case "on":
|
|
|
|
enabled = true;
|
|
|
|
break;
|
|
|
|
case "off":
|
|
|
|
enabled = false;
|
|
|
|
break;
|
|
|
|
case "toggle":
|
|
|
|
break; // Already toggled
|
|
|
|
default:
|
2022-05-06 12:57:45 +08:00
|
|
|
break;
|
2022-04-24 11:40:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-04 17:16:42 +08:00
|
|
|
targetPlayer.setGodmode(enabled);
|
2022-05-06 12:57:45 +08:00
|
|
|
CommandHandler.sendMessage(sender, translate("commands.godmode.success", (enabled ? translate("commands.status.enabled") : translate("commands.status.disabled")), targetPlayer.getNickname()));
|
2022-04-21 06:48:24 +08:00
|
|
|
}
|
|
|
|
}
|