mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
fixed economy and old plot removal task
*I need to update AdvPlots due to these changes as well.
This commit is contained in:
parent
ee9cee6ec8
commit
6a050f5287
@ -213,30 +213,32 @@ public class PlotHelper {
|
||||
* End of random number gen section
|
||||
*/
|
||||
|
||||
public static void removeSign(Player plr, Plot p) {
|
||||
World world = plr.getWorld();
|
||||
public static void removeSign(World world, Plot p) {
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
Location loc = manager.getSignLoc(plr, plotworld, p);
|
||||
Location loc = manager.getSignLoc(world, plotworld, p);
|
||||
Block bs = loc.getBlock();
|
||||
bs.setType(Material.AIR);
|
||||
}
|
||||
|
||||
public static void setSign(Player player, Plot p) {
|
||||
setSign(player.getWorld(), player.getName(), p);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setSign(Player plr, Plot p) {
|
||||
World world = plr.getWorld();
|
||||
public static void setSign(World world, String name, Plot p) {
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
Location loc = manager.getSignLoc(plr, plotworld, p);
|
||||
Location loc = manager.getSignLoc(world, plotworld, p);
|
||||
Block bs = loc.getBlock();
|
||||
bs.setType(Material.AIR);
|
||||
bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
||||
String id = p.id.x + ";" + p.id.y;
|
||||
Sign sign = (Sign) bs.getState();
|
||||
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(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
|
||||
sign.setLine(3, C.OWNER_SIGN_LINE_4.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%", name));
|
||||
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name));
|
||||
sign.update(true);
|
||||
}
|
||||
|
||||
@ -658,7 +660,28 @@ 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
|
||||
*
|
||||
@ -670,37 +693,27 @@ public class PlotHelper {
|
||||
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||
|
||||
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
|
||||
*/
|
||||
clearAllEntities(world, plot, false);
|
||||
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(requester.getWorld(), plot, Biome.FOREST);
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||
|
||||
manager.clearPlot(requester, plot);
|
||||
|
||||
removeSign(requester, plot);
|
||||
|
||||
clear(world, plot);
|
||||
removeSign(world, plot);
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""
|
||||
+ ((System.nanoTime() - start) / 1000000.0)));
|
||||
if (canSetFast) {
|
||||
refreshPlotChunks(world, plot);
|
||||
// SetBlockFast.update(requester);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -470,8 +470,11 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
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);
|
||||
removePlot(world, plot.id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -708,8 +711,8 @@ public class PlotMain extends JavaPlugin {
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
useEconomy = (economy != null);
|
||||
}
|
||||
useEconomy = (economy != null);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L);
|
||||
|
||||
if (Web.ENABLED) {
|
||||
|
@ -30,9 +30,9 @@ public abstract class PlotManager {
|
||||
* 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
|
||||
|
@ -220,8 +220,7 @@ public class DefaultPlotManager extends PlotManager {
|
||||
* plots
|
||||
*/
|
||||
@Override
|
||||
public boolean clearPlot(Player player, Plot plot) {
|
||||
World world = player.getWorld();
|
||||
public boolean clearPlot(World world, Plot plot) {
|
||||
DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world));
|
||||
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public Location getSignLoc(Player player, PlotWorld plotworld, Plot plot) {
|
||||
public Location getSignLoc(World world, PlotWorld plotworld, Plot plot) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user