mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-24 03:15:12 +01:00
Track placeholders when using setText()
This commit is contained in:
parent
cf2db447b8
commit
5064c989ed
@ -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()) {
|
||||
nmsNameble.setCustomNameNMS(text);
|
||||
if (nmsNameble != null) {
|
||||
if (text != null && !text.isEmpty()) {
|
||||
nmsNameble.setCustomNameNMS(text);
|
||||
} else {
|
||||
nmsNameble.setCustomNameNMS(null);
|
||||
}
|
||||
|
||||
if (getParent().isAllowPlaceholders()) {
|
||||
PlaceholdersManager.trackIfNecessary(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,6 +152,6 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftTextLine [text=" + text + "]";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class PlaceholdersManager {
|
||||
|
||||
public static void load(Plugin plugin) {
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -131,7 +131,7 @@ public class PlaceholdersManager {
|
||||
}
|
||||
|
||||
|
||||
// Players in a world count pattern.
|
||||
// Players in a world count pattern.
|
||||
matcher = WORLD_PATTERN.matcher(name);
|
||||
while (matcher.find()) {
|
||||
|
||||
@ -168,7 +168,7 @@ public class PlaceholdersManager {
|
||||
return String.valueOf(BungeeServerTracker.getPlayersOnline(serverName));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Animation pattern.
|
||||
matcher = ANIMATION_PATTERN.matcher(name);
|
||||
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user