Add join address to player pages

- On the main information card
- On each servers accordion

Affects issues:
- Close #2255
This commit is contained in:
Risto Lahtela 2022-01-30 11:07:17 +02:00
parent 019b59128f
commit 18ea0aac8c
8 changed files with 24 additions and 1 deletions

View File

@ -48,6 +48,7 @@ public class PerServerContainer extends HashMap<ServerUUID, DataContainer> {
putToContainerOfServer(serverUUID, PerServerKeys.REGISTERED, userInfo.getRegistered());
putToContainerOfServer(serverUUID, PerServerKeys.BANNED, userInfo.isBanned());
putToContainerOfServer(serverUUID, PerServerKeys.OPERATOR, userInfo.isOperator());
putToContainerOfServer(serverUUID, PerServerKeys.JOIN_ADDRESS, userInfo.getJoinAddress());
}
public void putUserInfo(Collection<UserInfo> userInformation) {

View File

@ -55,6 +55,7 @@ public class CommonKeys {
public static final Key<Boolean> BANNED = new Key<>(Boolean.class, "banned");
public static final Key<Boolean> OPERATOR = new Key<>(Boolean.class, "operator");
public static final Key<String> JOIN_ADDRESS = new Key<>(String.class, "join_address");
public static final Key<SessionsMutator> SESSIONS_MUTATOR = new Key<>(SessionsMutator.class, "SESSIONS_MUTATOR");
public static final Key<TPSMutator> TPS_MUTATOR = new Key<>(TPSMutator.class, "TPS_MUTATOR");

View File

@ -55,5 +55,6 @@ public class PerServerKeys {
public static final Key<Boolean> BANNED = CommonKeys.BANNED;
public static final Key<Boolean> OPERATOR = CommonKeys.OPERATOR;
public static final Key<String> JOIN_ADDRESS = CommonKeys.JOIN_ADDRESS;
}

View File

@ -114,4 +114,18 @@ public class PerServerMutator {
}
return false;
}
public Optional<String> latestJoinAddress() {
long latest = Long.MIN_VALUE;
String latestJoinAddress = null;
for (DataContainer value : data.values()) {
long registerDate = value.getValue(PerServerKeys.REGISTERED).orElse(Long.MIN_VALUE);
Optional<String> joinAddress = value.getValue(PerServerKeys.JOIN_ADDRESS);
if (registerDate > latest && joinAddress.isPresent()) {
latest = registerDate;
latestJoinAddress = joinAddress.get();
}
}
return Optional.ofNullable(latestJoinAddress);
}
}

View File

@ -182,6 +182,7 @@ public class PlayerJSONCreator {
info.put("activity_index", decimals.apply(activityIndex.getValue()));
info.put("activity_index_group", activityIndex.getGroup());
info.put("favorite_server", perServer.favoriteServer().map(favoriteServer -> serverNames.getOrDefault(favoriteServer, favoriteServer.toString())).orElse(locale.getString(GenericLang.UNKNOWN)));
info.put("latest_join_address", perServer.latestJoinAddress().orElse("-"));
double averagePing = ping.average();
int worstPing = ping.max();
int bestPing = ping.min();

View File

@ -83,6 +83,7 @@ public class ServerAccordion {
server.put("operator", ofServer.getValue(PerServerKeys.OPERATOR).orElse(false));
server.put("registered", year.apply(ofServer.getValue(PerServerKeys.REGISTERED).orElse(0L)));
server.put("last_seen", year.apply(sessionsMutator.toLastSeen()));
server.put("join_address", ofServer.getValue(PerServerKeys.JOIN_ADDRESS).orElse("-"));
server.put("session_count", sessionsMutator.count());
server.put("playtime", timeAmount.apply(sessionsMutator.toPlaytime()));

View File

@ -30,6 +30,7 @@ function loadPlayerOverviewValues(json, error) {
$(element).find("#data_activity_index").text(data.activity_index);
$(element).find("#data_activity_index_group").text(data.activity_index_group);
$(element).find("#data_favorite_server").text(data.favorite_server);
$(element).find("#data_latest_join_address").text(data.latest_join_address);
$(element).find("#data_average_ping").text(data.average_ping);
$(element).find("#data_best_ping").text(data.best_ping);
$(element).find("#data_worst_ping").text(data.worst_ping);
@ -223,6 +224,8 @@ function createserverAccordionBody(i, server) {
`<p><i class="col-teal far fa-fw fa-clock"></i> Longest Session<span class="float-end"><b>` + server.longest_session_length + `</b></span></p>` +
`<p><i class="col-teal far fa-fw fa-clock"></i> Session Median<span class="float-end"><b>` + server.session_median + `</b></span></p>` +
`<br>` +
`<p><i class="col-amber fa fa-fw fa-location-arrow"></i> Join Address<span class="float-end">` + server.join_address + `</span></p>` +
`<br>` +
`<p><i class="col-red fa fa-fw fa-crosshairs"></i> Player Kills<span class="float-end"><b>` + server.player_kills + `</b></span></p>` +
`<p><i class="col-green fa fa-fw fa-crosshairs"></i> Mob Kills<span class="float-end"><b>` + server.mob_kills + `</b></span></p>` +
`<p><i class=" fa fa-fw fa-skull"></i> Deaths<span class="float-end"><b>` + server.deaths + `</b></span></p>` +

View File

@ -184,7 +184,8 @@
id="data_activity_index_group"></span>)</span></p>
<p><i class="col-green fa fa-fw fa-server"></i> Favorite Server <span
class="float-end" id="data_favorite_server"></span></p>
<p>&nbsp; </p>
<p><i class="col-amber fa fa-fw fa-location-arrow"></i> Join Address<span
class="float-end" id="data_latest_join_address"></span></p>
<hr>
<p><i class="col-amber fa fa-fw fa-signal"></i> Average Ping <span
class="float-end" id="data_average_ping"></span></p>