mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 12:15:53 +01:00
Change isSpawned API to use old valid logic. May fix spawning issues.
This commit is contained in:
parent
95e9aa1389
commit
d72b6ef9e8
@ -621,6 +621,13 @@ public class EventListen implements Listener {
|
||||
List<NPC> ids = toRespawn.get(coord);
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
NPC npc = ids.get(i);
|
||||
if (npc.getOwningRegistry().getById(npc.getId()) != npc) {
|
||||
ids.remove(i--);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Prevented deregistered NPC from respawning", npc.getId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
boolean success = spawn(npc);
|
||||
if (!success) {
|
||||
if (Messaging.isDebugging()) {
|
||||
|
@ -140,6 +140,11 @@ public class CitizensNPC extends AbstractNPC {
|
||||
return super.isFlyable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawned() {
|
||||
return getEntity() != null && NMS.isValid(getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(final DataKey root) {
|
||||
super.load(root);
|
||||
|
@ -272,6 +272,10 @@ public class NMS {
|
||||
return BRIDGE.isOnGround(entity);
|
||||
}
|
||||
|
||||
public static boolean isValid(Entity entity) {
|
||||
return BRIDGE.isValid(entity);
|
||||
}
|
||||
|
||||
public static void load(CommandManager commands) {
|
||||
BRIDGE.load(commands);
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ public interface NMSBridge {
|
||||
|
||||
public boolean isOnGround(Entity entity);
|
||||
|
||||
public boolean isValid(Entity entity);
|
||||
|
||||
public void load(CommandManager commands);
|
||||
|
||||
public void loadPlugins();
|
||||
|
@ -509,6 +509,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSImpl.getHandle(entity).onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
return handle.valid && handle.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CommandManager commands) {
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
||||
|
@ -549,6 +549,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSImpl.getHandle(entity).onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
return handle.valid && handle.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CommandManager manager) {
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(BossBarTrait.class));
|
||||
|
@ -552,6 +552,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSImpl.getHandle(entity).onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
return handle.valid && handle.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CommandManager manager) {
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
||||
|
@ -45,7 +45,9 @@ public class HorseController extends MobEntityController {
|
||||
|
||||
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
|
||||
private double baseMovementSpeed;
|
||||
|
||||
private final CitizensNPC npc;
|
||||
|
||||
private boolean riding;
|
||||
|
||||
public EntityHorseNPC(World world) {
|
||||
|
@ -566,6 +566,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSImpl.getHandle(entity).onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
return handle.valid && handle.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CommandManager manager) {
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(LlamaTrait.class));
|
||||
|
@ -596,6 +596,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSImpl.getHandle(entity).onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
return handle.valid && handle.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CommandManager manager) {
|
||||
CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(CatTrait.class));
|
||||
|
@ -478,6 +478,12 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSImpl.getHandle(entity).onGround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(org.bukkit.entity.Entity entity) {
|
||||
Entity handle = getHandle(entity);
|
||||
return handle.valid && handle.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CommandManager commands) {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user