Adds an entity spawn listener for preventing Zombified Piglin spawns
This commit is contained in:
parent
a3ed1058e6
commit
5e79df9f44
@ -10,6 +10,7 @@ import net.knarcraft.stargate.container.BlockChangeRequest;
|
||||
import net.knarcraft.stargate.container.ChunkUnloadRequest;
|
||||
import net.knarcraft.stargate.listener.BlockEventListener;
|
||||
import net.knarcraft.stargate.listener.EntityEventListener;
|
||||
import net.knarcraft.stargate.listener.EntitySpawnListener;
|
||||
import net.knarcraft.stargate.listener.PlayerEventListener;
|
||||
import net.knarcraft.stargate.listener.PluginEventListener;
|
||||
import net.knarcraft.stargate.listener.PortalEventListener;
|
||||
@ -388,6 +389,7 @@ public class Stargate extends JavaPlugin {
|
||||
pluginManager.registerEvents(new WorldEventListener(), this);
|
||||
pluginManager.registerEvents(new PluginEventListener(this), this);
|
||||
pluginManager.registerEvents(new TeleportEventListener(), this);
|
||||
pluginManager.registerEvents(new EntitySpawnListener(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,25 @@
|
||||
package net.knarcraft.stargate.listener;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.portal.PortalHandler;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
/**
|
||||
* A listener that listens for any relevant events causing entities to spawn
|
||||
*/
|
||||
public class EntitySpawnListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
//Prevent Zombified Piglins and other creatures form spawning at stargates
|
||||
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL) {
|
||||
if (PortalHandler.getByEntrance(event.getLocation()) != null) {
|
||||
event.setCancelled(true);
|
||||
Stargate.debug("EntitySpawnListener", "Prevented creature from spawning at Stargate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user