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

View File

@ -58,7 +58,8 @@ import java.util.regex.Pattern;
/**
* 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 float lastRadius;
@ -87,7 +88,7 @@ import java.util.regex.Pattern;
Location loc = player.getLocation();
if (loc.getWorld().equals(world)) {
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;
}
((BukkitPlayer) player).player.sendBlockChange(bloc, data);
@ -98,7 +99,7 @@ import java.util.regex.Pattern;
public static boolean checkEntity(Entity entity, Plot plot) {
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot
.getArea().DEFAULT_FLAGS.isEmpty()) {
.getArea().DEFAULT_FLAGS.isEmpty()) {
return false;
}
switch (entity.getType()) {
@ -172,9 +173,16 @@ import java.util.regex.Pattern;
case MULE:
case ZOMBIE_HORSE:
case SKELETON_HORSE:
case PARROT:
case TURTLE:
case COD:
case SALMON:
case DOLPHIN:
case PUFFERFISH:
case TROPICAL_FISH:
// animal
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 CAVE_SPIDER:
case CREEPER:
@ -202,17 +210,19 @@ import java.util.regex.Pattern;
case EVOKER:
case VEX:
case ZOMBIE_VILLAGER:
case DROWNED:
case ILLUSIONER:
// monster
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:
if (entity instanceof LivingEntity) {
if (entity instanceof Animals) {
if (entity instanceof Animals || entity instanceof WaterMob) {
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) {
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 {
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();
switch (block.getType()) {
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();
if (!(entity instanceof ThrownPotion)) {
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();
Location loc = BukkitUtil.getLocation(entity);
if (!PlotSquared.get().hasPlotArea(loc.getWorld())) {
@ -448,7 +461,7 @@ import java.util.regex.Pattern;
return true;
}
if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return true;
}
entity.remove();
@ -460,7 +473,7 @@ import java.util.regex.Pattern;
return false;
}
Location sLoc =
BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
entity.remove();
return false;
@ -496,7 +509,7 @@ import java.util.regex.Pattern;
case "worldedit:up":
case "worldedit:/up":
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);
return;
}
@ -507,7 +520,7 @@ import java.util.regex.Pattern;
}
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
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();
String c = parts[0];
if (parts[0].contains(":")) {
@ -607,7 +620,7 @@ import java.util.regex.Pattern;
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) {
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_LAST_PLOT);
org.bukkit.Location to = event.getTo();
@ -636,7 +649,7 @@ import java.util.regex.Pattern;
int toX, toZ;
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();
// Check allowed
@ -660,7 +673,7 @@ import java.util.regex.Pattern;
if (moveTmp.isCancelled()) {
dest = from;
} else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX
|| MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
|| MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
dest = to;
} else {
dest = null;
@ -700,7 +713,7 @@ import java.util.regex.Pattern;
}
} else if (toPlot != null) {
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())
return;
@ -869,7 +883,7 @@ import java.util.regex.Pattern;
}
}
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")) {
message = C.color(message);
}
@ -879,7 +893,7 @@ import java.util.regex.Pattern;
}
if (!spies.isEmpty()) {
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) {
player.sendMessage(spyMessage);
}
@ -887,7 +901,8 @@ import java.util.regex.Pattern;
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();
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = location.getPlotArea();
@ -899,26 +914,26 @@ import java.util.regex.Pattern;
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (event.getBlock().getY() == 0) {
if (!Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
event.setCancelled(true);
return;
}
} else if (
(location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
&& !Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
(location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
&& !Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true);
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 (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return;
}
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_UNOWNED);
C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true);
return;
}
@ -926,19 +941,19 @@ import java.util.regex.Pattern;
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock();
if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name()))) {
.contains(PlotBlock.get(block.getType().name()))) {
return;
}
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_OTHER);
C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_BUILD_OTHER);
C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
return;
}
@ -951,7 +966,7 @@ import java.util.regex.Pattern;
}
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getInventory().getItemInMainHand().getType() == Material
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
return;
}
}
@ -988,13 +1003,13 @@ import java.util.regex.Pattern;
}
if (this.lastRadius != 0) {
List<Entity> nearby = event.getEntity()
.getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
.getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
for (Entity near : nearby) {
if (near instanceof TNTPrimed || near.getType()
.equals(EntityType.MINECART_TNT)) {
.equals(EntityType.MINECART_TNT)) {
if (!near.hasMetadata("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();
location = BukkitUtil.getLocation(block.getLocation());
if (!area.contains(location.getX(), location.getZ()) || !origin
.equals(area.getOwnedPlot(location))) {
.equals(area.getOwnedPlot(location))) {
iterator.remove();
}
}
@ -1209,8 +1224,8 @@ import java.util.regex.Pattern;
Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock();
if (destroy.isPresent() && destroy.get()
.contains(PlotBlock.get(block.getType().name())) || Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
.contains(PlotBlock.get(block.getType().name())) || Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
event.setCancelled(true);
@ -1273,7 +1288,7 @@ import java.util.regex.Pattern;
event.setCancelled(true);
return;
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
.equals(plot, area.getOwnedPlot(fLocation))) {
.equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);
return;
}
@ -1285,7 +1300,7 @@ import java.util.regex.Pattern;
}
}
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
.equals(null, area.getOwnedPlot(fLocation))) {
.equals(null, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);
}
}
@ -1327,12 +1342,12 @@ import java.util.regex.Pattern;
for (Block b : blocks) {
Location bloc = BukkitUtil.getLocation(b.getLocation());
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);
return;
}
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);
return;
}
@ -1364,7 +1379,7 @@ import java.util.regex.Pattern;
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
BlockFace dir = event.getDirection();
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) {
event.setCancelled(true);
return;
@ -1385,7 +1400,7 @@ import java.util.regex.Pattern;
try {
for (Block pulled : event.getBlocks()) {
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());
if (!area.contains(to.getX(), to.getZ())) {
event.setCancelled(true);
@ -1404,7 +1419,7 @@ import java.util.regex.Pattern;
}
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
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)) {
event.setCancelled(true);
return;
@ -1425,10 +1440,10 @@ import java.util.regex.Pattern;
if (event.getBlock().getType() == Material.DROPPER)
return;
BlockFace targetFace =
((org.bukkit.material.Dispenser) event.getBlock().getState().getData())
.getFacing();
((org.bukkit.material.Dispenser) event.getBlock().getState().getData())
.getFacing();
Location location =
BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
if (location.isPlotRoad()) {
event.setCancelled(true);
}
@ -1502,7 +1517,7 @@ import java.util.regex.Pattern;
}*/
HumanEntity entity = event.getWhoClicked();
if (!(entity instanceof Player) || !PlotSquared.get()
.hasPlotArea(entity.getWorld().getName())) {
.hasPlotArea(entity.getWorld().getName())) {
return;
}
@ -1601,14 +1616,14 @@ import java.util.regex.Pattern;
}
if (cancelled) {
if ((current.getType() == newItem.getType()) && (current.getDurability() == newItem
.getDurability())) {
.getDurability())) {
event.setCursor(
new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
event.setCancelled(true);
return;
}
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.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)
@ -1716,7 +1731,7 @@ import java.util.regex.Pattern;
location = BukkitUtil.getLocation(block.getLocation());
Material blockType = block.getType();
int blockId = ((LegacyPlotBlock) PlotSquared.get().IMP.getLegacyMappings()
.fromStringToLegacy(blockType.name())).id;
.fromStringToLegacy(blockType.name())).id;
switch (blockType) {
case ANVIL:
case ACACIA_DOOR:
@ -1849,7 +1864,7 @@ import java.util.regex.Pattern;
lb = new BukkitLazyBlock(PlotBlock.get(block.getType().toString()));
ItemStack hand = player.getInventory().getItemInMainHand();
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK
|| !player.isSneaking())) {
|| !player.isSneaking())) {
break;
}
Material type = (hand == null) ? null : hand.getType();
@ -1859,7 +1874,7 @@ import java.util.regex.Pattern;
}
if (type == null || type.isBlock()) {
location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_BLOCK;
break;
}
@ -1875,7 +1890,7 @@ import java.util.regex.Pattern;
break;
case ARMOR_STAND:
location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_MISC;
break;
case WRITTEN_BOOK:
@ -1933,7 +1948,7 @@ import java.util.regex.Pattern;
case PAINTING:
case ITEM_FRAME:
location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_HANGING;
break;
default:
@ -1954,7 +1969,7 @@ import java.util.regex.Pattern;
}
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
if (player.getInventory().getItemInMainHand().getType() == Material
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
return;
}
}
@ -1972,10 +1987,13 @@ import java.util.regex.Pattern;
return;
}
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) {
case SPAWNER_EGG:
case DISPENSE_EGG:
case OCELOT_BABY:
case EGG:
if (!area.SPAWN_EGGS) {
event.setCancelled(true);
return;
@ -2049,11 +2067,12 @@ import java.util.regex.Pattern;
}
} else if (event.getTo() == Material.AIR) {
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;
}
@ -2111,7 +2130,7 @@ import java.util.regex.Pattern;
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
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);
}
} else if (!plot.isAdded(pp.getUUID())) {
@ -2141,7 +2160,7 @@ import java.util.regex.Pattern;
location = BukkitUtil.getLocation(shooter.getLocation());
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
Block shooter =
((BlockProjectileSource) fireball.getShooter()).getBlock();
((BlockProjectileSource) fireball.getShooter()).getBlock();
location = BukkitUtil.getLocation(shooter.getLocation());
}
if (location != null && !plot.equals(location.getPlot())) {
@ -2154,12 +2173,12 @@ import java.util.regex.Pattern;
Block ignitingBlock = event.getIgnitingBlock();
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
!plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null
|| !plotIgnited.equals(plot)) ||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null
|| !plotIgnited.equals(plot))) {
!plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null
|| !plotIgnited.equals(plot)) ||
(igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null
|| !plotIgnited.equals(plot))) {
event.setCancelled(true);
}
}
@ -2170,8 +2189,8 @@ import java.util.regex.Pattern;
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
BlockFace bf = event.getBlockFace();
Block b =
event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
.getBlock();
event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
.getBlock();
Location location = BukkitUtil.getLocation(b.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
@ -2213,7 +2232,8 @@ import java.util.regex.Pattern;
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());
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
pp.unregister();
@ -2241,7 +2261,7 @@ import java.util.regex.Pattern;
return;
}
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);
} else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
@ -2272,7 +2292,7 @@ import java.util.regex.Pattern;
}
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
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 (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
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);
}
return;
@ -2305,7 +2325,7 @@ import java.util.regex.Pattern;
if (!plot.getFlag(Flags.HANGING_PLACE, false)) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
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);
}
return;
@ -2333,13 +2353,13 @@ import java.util.regex.Pattern;
if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
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);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
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);
}
} else if (!plot.isAdded(pp.getUUID())) {
@ -2348,7 +2368,7 @@ import java.util.regex.Pattern;
}
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
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);
}
}
@ -2366,17 +2386,17 @@ import java.util.regex.Pattern;
if (plot != null) {
if (!plot.hasOwner()) {
if (!Permissions
.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_UNOWNED);
C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true);
}
} else if (!plot.isAdded(player.getUUID())) {
if (!plot.getFlag(Flags.HANGING_BREAK, false)) {
if (!Permissions
.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT,
C.PERMISSION_ADMIN_DESTROY_OTHER);
C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true);
}
}
@ -2406,7 +2426,7 @@ import java.util.regex.Pattern;
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
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);
}
} else if (!plot.isAdded(pp.getUUID())) {
@ -2418,7 +2438,7 @@ import java.util.regex.Pattern;
return;
}
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
.getFlag(Flags.TAMED_INTERACT, false)) {
.getFlag(Flags.TAMED_INTERACT, false)) {
return;
}
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) {
@ -2455,14 +2475,14 @@ import java.util.regex.Pattern;
if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
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);
}
} else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT,
"plots.admin.vehicle.break.unowned");
"plots.admin.vehicle.break.unowned");
event.setCancelled(true);
return;
}
@ -2474,7 +2494,7 @@ import java.util.regex.Pattern;
}
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT,
"plots.admin.vehicle.break.other");
"plots.admin.vehicle.break.other");
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) {
EntityDamageByEntityEvent eventChange;
eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
EntityDamageEvent.DamageCause.FIRE_TICK, (double) event.getDuration());
EntityDamageEvent.DamageCause.FIRE_TICK, (double) event.getDuration());
onEntityDamageByEntityEvent(eventChange);
if (eventChange.isCancelled()) {
event.setCancelled(true);
@ -2539,7 +2560,7 @@ import java.util.regex.Pattern;
Location vloc = BukkitUtil.getLocation(victim);
PlotArea dArea = dloc.getPlotArea();
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) {
return true;
}
@ -2596,7 +2617,7 @@ import java.util.regex.Pattern;
} else { // shooter is not player
if (shooter instanceof BlockProjectileSource) {
Location sLoc = BukkitUtil
.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
dplot = dArea.getPlot(sLoc);
}
player = null;
@ -2608,51 +2629,51 @@ import java.util.regex.Pattern;
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (victim instanceof Hanging) { // hanging
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot
.isAdded(plotPlayer.getUUID()))) {
.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.destroy." + stub);
"plots.admin.destroy." + stub);
return false;
}
} else if (victim.getEntityId() == 30) {
if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot
.isAdded(plotPlayer.getUUID()))) {
.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.destroy." + stub);
"plots.admin.destroy." + stub);
return false;
}
} 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
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (victim instanceof Tameable) { // victim is tameable
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;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (victim instanceof Player) {
if (plot != null) {
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,
"plots.admin.pvp." + stub);
"plots.admin.pvp." + stub);
return false;
} else {
return true;
@ -2660,39 +2681,39 @@ import java.util.regex.Pattern;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
return false;
}
} else if (victim instanceof Creature) { // victim is animal
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;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
return true;
} else { // victim is something else
if (plot != null && (plot.getFlag(Flags.PVE, false) || plot
.isAdded(plotPlayer.getUUID()))) {
.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
}
return true;
} 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)) || !(damager instanceof Arrow
&& !(victim instanceof Creature)));
&& !(victim instanceof Creature)));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -2708,19 +2729,19 @@ import java.util.regex.Pattern;
if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
event.setHatching(false);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
"plots.admin.projectile.unowned");
"plots.admin.projectile.unowned");
event.setHatching(false);
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
MainUtil
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
event.setHatching(false);
}
}
@ -2738,15 +2759,15 @@ import java.util.regex.Pattern;
Plot plot = area.getPlot(location);
if (plot != null) {
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);
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 (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
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);
return;
}

View File

@ -30,7 +30,8 @@ import java.util.Iterator;
import java.util.Map.Entry;
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> healRunnable = new HashMap<>();
@ -80,7 +81,8 @@ import java.util.UUID;
}, 0L, 20L);
}
@EventHandler(priority = EventPriority.HIGH) public void onInteract(BlockDamageEvent event) {
@EventHandler(priority = EventPriority.HIGH)
public void onInteract(BlockDamageEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() != GameMode.SURVIVAL) {
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) {
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();
PlotPlayer pp = BukkitUtil.getPlayer(player);
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();
Plot plot = event.getPlot();
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();
feedRunnable.remove(player.getUniqueId());
healRunnable.remove(player.getUniqueId());
}
@EventHandler public void onPlotLeave(PlayerLeavePlotEvent event) {
@EventHandler
public void onPlotLeave(PlayerLeavePlotEvent event) {
Player leaver = event.getPlayer();
Plot plot = event.getPlot();
if (!plot.hasOwner()) {
@ -160,7 +167,8 @@ import java.util.UUID;
healRunnable.remove(leaver.getUniqueId());
}
@EventHandler public void onItemPickup(EntityPickupItemEvent event) {
@EventHandler
public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity();
if (ent instanceof Player) {
Player player = (Player) ent;
@ -181,7 +189,7 @@ import java.util.UUID;
final int interval;
final int amount;
final int max;
public int count = 0;
int count = 0;
Interval(int interval, int amount, int max) {
this.interval = interval;

View File

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

View File

@ -11,12 +11,10 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
public class SinglePlotArea extends GridPlotWorld {
private final SinglePlotArea instance;
public boolean VOID = false;
public SinglePlotArea() {
super("*", null, new SingleWorldGenerator(), null, null);
instance = this;
this.ALLOW_SIGNS = false;
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
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip