Only block natural spawn types.

This commit is contained in:
Olof Larsson 2014-10-03 18:01:40 +02:00
parent 8612f0a39a
commit a57f05eb1d
2 changed files with 13 additions and 5 deletions

View File

@ -55,10 +55,10 @@ public class MPlayerColl extends SenderColl<MPlayer>
// Maybe skipping ahead if the player is detached will solve the issue. // Maybe skipping ahead if the player is detached will solve the issue.
if (mplayer.detached()) continue; if (mplayer.detached()) continue;
if (mplayer.isOnline()) continue;
Long lastPlayed = Mixin.getLastPlayed(mplayer.getId()); Long lastPlayed = Mixin.getLastPlayed(mplayer.getId());
if (lastPlayed == null) continue; if (lastPlayed == null) continue;
if (mplayer.isOnline()) continue;
if (now - lastPlayed <= toleranceMillis) continue; if (now - lastPlayed <= toleranceMillis) continue;
if (MConf.get().logFactionLeave || MConf.get().logFactionKick) if (MConf.get().logFactionLeave || MConf.get().logFactionKick)

View File

@ -41,6 +41,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.hanging.HangingPlaceEvent;
@ -608,10 +609,17 @@ public class FactionsListenerMain implements Listener
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockMonsters(CreatureSpawnEvent event) public void blockMonsters(CreatureSpawnEvent event)
{ {
// If a monster is spawning ... // If a creature is spawning ...
if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return; 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()); PS ps = PS.valueOf(event.getLocation());
Faction faction = BoardColl.get().getFactionAt(ps); Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getMonsters())) return; if (faction.getFlag(MFlag.getMonsters())) return;