Fix NPCs being pullable

This commit is contained in:
fullwall 2016-06-09 19:06:37 +08:00
parent 94648aa53e
commit 1d45fe1d3e
2 changed files with 8 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
@ -262,6 +263,12 @@ public class EventListen implements Listener {
}
}
@EventHandler(ignoreCancelled=true)
public void onPlayerFish(PlayerFishEvent event) {
if (npcRegistry.isNPC(event.getCaught()) && npcRegistry.getNPC(event.getCaught()).isProtected()) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
if (event.isCancelled() && npcRegistry.isNPC(event.getEntity())) {

View File

@ -622,7 +622,7 @@ public class NMS {
NPC npc = npcRegistry.getNPC(hook.hooked.getBukkitEntity());
if (npc == null)
return;
if (npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
if (npc.isProtected()) {
hook.hooked = null;
hook.die();
}