Allow for console plot clearing.

This commit is contained in:
Sauilitired 2014-11-08 21:00:43 +01:00
parent a39d50843e
commit 4df3535a43
5 changed files with 59 additions and 16 deletions

View File

@ -15,7 +15,6 @@ public class WorldEditUtils {
// bukkitWorld.setBlock(vector, block);
// }
// catch (final WorldEditException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}

View File

@ -706,6 +706,12 @@ public class PlotHelper {
* @param plot
*/
public static void clear(final Player requester, final Plot plot) {
if (requester == null) {
clearAllEntities(plot.getWorld(), plot, false);
clear(plot.getWorld(), plot);
removeSign(plot.getWorld(), plot);
return;
}
if (runners.containsKey(plot)) {
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
return;
@ -716,11 +722,7 @@ public class PlotHelper {
final long start = System.nanoTime();
final World world;
if (requester != null) {
world = requester.getWorld();
} else {
world = Bukkit.getWorld(plot.world);
}
world = requester.getWorld();
/*
* keep
@ -730,7 +732,6 @@ public class PlotHelper {
removeSign(world, plot);
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0)));
return;
}
public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {

View File

@ -22,6 +22,27 @@
package com.intellectualcrafters.plot;
public class PlotId {
/**
* Get a Plot Id based on a string
*
* @param string to create id from
* @return null if the string is invalid
*/
public static PlotId fromString(final String string) {
int x, y;
String[] parts = string.split(";");
if (parts.length < 2)
return null;
try {
x = Integer.parseInt(parts[0]);
y = Integer.parseInt(parts[1]);
} catch (Exception e) {
return null;
}
return new PlotId(x, y);
}
/**
* x value
*/

View File

@ -763,13 +763,11 @@ public class PlotMain extends JavaPlugin {
PlotHelper.canSetFast = false;
}
// Setup version + downloads, will not be updated... maybe setup
// runnable? TODO Let jesse decide...
com.intellectualcrafters.plot.commands.plugin.setup(this);
setUUIDSaver(new PlotUUIDSaver());
// Looks really cool xD
getUUIDSaver().globalPopulate();
// UUIDHandler.startFetch(this);
}
/**
@ -1154,7 +1152,7 @@ public class PlotMain extends JavaPlugin {
for (final ConfigurationNode setting : plotworld.getSettingNodes()) {
options.put(setting.getConstant(), setting.getValue());
//TODO: Make jesse expalain wth was going on here
//TODO: Make jesse explain wth was going on here
}
for (final Entry<String, Object> node : options.entrySet()) {

View File

@ -21,16 +21,14 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Clear extends SubCommand {
public Clear() {
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, true);
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS, false);
// TODO console clear plot at location
@ -38,6 +36,32 @@ public class Clear extends SubCommand {
@Override
public boolean execute(final Player plr, final String... args) {
if (plr == null) {
// Is console
if (args.length < 2) {
PlotMain.sendConsoleSenderMessage("You need to specify two arguments: ID (0;0) & World (world)");
} else {
PlotId id = PlotId.fromString(args[0]);
String world = args[1];
if (id == null) {
PlotMain.sendConsoleSenderMessage("Invalid Plot ID: " + args[0]);
} else {
if (!PlotMain.isPlotWorld(world)) {
PlotMain.sendConsoleSenderMessage("Invalid plot world: " + world);
} else {
Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id);
if (plot == null) {
PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world);
} else {
plot.clear(null);
PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared.");
}
}
}
}
return true;
}
if (!PlayerFunctions.isInPlot(plr)) {
return sendMessage(plr, C.NOT_IN_PLOT);
}