mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-14 04:01:58 +01:00
First Session Message Counting
This commit is contained in:
parent
caece02f63
commit
d9a9c653da
@ -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<UUID, String> playerNames;
|
||||
private final Map<UUID, String> displayNames;
|
||||
|
||||
private final Set<UUID> playersWithFirstSession;
|
||||
private final Map<UUID, Integer> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user