mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-03-11 22:30:24 +01:00
Allow minecraft to remove NPCs on death instead of going through Citizens
This commit is contained in:
parent
9ad7c976bf
commit
72ac9134b1
@ -23,6 +23,11 @@ public abstract class AbstractEntityController implements EntityController {
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntity(Entity entity) {
|
||||
this.bukkitEntity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (bukkitEntity == null)
|
||||
|
@ -73,7 +73,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
event.setCancelled(Setting.KEEP_CHUNKS_LOADED.asBoolean());
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
if (event.isCancelled() && reason != DespawnReason.DEATH) {
|
||||
getEntity().getLocation().getChunk();
|
||||
Messaging.debug("Couldn't despawn", getId(), "due to despawn event cancellation. Force loaded chunk.",
|
||||
getEntity().isValid());
|
||||
@ -91,8 +91,11 @@ public class CitizensNPC extends AbstractNPC {
|
||||
trait.onDespawn();
|
||||
}
|
||||
Messaging.debug("Despawned", getId(), "DespawnReason.", reason);
|
||||
entityController.remove();
|
||||
|
||||
if (reason == DespawnReason.DEATH) {
|
||||
entityController.setEntity(null);
|
||||
} else {
|
||||
entityController.remove();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,16 @@
|
||||
package net.citizensnpcs.npc;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
public interface EntityController {
|
||||
Entity getBukkitEntity();
|
||||
|
||||
void remove();
|
||||
|
||||
void setEntity(Entity entity);
|
||||
|
||||
void spawn(Location at, NPC npc);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user