fixed economy and old plot removal task

*I need to update AdvPlots due to these changes as well.
This commit is contained in:
boy0001 2014-10-22 10:04:44 +11:00
parent ee9cee6ec8
commit 6a050f5287
4 changed files with 53 additions and 39 deletions

View File

@ -213,30 +213,32 @@ public class PlotHelper {
* End of random number gen section * End of random number gen section
*/ */
public static void removeSign(Player plr, Plot p) { public static void removeSign(World world, Plot p) {
World world = plr.getWorld();
PlotManager manager = PlotMain.getPlotManager(world); PlotManager manager = PlotMain.getPlotManager(world);
PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotWorld plotworld = PlotMain.getWorldSettings(world);
Location loc = manager.getSignLoc(plr, plotworld, p); Location loc = manager.getSignLoc(world, plotworld, p);
Block bs = loc.getBlock(); Block bs = loc.getBlock();
bs.setType(Material.AIR); bs.setType(Material.AIR);
} }
public static void setSign(Player player, Plot p) {
setSign(player.getWorld(), player.getName(), p);
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void setSign(Player plr, Plot p) { public static void setSign(World world, String name, Plot p) {
World world = plr.getWorld();
PlotManager manager = PlotMain.getPlotManager(world); PlotManager manager = PlotMain.getPlotManager(world);
PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotWorld plotworld = PlotMain.getWorldSettings(world);
Location loc = manager.getSignLoc(plr, plotworld, p); Location loc = manager.getSignLoc(world, plotworld, p);
Block bs = loc.getBlock(); Block bs = loc.getBlock();
bs.setType(Material.AIR); bs.setType(Material.AIR);
bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
String id = p.id.x + ";" + p.id.y; String id = p.id.x + ";" + p.id.y;
Sign sign = (Sign) bs.getState(); Sign sign = (Sign) bs.getState();
sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id)); sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id));
sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
sign.update(true); sign.update(true);
} }
@ -658,6 +660,27 @@ public class PlotHelper {
} }
} }
} }
public static void clear(final World world, final Plot plot) {
PlotManager manager = PlotMain.getPlotManager(world);
Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final int prime = 31;
int h = 1;
h = (prime * h) + pos1.getBlockX();
h = (prime * h) + pos1.getBlockZ();
state = h;
PlotHelper.setBiome(world, plot, Biome.FOREST);
manager.clearPlot(world, plot);
if (canSetFast) {
refreshPlotChunks(world, plot);
// SetBlockFast.update(requester);
}
}
/** /**
* Clear a plot * Clear a plot
@ -671,36 +694,26 @@ public class PlotHelper {
return; return;
} }
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
final long start = System.nanoTime(); final long start = System.nanoTime();
final World world = requester.getWorld();
final World world;
if (requester!=null) {
world = requester.getWorld();
}
else {
world = Bukkit.getWorld(plot.world);
}
/* /*
* keep * keep
*/ */
clearAllEntities(world, plot, false); clearAllEntities(world, plot, false);
PlotManager manager = PlotMain.getPlotManager(world); clear(world, plot);
removeSign(world, plot);
Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final int prime = 31;
int h = 1;
h = (prime * h) + pos1.getBlockX();
h = (prime * h) + pos1.getBlockZ();
state = h;
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
manager.clearPlot(requester, plot);
removeSign(requester, plot);
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""
+ ((System.nanoTime() - start) / 1000000.0))); + ((System.nanoTime() - start) / 1000000.0)));
if (canSetFast) {
refreshPlotChunks(world, plot);
// SetBlockFast.update(requester);
}
return; return;
} }

View File

@ -470,8 +470,11 @@ public class PlotMain extends JavaPlugin {
} }
} }
for (Plot plot: toDeletePlot) { for (Plot plot: toDeletePlot) {
getPlotManager(world).clearPlot(null, plot); World worldobj = Bukkit.getWorld(world);
PlotHelper.clear(worldobj, plot);
PlotHelper.removeSign(worldobj, plot);
DBFunc.delete(world, plot); DBFunc.delete(world, plot);
removePlot(world, plot.id, true);
} }
} }
} }
@ -708,8 +711,8 @@ public class PlotMain extends JavaPlugin {
if (economyProvider != null) { if (economyProvider != null) {
economy = economyProvider.getProvider(); economy = economyProvider.getProvider();
} }
useEconomy = (economy != null);
} }
useEconomy = (economy != null);
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L);
if (Web.ENABLED) { if (Web.ENABLED) {

View File

@ -30,9 +30,9 @@ 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(Player player, Plot plot); public abstract boolean clearPlot(World world, Plot plot);
public abstract Location getSignLoc(Player player, PlotWorld plotworld, Plot plot); public abstract Location getSignLoc(World world, PlotWorld plotworld, Plot plot);
/* /*
* Plot set functions (return false if you do not support the specific set * Plot set functions (return false if you do not support the specific set

View File

@ -220,8 +220,7 @@ public class DefaultPlotManager extends PlotManager {
* plots * plots
*/ */
@Override @Override
public boolean clearPlot(Player player, Plot plot) { public boolean clearPlot(World world, Plot plot) {
World world = player.getWorld();
DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world)); DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world));
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
@ -351,9 +350,8 @@ public class DefaultPlotManager extends PlotManager {
* Remove sign for a plot * Remove sign for a plot
*/ */
@Override @Override
public Location getSignLoc(Player player, PlotWorld plotworld, Plot plot) { public Location getSignLoc(World world, PlotWorld plotworld, Plot plot) {
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld; DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World world = player.getWorld();
return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1); return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1);
} }