use of com.djrapitops.plan.delivery.rendering.html.Html in project Plan by plan-player-analytics.
the class PlayersTableJSONCreator method addPlayerData.
private void addPlayerData(Map<String, Object> dataJson, TablePlayer player) {
String name = player.getName().orElse(player.getPlayerUUID().toString());
String url = (playersPage ? "./player/" : "../player/") + Html.encodeToURL(player.getPlayerUUID().toString());
int loginTimes = player.getSessionCount().orElse(0);
long activePlaytime = player.getActivePlaytime().orElse(-1L);
long registered = player.getRegistered().orElse(-1L);
long lastSeen = player.getLastSeen().orElse(-1L);
ActivityIndex activityIndex = player.getCurrentActivityIndex().orElseGet(() -> new ActivityIndex(0.0, 0));
boolean isBanned = player.isBanned();
String activityString = activityIndex.getFormattedValue(decimalFormatter) + (isBanned ? " (<b>" + locale.get(HtmlLang.LABEL_BANNED) + "</b>)" : " (" + activityIndex.getGroup() + ")");
String geolocation = player.getGeolocation().orElse("-");
Html link = openPlayerPageInNewTab ? Html.LINK_EXTERNAL : Html.LINK;
putDataEntry(dataJson, link.create(url, StringUtils.replace(StringEscapeUtils.escapeHtml4(name), "\\", "\\\\")), "name");
putDataEntry(dataJson, activityIndex.getValue(), activityString, "index");
putDataEntry(dataJson, activePlaytime, numberFormatters.get(FormatType.TIME_MILLISECONDS).apply(activePlaytime), "activePlaytime");
putDataEntry(dataJson, loginTimes, "sessions");
putDataEntry(dataJson, registered, numberFormatters.get(FormatType.DATE_YEAR).apply(registered), "registered");
putDataEntry(dataJson, lastSeen, numberFormatters.get(FormatType.DATE_YEAR).apply(lastSeen), "seen");
putDataEntry(dataJson, geolocation, "geolocation");
}
Aggregations