Skip to content

Commit

Permalink
Adjust requiresNameHologram
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 25, 2022
1 parent 1abf272 commit a2f7286
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Expand Up @@ -50,6 +50,8 @@
import net.citizensnpcs.api.util.SpigotUtil;

public abstract class AbstractNPC implements NPC {
protected Object coloredNameComponentCache;
protected String coloredNameStringCache;
private final GoalController goalController = new SimpleGoalController();
private final int id;
private Supplier<ItemStack> itemProvider = () -> {
Expand Down Expand Up @@ -90,8 +92,6 @@ public void setPersistent(String key, Object data) {
}
};
private String name;
protected Object coloredNameComponentCache;
protected String coloredNameStringCache;
private final NPCRegistry registry;
private final List<String> removedTraits = Lists.newArrayList();
private final List<Runnable> runnables = Lists.newArrayList();
Expand Down Expand Up @@ -241,7 +241,8 @@ protected EntityType getEntityType() {
@Override
public String getFullName() {
int nameLength = SpigotUtil.getMaxNameLength(getEntityType());
String replaced = Placeholders.replace(Messaging.parseComponents(name), null, this);
String replaced = Placeholders.replace(
coloredNameStringCache != null ? coloredNameStringCache : Messaging.parseComponents(name), null, this);
if (replaced.length() > nameLength) {
Messaging.severe("ID", id, "created with name length greater than " + nameLength + ", truncating", replaced,
"to", replaced.substring(0, nameLength));
Expand Down Expand Up @@ -408,8 +409,9 @@ public void removeTrait(Class<? extends Trait> traitClass) {
public boolean requiresNameHologram() {
return getEntityType() != EntityType.ARMOR_STAND
&& ((name.length() > 16 && getEntityType() == EntityType.PLAYER)
|| data().get(NPC.ALWAYS_USE_NAME_HOLOGRAM_METADATA, false) || name.contains("&x")
|| name.contains("§x") || !Placeholders.replace(name, null, this).equals(name));
|| data().get(NPC.ALWAYS_USE_NAME_HOLOGRAM_METADATA, false)
|| (coloredNameStringCache != null && coloredNameStringCache.contains("§x"))
|| !Placeholders.replace(name, null, this).equals(name));
}

@Override
Expand Down

0 comments on commit a2f7286

Please sign in to comment.