Subtle behaviour change to make players remove themselves from tablist on death

This commit is contained in:
fullwall 2022-11-12 16:17:06 +08:00
parent 102630a5e0
commit c02391ccc3
3 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.util.NMS;
public abstract class AbstractEntityController implements EntityController {
@ -31,8 +30,6 @@ public abstract class AbstractEntityController implements EntityController {
return;
if (bukkitEntity instanceof Player) {
NMS.removeFromWorld(bukkitEntity);
SkinnableEntity npc = bukkitEntity instanceof SkinnableEntity ? (SkinnableEntity) bukkitEntity : null;
npc.getSkinTracker().onRemoveNPC();
NMS.remove(bukkitEntity);
setEntity(null);
} else {

View File

@ -102,6 +102,11 @@ public class CitizensNPC extends AbstractNPC {
trait.onDespawn();
}
Messaging.debug("Despawned", this, "DespawnReason." + reason);
if (getEntity() instanceof SkinnableEntity) {
((SkinnableEntity) getEntity()).getSkinTracker().onRemoveNPC();
}
if (reason == DespawnReason.DEATH) {
entityController.setEntity(null);
} else {

View File

@ -299,7 +299,7 @@ citizens.commands.trait.removed=Removed {0} successfully.
citizens.commands.traitc.missing=Trait not found.
citizens.commands.traitc.not-configurable=That trait is not configurable.
citizens.commands.traitc.not-on-npc=The NPC doesn''t have that trait.
citizens.commands.unknown-command=Unknown command. Did you mean:
citizens.commands.unknown-command=Unknown command.
citizens.commands.waypoints.add.waypoint-added=Added waypoint at [[{0}]] (index [[{1}]]).
citizens.commands.waypoints.disableteleporting.disabled=[[{0}]] will no longer teleport when stuck pathfinding.
citizens.commands.waypoints.disableteleporting.enabled=[[{0}]] will now teleport when stuck pathfinding.