CommandSetWarp.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package me.km.commands;
  2. import me.km.api.GlobalText;
  3. import me.km.api.Location;
  4. import me.km.api.Module;
  5. import me.km.api.ModuleCommand;
  6. import me.km.api.SimpleConfig;
  7. import me.km.api.Utils;
  8. import me.km.permissions.Permissions;
  9. import net.minecraft.command.ICommandSender;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. public class CommandSetWarp extends ModuleCommand
  12. {
  13. public CommandSetWarp(Module m)
  14. {
  15. super("setwarp", m);
  16. super.setDescription("Erstellt einen neuen Warp");
  17. super.setUsage("/setwarp <warpname>");
  18. super.setPermission(Permissions.SET_WARP);
  19. }
  20. public boolean addWarp(String name, Location l)
  21. {
  22. SimpleConfig sc = new SimpleConfig(this.getModule(), "warp/" + name, false);
  23. if(sc.exists())
  24. {
  25. return false;
  26. }
  27. sc.setLocation("warp", l);
  28. sc.save();
  29. return true;
  30. }
  31. @Override
  32. public boolean execute(ICommandSender cs, String[] arg)
  33. {
  34. if(!(cs instanceof EntityPlayer))
  35. {
  36. this.getModule().send(cs, GlobalText.onlyPlayer());
  37. return true;
  38. }
  39. if(arg.length < 1)
  40. {
  41. return false;
  42. }
  43. if(addWarp(arg[0], Utils.getEntityLocation((EntityPlayer) cs)))
  44. {
  45. this.getModule().send(cs, "Der Warp " + arg[0] + " wurde erstellt.");
  46. return true;
  47. }
  48. this.getModule().send(cs, "Der Warp " + arg[0] + " existiert bereits.");
  49. return true;
  50. }
  51. }