12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package me.km.commands;
- import me.kt.api.GlobalText;
- import me.kt.api.Module;
- import me.kt.api.ModuleCommand;
- import org.bukkit.CropState;
- import org.bukkit.block.Block;
- import org.bukkit.block.BlockState;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.material.Crops;
- public class CommandGrow extends ModuleCommand
- {
- public CommandGrow(Module m)
- {
- super("grow", m);
- this.setDescription("Lässt die Pflanzen in deiner Umgebung wachsen");
- this.setUsage("/grow");
- this.setPermission("kt.grow");
- }
- @Override
- public boolean execute(CommandSender cs, String string, String[] arg)
- {
- if(!(cs instanceof Player))
- {
- this.getModule().send(cs, GlobalText.onlyPlayer());
- return true;
- }
- Block l = ((Player) cs).getLocation().getBlock();
- Block b;
- for(int x = -3; x < 4; x++)
- {
- for(int y = -3; y < 4; y++)
- {
- for(int z = -3; z < 4; z++)
- {
- b = l.getRelative(x, y, z);
- if(!(b.getState().getData() instanceof Crops))
- {
- continue;
- }
- if(((Crops) b.getState().getData()).getState() != CropState.RIPE)
- {
- BlockState state = b.getState();
- Crops crop = ((Crops) state.getData());
- crop.setState(CropState.RIPE);
- state.setData(crop);
- state.update();
- }
- }
- }
- }
- this.getModule().send(cs, "Die Pflanzen in deiner Umgebung sind gewachsen.");
- return true;
- }
- }
|