CommandKill.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package me.km.commands;
  2. import me.km.api.Utils;
  3. import me.km.api.GlobalText;
  4. import me.km.api.Module;
  5. import me.km.api.ModuleCommand;
  6. import me.km.exception.PlayerNotFoundException;
  7. import me.km.permissions.Permission;
  8. import me.km.permissions.Permissions;
  9. import net.minecraft.command.ICommandSender;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. public class CommandKill extends ModuleCommand
  12. {
  13. public CommandKill(Module m)
  14. {
  15. super("kill", m);
  16. super.setDescription("Tötet einen Spieler");
  17. super.setUsage("/kill [player]");
  18. super.setPermission(Permissions.KILL);
  19. }
  20. @Override
  21. public boolean execute(ICommandSender cs, String[] arg)
  22. {
  23. if(arg.length == 0 || !Permission.hasPermission(cs, Permissions.KILL_OTHER))
  24. {
  25. if(!(cs instanceof EntityPlayer))
  26. {
  27. this.getModule().send(cs, GlobalText.missingParameter());
  28. return true;
  29. }
  30. EntityPlayer p = (EntityPlayer) cs;
  31. p.onKillCommand();
  32. this.getModule().send(cs, "Du hast dich selbst getötet.");
  33. return true;
  34. }
  35. try
  36. {
  37. EntityPlayer affectedPlayer = Utils.getPlayerByName(arg[0]);
  38. affectedPlayer.onKillCommand();
  39. this.getModule().send(cs, "Du hast " + affectedPlayer.getName() + " getötet.");
  40. this.getModule().send(affectedPlayer, cs.getName() + " hat dich getötet.");
  41. }
  42. catch(PlayerNotFoundException ex)
  43. {
  44. this.getModule().send(cs, GlobalText.cantFindPlayer(arg[0]));
  45. }
  46. return true;
  47. }
  48. }