mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Calculating server times from sessions is now possible
This commit is contained in:
parent
f618a2466e
commit
5577771231
@ -107,7 +107,7 @@ public class PlayerProfile implements OfflinePlayer {
|
||||
UUID maxServer = null;
|
||||
for (Map.Entry<UUID, WorldTimes> entry : getWorldTimesPerServer().entrySet()) {
|
||||
long playTime = entry.getValue().getTotal();
|
||||
if (playTime < max) {
|
||||
if (playTime > max) {
|
||||
max = playTime;
|
||||
maxServer = entry.getKey();
|
||||
}
|
||||
@ -499,4 +499,23 @@ public class PlayerProfile implements OfflinePlayer {
|
||||
public void setOp(boolean b) {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
public void calculateWorldTimesPerServer() {
|
||||
if (worldTimesMap.containsKey(MiscUtils.getIPlan().getServerUuid())) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<UUID, List<Session>> entry : sessions.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
List<Session> sessions = entry.getValue();
|
||||
|
||||
WorldTimes times = worldTimesMap.getOrDefault(serverUUID, new WorldTimes(new HashMap<>()));
|
||||
for (Session session : sessions) {
|
||||
WorldTimes worldTimes = session.getWorldTimes();
|
||||
times.add(worldTimes);
|
||||
}
|
||||
worldTimesMap.put(serverUUID, times);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -158,4 +158,18 @@ public class WorldTimes {
|
||||
public String getCurrentWorld() {
|
||||
return currentWorld;
|
||||
}
|
||||
|
||||
public void add(WorldTimes toAdd) {
|
||||
Map<String, GMTimes> times = toAdd.getWorldTimes();
|
||||
for (Map.Entry<String, GMTimes> entry : times.entrySet()) {
|
||||
String worldName = entry.getKey();
|
||||
GMTimes gmTimes = entry.getValue();
|
||||
|
||||
GMTimes currentGMTimes = getGMTimes(worldName);
|
||||
for (String gm : GMTimes.getGMKeyArray()) {
|
||||
currentGMTimes.addTime(gm, gmTimes.getTime(gm));
|
||||
}
|
||||
worldTimes.put(worldName, currentGMTimes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,6 +257,7 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
Map<UUID, List<Session>> sessions = sessionsTable.getSessions(uuid);
|
||||
profile.setSessions(sessions);
|
||||
profile.calculateWorldTimesPerServer();
|
||||
profile.setTotalWorldTimes(worldTimesTable.getWorldTimesOfUser(uuid));
|
||||
|
||||
return profile;
|
||||
|
Loading…
Reference in New Issue
Block a user