mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-14 20:21:45 +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 main.java.com.djrapitops.plan.database.Database;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
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.
|
* 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> playerNames;
|
||||||
private final Map<UUID, String> displayNames;
|
private final Map<UUID, String> displayNames;
|
||||||
|
|
||||||
private final Set<UUID> playersWithFirstSession;
|
private final Map<UUID, Integer> firstSessionInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor.
|
* Class Constructor.
|
||||||
@ -41,7 +44,7 @@ public class DataCache extends SessionCache {
|
|||||||
|
|
||||||
playerNames = new HashMap<>();
|
playerNames = new HashMap<>();
|
||||||
displayNames = new HashMap<>();
|
displayNames = new HashMap<>();
|
||||||
playersWithFirstSession = new HashSet<>();
|
firstSessionInformation = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNames(UUID uuid, String playerName, String displayName) {
|
public void updateNames(UUID uuid, String playerName, String displayName) {
|
||||||
@ -70,14 +73,24 @@ public class DataCache extends SessionCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addFirstLeaveCheck(UUID uuid) {
|
public void addFirstLeaveCheck(UUID uuid) {
|
||||||
playersWithFirstSession.add(uuid);
|
firstSessionInformation.put(uuid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirstSession(UUID uuid) {
|
public boolean isFirstSession(UUID uuid) {
|
||||||
return playersWithFirstSession.contains(uuid);
|
return firstSessionInformation.containsKey(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearFromFirstLeaveCheck(UUID uuid) {
|
public void endFirstSessionActionTracking(UUID uuid) {
|
||||||
playersWithFirstSession.remove(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 name = p.getName();
|
||||||
String displayName = p.getDisplayName();
|
String displayName = p.getDisplayName();
|
||||||
|
|
||||||
|
DataCache dataCache = plugin.getDataCache();
|
||||||
|
if (dataCache.isFirstSession(uuid)) {
|
||||||
|
dataCache.firstSessionMessageSent(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName));
|
plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class PlanPlayerListener implements Listener {
|
|||||||
new EndSessionProcessor(uuid, time)
|
new EndSessionProcessor(uuid, time)
|
||||||
);
|
);
|
||||||
|
|
||||||
int messagesSent = 0; // TODO messages Sent on first session
|
int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid);
|
||||||
|
|
||||||
if (cache.isFirstSession(uuid)) {
|
if (cache.isFirstSession(uuid)) {
|
||||||
plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent));
|
plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent));
|
||||||
|
@ -36,7 +36,7 @@ public class FirstLeaveProcessor extends PlayerProcessor {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
} finally {
|
} finally {
|
||||||
plugin.getDataCache().clearFromFirstLeaveCheck(uuid);
|
plugin.getDataCache().endFirstSessionActionTracking(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user