mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
made changes to plot clear/signs being removed
This commit is contained in:
parent
b4f987e470
commit
c8c4f1d848
@ -9,7 +9,9 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@ -17,6 +19,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -202,17 +205,18 @@ public class PlotHelper {
|
||||
long r = ((nextLong() >>> 32) * n) >> 32;
|
||||
return (int) r;
|
||||
}
|
||||
/*
|
||||
* End of random number gen section
|
||||
*/
|
||||
|
||||
public static void removeSign(Player plr, Plot p) {
|
||||
World world = plr.getWorld();
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
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")
|
||||
public static void setSign(Player plr, Plot p) {
|
||||
@ -673,7 +677,6 @@ public class PlotHelper {
|
||||
manager.clearPlot(requester, plot);
|
||||
|
||||
removeSign(requester, plot);
|
||||
setSign(requester, plot);
|
||||
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""
|
||||
+ ((System.nanoTime() - start) / 1000000.0)));
|
||||
|
@ -56,7 +56,6 @@ public class Delete extends SubCommand {
|
||||
}
|
||||
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
||||
if (result) {
|
||||
PlotHelper.removeSign(plr, plot);
|
||||
plot.clear(plr);
|
||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||
}
|
||||
|
@ -252,23 +252,23 @@ public class DefaultPlotManager extends PlotManager {
|
||||
for (int i = startX; i < chunkX; i += 16) {
|
||||
for (int j = startZ; j < chunkZ; j += 16) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (min == null) {
|
||||
|
@ -119,66 +119,81 @@ public class WorldGuardListener implements Listener {
|
||||
@EventHandler(
|
||||
priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onUnlink(PlotUnlinkEvent event) {
|
||||
World w = event.getWorld();
|
||||
ArrayList<PlotId> plots = event.getPlots();
|
||||
Plot main = PlotMain.getPlots(w).get(plots.get(0));
|
||||
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(w);
|
||||
ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y);
|
||||
|
||||
DefaultDomain owner = region.getOwners();
|
||||
Map<Flag<?>, Object> flags = region.getFlags();
|
||||
DefaultDomain members = region.getMembers();
|
||||
|
||||
manager.removeRegion(main.id.x + "-" + main.id.y);
|
||||
for (int i = 1; i < plots.size(); i++) {
|
||||
PlotId id = plots.get(i);
|
||||
Location location1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
||||
Location location2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||
|
||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ());
|
||||
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2);
|
||||
|
||||
rg.setFlags(flags);
|
||||
|
||||
rg.setOwners(owner);
|
||||
|
||||
rg.setMembers(members);
|
||||
|
||||
manager.addRegion(rg);
|
||||
}
|
||||
try {
|
||||
World w = event.getWorld();
|
||||
ArrayList<PlotId> plots = event.getPlots();
|
||||
Plot main = PlotMain.getPlots(w).get(plots.get(0));
|
||||
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(w);
|
||||
ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y);
|
||||
|
||||
DefaultDomain owner = region.getOwners();
|
||||
Map<Flag<?>, Object> flags = region.getFlags();
|
||||
DefaultDomain members = region.getMembers();
|
||||
|
||||
manager.removeRegion(main.id.x + "-" + main.id.y);
|
||||
for (int i = 1; i < plots.size(); i++) {
|
||||
PlotId id = plots.get(i);
|
||||
Location location1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
||||
Location location2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||
|
||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ());
|
||||
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2);
|
||||
|
||||
rg.setFlags(flags);
|
||||
|
||||
rg.setOwners(owner);
|
||||
|
||||
rg.setMembers(members);
|
||||
|
||||
manager.addRegion(rg);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotClaim(PlayerClaimPlotEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Plot plot = event.getPlot();
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld());
|
||||
|
||||
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
||||
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
|
||||
|
||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||
BlockVector vector2 =
|
||||
new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
||||
|
||||
DefaultDomain owner = new DefaultDomain();
|
||||
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));
|
||||
|
||||
region.setOwners(owner);
|
||||
|
||||
manager.addRegion(region);
|
||||
try {
|
||||
Player player = event.getPlayer();
|
||||
Plot plot = event.getPlot();
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld());
|
||||
|
||||
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
||||
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
|
||||
|
||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||
BlockVector vector2 =
|
||||
new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
||||
|
||||
DefaultDomain owner = new DefaultDomain();
|
||||
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));
|
||||
|
||||
region.setOwners(owner);
|
||||
|
||||
manager.addRegion(region);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotDelete(PlotDeleteEvent event) {
|
||||
PlotId plot = event.getPlotId();
|
||||
World world = Bukkit.getWorld(event.getWorld());
|
||||
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
manager.removeRegion(plot.x + "-" + plot.y);
|
||||
try {
|
||||
PlotId plot = event.getPlotId();
|
||||
World world = Bukkit.getWorld(event.getWorld());
|
||||
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
manager.removeRegion(plot.x + "-" + plot.y);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user