-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Layout - Implement latency updating for player slots (#545)
- Loading branch information
NEZNAMY
committed
Mar 31, 2022
1 parent
6d922d5
commit a8b0b48
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
shared/src/main/java/me/neznamy/tab/shared/features/layout/LayoutLatencyRefresher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.neznamy.tab.shared.features.layout; | ||
|
||
import me.neznamy.tab.api.TabFeature; | ||
import me.neznamy.tab.api.TabPlayer; | ||
import me.neznamy.tab.api.protocol.PacketPlayOutPlayerInfo; | ||
import me.neznamy.tab.shared.TAB; | ||
import me.neznamy.tab.shared.TabConstants; | ||
|
||
public class LayoutLatencyRefresher extends TabFeature { | ||
|
||
private final LayoutManager manager; | ||
|
||
public LayoutLatencyRefresher(LayoutManager manager) { | ||
super(manager.getFeatureName(), "Updating latency"); | ||
this.manager = manager; | ||
TAB.getInstance().getPlaceholderManager().addUsedPlaceholder("%ping%", this); | ||
} | ||
|
||
@Override | ||
public void refresh(TabPlayer p, boolean force) { | ||
for (TabPlayer all : TAB.getInstance().getOnlinePlayers()) { | ||
PlayerSlot slot = manager.getPlayerViews().get(all).getSlot(p); | ||
if (slot != null) { | ||
all.sendCustomPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, | ||
new PacketPlayOutPlayerInfo.PlayerInfoData(slot.getUUID(), p.getPing())), TabConstants.PacketCategory.LAYOUT_LATENCY); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters