mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-29 12:37:40 +01:00
Restructured Analysis to use ServerProfile
This commit is contained in:
parent
c4963c117a
commit
55244b2f8c
@ -1,15 +1,27 @@
|
||||
package main.java.com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import main.java.com.djrapitops.plan.data.analysis.*;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.theme.Colors;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.*;
|
||||
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.CommandUseTableCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Big container object for Data.
|
||||
@ -27,72 +39,13 @@ import java.util.Map;
|
||||
*/
|
||||
public class AnalysisData extends RawData {
|
||||
|
||||
private final ActivityPart activityPart;
|
||||
private final CommandUsagePart commandUsagePart;
|
||||
private final GeolocationPart geolocationPart;
|
||||
private final JoinInfoPart joinInfoPart;
|
||||
private final KillPart killPart;
|
||||
private final PlayerCountPart playerCountPart;
|
||||
private final PlaytimePart playtimePart;
|
||||
private final TPSPart tpsPart;
|
||||
private final WorldPart worldPart;
|
||||
private long refreshDate;
|
||||
private String pluginsTabLayout;
|
||||
private Map<String, Serializable> additionalDataReplaceMap;
|
||||
@Deprecated
|
||||
private String playersTable;
|
||||
|
||||
public AnalysisData() {
|
||||
commandUsagePart = new CommandUsagePart();
|
||||
geolocationPart = new GeolocationPart();
|
||||
joinInfoPart = new JoinInfoPart();
|
||||
playerCountPart = new PlayerCountPart();
|
||||
playtimePart = new PlaytimePart();
|
||||
killPart = new KillPart(joinInfoPart);
|
||||
tpsPart = new TPSPart();
|
||||
activityPart = new ActivityPart(playerCountPart, joinInfoPart, tpsPart);
|
||||
worldPart = new WorldPart();
|
||||
}
|
||||
|
||||
public ActivityPart getActivityPart() {
|
||||
return activityPart;
|
||||
}
|
||||
|
||||
public CommandUsagePart getCommandUsagePart() {
|
||||
return commandUsagePart;
|
||||
}
|
||||
|
||||
public GeolocationPart getGeolocationPart() {
|
||||
return geolocationPart;
|
||||
}
|
||||
|
||||
public JoinInfoPart getJoinInfoPart() {
|
||||
return joinInfoPart;
|
||||
}
|
||||
|
||||
public KillPart getKillPart() {
|
||||
return killPart;
|
||||
}
|
||||
|
||||
public PlayerCountPart getPlayerCountPart() {
|
||||
return playerCountPart;
|
||||
}
|
||||
|
||||
public PlaytimePart getPlaytimePart() {
|
||||
return playtimePart;
|
||||
}
|
||||
|
||||
public TPSPart getTpsPart() {
|
||||
return tpsPart;
|
||||
}
|
||||
|
||||
public WorldPart getWorldPart() {
|
||||
return worldPart;
|
||||
}
|
||||
|
||||
public List<RawData> getAllParts() {
|
||||
return Arrays.asList(activityPart, commandUsagePart, geolocationPart,
|
||||
joinInfoPart, killPart, playerCountPart, playtimePart, tpsPart,
|
||||
worldPart);
|
||||
}
|
||||
|
||||
public void setPluginsTabLayout(String pluginsTabLayout) {
|
||||
@ -107,32 +60,24 @@ public class AnalysisData extends RawData {
|
||||
this.playersTable = playersTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void analyse() {
|
||||
if (playersTable == null) {
|
||||
playersTable = "";
|
||||
}
|
||||
if (pluginsTabLayout == null) {
|
||||
pluginsTabLayout = "";
|
||||
}
|
||||
|
||||
addValue("tableBodyPlayerList", playersTable);
|
||||
private void addConstants() {
|
||||
addValue("version", MiscUtils.getIPlan().getVersion());
|
||||
addValue("worldPieColors", Settings.THEME_GRAPH_WORLD_PIE.toString());
|
||||
addValue("gmPieColors", Settings.THEME_GRAPH_GM_PIE.toString());
|
||||
addValue("serverName", Settings.SERVER_NAME.toString());
|
||||
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||
addValue("refresh", FormatUtils.formatTimeStamp(refreshDate));
|
||||
|
||||
final List<RawData> parts = getAllParts();
|
||||
parts.forEach(part -> {
|
||||
try {
|
||||
Benchmark.start(part.getClass().getSimpleName());
|
||||
part.analyseData();
|
||||
Benchmark.stop("Analysis", part.getClass().getSimpleName());
|
||||
if (part.isAnalysed()) {
|
||||
addValues(part.getReplaceMap());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
});
|
||||
refreshDate = MiscUtils.getTime();
|
||||
addValue("activityPieColors", Settings.THEME_GRAPH_ACTIVITY_PIE.toString());
|
||||
addValue("playersGraphColor", Colors.PLAYERS_ONLINE.getColor());
|
||||
addValue("tpsHighColor", Colors.TPS_HIGH.getColor());
|
||||
addValue("tpsMediumColor", Colors.TPS_MED.getColor());
|
||||
addValue("tpsLowColor", Colors.TPS_LOW.getColor());
|
||||
addValue("tpsMedium", Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber());
|
||||
addValue("tpsHigh", Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH.getNumber());
|
||||
|
||||
addValue("playersMax", ServerProfile.getPlayersMax());
|
||||
addValue("playersOnline", ServerProfile.getPlayersOnline());
|
||||
}
|
||||
|
||||
public String replacePluginsTabLayout() {
|
||||
@ -142,4 +87,192 @@ public class AnalysisData extends RawData {
|
||||
public long getRefreshDate() {
|
||||
return refreshDate;
|
||||
}
|
||||
|
||||
public void analyze(ServerProfile profile) {
|
||||
addConstants();
|
||||
long now = MiscUtils.getTime();
|
||||
refreshDate = now;
|
||||
long dayAgo = now - TimeAmount.DAY.ms();
|
||||
long weekAgo = now - TimeAmount.WEEK.ms();
|
||||
long monthAgo = now - TimeAmount.MONTH.ms();
|
||||
|
||||
Map<UUID, List<Session>> sessions = profile.getSessions();
|
||||
List<Session> allSessions = profile.getAllSessions();
|
||||
allSessions.sort(new SessionStartComparator());
|
||||
|
||||
List<PlayerProfile> players = profile.getPlayers();
|
||||
List<PlayerProfile> ops = profile.getOps().collect(Collectors.toList());
|
||||
int 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);
|
||||
|
||||
addValue("ops", ops.size());
|
||||
addValue("playersTotal", playersTotal);
|
||||
|
||||
// TODO Rewrite Activity Pie
|
||||
addValue("playersActive", 0);
|
||||
addValue("active", 0);
|
||||
addValue("inactive", 0);
|
||||
addValue("joinLeaver", 0);
|
||||
addValue("banned", 0);
|
||||
|
||||
commandUsage(commandUsage);
|
||||
|
||||
addValue("playtimeTotal", FormatUtils.formatTimeAmount(profile.getTotalPlaytime()));
|
||||
addValue("playtimeAverage", FormatUtils.formatTimeAmount(profile.getAveragePlayTime()));
|
||||
}
|
||||
|
||||
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", HtmlUtils.removeXSS(CommandUseTableCreator.createTable(commandUsage)));
|
||||
}
|
||||
|
||||
private void geolocationsTab(List<String> geoLocations) {
|
||||
Map<String, String> geoCodes = new HashMap<>();
|
||||
Map<String, Integer> geoCodeCounts = new HashMap<>();
|
||||
String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe"};
|
||||
String[] codes = new String[]{"AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE"};
|
||||
for (int i = 0; i < countries.length; i++) {
|
||||
String country = countries[i];
|
||||
String countryCode = codes[i];
|
||||
|
||||
geoCodes.put(country, countryCode);
|
||||
geoCodeCounts.put(countryCode, 0);
|
||||
}
|
||||
for (String geoLocation : geoLocations) {
|
||||
String countryCode = geoCodes.get(geoLocation);
|
||||
if (countryCode != null) {
|
||||
geoCodeCounts.computeIfPresent(countryCode, (computedCountry, amount) -> amount + 1);
|
||||
}
|
||||
}
|
||||
addValue("geoMapSeries", WorldMapCreator.createDataSeries(geoCodeCounts));
|
||||
}
|
||||
|
||||
private void onlineActivityNumbers(ServerProfile profile, Map<UUID, List<Session>> sessions, List<PlayerProfile> players) {
|
||||
long now = MiscUtils.getTime();
|
||||
long dayAgo = now - TimeAmount.DAY.ms();
|
||||
long weekAgo = now - TimeAmount.WEEK.ms();
|
||||
long monthAgo = now - TimeAmount.MONTH.ms();
|
||||
|
||||
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();
|
||||
int newD = newDay.size();
|
||||
int newW = newWeek.size();
|
||||
int newM = newMonth.size();
|
||||
int playersTotal = players.size();
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
private List<Long> toRegistered(List<PlayerProfile> players) {
|
||||
return players.stream().map(PlayerProfile::getRegistered).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
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());
|
||||
String[] tables = SessionsTableCreator.createTable(sessions, allSessions);
|
||||
String[] sessionContent = SessionTabStructureCreator.creteStructure(sessions, allSessions);
|
||||
|
||||
addValue("sessionCount", allSessions.size());
|
||||
addValue("accordionSessions", sessionContent[0]);
|
||||
addValue("sessionTabGraphViewFunctions", sessionContent[1]);
|
||||
addValue("tableBodySessions", tables[0]);
|
||||
addValue("listRecentLogins", tables[1]);
|
||||
addValue("sessionAverage", FormatUtils.formatTimeAmount(MathUtils.averageLong(allSessions.stream().map(Session::getLength))));
|
||||
addValue("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessionsMonth));
|
||||
|
||||
addValue("deathCount", ServerProfile.getDeathCount(allSessions));
|
||||
addValue("mobKillCount", ServerProfile.getMobKillCount(allSessions));
|
||||
addValue("killCount", ServerProfile.getPlayerKills(allSessions).size());
|
||||
}
|
||||
|
||||
private void directProfileVariables(ServerProfile profile) {
|
||||
WorldTimes worldTimes = profile.getServerWorldtimes();
|
||||
long allTimePeak = profile.getAllTimePeak();
|
||||
long lastPeak = profile.getLastPeakDate();
|
||||
|
||||
addValue("tablePlayerlist", Html.TABLE_PLAYERS.parse(profile.createPlayersTableBody()));
|
||||
addValue("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal()));
|
||||
String[] seriesData = WorldPieCreator.createSeriesData(worldTimes);
|
||||
addValue("worldSeries", seriesData[0]);
|
||||
addValue("gmSeries", seriesData[1]);
|
||||
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() : "-");
|
||||
}
|
||||
|
||||
private void performanceTab(List<TPS> tpsData, List<TPS> tpsDataDay, List<TPS> tpsDataWeek, List<TPS> tpsDataMonth) {
|
||||
addValue("tpsSpikeMonth", ServerProfile.getLowSpikeCount(tpsDataMonth));
|
||||
addValue("tpsSpikeWeek", ServerProfile.getLowSpikeCount(tpsDataWeek));
|
||||
addValue("tpsSpikeDay", ServerProfile.getLowSpikeCount(tpsDataDay));
|
||||
|
||||
addValue("playersOnlineSeries", PlayerActivityGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("tpsSeries", TPSGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("cpuSeries", CPUGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("ramSeries", RamGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("entitySeries", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsData));
|
||||
addValue("chunkSeries", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsData));
|
||||
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
package main.java.com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
@ -16,45 +16,13 @@ public abstract class RawData {
|
||||
|
||||
private final Map<String, Serializable> replaceMap;
|
||||
|
||||
/**
|
||||
* Status info for call to analyzeData method.
|
||||
*/
|
||||
protected boolean analysed;
|
||||
|
||||
/**
|
||||
* Only used by subclasses.
|
||||
*/
|
||||
public RawData() {
|
||||
replaceMap = new HashMap<>();
|
||||
analysed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition if analyseData() has been called.
|
||||
*
|
||||
* @return true if the method has been called.
|
||||
*/
|
||||
public boolean isAnalysed() {
|
||||
return analysed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyses the data added together.
|
||||
* <p>
|
||||
* Places place-holders to the replace map.
|
||||
*/
|
||||
public void analyseData() {
|
||||
analysed = true;
|
||||
this.analyse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses should analyse the data added together.
|
||||
* <p>
|
||||
* Place-holders should be added to the replace map.
|
||||
*/
|
||||
protected abstract void analyse();
|
||||
|
||||
/**
|
||||
* Adds values from an existing replaceMap.
|
||||
*
|
@ -13,7 +13,6 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.PlayerProfileLastPlayedComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.TPSComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.PlayersTableCreator;
|
||||
|
||||
import java.util.*;
|
||||
@ -43,9 +42,6 @@ public class ServerProfile {
|
||||
private long allTimePeak;
|
||||
private int allTimePeakPlayers;
|
||||
|
||||
// Active information
|
||||
private int playersOnline;
|
||||
private int playersMax;
|
||||
|
||||
public ServerProfile(UUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
@ -57,8 +53,6 @@ public class ServerProfile {
|
||||
allTimePeakPlayers = -1;
|
||||
lastPeakDate = -1;
|
||||
lastPeakPlayers = -1;
|
||||
playersOnline = -1;
|
||||
playersMax = -1;
|
||||
}
|
||||
|
||||
public List<PlayerProfile> getPlayers() {
|
||||
@ -85,9 +79,7 @@ public class ServerProfile {
|
||||
this.commandUsage = commandUsage;
|
||||
}
|
||||
|
||||
public long getLowSpikeCount(long after, long before) {
|
||||
List<TPS> tpsData = getTPSData(after, before).sorted(new TPSComparator()).collect(Collectors.toList());
|
||||
|
||||
public static long getLowSpikeCount(List<TPS> tpsData) {
|
||||
int mediumThreshold = Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber();
|
||||
|
||||
boolean wasLow = false;
|
||||
@ -171,7 +163,7 @@ public class ServerProfile {
|
||||
return getNewPlayers(after, before) * 1.0 / AnalysisUtils.getNumberOfDaysBetween(after, before);
|
||||
}
|
||||
|
||||
private Stream<PlayerProfile> getPlayersWhoPlayedBetween(long after, long before) {
|
||||
public Stream<PlayerProfile> getPlayersWhoPlayedBetween(long after, long before) {
|
||||
return players.stream()
|
||||
.filter(player -> player.playedBetween(after, before));
|
||||
}
|
||||
@ -209,11 +201,15 @@ public class ServerProfile {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
public List<Session> getSessions() {
|
||||
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 List<PlayerKill> getPlayerKills(List<Session> s) {
|
||||
public static List<PlayerKill> getPlayerKills(List<Session> s) {
|
||||
List<PlayerKill> kills = new ArrayList<>();
|
||||
for (Session session : s) {
|
||||
kills.addAll(session.getPlayerKills());
|
||||
@ -221,7 +217,7 @@ public class ServerProfile {
|
||||
return kills;
|
||||
}
|
||||
|
||||
public long getMobKillCount(List<Session> s) {
|
||||
public static long getMobKillCount(List<Session> s) {
|
||||
long total = 0;
|
||||
for (Session session : s) {
|
||||
total += session.getMobKills();
|
||||
@ -229,7 +225,7 @@ public class ServerProfile {
|
||||
return total;
|
||||
}
|
||||
|
||||
public long getDeathCount(List<Session> s) {
|
||||
public static long getDeathCount(List<Session> s) {
|
||||
long total = 0;
|
||||
for (Session session : s) {
|
||||
total += session.getDeaths();
|
||||
@ -279,7 +275,7 @@ public class ServerProfile {
|
||||
this.allTimePeakPlayers = allTimePeakPlayers;
|
||||
}
|
||||
|
||||
public int getPlayersOnline() {
|
||||
public static int getPlayersOnline() {
|
||||
if (Check.isBungeeAvailable()) {
|
||||
return PlanBungee.getInstance().getProxy().getOnlineCount();
|
||||
} else {
|
||||
@ -287,7 +283,19 @@ public class ServerProfile {
|
||||
}
|
||||
}
|
||||
|
||||
public int getPlayersMax() {
|
||||
public static int getPlayersMax() {
|
||||
return MiscUtils.getIPlan().getVariable().getMaxPlayers();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.theme.Colors;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.PlayerActivityGraphCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraphCreator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Part responsible for all Player Activity related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${active} - (Number)
|
||||
* ${inactive} - (Number)
|
||||
* ${joinLeaver} - (Number)
|
||||
* ${banned} - (Number)
|
||||
* ${activityColors} - Color array
|
||||
* ${playersGraphColor} - Color
|
||||
* <p>
|
||||
* ${playersOnlineSeries} - Data for HighCharts
|
||||
* ${sessionLengthSeries} - Data for HighCharts
|
||||
* ${punchCardSeries} - Data for HighCharts
|
||||
* <p>
|
||||
* ${sessionAverage} - Formatted Time amount
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class ActivityPart extends RawData {
|
||||
|
||||
private final PlayerCountPart playerCount;
|
||||
private final JoinInfoPart joins;
|
||||
private final TPSPart tpsPart;
|
||||
private final Set<UUID> bans;
|
||||
private final Set<UUID> active;
|
||||
private final Set<UUID> inactive;
|
||||
private final Set<UUID> joinedOnce;
|
||||
private List<String> recentPlayers;
|
||||
private List<UUID> recentPlayersUUIDs;
|
||||
|
||||
public ActivityPart(PlayerCountPart playerCount, JoinInfoPart joins, TPSPart tps) {
|
||||
this.playerCount = playerCount;
|
||||
this.joins = joins;
|
||||
tpsPart = tps;
|
||||
bans = new HashSet<>();
|
||||
active = new HashSet<>();
|
||||
inactive = new HashSet<>();
|
||||
joinedOnce = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
Verify.nullCheck(recentPlayers);
|
||||
Verify.nullCheck(recentPlayersUUIDs);
|
||||
|
||||
activityPiechart();
|
||||
|
||||
playerActivityGraphs();
|
||||
|
||||
final List<Session> sessions = joins.getAllSessions();
|
||||
|
||||
List<Long> lengths = AnalysisUtils.transformSessionDataToLengths(sessions);
|
||||
long averageLength = MathUtils.averageLong(lengths);
|
||||
addValue("sessionAverage", FormatUtils.formatTimeAmount(averageLength));
|
||||
|
||||
List<Session> sessionsMonth = sessions.stream()
|
||||
.filter(s -> s.getSessionStart() > MiscUtils.getTime() - TimeAmount.MONTH.ms())
|
||||
.collect(Collectors.toList());
|
||||
addValue("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessionsMonth));
|
||||
}
|
||||
|
||||
private void playerActivityGraphs() {
|
||||
List<TPS> tpsData = tpsPart.getTpsData();
|
||||
addValue("playersOnlineSeries", PlayerActivityGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("playersGraphColor", Colors.PLAYERS_ONLINE.getColor());
|
||||
}
|
||||
|
||||
private void activityPiechart() {
|
||||
calculateActivityAmounts();
|
||||
|
||||
int[] counts = new int[]{active.size(), inactive.size(), joinedOnce.size(), bans.size()};
|
||||
|
||||
addValue("activityPieColors", Settings.THEME_GRAPH_ACTIVITY_PIE.toString());
|
||||
addValue("playersActive", counts[0]);
|
||||
addValue("active", counts[0]);
|
||||
addValue("inactive", counts[1]);
|
||||
addValue("joinLeaver", counts[2]);
|
||||
addValue("banned", counts[3]);
|
||||
}
|
||||
|
||||
private void calculateActivityAmounts() {
|
||||
Map<UUID, List<Session>> allSessions = joins.getSessions();
|
||||
for (UUID uuid : playerCount.getUuids()) {
|
||||
if (bans.contains(uuid)) {
|
||||
continue;
|
||||
}
|
||||
List<Session> sessions = allSessions.getOrDefault(uuid, new ArrayList<>());
|
||||
long lastSeen = AnalysisUtils.getLastSeen(sessions);
|
||||
long playtime = AnalysisUtils.getTotalPlaytime(sessions);
|
||||
int sessionCount = sessions.size();
|
||||
if (sessionCount <= 1) {
|
||||
addJoinedOnce(uuid);
|
||||
continue;
|
||||
}
|
||||
boolean isActive = AnalysisUtils.isActive(MiscUtils.getTime(), lastSeen, playtime, sessionCount);
|
||||
if (isActive) {
|
||||
addActive(uuid);
|
||||
} else {
|
||||
addInActive(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addBans(Collection<UUID> uuids) {
|
||||
bans.addAll(uuids);
|
||||
}
|
||||
|
||||
public void addBan(UUID uuid) {
|
||||
bans.add(Verify.nullCheck(uuid));
|
||||
}
|
||||
|
||||
public void addActive(UUID uuid) {
|
||||
active.add(Verify.nullCheck(uuid));
|
||||
}
|
||||
|
||||
public void addInActive(UUID uuid) {
|
||||
inactive.add(Verify.nullCheck(uuid));
|
||||
}
|
||||
|
||||
public void addJoinedOnce(UUID uuid) {
|
||||
joinedOnce.add(Verify.nullCheck(uuid));
|
||||
}
|
||||
|
||||
public Map<Long, Integer> getPlayersOnline() {
|
||||
return tpsPart.getTpsData().stream().distinct().collect(Collectors.toMap(TPS::getDate, TPS::getPlayers));
|
||||
}
|
||||
|
||||
public List<String> getRecentPlayers() {
|
||||
return recentPlayers;
|
||||
}
|
||||
|
||||
public void setRecentPlayers(List<String> recentPlayers) {
|
||||
this.recentPlayers = recentPlayers;
|
||||
}
|
||||
|
||||
public List<UUID> getRecentPlayersUUIDs() {
|
||||
return recentPlayersUUIDs;
|
||||
}
|
||||
|
||||
public void setRecentPlayersUUIDs(List<UUID> recentPlayersUUIDs) {
|
||||
this.recentPlayersUUIDs = recentPlayersUUIDs;
|
||||
}
|
||||
|
||||
public Set<UUID> getBans() {
|
||||
return bans;
|
||||
}
|
||||
|
||||
public Set<UUID> getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public Set<UUID> getInactive() {
|
||||
return inactive;
|
||||
}
|
||||
|
||||
public Set<UUID> getJoinedOnce() {
|
||||
return joinedOnce;
|
||||
}
|
||||
}
|
@ -1,63 +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 main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.CommandUseTableCreator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Part responsible for all CommandUsage related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${commandCount} - (Number)
|
||||
* ${commandUniqueCount} - (Number)
|
||||
* ${tableBodyCommands} - Table body for CommandUsage table.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class CommandUsagePart extends RawData {
|
||||
|
||||
private Map<String, Integer> commandUsage;
|
||||
|
||||
public CommandUsagePart() {
|
||||
this.commandUsage = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
addValue("commandUniqueCount", String.valueOf(getUniqueCommands()));
|
||||
addValue("commandCount", String.valueOf(getCommandTotal()));
|
||||
String commandUsageTable = CommandUseTableCreator.createTable(commandUsage);
|
||||
addValue("tableBodyCommands", HtmlUtils.removeXSS(commandUsageTable));
|
||||
}
|
||||
|
||||
public void setCommandUsage(Map<String, Integer> commandUsage) {
|
||||
this.commandUsage = commandUsage;
|
||||
}
|
||||
|
||||
public void addCommands(Map<String, Integer> commandUsage) {
|
||||
this.commandUsage.putAll(commandUsage);
|
||||
}
|
||||
|
||||
public int getUniqueCommands() {
|
||||
return commandUsage.keySet().size();
|
||||
}
|
||||
|
||||
public long getCommandTotal() {
|
||||
return commandUsage.values().stream().mapToLong(i -> i).sum();
|
||||
}
|
||||
|
||||
public Map<String, Integer> getCommandUsage() {
|
||||
return commandUsage;
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.WorldMapCreator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Part responsible for all Geolocation related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${geoMapSeries}
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class GeolocationPart extends RawData {
|
||||
|
||||
private final Map<UUID, String> mostCommonGeolocations;
|
||||
private final Map<String, String> geoCodes;
|
||||
private final Map<String, Integer> geoCodeCounts;
|
||||
|
||||
public GeolocationPart() {
|
||||
geoCodes = new HashMap<>();
|
||||
geoCodeCounts = new HashMap<>();
|
||||
mostCommonGeolocations = new HashMap<>();
|
||||
|
||||
String[] countries = new String[]{"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe"};
|
||||
String[] codes = new String[]{"AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE"};
|
||||
for (int i = 0; i < countries.length; i++) {
|
||||
String country = countries[i];
|
||||
String countryCode = codes[i];
|
||||
|
||||
geoCodes.put(country, countryCode);
|
||||
geoCodeCounts.put(countryCode, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
addValue("geoMapSeries", WorldMapCreator.createDataSeries(geoCodeCounts));
|
||||
}
|
||||
|
||||
public void addGeolocation(String country) {
|
||||
String countryCode = geoCodes.get(country);
|
||||
if (countryCode != null) {
|
||||
geoCodeCounts.computeIfPresent(countryCode, (computedCountry, amount) -> amount + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void addGeoLocations(Map<UUID, List<String>> geolocations) {
|
||||
for (Map.Entry<UUID, List<String>> entry : geolocations.entrySet()) {
|
||||
String mostCommon = getMostCommon(entry.getValue());
|
||||
mostCommonGeolocations.put(entry.getKey(), mostCommon);
|
||||
addGeolocation(mostCommon);
|
||||
}
|
||||
}
|
||||
|
||||
private String getMostCommon(List<String> geoLocs) {
|
||||
Map<String, Long> occurrences =
|
||||
geoLocs.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
||||
String mostCommon = "Not Known";
|
||||
long count = -1;
|
||||
for (Map.Entry<String, Long> entry : occurrences.entrySet()) {
|
||||
Long value = entry.getValue();
|
||||
if (value > count) {
|
||||
mostCommon = entry.getKey();
|
||||
count = value;
|
||||
}
|
||||
}
|
||||
return mostCommon;
|
||||
}
|
||||
|
||||
public Map<UUID, String> getMostCommonGeoLocations() {
|
||||
return mostCommonGeolocations;
|
||||
}
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Part responsible for all Player player related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${playersAverage} - (Number)
|
||||
* ${playersNewAverage} - (Number)
|
||||
* <p>
|
||||
* ${playersDay} - (Number)
|
||||
* ${playersWeek} - (Number)
|
||||
* ${playersMonth} - (Number)
|
||||
* ${playersAverageDay} - (Number)
|
||||
* ${playersAverageWeek} - (Number)
|
||||
* ${playersAverageMonth} - (Number)
|
||||
* ${playersNewDay} - (Number)
|
||||
* ${playersNewWeek} - (Number)
|
||||
* ${playersNewMonth} - (Number)
|
||||
* ${playersNewAverageDay} - (Number)
|
||||
* ${playersNewAverageWeek} - (Number)
|
||||
* ${playersNewAverageMonth} - (Number)
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class JoinInfoPart extends RawData {
|
||||
|
||||
private final Map<UUID, Session> activeSessions;
|
||||
private final Map<UUID, List<Session>> sessions;
|
||||
private final Map<UUID, Long> registered;
|
||||
private long loginTimes;
|
||||
|
||||
public JoinInfoPart() {
|
||||
activeSessions = new HashMap<>();
|
||||
sessions = new HashMap<>();
|
||||
registered = new HashMap<>();
|
||||
loginTimes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
newPlayers();
|
||||
uniquePlayers();
|
||||
uniquePlayersPerDay();
|
||||
|
||||
addValue("sessionCount", getAllSessions().size());
|
||||
|
||||
sessionTables();
|
||||
}
|
||||
|
||||
private void sessionTables() {
|
||||
String[] tables = SessionsTableCreator.createTable(this);
|
||||
String[] sessionContent = SessionTabStructureCreator.creteStructure(this);
|
||||
addValue("accordionSessions", sessionContent[0]);
|
||||
addValue("sessionTabGraphViewFunctions", sessionContent[1]);
|
||||
addValue("tableBodySessions", tables[0]);
|
||||
addValue("tableBodyRecentLogins", tables[1]);
|
||||
}
|
||||
|
||||
private void uniquePlayers() {
|
||||
int uniqueDay = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.DAY.ms());
|
||||
int uniqueWeek = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.WEEK.ms());
|
||||
int uniqueMonth = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.MONTH.ms());
|
||||
|
||||
addValue("playersDay", uniqueDay);
|
||||
addValue("playersWeek", uniqueWeek);
|
||||
addValue("playersMonth", uniqueMonth);
|
||||
}
|
||||
|
||||
private void uniquePlayersPerDay() {
|
||||
int perDay = AnalysisUtils.getUniqueJoinsPerDay(sessions, -1);
|
||||
int perDayDay = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.DAY.ms());
|
||||
int perDayWeek = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.WEEK.ms());
|
||||
int perDayMonth = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.MONTH.ms());
|
||||
|
||||
addValue("playersAverage", perDay);
|
||||
addValue("playersAverageDay", perDayDay);
|
||||
addValue("playersAverageWeek", perDayWeek);
|
||||
addValue("playersAverageMonth", perDayMonth);
|
||||
}
|
||||
|
||||
private void newPlayers() {
|
||||
long now = MiscUtils.getTime();
|
||||
List<Long> registeredList = getRegisteredList();
|
||||
long newDay = AnalysisUtils.getNewPlayers(registeredList, TimeAmount.DAY.ms(), now);
|
||||
long newWeek = AnalysisUtils.getNewPlayers(registeredList, TimeAmount.WEEK.ms(), now);
|
||||
long newMonth = AnalysisUtils.getNewPlayers(registeredList, TimeAmount.MONTH.ms(), now);
|
||||
|
||||
addValue("playersNewDay", newDay);
|
||||
addValue("playersNewWeek", newWeek);
|
||||
addValue("playersNewMonth", newMonth);
|
||||
|
||||
long newPerDay = AnalysisUtils.getNewUsersPerDay(registeredList, -1);
|
||||
long newPerDayDay = AnalysisUtils.getNewUsersPerDay(registeredList, TimeAmount.DAY.ms());
|
||||
long newPerDayWeek = AnalysisUtils.getNewUsersPerDay(registeredList, TimeAmount.WEEK.ms());
|
||||
long newPerDayMonth = AnalysisUtils.getNewUsersPerDay(registeredList, TimeAmount.MONTH.ms());
|
||||
|
||||
addValue("playersNewAverage", newPerDay);
|
||||
addValue("playersNewAverageDay", newPerDayDay);
|
||||
addValue("playersNewAverageWeek", newPerDayWeek);
|
||||
addValue("playersNewAverageMonth", newPerDayMonth);
|
||||
}
|
||||
|
||||
public void addToLoginTimes() {
|
||||
addToLoginTimes(1);
|
||||
}
|
||||
|
||||
public void addToLoginTimes(int amount) {
|
||||
loginTimes += amount;
|
||||
}
|
||||
|
||||
public long getLoginTimes() {
|
||||
return loginTimes;
|
||||
}
|
||||
|
||||
public Map<UUID, List<Session>> getSessions() {
|
||||
return sessions;
|
||||
}
|
||||
|
||||
public List<Session> getAllSessions() {
|
||||
List<Session> sessions = MiscUtils.flatMap(this.sessions.values());
|
||||
sessions.addAll(activeSessions.values());
|
||||
return sessions;
|
||||
}
|
||||
|
||||
public void addRegistered(UUID uuid, long registerDate) {
|
||||
registered.put(uuid, registerDate);
|
||||
}
|
||||
|
||||
public void addRegistered(Map<UUID, Long> registerDates) {
|
||||
registered.putAll(registerDates);
|
||||
}
|
||||
|
||||
public Map<UUID, Long> getRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
||||
public List<Long> getRegisteredList() {
|
||||
return new ArrayList<>(registered.values());
|
||||
}
|
||||
|
||||
public void addSessions(Map<UUID, List<Session>> sessions) {
|
||||
this.sessions.putAll(Verify.nullCheck(sessions));
|
||||
}
|
||||
|
||||
public void addSessions(UUID uuid, List<Session> sessions) {
|
||||
Verify.nullCheck(uuid);
|
||||
Verify.nullCheck(sessions);
|
||||
this.sessions.put(uuid, sessions.stream().distinct().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public void addActiveSessions(Map<UUID, Session> activeSessions) {
|
||||
this.activeSessions.putAll(activeSessions);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.PlayerKill;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Part responsible for all Death related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${killCount} - (Number)
|
||||
* ${mobKillCount} - (Number)
|
||||
* ${deathCount} - (Number)
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class KillPart extends RawData {
|
||||
|
||||
private final JoinInfoPart joinInfoPart;
|
||||
|
||||
private long playerKills;
|
||||
private long mobKills;
|
||||
private long deaths;
|
||||
|
||||
public KillPart(JoinInfoPart joinInfoPart) {
|
||||
this.joinInfoPart = joinInfoPart;
|
||||
|
||||
playerKills = 0;
|
||||
mobKills = 0;
|
||||
deaths = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
List<Session> sessions = joinInfoPart.getAllSessions();
|
||||
deaths += sessions.stream().mapToLong(Session::getDeaths).sum();
|
||||
mobKills += sessions.stream().mapToLong(Session::getMobKills).sum();
|
||||
playerKills += sessions.stream().map(Session::getPlayerKills).mapToLong(Collection::size).sum();
|
||||
|
||||
addValue("deathCount", this.deaths);
|
||||
addValue("mobKillCount", mobKills);
|
||||
addValue("killCount", playerKills);
|
||||
}
|
||||
|
||||
public long getPlayerKills() {
|
||||
return playerKills;
|
||||
}
|
||||
|
||||
public long getMobKills() {
|
||||
return mobKills;
|
||||
}
|
||||
|
||||
public long getDeaths() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
public void addKills(Map<UUID, List<PlayerKill>> playerKills) {
|
||||
this.playerKills += playerKills.values().stream().mapToLong(Collection::size).sum();
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Part responsible for counting players.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${playersTotal}, ${ops}
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerCountPart extends RawData {
|
||||
|
||||
private final Set<UUID> uuids;
|
||||
private final Set<UUID> ops;
|
||||
|
||||
public PlayerCountPart() {
|
||||
uuids = new HashSet<>();
|
||||
ops = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
addValue("ops", ops.size());
|
||||
addValue("playersTotal", uuids.size());
|
||||
}
|
||||
|
||||
public void addPlayer(UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
uuids.add(uuid);
|
||||
}
|
||||
|
||||
public void addPlayers(Collection<UUID> uuids) {
|
||||
Verify.nullCheck(uuids);
|
||||
this.uuids.addAll(uuids);
|
||||
}
|
||||
|
||||
public void addOPs(Collection<UUID> uuids) {
|
||||
Verify.nullCheck(uuids);
|
||||
this.ops.addAll(uuids);
|
||||
}
|
||||
|
||||
public void addOP(UUID uuid) {
|
||||
Verify.nullCheck(uuid);
|
||||
ops.add(uuid);
|
||||
}
|
||||
|
||||
public Set<UUID> getUuids() {
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return uuids.size();
|
||||
}
|
||||
|
||||
public Set<UUID> getOps() {
|
||||
return ops;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
|
||||
/**
|
||||
* Part responsible for all Playtime related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${playtimeTotal} - Formatted time amount
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlaytimePart extends RawData {
|
||||
|
||||
private long totalPlaytime;
|
||||
private long playtime30d;
|
||||
private long playtime7d;
|
||||
private long playtime24h;
|
||||
|
||||
public PlaytimePart() {
|
||||
totalPlaytime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
addValue("playtimeTotal", FormatUtils.formatTimeAmount(totalPlaytime));
|
||||
addValue("playtimeMonth", FormatUtils.formatTimeAmount(playtime30d));
|
||||
addValue("playtimeWeek", FormatUtils.formatTimeAmount(playtime7d));
|
||||
addValue("playtimeDay", FormatUtils.formatTimeAmount(playtime24h));
|
||||
}
|
||||
|
||||
public void addToPlaytime(long amount) {
|
||||
totalPlaytime += amount;
|
||||
}
|
||||
|
||||
public void setTotalPlaytime(long totalPlaytime) {
|
||||
this.totalPlaytime = totalPlaytime;
|
||||
}
|
||||
|
||||
public void setPlaytime30d(long playtime30d) {
|
||||
this.playtime30d = playtime30d;
|
||||
}
|
||||
|
||||
public void setPlaytime7d(long playtime7d) {
|
||||
this.playtime7d = playtime7d;
|
||||
}
|
||||
|
||||
public void setPlaytime24h(long playtime24h) {
|
||||
this.playtime24h = playtime24h;
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.theme.Colors;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.CPUGraphCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.RamGraphCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.TPSGraphCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.WorldLoadGraphCreator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Part responsible for all TPS related analysis.
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after being analyzed:
|
||||
* ${tpsSeries} - HighCharts data
|
||||
* ${cpuSeries} - HighCharts data
|
||||
* ${ramSeries} - HighCharts data
|
||||
* ${entitySeries} - HighCharts data
|
||||
* ${chunkSeries} - HighCharts data
|
||||
* <p>
|
||||
* ${tpsAverageDay} - (Number)
|
||||
* ${tpsAverageWeek} - (Number)
|
||||
* ${cpuAverageDay} - (Number)%
|
||||
* ${cpuAverageWeek} - (Number)%
|
||||
* ${ramAverageDay} - (Number) MB
|
||||
* ${ramAverageWeek} - (Number) MB
|
||||
* ${entityAverageDay} - (Number)
|
||||
* ${entityAverageWeek} - (Number)
|
||||
* ${chunkAverageDay} - (Number)
|
||||
* ${chunkAverageWeek} - (Number)
|
||||
* <p>
|
||||
* ${tpsMedium} - (Number) Color Threshold for Medium TPS
|
||||
* ${tpsHigh} - (Number) Color Threshold for High TPS
|
||||
* ${tpsLowColor} - Color of Low TPS
|
||||
* ${tpsMediumColor} - Color of Low TPS
|
||||
* ${tpsHighColor} - Color of Low TPS
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
*/
|
||||
@Deprecated
|
||||
public class TPSPart extends RawData {
|
||||
|
||||
private final List<TPS> tpsData;
|
||||
private TPS allTimePeak;
|
||||
private TPS lastPeak;
|
||||
|
||||
public TPSPart() {
|
||||
this.tpsData = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyse() {
|
||||
long now = MiscUtils.getTime();
|
||||
List<TPS> week = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.WEEK.ms());
|
||||
List<TPS> day = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.DAY.ms());
|
||||
|
||||
tpsGraphOptions();
|
||||
|
||||
chartData();
|
||||
|
||||
averages(week, day);
|
||||
|
||||
peaks();
|
||||
}
|
||||
|
||||
private void peaks() {
|
||||
if (lastPeak != null) {
|
||||
addValue("lastPeakTime", FormatUtils.formatTimeStampYear(lastPeak.getDate()));
|
||||
addValue("playersLastPeak", lastPeak.getPlayers());
|
||||
} else {
|
||||
addValue("lastPeakTime", "No Data");
|
||||
addValue("playersLastPeak", "-");
|
||||
}
|
||||
|
||||
if (allTimePeak != null) {
|
||||
addValue("bestPeakTime", FormatUtils.formatTimeStampYear(allTimePeak.getDate()));
|
||||
addValue("playersBestPeak", allTimePeak.getPlayers());
|
||||
} else {
|
||||
addValue("bestPeakTime", "No Data");
|
||||
addValue("playersBestPeak", "-");
|
||||
}
|
||||
}
|
||||
|
||||
private void averages(List<TPS> week, List<TPS> day) {
|
||||
double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTicksPerSecond));
|
||||
double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTicksPerSecond));
|
||||
|
||||
double averageCPUWeek = MathUtils.averageDouble(week.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
double averageCPUDay = MathUtils.averageDouble(day.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||
|
||||
long averageUsedMemoryWeek = MathUtils.averageLong(week.stream().map(TPS::getUsedMemory).filter(i -> i != 0));
|
||||
long averageUsedMemoryDay = MathUtils.averageLong(day.stream().map(TPS::getUsedMemory).filter(i -> i != 0));
|
||||
|
||||
double averageEntityCountWeek = MathUtils.averageInt(week.stream().map(TPS::getEntityCount).filter(i -> i != 0));
|
||||
double averageEntityCountDay = MathUtils.averageInt(day.stream().map(TPS::getEntityCount).filter(i -> i != 0));
|
||||
|
||||
double averageChunksLoadedWeek = MathUtils.averageInt(week.stream().map(TPS::getChunksLoaded).filter(i -> i != 0));
|
||||
double averageChunksLoadedDay = MathUtils.averageInt(day.stream().map(TPS::getChunksLoaded).filter(i -> i != 0));
|
||||
|
||||
addValue("tpsAverageWeek", FormatUtils.cutDecimals(averageTPSWeek));
|
||||
addValue("tpsAverageDay", FormatUtils.cutDecimals(averageTPSDay));
|
||||
|
||||
addValue("cpuAverageWeek", averageCPUWeek >= 0 ? FormatUtils.cutDecimals(averageCPUWeek) + "%" : "Unavailable");
|
||||
addValue("cpuAverageDay", averageCPUDay >= 0 ? FormatUtils.cutDecimals(averageCPUDay) + "%" : "Unavailable");
|
||||
|
||||
addValue("ramAverageWeek", FormatUtils.cutDecimals(averageUsedMemoryWeek));
|
||||
addValue("ramAverageDay", FormatUtils.cutDecimals(averageUsedMemoryDay));
|
||||
|
||||
addValue("entityAverageWeek", FormatUtils.cutDecimals(averageEntityCountWeek));
|
||||
addValue("entityAverageDay", FormatUtils.cutDecimals(averageEntityCountDay));
|
||||
|
||||
addValue("chunkAverageWeek", FormatUtils.cutDecimals(averageChunksLoadedWeek));
|
||||
addValue("chunkAverageDay", FormatUtils.cutDecimals(averageChunksLoadedDay));
|
||||
}
|
||||
|
||||
private void chartData() {
|
||||
addValue("tpsSeries", TPSGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("cpuSeries", CPUGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("ramSeries", RamGraphCreator.buildSeriesDataString(tpsData));
|
||||
addValue("entitySeries", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsData));
|
||||
addValue("chunkSeries", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsData));
|
||||
}
|
||||
|
||||
private void tpsGraphOptions() {
|
||||
addValue("tpsHighColor", Colors.TPS_HIGH.getColor());
|
||||
addValue("tpsMediumColor", Colors.TPS_MED.getColor());
|
||||
addValue("tpsLowColor", Colors.TPS_LOW.getColor());
|
||||
addValue("tpsMedium", Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber());
|
||||
addValue("tpsHigh", Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH.getNumber());
|
||||
}
|
||||
|
||||
public List<TPS> getTpsData() {
|
||||
return tpsData;
|
||||
}
|
||||
|
||||
public void addTpsData(Collection<TPS> data) {
|
||||
tpsData.addAll(Verify.nullCheck(data));
|
||||
}
|
||||
|
||||
public void setAllTimePeak(TPS allTimePeak) {
|
||||
this.allTimePeak = allTimePeak;
|
||||
}
|
||||
|
||||
public void setLastPeak(TPS lastPeak) {
|
||||
this.lastPeak = lastPeak;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.WorldPieCreator;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Part responsible for all World Playtime related analysis.
|
||||
* <p>
|
||||
* World times Pie
|
||||
* <p>
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
* <p>
|
||||
* Contains following placeholders after analyzed:
|
||||
* ${worldTotal} - Total playtime for all worlds
|
||||
* ${worldSeries} - Data for HighCharts
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class WorldPart extends RawData {
|
||||
|
||||
private WorldTimes worldTimes;
|
||||
|
||||
public WorldPart() {
|
||||
worldTimes = new WorldTimes(new HashMap<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void analyse() {
|
||||
addValue("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal()));
|
||||
String[] seriesData = WorldPieCreator.createSeriesData(worldTimes);
|
||||
addValue("worldSeries", seriesData[0]);
|
||||
addValue("gmSeries", seriesData[1]);
|
||||
addValue("worldPieColors", Settings.THEME_GRAPH_WORLD_PIE.toString());
|
||||
addValue("gmPieColors", Settings.THEME_GRAPH_GM_PIE.toString());
|
||||
}
|
||||
|
||||
public WorldTimes getWorldTimes() {
|
||||
return worldTimes;
|
||||
}
|
||||
|
||||
public void setWorldTimes(WorldTimes worldTimes) {
|
||||
this.worldTimes = worldTimes;
|
||||
}
|
||||
}
|
@ -7,12 +7,9 @@ package main.java.com.djrapitops.plan.systems.info.parsing;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
|
||||
@ -37,12 +34,7 @@ public class AnalysisPageParser extends PageParser {
|
||||
public String parse() throws ParseException {
|
||||
addValues(data.getReplaceMap());
|
||||
addValue("tabContentPlugins", data.replacePluginsTabLayout());
|
||||
addValue("serverName", Settings.SERVER_NAME.toString());
|
||||
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||
addValue("refresh", FormatUtils.formatTimeStamp(data.getRefreshDate()));
|
||||
|
||||
addValue("playersMax", plugin.getVariable().getMaxPlayers());
|
||||
addValue("playersOnline", getPlayersOnline());
|
||||
try {
|
||||
return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("web/server.html"), placeHolders);
|
||||
} catch (IOException e) {
|
||||
|
@ -2,36 +2,28 @@ package main.java.com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.*;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.data.ServerProfile;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.data.analysis.*;
|
||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.tables.TPSTable;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.ErrorResponse;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InternalErrorResponse;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.PlayersTableCreator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -120,19 +112,22 @@ public class Analysis {
|
||||
analysisData.setPluginsTabLayout(HtmlStructure.createAnalysisPluginsTabLayout(thirdPartyPlugins));
|
||||
|
||||
Benchmark.stop("Analysis", "Create Empty dataset");
|
||||
fillDataset(analysisData, db);
|
||||
Benchmark.start("Fetch Phase");
|
||||
ServerProfile profile = db.getServerProfile(Plan.getServerUUID());
|
||||
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
|
||||
|
||||
Benchmark.start("Analysis Phase");
|
||||
Log.logDebug("Analysis", "Analysis Phase");
|
||||
|
||||
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(analysisData.getPlayerCountPart().getPlayerCount(), fetchPhaseLength));
|
||||
analysisData.analyseData();
|
||||
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(profile.getPlayerCount(), fetchPhaseLength));
|
||||
|
||||
analysisData.analyze(profile);
|
||||
|
||||
Benchmark.stop("Analysis", "Analysis Phase");
|
||||
|
||||
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
|
||||
Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)");
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(analysisData.getPlayerCountPart().getUuids()));
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(profile.getUuids()));
|
||||
((BukkitInformationManager) infoManager).cacheAnalysisData(analysisData);
|
||||
|
||||
// TODO Export
|
||||
@ -232,106 +227,4 @@ public class Analysis {
|
||||
public void setTaskId(int id) {
|
||||
taskId = id;
|
||||
}
|
||||
|
||||
private void fillDataset(AnalysisData analysisData, Database db) {
|
||||
ActivityPart activity = analysisData.getActivityPart();
|
||||
CommandUsagePart commandUsagePart = analysisData.getCommandUsagePart();
|
||||
GeolocationPart geolocPart = analysisData.getGeolocationPart();
|
||||
JoinInfoPart joinInfo = analysisData.getJoinInfoPart();
|
||||
KillPart killPart = analysisData.getKillPart();
|
||||
PlayerCountPart playerCount = analysisData.getPlayerCountPart();
|
||||
PlaytimePart playtime = analysisData.getPlaytimePart();
|
||||
TPSPart tpsPart = analysisData.getTpsPart();
|
||||
WorldPart worldPart = analysisData.getWorldPart();
|
||||
|
||||
long now = MiscUtils.getTime();
|
||||
|
||||
Benchmark.start("Analysis", "Fetch Phase");
|
||||
try {
|
||||
Map<String, Integer> commandUse = plugin.getDB().getCommandUse();
|
||||
commandUsagePart.setCommandUsage(commandUse);
|
||||
|
||||
TPSTable tpsTable = db.getTpsTable();
|
||||
List<TPS> tpsData = tpsTable.getTPSData();
|
||||
tpsTable.getAllTimePeak().ifPresent(tpsPart::setAllTimePeak);
|
||||
tpsTable.getPeakPlayerCount(now - (TimeAmount.DAY.ms() * 2)).ifPresent(tpsPart::setLastPeak);
|
||||
|
||||
tpsPart.addTpsData(tpsData);
|
||||
Log.logDebug("Analysis", "TPS Data Size: " + tpsData.size());
|
||||
|
||||
List<UserInfo> userInfo = db.getUserInfoTable().getServerUserInfo().stream().distinct().collect(Collectors.toList());
|
||||
|
||||
for (UserInfo user : userInfo) {
|
||||
if (user.isBanned()) {
|
||||
activity.addBan(user.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
Map<UUID, Long> lastSeen = db.getSessionsTable().getLastSeenForAllPlayers();
|
||||
for (UserInfo info : userInfo) {
|
||||
Long userLastSeen = lastSeen.getOrDefault(info.getUuid(), 0L);
|
||||
info.setLastSeen(userLastSeen);
|
||||
}
|
||||
|
||||
userInfo.sort(new UserInfoLastPlayedComparator());
|
||||
|
||||
activity.setRecentPlayersUUIDs(userInfo.stream().map(UserInfo::getUuid).collect(Collectors.toList()));
|
||||
activity.setRecentPlayers(userInfo.stream().map(UserInfo::getName).collect(Collectors.toList()));
|
||||
|
||||
playerCount.addPlayers(userInfo.stream().map(UserInfo::getUuid).collect(Collectors.toSet()));
|
||||
|
||||
Map<UUID, Long> registered = userInfo.stream().collect(Collectors.toMap(UserInfo::getUuid, UserInfo::getRegistered));
|
||||
joinInfo.addRegistered(registered);
|
||||
activity.addBans(userInfo.stream().filter(UserInfo::isBanned).map(UserInfo::getUuid).collect(Collectors.toSet()));
|
||||
|
||||
playerCount.addOPs(userInfo.stream().filter(UserInfo::isOpped).map(UserInfo::getUuid).collect(Collectors.toSet()));
|
||||
|
||||
Map<UUID, Session> activeSessions = SessionCache.getActiveSessions();
|
||||
Map<UUID, List<Session>> sessions = db.getSessionsTable().getAllSessions(true).get(Plan.getServerUUID());
|
||||
joinInfo.addActiveSessions(activeSessions);
|
||||
if (sessions != null) {
|
||||
joinInfo.addSessions(sessions);
|
||||
}
|
||||
|
||||
Map<UUID, List<GeoInfo>> geolocations = db.getIpsTable().getAllGeoInfo();
|
||||
// geolocPart.addGeoLocations(geolocations);
|
||||
|
||||
analysisData.setPlayersTable(PlayersTableCreator.createTable(userInfo, joinInfo, geolocPart));
|
||||
|
||||
Map<UUID, List<PlayerKill>> playerKills = db.getKillsTable().getPlayerKills();
|
||||
killPart.addKills(playerKills);
|
||||
|
||||
WorldTimes worldTimes = db.getWorldTimesTable().getWorldTimesOfServer();
|
||||
AnalysisUtils.addMissingWorlds(worldTimes);
|
||||
|
||||
worldPart.setWorldTimes(worldTimes);
|
||||
|
||||
playtime.setTotalPlaytime(db.getSessionsTable().getPlaytimeOfServer());
|
||||
playtime.setPlaytime30d(db.getSessionsTable().getPlaytimeOfServer(now - TimeAmount.MONTH.ms()));
|
||||
playtime.setPlaytime7d(db.getSessionsTable().getPlaytimeOfServer(now - TimeAmount.WEEK.ms()));
|
||||
playtime.setPlaytime24h(db.getSessionsTable().getPlaytimeOfServer(now - TimeAmount.DAY.ms()));
|
||||
|
||||
List<PluginData> banSources = plugin.getHookHandler().getAdditionalDataSources()
|
||||
.stream().filter(PluginData::isBanData).collect(Collectors.toList());
|
||||
|
||||
for (UUID uuid : playerCount.getUuids()) {
|
||||
boolean banned = banSources.stream().anyMatch(pluginData -> {
|
||||
StaticHolder.saveInstance(this.getClass(), plugin.getClass());
|
||||
try {
|
||||
Serializable value = pluginData.getValue(uuid);
|
||||
return value instanceof Boolean
|
||||
&& (boolean) value;
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchMethodError | NoSuchFieldError e) {
|
||||
Log.toLog(pluginData.getSourcePlugin() + pluginData.getPlaceholder() + " (Cause) ", e);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (banned) {
|
||||
activity.addBan(uuid);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,16 +191,12 @@ public class AnalysisUtils {
|
||||
return uniqueJoins.size();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long scale) {
|
||||
public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long after) {
|
||||
Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>();
|
||||
long now = MiscUtils.getTime();
|
||||
long nowMinusScale = now - scale;
|
||||
|
||||
sessions.forEach((uuid, s) -> {
|
||||
for (Session session : s) {
|
||||
if (scale != -1
|
||||
&& session.getSessionStart() < nowMinusScale) {
|
||||
if (session.getSessionStart() < after) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -221,23 +217,15 @@ public class AnalysisUtils {
|
||||
return total / numberOfDays;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static long getNewUsersPerDay(List<Long> registers, long scale) {
|
||||
long now = MiscUtils.getTime();
|
||||
long nowMinusScale = now - scale;
|
||||
|
||||
public static long getNewUsersPerDay(List<Long> registers, long after, long total) {
|
||||
Set<Integer> days = new HashSet<>();
|
||||
for (Long date : registers) {
|
||||
if (scale != -1) {
|
||||
if (date < nowMinusScale) {
|
||||
continue;
|
||||
}
|
||||
int day = getDayOfYear(date);
|
||||
days.add(day);
|
||||
if (date < after) {
|
||||
continue;
|
||||
}
|
||||
int day = getDayOfYear(date);
|
||||
days.add(day);
|
||||
}
|
||||
|
||||
long total = registers.stream().filter(date -> date >= nowMinusScale).count();
|
||||
int numberOfDays = days.size();
|
||||
|
||||
if (numberOfDays == 0) {
|
||||
|
@ -58,7 +58,7 @@ public enum Html {
|
||||
),
|
||||
TABLE_PLAYERS("<table class=\"table table-bordered table-striped table-hover player-table dataTable\"><thead><tr>" +
|
||||
"<th><i class=\"fa fa-user\"></i> Name</th>" +
|
||||
"<th><i class=\"fa fa-check\"></i> Active</th>" +
|
||||
"<th><i class=\"fa fa-check\"></i> Activity Index</th>" +
|
||||
"<th><i class=\"fa fa-clock-o\"></i> Playtime</th>" +
|
||||
"<th><i class=\"fa fa-calendar-plus-o\"></i> Sessions</th>" +
|
||||
"<th><i class=\"fa fa-user-plus\"></i> Registered</th>" +
|
||||
|
@ -13,7 +13,6 @@ import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -106,7 +105,7 @@ public class HtmlStructure {
|
||||
}
|
||||
}
|
||||
|
||||
return new String[]{Html.TABLE_SESSIONS.parse(SessionsTableCreator.createTable(uuidByID, allSessions)[0]), ""};
|
||||
return new String[]{/*Html.TABLE_SESSIONS.parse(SessionsTableCreator.createTable(uuidByID, allSessions)[0]),*/"", ""};
|
||||
}
|
||||
|
||||
public static String createInspectPluginsTabContent(String serverName, List<PluginData> plugins, Map<String, Serializable> replaceMap) {
|
||||
|
@ -6,21 +6,18 @@ package main.java.com.djrapitops.plan.utilities.html.structure;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.data.analysis.JoinInfoPart;
|
||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||
import main.java.com.djrapitops.plan.utilities.html.graphs.WorldPieCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.KillsTableCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
@ -33,9 +30,9 @@ public class SessionTabStructureCreator {
|
||||
|
||||
Map<Integer, UUID> uuidsByID = generateIDtoUUIDMap(sessions);
|
||||
|
||||
if (Settings.DISPLAY_SESSIONS_AS_TABLE.isTrue()) {
|
||||
return new String[]{Html.TABLE_SESSIONS.parse("", "", "", SessionsTableCreator.createTable(uuidsByID, allSessions)[0]), ""};
|
||||
}
|
||||
// if (Settings.DISPLAY_SESSIONS_AS_TABLE.isTrue()) {
|
||||
// return new String[]{Html.TABLE_SESSIONS.parse("", "", "", SessionsTableCreator.createTable(uuidsByID, allSessions)[0]), ""};
|
||||
// }
|
||||
|
||||
if (Verify.isEmpty(allSessions)) {
|
||||
return new String[]{"<div class=\"body\">" +
|
||||
@ -172,20 +169,15 @@ public class SessionTabStructureCreator {
|
||||
return uuidsByID;
|
||||
}
|
||||
|
||||
public static String[] creteStructure(JoinInfoPart joinInfoPart) {
|
||||
public static String[] creteStructure(Map<UUID, List<Session>> sessions, List<Session> allSessions) {
|
||||
Map<UUID, Map<String, List<Session>>> map = new HashMap<>();
|
||||
Map<UUID, List<Session>> sessions = joinInfoPart.getSessions();
|
||||
|
||||
for (Map.Entry<UUID, List<Session>> entry : sessions.entrySet()) {
|
||||
Map<String, List<Session>> serverSpecificMap = new HashMap<>();
|
||||
serverSpecificMap.put("This server", entry.getValue());
|
||||
map.put(entry.getKey(), serverSpecificMap);
|
||||
}
|
||||
|
||||
List<Session> allSessions = sessions.values().stream()
|
||||
.flatMap(Collection::stream)
|
||||
.sorted(new SessionStartComparator())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return creteStructure(map, allSessions, true);
|
||||
}
|
||||
}
|
@ -4,17 +4,12 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.PlayerProfile;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.data.UserInfo;
|
||||
import main.java.com.djrapitops.plan.data.analysis.GeolocationPart;
|
||||
import main.java.com.djrapitops.plan.data.analysis.JoinInfoPart;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.PlayerProfileLastPlayedComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -29,87 +24,13 @@ public class PlayersTableCreator {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String createTable(List<UserInfo> userInfo, JoinInfoPart joinInfoPart, GeolocationPart geolocationPart) {
|
||||
if (userInfo.isEmpty()) {
|
||||
return Html.TABLELINE_PLAYERS.parse("<b>No Players</b>", "", "", "", "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
StringBuilder html = new StringBuilder();
|
||||
|
||||
Map<UUID, List<Session>> sessions = joinInfoPart.getSessions();
|
||||
Map<UUID, String> geoLocations = geolocationPart.getMostCommonGeoLocations();
|
||||
|
||||
long now = MiscUtils.getTime();
|
||||
|
||||
int i = 0;
|
||||
for (UserInfo user : userInfo) {
|
||||
if (i >= 750) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
UUID uuid = user.getUuid();
|
||||
boolean isBanned = user.isBanned();
|
||||
List<Session> userSessions = sessions.get(uuid);
|
||||
int loginTimes = 0;
|
||||
long playtime = 0;
|
||||
if (userSessions != null) {
|
||||
loginTimes = userSessions.size();
|
||||
playtime = AnalysisUtils.getTotalPlaytime(userSessions);
|
||||
}
|
||||
boolean isUnknown = loginTimes == 1;
|
||||
long registered = user.getRegistered();
|
||||
|
||||
boolean isActive = AnalysisUtils.isActive(now, user.getLastSeen(), playtime, loginTimes);
|
||||
|
||||
long lastSeen = user.getLastSeen();
|
||||
|
||||
String activityString = getActivityString(isBanned, isUnknown, isActive);
|
||||
|
||||
|
||||
String geoLocation = geoLocations.get(uuid);
|
||||
if (geoLocation == null) {
|
||||
geoLocation = "Not Known";
|
||||
}
|
||||
html.append(Html.TABLELINE_PLAYERS.parse(
|
||||
Html.LINK.parse(Plan.getPlanAPI().getPlayerInspectPageLink(user.getName()), user.getName()),
|
||||
activityString,
|
||||
String.valueOf(playtime), FormatUtils.formatTimeAmount(playtime),
|
||||
String.valueOf(loginTimes),
|
||||
String.valueOf(registered), FormatUtils.formatTimeStampYear(registered),
|
||||
String.valueOf(lastSeen), lastSeen != 0 ? FormatUtils.formatTimeStamp(lastSeen) : "-",
|
||||
String.valueOf(geoLocation)
|
||||
));
|
||||
} catch (NullPointerException e) {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
Log.toLog(PlayersTableCreator.class.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
private static String getActivityString(boolean isBanned, boolean isUnknown, boolean isActive) {
|
||||
if (isBanned) {
|
||||
return "Banned";
|
||||
}
|
||||
|
||||
if (isUnknown) {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
return isActive ? "Active" : "Inactive";
|
||||
}
|
||||
|
||||
public static String createTable(List<PlayerProfile> players) {
|
||||
if (players.isEmpty()) {
|
||||
return Html.TABLELINE_PLAYERS.parse("<b>No Players</b>", "", "", "", "", "", "", "", "", "");
|
||||
}
|
||||
|
||||
players.sort(new PlayerProfileLastPlayedComparator());
|
||||
|
||||
StringBuilder html = new StringBuilder();
|
||||
|
||||
long now = MiscUtils.getTime();
|
||||
@ -125,14 +46,11 @@ public class PlayersTableCreator {
|
||||
boolean isBanned = profile.isBanned();
|
||||
long loginTimes = profile.getSessionCount(serverUUID);
|
||||
long playtime = profile.getPlaytime(serverUUID);
|
||||
boolean isUnknown = loginTimes <= 1;
|
||||
long registered = profile.getRegistered();
|
||||
|
||||
boolean isActive = AnalysisUtils.isActive(now, profile.getLastSeen(), playtime, loginTimes);
|
||||
|
||||
long lastSeen = profile.getLastSeen();
|
||||
|
||||
String activityString = getActivityString(isBanned, isUnknown, isActive);
|
||||
String activityString = isBanned ? "Banned" : FormatUtils.cutDecimals(profile.getActivityIndex(now));
|
||||
|
||||
String geoLocation = profile.getMostRecentGeoInfo().getGeolocation();
|
||||
html.append(Html.TABLELINE_PLAYERS.parse(
|
||||
|
@ -7,7 +7,6 @@ package main.java.com.djrapitops.plan.utilities.html.tables;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.WorldAliasSettings;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.data.analysis.JoinInfoPart;
|
||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.cache.SessionCache;
|
||||
@ -26,25 +25,25 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class SessionsTableCreator {
|
||||
|
||||
public static String[] createTable(JoinInfoPart joinInfoPart) {
|
||||
private static Map<Integer, UUID> getUUIDsByID(Map<UUID, List<Session>> sessionsByUser) {
|
||||
Map<Integer, UUID> uuidByID = new HashMap<>();
|
||||
for (Map.Entry<UUID, List<Session>> entry : joinInfoPart.getSessions().entrySet()) {
|
||||
for (Map.Entry<UUID, List<Session>> entry : sessionsByUser.entrySet()) {
|
||||
List<Session> sessions = entry.getValue();
|
||||
for (Session session : sessions) {
|
||||
uuidByID.put(session.getSessionID(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
List<Session> allSessions = joinInfoPart.getAllSessions();
|
||||
return createTable(uuidByID, allSessions);
|
||||
return uuidByID;
|
||||
}
|
||||
|
||||
public static String[] createTable(Map<Integer, UUID> uuidByID, List<Session> allSessions) {
|
||||
public static String[] createTable(Map<UUID, List<Session>> sessionsByUser, List<Session> allSessions) {
|
||||
if (allSessions.isEmpty()) {
|
||||
return new String[]{Html.TABLELINE_4.parse("<b>No Sessions</b>", "", "", ""),
|
||||
Html.TABLELINE_2.parse("<b>No Sessions</b>", "")};
|
||||
}
|
||||
|
||||
Map<Integer, UUID> uuidByID = getUUIDsByID(sessionsByUser);
|
||||
|
||||
allSessions.sort(new SessionStartComparator());
|
||||
|
||||
StringBuilder sessionTableBuilder = new StringBuilder();
|
||||
@ -88,7 +87,11 @@ public class SessionsTableCreator {
|
||||
));
|
||||
|
||||
if (recentLoginsNames.size() < 20 && !recentLoginsNames.contains(name)) {
|
||||
recentLoginsBuilder.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, name), start));
|
||||
boolean isNew = sessionsByUser.get(uuid).size() <= 2;
|
||||
|
||||
recentLoginsBuilder.append("<li><a class=\"col-").append(isNew ? "light-green" : "blue").append(" font-bold\" href=\"").append(inspectUrl)
|
||||
.append("\">").append(name).append("</a><span class=\"pull-right\">").append(start).append("</span></li>");
|
||||
|
||||
recentLoginsNames.add(name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user