Fixed player page kills formatting

This commit is contained in:
Rsl1122 2019-08-25 11:26:05 +03:00
parent 5021ada67f
commit 78654d6552
4 changed files with 16 additions and 3 deletions

View File

@ -113,4 +113,8 @@ public class PlayerKill implements DateHolder {
"date=" + date + ", " + "date=" + date + ", " +
"weapon='" + weapon + "'}"; "weapon='" + weapon + "'}";
} }
public boolean isSelfKill() {
return getVictimName().map(v -> v.equals(killerName)).orElse(false);
}
} }

View File

@ -37,6 +37,10 @@ public class PlayerKillMutator {
this.kills = kills; this.kills = kills;
} }
public PlayerKillMutator filterNonSelfKills() {
return new PlayerKillMutator(kills.stream().filter(PlayerKill::isSelfKill).collect(Collectors.toList()));
}
public List<Map<String, Object>> toJSONAsMap(Formatters formatters) { public List<Map<String, Object>> toJSONAsMap(Formatters formatters) {
return kills.stream().map( return kills.stream().map(
kill -> { kill -> {

View File

@ -17,6 +17,7 @@
package com.djrapitops.plan.system.json; package com.djrapitops.plan.system.json;
import com.djrapitops.plan.data.container.GeoInfo; import com.djrapitops.plan.data.container.GeoInfo;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.store.containers.PlayerContainer; import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys; import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.mutators.*; import com.djrapitops.plan.data.store.mutators.*;
@ -89,6 +90,8 @@ public class PlayerJSONParser {
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player); SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
Map<UUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer(); Map<UUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer();
List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount).asMaps(); List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount).asMaps();
List<PlayerKill> kills = player.getValue(PlayerKeys.PLAYER_KILLS).orElse(Collections.emptyList());
List<PlayerKill> deaths = player.getValue(PlayerKeys.PLAYER_DEATHS_KILLS).orElse(Collections.emptyList());
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("info", createInfoJSONMap(player, serverNames)); data.put("info", createInfoJSONMap(player, serverNames));
@ -101,8 +104,8 @@ public class PlayerJSONParser {
data.put("connections", player.getValue(PlayerKeys.GEO_INFO) data.put("connections", player.getValue(PlayerKeys.GEO_INFO)
.map(geoInfo -> ConnectionInfo.fromGeoInfo(geoInfo, year)) .map(geoInfo -> ConnectionInfo.fromGeoInfo(geoInfo, year))
.orElse(Collections.emptyList())); .orElse(Collections.emptyList()));
data.put("player_kills", player.getValue(PlayerKeys.PLAYER_KILLS).orElse(Collections.emptyList())); data.put("player_kills", new PlayerKillMutator(kills).filterNonSelfKills().toJSONAsMap(formatters));
data.put("player_deaths", player.getValue(PlayerKeys.PLAYER_DEATHS_KILLS).orElse(Collections.emptyList())); data.put("player_deaths", new PlayerKillMutator(deaths).toJSONAsMap(formatters));
data.put("sessions", sessionsMutator.toServerNameJSONMaps(graphs, config.getWorldAliasSettings(), formatters)); data.put("sessions", sessionsMutator.toServerNameJSONMaps(graphs, config.getWorldAliasSettings(), formatters));
data.put("sessions_per_page", config.get(DisplaySettings.SESSIONS_PER_PAGE)); data.put("sessions_per_page", config.get(DisplaySettings.SESSIONS_PER_PAGE));
data.put("servers", serverAccordion); data.put("servers", serverAccordion);

View File

@ -104,7 +104,9 @@ function createKillsTable(player_kills) {
for (var i = 0; i < player_kills.length; i++) { for (var i = 0; i < player_kills.length; i++) {
var kill = player_kills[i]; var kill = player_kills[i];
table += '<tr><td>' + kill.date + '</td>' + table += '<tr><td>' + kill.date + '</td>' +
'<td>' + kill.killer + '<i class="fa fa-fw fa-angle-right col-red"></i>' + kill.victim + '</td>' + '<td>' + kill.killer +
(kill.killer === kill.victim ? '<i class="fa fa-fw fa-skull-crossbones col-red"></i>' : '<i class="fa fa-fw fa-angle-right col-red"></i>') +
kill.victim + '</td>' +
'<td>' + kill.weapon + '</td></tr>' '<td>' + kill.weapon + '</td></tr>'
} }