Trial portals

This commit is contained in:
fullwall 2018-10-01 18:36:12 +08:00
parent edc36c76c8
commit 92121c11e2

View File

@ -26,6 +26,7 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.PlayerLeashEntityEvent;
import org.bukkit.event.entity.PotionSplashEvent;
@ -270,6 +271,17 @@ public class EventListen implements Listener {
}
}
@EventHandler
public void onEntityPortal(EntityPortalEvent event) {
NPC npc = npcRegistry.getNPC(event.getEntity());
if (npc == null && event.getEntityType() != EntityType.PLAYER)
return;
event.setCancelled(true);
npc.despawn(DespawnReason.PENDING_RESPAWN);
event.getTo().getChunk();
npc.spawn(event.getTo(), SpawnReason.RESPAWN);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
if (event.isCancelled() && npcRegistry.isNPC(event.getEntity())) {