mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-25 00:31:49 +01:00
Removed stuff related to Actions and old Analysis classes and MathUtils
This commit is contained in:
parent
b6e23acd8e
commit
a730c76543
@ -7,12 +7,8 @@ package com.djrapitops.plan;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.system.cache.CacheSystem;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
@ -57,7 +53,6 @@ public class ShutdownHook extends Thread {
|
||||
Map<UUID, Session> activeSessions = SessionCache.getActiveSessions();
|
||||
long now = System.currentTimeMillis();
|
||||
db = Database.getActive();
|
||||
saveFirstSessionInformation(db, now);
|
||||
saveActiveSessions(db, activeSessions, now);
|
||||
} catch (IllegalStateException ignored) {
|
||||
/* Database is not initialized */
|
||||
@ -74,22 +69,6 @@ public class ShutdownHook extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFirstSessionInformation(Database db, long now) throws DBInitException {
|
||||
DataCache dataCache = CacheSystem.getInstance().getDataCache();
|
||||
for (Map.Entry<UUID, Integer> entry : dataCache.getFirstSessionMsgCounts().entrySet()) {
|
||||
if (!db.isOpen()) {
|
||||
db.init();
|
||||
}
|
||||
try {
|
||||
UUID uuid = entry.getKey();
|
||||
int messagesSent = entry.getValue();
|
||||
db.save().action(uuid, new Action(now, Actions.FIRST_LOGOUT, "Messages sent: " + messagesSent));
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveActiveSessions(Database db, Map<UUID, Session> activeSessions, long now) throws DBInitException {
|
||||
for (Map.Entry<UUID, Session> entry : activeSessions.entrySet()) {
|
||||
UUID uuid = entry.getKey();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
@ -12,7 +12,6 @@ import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
@ -46,12 +45,14 @@ public class AnalyzeCommand extends CommandNode {
|
||||
try {
|
||||
Server server = getServer(args).orElseGet(ServerInfo::getServer);
|
||||
UUID serverUUID = server.getUuid();
|
||||
if (!ServerInfo.getServerUUID().equals(serverUUID) || !Analysis.isAnalysisBeingRun()) {
|
||||
|
||||
// TODO Create a new system to prevent multiple concurrent Analysis
|
||||
if (!ServerInfo.getServerUUID().equals(serverUUID)) {
|
||||
InfoSystem.getInstance().generateAnalysisPage(serverUUID);
|
||||
}
|
||||
sendWebUserNotificationIfNecessary(sender);
|
||||
sendLink(server, sender);
|
||||
} catch (DBException | WebException e) {
|
||||
} catch (DBOpException | WebException e) {
|
||||
sender.sendMessage("§cError occurred: " + e.toString());
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
@ -74,7 +75,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||
}
|
||||
|
||||
private void sendWebUserNotificationIfNecessary(ISender sender) throws DBException {
|
||||
private void sendWebUserNotificationIfNecessary(ISender sender) {
|
||||
if (WebServerSystem.getInstance().getWebServer().isAuthRequired() && CommandUtils.isPlayer(sender)) {
|
||||
|
||||
boolean senderHasWebUser = Database.getActive().check().doesWebUserExists(sender.getName());
|
||||
@ -84,7 +85,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<Server> getServer(String[] args) throws DBException {
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1 && ConnectionSystem.getInstance().isServerAvailable()) {
|
||||
Map<UUID, Server> bukkitServers = Database.getActive().fetch().getBukkitServers();
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.data;
|
||||
|
||||
import org.apache.commons.text.WordUtils;
|
||||
|
||||
/**
|
||||
* IDs of various actions
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public enum Actions {
|
||||
UNKNOWN(-1),
|
||||
FIRST_SESSION(1),
|
||||
FIRST_LOGOUT(2),
|
||||
NEW_NICKNAME(3),
|
||||
KILLED(-2); // Not stored in ActionsTable.
|
||||
|
||||
private final int id;
|
||||
|
||||
Actions(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Actions getById(int id) {
|
||||
for (Actions a : values()) {
|
||||
if (a.getId() == id) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return WordUtils.capitalizeFully(name(), '_').replace('_', ' ');
|
||||
}
|
||||
}
|
@ -1,463 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.comparators.ActionComparator;
|
||||
import com.djrapitops.plan.utilities.comparators.GeoInfoComparator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Data container object for a single player.
|
||||
* <p>
|
||||
* Created to streamline analysis and to make it easier to understand.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerProfile {
|
||||
|
||||
// Identification
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
|
||||
// Basic information
|
||||
private final long registered;
|
||||
private Map<UUID, Long> registeredMap;
|
||||
private Set<UUID> bannedOnServers;
|
||||
private Set<UUID> oppedOnServers;
|
||||
private int timesKicked;
|
||||
|
||||
// Activity related information
|
||||
private Map<UUID, List<Session>> sessions;
|
||||
private List<Action> actions;
|
||||
private Map<UUID, WorldTimes> worldTimesMap;
|
||||
|
||||
// Extra information
|
||||
private Map<UUID, List<String>> nicknames;
|
||||
private List<GeoInfo> geoInformation;
|
||||
|
||||
// Plugin data
|
||||
private Map<String, String> pluginReplaceMap;
|
||||
|
||||
// Value that requires lot of processing
|
||||
private Map<Long, ActivityIndex> activityIndexCache;
|
||||
|
||||
public PlayerProfile(UUID uuid, String name, long registered) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.registered = registered;
|
||||
registeredMap = new HashMap<>();
|
||||
|
||||
bannedOnServers = new HashSet<>();
|
||||
oppedOnServers = new HashSet<>();
|
||||
|
||||
sessions = new HashMap<>();
|
||||
actions = new ArrayList<>();
|
||||
worldTimesMap = new HashMap<>();
|
||||
|
||||
nicknames = new HashMap<>();
|
||||
geoInformation = new ArrayList<>();
|
||||
|
||||
pluginReplaceMap = new HashMap<>();
|
||||
activityIndexCache = new HashMap<>();
|
||||
}
|
||||
|
||||
public static long getPlaytime(Stream<Session> s) {
|
||||
return s.mapToLong(Session::getLength).sum();
|
||||
}
|
||||
|
||||
public static long getLongestSession(Stream<Session> s) {
|
||||
OptionalLong longestSession = s.mapToLong(Session::getLength).max();
|
||||
if (longestSession.isPresent()) {
|
||||
return longestSession.getAsLong();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static long getSessionMedian(Stream<Session> s) {
|
||||
List<Long> sessionLenghts = s.map(Session::getLength)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
if (sessionLenghts.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return sessionLenghts.get(sessionLenghts.size() / 2);
|
||||
}
|
||||
|
||||
public static long getSessionAverage(Stream<Session> s) {
|
||||
OptionalDouble average = s.map(Session::getLength)
|
||||
.mapToLong(i -> i)
|
||||
.average();
|
||||
if (average.isPresent()) {
|
||||
return (long) average.getAsDouble();
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static Stream<PlayerKill> getPlayerKills(Stream<Session> s) {
|
||||
return s.map(Session::getPlayerKills)
|
||||
.flatMap(Collection::stream);
|
||||
}
|
||||
|
||||
public static long getDeathCount(Stream<Session> s) {
|
||||
return s.mapToLong(Session::getDeaths)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public static long getMobKillCount(Stream<Session> s) {
|
||||
return s.mapToLong(Session::getMobKills)
|
||||
.sum();
|
||||
}
|
||||
|
||||
// Calculating Getters
|
||||
public ActivityIndex getActivityIndex(long date) {
|
||||
return activityIndexCache.computeIfAbsent(date, dateValue -> new ActivityIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total world times of the player.
|
||||
*
|
||||
* @return returns the WorldTimes in the "null" key of the map.
|
||||
*/
|
||||
public WorldTimes getWorldTimes() {
|
||||
return worldTimesMap.getOrDefault(null, new WorldTimes(new HashMap<>()));
|
||||
}
|
||||
|
||||
public void setWorldTimes(Map<UUID, WorldTimes> worldTimes) {
|
||||
worldTimesMap.putAll(worldTimes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get world times per server for this player.
|
||||
*
|
||||
* @return a copy of the WorldTimes Map without the "null" key.
|
||||
*/
|
||||
public Map<UUID, WorldTimes> getWorldTimesPerServer() {
|
||||
Map<UUID, WorldTimes> map = new HashMap<>(worldTimesMap);
|
||||
map.remove(null);
|
||||
return map;
|
||||
}
|
||||
|
||||
public UUID getFavoriteServer() {
|
||||
long max = 0L;
|
||||
UUID maxServer = null;
|
||||
for (Map.Entry<UUID, WorldTimes> entry : getWorldTimesPerServer().entrySet()) {
|
||||
long playTime = entry.getValue().getTotal();
|
||||
if (playTime > max) {
|
||||
max = playTime;
|
||||
maxServer = entry.getKey();
|
||||
}
|
||||
}
|
||||
return maxServer;
|
||||
}
|
||||
|
||||
public long getLastSeen() {
|
||||
return getLastSeen(getAllSessions());
|
||||
}
|
||||
|
||||
public long getLastSeen(Stream<Session> s) {
|
||||
OptionalLong max = s.mapToLong(session -> Math.max(session.getSessionStart(), session.getSessionEnd())).max();
|
||||
if (max.isPresent()) {
|
||||
return max.getAsLong();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getTotalPlaytime() {
|
||||
return getPlaytime(-1, System.currentTimeMillis() + 1L);
|
||||
}
|
||||
|
||||
public long getPlaytime(long after, long before) {
|
||||
return getPlaytime(getSessions(after, before));
|
||||
}
|
||||
|
||||
public long getPlaytime(UUID serverUUID) {
|
||||
return getPlaytime(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
public long getLongestSession() {
|
||||
return getLongestSession(-1, System.currentTimeMillis() + 1L);
|
||||
}
|
||||
|
||||
public long getLongestSession(int after, long before) {
|
||||
return getLongestSession(getSessions(after, before));
|
||||
}
|
||||
|
||||
public long getLongestSession(UUID serverUUID) {
|
||||
return getLongestSession(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
public long getSessionMedian() {
|
||||
return getSessionMedian(-1, System.currentTimeMillis() + 1L);
|
||||
}
|
||||
|
||||
public long getSessionMedian(int after, long before) {
|
||||
return getSessionMedian(getSessions(after, before));
|
||||
}
|
||||
|
||||
public long getSessionMedian(UUID serverUUID) {
|
||||
return getSessionMedian(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
// Special Getters
|
||||
|
||||
public long getSessionAverage() {
|
||||
return getSessionAverage(-1, System.currentTimeMillis() + 1L);
|
||||
}
|
||||
|
||||
public long getSessionAverage(int after, long before) {
|
||||
return getSessionAverage(getSessions(after, before));
|
||||
}
|
||||
|
||||
public long getSessionAverage(UUID serverUUID) {
|
||||
return getSessionAverage(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
public boolean playedBetween(long after, long before) {
|
||||
return getSessions(after, before).findFirst().isPresent();
|
||||
}
|
||||
|
||||
public Stream<Session> getAllSessions() {
|
||||
return sessions.values().stream().flatMap(Collection::stream);
|
||||
}
|
||||
|
||||
public Stream<Session> getSessions(long after, long before) {
|
||||
return getAllSessions()
|
||||
.filter(session -> session.getSessionStart() >= after && session.getSessionStart() <= before);
|
||||
}
|
||||
|
||||
public GeoInfo getMostRecentGeoInfo() {
|
||||
if (geoInformation.isEmpty()) {
|
||||
return new GeoInfo("-", "Not Known", System.currentTimeMillis(), "");
|
||||
}
|
||||
geoInformation.sort(new GeoInfoComparator());
|
||||
return geoInformation.get(0);
|
||||
}
|
||||
|
||||
public List<Action> getAllActions() {
|
||||
List<Action> actions = new ArrayList<>(this.actions);
|
||||
getPlayerKills().map(PlayerKill::convertToAction).forEach(actions::add);
|
||||
actions.sort(new ActionComparator());
|
||||
return actions;
|
||||
}
|
||||
|
||||
public Stream<PlayerKill> getPlayerKills() {
|
||||
return getPlayerKills(getAllSessions());
|
||||
}
|
||||
|
||||
public Stream<PlayerKill> getPlayerKills(UUID serverUUID) {
|
||||
return getPlayerKills(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
public long getPlayerKillCount() {
|
||||
return getPlayerKills().count();
|
||||
}
|
||||
|
||||
public long getPlayerKillCount(UUID serverUUID) {
|
||||
return getPlayerKills(serverUUID).count();
|
||||
}
|
||||
|
||||
public long getDeathCount() {
|
||||
return getDeathCount(getAllSessions());
|
||||
}
|
||||
|
||||
public long getDeathCount(UUID serverUUID) {
|
||||
return getDeathCount(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
public long getMobKillCount() {
|
||||
return getMobKillCount(getAllSessions());
|
||||
}
|
||||
|
||||
public long getMobKillCount(UUID serverUUID) {
|
||||
return getMobKillCount(getSessions(serverUUID).stream());
|
||||
}
|
||||
|
||||
public long getSessionCount() {
|
||||
return getAllSessions().count();
|
||||
}
|
||||
|
||||
public long getSessionCount(UUID serverUUID) {
|
||||
return getSessions(serverUUID).size();
|
||||
}
|
||||
|
||||
// Setters & Adders
|
||||
|
||||
public long getRegistered(UUID serverUUID) {
|
||||
return registeredMap.getOrDefault(serverUUID, -1L);
|
||||
}
|
||||
|
||||
public void bannedOnServer(UUID serverUUID) {
|
||||
bannedOnServers.add(serverUUID);
|
||||
}
|
||||
|
||||
public void oppedOnServer(UUID serverUUID) {
|
||||
oppedOnServers.add(serverUUID);
|
||||
}
|
||||
|
||||
public void bannedOnServer(Collection<UUID> serverUUIDs) {
|
||||
bannedOnServers.addAll(serverUUIDs);
|
||||
}
|
||||
|
||||
public void oppedOnServer(Collection<UUID> serverUUIDs) {
|
||||
oppedOnServers.addAll(serverUUIDs);
|
||||
}
|
||||
|
||||
public void setSessions(UUID serverUUID, List<Session> sessions) {
|
||||
this.sessions.put(serverUUID, sessions);
|
||||
}
|
||||
|
||||
public void addActiveSession(Session activeSession) {
|
||||
UUID serverUUID = ServerInfo.getServerUUID();
|
||||
List<Session> sessions = getSessions(serverUUID);
|
||||
sessions.add(activeSession);
|
||||
this.sessions.put(serverUUID, sessions);
|
||||
}
|
||||
|
||||
public List<Session> getSessions(UUID serverUUID) {
|
||||
return this.sessions.getOrDefault(serverUUID, new ArrayList<>());
|
||||
}
|
||||
|
||||
public void addReplaceValue(String placeholder, Serializable value) {
|
||||
pluginReplaceMap.put(placeholder, value.toString());
|
||||
}
|
||||
|
||||
public void setWorldTimes(UUID serverUUID, WorldTimes worldTimes) {
|
||||
worldTimesMap.put(serverUUID, worldTimes);
|
||||
}
|
||||
|
||||
public void setTotalWorldTimes(WorldTimes worldTimes) {
|
||||
worldTimesMap.put(null, worldTimes);
|
||||
}
|
||||
|
||||
public void setRegistered(UUID serverUUID, long registered) {
|
||||
registeredMap.put(serverUUID, registered);
|
||||
}
|
||||
|
||||
public int getTimesKicked() {
|
||||
return timesKicked;
|
||||
}
|
||||
|
||||
// Default Setters
|
||||
|
||||
public void setTimesKicked(int timesKicked) {
|
||||
this.timesKicked = timesKicked;
|
||||
}
|
||||
|
||||
public Map<UUID, List<String>> getNicknames() {
|
||||
return nicknames;
|
||||
}
|
||||
|
||||
public void setNicknames(Map<UUID, List<String>> nicknames) {
|
||||
this.nicknames = nicknames;
|
||||
}
|
||||
|
||||
public List<GeoInfo> getGeoInformation() {
|
||||
return geoInformation;
|
||||
}
|
||||
|
||||
// Default Getters
|
||||
|
||||
public void setGeoInformation(List<GeoInfo> geoInformation) {
|
||||
this.geoInformation = geoInformation;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
||||
public Set<UUID> getBannedOnServers() {
|
||||
return bannedOnServers;
|
||||
}
|
||||
|
||||
public Set<UUID> getOppedOnServers() {
|
||||
return oppedOnServers;
|
||||
}
|
||||
|
||||
public Map<UUID, List<Session>> getSessions() {
|
||||
return sessions;
|
||||
}
|
||||
|
||||
public void setSessions(Map<UUID, List<Session>> sessions) {
|
||||
this.sessions.putAll(sessions);
|
||||
}
|
||||
|
||||
public List<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(List<Action> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public Map<String, String> getPluginReplaceMap() {
|
||||
return pluginReplaceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldTimes map.
|
||||
*
|
||||
* @return Map that contains WorldTimes for each server and a total in the "null" key.
|
||||
*/
|
||||
public Map<UUID, WorldTimes> getWorldTimesMap() {
|
||||
return worldTimesMap;
|
||||
}
|
||||
|
||||
// OfflinePlayer methods for possible PluginData analysis
|
||||
|
||||
public boolean isBanned() {
|
||||
return bannedOnServers.size() != 0;
|
||||
}
|
||||
|
||||
public boolean isOp() {
|
||||
return oppedOnServers.contains(ServerInfo.getServerUUID());
|
||||
}
|
||||
|
||||
public static long getAFKTime(Stream<Session> sessions) {
|
||||
return sessions.mapToLong(Session::getAfkLength).sum();
|
||||
}
|
||||
|
||||
public static long getActivePlaytime(Stream<Session> sessions) {
|
||||
return sessions.mapToLong(Session::getActiveLength).sum();
|
||||
}
|
||||
|
||||
public void calculateWorldTimesPerServer() {
|
||||
if (worldTimesMap.containsKey(ServerInfo.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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,260 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import com.djrapitops.plan.utilities.comparators.PlayerProfileLastPlayedComparator;
|
||||
import com.djrapitops.plan.utilities.html.tables.PlayersTableCreator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Data class for streamlining Analysis data.
|
||||
* <p>
|
||||
* Most of the methods are not the most efficient when multiple of them are used.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class ServerProfile {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
// Database information
|
||||
private List<PlayerProfile> players;
|
||||
private List<TPS> tps;
|
||||
private Map<String, Integer> commandUsage;
|
||||
|
||||
// Information calculated with SQL
|
||||
private WorldTimes serverWorldtimes;
|
||||
private long lastPeakDate;
|
||||
private int lastPeakPlayers;
|
||||
private long allTimePeak;
|
||||
private int allTimePeakPlayers;
|
||||
|
||||
// Calculated once
|
||||
private Map<UUID, PlayerProfile> playerMap;
|
||||
|
||||
public ServerProfile(UUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
players = new ArrayList<>();
|
||||
tps = new ArrayList<>();
|
||||
commandUsage = new HashMap<>();
|
||||
|
||||
allTimePeak = -1;
|
||||
allTimePeakPlayers = -1;
|
||||
lastPeakDate = -1;
|
||||
lastPeakPlayers = -1;
|
||||
}
|
||||
|
||||
public static long getLowSpikeCount(List<TPS> tpsData) {
|
||||
return new TPSMutator(tpsData).lowTpsSpikeCount();
|
||||
}
|
||||
|
||||
public static List<PlayerKill> getPlayerKills(List<Session> s) {
|
||||
List<PlayerKill> kills = new ArrayList<>();
|
||||
for (Session session : s) {
|
||||
kills.addAll(session.getPlayerKills());
|
||||
}
|
||||
return kills;
|
||||
}
|
||||
|
||||
public static long getMobKillCount(List<Session> s) {
|
||||
long total = 0;
|
||||
for (Session session : s) {
|
||||
total += session.getMobKills();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public static long getDeathCount(List<Session> s) {
|
||||
long total = 0;
|
||||
for (Session session : s) {
|
||||
total += session.getDeaths();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public static long serverDownTime(List<TPS> tpsData) {
|
||||
return new TPSMutator(tpsData).serverDownTime();
|
||||
}
|
||||
|
||||
public static long serverIdleTime(List<TPS> tpsData) {
|
||||
return new TPSMutator(tpsData).serverIdleTime();
|
||||
}
|
||||
|
||||
public static double aboveLowThreshold(List<TPS> tpsData) {
|
||||
return new TPSMutator(tpsData).percentageTPSAboveLowThreshold();
|
||||
}
|
||||
|
||||
public List<PlayerProfile> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
public void setPlayers(List<PlayerProfile> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public List<TPS> getTps() {
|
||||
return tps;
|
||||
}
|
||||
|
||||
public void setTps(List<TPS> tps) {
|
||||
this.tps = tps;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getCommandUsage() {
|
||||
return commandUsage;
|
||||
}
|
||||
|
||||
public void setCommandUsage(Map<String, Integer> commandUsage) {
|
||||
this.commandUsage = commandUsage;
|
||||
}
|
||||
|
||||
public long getNewPlayers(long after, long before) {
|
||||
return getPlayersWhoRegistered(after, before).count();
|
||||
}
|
||||
|
||||
public long getUniquePlayers(long after, long before) {
|
||||
return getPlayersWhoPlayedBetween(after, before).count();
|
||||
}
|
||||
|
||||
public double getNewPlayersPerDay(long after, long before) {
|
||||
long days = AnalysisUtils.getNumberOfDaysBetween(after, before);
|
||||
long newPlayers = getNewPlayers(after, before);
|
||||
return days == 0 ? newPlayers : newPlayers * 1.0 / days;
|
||||
}
|
||||
|
||||
public Stream<PlayerProfile> getPlayersWhoPlayedBetween(long after, long before) {
|
||||
return players.stream()
|
||||
.filter(player -> player.playedBetween(after, before));
|
||||
}
|
||||
|
||||
public Stream<PlayerProfile> getPlayersWhoRegistered(long after, long before) {
|
||||
return players.stream()
|
||||
.filter(player -> player.getRegistered() >= after && player.getRegistered() <= before);
|
||||
}
|
||||
|
||||
public Stream<TPS> getTPSData(long after, long before) {
|
||||
return tps.stream().filter(tps -> tps.getDate() >= after && tps.getDate() <= before);
|
||||
}
|
||||
|
||||
public String createPlayersTableBody() {
|
||||
players.sort(new PlayerProfileLastPlayedComparator());
|
||||
return PlayersTableCreator.createTable(players);
|
||||
}
|
||||
|
||||
public List<String> getGeoLocations() {
|
||||
return players.stream()
|
||||
.map(PlayerProfile::getMostRecentGeoInfo)
|
||||
.map(GeoInfo::getGeolocation)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// Default setters & getters
|
||||
|
||||
public long getTotalPlaytime() {
|
||||
return serverWorldtimes.getTotal();
|
||||
}
|
||||
|
||||
public long getAveragePlayTime() {
|
||||
return MathUtils.averageLong(getTotalPlaytime(), getPlayerCount());
|
||||
}
|
||||
|
||||
public long getPlayerCount() {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
public Map<UUID, List<Session>> getSessions() {
|
||||
return players.stream().collect(Collectors.toMap(PlayerProfile::getUuid, p -> p.getSessions(serverUUID)));
|
||||
}
|
||||
|
||||
public List<Session> getAllSessions() {
|
||||
return players.stream().map(p -> p.getSessions(serverUUID)).flatMap(Collection::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public WorldTimes getServerWorldtimes() {
|
||||
return serverWorldtimes;
|
||||
}
|
||||
|
||||
public void setServerWorldtimes(WorldTimes serverWorldtimes) {
|
||||
this.serverWorldtimes = serverWorldtimes;
|
||||
}
|
||||
|
||||
public long getLastPeakDate() {
|
||||
return lastPeakDate;
|
||||
}
|
||||
|
||||
public void setLastPeakDate(long lastPeakDate) {
|
||||
this.lastPeakDate = lastPeakDate;
|
||||
}
|
||||
|
||||
public int getLastPeakPlayers() {
|
||||
return lastPeakPlayers;
|
||||
}
|
||||
|
||||
public void setLastPeakPlayers(int lastPeakPlayers) {
|
||||
this.lastPeakPlayers = lastPeakPlayers;
|
||||
}
|
||||
|
||||
public long getAllTimePeak() {
|
||||
return allTimePeak;
|
||||
}
|
||||
|
||||
public void setAllTimePeak(long allTimePeak) {
|
||||
this.allTimePeak = allTimePeak;
|
||||
}
|
||||
|
||||
public int getAllTimePeakPlayers() {
|
||||
return allTimePeakPlayers;
|
||||
}
|
||||
|
||||
public void setAllTimePeakPlayers(int allTimePeakPlayers) {
|
||||
this.allTimePeakPlayers = allTimePeakPlayers;
|
||||
}
|
||||
|
||||
public Stream<PlayerProfile> getOps() {
|
||||
return players.stream().filter(PlayerProfile::isOp);
|
||||
}
|
||||
|
||||
public Set<UUID> getUuids() {
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
for (PlayerProfile player : players) {
|
||||
uuids.add(player.getUuid());
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public PlayerProfile getPlayer(UUID uuid) {
|
||||
if (playerMap == null) {
|
||||
playerMap = players.stream().collect(Collectors.toMap(PlayerProfile::getUuid, Function.identity()));
|
||||
}
|
||||
|
||||
return playerMap.get(uuid);
|
||||
}
|
||||
|
||||
public void addActiveSessions(Map<UUID, Session> activeSessions) {
|
||||
for (Map.Entry<UUID, Session> entry : activeSessions.entrySet()) {
|
||||
UUID uuid = entry.getKey();
|
||||
Session session = entry.getValue();
|
||||
session.setSessionID((int) session.getSessionStart());
|
||||
|
||||
PlayerProfile player = getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.addActiveSession(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,405 +0,0 @@
|
||||
package com.djrapitops.plan.data.calculation;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.ServerProfile;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.store.mutators.RetentionData;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.graphs.ActivityStackGraph;
|
||||
import com.djrapitops.plan.utilities.html.graphs.PunchCardGraph;
|
||||
import com.djrapitops.plan.utilities.html.graphs.WorldMap;
|
||||
import com.djrapitops.plan.utilities.html.graphs.calendar.ServerCalendar;
|
||||
import com.djrapitops.plan.utilities.html.graphs.line.*;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.ActivityPie;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.utilities.html.tables.CommandUseTable;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Big container object for Data.
|
||||
* <p>
|
||||
* Contains parts that can be analysed. Each part has their own purpose.
|
||||
* <p>
|
||||
* Parts contain variables that can be added to. These variables are then
|
||||
* analysed using the analysis method.
|
||||
* <p>
|
||||
* After being analysed the ReplaceMap can be retrieved for replacing
|
||||
* placeholders on the server.html file.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class AnalysisData extends RawData {
|
||||
|
||||
private long refreshDate;
|
||||
|
||||
private Map<String, Long> analyzedValues;
|
||||
private Set<RetentionData> stickyMonthData;
|
||||
private List<PlayerProfile> players;
|
||||
|
||||
public AnalysisData() {
|
||||
analyzedValues = new HashMap<>();
|
||||
stickyMonthData = new HashSet<>();
|
||||
}
|
||||
|
||||
private void addConstants() {
|
||||
addValue("version", PlanPlugin.getInstance().getVersion());
|
||||
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
||||
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
||||
addValue("serverName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||
addValue("refresh", FormatUtils.formatTimeStampClock(refreshDate));
|
||||
|
||||
addValue("activityPieColors", Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE));
|
||||
addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
|
||||
addValue("tpsHighColor", Theme.getValue(ThemeVal.GRAPH_TPS_HIGH));
|
||||
addValue("tpsMediumColor", Theme.getValue(ThemeVal.GRAPH_TPS_MED));
|
||||
addValue("tpsLowColor", Theme.getValue(ThemeVal.GRAPH_TPS_LOW));
|
||||
addValue("worldMapColLow", Theme.getValue(ThemeVal.WORLD_MAP_LOW));
|
||||
addValue("worldMapColHigh", Theme.getValue(ThemeVal.WORLD_MAP_HIGH));
|
||||
addValue("tpsMedium", Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber());
|
||||
addValue("tpsHigh", Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH.getNumber());
|
||||
|
||||
ServerProperties serverProperties = ServerInfo.getServerProperties();
|
||||
addValue("playersMax", serverProperties.getMaxPlayers());
|
||||
addValue("playersOnline", serverProperties.getOnlinePlayers());
|
||||
}
|
||||
|
||||
public void analyze(ServerProfile profile) {
|
||||
long now = System.currentTimeMillis();
|
||||
refreshDate = now;
|
||||
long dayAgo = now - TimeAmount.DAY.ms();
|
||||
long weekAgo = now - TimeAmount.WEEK.ms();
|
||||
long monthAgo = now - TimeAmount.MONTH.ms();
|
||||
|
||||
addConstants();
|
||||
|
||||
got("now", now);
|
||||
got("dayAgo", dayAgo);
|
||||
got("weekAgo", weekAgo);
|
||||
got("monthAgo", monthAgo);
|
||||
|
||||
Map<UUID, List<Session>> sessions = profile.getSessions();
|
||||
List<Session> allSessions = profile.getAllSessions();
|
||||
allSessions.sort(new SessionStartComparator());
|
||||
|
||||
players = profile.getPlayers();
|
||||
List<PlayerProfile> ops = profile.getOps().collect(Collectors.toList());
|
||||
long playersTotal = got("playersTotal", players.size());
|
||||
|
||||
List<TPS> tpsData = profile.getTPSData(0, now).collect(Collectors.toList());
|
||||
List<TPS> tpsDataDay = profile.getTPSData(dayAgo, now).collect(Collectors.toList());
|
||||
List<TPS> tpsDataWeek = profile.getTPSData(weekAgo, now).collect(Collectors.toList());
|
||||
List<TPS> tpsDataMonth = profile.getTPSData(monthAgo, now).collect(Collectors.toList());
|
||||
|
||||
List<String> geoLocations = profile.getGeoLocations();
|
||||
Map<String, Integer> commandUsage = profile.getCommandUsage();
|
||||
|
||||
directProfileVariables(profile);
|
||||
performanceTab(tpsData, tpsDataDay, tpsDataWeek, tpsDataMonth);
|
||||
sessionData(monthAgo, sessions, allSessions);
|
||||
onlineActivityNumbers(profile, sessions, players);
|
||||
geolocationsTab(geoLocations);
|
||||
commandUsage(commandUsage);
|
||||
|
||||
List<Long> registered = profile.getPlayers().stream().map(PlayerProfile::getRegistered).collect(Collectors.toList());
|
||||
ServerCalendar serverCalendar = new ServerCalendar(registered, sessions);
|
||||
addValue("calendarSeries", serverCalendar.toCalendarSeries());
|
||||
addValue("firstDay", 1);
|
||||
|
||||
addValue("ops", ops.size());
|
||||
addValue("playersTotal", playersTotal);
|
||||
|
||||
healthTab(now, players, tpsDataMonth);
|
||||
|
||||
long totalPlaytime = profile.getTotalPlaytime();
|
||||
addValue("playtimeTotal", playersTotal != 0 ? Formatters.timeAmount().apply(totalPlaytime) : "No Players");
|
||||
addValue("playtimeAverage", playersTotal != 0 ? Formatters.timeAmount().apply(MathUtils.averageLong(totalPlaytime, playersTotal)) : "-");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void healthTab(long now, List<PlayerProfile> players, List<TPS> tpsDataMonth) {
|
||||
TreeMap<Long, Map<String, Set<UUID>>> activityData = AnalysisUtils.turnToActivityDataMap(now, players);
|
||||
|
||||
Map<String, Set<UUID>> activityNow = activityData.getOrDefault(now, new HashMap<>());
|
||||
|
||||
ActivityStackGraph activityStackGraph = new ActivityStackGraph(activityData);
|
||||
String activityPieSeries = new ActivityPie(activityNow).toHighChartsSeries();
|
||||
|
||||
addValue("activityStackCategories", activityStackGraph.toHighChartsLabels());
|
||||
addValue("activityStackSeries", activityStackGraph.toHighChartsSeries());
|
||||
addValue("activityPieSeries", activityPieSeries);
|
||||
|
||||
Set<UUID> veryActiveNow = activityNow.getOrDefault("Very Active", new HashSet<>());
|
||||
Set<UUID> activeNow = activityNow.getOrDefault("Active", new HashSet<>());
|
||||
Set<UUID> regularNow = activityNow.getOrDefault("Regular", new HashSet<>());
|
||||
|
||||
addValue("playersRegular", (veryActiveNow.size() + activeNow.size() + regularNow.size()));
|
||||
|
||||
HealthNotes healthNotes = new HealthNotes(this, activityData, tpsDataMonth, now);
|
||||
healthNotes.analyzeHealth();
|
||||
|
||||
addValue("healthNotes", healthNotes.parse());
|
||||
addValue("healthIndex", healthNotes.getServerHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void commandUsage(Map<String, Integer> commandUsage) {
|
||||
addValue("commandUniqueCount", String.valueOf(commandUsage.size()));
|
||||
addValue("commandCount", MathUtils.sumInt(commandUsage.values().stream().map(i -> (int) i)));
|
||||
addValue("tableBodyCommands", new CommandUseTable(commandUsage).parseBody());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void geolocationsTab(List<String> geoLocations) {
|
||||
addValue("geoMapSeries", new WorldMap(geoLocations).toHighChartsSeries());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void onlineActivityNumbers(ServerProfile profile, Map<UUID, List<Session>> sessions, List<PlayerProfile> players) {
|
||||
long now = value("now");
|
||||
long dayAgo = value("dayAgo");
|
||||
long weekAgo = value("weekAgo");
|
||||
long monthAgo = value("monthAgo");
|
||||
|
||||
List<PlayerProfile> newDay = profile.getPlayersWhoRegistered(dayAgo, now).collect(Collectors.toList());
|
||||
List<PlayerProfile> newWeek = profile.getPlayersWhoRegistered(weekAgo, now).collect(Collectors.toList());
|
||||
List<PlayerProfile> newMonth = profile.getPlayersWhoRegistered(monthAgo, now).collect(Collectors.toList());
|
||||
List<PlayerProfile> uniqueDay = profile.getPlayersWhoPlayedBetween(dayAgo, now).collect(Collectors.toList());
|
||||
List<PlayerProfile> uniqueWeek = profile.getPlayersWhoPlayedBetween(weekAgo, now).collect(Collectors.toList());
|
||||
List<PlayerProfile> uniqueMonth = profile.getPlayersWhoPlayedBetween(monthAgo, now).collect(Collectors.toList());
|
||||
|
||||
int uniqD = uniqueDay.size();
|
||||
int uniqW = uniqueWeek.size();
|
||||
int uniqM = uniqueMonth.size();
|
||||
long newD = got("newD", newDay.size());
|
||||
long newW = got("newW", newWeek.size());
|
||||
long newM = got("newM", newMonth.size());
|
||||
long playersTotal = value("playersTotal");
|
||||
|
||||
addValue("playersDay", uniqD);
|
||||
addValue("playersWeek", uniqW);
|
||||
addValue("playersMonth", uniqM);
|
||||
addValue("playersNewDay", newD);
|
||||
addValue("playersNewWeek", newW);
|
||||
addValue("playersNewMonth", newM);
|
||||
|
||||
addValue("playersAverage", AnalysisUtils.getUniqueJoinsPerDay(sessions, -1));
|
||||
addValue("playersAverageDay", AnalysisUtils.getUniqueJoinsPerDay(sessions, dayAgo));
|
||||
addValue("playersAverageWeek", AnalysisUtils.getUniqueJoinsPerDay(sessions, weekAgo));
|
||||
addValue("playersAverageMonth", AnalysisUtils.getUniqueJoinsPerDay(sessions, monthAgo));
|
||||
addValue("playersNewAverage", AnalysisUtils.getNewUsersPerDay(toRegistered(players), -1, playersTotal));
|
||||
addValue("playersNewAverageDay", AnalysisUtils.getNewUsersPerDay(toRegistered(newDay), -1, newD));
|
||||
addValue("playersNewAverageWeek", AnalysisUtils.getNewUsersPerDay(toRegistered(newWeek), -1, newW));
|
||||
addValue("playersNewAverageMonth", AnalysisUtils.getNewUsersPerDay(toRegistered(newMonth), -1, newM));
|
||||
|
||||
stickiness(now, weekAgo, monthAgo, newDay, newWeek, newMonth);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void stickiness(long now, long weekAgo, long monthAgo,
|
||||
List<PlayerProfile> newDay, List<PlayerProfile> newWeek, List<PlayerProfile> newMonth) {
|
||||
long newD = value("newD");
|
||||
long newW = value("newW");
|
||||
long newM = value("newM");
|
||||
|
||||
List<PlayerProfile> playersStuckPerMonth = newMonth.stream()
|
||||
.filter(p -> {
|
||||
long backLimit = Math.max(monthAgo, p.getRegistered());
|
||||
long half = backLimit + ((now - backLimit) / 2L);
|
||||
return p.playedBetween(backLimit, half) && p.playedBetween(half, now);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
List<PlayerProfile> playersStuckPerWeek = newWeek.stream()
|
||||
.filter(p -> {
|
||||
long backLimit = Math.max(weekAgo, p.getRegistered());
|
||||
long half = backLimit + ((now - backLimit) / 2L);
|
||||
return p.playedBetween(backLimit, half) && p.playedBetween(half, now);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int stuckPerM = playersStuckPerMonth.size();
|
||||
int stuckPerW = playersStuckPerWeek.size();
|
||||
got("stuckPerM", stuckPerM);
|
||||
got("stuckPerW", stuckPerW);
|
||||
|
||||
stickyMonthData = newMonth.stream().map(RetentionData::new).distinct().collect(Collectors.toSet());
|
||||
|
||||
addValue("playersStuckMonth", stuckPerM);
|
||||
addValue("playersStuckWeek", stuckPerW);
|
||||
addValue("playersStuckPercMonth", newM != 0 ? FormatUtils.cutDecimals(MathUtils.averageDouble(stuckPerM, newM) * 100.0) + "%" : "-");
|
||||
addValue("playersStuckPercWeek", newW != 0 ? FormatUtils.cutDecimals(MathUtils.averageDouble(stuckPerW, newW) * 100.0) + "%" : "-");
|
||||
|
||||
stuckPerDay(newDay, newD, monthAgo);
|
||||
}
|
||||
|
||||
private void stuckPerDay(List<PlayerProfile> newDay, long newD, long monthAgo) {
|
||||
if (newD != 0) {
|
||||
List<PlayerProfile> stuckAfterMonth = new ArrayList<>();
|
||||
List<PlayerProfile> notStuckAfterMonth = new ArrayList<>();
|
||||
|
||||
for (PlayerProfile player : players) {
|
||||
long registered = player.getRegistered();
|
||||
|
||||
// Discard uncertain data
|
||||
if (registered > monthAgo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long monthAfterRegister = registered + TimeAmount.MONTH.ms();
|
||||
long half = registered + (TimeAmount.MONTH.ms() / 2L);
|
||||
if (player.playedBetween(registered, half) && player.playedBetween(half, monthAfterRegister)) {
|
||||
stuckAfterMonth.add(player);
|
||||
} else {
|
||||
notStuckAfterMonth.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (stuckAfterMonth.isEmpty() || notStuckAfterMonth.isEmpty()) {
|
||||
addValue("playersStuckDay", 0);
|
||||
addValue("playersStuckPercDay", "Not enough data");
|
||||
return;
|
||||
}
|
||||
|
||||
List<RetentionData> stuck = stuckAfterMonth.stream().map(RetentionData::new).collect(Collectors.toList());
|
||||
List<RetentionData> nonStuck = notStuckAfterMonth.stream().map(RetentionData::new).collect(Collectors.toList());
|
||||
|
||||
RetentionData avgStuck = AnalysisUtils.average(stuck);
|
||||
RetentionData avgNonStuck = AnalysisUtils.average(nonStuck);
|
||||
|
||||
int stuckPerD = 0;
|
||||
for (PlayerProfile player : newDay) {
|
||||
RetentionData retentionData = new RetentionData(player);
|
||||
if (retentionData.distance(avgStuck) < retentionData.distance(avgNonStuck)) {
|
||||
stuckPerD++;
|
||||
}
|
||||
}
|
||||
|
||||
addValue("playersStuckDay", stuckPerD);
|
||||
addValue("playersStuckPercDay", FormatUtils.cutDecimals(MathUtils.averageDouble(stuckPerD, newD) * 100.0) + "%");
|
||||
} else {
|
||||
addValue("playersStuckDay", 0);
|
||||
addValue("playersStuckPercDay", "-");
|
||||
}
|
||||
}
|
||||
|
||||
private List<Long> toRegistered(List<PlayerProfile> players) {
|
||||
return players.stream().map(PlayerProfile::getRegistered).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void sessionData(long monthAgo, Map<UUID, List<Session>> sessions, List<Session> allSessions) {
|
||||
List<Session> sessionsMonth = allSessions.stream()
|
||||
.filter(s -> s.getSessionStart() >= monthAgo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
addValue("sessionCount", allSessions.size());
|
||||
addValue("accordionSessions", "");
|
||||
addValue("sessionTabGraphViewFunctions", "");
|
||||
addValue("tableBodySessions", "");
|
||||
addValue("listRecentLogins", "");
|
||||
addValue("sessionAverage", Formatters.timeAmount().apply(new SessionsMutator(allSessions).toAverageSessionLength()));
|
||||
addValue("punchCardSeries", new PunchCardGraph(sessionsMonth).toHighChartsSeries());
|
||||
|
||||
addValue("deaths", ServerProfile.getDeathCount(allSessions));
|
||||
addValue("mobKillCount", ServerProfile.getMobKillCount(allSessions));
|
||||
addValue("killCount", ServerProfile.getPlayerKills(allSessions).size());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void directProfileVariables(ServerProfile profile) {
|
||||
WorldTimes worldTimes = profile.getServerWorldtimes();
|
||||
long allTimePeak = profile.getAllTimePeak();
|
||||
long lastPeak = profile.getLastPeakDate();
|
||||
|
||||
String playersTableBody = profile.createPlayersTableBody();
|
||||
addValue("tablePlayerlist", Settings.PLAYERTABLE_FOOTER.isTrue() ?
|
||||
Html.TABLE_PLAYERS_FOOTER.parse(playersTableBody)
|
||||
: Html.TABLE_PLAYERS.parse(playersTableBody));
|
||||
addValue("worldTotal", Formatters.timeAmount().apply(worldTimes.getTotal()));
|
||||
WorldPie worldPie = new WorldPie(worldTimes);
|
||||
addValue("worldSeries", worldPie.toHighChartsSeries());
|
||||
addValue("gmSeries", worldPie.toHighChartsDrilldown());
|
||||
addValue("lastPeakTime", lastPeak != -1 ? FormatUtils.formatTimeStampYear(lastPeak) : "No Data");
|
||||
addValue("playersLastPeak", lastPeak != -1 ? profile.getLastPeakPlayers() : "-");
|
||||
addValue("bestPeakTime", allTimePeak != -1 ? FormatUtils.formatTimeStampYear(allTimePeak) : "No Data");
|
||||
addValue("playersBestPeak", allTimePeak != -1 ? profile.getAllTimePeakPlayers() : "-");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void performanceTab(List<TPS> tpsData, List<TPS> tpsDataDay, List<TPS> tpsDataWeek, List<TPS> tpsDataMonth) {
|
||||
got("tpsSpikeMonth", ServerProfile.getLowSpikeCount(tpsDataMonth));
|
||||
got("tpsSpikeWeek", ServerProfile.getLowSpikeCount(tpsDataWeek));
|
||||
got("tpsSpikeDay", ServerProfile.getLowSpikeCount(tpsDataDay));
|
||||
addValue("tpsSpikeMonth", value("tpsSpikeMonth"));
|
||||
addValue("tpsSpikeWeek", value("tpsSpikeWeek"));
|
||||
addValue("tpsSpikeDay", value("tpsSpikeDay"));
|
||||
|
||||
addValue("playersOnlineSeries", new OnlineActivityGraph(tpsData).toHighChartsSeries());
|
||||
addValue("tpsSeries", new TPSGraph(tpsData).toHighChartsSeries());
|
||||
addValue("cpuSeries", new CPUGraph(tpsData).toHighChartsSeries());
|
||||
addValue("ramSeries", new RamGraph(tpsData).toHighChartsSeries());
|
||||
addValue("entitySeries", new EntityGraph(tpsData).toHighChartsSeries());
|
||||
addValue("chunkSeries", new ChunkGraph(tpsData).toHighChartsSeries());
|
||||
|
||||
double averageCPUMonth = MathUtils.averageDouble(tpsDataMonth.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
double averageCPUWeek = MathUtils.averageDouble(tpsDataWeek.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
double averageCPUDay = MathUtils.averageDouble(tpsDataDay.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
|
||||
addValue("tpsAverageMonth", FormatUtils.cutDecimals(MathUtils.averageDouble(tpsDataMonth.stream().map(TPS::getTicksPerSecond))));
|
||||
addValue("tpsAverageWeek", FormatUtils.cutDecimals(MathUtils.averageDouble(tpsDataWeek.stream().map(TPS::getTicksPerSecond))));
|
||||
addValue("tpsAverageDay", FormatUtils.cutDecimals(MathUtils.averageDouble(tpsDataDay.stream().map(TPS::getTicksPerSecond))));
|
||||
|
||||
addValue("cpuAverageMonth", averageCPUMonth >= 0 ? FormatUtils.cutDecimals(averageCPUMonth) + "%" : "Unavailable");
|
||||
addValue("cpuAverageWeek", averageCPUWeek >= 0 ? FormatUtils.cutDecimals(averageCPUWeek) + "%" : "Unavailable");
|
||||
addValue("cpuAverageDay", averageCPUDay >= 0 ? FormatUtils.cutDecimals(averageCPUDay) + "%" : "Unavailable");
|
||||
|
||||
addValue("ramAverageMonth", FormatUtils.cutDecimals(MathUtils.averageLong(tpsDataMonth.stream().map(TPS::getUsedMemory).filter(i -> i != 0))));
|
||||
addValue("ramAverageWeek", FormatUtils.cutDecimals(MathUtils.averageLong(tpsDataWeek.stream().map(TPS::getUsedMemory).filter(i -> i != 0))));
|
||||
addValue("ramAverageDay", FormatUtils.cutDecimals(MathUtils.averageLong(tpsDataDay.stream().map(TPS::getUsedMemory).filter(i -> i != 0))));
|
||||
|
||||
addValue("entityAverageMonth", FormatUtils.cutDecimals(MathUtils.averageInt(tpsDataMonth.stream().map(TPS::getEntityCount).filter(i -> i != 0))));
|
||||
addValue("entityAverageWeek", FormatUtils.cutDecimals(MathUtils.averageInt(tpsDataWeek.stream().map(TPS::getEntityCount).filter(i -> i != 0))));
|
||||
addValue("entityAverageDay", FormatUtils.cutDecimals(MathUtils.averageInt(tpsDataDay.stream().map(TPS::getEntityCount).filter(i -> i != 0))));
|
||||
|
||||
addValue("chunkAverageMonth", FormatUtils.cutDecimals(MathUtils.averageInt(tpsDataMonth.stream().map(TPS::getChunksLoaded).filter(i -> i != 0))));
|
||||
addValue("chunkAverageWeek", FormatUtils.cutDecimals(MathUtils.averageInt(tpsDataWeek.stream().map(TPS::getChunksLoaded).filter(i -> i != 0))));
|
||||
addValue("chunkAverageDay", FormatUtils.cutDecimals(MathUtils.averageInt(tpsDataDay.stream().map(TPS::getChunksLoaded).filter(i -> i != 0))));
|
||||
}
|
||||
|
||||
private long got(String key, long v) {
|
||||
analyzedValues.put(key, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
public long value(String key) {
|
||||
return analyzedValues.getOrDefault(key, 0L);
|
||||
}
|
||||
|
||||
public Set<RetentionData> getStickyMonthData() {
|
||||
return stickyMonthData;
|
||||
}
|
||||
|
||||
public List<PlayerProfile> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
}
|
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.data.calculation;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.ServerProfile;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.store.mutators.RetentionData;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Class in charge of Server health analysis.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class HealthNotes {
|
||||
|
||||
private final List<String> notes;
|
||||
private final AnalysisData analysisData;
|
||||
private final SortedMap<Long, Map<String, Set<UUID>>> activityData;
|
||||
private final List<TPS> tpsDataMonth;
|
||||
private final long now;
|
||||
private final long fourWeeksAgo;
|
||||
private double serverHealth;
|
||||
|
||||
public HealthNotes(AnalysisData analysisData, SortedMap<Long, Map<String, Set<UUID>>> activityData, List<TPS> tpsDataMonth, long now) {
|
||||
this.notes = new ArrayList<>();
|
||||
serverHealth = 100.0;
|
||||
|
||||
this.analysisData = analysisData;
|
||||
this.activityData = activityData;
|
||||
this.tpsDataMonth = tpsDataMonth;
|
||||
this.now = now;
|
||||
this.fourWeeksAgo = now - TimeAmount.WEEK.ms() * 4L;
|
||||
}
|
||||
|
||||
public void analyzeHealth() {
|
||||
activityChangeNote();
|
||||
newPlayerNote();
|
||||
activePlayerPlaytimeChange();
|
||||
lowPerformance();
|
||||
}
|
||||
|
||||
public String parse() {
|
||||
StringBuilder healthNoteBuilder = new StringBuilder();
|
||||
for (String healthNote : notes) {
|
||||
healthNoteBuilder.append(healthNote);
|
||||
}
|
||||
return healthNoteBuilder.toString();
|
||||
}
|
||||
|
||||
public double getServerHealth() {
|
||||
return serverHealth;
|
||||
}
|
||||
|
||||
private void activityChangeNote() {
|
||||
Map<String, Set<UUID>> activityNow = activityData.getOrDefault(now, new HashMap<>());
|
||||
Set<UUID> veryActiveNow = activityNow.getOrDefault("Very Active", new HashSet<>());
|
||||
Set<UUID> activeNow = activityNow.getOrDefault("Active", new HashSet<>());
|
||||
Set<UUID> regularNow = activityNow.getOrDefault("Regular", new HashSet<>());
|
||||
|
||||
Map<String, Set<UUID>> activityFourWAgo = activityData.getOrDefault(fourWeeksAgo, new HashMap<>());
|
||||
Set<UUID> veryActiveFWAG = activityFourWAgo.getOrDefault("Very Active", new HashSet<>());
|
||||
Set<UUID> activeFWAG = activityFourWAgo.getOrDefault("Active", new HashSet<>());
|
||||
Set<UUID> regularFWAG = activityFourWAgo.getOrDefault("Regular", new HashSet<>());
|
||||
|
||||
Set<UUID> regularRemainCompareSet = new HashSet<>(regularFWAG);
|
||||
regularRemainCompareSet.addAll(activeFWAG);
|
||||
regularRemainCompareSet.addAll(veryActiveFWAG);
|
||||
|
||||
int activeFWAGNum = regularRemainCompareSet.size();
|
||||
regularRemainCompareSet.removeAll(regularNow);
|
||||
regularRemainCompareSet.removeAll(activeNow);
|
||||
regularRemainCompareSet.removeAll(veryActiveNow);
|
||||
int notRegularAnymore = regularRemainCompareSet.size();
|
||||
int remain = activeFWAGNum - notRegularAnymore;
|
||||
double percRemain = remain * 100.0 / activeFWAGNum;
|
||||
|
||||
int newActive = getNewActive(veryActiveNow, activeNow, regularNow, veryActiveFWAG, activeFWAG, regularFWAG);
|
||||
|
||||
int change = newActive - notRegularAnymore;
|
||||
|
||||
String remainNote = "";
|
||||
if (activeFWAGNum != 0) {
|
||||
remainNote = " ";
|
||||
if (percRemain > 50) {
|
||||
remainNote += Html.GREEN_THUMB.parse();
|
||||
} else if (percRemain > 20) {
|
||||
remainNote += Html.YELLOW_FLAG.parse();
|
||||
} else {
|
||||
remainNote += Html.RED_WARN.parse();
|
||||
serverHealth -= 2.5;
|
||||
}
|
||||
|
||||
remainNote += " " + FormatUtils.cutDecimals(percRemain) + "% of regular players have remained active ("
|
||||
+ remain + "/" + activeFWAGNum + ")";
|
||||
}
|
||||
if (change > 0) {
|
||||
notes.add(
|
||||
"<p>" + Html.GREEN_THUMB.parse() + " Number of regular players has increased (+" + change + ")<br>" +
|
||||
remainNote + "</p>");
|
||||
} else if (change == 0) {
|
||||
notes.add(
|
||||
"<p>" + Html.GREEN_THUMB.parse() + " Number of regular players has stayed the same (+" + change + ")<br>" +
|
||||
remainNote + "</p>");
|
||||
} else if (change > -20) {
|
||||
notes.add(
|
||||
"<p>" + Html.YELLOW_FLAG.parse() + " Number of regular players has decreased (" + change + ")<br>" +
|
||||
remainNote + "</p>");
|
||||
serverHealth -= 5;
|
||||
} else {
|
||||
notes.add(
|
||||
"<p>" + Html.RED_WARN.parse() + " Number of regular players has decreased (" + change + ")<br>" +
|
||||
remainNote + "</p>");
|
||||
serverHealth -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
private void newPlayerNote() {
|
||||
double avgOnlineOnRegister = MathUtils.averageDouble(analysisData.getStickyMonthData().stream().map(RetentionData::getOnlineOnJoin));
|
||||
if (avgOnlineOnRegister >= 1) {
|
||||
notes.add("<p>" + Html.GREEN_THUMB.parse() + " New Players have players to play with when they join ("
|
||||
+ FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)</p>");
|
||||
} else {
|
||||
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " New Players may not have players to play with when they join ("
|
||||
+ FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)</p>");
|
||||
serverHealth -= 5;
|
||||
}
|
||||
|
||||
long newM = analysisData.value("newM");
|
||||
long stuckPerM = analysisData.value("stuckPerM");
|
||||
|
||||
if (newM != 0) {
|
||||
double stuckPerc = MathUtils.averageDouble(stuckPerM, newM) * 100;
|
||||
if (stuckPerc >= 25) {
|
||||
notes.add("<p>" + Html.GREEN_THUMB.parse() + " " + FormatUtils.cutDecimals(stuckPerc)
|
||||
+ "% of new players have stuck around (" + stuckPerM + "/" + newM + ")</p>");
|
||||
} else {
|
||||
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " " + FormatUtils.cutDecimals(stuckPerc)
|
||||
+ "% of new players have stuck around (" + stuckPerM + "/" + newM + ")</p>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void activePlayerPlaytimeChange() {
|
||||
List<PlayerProfile> currentActivePlayers = analysisData.getPlayers().stream()
|
||||
.filter(player -> player.getActivityIndex(now).getValue() >= 1.75)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
long twoWeeksAgo = now - TimeAmount.WEEK.ms() * 2L;
|
||||
|
||||
long totalFourToTwoWeeks = 0;
|
||||
long totalLastTwoWeeks = 0;
|
||||
for (PlayerProfile activePlayer : currentActivePlayers) {
|
||||
totalFourToTwoWeeks += activePlayer.getPlaytime(analysisData.value("monthAgo"), twoWeeksAgo);
|
||||
totalLastTwoWeeks += activePlayer.getPlaytime(twoWeeksAgo, now);
|
||||
}
|
||||
int currentlyActive = currentActivePlayers.size();
|
||||
if (currentlyActive != 0) {
|
||||
long avgFourToTwoWeeks = MathUtils.averageLong(totalFourToTwoWeeks, currentlyActive);
|
||||
long avgLastTwoWeeks = MathUtils.averageLong(totalLastTwoWeeks, currentlyActive);
|
||||
String avgLastTwoWeeksString = Formatters.timeAmount().apply(avgLastTwoWeeks);
|
||||
String avgFourToTwoWeeksString = Formatters.timeAmount().apply(avgFourToTwoWeeks);
|
||||
if (avgFourToTwoWeeks >= avgLastTwoWeeks) {
|
||||
notes.add("<p>" + Html.GREEN_THUMB.parse() + " Active players seem to have things to do (Played "
|
||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||
+ ", last two weeks vs weeks 2-4)</p>");
|
||||
} else if (avgFourToTwoWeeks - avgLastTwoWeeks > TimeAmount.HOUR.ms() * 2L) {
|
||||
notes.add("<p>" + Html.RED_WARN.parse() + " Active players might be running out of things to do (Played "
|
||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||
+ ", last two weeks vs weeks 2-4)</p>");
|
||||
serverHealth -= 5;
|
||||
} else {
|
||||
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " Active players might be running out of things to do (Played "
|
||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||
+ ", last two weeks vs weeks 2-4)</p>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void lowPerformance() {
|
||||
long serverDownTime = ServerProfile.serverDownTime(tpsDataMonth);
|
||||
double aboveThreshold = ServerProfile.aboveLowThreshold(tpsDataMonth);
|
||||
long tpsSpikeMonth = analysisData.value("tpsSpikeMonth");
|
||||
|
||||
String avgLowThresholdString = " ";
|
||||
if (aboveThreshold >= 0.96) {
|
||||
avgLowThresholdString += Html.GREEN_THUMB.parse();
|
||||
} else if (aboveThreshold >= 0.9) {
|
||||
avgLowThresholdString += Html.YELLOW_FLAG.parse();
|
||||
serverHealth *= 0.9;
|
||||
} else {
|
||||
avgLowThresholdString += Html.RED_WARN.parse();
|
||||
serverHealth *= 0.6;
|
||||
}
|
||||
avgLowThresholdString += " Average TPS was above Low Threshold "
|
||||
+ FormatUtils.cutDecimals(aboveThreshold * 100.0) + "% of the time";
|
||||
|
||||
if (tpsSpikeMonth <= 5) {
|
||||
notes.add("<p>" + Html.GREEN_THUMB.parse()
|
||||
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
||||
" " + tpsSpikeMonth + " times<br>" +
|
||||
avgLowThresholdString + "</p>");
|
||||
} else if (tpsSpikeMonth <= 25) {
|
||||
notes.add("<p>" + Html.YELLOW_FLAG.parse()
|
||||
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
||||
" " + tpsSpikeMonth + " times<br>" +
|
||||
avgLowThresholdString + "</p>");
|
||||
serverHealth *= 0.95;
|
||||
} else {
|
||||
notes.add("<p>" + Html.RED_WARN.parse()
|
||||
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
||||
" " + tpsSpikeMonth + " times<br>" +
|
||||
avgLowThresholdString + "</p>");
|
||||
serverHealth *= 0.8;
|
||||
}
|
||||
|
||||
Formatter<Long> formatter = Formatters.timeAmount();
|
||||
if (serverDownTime <= TimeAmount.DAY.ms()) {
|
||||
notes.add("<p>" + Html.GREEN_THUMB.parse() + " Total Server downtime (No Data) was "
|
||||
+ formatter.apply(serverDownTime) + "</p>");
|
||||
} else if (serverDownTime <= TimeAmount.WEEK.ms()) {
|
||||
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " Total Server downtime (No Data) was "
|
||||
+ formatter.apply(serverDownTime) + "</p>");
|
||||
serverHealth *= (TimeAmount.WEEK.ms() - serverDownTime) * 1.0 / TimeAmount.WEEK.ms();
|
||||
} else {
|
||||
notes.add("<p>" + Html.RED_WARN.parse() + " Total Server downtime (No Data) was "
|
||||
+ formatter.apply(serverDownTime) + "</p>");
|
||||
serverHealth *= (TimeAmount.MONTH.ms() - serverDownTime) * 1.0 / TimeAmount.MONTH.ms();
|
||||
}
|
||||
}
|
||||
|
||||
private int getNewActive(Set<UUID> veryActiveNow, Set<UUID> activeNow, Set<UUID> regularNow, Set<UUID> veryActiveFWAG, Set<UUID> activeFWAG, Set<UUID> regularFWAG) {
|
||||
Set<UUID> regularNewCompareSet = new HashSet<>(regularNow);
|
||||
regularNewCompareSet.addAll(activeNow);
|
||||
regularNewCompareSet.addAll(veryActiveNow);
|
||||
regularNewCompareSet.removeAll(regularFWAG);
|
||||
regularNewCompareSet.removeAll(activeFWAG);
|
||||
regularNewCompareSet.removeAll(veryActiveFWAG);
|
||||
return regularNewCompareSet.size();
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.djrapitops.plan.data.calculation;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Extending objects should represent, add together and analyse data.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class RawData {
|
||||
|
||||
private final Map<String, Serializable> replaceMap;
|
||||
|
||||
/**
|
||||
* Only used by subclasses.
|
||||
*/
|
||||
public RawData() {
|
||||
replaceMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds values from an existing replaceMap.
|
||||
*
|
||||
* @param values Map that contains place-holders.
|
||||
*/
|
||||
public void addValues(Map<String, Serializable> values) {
|
||||
Verify.nullCheck(values);
|
||||
replaceMap.putAll(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a placeholder to the replaceMap.
|
||||
*
|
||||
* @param placeholder placeholder, without prefix and suffix
|
||||
* @param value Any value the placeholder should be replaced with.
|
||||
*/
|
||||
public void addValue(String placeholder, Serializable value) {
|
||||
replaceMap.put(placeholder, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the placeholders and values.
|
||||
*
|
||||
* @return Map containing the placeholders and values.
|
||||
*/
|
||||
public Map<String, Serializable> getReplaceMap() {
|
||||
return replaceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the value for a placeholder without the placeholder prefix and suffix.
|
||||
*
|
||||
* @param key placeholder name without ${ and }
|
||||
* @return Value the placeholder should be replaced with or null.
|
||||
*/
|
||||
public Serializable get(String key) {
|
||||
return replaceMap.get(key);
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Class that represents an action made by a player.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class Action implements DateHolder {
|
||||
private final long date;
|
||||
private final Actions doneAction;
|
||||
private final String additionalInfo;
|
||||
private int serverID;
|
||||
|
||||
public Action(long date, Actions doneAction, String additionalInfo) {
|
||||
this.date = date;
|
||||
this.doneAction = doneAction;
|
||||
this.additionalInfo = additionalInfo;
|
||||
}
|
||||
|
||||
public Action(long date, Actions doneAction, String additionalInfo, int serverID) {
|
||||
this.date = date;
|
||||
this.doneAction = doneAction;
|
||||
this.additionalInfo = additionalInfo;
|
||||
this.serverID = serverID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Actions getDoneAction() {
|
||||
return doneAction;
|
||||
}
|
||||
|
||||
public String getAdditionalInfo() {
|
||||
return additionalInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can only be used on Action classes returned by the ActionsTable.
|
||||
*
|
||||
* @return ID of the server the action occurred on.
|
||||
*/
|
||||
public int getServerID() {
|
||||
return serverID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Action action = (Action) o;
|
||||
return date == action.date &&
|
||||
serverID == action.serverID &&
|
||||
doneAction == action.doneAction &&
|
||||
Objects.equals(additionalInfo, action.additionalInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(date, doneAction, additionalInfo, serverID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Html.TABLELINE_3.parse(Formatters.year().apply(this), doneAction.toString(), additionalInfo);
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.djrapitops.plan.data.container;
|
||||
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
@ -55,12 +53,6 @@ public class PlayerKill implements DateHolder {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Action convertToAction() {
|
||||
String name = DataCache.getInstance().getName(victim);
|
||||
return new Action(date, Actions.KILLED, name + " with " + weapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -10,7 +10,7 @@ import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Container used to parse data for Analysis page.
|
||||
* Container used to parse data for Server page.
|
||||
* <p>
|
||||
* Similar to InspectContainer, but can contain data for each player for a bigger Player data table.
|
||||
* <p>
|
||||
|
@ -9,12 +9,6 @@ public class ActivityIndex {
|
||||
|
||||
private final double value;
|
||||
|
||||
// Temp constructor for PlayerProfile support
|
||||
@Deprecated
|
||||
public ActivityIndex() {
|
||||
value = 0.0;
|
||||
}
|
||||
|
||||
public ActivityIndex(DataContainer container, long date) {
|
||||
value = calculate(container, date);
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.data.store.mutators;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
@ -23,11 +22,6 @@ public class RetentionData {
|
||||
private final double activityIndex;
|
||||
private double onlineOnJoin;
|
||||
|
||||
@Deprecated
|
||||
public RetentionData(PlayerProfile player) {
|
||||
activityIndex = player.getActivityIndex(player.getRegistered() + TimeAmount.DAY.ms()).getValue();
|
||||
}
|
||||
|
||||
public RetentionData(double activityIndex, double onlineOnJoin) {
|
||||
this.activityIndex = activityIndex;
|
||||
this.onlineOnJoin = onlineOnJoin;
|
||||
|
@ -7,7 +7,6 @@ import com.djrapitops.plan.data.store.keys.CommonKeys;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@ -147,7 +146,7 @@ public class SessionsMutator {
|
||||
uniqueJoins.get(day).add(uuid);
|
||||
}
|
||||
|
||||
int total = MathUtils.sumInt(uniqueJoins.values().stream().map(Set::size));
|
||||
int total = (int) uniqueJoins.values().stream().mapToInt(Set::size).count();
|
||||
int numberOfDays = uniqueJoins.size();
|
||||
|
||||
if (numberOfDays == 0) {
|
||||
|
@ -20,7 +20,6 @@ import java.util.UUID;
|
||||
*/
|
||||
public class SessionCache {
|
||||
|
||||
private static final Map<UUID, Integer> firstSessionInformation = new HashMap<>();
|
||||
private static final Map<UUID, Session> activeSessions = new HashMap<>();
|
||||
protected final PlanSystem system;
|
||||
|
||||
@ -88,46 +87,4 @@ public class SessionCache {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for marking first Session Actions to be saved.
|
||||
*
|
||||
* @param uuid UUID of the new player.
|
||||
*/
|
||||
@Deprecated
|
||||
public void markFirstSession(UUID uuid) {
|
||||
firstSessionInformation.put(uuid, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a session is player's first session on the server.
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @return true / false
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isFirstSession(UUID uuid) {
|
||||
return firstSessionInformation.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void endFirstSessionActionTracking(UUID uuid) {
|
||||
firstSessionInformation.remove(uuid);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void firstSessionMessageSent(UUID uuid) {
|
||||
Integer msgCount = firstSessionInformation.getOrDefault(uuid, 0);
|
||||
msgCount++;
|
||||
firstSessionInformation.put(uuid, msgCount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getFirstSessionMsgCount(UUID uuid) {
|
||||
return firstSessionInformation.getOrDefault(uuid, 0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<UUID, Integer> getFirstSessionMsgCounts() {
|
||||
return firstSessionInformation;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.djrapitops.plan.system.database.databases.operation;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.ServerProfile;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.data.container.*;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.containers.ServerContainer;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
@ -16,12 +17,6 @@ public interface FetchOperations {
|
||||
|
||||
ServerContainer getServerContainer(UUID serverUUID);
|
||||
|
||||
@Deprecated
|
||||
ServerProfile getServerProfile(UUID serverUUID);
|
||||
|
||||
@Deprecated
|
||||
List<PlayerProfile> getPlayers(UUID serverUUID);
|
||||
|
||||
// UUIDs
|
||||
|
||||
PlayerContainer getPlayerContainer(UUID uuid);
|
||||
@ -68,9 +63,6 @@ public interface FetchOperations {
|
||||
|
||||
List<String> getNicknamesOfPlayerOnServer(UUID uuid, UUID serverUUID);
|
||||
|
||||
@Deprecated
|
||||
List<Action> getActions(UUID uuid);
|
||||
|
||||
Map<UUID, UserInfo> getUsers();
|
||||
|
||||
Map<UUID, Long> getLastSeenForAllPlayers();
|
||||
|
@ -5,7 +5,10 @@
|
||||
package com.djrapitops.plan.system.database.databases.operation;
|
||||
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.data.container.*;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
|
||||
@ -48,9 +51,6 @@ public interface SaveOperations {
|
||||
|
||||
void registerNewUser(UUID uuid, long registered, String name);
|
||||
|
||||
@Deprecated
|
||||
void action(UUID uuid, Action action);
|
||||
|
||||
void geoInfo(UUID uuid, GeoInfo geoInfo);
|
||||
|
||||
void playerWasKicked(UUID uuid);
|
||||
|
@ -35,7 +35,6 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
private final UsersTable usersTable;
|
||||
private final UserInfoTable userInfoTable;
|
||||
private final ActionsTable actionsTable;
|
||||
private final KillsTable killsTable;
|
||||
private final NicknamesTable nicknamesTable;
|
||||
private final SessionsTable sessionsTable;
|
||||
@ -73,7 +72,6 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
usersTable = new UsersTable(this);
|
||||
userInfoTable = new UserInfoTable(this);
|
||||
actionsTable = new ActionsTable(this);
|
||||
geoInfoTable = new GeoInfoTable(this);
|
||||
nicknamesTable = new NicknamesTable(this);
|
||||
sessionsTable = new SessionsTable(this);
|
||||
@ -165,7 +163,6 @@ public abstract class SQLDB extends Database {
|
||||
versionTable.setVersion(11);
|
||||
}
|
||||
if (version < 12) {
|
||||
actionsTable.alterTableV12();
|
||||
geoInfoTable.alterTableV12();
|
||||
versionTable.setVersion(12);
|
||||
}
|
||||
@ -222,8 +219,8 @@ public abstract class SQLDB extends Database {
|
||||
return new Table[]{
|
||||
serverTable, usersTable, userInfoTable, geoInfoTable,
|
||||
nicknamesTable, sessionsTable, killsTable,
|
||||
commandUseTable, actionsTable, tpsTable,
|
||||
worldTable, worldTimesTable, securityTable, transferTable
|
||||
commandUseTable, tpsTable, worldTable,
|
||||
worldTimesTable, securityTable, transferTable
|
||||
};
|
||||
}
|
||||
|
||||
@ -235,10 +232,9 @@ public abstract class SQLDB extends Database {
|
||||
public Table[] getAllTablesInRemoveOrder() {
|
||||
return new Table[]{
|
||||
transferTable, geoInfoTable, nicknamesTable, killsTable,
|
||||
worldTimesTable, sessionsTable, actionsTable,
|
||||
worldTable, userInfoTable, usersTable,
|
||||
commandUseTable, tpsTable, securityTable,
|
||||
serverTable
|
||||
worldTimesTable, sessionsTable, worldTable,
|
||||
userInfoTable, usersTable, commandUseTable,
|
||||
tpsTable, securityTable, serverTable
|
||||
};
|
||||
}
|
||||
|
||||
@ -416,10 +412,6 @@ public abstract class SQLDB extends Database {
|
||||
return serverTable;
|
||||
}
|
||||
|
||||
public ActionsTable getActionsTable() {
|
||||
return actionsTable;
|
||||
}
|
||||
|
||||
public UserInfoTable getUserInfoTable() {
|
||||
return userInfoTable;
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.djrapitops.plan.system.database.databases.sql.operation;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.ServerProfile;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.data.container.*;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PerServerContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
@ -131,63 +132,6 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
||||
return containers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerProfile getServerProfile(UUID serverUUID) {
|
||||
ServerProfile profile = new ServerProfile(serverUUID);
|
||||
|
||||
profile.setPlayers(getPlayers(serverUUID));
|
||||
profile.setTps(tpsTable.getTPSData(serverUUID));
|
||||
Optional<TPS> allTimePeak = tpsTable.getAllTimePeak(serverUUID);
|
||||
allTimePeak.ifPresent(peak -> {
|
||||
profile.setAllTimePeak(peak.getDate());
|
||||
profile.setAllTimePeakPlayers(peak.getPlayers());
|
||||
});
|
||||
Optional<TPS> lastPeak = tpsTable.getPeakPlayerCount(serverUUID, System.currentTimeMillis() - (TimeAmount.DAY.ms() * 2L));
|
||||
lastPeak.ifPresent(peak -> {
|
||||
profile.setLastPeakDate(peak.getDate());
|
||||
profile.setLastPeakPlayers(peak.getPlayers());
|
||||
});
|
||||
|
||||
profile.setCommandUsage(commandUseTable.getCommandUse(serverUUID));
|
||||
profile.setServerWorldtimes(worldTimesTable.getWorldTimesOfServer(serverUUID));
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerProfile> getPlayers(UUID serverUUID) {
|
||||
List<UserInfo> serverUserInfo = userInfoTable.getServerUserInfo(serverUUID);
|
||||
Map<UUID, Integer> timesKicked = usersTable.getAllTimesKicked();
|
||||
Map<UUID, List<Action>> actions = actionsTable.getServerActions(serverUUID);
|
||||
Map<UUID, List<GeoInfo>> geoInfo = geoInfoTable.getAllGeoInfo();
|
||||
|
||||
Map<UUID, List<Session>> sessions = sessionsTable.getSessionInfoOfServer(serverUUID);
|
||||
Map<UUID, Map<UUID, List<Session>>> map = new HashMap<>();
|
||||
map.put(serverUUID, sessions);
|
||||
killsTable.addKillsToSessions(map);
|
||||
worldTimesTable.addWorldTimesToSessions(map);
|
||||
|
||||
List<PlayerProfile> players = new ArrayList<>();
|
||||
|
||||
for (UserInfo userInfo : serverUserInfo) {
|
||||
UUID uuid = userInfo.getUuid();
|
||||
PlayerProfile profile = new PlayerProfile(uuid, userInfo.getName(), userInfo.getRegistered());
|
||||
profile.setTimesKicked(timesKicked.getOrDefault(uuid, 0));
|
||||
if (userInfo.isBanned()) {
|
||||
profile.bannedOnServer(serverUUID);
|
||||
}
|
||||
if (userInfo.isOperator()) {
|
||||
profile.oppedOnServer(serverUUID);
|
||||
}
|
||||
profile.setActions(actions.getOrDefault(uuid, new ArrayList<>()));
|
||||
profile.setGeoInformation(geoInfo.getOrDefault(uuid, new ArrayList<>()));
|
||||
profile.setSessions(serverUUID, sessions.getOrDefault(uuid, new ArrayList<>()));
|
||||
|
||||
players.add(profile);
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerContainer getPlayerContainer(UUID uuid) {
|
||||
PlayerContainer container = new PlayerContainer();
|
||||
@ -341,11 +285,6 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
||||
return nicknamesTable.getNicknames(uuid, serverUUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> getActions(UUID uuid) {
|
||||
return actionsTable.getActions(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, UserInfo> getUsers() {
|
||||
return usersTable.getUsers();
|
||||
|
@ -9,7 +9,6 @@ public class SQLOps {
|
||||
|
||||
protected final UsersTable usersTable;
|
||||
protected final UserInfoTable userInfoTable;
|
||||
protected final ActionsTable actionsTable;
|
||||
protected final KillsTable killsTable;
|
||||
protected final NicknamesTable nicknamesTable;
|
||||
protected final SessionsTable sessionsTable;
|
||||
@ -27,7 +26,6 @@ public class SQLOps {
|
||||
|
||||
usersTable = db.getUsersTable();
|
||||
userInfoTable = db.getUserInfoTable();
|
||||
actionsTable = db.getActionsTable();
|
||||
killsTable = db.getKillsTable();
|
||||
nicknamesTable = db.getNicknamesTable();
|
||||
sessionsTable = db.getSessionsTable();
|
||||
|
@ -5,7 +5,10 @@
|
||||
package com.djrapitops.plan.system.database.databases.sql.operation;
|
||||
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.data.container.*;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
@ -81,11 +84,6 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
||||
usersTable.registerUser(uuid, registered, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(UUID uuid, Action action) {
|
||||
actionsTable.insertAction(uuid, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void geoInfo(UUID uuid, GeoInfo geoInfo) {
|
||||
geoInfoTable.saveGeoInfo(uuid, geoInfo);
|
||||
|
@ -1,252 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Column;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Select;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Sql;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Table that is in charge of storing actions.
|
||||
*
|
||||
* Table Name: plan_actions
|
||||
*
|
||||
* For contained columns {@see Col}
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @see Action
|
||||
*/
|
||||
@Deprecated
|
||||
public class ActionsTable extends UserIDTable {
|
||||
|
||||
public ActionsTable(SQLDB db) {
|
||||
super("plan_actions", db);
|
||||
serverTable = db.getServerTable();
|
||||
insertStatement = "INSERT INTO " + tableName + " ("
|
||||
+ Col.USER_ID + ", "
|
||||
+ Col.SERVER_ID + ", "
|
||||
+ Col.ACTION_ID + ", "
|
||||
+ Col.DATE + ", "
|
||||
+ Col.ADDITIONAL_INFO
|
||||
+ ") VALUES ("
|
||||
+ usersTable.statementSelectID + ", "
|
||||
+ serverTable.statementSelectServerID + ", "
|
||||
+ "?, ?, ?)";
|
||||
}
|
||||
|
||||
private final ServerTable serverTable;
|
||||
private String insertStatement;
|
||||
|
||||
@Override
|
||||
public void createTable() throws DBInitException {
|
||||
ServerTable serverTable = db.getServerTable();
|
||||
createTable(TableSqlParser.createTable(tableName)
|
||||
.column(Col.USER_ID, Sql.INT).notNull()
|
||||
.column(Col.SERVER_ID, Sql.INT).notNull()
|
||||
.column(Col.DATE, Sql.LONG).notNull()
|
||||
.column(Col.ACTION_ID, Sql.INT).notNull()
|
||||
.column(Col.ADDITIONAL_INFO, Sql.varchar(300))
|
||||
.foreignKey(Col.USER_ID, usersTable.toString(), UsersTable.Col.ID)
|
||||
.foreignKey(Col.SERVER_ID, serverTable.toString(), ServerTable.Col.SERVER_ID)
|
||||
.toString());
|
||||
}
|
||||
|
||||
public void alterTableV12() {
|
||||
if (usingMySQL) {
|
||||
executeUnsafe("ALTER TABLE " + tableName + " MODIFY " + Col.ADDITIONAL_INFO + " VARCHAR(300)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get all Actions done by a user on this server.
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @return List of actions done by the player. Does not include the kills.
|
||||
*/
|
||||
public List<Action> getActions(UUID uuid) {
|
||||
String sql = Select.all(tableName)
|
||||
.where(Col.USER_ID + "=" + usersTable.statementSelectID)
|
||||
.toString();
|
||||
|
||||
return query(new QueryStatement<List<Action>>(sql, 5000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, uuid.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> processResults(ResultSet set) throws SQLException {
|
||||
List<Action> actions = new ArrayList<>();
|
||||
while (set.next()) {
|
||||
int serverID = set.getInt(Col.SERVER_ID.get());
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
Actions doneAction = Actions.getById(set.getInt(Col.ACTION_ID.get()));
|
||||
String additionalInfo = set.getString(Col.ADDITIONAL_INFO.get());
|
||||
actions.add(new Action(date, doneAction, additionalInfo, serverID));
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void insertAction(UUID uuid, Action action) {
|
||||
execute(new ExecStatement(insertStatement) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, ServerInfo.getServerUUID().toString());
|
||||
statement.setInt(3, action.getDoneAction().getId());
|
||||
statement.setLong(4, action.getDate());
|
||||
statement.setString(5, action.getAdditionalInfo());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<UUID, Map<UUID, List<Action>>> getAllActions() {
|
||||
String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as uuid";
|
||||
String serverIDColumn = serverTable + "." + ServerTable.Col.SERVER_ID;
|
||||
String serverUUIDColumn = serverTable + "." + ServerTable.Col.SERVER_UUID + " as s_uuid";
|
||||
String sql = "SELECT " +
|
||||
Col.ACTION_ID + ", " +
|
||||
Col.DATE + ", " +
|
||||
Col.ADDITIONAL_INFO + ", " +
|
||||
usersUUIDColumn + ", " +
|
||||
serverUUIDColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.USER_ID +
|
||||
" INNER JOIN " + serverTable + " on " + serverIDColumn + "=" + Col.SERVER_ID;
|
||||
|
||||
return query(new QueryAllStatement<Map<UUID, Map<UUID, List<Action>>>>(sql, 20000) {
|
||||
@Override
|
||||
public Map<UUID, Map<UUID, List<Action>>> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, Map<UUID, List<Action>>> map = new HashMap<>();
|
||||
while (set.next()) {
|
||||
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
|
||||
UUID uuid = UUID.fromString(set.getString("uuid"));
|
||||
|
||||
Map<UUID, List<Action>> serverMap = map.getOrDefault(serverUUID, new HashMap<>());
|
||||
List<Action> actions = serverMap.getOrDefault(uuid, new ArrayList<>());
|
||||
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
Actions doneAction = Actions.getById(set.getInt(Col.ACTION_ID.get()));
|
||||
String additionalInfo = set.getString(Col.ADDITIONAL_INFO.get());
|
||||
|
||||
actions.add(new Action(date, doneAction, additionalInfo, -1));
|
||||
|
||||
serverMap.put(uuid, actions);
|
||||
map.put(serverUUID, serverMap);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<UUID, List<Action>> getServerActions(UUID serverUUID) {
|
||||
String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as uuid";
|
||||
String sql = "SELECT " +
|
||||
Col.ACTION_ID + ", " +
|
||||
Col.DATE + ", " +
|
||||
Col.ADDITIONAL_INFO + ", " +
|
||||
usersUUIDColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.USER_ID +
|
||||
" WHERE " + serverTable.statementSelectServerID + "=" + Col.SERVER_ID;
|
||||
|
||||
return query(new QueryStatement<Map<UUID, List<Action>>>(sql, 20000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, List<Action>> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, List<Action>> map = new HashMap<>();
|
||||
while (set.next()) {
|
||||
UUID uuid = UUID.fromString(set.getString("uuid"));
|
||||
|
||||
List<Action> actions = map.getOrDefault(uuid, new ArrayList<>());
|
||||
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
Actions doneAction = Actions.getById(set.getInt(Col.ACTION_ID.get()));
|
||||
String additionalInfo = set.getString(Col.ADDITIONAL_INFO.get());
|
||||
|
||||
actions.add(new Action(date, doneAction, additionalInfo, -1));
|
||||
|
||||
map.put(uuid, actions);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void insertActions(Map<UUID, Map<UUID, List<Action>>> allActions) {
|
||||
if (Verify.isEmpty(allActions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
executeBatch(new ExecStatement(insertStatement) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
for (UUID serverUUID : allActions.keySet()) {
|
||||
// Every User
|
||||
for (Map.Entry<UUID, List<Action>> entry : allActions.get(serverUUID).entrySet()) {
|
||||
UUID uuid = entry.getKey();
|
||||
// Every Action
|
||||
List<Action> actions = entry.getValue();
|
||||
for (Action action : actions) {
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, serverUUID.toString());
|
||||
statement.setInt(3, action.getDoneAction().getId());
|
||||
statement.setLong(4, action.getDate());
|
||||
statement.setString(5, action.getAdditionalInfo());
|
||||
statement.addBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public enum Col implements Column {
|
||||
USER_ID(UserIDTable.Col.USER_ID.get()),
|
||||
SERVER_ID("server_id"),
|
||||
DATE("date"),
|
||||
ACTION_ID("action_id"),
|
||||
ADDITIONAL_INFO("additional_info");
|
||||
|
||||
private final String column;
|
||||
|
||||
Col(String column) {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return column;
|
||||
}
|
||||
}
|
||||
}
|
@ -80,21 +80,12 @@ public class BatchOperationTable extends Table {
|
||||
copyTPS(toDB);
|
||||
copyWebUsers(toDB);
|
||||
copyCommandUse(toDB);
|
||||
copyActions(toDB);
|
||||
copyIPsAndGeolocs(toDB);
|
||||
copyNicknames(toDB);
|
||||
copySessions(toDB);
|
||||
copyUserInfo(toDB);
|
||||
}
|
||||
|
||||
public void copyActions(BatchOperationTable toDB) {
|
||||
if (toDB.equals(this)) {
|
||||
return;
|
||||
}
|
||||
Log.debug("Batch Copy Actions");
|
||||
toDB.db.getActionsTable().insertActions(db.getActionsTable().getAllActions());
|
||||
}
|
||||
|
||||
public void copyCommandUse(BatchOperationTable toDB) {
|
||||
if (toDB.equals(this)) {
|
||||
return;
|
||||
|
@ -49,8 +49,6 @@ public class Version8TransferTable extends TransferTable {
|
||||
db.getWorldTimesTable().createTable();
|
||||
|
||||
dropTable("plan_actions");
|
||||
db.getActionsTable().createTable();
|
||||
|
||||
dropTable("plan_gamemodetimes");
|
||||
dropTable("temp_nicks");
|
||||
dropTable("temp_kills");
|
||||
|
@ -15,7 +15,6 @@ import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.webserver.pages.parsing.AnalysisPage;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
@ -53,9 +52,8 @@ public class GenerateAnalysisPageRequest extends InfoRequestWithVariables implem
|
||||
throw new BadRequestException("Requested Analysis page from wrong server.");
|
||||
}
|
||||
|
||||
if (!Analysis.isAnalysisBeingRun()) {
|
||||
generateAndCache(serverUUID);
|
||||
}
|
||||
// TODO Create a new system to prevent multiple concurrent Analysis
|
||||
generateAndCache(serverUUID);
|
||||
|
||||
return DefaultResponses.SUCCESS.get();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.system.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.player.NameProcessor;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
@ -42,12 +41,6 @@ public class ChatListener implements Listener {
|
||||
UUID uuid = p.getUniqueId();
|
||||
String name = p.getName();
|
||||
String displayName = p.getDisplayName();
|
||||
|
||||
SessionCache sessionCache = SessionCache.getInstance();
|
||||
if (sessionCache.isFirstSession(uuid)) {
|
||||
sessionCache.firstSessionMessageSent(uuid);
|
||||
}
|
||||
|
||||
Processing.submit(new NameProcessor(uuid, name, displayName));
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.player.*;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -94,12 +93,10 @@ public class PlayerOnlineListener implements Listener {
|
||||
String playerName = player.getName();
|
||||
String displayName = player.getDisplayName();
|
||||
|
||||
int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline();
|
||||
|
||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, time, world, gm));
|
||||
|
||||
Processing.submit(
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,
|
||||
new RegisterProcessor(uuid, player.getFirstPlayed(), playerName,
|
||||
new IPUpdateProcessor(uuid, ip, time),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new PlayerPageUpdateProcessor(uuid)
|
||||
@ -127,13 +124,6 @@ public class PlayerOnlineListener implements Listener {
|
||||
Processing.submit(new BanAndOpProcessor(uuid, player.isBanned(), player.isOp()));
|
||||
Processing.submit(new EndSessionProcessor(uuid, time));
|
||||
Processing.submit(new NetworkPageUpdateProcessor());
|
||||
|
||||
SessionCache sessionCache = SessionCache.getInstance();
|
||||
if (sessionCache.isFirstSession(uuid)) {
|
||||
int messagesSent = sessionCache.getFirstSessionMsgCount(uuid);
|
||||
Processing.submit(new FirstLeaveProcessor(uuid, time, messagesSent));
|
||||
}
|
||||
|
||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.djrapitops.plan.system.listeners.sponge;
|
||||
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.player.NameProcessor;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
@ -36,12 +35,6 @@ public class SpongeChatListener {
|
||||
UUID uuid = player.getUniqueId();
|
||||
String name = player.getName();
|
||||
String displayName = player.getDisplayNameData().displayName().get().toPlain();
|
||||
|
||||
SessionCache sessionCache = SessionCache.getInstance();
|
||||
if (sessionCache.isFirstSession(uuid)) {
|
||||
sessionCache.firstSessionMessageSent(uuid);
|
||||
}
|
||||
|
||||
Processing.submit(new NameProcessor(uuid, name, displayName));
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.player.*;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.spongepowered.api.Sponge;
|
||||
@ -97,12 +96,10 @@ public class SpongePlayerListener {
|
||||
String playerName = player.getName();
|
||||
String displayName = player.getDisplayNameData().displayName().get().toPlain();
|
||||
|
||||
int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline();
|
||||
|
||||
SessionCache.getInstance().cacheSession(uuid, new Session(uuid, time, world, gm));
|
||||
|
||||
Processing.submit(
|
||||
new RegisterProcessor(uuid, time, time, playerName, playersOnline,
|
||||
new RegisterProcessor(uuid, time, playerName,
|
||||
new IPUpdateProcessor(uuid, ip, time),
|
||||
new NameProcessor(uuid, playerName, displayName),
|
||||
new PlayerPageUpdateProcessor(uuid)
|
||||
@ -130,13 +127,6 @@ public class SpongePlayerListener {
|
||||
Processing.submit(new BanAndOpProcessor(uuid, isBanned(player.getProfile()), false));
|
||||
Processing.submit(new EndSessionProcessor(uuid, time));
|
||||
Processing.submit(new NetworkPageUpdateProcessor());
|
||||
|
||||
SessionCache sessionCache = SessionCache.getInstance();
|
||||
if (sessionCache.isFirstSession(uuid)) {
|
||||
int messagesSent = sessionCache.getFirstSessionMsgCount(uuid);
|
||||
Processing.submit(new FirstLeaveProcessor(uuid, time, messagesSent));
|
||||
}
|
||||
|
||||
Processing.submit(new PlayerPageUpdateProcessor(uuid));
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.system.processing.processors.player;
|
||||
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Processor for inserting a FIRST_LOGOUT Action.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public class FirstLeaveProcessor implements CriticalRunnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final Action leaveAction;
|
||||
|
||||
public FirstLeaveProcessor(UUID uuid, long time, int messagesSent) {
|
||||
this.uuid = uuid;
|
||||
leaveAction = new Action(time, Actions.FIRST_LOGOUT, "Messages sent: " + messagesSent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Database.getActive().save().action(uuid, leaveAction);
|
||||
} finally {
|
||||
SessionCache.getInstance().endFirstSessionActionTracking(uuid);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,9 +4,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.system.processing.processors.player;
|
||||
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
@ -23,16 +20,12 @@ public class RegisterProcessor implements CriticalRunnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final long registered;
|
||||
private final long time;
|
||||
private final int playersOnline;
|
||||
private final String name;
|
||||
private final Runnable[] afterProcess;
|
||||
|
||||
public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline, Runnable... afterProcess) {
|
||||
public RegisterProcessor(UUID uuid, long registered, String name, Runnable... afterProcess) {
|
||||
this.uuid = uuid;
|
||||
this.registered = registered;
|
||||
this.time = time;
|
||||
this.playersOnline = playersOnline;
|
||||
this.name = name;
|
||||
this.afterProcess = afterProcess;
|
||||
}
|
||||
@ -48,11 +41,6 @@ public class RegisterProcessor implements CriticalRunnable {
|
||||
if (!db.check().isPlayerRegisteredOnThisServer(uuid)) {
|
||||
db.save().registerNewUserOnThisServer(uuid, registered);
|
||||
}
|
||||
if (db.fetch().getActions(uuid).size() > 0) {
|
||||
return;
|
||||
}
|
||||
SessionCache.getInstance().markFirstSession(uuid);
|
||||
db.save().action(uuid, new Action(time, Actions.FIRST_SESSION, "Online: " + playersOnline + " Players"));
|
||||
} finally {
|
||||
for (Runnable runnable : afterProcess) {
|
||||
Processing.submit(runnable);
|
||||
|
@ -7,7 +7,6 @@ import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||
import com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
|
||||
@ -22,11 +21,10 @@ public class BootAnalysisTask extends AbsRunnable {
|
||||
try {
|
||||
String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString();
|
||||
Log.info(bootAnalysisRunMsg);
|
||||
if (!Analysis.isAnalysisBeingRun()) {
|
||||
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
||||
InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID()))
|
||||
);
|
||||
}
|
||||
// TODO Create a new system to prevent multiple concurrent Analysis
|
||||
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
||||
InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID()))
|
||||
);
|
||||
} catch (IllegalStateException e) {
|
||||
if (!PlanPlugin.getInstance().isReloading()) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
|
@ -5,7 +5,6 @@ import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.WebExceptionLogger;
|
||||
import com.djrapitops.plan.system.info.request.GenerateAnalysisPageRequest;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
|
||||
@ -18,11 +17,10 @@ public class PeriodicAnalysisTask extends AbsRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!Analysis.isAnalysisBeingRun()) {
|
||||
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
||||
InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID()))
|
||||
);
|
||||
}
|
||||
// TODO Create a new system to prevent multiple concurrent Analysis
|
||||
WebExceptionLogger.logIfOccurs(this.getClass(), () ->
|
||||
InfoSystem.getInstance().sendRequest(new GenerateAnalysisPageRequest(ServerInfo.getServerUUID()))
|
||||
);
|
||||
} catch (IllegalStateException e) {
|
||||
if (!PlanPlugin.getInstance().isReloading()) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
||||
import static com.djrapitops.plan.data.store.keys.AnalysisKeys.*;
|
||||
|
||||
/**
|
||||
* Used for parsing a Html String out of AnalysisData and the html file.
|
||||
* Used for parsing a Html String out of AnalysisContainer and the html file.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,8 +5,6 @@
|
||||
package com.djrapitops.plan.system.webserver.pages.parsing;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.containers.PerServerContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
@ -36,7 +34,6 @@ import com.djrapitops.plan.utilities.html.graphs.pie.ServerPreferencePie;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.utilities.html.structure.ServerAccordion;
|
||||
import com.djrapitops.plan.utilities.html.structure.SessionAccordion;
|
||||
import com.djrapitops.plan.utilities.html.tables.ActionsTable;
|
||||
import com.djrapitops.plan.utilities.html.tables.GeoInfoTable;
|
||||
import com.djrapitops.plan.utilities.html.tables.NicknameTable;
|
||||
import com.djrapitops.plan.utilities.html.tables.PlayerSessionTable;
|
||||
@ -232,8 +229,6 @@ public class InspectPage extends Page {
|
||||
addValue("sessionCountWeek", sessionCountWeek);
|
||||
addValue("sessionCountMonth", sessionCountMonth);
|
||||
|
||||
addValue("tableBodyActions", new ActionsTable(Collections.singletonList(new Action(0, Actions.UNKNOWN, "Deprecated"))).parseBody());
|
||||
|
||||
String punchCardData = new PunchCardGraph(allSessions).toHighChartsSeries();
|
||||
WorldTimes worldTimes = container.getValue(PlayerKeys.WORLD_TIMES).orElse(new WorldTimes(new HashMap<>()));
|
||||
|
||||
|
@ -1,208 +0,0 @@
|
||||
package com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.ServerProfile;
|
||||
import com.djrapitops.plan.data.calculation.AnalysisData;
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.plugin.BanData;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.tasks.ServerTaskSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class Analysis implements Callable<AnalysisData> {
|
||||
|
||||
private static Long refreshDate;
|
||||
private final UUID serverUUID;
|
||||
private final Database database;
|
||||
|
||||
private static ServerProfile serverProfile;
|
||||
private final DataCache dataCache;
|
||||
|
||||
private static Future<AnalysisData> future;
|
||||
|
||||
private boolean analysingThisServer;
|
||||
|
||||
private Analysis(UUID serverUUID, Database database, DataCache dataCache) {
|
||||
this.serverUUID = serverUUID;
|
||||
analysingThisServer = ServerInfo.getServerUUID().equals(serverUUID);
|
||||
this.database = database;
|
||||
this.dataCache = dataCache;
|
||||
}
|
||||
|
||||
public static Optional<Long> getRefreshDate() {
|
||||
return Optional.ofNullable(refreshDate);
|
||||
}
|
||||
|
||||
public static AnalysisData runAnalysisFor(UUID serverUUID, Database database, DataCache dataCache) throws Exception {
|
||||
try {
|
||||
future = future != null ? future : Processing.submit(new Analysis(serverUUID, database, dataCache));
|
||||
return future.get();
|
||||
} finally {
|
||||
future = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only available during Analysis.
|
||||
*
|
||||
* @return ServerProfile being analyzed or null if analysis is not being run.
|
||||
*/
|
||||
// TODO Remove use of this method in PluginData
|
||||
public static ServerProfile getServerProfile() {
|
||||
return serverProfile;
|
||||
}
|
||||
|
||||
// TODO Remove use of this method and replace with a new source for the method
|
||||
@Deprecated
|
||||
public static boolean isAnalysisBeingRun() {
|
||||
return serverProfile != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisData call() {
|
||||
return runAnalysis();
|
||||
}
|
||||
|
||||
private static void updateRefreshDate() {
|
||||
Analysis.refreshDate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void updatePlayerNameCache(ServerProfile profile) {
|
||||
for (PlayerProfile player : profile.getPlayers()) {
|
||||
dataCache.updateNames(player.getUuid(), player.getName(), null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBannedByPlugins(ServerProfile profile) {
|
||||
if (!analysingThisServer) {
|
||||
return;
|
||||
}
|
||||
List<BanData> banPlugins = HookHandler.getInstance().getAdditionalDataSources().stream()
|
||||
.filter(p -> p instanceof BanData)
|
||||
.map(p -> (BanData) p)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Set<UUID> banned = new HashSet<>();
|
||||
for (BanData banPlugin : banPlugins) {
|
||||
Set<UUID> uuids = profile.getUuids();
|
||||
try {
|
||||
banned.addAll(banPlugin.filterBanned(uuids));
|
||||
} catch (Exception | NoSuchMethodError | NoClassDefFoundError | NoSuchFieldError e) {
|
||||
Log.toLog("PluginData caused exception: " + banPlugin.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
profile.getPlayers().stream().filter(player -> banned.contains(player.getUuid()))
|
||||
.forEach(player -> player.bannedOnServer(serverUUID));
|
||||
}
|
||||
|
||||
private void log(String msg) {
|
||||
if (Settings.ANALYSIS_LOG.isTrue()) {
|
||||
Log.info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<PluginData, AnalysisContainer> analyzeAdditionalPluginData(Set<UUID> uuids) {
|
||||
if (!analysingThisServer) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Map<PluginData, AnalysisContainer> containers = new HashMap<>();
|
||||
|
||||
Benchmark.start("Analysis", "Analysis: 3rd party");
|
||||
List<PluginData> sources = HookHandler.getInstance().getAdditionalDataSources();
|
||||
|
||||
Log.logDebug("Analysis", "Additional Sources: " + sources.size());
|
||||
sources.parallelStream().forEach(source -> {
|
||||
PlanPlugin plugin = PlanPlugin.getInstance();
|
||||
StaticHolder.saveInstance(this.getClass(), plugin.getClass());
|
||||
try {
|
||||
Benchmark.start("Analysis", "Analysis: Source " + source.getSourcePlugin());
|
||||
|
||||
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
|
||||
if (container != null && !container.isEmpty()) {
|
||||
containers.put(source, container);
|
||||
}
|
||||
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
||||
Log.error("A PluginData-source caused an exception: " + source.getSourcePlugin());
|
||||
Log.toLog(this.getClass(), e);
|
||||
} finally {
|
||||
Benchmark.stop("Analysis", "Analysis: Source " + source.getSourcePlugin());
|
||||
}
|
||||
});
|
||||
Benchmark.stop("Analysis", "Analysis: 3rd party");
|
||||
return containers;
|
||||
}
|
||||
|
||||
private AnalysisData runAnalysis() {
|
||||
((ServerTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis();
|
||||
|
||||
Benchmark.start("Analysis: Total");
|
||||
log(Locale.get(Msg.ANALYSIS_START).toString());
|
||||
return analyze();
|
||||
}
|
||||
|
||||
private static void setServerProfile(ServerProfile serverProfile) {
|
||||
Analysis.serverProfile = serverProfile;
|
||||
}
|
||||
|
||||
private AnalysisData analyze() {
|
||||
log(Locale.get(Msg.ANALYSIS_FETCH).toString());
|
||||
Log.logDebug("Analysis", "Analysis Fetch Phase");
|
||||
Benchmark.start("Analysis", "Analysis: Fetch Phase");
|
||||
try {
|
||||
AnalysisData analysisData = new AnalysisData();
|
||||
|
||||
ServerProfile server = database.fetch().getServerProfile(serverUUID);
|
||||
if (analysingThisServer) {
|
||||
server.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions()));
|
||||
}
|
||||
Analysis.setServerProfile(server);
|
||||
|
||||
updatePlayerNameCache(server);
|
||||
|
||||
long fetchPhaseLength = Benchmark.stop("Analysis", "Analysis: Fetch Phase");
|
||||
setBannedByPlugins(server);
|
||||
|
||||
Benchmark.start("Analysis", "Analysis: Data Analysis");
|
||||
Log.logDebug("Analysis", "Analysis Phase");
|
||||
|
||||
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(server.getPlayerCount(), fetchPhaseLength));
|
||||
|
||||
analysisData.analyze(server);
|
||||
|
||||
Benchmark.stop("Analysis", "Analysis: Data Analysis");
|
||||
|
||||
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
|
||||
return analysisData;
|
||||
} finally {
|
||||
Analysis.updateRefreshDate();
|
||||
long time = Benchmark.stop("Analysis", "Analysis: Total");
|
||||
Log.logDebug("Analysis");
|
||||
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, ""));
|
||||
Analysis.setServerProfile(null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.data.store.mutators.RetentionData;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.settings.WorldAliasSettings;
|
||||
@ -54,51 +52,6 @@ public class AnalysisUtils {
|
||||
return uuids.size();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long after) {
|
||||
Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>();
|
||||
|
||||
sessions.forEach((uuid, s) -> {
|
||||
for (Session session : s) {
|
||||
if (session.getSessionStart() < after) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int day = getDayOfYear(session);
|
||||
|
||||
uniqueJoins.computeIfAbsent(day, computedDay -> new HashSet<>());
|
||||
uniqueJoins.get(day).add(uuid);
|
||||
}
|
||||
});
|
||||
|
||||
int total = uniqueJoins.values().stream().mapToInt(Set::size).sum();
|
||||
int numberOfDays = uniqueJoins.size();
|
||||
|
||||
if (numberOfDays == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return total / numberOfDays;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static long getNewUsersPerDay(List<Long> registers, long after, long total) {
|
||||
Set<Integer> days = new HashSet<>();
|
||||
for (Long date : registers) {
|
||||
if (date < after) {
|
||||
continue;
|
||||
}
|
||||
int day = getDayOfYear(date);
|
||||
days.add(day);
|
||||
}
|
||||
int numberOfDays = days.size();
|
||||
|
||||
if (numberOfDays == 0) {
|
||||
return 0;
|
||||
}
|
||||
return total / numberOfDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the session start list into a list of int arrays.
|
||||
* <p>
|
||||
@ -128,17 +81,6 @@ public class AnalysisUtils {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static int getDayOfYear(Session session) {
|
||||
return getDayOfYear(session.getUnsafe(SessionKeys.START));
|
||||
|
||||
}
|
||||
|
||||
public static int getDayOfYear(long date) {
|
||||
Calendar day = Calendar.getInstance();
|
||||
day.setTimeInMillis(date);
|
||||
return day.get(Calendar.DAY_OF_YEAR);
|
||||
}
|
||||
|
||||
public static double getAveragePerDay(long after, long before, long total) {
|
||||
return (double) total / getNumberOfDaysBetween(after, before);
|
||||
}
|
||||
@ -169,26 +111,6 @@ public class AnalysisUtils {
|
||||
return userSessions;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static TreeMap<Long, Map<String, Set<UUID>>> turnToActivityDataMap(long time, List<PlayerProfile> players) {
|
||||
TreeMap<Long, Map<String, Set<UUID>>> activityData = new TreeMap<>();
|
||||
if (!players.isEmpty()) {
|
||||
for (PlayerProfile player : players) {
|
||||
for (long date = time; date >= time - TimeAmount.MONTH.ms() * 2L; date -= TimeAmount.WEEK.ms()) {
|
||||
ActivityIndex activityIndex = player.getActivityIndex(date);
|
||||
String activityGroup = activityIndex.getGroup();
|
||||
|
||||
Map<String, Set<UUID>> map = activityData.getOrDefault(date, new HashMap<>());
|
||||
Set<UUID> uuids = map.getOrDefault(activityGroup, new HashSet<>());
|
||||
uuids.add(player.getUuid());
|
||||
map.put(activityGroup, uuids);
|
||||
activityData.put(date, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
return activityData;
|
||||
}
|
||||
|
||||
public static Map<String, Long> getPlaytimePerAlias(WorldTimes worldTimes) {
|
||||
// WorldTimes Map<String, GMTimes>
|
||||
Map<String, Long> playtimePerWorld = worldTimes.getWorldTimes()
|
||||
|
@ -1,176 +0,0 @@
|
||||
package com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class MathUtils {
|
||||
|
||||
private static final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH);
|
||||
private static final DecimalFormat decimalFormat = new DecimalFormat("#.##", decimalFormatSymbols);
|
||||
|
||||
/**
|
||||
* Constructor used to hide the public constructor
|
||||
*/
|
||||
private MathUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the average of a Stream of Integers.
|
||||
* If there are no components in the Stream, it will return 0.
|
||||
*
|
||||
* @param values The Stream of Integers.
|
||||
* @return The average
|
||||
*/
|
||||
public static double averageInt(Stream<Integer> values) {
|
||||
OptionalDouble average = values.mapToInt(i -> i).average();
|
||||
|
||||
return average.isPresent() ? average.getAsDouble() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the average of a Collection with Long as Entry.
|
||||
* If the collection is empty, it will return 0.
|
||||
*
|
||||
* @param values The Collection with Long as the Entry.
|
||||
* @return The average
|
||||
* @see #averageLong(Stream)
|
||||
*/
|
||||
public static long averageLong(Collection<Long> values) {
|
||||
return averageLong(values.stream());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the average of a Stream of Longs.
|
||||
* If there are no components in the Stream, it will return 0.
|
||||
*
|
||||
* @param values The Stream of Longs.
|
||||
* @return The average
|
||||
* @see #averageLong(Collection)
|
||||
*/
|
||||
public static long averageLong(Stream<Long> values) {
|
||||
OptionalDouble average = values.mapToLong(i -> i).average();
|
||||
|
||||
return average.isPresent() ? (long) average.getAsDouble() : 0L;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the average of a Stream of Double.
|
||||
* If there are no components in the Stream, it will return 0.
|
||||
*
|
||||
* @param values The Stream of Double.
|
||||
* @return The average
|
||||
*/
|
||||
public static double averageDouble(Stream<Double> values) {
|
||||
OptionalDouble average = values.mapToDouble(i -> i).average();
|
||||
|
||||
return average.isPresent() ? average.getAsDouble() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the average
|
||||
*
|
||||
* @param total The total summed amount of all Integers
|
||||
* @param size The amount of all Integers that were summed
|
||||
* @return The average
|
||||
* @see #averageLong(long, long)
|
||||
*/
|
||||
public static double average(int total, int size) {
|
||||
return (double) total / size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the average
|
||||
*
|
||||
* @param total The total summed amount of all Longs
|
||||
* @param size The amount of all Longs that were summed
|
||||
* @return The average
|
||||
* @see #average(int, int)
|
||||
*/
|
||||
public static long averageLong(long total, long size) {
|
||||
if (size == 0) {
|
||||
return -1L;
|
||||
}
|
||||
return total / size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts all Booleans that are true in the Stream of Booleans
|
||||
*
|
||||
* @param values The Stream of Booleans
|
||||
* @return The amount of Booleans that are true
|
||||
*/
|
||||
public static long countTrueBoolean(Stream<Boolean> values) {
|
||||
return values.filter(value -> value).count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sums all Integers in a Stream of Serializable
|
||||
*
|
||||
* @param values The Stream of Serializable
|
||||
* @return The sum
|
||||
* @see #sumLong(Stream)
|
||||
* @see #sumDouble(Stream)
|
||||
*/
|
||||
public static int sumInt(Stream<Serializable> values) {
|
||||
return values
|
||||
.mapToInt(value -> (Integer) value)
|
||||
.sum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sums all Longs in a Stream of Serializable
|
||||
*
|
||||
* @param values The Stream of Serializable
|
||||
* @return The sum
|
||||
* @see #sumInt(Stream)
|
||||
* @see #sumDouble(Stream)
|
||||
*/
|
||||
public static long sumLong(Stream<Serializable> values) {
|
||||
return values
|
||||
.mapToLong(value -> (Long) value)
|
||||
.sum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sums all Doubles in a Stream of Serializable
|
||||
*
|
||||
* @param values The Stream of Serializable
|
||||
* @return The sum
|
||||
* @see #sumLong(Stream)
|
||||
* @see #sumInt(Stream)
|
||||
*/
|
||||
public static double sumDouble(Stream<Serializable> values) {
|
||||
return values
|
||||
.mapToDouble(value -> (Double) value)
|
||||
.sum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds the double to a double with two digits at the end.
|
||||
* Output: #.##
|
||||
*
|
||||
* @param number The number that's rounded
|
||||
* @return The rounded number
|
||||
*/
|
||||
public static double round(double number) {
|
||||
return Double.valueOf(decimalFormat.format(number));
|
||||
}
|
||||
|
||||
public static double averageDouble(double amount, double size) {
|
||||
if (size == 0) {
|
||||
return -1;
|
||||
}
|
||||
return amount / size;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.djrapitops.plan.utilities.comparators;
|
||||
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator for comparing Actions so that latest is the first component.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class ActionComparator implements Comparator<Action> {
|
||||
|
||||
@Override
|
||||
public int compare(Action o1, Action o2) {
|
||||
return -Long.compare(o1.getDate(), o2.getDate());
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.comparators;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Comparator for PlayerProfile so that most recently seen is first.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerProfileLastPlayedComparator implements Comparator<PlayerProfile> {
|
||||
|
||||
@Override
|
||||
public int compare(PlayerProfile u1, PlayerProfile u2) {
|
||||
return Long.compare(u2.getLastSeen(), u1.getLastSeen());
|
||||
}
|
||||
}
|
@ -9,8 +9,6 @@ import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
@ -92,12 +90,12 @@ public class HtmlStructure {
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
// TODO Rework into NetworkPage generation
|
||||
public static String createServerContainer() {
|
||||
ServerProperties properties = ServerInfo.getServerProperties();
|
||||
int maxPlayers = properties.getMaxPlayers();
|
||||
int online = properties.getOnlinePlayers();
|
||||
Optional<Long> analysisRefreshDate = Analysis.getRefreshDate();
|
||||
String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStampClock).orElse("-");
|
||||
String refresh = "-";
|
||||
|
||||
Server server = ServerInfo.getServer();
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
||||
import com.djrapitops.plan.utilities.html.tables.PluginPlayersTable;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
@ -78,7 +77,8 @@ public class AnalysisPluginsTabContentCreator {
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\"><h2><i class=\"fa fa-users\"></i> Plugin Data</h2></div>" +
|
||||
"<div class=\"body\">" +
|
||||
new PluginPlayersTable(containers, Analysis.getServerProfile().getPlayers()).parseHtml() +
|
||||
// TODO Start using ServerContainer and PlayerContainers instead
|
||||
new PluginPlayersTable(containers, new ArrayList<>()).parseHtml() +
|
||||
"</div></div></div>" +
|
||||
"</div></div></div>";
|
||||
|
||||
|
@ -4,13 +4,12 @@
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.html.structure;
|
||||
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PerServerContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PerServerKeys;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
@ -19,7 +18,10 @@ import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plugin.utilities.Format;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* HTML utility class for creating a Server Accordion.
|
||||
@ -64,21 +66,21 @@ public class ServerAccordion extends AbstractAccordion {
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
WorldTimes worldTimes = container.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes(new HashMap<>()));
|
||||
|
||||
List<Session> sessions = container.getValue(PerServerKeys.SESSIONS).orElse(new ArrayList<>());
|
||||
SessionsMutator sessionsMutator = SessionsMutator.forContainer(container);
|
||||
|
||||
boolean banned = container.getValue(PerServerKeys.BANNED).orElse(false);
|
||||
boolean operator = container.getValue(PerServerKeys.OPERATOR).orElse(false);
|
||||
long registered = container.getValue(PerServerKeys.REGISTERED).orElse(0L);
|
||||
|
||||
long playtime = PlayerProfile.getPlaytime(sessions.stream());
|
||||
long afkTime = PlayerProfile.getAFKTime(sessions.stream());
|
||||
int sessionCount = sessions.size();
|
||||
long sessionMedian = PlayerProfile.getSessionMedian(sessions.stream());
|
||||
long longestSession = PlayerProfile.getLongestSession(sessions.stream());
|
||||
long playtime = sessionsMutator.toPlaytime();
|
||||
long afkTime = sessionsMutator.toAfkTime();
|
||||
int sessionCount = sessionsMutator.count();
|
||||
long sessionMedian = sessionsMutator.toMedianSessionLength();
|
||||
long longestSession = sessionsMutator.toLongestSessionLength();
|
||||
|
||||
long mobKills = PlayerProfile.getMobKillCount(sessions.stream());
|
||||
long playerKills = PlayerProfile.getPlayerKills(sessions.stream()).count();
|
||||
long deaths = PlayerProfile.getDeathCount(sessions.stream());
|
||||
long mobKills = sessionsMutator.toMobKillCount();
|
||||
long playerKills = sessionsMutator.toPlayerKillCount();
|
||||
long deaths = sessionsMutator.toDeathCount();
|
||||
|
||||
String play = timeFormatter.apply(playtime);
|
||||
String afk = timeFormatter.apply(afkTime);
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatter;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utility Class for creating Actions Table for inspect page.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class ActionsTable extends TableContainer {
|
||||
|
||||
public ActionsTable(List<Action> actions) {
|
||||
super("Date", "Action", "Info");
|
||||
|
||||
if (actions.isEmpty()) {
|
||||
addRow("No Actions");
|
||||
} else {
|
||||
addValues(actions);
|
||||
}
|
||||
}
|
||||
|
||||
private void addValues(Iterable<Action> actions) {
|
||||
int i = 0;
|
||||
Formatter<DateHolder> formatter = Formatters.year();
|
||||
for (Action action : actions) {
|
||||
if (i > 50) {
|
||||
break;
|
||||
}
|
||||
addRow(
|
||||
formatter.apply(action),
|
||||
action.getDoneAction().toString(),
|
||||
HtmlUtils.swapColorsToSpan(action.getAdditionalInfo())
|
||||
);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.store.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
*/
|
||||
// TODO Start using TableContainer for both tables
|
||||
public class PlayersTableCreator {
|
||||
|
||||
/**
|
||||
* Constructor used to hide the public constructor
|
||||
*/
|
||||
private PlayersTableCreator() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static String createTable(List<PlayerProfile> players) {
|
||||
if (players.isEmpty()) {
|
||||
return Html.TABLELINE_PLAYERS.parse("<b>No Players</b>", "", "", "", "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
StringBuilder html = new StringBuilder();
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
UUID serverUUID = ServerInfo.getServerUUID();
|
||||
|
||||
int i = 0;
|
||||
int maxPlayers = Settings.MAX_PLAYERS.getNumber();
|
||||
if (maxPlayers <= 0) {
|
||||
maxPlayers = 2000;
|
||||
}
|
||||
for (PlayerProfile profile : players) {
|
||||
if (i >= maxPlayers) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
boolean isBanned = profile.isBanned();
|
||||
long loginTimes = profile.getSessionCount(serverUUID);
|
||||
long playtime = profile.getPlaytime(serverUUID);
|
||||
long registered = profile.getRegistered();
|
||||
|
||||
long lastSeen = profile.getLastSeen();
|
||||
|
||||
ActivityIndex activityIndex = profile.getActivityIndex(now);
|
||||
String activityGroup = activityIndex.getGroup();
|
||||
String activityString = activityIndex.getFormattedValue()
|
||||
+ (isBanned ? " (<b>Banned</b>)" : " (" + activityGroup + ")");
|
||||
|
||||
String geoLocation = profile.getMostRecentGeoInfo().getGeolocation();
|
||||
html.append(Html.TABLELINE_PLAYERS.parse(
|
||||
Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName()),
|
||||
activityString,
|
||||
playtime, Formatters.timeAmount().apply(playtime),
|
||||
loginTimes,
|
||||
registered, Formatters.year().apply(() -> registered),
|
||||
lastSeen, Formatters.year().apply(() -> lastSeen),
|
||||
geoLocation
|
||||
));
|
||||
} catch (NullPointerException e) {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
Log.warn("THIS ERROR IS ONLY LOGGED IN DEV MODE:");
|
||||
Log.toLog(PlayersTableCreator.class.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return html.toString();
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.PlayerProfile;
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
@ -20,13 +21,13 @@ import java.util.*;
|
||||
*/
|
||||
public class PluginPlayersTable extends TableContainer {
|
||||
|
||||
private Collection<PlayerProfile> players;
|
||||
private Collection<PlayerContainer> players;
|
||||
|
||||
public PluginPlayersTable(Map<PluginData, AnalysisContainer> containers, Collection<PlayerProfile> players) {
|
||||
public PluginPlayersTable(Map<PluginData, AnalysisContainer> containers, Collection<PlayerContainer> players) {
|
||||
this(getPluginDataSet(containers), players);
|
||||
}
|
||||
|
||||
private PluginPlayersTable(TreeMap<String, Map<UUID, ? extends Serializable>> pluginDataSet, Collection<PlayerProfile> players) {
|
||||
private PluginPlayersTable(TreeMap<String, Map<UUID, ? extends Serializable>> pluginDataSet, Collection<PlayerContainer> players) {
|
||||
super(true, getHeaders(pluginDataSet.keySet()));
|
||||
|
||||
this.players = players;
|
||||
@ -64,12 +65,13 @@ public class PluginPlayersTable extends TableContainer {
|
||||
if (maxPlayers <= 0) {
|
||||
maxPlayers = 2000;
|
||||
}
|
||||
for (PlayerProfile profile : players) {
|
||||
for (PlayerContainer profile : players) {
|
||||
if (i >= maxPlayers) {
|
||||
break;
|
||||
}
|
||||
UUID uuid = profile.getUuid();
|
||||
String link = Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(profile.getName()), profile.getName());
|
||||
UUID uuid = profile.getUnsafe(PlayerKeys.UUID);
|
||||
String name = profile.getValue(PlayerKeys.NAME).orElse("Unknown");
|
||||
String link = Html.LINK_EXTERNAL.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name);
|
||||
|
||||
String[] playerData = FormatUtils.mergeArrays(new String[]{link}, rows.getOrDefault(uuid, new String[]{}));
|
||||
addRow(ArrayUtils.addAll(playerData));
|
||||
@ -82,8 +84,8 @@ public class PluginPlayersTable extends TableContainer {
|
||||
Map<UUID, String[]> rows = new HashMap<>();
|
||||
|
||||
int size = header.length - 1;
|
||||
for (PlayerProfile profile : players) {
|
||||
UUID uuid = profile.getUuid();
|
||||
for (PlayerContainer profile : players) {
|
||||
UUID uuid = profile.getUnsafe(PlayerKeys.UUID);
|
||||
|
||||
String[] row = new String[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
@ -8,7 +8,6 @@ package com.djrapitops.plan.system.database.databases;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.data.container.*;
|
||||
import com.djrapitops.plan.data.store.Key;
|
||||
@ -242,20 +241,6 @@ public class SQLiteTest {
|
||||
database.getUsersTable().registerUser(player2UUID, 123456789L, "Test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActionsTable() {
|
||||
saveUserOne();
|
||||
ActionsTable actionsTable = db.getActionsTable();
|
||||
|
||||
Action save = new Action(234567890L, Actions.FIRST_SESSION, "Additional Info");
|
||||
Action expected = new Action(234567890L, Actions.FIRST_SESSION, "Additional Info", 1);
|
||||
|
||||
actionsTable.insertAction(playerUUID, save);
|
||||
|
||||
List<Action> actions = actionsTable.getActions(playerUUID);
|
||||
assertEquals(expected, actions.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIPTable() throws DBInitException {
|
||||
saveUserOne();
|
||||
@ -555,7 +540,6 @@ public class SQLiteTest {
|
||||
SessionsTable sessionsTable = db.getSessionsTable();
|
||||
NicknamesTable nicknamesTable = db.getNicknamesTable();
|
||||
GeoInfoTable geoInfoTable = db.getGeoInfoTable();
|
||||
ActionsTable actionsTable = db.getActionsTable();
|
||||
|
||||
userInfoTable.registerUserInfo(playerUUID, 223456789L);
|
||||
saveTwoWorlds();
|
||||
@ -568,7 +552,6 @@ public class SQLiteTest {
|
||||
sessionsTable.saveSession(playerUUID, session);
|
||||
nicknamesTable.saveUserName(playerUUID, new Nickname("TestNick", System.currentTimeMillis(), TestConstants.SERVER_UUID));
|
||||
geoInfoTable.saveGeoInfo(playerUUID, new GeoInfo("1.2.3.4", "TestLoc", 223456789L, "3"));
|
||||
actionsTable.insertAction(playerUUID, new Action(1324L, Actions.FIRST_SESSION, "Add"));
|
||||
|
||||
assertTrue(usersTable.isRegistered(playerUUID));
|
||||
|
||||
@ -579,7 +562,6 @@ public class SQLiteTest {
|
||||
assertTrue(nicknamesTable.getNicknames(playerUUID).isEmpty());
|
||||
assertTrue(geoInfoTable.getGeoInfo(playerUUID).isEmpty());
|
||||
assertTrue(sessionsTable.getSessions(playerUUID).isEmpty());
|
||||
assertTrue(actionsTable.getActions(playerUUID).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -589,7 +571,6 @@ public class SQLiteTest {
|
||||
SessionsTable sessionsTable = db.getSessionsTable();
|
||||
NicknamesTable nicknamesTable = db.getNicknamesTable();
|
||||
GeoInfoTable geoInfoTable = db.getGeoInfoTable();
|
||||
ActionsTable actionsTable = db.getActionsTable();
|
||||
TPSTable tpsTable = db.getTpsTable();
|
||||
SecurityTable securityTable = db.getSecurityTable();
|
||||
|
||||
@ -604,7 +585,6 @@ public class SQLiteTest {
|
||||
assertTrue(nicknamesTable.getNicknames(playerUUID).isEmpty());
|
||||
assertTrue(geoInfoTable.getGeoInfo(playerUUID).isEmpty());
|
||||
assertTrue(sessionsTable.getSessions(playerUUID).isEmpty());
|
||||
assertTrue(actionsTable.getActions(playerUUID).isEmpty());
|
||||
assertTrue(db.getCommandUseTable().getCommandUse().isEmpty());
|
||||
assertTrue(db.getWorldTable().getAllWorlds().isEmpty());
|
||||
assertTrue(tpsTable.getTPSData().isEmpty());
|
||||
@ -619,7 +599,6 @@ public class SQLiteTest {
|
||||
SessionsTable sessionsTable = database.getSessionsTable();
|
||||
NicknamesTable nicknamesTable = database.getNicknamesTable();
|
||||
GeoInfoTable geoInfoTable = database.getGeoInfoTable();
|
||||
ActionsTable actionsTable = database.getActionsTable();
|
||||
TPSTable tpsTable = database.getTpsTable();
|
||||
SecurityTable securityTable = database.getSecurityTable();
|
||||
|
||||
@ -638,7 +617,6 @@ public class SQLiteTest {
|
||||
nicknamesTable.saveUserName(playerUUID, new Nickname("TestNick", System.currentTimeMillis(), TestConstants.SERVER_UUID));
|
||||
geoInfoTable.saveGeoInfo(playerUUID, new GeoInfo("1.2.3.4", "TestLoc", 223456789L,
|
||||
new SHA256Hash("1.2.3.4").create()));
|
||||
actionsTable.insertAction(playerUUID, new Action(1324L, Actions.FIRST_SESSION, "Add"));
|
||||
|
||||
assertTrue(usersTable.isRegistered(playerUUID));
|
||||
|
||||
@ -776,7 +754,6 @@ public class SQLiteTest {
|
||||
SessionsTable sessionsTable = backup.getSessionsTable();
|
||||
NicknamesTable nicknamesTable = backup.getNicknamesTable();
|
||||
GeoInfoTable ipsTable = backup.getGeoInfoTable();
|
||||
ActionsTable actionsTable = backup.getActionsTable();
|
||||
TPSTable tpsTable = backup.getTpsTable();
|
||||
SecurityTable securityTable = backup.getSecurityTable();
|
||||
|
||||
@ -787,7 +764,6 @@ public class SQLiteTest {
|
||||
assertFalse(nicknamesTable.getNicknames(playerUUID).isEmpty());
|
||||
assertFalse(ipsTable.getGeoInfo(playerUUID).isEmpty());
|
||||
assertFalse(sessionsTable.getSessions(playerUUID).isEmpty());
|
||||
assertFalse(actionsTable.getActions(playerUUID).isEmpty());
|
||||
assertFalse(backup.getCommandUseTable().getCommandUse().isEmpty());
|
||||
assertFalse(backup.getWorldTable().getAllWorlds().isEmpty());
|
||||
assertFalse(tpsTable.getTPSData().isEmpty());
|
||||
@ -878,7 +854,7 @@ public class SQLiteTest {
|
||||
System.out.println("\n- Running RegisterProcessors -");
|
||||
List<RegisterProcessor> processors = new ArrayList<>();
|
||||
for (int i = 0; i < 200; i++) {
|
||||
processors.add(new RegisterProcessor(playerUUID, 500L, 1000L, "name", 4));
|
||||
processors.add(new RegisterProcessor(playerUUID, 500L, "name"));
|
||||
}
|
||||
for (RegisterProcessor processor : processors) {
|
||||
processor.run();
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ActionsTest {
|
||||
|
||||
@Test
|
||||
public void getUnknownActionsEnum() {
|
||||
Actions action = Actions.getById(Integer.MIN_VALUE);
|
||||
assertEquals(Actions.UNKNOWN, action);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user