Update tablist display logic

This commit is contained in:
fullwall 2024-05-14 17:53:17 +08:00
parent b12732d805
commit e8eadbfa36
10 changed files with 30 additions and 10 deletions

View File

@ -22,6 +22,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_11_R1.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_11_R1.network.EmptyNetworkManager;
@ -225,7 +226,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public IChatBaseComponent getPlayerListName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
return npc != null ? (IChatBaseComponent) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getPlayerListName();
}
@Override

View File

@ -23,6 +23,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_12_R1.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_12_R1.network.EmptyNetworkManager;
@ -228,7 +229,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public IChatBaseComponent getPlayerListName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
return npc != null ? (IChatBaseComponent) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getPlayerListName();
}
@Override

View File

@ -23,6 +23,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_13_R2.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_13_R2.network.EmptyNetworkManager;
@ -219,7 +220,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public IChatBaseComponent getPlayerListName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
return npc != null ? (IChatBaseComponent) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getPlayerListName();
}
@Override

View File

@ -22,6 +22,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_14_R1.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_14_R1.network.EmptyNetworkManager;
@ -210,7 +211,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public IChatBaseComponent getPlayerListName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
return npc != null ? (IChatBaseComponent) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getPlayerListName();
}
@Override

View File

@ -21,6 +21,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_15_R1.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_15_R1.network.EmptyNetworkManager;
@ -202,7 +203,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public IChatBaseComponent getPlayerListName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
return npc != null ? (IChatBaseComponent) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getPlayerListName();
}
@Override

View File

@ -22,6 +22,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_16_R3.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_16_R3.network.EmptyNetworkManager;
@ -182,7 +183,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
public IChatBaseComponent getPlayerListName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new ChatComponentText("");
return super.getPlayerListName();
return npc != null ? (IChatBaseComponent) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getPlayerListName();
}
@Override

View File

@ -19,6 +19,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_17_R1.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_17_R1.network.EmptyNetworkManager;
@ -223,7 +224,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
public Component getTabListDisplayName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new TextComponent("");
return super.getTabListDisplayName();
return npc != null ? (Component) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getTabListDisplayName();
}
@Override

View File

@ -20,6 +20,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_18_R2.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_18_R2.network.EmptyNetworkManager;
@ -224,7 +225,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
public Component getTabListDisplayName() {
if (npc != null && npc.shouldRemoveFromTabList())
return new TextComponent("");
return super.getTabListDisplayName();
return npc != null ? (Component) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getTabListDisplayName();
}
@Override

View File

@ -19,6 +19,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_19_R3.network.EmptyNetHandler;
import net.citizensnpcs.nms.v1_19_R3.network.EmptyNetworkManager;
@ -218,7 +219,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
public Component getTabListDisplayName() {
if (npc != null && npc.shouldRemoveFromTabList())
return MutableComponent.create(new LiteralContents(""));
return super.getTabListDisplayName();
return npc != null ? (Component) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getTabListDisplayName();
}
@Override

View File

@ -17,6 +17,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.nms.v1_20_R4.network.EmptyConnection;
import net.citizensnpcs.nms.v1_20_R4.network.EmptyPacketListener;
@ -220,7 +221,8 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
public Component getTabListDisplayName() {
if (npc != null && npc.shouldRemoveFromTabList())
return MutableComponent.create(new LiteralContents(""));
return super.getTabListDisplayName();
return npc != null ? (Component) Messaging.minecraftComponentFromRawMessage(npc.getRawName())
: super.getTabListDisplayName();
}
@Override