mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Allow for console plot clearing.
This commit is contained in:
parent
a39d50843e
commit
4df3535a43
@ -15,7 +15,6 @@ public class WorldEditUtils {
|
|||||||
// bukkitWorld.setBlock(vector, block);
|
// bukkitWorld.setBlock(vector, block);
|
||||||
// }
|
// }
|
||||||
// catch (final WorldEditException e) {
|
// catch (final WorldEditException e) {
|
||||||
// // TODO Auto-generated catch block
|
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -706,6 +706,12 @@ public class PlotHelper {
|
|||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
public static void clear(final Player requester, final Plot 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)) {
|
if (runners.containsKey(plot)) {
|
||||||
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
|
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
|
||||||
return;
|
return;
|
||||||
@ -716,11 +722,7 @@ public class PlotHelper {
|
|||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
|
|
||||||
final World world;
|
final World world;
|
||||||
if (requester != null) {
|
|
||||||
world = requester.getWorld();
|
world = requester.getWorld();
|
||||||
} else {
|
|
||||||
world = Bukkit.getWorld(plot.world);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* keep
|
* keep
|
||||||
@ -730,7 +732,6 @@ public class PlotHelper {
|
|||||||
removeSign(world, plot);
|
removeSign(world, plot);
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0)));
|
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) {
|
public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
||||||
|
@ -22,6 +22,27 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
public class PlotId {
|
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
|
* x value
|
||||||
*/
|
*/
|
||||||
|
@ -763,13 +763,11 @@ public class PlotMain extends JavaPlugin {
|
|||||||
PlotHelper.canSetFast = false;
|
PlotHelper.canSetFast = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup version + downloads, will not be updated... maybe setup
|
|
||||||
// runnable? TODO Let jesse decide...
|
|
||||||
com.intellectualcrafters.plot.commands.plugin.setup(this);
|
com.intellectualcrafters.plot.commands.plugin.setup(this);
|
||||||
|
|
||||||
setUUIDSaver(new PlotUUIDSaver());
|
setUUIDSaver(new PlotUUIDSaver());
|
||||||
|
// Looks really cool xD
|
||||||
getUUIDSaver().globalPopulate();
|
getUUIDSaver().globalPopulate();
|
||||||
// UUIDHandler.startFetch(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1154,7 +1152,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
|
|
||||||
for (final ConfigurationNode setting : plotworld.getSettingNodes()) {
|
for (final ConfigurationNode setting : plotworld.getSettingNodes()) {
|
||||||
options.put(setting.getConstant(), setting.getValue());
|
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()) {
|
for (final Entry<String, Object> node : options.entrySet()) {
|
||||||
|
@ -21,16 +21,14 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.*;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import org.bukkit.Bukkit;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Clear extends SubCommand {
|
public class Clear extends SubCommand {
|
||||||
|
|
||||||
public Clear() {
|
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
|
// TODO console clear plot at location
|
||||||
|
|
||||||
@ -38,6 +36,32 @@ public class Clear extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
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)) {
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user