CommandGrow.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package me.km.commands;
  2. import me.kt.api.GlobalText;
  3. import me.kt.api.Module;
  4. import me.kt.api.ModuleCommand;
  5. import org.bukkit.CropState;
  6. import org.bukkit.block.Block;
  7. import org.bukkit.block.BlockState;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.material.Crops;
  11. public class CommandGrow extends ModuleCommand
  12. {
  13. public CommandGrow(Module m)
  14. {
  15. super("grow", m);
  16. this.setDescription("Lässt die Pflanzen in deiner Umgebung wachsen");
  17. this.setUsage("/grow");
  18. this.setPermission("kt.grow");
  19. }
  20. @Override
  21. public boolean execute(CommandSender cs, String string, String[] arg)
  22. {
  23. if(!(cs instanceof Player))
  24. {
  25. this.getModule().send(cs, GlobalText.onlyPlayer());
  26. return true;
  27. }
  28. Block l = ((Player) cs).getLocation().getBlock();
  29. Block b;
  30. for(int x = -3; x < 4; x++)
  31. {
  32. for(int y = -3; y < 4; y++)
  33. {
  34. for(int z = -3; z < 4; z++)
  35. {
  36. b = l.getRelative(x, y, z);
  37. if(!(b.getState().getData() instanceof Crops))
  38. {
  39. continue;
  40. }
  41. if(((Crops) b.getState().getData()).getState() != CropState.RIPE)
  42. {
  43. BlockState state = b.getState();
  44. Crops crop = ((Crops) state.getData());
  45. crop.setState(CropState.RIPE);
  46. state.setData(crop);
  47. state.update();
  48. }
  49. }
  50. }
  51. }
  52. this.getModule().send(cs, "Die Pflanzen in deiner Umgebung sind gewachsen.");
  53. return true;
  54. }
  55. }