From 2c76c0608c418faf8a74b5bcfe96292ec406e0c7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 23:38:02 +1000 Subject: [PATCH] Added debugfill command --- .../intellectualcrafters/plot/BukkitMain.java | 2 + .../plot/commands/DebugFill.java | 120 ++++++++++++++++++ .../plot/commands/DebugUUID.java | 48 ++++++- 3 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 0a70a3765..e2a3cbd76 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.commands.Debug; import com.intellectualcrafters.plot.commands.DebugClaimTest; import com.intellectualcrafters.plot.commands.DebugClear; import com.intellectualcrafters.plot.commands.DebugExec; +import com.intellectualcrafters.plot.commands.DebugFill; import com.intellectualcrafters.plot.commands.DebugFixFlags; import com.intellectualcrafters.plot.commands.DebugLoadTest; import com.intellectualcrafters.plot.commands.DebugRoadRegen; @@ -209,6 +210,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { MainCommand.subCommands.add(new Template()); MainCommand.subCommands.add(new Setup()); MainCommand.subCommands.add(new DebugUUID()); + MainCommand.subCommands.add(new DebugFill()); MainCommand.subCommands.add(new DebugSaveTest()); MainCommand.subCommands.add(new DebugLoadTest()); MainCommand.subCommands.add(new CreateRoadSchematic()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java new file mode 100644 index 000000000..fc676c07c --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java @@ -0,0 +1,120 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.SetBlockQueue; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; + +public class DebugFill extends SubCommand { + public DebugFill() { + super("fill", "plots.fill", "Fill or surround a plot in bedrock", "fill", "debugfill", CommandCategory.DEBUG, true); + } + + @Override + public boolean execute(final PlotPlayer player, final String... args) { + if (args.length != 1 || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill "); + return true; + } + final Location loc = player.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(player, C.NOT_IN_PLOT); + } + if ((plot == null) || !plot.hasOwner()) { + MainUtil.sendMessage(player, C.PLOT_UNOWNED); + return false; + } + if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.fill")) { + MainUtil.sendMessage(player, C.NO_PLOT_PERMS); + return true; + } + final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + MainUtil.sendMessage(player, "&cPreparing task"); + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(player, "&7 - Starting"); + if (args[0].equalsIgnoreCase("all")) { + for (int x = bottom.getX(); x <= top.getX(); x++) { + for (int y = 0; y <= 255; y++) { + for (int z = bottom.getZ(); z <= top.getZ(); z++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + } + } + else if (args[0].equals("outline")) { + int x, z; + z = bottom.getZ(); + for (x = bottom.getX(); x <= (top.getX() - 1); x++) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + x = top.getX(); + for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + z = top.getZ(); + for (x = top.getX(); x >= (bottom.getX() + 1); x--) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + x = bottom.getX(); + for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + int y = 255; + for (x = bottom.getX(); x <= top.getX(); x++) { + for (z = bottom.getZ(); z <= top.getZ(); z++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + } + SetBlockQueue.addNotify(new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(player, "&aFill task complete!"); + } + }); + } + }); + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index f147502ee..1e072abac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -21,12 +21,21 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetBlockQueue; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; public class DebugUUID extends SubCommand { public DebugUUID() { - super("debuguuid", "plots.admin", "Debug uuid conversion", "debuguuid", "uuidconvert", CommandCategory.DEBUG, false); + super("uuidconvert", "plots.admin", "Debug uuid conversion", "debuguuid", "debuguuid", CommandCategory.DEBUG, false); } @Override @@ -35,6 +44,43 @@ public class DebugUUID extends SubCommand { MainUtil.sendMessage(player, C.NOT_CONSOLE); return false; } + if (args.length == 0) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert "); + return false; + } + + UUIDWrapper currentUUIDWrapper = UUIDHandler.uuidWrapper; + UUIDWrapper newWrapper = null; + + switch (args[0].toLowerCase()) { + case "lower": { + newWrapper = new LowerOfflineUUIDWrapper(); + break; + } + case "offline": { + newWrapper = new OfflineUUIDWrapper(); + break; + } + case "online": { + newWrapper = new DefaultUUIDWrapper(); + break; + } + default: { + try { + Class clazz = Class.forName(args[0]); + newWrapper = (UUIDWrapper) clazz.newInstance(); + } + catch (Exception e) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert "); + return false; + } + } + } + + if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) { + MainUtil.sendMessage(player, "&cUUID mode already in use!"); + return false; + } return true; }