use of org.terasology.engine.logic.afk.AfkComponent in project Terasology by MovingBlocks.
the class OnlinePlayersOverlay method determinePlayerAndPing.
private String determinePlayerAndPing(PingStockComponent pingStockComponent) {
Map<EntityRef, Long> pingMap = pingStockComponent.getValues();
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Map.Entry<EntityRef, Long> entry : pingMap.entrySet()) {
EntityRef clientEntity = entry.getKey();
if (clientEntity == null || clientEntity.getComponent(ClientComponent.class) == null) {
logger.warn("OnlinePlayersOverlay skipping a null client entity or component");
continue;
}
if (!first) {
sb.append("\n");
}
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
AfkComponent afkComponent = clientEntity.getComponent(AfkComponent.class);
if (afkComponent != null) {
if (afkComponent.afk) {
sb.append(FontColor.getColored("[AFK]", Color.red));
sb.append(" ");
}
}
sb.append(PlayerUtil.getColoredPlayerName(clientComp.clientInfo));
sb.append(" ");
Long pingValue = pingMap.get(clientEntity);
if (pingValue == null) {
sb.append("-");
} else {
sb.append(pingValue.toString());
sb.append("ms");
}
first = false;
}
return sb.toString();
}
Aggregations