made changes to plot clear/signs being removed

This commit is contained in:
boy0001 2014-10-19 18:29:39 +11:00
parent b4f987e470
commit c8c4f1d848
4 changed files with 81 additions and 64 deletions

View File

@ -9,7 +9,9 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -17,6 +19,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -202,17 +205,18 @@ public class PlotHelper {
long r = ((nextLong() >>> 32) * n) >> 32; long r = ((nextLong() >>> 32) * n) >> 32;
return (int) r; return (int) r;
} }
/*
* End of random number gen section
*/
public static void removeSign(Player plr, Plot p) { public static void removeSign(Player plr, Plot p) {
World world = plr.getWorld(); 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(plr, plotworld, p);
loc.getBlock().setType(Material.AIR); Block bs = loc.getBlock();
bs.setType(Material.AIR);
} }
/*
* End of random number gen section
*/
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void setSign(Player plr, Plot p) { public static void setSign(Player plr, Plot p) {
@ -673,7 +677,6 @@ public class PlotHelper {
manager.clearPlot(requester, plot); manager.clearPlot(requester, plot);
removeSign(requester, plot); removeSign(requester, plot);
setSign(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)));

View File

@ -56,7 +56,6 @@ public class Delete extends SubCommand {
} }
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
if (result) { if (result) {
PlotHelper.removeSign(plr, plot);
plot.clear(plr); plot.clear(plr);
DBFunc.delete(plr.getWorld().getName(), plot); DBFunc.delete(plr.getWorld().getName(), plot);
} }

View File

@ -252,23 +252,23 @@ public class DefaultPlotManager extends PlotManager {
for (int i = startX; i < chunkX; i += 16) { for (int i = startX; i < chunkX; i += 16) {
for (int j = startZ; j < chunkZ; j += 16) { for (int j = startZ; j < chunkZ; j += 16) {
Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j)); Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j));
if ((plot1 != null) && (plot1.getId() != plot.getId()) && plot1.hasOwner()) { if ((plot1 != null) && (plot1.getId() != plot.getId())) {
break; break;
} }
Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j)); Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
if ((plot2 != null) && (plot2.getId() != plot.getId()) && plot2.hasOwner()) { if ((plot2 != null) && (plot2.getId() != plot.getId())) {
break; break;
} }
Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
if ((plot3 != null) && (plot3.getId() != plot.getId()) && plot3.hasOwner()) { if ((plot3 != null) && (plot3.getId() != plot.getId())) {
break; break;
} }
Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15)); Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
if ((plot4 != null) && (plot4.getId() != plot.getId()) && plot4.hasOwner()) { if ((plot4 != null) && (plot4.getId() != plot.getId())) {
break; break;
} }
Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
if ((plot5 != null) && (plot5.getId() != plot.getId()) && plot5.hasOwner()) { if ((plot5 != null) && (plot5.getId() != plot.getId())) {
break; break;
} }
if (min == null) { if (min == null) {

View File

@ -119,6 +119,7 @@ public class WorldGuardListener implements Listener {
@EventHandler( @EventHandler(
priority = EventPriority.MONITOR, ignoreCancelled = true) priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUnlink(PlotUnlinkEvent event) { public void onUnlink(PlotUnlinkEvent event) {
try {
World w = event.getWorld(); World w = event.getWorld();
ArrayList<PlotId> plots = event.getPlots(); ArrayList<PlotId> plots = event.getPlots();
Plot main = PlotMain.getPlots(w).get(plots.get(0)); Plot main = PlotMain.getPlots(w).get(plots.get(0));
@ -149,9 +150,14 @@ public class WorldGuardListener implements Listener {
manager.addRegion(rg); manager.addRegion(rg);
} }
} }
catch (Exception e) {
}
}
@EventHandler @EventHandler
public void onPlotClaim(PlayerClaimPlotEvent event) { public void onPlotClaim(PlayerClaimPlotEvent event) {
try {
Player player = event.getPlayer(); Player player = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld()); RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld());
@ -172,13 +178,22 @@ public class WorldGuardListener implements Listener {
manager.addRegion(region); manager.addRegion(region);
} }
catch (Exception e) {
}
}
@EventHandler @EventHandler
public void onPlotDelete(PlotDeleteEvent event) { public void onPlotDelete(PlotDeleteEvent event) {
try {
PlotId plot = event.getPlotId(); PlotId plot = event.getPlotId();
World world = Bukkit.getWorld(event.getWorld()); World world = Bukkit.getWorld(event.getWorld());
RegionManager manager = PlotMain.worldGuard.getRegionManager(world); RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
manager.removeRegion(plot.x + "-" + plot.y); manager.removeRegion(plot.x + "-" + plot.y);
} }
catch (Exception e) {
}
}
} }