Fixes plot claim block removing on clear.

This commit is contained in:
boy0001 2014-12-16 15:44:25 +11:00
parent d2ef1c350a
commit 42c02b37bf
10 changed files with 31 additions and 68 deletions

View File

@ -579,7 +579,7 @@ public class PlotMain extends JavaPlugin {
} }
for (final Plot plot : toDeletePlot) { for (final Plot plot : toDeletePlot) {
final World worldobj = Bukkit.getWorld(world); final World worldobj = Bukkit.getWorld(world);
PlotHelper.clear(worldobj, plot); PlotHelper.clear(worldobj, plot, true);
PlotHelper.removeSign(worldobj, plot); PlotHelper.removeSign(worldobj, plot);
DBFunc.delete(world, plot); DBFunc.delete(world, plot);
removePlot(world, plot.id, true); removePlot(world, plot.id, true);

View File

@ -57,7 +57,7 @@ public class Clear extends SubCommand {
if (plot == null) { if (plot == null) {
PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world); PlotMain.sendConsoleSenderMessage("Could not find plot " + args[0] + " in world " + world);
} else { } else {
plot.clear(null); plot.clear(null, false);
PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared."); PlotMain.sendConsoleSenderMessage("Plot " + plot.getId().toString() + " cleared.");
} }
} }
@ -78,6 +78,11 @@ public class Clear extends SubCommand {
} }
assert plot != null; assert plot != null;
plot.clear(plr); plot.clear(plr);
// sign
// wall
return true; return true;
} }
} }

View File

@ -60,7 +60,7 @@ public class Delete extends SubCommand {
} }
final boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); final boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
if (result) { if (result) {
plot.clear(plr); plot.clear(plr, true);
DBFunc.delete(plr.getWorld().getName(), plot); DBFunc.delete(plr.getWorld().getName(), plot);
if ((Math.abs(plot.id.x) <= Math.abs(Auto.lastPlot.x)) && (Math.abs(plot.id.y) <= Math.abs(Auto.lastPlot.y))) { if ((Math.abs(plot.id.x) <= Math.abs(Auto.lastPlot.x)) && (Math.abs(plot.id.y) <= Math.abs(Auto.lastPlot.y))) {
Auto.lastPlot = plot.id; Auto.lastPlot = plot.id;

View File

@ -81,7 +81,6 @@ public class SetOwner extends SubCommand {
PlotMain.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current); PlotMain.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current);
} }
} }
PlotHelper.setSign(world, args[0], plot); PlotHelper.setSign(world, args[0], plot);
PlayerFunctions.sendMessage(plr, C.SET_OWNER); PlayerFunctions.sendMessage(plr, C.SET_OWNER);

View File

@ -32,6 +32,8 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast; import com.intellectualcrafters.plot.util.SetBlockFast;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -115,7 +117,7 @@ public class Unlink extends SubCommand {
if (ly) { if (ly) {
manager.createRoadSouth(plotworld, p); manager.createRoadSouth(plotworld, p);
} }
PlotHelper.setSign(plr.getWorld(), UUIDHandler.getName(plot.owner), plot);
} }
} }
try { try {

View File

@ -224,56 +224,6 @@ public class DefaultPlotManager extends PlotManager {
return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z); return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z);
} }
public void clearPlotAsync(final World world, final Plot plot) {
PlotHelper.runners.put(plot, 1);
final DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world));
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
final PlotBlock[] filling = dpw.MAIN_BLOCK;
// PlotBlock wall = dpw.WALL_BLOCK;
final PlotBlock wall = dpw.WALL_BLOCK;
final PlotBlock wall_filling = dpw.WALL_FILLING;
Block block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, 1, pos1.getBlockZ()));
if ((block.getTypeId() != wall_filling.id) || (block.getData() != wall_filling.data)) {
setWallFilling(world, dpw, plot.id, wall_filling);
}
block = world.getBlockAt(new Location(world, pos1.getBlockX() - 1, dpw.WALL_HEIGHT + 1, pos1.getBlockZ()));
if ((block.getTypeId() != wall.id) || (block.getData() != wall.data)) {
setWall(world, dpw, plot.id, wall);
}
int count = 10000;
int s_x = pos1.getBlockX();
int s_y = 0;
int s_z = pos1.getBlockZ();
int e_x = pos2.getBlockX();
int e_y = world.getMaxHeight();
int e_z = pos2.getBlockZ();
Plugin plugin = (Plugin) PlotMain.getMain();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
}, 1L);
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
}
/** /**
* Clearing the plot needs to only consider removing the blocks - This * Clearing the plot needs to only consider removing the blocks - This
* implementation has used the SetCuboid function, as it is fast, and uses * implementation has used the SetCuboid function, as it is fast, and uses
@ -283,7 +233,7 @@ public class DefaultPlotManager extends PlotManager {
* plots * plots
*/ */
@Override @Override
public boolean clearPlot(final World world, final Plot plot) { public boolean clearPlot(final World world, final Plot plot, boolean isDelete) {
PlotHelper.runners.put(plot, 1); PlotHelper.runners.put(plot, 1);
final Plugin plugin = (Plugin) PlotMain.getMain(); final Plugin plugin = (Plugin) PlotMain.getMain();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() {
@ -299,7 +249,14 @@ public class DefaultPlotManager extends PlotManager {
final PlotBlock[] filling = dpw.MAIN_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK;
// PlotBlock wall = dpw.WALL_BLOCK; // PlotBlock wall = dpw.WALL_BLOCK;
final PlotBlock wall = dpw.WALL_BLOCK; final PlotBlock wall;
if (isDelete) {
wall = dpw.WALL_BLOCK;
}
else {
wall = dpw.CLAIMED_WALL_BLOCK;
}
final PlotBlock wall_filling = dpw.WALL_FILLING; final PlotBlock wall_filling = dpw.WALL_FILLING;

View File

@ -550,7 +550,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final Set<Plot> plots = PlotMain.getPlots(event.getPlayer()); final Set<Plot> plots = PlotMain.getPlots(event.getPlayer());
for (final Plot plot : plots) { for (final Plot plot : plots) {
final PlotManager manager = PlotMain.getPlotManager(plot.getWorld()); final PlotManager manager = PlotMain.getPlotManager(plot.getWorld());
manager.clearPlot(null, plot); manager.clearPlot(null, plot, true);
DBFunc.delete(plot.getWorld().getName(), plot); DBFunc.delete(plot.getWorld().getName(), plot);
PlotMain.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); PlotMain.sendConsoleSenderMessage(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
} }

View File

@ -342,8 +342,8 @@ public class Plot implements Cloneable {
* *
* @param plr initiator * @param plr initiator
*/ */
public void clear(final Player plr) { public void clear(final Player plr, boolean isDelete) {
PlotHelper.clear(plr, this); PlotHelper.clear(plr, this, isDelete);
} }
@Override @Override

View File

@ -51,7 +51,7 @@ public abstract class PlotManager {
* Plot clearing (return false if you do not support some method) * Plot clearing (return false if you do not support some method)
*/ */
public abstract boolean clearPlot(final World world, final Plot plot); public abstract boolean clearPlot(final World world, final Plot plot, boolean isDelete);
public abstract Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot); public abstract Location getSignLoc(final World world, final PlotWorld plotworld, final Plot plot);

View File

@ -683,7 +683,7 @@ public class PlotHelper {
} }
} }
public static void clear(final World world, final Plot plot) { public static void clear(final World world, final Plot plot, final boolean isDelete) {
if (runners.containsKey(plot)) { if (runners.containsKey(plot)) {
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER); PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
return; return;
@ -698,7 +698,7 @@ public class PlotHelper {
h = (prime * h) + pos1.getBlockZ(); h = (prime * h) + pos1.getBlockZ();
state = h; state = h;
manager.clearPlot(world, plot); manager.clearPlot(world, plot, isDelete);
if (canSetFast) { if (canSetFast) {
final Plugin plugin = (Plugin) PlotMain.getMain(); final Plugin plugin = (Plugin) PlotMain.getMain();
@ -715,10 +715,10 @@ public class PlotHelper {
* @param requester * @param requester
* @param plot * @param plot
*/ */
public static void clear(final Player requester, final Plot plot) { public static void clear(final Player requester, final Plot plot, final boolean isDelete) {
if (requester == null) { if (requester == null) {
clearAllEntities(plot.getWorld(), plot, false); clearAllEntities(plot.getWorld(), plot, false);
clear(plot.getWorld(), plot); clear(plot.getWorld(), plot, isDelete);
removeSign(plot.getWorld(), plot); removeSign(plot.getWorld(), plot);
return; return;
} }
@ -735,11 +735,11 @@ public class PlotHelper {
world = requester.getWorld(); world = requester.getWorld();
clearAllEntities(world, plot, false); clearAllEntities(world, plot, false);
clear(world, plot); clear(world, plot, isDelete);
removeSign(world, plot); removeSign(world, plot);
final Plugin plugin = (Plugin) PlotMain.getMain(); final Plugin plugin = (Plugin) PlotMain.getMain();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() {
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start) / 1000.0))); PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
} }, 90L); } }, 90L);
} }