Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix arrow death bug

  • Loading branch information...
commit cf952df7e314f458ac2ae80f437ece61ab1a3d83 1 parent db75612
fullwall authored
View
1  src/core/net/citizensnpcs/TickTask.java
@@ -109,7 +109,6 @@ private static void cacheActions(HumanNPC npc, Player player) {
}
public static void scheduleRespawn(HumanNPC npc, int delay) {
- NPCManager.getList().remove(npc.getUID());
new RespawnTask(npc).register(delay);
}
View
7 src/core/net/citizensnpcs/listeners/EntityListen.java
@@ -97,8 +97,11 @@ public void onEntityTarget(NPCTargetEvent event) {
public void onEntityDeath(EntityDeathEvent event) {
CreatureTask.onEntityDeath(event.getEntity());
if (NPCManager.isNPC(event.getEntity())) {
- NPCManager.get(event.getEntity()).callDeathEvent(event);
- NPCManager.removeForRespawn(NPCManager.get(event.getEntity()).getUID());
+ HumanNPC npc = NPCManager.get(event.getEntity());
+ if (NPCManager.get(npc.getUID()) != npc)
+ return;
+ npc.callDeathEvent(event);
+ NPCManager.removeForRespawn(npc.getUID());
}
}
}
View
3  src/core/net/citizensnpcs/listeners/WorldListen.java
@@ -27,8 +27,7 @@ public void onChunkUnload(ChunkUnloadEvent event) {
if (event.isCancelled())
return;
// Stores NPC location/name for later respawn.
- for (int entry : NPCManager.GlobalUIDs.keySet()) {
- HumanNPC npc = NPCManager.get(entry);
+ for (HumanNPC npc : NPCManager.getList().values()) {
if (event.getWorld().equals(npc.getWorld()) && event.getChunk().getX() == npc.getChunkX()
&& event.getChunk().getZ() == npc.getChunkZ()) {
NPCLocation loc = new NPCLocation(npc.getLocation(), npc.getUID(), npc.getOwner());
View
2  src/core/net/citizensnpcs/resources/npclib/NPCManager.java
@@ -64,9 +64,9 @@ public static void faceEntity(HumanNPC npc, Entity entity) {
// Despawns an NPC.
public static void despawn(int UID, NPCRemoveReason reason) {
- GlobalUIDs.remove(UID);
if (list.get(UID) == null)
return;
+ GlobalUIDs.remove(UID);
NPCSpawner.despawnNPC(list.remove(UID), reason);
}
View
4 src/core/net/citizensnpcs/resources/npclib/NPCSpawner.java
@@ -104,12 +104,12 @@ public static HumanNPC spawnNPC(HumanNPC npc, Location loc) {
}
public static void despawnNPC(HumanNPC npc, NPCRemoveReason reason) {
- if (getWorldServer(npc.getWorld()).getEntity(npc.getHandle().id) != npc.getHandle() || npc.getHandle().dead)
+ if (getWorldServer(npc.getWorld()).getEntity(npc.getPlayer().getEntityId()) != npc.getHandle()
+ || npc.getHandle().dead)
return;
Bukkit.getServer().getPluginManager().callEvent(new NPCRemoveEvent(npc, reason));
PacketUtils.sendPacketToOnline(new Packet29DestroyEntity(npc.getHandle().id), null);
npc.getHandle().die();
- getWorldServer(npc.getWorld()).removeEntity(npc.getHandle());
}
public static void despawnNPC(CraftNPC npc, NPCRemoveReason reason) {
Please sign in to comment.
Something went wrong with that request. Please try again.