diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java index bbda075ec..c6d416b66 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/cache/DataCache.java @@ -5,7 +5,10 @@ import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.database.Database; import java.sql.SQLException; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; /** * This Class contains the Cache. @@ -25,7 +28,7 @@ public class DataCache extends SessionCache { private final Map playerNames; private final Map displayNames; - private final Set playersWithFirstSession; + private final Map firstSessionInformation; /** * Class Constructor. @@ -41,7 +44,7 @@ public class DataCache extends SessionCache { playerNames = new HashMap<>(); displayNames = new HashMap<>(); - playersWithFirstSession = new HashSet<>(); + firstSessionInformation = new HashMap<>(); } public void updateNames(UUID uuid, String playerName, String displayName) { @@ -70,14 +73,24 @@ public class DataCache extends SessionCache { } public void addFirstLeaveCheck(UUID uuid) { - playersWithFirstSession.add(uuid); + firstSessionInformation.put(uuid, 0); } public boolean isFirstSession(UUID uuid) { - return playersWithFirstSession.contains(uuid); + return firstSessionInformation.containsKey(uuid); } - public void clearFromFirstLeaveCheck(UUID uuid) { - playersWithFirstSession.remove(uuid); + public void endFirstSessionActionTracking(UUID uuid) { + firstSessionInformation.remove(uuid); + } + + public void firstSessionMessageSent(UUID uuid) { + Integer msgCount = firstSessionInformation.getOrDefault(uuid, 0); + msgCount++; + firstSessionInformation.put(uuid, msgCount); + } + + public int getFirstSessionMsgCount(UUID uuid) { + return firstSessionInformation.getOrDefault(uuid, 0); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java index 42a0a75e2..a11e7637b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanChatListener.java @@ -47,6 +47,11 @@ public class PlanChatListener implements Listener { String name = p.getName(); String displayName = p.getDisplayName(); + DataCache dataCache = plugin.getDataCache(); + if (dataCache.isFirstSession(uuid)) { + dataCache.firstSessionMessageSent(uuid); + } + plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName)); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java index 861c63fdb..5f8d4237c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/listeners/PlanPlayerListener.java @@ -122,7 +122,7 @@ public class PlanPlayerListener implements Listener { new EndSessionProcessor(uuid, time) ); - int messagesSent = 0; // TODO messages Sent on first session + int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid); if (cache.isFirstSession(uuid)) { plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent)); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java index bacd74238..116d1d665 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/processing/player/FirstLeaveProcessor.java @@ -36,7 +36,7 @@ public class FirstLeaveProcessor extends PlayerProcessor { } catch (SQLException e) { Log.toLog(this.getClass().getName(), e); } finally { - plugin.getDataCache().clearFromFirstLeaveCheck(uuid); + plugin.getDataCache().endFirstSessionActionTracking(uuid); } } } \ No newline at end of file