123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package me.km.commands;
- import me.km.api.Utils;
- import me.km.api.GlobalText;
- import me.km.api.Module;
- import me.km.api.ModuleCommand;
- import me.km.exception.PlayerNotFoundException;
- import me.km.permissions.Permission;
- import me.km.permissions.Permissions;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.entity.player.EntityPlayer;
- public class CommandKill extends ModuleCommand
- {
- public CommandKill(Module m)
- {
- super("kill", m);
- super.setDescription("Tötet einen Spieler");
- super.setUsage("/kill [player]");
- super.setPermission(Permissions.KILL);
- }
- @Override
- public boolean execute(ICommandSender cs, String[] arg)
- {
- if(arg.length == 0 || !Permission.hasPermission(cs, Permissions.KILL_OTHER))
- {
- if(!(cs instanceof EntityPlayer))
- {
- this.getModule().send(cs, GlobalText.missingParameter());
- return true;
- }
- EntityPlayer p = (EntityPlayer) cs;
- p.onKillCommand();
- this.getModule().send(cs, "Du hast dich selbst getötet.");
- return true;
- }
- try
- {
- EntityPlayer affectedPlayer = Utils.getPlayerByName(arg[0]);
- affectedPlayer.onKillCommand();
- this.getModule().send(cs, "Du hast " + affectedPlayer.getName() + " getötet.");
- this.getModule().send(affectedPlayer, cs.getName() + " hat dich getötet.");
- }
- catch(PlayerNotFoundException ex)
- {
- this.getModule().send(cs, GlobalText.cantFindPlayer(arg[0]));
- }
- return true;
- }
- }
|