Skip to content

Commit

Permalink
Merge pull request #248 from JCThePants/JCThePants-patch-3
Browse files Browse the repository at this point in the history
Fix dead player NPC not removed from world.
  • Loading branch information
fullwall committed Feb 24, 2015
2 parents 7e141f3 + 1088138 commit a13fdee
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.trait.Inventory;
Expand All @@ -22,6 +23,7 @@
import net.minecraft.server.v1_8_R1.AttributeInstance;
import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_8_R1.BlockPosition;
import net.minecraft.server.v1_8_R1.DamageSource;
import net.minecraft.server.v1_8_R1.Entity;
import net.minecraft.server.v1_8_R1.EntityPlayer;
import net.minecraft.server.v1_8_R1.EnumGamemode;
Expand Down Expand Up @@ -84,6 +86,22 @@ public void collide(net.minecraft.server.v1_8_R1.Entity entity) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
}

@Override
public void die(DamageSource damagesource) {
// players that die are not normally removed from the world. when the
// NPC dies, we are done with the instance and it should be removed.
if (dead) {
return;
}
super.die(damagesource);
Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
world.removeEntity(EntityHumanNPC.this);
}
}, 35); // give enough time for death and smoke animation
}

@Override
public void e(float f, float f1) {
Expand Down

0 comments on commit a13fdee

Please sign in to comment.