Track placeholders when using setText()

This commit is contained in:
filoghost 2014-12-23 11:42:52 +01:00
parent cf2db447b8
commit 5064c989ed
2 changed files with 20 additions and 8 deletions

View File

@ -10,6 +10,7 @@ import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSRideable;
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
import com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager;
import com.gmail.filoghost.holographicdisplays.util.Offsets;
public class CraftTextLine extends CraftTouchableLine implements TextLine {
@ -37,8 +38,16 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
public void setText(String text) {
this.text = text;
if (nmsNameble != null && text != null && !text.isEmpty()) {
if (nmsNameble != null) {
if (text != null && !text.isEmpty()) {
nmsNameble.setCustomNameNMS(text);
} else {
nmsNameble.setCustomNameNMS(null);
}
if (getParent().isAllowPlaceholders()) {
PlaceholdersManager.trackIfNecessary(this);
}
}
}

View File

@ -212,10 +212,13 @@ public class PlaceholdersManager {
}
// It could be already tracked!
if (linesToUpdate.add(lineData)) {
updatePlaceholders(lineData);
if (!linesToUpdate.add(lineData)) {
linesToUpdate.remove(lineData);
linesToUpdate.add(lineData);
}
updatePlaceholders(lineData);
} else {
// The name needs to be updated anyways.