diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java deleted file mode 100644 index d3480d42..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java +++ /dev/null @@ -1,78 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import java.util.Optional; -import me.totalfreedom.totalfreedommod.rank.Rank; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.type.Switch; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) -@CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/ ") -public class Command_setlever extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length != 5) - { - return false; - } - - double x, y, z; - try - { - x = Double.parseDouble(args[0]); - y = Double.parseDouble(args[1]); - z = Double.parseDouble(args[2]); - - // Shows the "Invalid coordinates" message without having to do boilerplate bullshit - if (Math.abs(x) > 29999998 || Math.abs(y) > 29999998 || Math.abs(z) > 29999998) - { - throw new IllegalArgumentException(); - } - } - catch (IllegalArgumentException ex) - { - msg("Invalid coordinates."); - return true; - } - - Optional optionalWorld = server.getWorlds().stream().filter(world -> - world.getName().equalsIgnoreCase(args[3])).findAny(); - - if (optionalWorld.isEmpty()) - { - msg("Invalid world: " + args[3]); - return true; - } - - final Location leverLocation = new Location(optionalWorld.get(), x, y, z); - final Block targetBlock = leverLocation.getBlock(); - - if (targetBlock.getType() == Material.LEVER) - { - BlockState state = targetBlock.getState(); - BlockData data = state.getBlockData(); - Switch caster = (Switch) data; - - caster.setPowered(args[4].trim().equalsIgnoreCase("on") || args[4].trim().equalsIgnoreCase("1")); - state.setBlockData(data); - state.update(); - - plugin.cpb.getCoreProtectAPI().logInteraction(sender.getName(), leverLocation); - } - else - { - msg("That block isn't a lever."); - } - - return true; - } -}