CommandSetBed.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package me.km.commands;
  2. import me.km.api.GlobalText;
  3. import me.km.api.Module;
  4. import me.km.api.ModuleCommand;
  5. import me.km.api.Utils;
  6. import me.km.permissions.Permissions;
  7. import net.minecraft.command.ICommandSender;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.init.Blocks;
  10. import net.minecraft.util.math.BlockPos;
  11. public class CommandSetBed extends ModuleCommand
  12. {
  13. public CommandSetBed(Module m)
  14. {
  15. super("setbed", m);
  16. super.setDescription("Setzt deinen Bettspawn");
  17. super.setUsage("/setbed");
  18. super.setPermission(Permissions.SET_BED);
  19. }
  20. @Override
  21. public boolean execute(ICommandSender cs, String[] arg)
  22. {
  23. if(!(cs instanceof EntityPlayer))
  24. {
  25. this.getModule().send(cs, GlobalText.onlyPlayer());
  26. return true;
  27. }
  28. EntityPlayer p = (EntityPlayer) cs;
  29. BlockPos pos = Utils.getPlayerTarget(p);
  30. if(p.world.getBlockState(pos).getBlock() != Blocks.BED)
  31. {
  32. this.getModule().send(cs, "Du musst auf ein Bett gerichtet sein.");
  33. return true;
  34. }
  35. p.setSpawnPoint(pos, false);
  36. p.bedLocation = pos;
  37. this.getModule().send(cs, "Dein Bett-Spawn wurde gesetzt.");
  38. return true;
  39. }
  40. }