Skip to content

Commit

Permalink
Respect name visibility properly
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 10, 2020
1 parent 44b6da4 commit 652a68a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java
Expand Up @@ -399,7 +399,7 @@ private void updateCustomName() {
if (!getEntity().isCustomNameVisible()
&& !data().<Object> get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString().equals("hover")) {
getEntity().setCustomName("");
} else {
} else if (!requiresNameHologram()) {
nameVisibility = true;
getEntity().setCustomName(getFullName());
}
Expand Down
12 changes: 10 additions & 2 deletions main/src/main/java/net/citizensnpcs/trait/HologramTrait.java
Expand Up @@ -77,9 +77,8 @@ public List<String> getLines() {
private void load() {
currentLoc = npc.getStoredLocation();
int i = 0;
if (npc.requiresNameHologram()) {
if (npc.requiresNameHologram() && npc.data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true)) {
nameNPC = createHologram(npc.getFullName(), 0);
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
}
for (String line : lines) {
hologramNPCs.add(createHologram(Placeholders.replace(line, null, npc), getHeight(i)));
Expand Down Expand Up @@ -114,6 +113,15 @@ public void run() {
unload();
return;
}
if (npc.requiresNameHologram()) {
boolean visible = npc.data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true);
if (nameNPC != null && !visible) {
nameNPC.destroy();
nameNPC = null;
} else if (nameNPC == null && visible) {
nameNPC = createHologram(npc.getFullName(), 0);
}
}
boolean update = currentLoc.distanceSquared(npc.getStoredLocation()) >= 0.01;
if (update) {
currentLoc = npc.getStoredLocation();
Expand Down

0 comments on commit 652a68a

Please sign in to comment.