Added debugfill command

This commit is contained in:
boy0001 2015-04-26 23:38:02 +10:00
parent 6c68f88df9
commit 2c76c0608c
3 changed files with 169 additions and 1 deletions

View File

@ -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());

View File

@ -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 <outline|all>");
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;
}
}

View File

@ -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 <lower|offline|online>");
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 <lower|offline|online>");
return false;
}
}
}
if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) {
MainUtil.sendMessage(player, "&cUUID mode already in use!");
return false;
}
return true;
}