mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-31 13:37:40 +01:00
fix: hologram issues (#3195)
* fix: force hologram entity names to be updated * fix: possibly NPE * fix: delay placeholder computing
This commit is contained in:
parent
d068180179
commit
cc17c48df3
@ -533,7 +533,7 @@ public class HologramTrait extends Trait {
|
|||||||
|
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
this.text = text == null ? "" : text;
|
this.text = text == null ? "" : text;
|
||||||
if (ITEM_MATCHER.matcher(text).find() && !(renderer instanceof ItemRenderer)) {
|
if (ITEM_MATCHER.matcher(this.text).find() && !(renderer instanceof ItemRenderer)) {
|
||||||
renderer.destroy();
|
renderer.destroy();
|
||||||
mb = 0.21;
|
mb = 0.21;
|
||||||
mt = 0.07;
|
mt = 0.07;
|
||||||
@ -866,7 +866,13 @@ public class HologramTrait extends Trait {
|
|||||||
this.text = raw;
|
this.text = raw;
|
||||||
if (hologram == null)
|
if (hologram == null)
|
||||||
return;
|
return;
|
||||||
hologram.setName(Placeholders.replace(text, null, npc));
|
if (hologram.isSpawned()) {
|
||||||
|
final String updatedName = Placeholders.replace(text, null, npc);
|
||||||
|
final Entity hologramEntity = hologram.getEntity();
|
||||||
|
hologramEntity.setCustomName(null);
|
||||||
|
// Use underlying Bukkit API to suppress rename event
|
||||||
|
hologramEntity.setCustomName(updatedName);
|
||||||
|
}
|
||||||
if (!Placeholders.containsPlaceholders(text)) {
|
if (!Placeholders.containsPlaceholders(text)) {
|
||||||
hologram.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, Messaging.stripColor(text).length() > 0);
|
hologram.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, Messaging.stripColor(text).length() > 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user