diff --git a/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologramLine.java b/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologramLine.java index 0fbc4183..0ecb2e27 100644 --- a/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologramLine.java +++ b/common/src/main/java/me/filoghost/holographicdisplays/common/hologram/StandardHologramLine.java @@ -15,4 +15,6 @@ public interface StandardHologramLine extends StandardHologramComponent { double getHeight(); + void setChanged(); + } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java index eff987c2..01622d77 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/api/APIHologram.java @@ -101,6 +101,9 @@ public class APIHologram extends BaseHologram implements Hologr } this.allowPlaceholders = allowPlaceholders; + for (APIHologramLine line : getLines()) { + line.setChanged(); + } } @Override diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java index 39baf1de..7914c8e5 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/base/BaseHologramLine.java @@ -30,7 +30,8 @@ public abstract class BaseHologramLine extends BaseHologramComponent implements return hologram; } - protected void setChanged() { + @Override + public void setChanged() { tracker.setLineChanged(); } diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/DisplayText.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/DisplayText.java index 8741a929..9e80ba60 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/DisplayText.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/DisplayText.java @@ -26,7 +26,7 @@ class DisplayText { void set(@Nullable String textString) { textWithoutReplacements = StringWithPlaceholders.of(textString); - textWithGlobalReplacements = null; + textWithGlobalReplacements = textWithoutReplacements; } String get() { diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java index 48665f0a..1c652a8d 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/plugin/hologram/tracking/TextLineTracker.java @@ -20,6 +20,7 @@ public class TextLineTracker extends TouchableLineTracker { private final DisplayText displayText; private boolean displayTextChanged; + private boolean allowPlaceholders; public TextLineTracker(StandardTextLine line, NMSManager nmsManager, PlaceholderTracker placeholderTracker) { super(line, nmsManager); @@ -29,6 +30,10 @@ public class TextLineTracker extends TouchableLineTracker { @Override protected boolean updatePlaceholders() { + if (!allowPlaceholders) { + return false; + } + boolean placeholdersChanged = displayText.updateGlobalReplacements(); if (placeholdersChanged) { displayTextChanged = true; // Mark as changed to trigger a packet send with updated placeholders @@ -46,6 +51,12 @@ public class TextLineTracker extends TouchableLineTracker { this.displayText.set(displayText); this.displayTextChanged = true; } + + boolean allowPlaceholders = line.isAllowPlaceholders(); + if (this.allowPlaceholders != allowPlaceholders) { + this.allowPlaceholders = allowPlaceholders; + this.displayTextChanged = true; + } } @MustBeInvokedByOverriders @@ -60,7 +71,9 @@ public class TextLineTracker extends TouchableLineTracker { protected void addSpawnPackets(NMSPacketList packetList) { super.addSpawnPackets(packetList); - if (displayText.containsIndividualPlaceholders()) { + if (!allowPlaceholders) { + packetList.addArmorStandSpawnPackets(armorStandEntityID, locationX, getArmorStandLocationY(), locationZ, displayText.get()); + } else if (displayText.containsIndividualPlaceholders()) { packetList.addArmorStandSpawnPackets(armorStandEntityID, locationX, getArmorStandLocationY(), locationZ, displayText::getWithIndividualReplacements); } else { packetList.addArmorStandSpawnPackets(armorStandEntityID, locationX, getArmorStandLocationY(), locationZ, displayText.getWithGlobalReplacements()); @@ -79,7 +92,9 @@ public class TextLineTracker extends TouchableLineTracker { super.addChangesPackets(packetList); if (displayTextChanged) { - if (displayText.containsIndividualPlaceholders()) { + if (!allowPlaceholders) { + packetList.addArmorStandNameChangePackets(armorStandEntityID, displayText.get()); + } else if (displayText.containsIndividualPlaceholders()) { packetList.addArmorStandNameChangePackets(armorStandEntityID, displayText::getWithIndividualReplacements); } else { packetList.addArmorStandNameChangePackets(armorStandEntityID, displayText.getWithGlobalReplacements());