Minor changes, formatting, comments.

One notable thing added was the inclusion of more of the new mobs in one of the events.
This commit is contained in:
matt 2018-12-27 00:46:32 -05:00
parent 75bcd1adec
commit a529518b91
6 changed files with 179 additions and 147 deletions

View File

@ -32,7 +32,8 @@ import java.util.HashSet;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass; import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused") public class ChunkListener implements Listener { @SuppressWarnings("unused")
public class ChunkListener implements Listener {
private RefMethod methodGetHandleChunk; private RefMethod methodGetHandleChunk;
private RefField mustSave; private RefField mustSave;
@ -48,7 +49,7 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable ignored) { } catch (Throwable ignored) {
PlotSquared.debug(PlotSquared.get().IMP.getPluginName() PlotSquared.debug(PlotSquared.get().IMP.getPluginName()
+ "/Server not compatible for chunk processor trim/gc"); + "/Server not compatible for chunk processor trim/gc");
Settings.Chunk_Processor.AUTO_TRIM = false; Settings.Chunk_Processor.AUTO_TRIM = false;
} }
} }
@ -69,11 +70,11 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world); Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
Object chunkMap = w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w); Object chunkMap = w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
Method methodIsChunkInUse = Method methodIsChunkInUse =
chunkMap.getClass().getDeclaredMethod("isChunkInUse", int.class, int.class); chunkMap.getClass().getDeclaredMethod("isChunkInUse", int.class, int.class);
Chunk[] chunks = world.getLoadedChunks(); Chunk[] chunks = world.getLoadedChunks();
for (Chunk chunk : chunks) { for (Chunk chunk : chunks) {
if ((boolean) methodIsChunkInUse if ((boolean) methodIsChunkInUse
.invoke(chunkMap, chunk.getX(), chunk.getZ())) { .invoke(chunkMap, chunk.getX(), chunk.getZ())) {
continue; continue;
} }
int x = chunk.getX(); int x = chunk.getX();
@ -143,7 +144,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
return plot != null && plot.hasOwner(); return plot != null && plot.hasOwner();
} }
@EventHandler public void onChunkUnload(ChunkUnloadEvent event) { @EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
if (ignoreUnload) { if (ignoreUnload) {
return; return;
} }
@ -161,11 +163,13 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
} }
} }
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { @EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
processChunk(event.getChunk(), false); processChunk(event.getChunk(), false);
} }
@EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { @EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity(); Item entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk(); Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) { if (chunk == this.lastChunk) {
@ -241,7 +245,7 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex); TaskManager.tasks.remove(currentIndex);
PlotSquared PlotSquared
.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!"); .debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true); chunk.unload(true, true);
return; return;
} }
@ -265,14 +269,14 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
} }
} }
PlotSquared.debug( PlotSquared.debug(
C.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX() << 4) C.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX() << 4)
+ "," + (chunk.getX() << 4)); + "," + (chunk.getX() << 4));
} }
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) { if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
if (unload) { if (unload) {
PlotSquared.debug( PlotSquared.debug(
C.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + "," + ( C.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (
chunk.getX() << 4)); chunk.getX() << 4));
cleanChunk(chunk); cleanChunk(chunk);
return true; return true;
} }

View File

@ -58,7 +58,8 @@ import java.util.regex.Pattern;
/** /**
* Player Events involving plots. * Player Events involving plots.
*/ */
@SuppressWarnings("unused") public class PlayerEvents extends PlotListener implements Listener { @SuppressWarnings("unused")
public class PlayerEvents extends PlotListener implements Listener {
private boolean pistonBlocks = true; private boolean pistonBlocks = true;
private float lastRadius; private float lastRadius;
@ -87,7 +88,7 @@ import java.util.regex.Pattern;
Location loc = player.getLocation(); Location loc = player.getLocation();
if (loc.getWorld().equals(world)) { if (loc.getWorld().equals(world)) {
if (16 * Math.abs(loc.getX() - x) / 16 > distance if (16 * Math.abs(loc.getX() - x) / 16 > distance
|| 16 * Math.abs(loc.getZ() - z) / 16 > distance) { || 16 * Math.abs(loc.getZ() - z) / 16 > distance) {
continue; continue;
} }
((BukkitPlayer) player).player.sendBlockChange(bloc, data); ((BukkitPlayer) player).player.sendBlockChange(bloc, data);
@ -98,7 +99,7 @@ import java.util.regex.Pattern;
public static boolean checkEntity(Entity entity, Plot plot) { public static boolean checkEntity(Entity entity, Plot plot) {
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot
.getArea().DEFAULT_FLAGS.isEmpty()) { .getArea().DEFAULT_FLAGS.isEmpty()) {
return false; return false;
} }
switch (entity.getType()) { switch (entity.getType()) {
@ -172,9 +173,16 @@ import java.util.regex.Pattern;
case MULE: case MULE:
case ZOMBIE_HORSE: case ZOMBIE_HORSE:
case SKELETON_HORSE: case SKELETON_HORSE:
case PARROT:
case TURTLE:
case COD:
case SALMON:
case DOLPHIN:
case PUFFERFISH:
case TROPICAL_FISH:
// animal // animal
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
case BLAZE: case BLAZE:
case CAVE_SPIDER: case CAVE_SPIDER:
case CREEPER: case CREEPER:
@ -202,17 +210,19 @@ import java.util.regex.Pattern;
case EVOKER: case EVOKER:
case VEX: case VEX:
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
case DROWNED:
case ILLUSIONER:
// monster // monster
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
default: default:
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
if (entity instanceof Animals) { if (entity instanceof Animals || entity instanceof WaterMob) {
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
} else if (entity instanceof Monster) { } else if (entity instanceof Monster) {
return EntityUtil return EntityUtil
.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
} else { } else {
return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP); return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
} }
@ -227,7 +237,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) { @EventHandler
public void onRedstoneEvent(BlockRedstoneEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
switch (block.getType()) { switch (block.getType()) {
case OBSERVER: case OBSERVER:
@ -405,7 +416,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event) { @EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) { if (!(entity instanceof ThrownPotion)) {
return; return;
@ -426,7 +438,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler public boolean onProjectileHit(ProjectileHitEvent event) { @EventHandler
public boolean onProjectileHit(ProjectileHitEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
Location loc = BukkitUtil.getLocation(entity); Location loc = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().hasPlotArea(loc.getWorld())) { if (!PlotSquared.get().hasPlotArea(loc.getWorld())) {
@ -448,7 +461,7 @@ import java.util.regex.Pattern;
return true; return true;
} }
if (plot.isAdded(pp.getUUID()) || Permissions if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) { .hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return true; return true;
} }
entity.remove(); entity.remove();
@ -460,7 +473,7 @@ import java.util.regex.Pattern;
return false; return false;
} }
Location sLoc = Location sLoc =
BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation()); BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
if (!area.contains(sLoc.getX(), sLoc.getZ())) { if (!area.contains(sLoc.getX(), sLoc.getZ())) {
entity.remove(); entity.remove();
return false; return false;
@ -496,7 +509,7 @@ import java.util.regex.Pattern;
case "worldedit:up": case "worldedit:up":
case "worldedit:/up": case "worldedit:/up":
if (plot == null || (!plot.isAdded(pp.getUUID()) && !Permissions if (plot == null || (!plot.isAdded(pp.getUUID()) && !Permissions
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true))) { .hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -507,7 +520,7 @@ import java.util.regex.Pattern;
} }
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS); Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
if (flag.isPresent() && !Permissions if (flag.isPresent() && !Permissions
.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) { .hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
List<String> blocked_cmds = flag.get(); List<String> blocked_cmds = flag.get();
String c = parts[0]; String c = parts[0];
if (parts[0].contains(":")) { if (parts[0].contains(":")) {
@ -607,7 +620,7 @@ import java.util.regex.Pattern;
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld() if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld()
.equals(event.getTo().getWorld())) { .equals(event.getTo().getWorld())) {
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION); BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION);
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT); BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT);
org.bukkit.Location to = event.getTo(); org.bukkit.Location to = event.getTo();
@ -636,7 +649,7 @@ import java.util.regex.Pattern;
int toX, toZ; int toX, toZ;
if ((toX = MathMan.roundInt(to.getX())) != MathMan.roundInt(from.getX()) if ((toX = MathMan.roundInt(to.getX())) != MathMan.roundInt(from.getX())
| (toZ = MathMan.roundInt(to.getZ())) != MathMan.roundInt(from.getZ())) { | (toZ = MathMan.roundInt(to.getZ())) != MathMan.roundInt(from.getZ())) {
Vehicle vehicle = event.getVehicle(); Vehicle vehicle = event.getVehicle();
// Check allowed // Check allowed
@ -660,7 +673,7 @@ import java.util.regex.Pattern;
if (moveTmp.isCancelled()) { if (moveTmp.isCancelled()) {
dest = from; dest = from;
} else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX } else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX
|| MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) { || MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
dest = to; dest = to;
} else { } else {
dest = null; dest = null;
@ -700,7 +713,7 @@ import java.util.regex.Pattern;
} }
} else if (toPlot != null) { } else if (toPlot != null) {
vehicle.setMetadata("plot", vehicle.setMetadata("plot",
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, toPlot)); new FixedMetadataValue((Plugin) PlotSquared.get().IMP, toPlot));
} }
} }
} }
@ -835,7 +848,8 @@ import java.util.regex.Pattern;
} }
} }
@EventHandler(priority = EventPriority.LOW) public void onChat(AsyncPlayerChatEvent event) { @EventHandler(priority = EventPriority.LOW)
public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -869,7 +883,7 @@ import java.util.regex.Pattern;
} }
} }
String partial = ChatColor.translateAlternateColorCodes('&', String partial = ChatColor.translateAlternateColorCodes('&',
format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender)); format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
if (plotPlayer.hasPermission("plots.chat.color")) { if (plotPlayer.hasPermission("plots.chat.color")) {
message = C.color(message); message = C.color(message);
} }
@ -879,7 +893,7 @@ import java.util.regex.Pattern;
} }
if (!spies.isEmpty()) { if (!spies.isEmpty()) {
String spyMessage = C.PLOT_CHAT_SPY_FORMAT.s().replace("%plot_id%", id.x + ";" + id.y) String spyMessage = C.PLOT_CHAT_SPY_FORMAT.s().replace("%plot_id%", id.x + ";" + id.y)
.replace("%sender%", sender).replace("%msg%", message); .replace("%sender%", sender).replace("%msg%", message);
for (Player player : spies) { for (Player player : spies) {
player.sendMessage(spyMessage); player.sendMessage(spyMessage);
} }
@ -887,7 +901,8 @@ import java.util.regex.Pattern;
PlotSquared.debug(full); PlotSquared.debug(full);
} }
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) { @EventHandler(priority = EventPriority.LOWEST)
public void blockDestroy(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location location = BukkitUtil.getLocation(event.getBlock().getLocation()); Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
@ -899,26 +914,26 @@ import java.util.regex.Pattern;
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (event.getBlock().getY() == 0) { if (event.getBlock().getY() == 0) {
if (!Permissions if (!Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL); C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if ( } else if (
(location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) (location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
&& !Permissions && !Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) { .hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(plotPlayer, MainUtil.sendMessage(plotPlayer,
C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_UNOWNED); C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -926,19 +941,19 @@ import java.util.regex.Pattern;
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name()))) { .contains(PlotBlock.get(block.getType().name()))) {
return; return;
} }
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_OTHER); C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_BUILD_OTHER); C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -951,7 +966,7 @@ import java.util.regex.Pattern;
} }
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) { if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getInventory().getItemInMainHand().getType() == Material if (player.getInventory().getItemInMainHand().getType() == Material
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) { .getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
return; return;
} }
} }
@ -988,13 +1003,13 @@ import java.util.regex.Pattern;
} }
if (this.lastRadius != 0) { if (this.lastRadius != 0) {
List<Entity> nearby = event.getEntity() List<Entity> nearby = event.getEntity()
.getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius); .getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
for (Entity near : nearby) { for (Entity near : nearby) {
if (near instanceof TNTPrimed || near.getType() if (near instanceof TNTPrimed || near.getType()
.equals(EntityType.MINECART_TNT)) { .equals(EntityType.MINECART_TNT)) {
if (!near.hasMetadata("plot")) { if (!near.hasMetadata("plot")) {
near.setMetadata("plot", near.setMetadata("plot",
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot)); new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
} }
} }
} }
@ -1005,7 +1020,7 @@ import java.util.regex.Pattern;
Block block = iterator.next(); Block block = iterator.next();
location = BukkitUtil.getLocation(block.getLocation()); location = BukkitUtil.getLocation(block.getLocation());
if (!area.contains(location.getX(), location.getZ()) || !origin if (!area.contains(location.getX(), location.getZ()) || !origin
.equals(area.getOwnedPlot(location))) { .equals(area.getOwnedPlot(location))) {
iterator.remove(); iterator.remove();
} }
} }
@ -1209,8 +1224,8 @@ import java.util.regex.Pattern;
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK); Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock(); Block block = event.getBlock();
if (destroy.isPresent() && destroy.get() if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name())) || Permissions .contains(PlotBlock.get(block.getType().name())) || Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
event.setCancelled(true); event.setCancelled(true);
@ -1273,7 +1288,7 @@ import java.util.regex.Pattern;
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
.equals(plot, area.getOwnedPlot(fLocation))) { .equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -1285,7 +1300,7 @@ import java.util.regex.Pattern;
} }
} }
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
.equals(null, area.getOwnedPlot(fLocation))) { .equals(null, area.getOwnedPlot(fLocation))) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -1327,12 +1342,12 @@ import java.util.regex.Pattern;
for (Block b : blocks) { for (Block b : blocks) {
Location bloc = BukkitUtil.getLocation(b.getLocation()); Location bloc = BukkitUtil.getLocation(b.getLocation());
if (!area.contains(bloc.getX(), bloc.getZ()) || !area if (!area.contains(bloc.getX(), bloc.getZ()) || !area
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) { .contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot( if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) { bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -1364,7 +1379,7 @@ import java.util.regex.Pattern;
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) { if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
BlockFace dir = event.getDirection(); BlockFace dir = event.getDirection();
location = BukkitUtil.getLocation(block.getLocation() location = BukkitUtil.getLocation(block.getLocation()
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); .add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (location.getPlotArea() != null) { if (location.getPlotArea() != null) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -1385,7 +1400,7 @@ import java.util.regex.Pattern;
try { try {
for (Block pulled : event.getBlocks()) { for (Block pulled : event.getBlocks()) {
Location from = BukkitUtil.getLocation( Location from = BukkitUtil.getLocation(
pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ())); pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ()));
Location to = BukkitUtil.getLocation(pulled.getLocation()); Location to = BukkitUtil.getLocation(pulled.getLocation());
if (!area.contains(to.getX(), to.getZ())) { if (!area.contains(to.getX(), to.getZ())) {
event.setCancelled(true); event.setCancelled(true);
@ -1404,7 +1419,7 @@ import java.util.regex.Pattern;
} }
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) { if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
location = BukkitUtil.getLocation( location = BukkitUtil.getLocation(
block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (!area.contains(location)) { if (!area.contains(location)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -1425,10 +1440,10 @@ import java.util.regex.Pattern;
if (event.getBlock().getType() == Material.DROPPER) if (event.getBlock().getType() == Material.DROPPER)
return; return;
BlockFace targetFace = BlockFace targetFace =
((org.bukkit.material.Dispenser) event.getBlock().getState().getData()) ((org.bukkit.material.Dispenser) event.getBlock().getState().getData())
.getFacing(); .getFacing();
Location location = Location location =
BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation()); BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
if (location.isPlotRoad()) { if (location.isPlotRoad()) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -1502,7 +1517,7 @@ import java.util.regex.Pattern;
}*/ }*/
HumanEntity entity = event.getWhoClicked(); HumanEntity entity = event.getWhoClicked();
if (!(entity instanceof Player) || !PlotSquared.get() if (!(entity instanceof Player) || !PlotSquared.get()
.hasPlotArea(entity.getWorld().getName())) { .hasPlotArea(entity.getWorld().getName())) {
return; return;
} }
@ -1601,14 +1616,14 @@ import java.util.regex.Pattern;
} }
if (cancelled) { if (cancelled) {
if ((current.getType() == newItem.getType()) && (current.getDurability() == newItem if ((current.getType() == newItem.getType()) && (current.getDurability() == newItem
.getDurability())) { .getDurability())) {
event.setCursor( event.setCursor(
new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability())); new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
event.setCursor( event.setCursor(
new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability())); new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
} }
} }
@ -1688,7 +1703,7 @@ import java.util.regex.Pattern;
event.setCancelled(true); event.setCancelled(true);
} }
event.blockList().removeIf( event.blockList().removeIf(
b -> !plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))); b -> !plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation()))));
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@ -1716,7 +1731,7 @@ import java.util.regex.Pattern;
location = BukkitUtil.getLocation(block.getLocation()); location = BukkitUtil.getLocation(block.getLocation());
Material blockType = block.getType(); Material blockType = block.getType();
int blockId = ((LegacyPlotBlock) PlotSquared.get().IMP.getLegacyMappings() int blockId = ((LegacyPlotBlock) PlotSquared.get().IMP.getLegacyMappings()
.fromStringToLegacy(blockType.name())).id; .fromStringToLegacy(blockType.name())).id;
switch (blockType) { switch (blockType) {
case ANVIL: case ANVIL:
case ACACIA_DOOR: case ACACIA_DOOR:
@ -1849,7 +1864,7 @@ import java.util.regex.Pattern;
lb = new BukkitLazyBlock(PlotBlock.get(block.getType().toString())); lb = new BukkitLazyBlock(PlotBlock.get(block.getType().toString()));
ItemStack hand = player.getInventory().getItemInMainHand(); ItemStack hand = player.getInventory().getItemInMainHand();
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK
|| !player.isSneaking())) { || !player.isSneaking())) {
break; break;
} }
Material type = (hand == null) ? null : hand.getType(); Material type = (hand == null) ? null : hand.getType();
@ -1859,7 +1874,7 @@ import java.util.regex.Pattern;
} }
if (type == null || type.isBlock()) { if (type == null || type.isBlock()) {
location = BukkitUtil location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation()); .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_BLOCK; eventType = PlayerBlockEventType.PLACE_BLOCK;
break; break;
} }
@ -1875,7 +1890,7 @@ import java.util.regex.Pattern;
break; break;
case ARMOR_STAND: case ARMOR_STAND:
location = BukkitUtil location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation()); .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_MISC; eventType = PlayerBlockEventType.PLACE_MISC;
break; break;
case WRITTEN_BOOK: case WRITTEN_BOOK:
@ -1933,7 +1948,7 @@ import java.util.regex.Pattern;
case PAINTING: case PAINTING:
case ITEM_FRAME: case ITEM_FRAME:
location = BukkitUtil location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation()); .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_HANGING; eventType = PlayerBlockEventType.PLACE_HANGING;
break; break;
default: default:
@ -1954,7 +1969,7 @@ import java.util.regex.Pattern;
} }
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) { if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getInventory().getItemInMainHand().getType() == Material if (player.getInventory().getItemInMainHand().getType() == Material
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) { .getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
return; return;
} }
} }
@ -1972,10 +1987,13 @@ import java.util.regex.Pattern;
return; return;
} }
CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
//TODO needs an overhaul for the increased number of spawn reasons added to this event.
//I can't believe they waited so damn long to expand this API set.
switch (reason) { switch (reason) {
case SPAWNER_EGG: case SPAWNER_EGG:
case DISPENSE_EGG: case DISPENSE_EGG:
case OCELOT_BABY: case OCELOT_BABY:
case EGG:
if (!area.SPAWN_EGGS) { if (!area.SPAWN_EGGS) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -2049,11 +2067,12 @@ import java.util.regex.Pattern;
} }
} else if (event.getTo() == Material.AIR) { } else if (event.getTo() == Material.AIR) {
event.getEntity() event.getEntity()
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot)); .setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
} }
} }
@EventHandler public void onPrime(ExplosionPrimeEvent event) { @EventHandler
public void onPrime(ExplosionPrimeEvent event) {
this.lastRadius = event.getRadius() + 1; this.lastRadius = event.getRadius() + 1;
} }
@ -2111,7 +2130,7 @@ import java.util.regex.Pattern;
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
@ -2141,7 +2160,7 @@ import java.util.regex.Pattern;
location = BukkitUtil.getLocation(shooter.getLocation()); location = BukkitUtil.getLocation(shooter.getLocation());
} else if (fireball.getShooter() instanceof BlockProjectileSource) { } else if (fireball.getShooter() instanceof BlockProjectileSource) {
Block shooter = Block shooter =
((BlockProjectileSource) fireball.getShooter()).getBlock(); ((BlockProjectileSource) fireball.getShooter()).getBlock();
location = BukkitUtil.getLocation(shooter.getLocation()); location = BukkitUtil.getLocation(shooter.getLocation());
} }
if (location != null && !plot.equals(location.getPlot())) { if (location != null && !plot.equals(location.getPlot())) {
@ -2154,12 +2173,12 @@ import java.util.regex.Pattern;
Block ignitingBlock = event.getIgnitingBlock(); Block ignitingBlock = event.getIgnitingBlock();
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot(); Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && ( if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
!plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null !plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null
|| !plotIgnited.equals(plot)) || || !plotIgnited.equals(plot)) ||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && ( || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null !plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null
|| !plotIgnited.equals(plot))) { || !plotIgnited.equals(plot))) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -2170,8 +2189,8 @@ import java.util.regex.Pattern;
public void onBucketEmpty(PlayerBucketEmptyEvent event) { public void onBucketEmpty(PlayerBucketEmptyEvent event) {
BlockFace bf = event.getBlockFace(); BlockFace bf = event.getBlockFace();
Block b = Block b =
event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()) event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
.getBlock(); .getBlock();
Location location = BukkitUtil.getLocation(b.getLocation()); Location location = BukkitUtil.getLocation(b.getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
@ -2213,7 +2232,8 @@ import java.util.regex.Pattern;
PlotInventory.removePlotInventoryOpen(BukkitUtil.getPlayer(player)); PlotInventory.removePlotInventoryOpen(BukkitUtil.getPlayer(player));
} }
@EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) { @EventHandler(priority = EventPriority.MONITOR)
public void onLeave(PlayerQuitEvent event) {
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName()); TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
pp.unregister(); pp.unregister();
@ -2241,7 +2261,7 @@ import java.util.regex.Pattern;
return; return;
} }
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE); Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
@ -2272,7 +2292,7 @@ import java.util.regex.Pattern;
} }
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) { if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
entity entity
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot)); .setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
} }
} }
@ -2296,7 +2316,7 @@ import java.util.regex.Pattern;
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
@ -2305,7 +2325,7 @@ import java.util.regex.Pattern;
if (!plot.getFlag(Flags.HANGING_PLACE, false)) { if (!plot.getFlag(Flags.HANGING_PLACE, false)) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
@ -2333,13 +2353,13 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
@ -2348,7 +2368,7 @@ import java.util.regex.Pattern;
} }
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -2366,17 +2386,17 @@ import java.util.regex.Pattern;
if (plot != null) { if (plot != null) {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions if (!Permissions
.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { .hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_UNOWNED); C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(player.getUUID())) { } else if (!plot.isAdded(player.getUUID())) {
if (!plot.getFlag(Flags.HANGING_BREAK, false)) { if (!plot.getFlag(Flags.HANGING_BREAK, false)) {
if (!Permissions if (!Permissions
.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_OTHER); C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -2406,7 +2426,7 @@ import java.util.regex.Pattern;
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
@ -2418,7 +2438,7 @@ import java.util.regex.Pattern;
return; return;
} }
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
.getFlag(Flags.TAMED_INTERACT, false)) { .getFlag(Flags.TAMED_INTERACT, false)) {
return; return;
} }
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) { if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) {
@ -2455,14 +2475,14 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road"); .sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
event.setCancelled(true); event.setCancelled(true);
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT,
"plots.admin.vehicle.break.unowned"); "plots.admin.vehicle.break.unowned");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -2474,7 +2494,7 @@ import java.util.regex.Pattern;
} }
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT,
"plots.admin.vehicle.break.other"); "plots.admin.vehicle.break.other");
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -2501,11 +2521,12 @@ import java.util.regex.Pattern;
} }
} }
@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST) @SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
EntityDamageByEntityEvent eventChange; EntityDamageByEntityEvent eventChange;
eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
EntityDamageEvent.DamageCause.FIRE_TICK, (double) event.getDuration()); EntityDamageEvent.DamageCause.FIRE_TICK, (double) event.getDuration());
onEntityDamageByEntityEvent(eventChange); onEntityDamageByEntityEvent(eventChange);
if (eventChange.isCancelled()) { if (eventChange.isCancelled()) {
event.setCancelled(true); event.setCancelled(true);
@ -2539,7 +2560,7 @@ import java.util.regex.Pattern;
Location vloc = BukkitUtil.getLocation(victim); Location vloc = BukkitUtil.getLocation(victim);
PlotArea dArea = dloc.getPlotArea(); PlotArea dArea = dloc.getPlotArea();
PlotArea vArea = PlotArea vArea =
dArea != null && dArea.contains(vloc.getX(), vloc.getZ()) ? dArea : vloc.getPlotArea(); dArea != null && dArea.contains(vloc.getX(), vloc.getZ()) ? dArea : vloc.getPlotArea();
if (dArea == null && vArea == null) { if (dArea == null && vArea == null) {
return true; return true;
} }
@ -2596,7 +2617,7 @@ import java.util.regex.Pattern;
} else { // shooter is not player } else { // shooter is not player
if (shooter instanceof BlockProjectileSource) { if (shooter instanceof BlockProjectileSource) {
Location sLoc = BukkitUtil Location sLoc = BukkitUtil
.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation()); .getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
dplot = dArea.getPlot(sLoc); dplot = dArea.getPlot(sLoc);
} }
player = null; player = null;
@ -2608,51 +2629,51 @@ import java.util.regex.Pattern;
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (victim instanceof Hanging) { // hanging if (victim instanceof Hanging) { // hanging
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot
.isAdded(plotPlayer.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.destroy." + stub); "plots.admin.destroy." + stub);
return false; return false;
} }
} else if (victim.getEntityId() == 30) { } else if (victim.getEntityId() == 30) {
if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot
.isAdded(plotPlayer.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.destroy." + stub); "plots.admin.destroy." + stub);
return false; return false;
} }
} else if (victim instanceof Monster } else if (victim instanceof Monster
|| victim instanceof EnderDragon) { // victim is monster || victim instanceof EnderDragon) { // victim is monster
if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) { .getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} else if (victim instanceof Tameable) { // victim is tameable } else if (victim instanceof Tameable) { // victim is tameable
if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) { .getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} else if (victim instanceof Player) { } else if (victim instanceof Player) {
if (plot != null) { if (plot != null) {
if (Flags.PVP.isFalse(plot) && !Permissions if (Flags.PVP.isFalse(plot) && !Permissions
.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { .hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.pvp." + stub); "plots.admin.pvp." + stub);
return false; return false;
} else { } else {
return true; return true;
@ -2660,39 +2681,39 @@ import java.util.regex.Pattern;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
return false; return false;
} }
} else if (victim instanceof Creature) { // victim is animal } else if (victim instanceof Creature) { // victim is animal
if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) { .getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event } else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
return true; return true;
} else { // victim is something else } else { // victim is something else
if (plot != null && (plot.getFlag(Flags.PVE, false) || plot if (plot != null && (plot.getFlag(Flags.PVE, false) || plot
.isAdded(plotPlayer.getUUID()))) { .isAdded(plotPlayer.getUUID()))) {
return true; return true;
} }
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false; return false;
} }
} }
return true; return true;
} else if (dplot != null && (!dplot.equals(vplot) || Objects } else if (dplot != null && (!dplot.equals(vplot) || Objects
.equals(dplot.guessOwner(), vplot.guessOwner()))) { .equals(dplot.guessOwner(), vplot.guessOwner()))) {
return vplot != null && Flags.PVE.isTrue(vplot); return vplot != null && Flags.PVE.isTrue(vplot);
} }
return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow
&& !(victim instanceof Creature))); && !(victim instanceof Creature)));
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -2708,19 +2729,19 @@ import java.util.regex.Pattern;
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road"); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
event.setHatching(false); event.setHatching(false);
} }
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.projectile.unowned"); "plots.admin.projectile.unowned");
event.setHatching(false); event.setHatching(false);
} }
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
MainUtil MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other"); .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
event.setHatching(false); event.setHatching(false);
} }
} }
@ -2738,15 +2759,15 @@ import java.util.regex.Pattern;
Plot plot = area.getPlot(location); Plot plot = area.getPlot(location);
if (plot != null) { if (plot != null) {
if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
&& !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) { && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(pp, MainUtil.sendMessage(pp,
C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil MainUtil
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED); .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -30,7 +30,8 @@ import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener { @SuppressWarnings("unused")
public class PlotPlusListener extends PlotListener implements Listener {
private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>(); private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>(); private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
@ -80,7 +81,8 @@ import java.util.UUID;
}, 0L, 20L); }, 0L, 20L);
} }
@EventHandler(priority = EventPriority.HIGH) public void onInteract(BlockDamageEvent event) { @EventHandler(priority = EventPriority.HIGH)
public void onInteract(BlockDamageEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player.getGameMode() != GameMode.SURVIVAL) { if (player.getGameMode() != GameMode.SURVIVAL) {
return; return;
@ -99,7 +101,8 @@ import java.util.UUID;
} }
} }
@EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) { @EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) { if (event.getEntityType() != EntityType.PLAYER) {
return; return;
} }
@ -113,7 +116,8 @@ import java.util.UUID;
} }
} }
@EventHandler public void onItemDrop(PlayerDropItemEvent event) { @EventHandler
public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot(); Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
@ -128,7 +132,8 @@ import java.util.UUID;
} }
} }
@EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) { @EventHandler
public void onPlotEnter(PlayerEnterPlotEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
Optional<Integer[]> feed = plot.getFlag(Flags.FEED); Optional<Integer[]> feed = plot.getFlag(Flags.FEED);
@ -143,13 +148,15 @@ import java.util.UUID;
} }
} }
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) { @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
feedRunnable.remove(player.getUniqueId()); feedRunnable.remove(player.getUniqueId());
healRunnable.remove(player.getUniqueId()); healRunnable.remove(player.getUniqueId());
} }
@EventHandler public void onPlotLeave(PlayerLeavePlotEvent event) { @EventHandler
public void onPlotLeave(PlayerLeavePlotEvent event) {
Player leaver = event.getPlayer(); Player leaver = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
@ -160,7 +167,8 @@ import java.util.UUID;
healRunnable.remove(leaver.getUniqueId()); healRunnable.remove(leaver.getUniqueId());
} }
@EventHandler public void onItemPickup(EntityPickupItemEvent event) { @EventHandler
public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity(); LivingEntity ent = event.getEntity();
if (ent instanceof Player) { if (ent instanceof Player) {
Player player = (Player) ent; Player player = (Player) ent;
@ -181,7 +189,7 @@ import java.util.UUID;
final int interval; final int interval;
final int amount; final int amount;
final int max; final int max;
public int count = 0; int count = 0;
Interval(int interval, int amount, int max) { Interval(int interval, int amount, int max) {
this.interval = interval; this.interval = interval;

View File

@ -1072,22 +1072,22 @@ public class BukkitChunkManager extends ChunkManager {
} }
for (short y = 0; y <= maxY; y++) { for (short y = 0; y <= maxY; y++) {
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
Material id = block.getType(); Material blockType = block.getType();
if (storeNormal) { if (storeNormal) {
if (id.name().contains("AIR")) { if (blockType.name().contains("AIR")) {
ids[y] = StringPlotBlock.EVERYTHING; ids[y] = StringPlotBlock.EVERYTHING;
} else { } else {
ids[y] = PlotBlock.get(id.name()); ids[y] = PlotBlock.get(blockType.name());
} }
} }
if (!id.name().contains("AIR")) { if (!blockType.name().contains("AIR")) {
try { try {
BlockLoc bl = new BlockLoc(x + offsetX, y, z + offsetZ); BlockLoc bl = new BlockLoc(x + offsetX, y, z + offsetZ);
if (block.getState() instanceof InventoryHolder) { if (block.getState() instanceof InventoryHolder) {
InventoryHolder inventoryHolder = (InventoryHolder) block.getState(); InventoryHolder inventoryHolder = (InventoryHolder) block.getState();
ItemStack[] inventory = ItemStack[] inventory =
inventoryHolder.getInventory().getContents().clone(); inventoryHolder.getInventory().getContents().clone();
switch (id) { switch (blockType) {
case CHEST: case CHEST:
this.chestContents.put(bl, inventory); this.chestContents.put(bl, inventory);
break; break;

View File

@ -11,12 +11,10 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
public class SinglePlotArea extends GridPlotWorld { public class SinglePlotArea extends GridPlotWorld {
private final SinglePlotArea instance;
public boolean VOID = false; public boolean VOID = false;
public SinglePlotArea() { public SinglePlotArea() {
super("*", null, new SingleWorldGenerator(), null, null); super("*", null, new SingleWorldGenerator(), null, null);
instance = this;
this.ALLOW_SIGNS = false; this.ALLOW_SIGNS = false;
this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
} }

View File

@ -1,5 +1,6 @@
#Fri Dec 21 16:11:33 EST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip