From 8f887cc22dfe601b0cdf3382189a95f39398996f Mon Sep 17 00:00:00 2001 From: Pugzy Date: Mon, 24 Jul 2023 17:39:35 +0100 Subject: [PATCH] Remove present checks and update getters Signed-off-by: Pugzy --- .../main/java/tc/oc/pgm/stats/StatsMatchModule.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/stats/StatsMatchModule.java b/core/src/main/java/tc/oc/pgm/stats/StatsMatchModule.java index f82a2e8910..0f47c8418d 100644 --- a/core/src/main/java/tc/oc/pgm/stats/StatsMatchModule.java +++ b/core/src/main/java/tc/oc/pgm/stats/StatsMatchModule.java @@ -14,6 +14,7 @@ import java.time.Duration; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -52,7 +53,6 @@ import tc.oc.pgm.api.player.event.MatchPlayerDeathEvent; import tc.oc.pgm.api.setting.SettingKey; import tc.oc.pgm.api.setting.SettingValue; -import tc.oc.pgm.controlpoint.events.ControlPointEvent; import tc.oc.pgm.core.CoreLeakEvent; import tc.oc.pgm.destroyable.DestroyableDestroyedEvent; import tc.oc.pgm.destroyable.DestroyableHealthChange; @@ -107,11 +107,11 @@ public StatsMatchModule(Match match) { this.match = match; } - public Map getGlobalStats() { - return allPlayerStats; + public Map getStats() { + return Collections.unmodifiableMap(allPlayerStats); } - public Table getStats() { + public Table getParticipationStats() { return Tables.unmodifiableTable(stats); } @@ -172,7 +172,6 @@ public void onCoreLeak(CoreLeakEvent event) { .forEach( leaker -> { if (leaker.getPlayerState() != null) { - // TODO: wrong method getPlayerStat(leaker.getPlayerState()).onCoreLeak(); } }); @@ -180,7 +179,7 @@ public void onCoreLeak(CoreLeakEvent event) { @EventHandler(priority = EventPriority.MONITOR) public void onGoalTouch(GoalTouchEvent event) { - if (event.getPlayer() == null || !event.getPlayer().getPlayer().isPresent()) return; + if (event.getPlayer() == null) return; if (event.getGoal() instanceof MonumentWool) { if (event.isFirstForPlayer()) { @@ -195,7 +194,7 @@ public void onGoalTouch(GoalTouchEvent event) { @EventHandler(priority = EventPriority.MONITOR) public void onWoolCapture(PlayerWoolPlaceEvent event) { - if (event.getPlayer() != null && event.getPlayer().getPlayer().isPresent()) { + if (event.getPlayer() != null) { getPlayerStat(event.getPlayer()).onWoolCapture(); } }