# v1.0.11
Performance fix for servers with 100+ players where mass teleportation caused severe lag from redundant nametag packet storms.
---
## Fixed
### Mass Teleport Performance (O(N²) → O(N))
When many players teleported simultaneously, the plugin would call `updateVisibilityForAll()` on **every other nametag** for each teleporting player. With 100 players teleporting, this produced ~1,000,000 visibility checks and a massive spike in packet sends, causing server-wide lag.
The root cause was in the teleport, world change, respawn, and player load event handlers — each one iterated all nametags and recalculated visibility against **all online players**, rather than just the single player who triggered the event.
**Before:** Each teleport triggered N full visibility recalculations (one per nametag), each iterating N online players = O(N²) per event.
**After:** Each teleport triggers N targeted single-viewer checks = O(N) per event.
### Debounced Teleport Refresh Scheduling
Rapid consecutive teleports for the same player (e.g. chain teleportation, portal loops) previously stacked independent 20-tick delayed tasks that all fired on the same tick. Now, each new teleport cancels the player's pending refresh before scheduling a new one — only the latest teleport's refresh executes.
### Redundant Packet Listener Work During Teleports
The `DESTROY_ENTITIES` packet interceptor was scheduling its own hide/show cycle for nametags whose owning player was already being handled by the teleport event handler. Both paths would fire 20 ticks later, producing duplicate despawn/spawn packets for every viewer. The packet listener now skips players with a pending teleport refresh.
### `hideForAll()` Iterated All Online Players
`hideForAll()` previously looped over every online player to send destroy packets, even those who were never shown the nametag. It now only iterates the actual viewer set, avoiding unnecessary work. On a 100-player server where a nametag is visible to 20 nearby players, this eliminates 80% of destroy packets.
---
## Changed
- **`updateVisibilityFor(Player viewer)`** added to `INametag` API — allows targeted single-viewer visibility recalculation without iterating all online players.
---
## Developer Notes
### New API: `updateVisibilityFor(Player viewer)`
A new method on `INametag` enables targeted visibility updates for a single viewer:
```java
INametag nametag = SignAPI.getNametagManager().get(player);
nametag.updateVisibilityFor(viewer); // Only checks/updates for this one viewer
```
This is significantly cheaper than `updateVisibilityForAll()` when you know only one viewer's state has changed (e.g. after a teleport or world change). The full `updateVisibilityForAll()` method is still available and used by the periodic scheduler for text/metadata updates.