package dk.thoerup.bukkit.hoeruputils; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class GrassCommand implements CommandExecutor { @Override public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { if (! (sender instanceof Player)) { //what are you then ? return false; } Player p = (Player) sender; Location loc = p.getLocation(); World w = loc.getWorld(); Block b = w.getBlockAt(loc.getBlockX(), loc.getBlockY()-1, loc.getBlockZ()); if (b.getTypeId() == 3) { b.setTypeId(2); } else { p.sendMessage("Can only plant grass on dirt"); } return true; } }