mirror of
https://github.com/YouHaveTrouble/NotJustNameplates.git
synced 2026-05-12 06:26:58 +00:00
properly remove orphan nameplates
This commit is contained in:
@@ -30,7 +30,10 @@ public class NameplateManager implements Listener {
|
|||||||
// Remove all orphan nameplates
|
// Remove all orphan nameplates
|
||||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> Bukkit.getWorlds().forEach(world -> world.getEntities().forEach(entity -> {
|
Bukkit.getScheduler().runTaskTimer(plugin, () -> Bukkit.getWorlds().forEach(world -> world.getEntities().forEach(entity -> {
|
||||||
if (!(entity instanceof TextDisplay textDisplay)) return;
|
if (!(entity instanceof TextDisplay textDisplay)) return;
|
||||||
if (textDisplay.getPersistentDataContainer().has(Nameplate.NAMEPLATE_KEY)) return;
|
if (!textDisplay.getPersistentDataContainer().has(Nameplate.NAMEPLATE_KEY)) return;
|
||||||
|
for (Nameplate nameplate : nameplates.values()) {
|
||||||
|
if (nameplate.getEntity() == textDisplay) return;
|
||||||
|
}
|
||||||
textDisplay.remove();
|
textDisplay.remove();
|
||||||
})), 100, 100);
|
})), 100, 100);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user