Only block natural spawn types.
This commit is contained in:
		@@ -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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user