Add debug statement to forwardingNPCHolder

This commit is contained in:
fullwall 2021-03-31 22:31:24 +08:00
parent fa0cf4fc95
commit 48a2763a1b
1 changed files with 9 additions and 1 deletions

View File

@ -3,11 +3,19 @@ package net.citizensnpcs.nms.v1_16_R3.util;
import org.bukkit.entity.Entity;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.NPCHolder;
public interface ForwardingNPCHolder extends NPCHolder, Entity {
@Override
default NPC getNPC() {
return ((NPCHolder) NMSImpl.getHandle(this)).getNPC();
net.minecraft.server.v1_16_R3.Entity handle = NMSImpl.getHandle(this);
if (!(handle instanceof NPCHolder)) {
if (Messaging.isDebugging()) {
Messaging.debug("ForwardingNPCHolder with an improper bukkit entity", this, handle);
}
return null;
}
return ((NPCHolder) handle).getNPC();
}
}