diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index e685631c0..c81415a37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -3,13 +3,18 @@ package com.intellectualcrafters.plot.listeners; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.world.ChunkLoadEvent; @@ -35,7 +40,7 @@ public class ChunkListener implements Listener { private Chunk lastChunk = null; - @EventHandler + @EventHandler(priority=EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) { Item entity = event.getEntity(); Chunk chunk = entity.getLocation().getChunk(); @@ -58,7 +63,25 @@ public class ChunkListener implements Listener { } } - @EventHandler + private long last = 0; + private int count = 0; + + @EventHandler(priority=EventPriority.LOWEST) + public void onBlockPhysics(BlockPhysicsEvent event) { + long now = System.currentTimeMillis(); + if (now - last < 20) { + if (count > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + event.setCancelled(true); + } + count++; + } + else { + count = 0; + } + last = now; + } + + @EventHandler(priority=EventPriority.LOWEST) public void onEntitySpawn(CreatureSpawnEvent event) { LivingEntity entity = event.getEntity(); Chunk chunk = entity.getLocation().getChunk(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 4bd1b65fd..dbdbc2b86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -145,11 +145,14 @@ public class PlotListener extends APlotListener { if (musicFlag != null) { player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); Integer id = (Integer) musicFlag.getValue(); - if (id != 0) { + if (id >= 2256 && id <= 2267) { Location center = MainUtil.getPlotCenter(plot); org.bukkit.Location newLoc = BukkitUtil.getLocation(center); newLoc.setY(Math.min((((int) player.getLocation().getBlockY())/16) * 16, 240)); - player.playEffect(newLoc, Effect.RECORD_PLAY, Material.getMaterial(id)); + try { + player.playEffect(newLoc, Effect.RECORD_PLAY, Material.getMaterial(id)); + } + catch (Exception e) {} } } CommentManager.sendTitle(pp, plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index c3677f6cc..fd7c85b16 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -118,9 +118,6 @@ public class ExpireManager { expiredPlots.get(world).remove(plot); return; } - if (plot.settings.isMerged()) { - MainUtil.unlinkPlot(plot); - } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); RunnableVal run = new RunnableVal() { @Override @@ -134,10 +131,14 @@ public class ExpireManager { return; } else if (changed >= Settings.MIN_BLOCKS_CHANGED_IGNORED && Settings.MIN_BLOCKS_CHANGED_IGNORED > 0) { + PlotSquared.log("&aIgnoring modified plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : "")); expiredPlots.get(world).remove(plot); return; } } + if (plot.settings.isMerged()) { + MainUtil.unlinkPlot(plot); + } manager.clearPlot(plotworld, plot, false, null); MainUtil.removeSign(plot); DBFunc.delete(world, plot);