diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java b/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java index 74d3a6b5..968c8766 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java @@ -55,10 +55,10 @@ public class MPlayerColl extends SenderColl // Maybe skipping ahead if the player is detached will solve the issue. if (mplayer.detached()) continue; + if (mplayer.isOnline()) continue; + Long lastPlayed = Mixin.getLastPlayed(mplayer.getId()); if (lastPlayed == null) continue; - - if (mplayer.isOnline()) continue; if (now - lastPlayed <= toleranceMillis) continue; if (MConf.get().logFactionLeave || MConf.get().logFactionKick) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java index 85351fa2..abbe57ce 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -41,6 +41,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PotionSplashEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; @@ -608,10 +609,17 @@ public class FactionsListenerMain implements Listener @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockMonsters(CreatureSpawnEvent event) { - // If a monster is spawning ... - if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return; + // If a creature is spawning ... + EntityType type = event.getEntityType(); - // ... at a place where monsters are forbidden ... + // ... and that creature is a monster ... + if ( ! MConf.get().entityTypesMonsters.contains(type)) return; + + // ... and the reason for the spawn is natural ... + SpawnReason reason = event.getSpawnReason(); + if (reason != SpawnReason.NATURAL && reason != SpawnReason.JOCKEY) return; + + // ... and monsters are forbidden at the location ... PS ps = PS.valueOf(event.getLocation()); Faction faction = BoardColl.get().getFactionAt(ps); if (faction.getFlag(MFlag.getMonsters())) return;