mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-17 15:55:02 +02:00
Merge remote-tracking branch 'Fuzzlemann/master'
This commit is contained in:
commit
8640520af9
4
.gitignore
vendored
4
.gitignore
vendored
@ -13,3 +13,7 @@
|
|||||||
/Filetool/build/
|
/Filetool/build/
|
||||||
/PlanPluginBridge/target/
|
/PlanPluginBridge/target/
|
||||||
/MakroS/nbproject/private/
|
/MakroS/nbproject/private/
|
||||||
|
*.xml
|
||||||
|
Plan/Plan.iml
|
||||||
|
Plan/.sonar/.sonar_lock
|
||||||
|
Plan/.sonar/report-task.txt
|
||||||
|
@ -34,12 +34,12 @@ import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
|||||||
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.data.cache.PageCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.PageCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.data.listeners.*;
|
import main.java.com.djrapitops.plan.data.listeners.*;
|
||||||
|
import main.java.com.djrapitops.plan.data.server.ServerInfoManager;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
||||||
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||||
import main.java.com.djrapitops.plan.locale.Locale;
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
import main.java.com.djrapitops.plan.locale.Msg;
|
import main.java.com.djrapitops.plan.locale.Msg;
|
||||||
import main.java.com.djrapitops.plan.ui.theme.Theme;
|
|
||||||
import main.java.com.djrapitops.plan.ui.webserver.WebServer;
|
import main.java.com.djrapitops.plan.ui.webserver.WebServer;
|
||||||
import main.java.com.djrapitops.plan.ui.webserver.api.bukkit.*;
|
import main.java.com.djrapitops.plan.ui.webserver.api.bukkit.*;
|
||||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||||
@ -77,6 +77,8 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
|
|
||||||
private WebServer uiServer;
|
private WebServer uiServer;
|
||||||
|
|
||||||
|
private ServerInfoManager serverInfoManager;
|
||||||
|
|
||||||
private ServerVariableHolder serverVariableHolder;
|
private ServerVariableHolder serverVariableHolder;
|
||||||
private int bootAnalysisTaskID = -1;
|
private int bootAnalysisTaskID = -1;
|
||||||
|
|
||||||
@ -165,14 +167,11 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
|
|
||||||
Benchmark.start("Analysis refresh task registration");
|
Benchmark.start("Analysis refresh task registration");
|
||||||
// Analysis refresh settings
|
// Analysis refresh settings
|
||||||
boolean bootAnalysisIsEnabled = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue();
|
|
||||||
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
|
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
|
||||||
boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0;
|
boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0;
|
||||||
|
|
||||||
// Analysis refresh tasks
|
// Analysis refresh tasks
|
||||||
if (bootAnalysisIsEnabled) {
|
startBootAnalysisTask();
|
||||||
startBootAnalysisTask();
|
|
||||||
}
|
|
||||||
if (analysisRefreshTaskIsEnabled) {
|
if (analysisRefreshTaskIsEnabled) {
|
||||||
startAnalysisRefreshTask(analysisRefreshMinutes);
|
startAnalysisRefreshTask(analysisRefreshMinutes);
|
||||||
}
|
}
|
||||||
@ -180,23 +179,26 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
Benchmark.stop("Enable", "Analysis refresh task registration");
|
Benchmark.stop("Enable", "Analysis refresh task registration");
|
||||||
|
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
// Data view settings
|
|
||||||
boolean webserverIsEnabled = Settings.WEBSERVER_ENABLED.isTrue();
|
|
||||||
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
|
||||||
boolean usingAlternativeUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
|
||||||
boolean hasDataViewCapability = usingAlternativeIP || usingAlternativeUI || webserverIsEnabled;
|
|
||||||
|
|
||||||
uiServer = new WebServer(this);
|
uiServer = new WebServer(this);
|
||||||
if (webserverIsEnabled) {
|
registerWebAPIs(); // TODO Move to WebServer class
|
||||||
registerWebAPIs();
|
uiServer.initServer();
|
||||||
uiServer.initServer();
|
|
||||||
|
|
||||||
if (!uiServer.isEnabled()) {
|
if (!uiServer.isEnabled()) {
|
||||||
Log.error("WebServer was not successfully initialized.");
|
Log.error("WebServer was not successfully initialized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFilter();
|
Benchmark.start("ServerInfo Registration");
|
||||||
} else if (!hasDataViewCapability) {
|
serverInfoManager = new ServerInfoManager(this);
|
||||||
|
Benchmark.stop("Enable", "ServerInfo Registration");
|
||||||
|
|
||||||
|
setupFilter(); // TODO Move to RegisterCommand Constructor
|
||||||
|
|
||||||
|
// Data view settings // TODO Rewrite. (TextUI removed & webserver might be running on bungee
|
||||||
|
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||||
|
boolean hasDataViewCapability = usingAlternativeIP;
|
||||||
|
|
||||||
|
if (!hasDataViewCapability) {
|
||||||
Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_NO_DATA_VIEW).toString());
|
Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_NO_DATA_VIEW).toString());
|
||||||
}
|
}
|
||||||
if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) {
|
if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) {
|
||||||
@ -215,8 +217,6 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
// BStats bStats = new BStats(this);
|
// BStats bStats = new BStats(this);
|
||||||
// bStats.registerMetrics();
|
// bStats.registerMetrics();
|
||||||
|
|
||||||
Theme.test(); //TODO Remove
|
|
||||||
|
|
||||||
Log.debug("Verbose debug messages are enabled.");
|
Log.debug("Verbose debug messages are enabled.");
|
||||||
Log.logDebug("Enable", Benchmark.stop("Enable", "Enable"));
|
Log.logDebug("Enable", Benchmark.stop("Enable", "Enable"));
|
||||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
Log.info(Locale.get(Msg.ENABLED).toString());
|
||||||
@ -455,4 +455,14 @@ public class Plan extends BukkitPlugin<Plan> {
|
|||||||
public ServerVariableHolder getVariable() {
|
public ServerVariableHolder getVariable() {
|
||||||
return serverVariableHolder;
|
return serverVariableHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get the object storing server info
|
||||||
|
*
|
||||||
|
* @return ServerInfoManager
|
||||||
|
* @see ServerInfoManager
|
||||||
|
*/
|
||||||
|
public ServerInfoManager getServerInfoManager() {
|
||||||
|
return serverInfoManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,31 +13,15 @@ public enum Settings {
|
|||||||
// Boolean
|
// Boolean
|
||||||
BUNGEE_COPY_CONFIG("Bungee-Override.CopyBungeeConfig"),
|
BUNGEE_COPY_CONFIG("Bungee-Override.CopyBungeeConfig"),
|
||||||
BUNGEE_OVERRIDE_STANDALONE_MODE("Bungee-Override.StandaloneMode"),
|
BUNGEE_OVERRIDE_STANDALONE_MODE("Bungee-Override.StandaloneMode"),
|
||||||
@Deprecated WEBSERVER_ENABLED("Settings.WebServer.Enabled"),
|
|
||||||
@Deprecated ANALYSIS_REFRESH_ON_ENABLE("Settings.Cache.AnalysisCache.RefreshAnalysisCacheOnEnable"),
|
|
||||||
@Deprecated ANALYSIS_LOG_TO_CONSOLE("Settings.Analysis.LogProgressOnConsole"),
|
|
||||||
@Deprecated ANALYSIS_LOG_FINISHED("Settings.Analysis.NotifyWhenFinished"),
|
|
||||||
ANALYSIS_EXPORT("Analysis.Export.Enabled"),
|
ANALYSIS_EXPORT("Analysis.Export.Enabled"),
|
||||||
SHOW_ALTERNATIVE_IP("Commands.AlternativeIP.Enabled"),
|
SHOW_ALTERNATIVE_IP("Commands.AlternativeIP.Enabled"),
|
||||||
@Deprecated USE_ALTERNATIVE_UI("Settings.UseTextUI"),
|
|
||||||
LOG_UNKNOWN_COMMANDS("DAta.Commands.LogUnknownCommands"),
|
LOG_UNKNOWN_COMMANDS("DAta.Commands.LogUnknownCommands"),
|
||||||
COMBINE_COMMAND_ALIASES("Data.Commands.CombineCommandAliases"),
|
COMBINE_COMMAND_ALIASES("Data.Commands.CombineCommandAliases"),
|
||||||
@Deprecated SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
|
|
||||||
@Deprecated PLAYERLIST_SHOW_IMAGES("Customization.SmallHeadImagesOnAnalysisPlayerlist"),
|
|
||||||
WRITE_NEW_LOCALE("Plugin.WriteNewLocaleFileOnStart"),
|
WRITE_NEW_LOCALE("Plugin.WriteNewLocaleFileOnStart"),
|
||||||
|
|
||||||
// Integer
|
// Integer
|
||||||
@Deprecated ANALYSIS_MINUTES_FOR_ACTIVE("Settings.Analysis.MinutesPlayedUntilConsidiredActive"),
|
|
||||||
@Deprecated SAVE_CACHE_MIN("Settings.Cache.DataCache.SaveEveryXMinutes"),
|
|
||||||
@Deprecated CLEAR_INSPECT_CACHE("Settings.Cache.InspectCache.ClearFromInspectCacheAfterXMinutes"),
|
|
||||||
@Deprecated CLEAR_CACHE_X_SAVES("Settings.Cache.DataCache.ClearCacheEveryXSaves"),
|
|
||||||
WEBSERVER_PORT("WebServer.Port"),
|
WEBSERVER_PORT("WebServer.Port"),
|
||||||
ANALYSIS_AUTO_REFRESH("Analysis.AutoRefreshPeriod"),
|
ANALYSIS_AUTO_REFRESH("Analysis.AutoRefreshPeriod"),
|
||||||
@Deprecated PROCESS_GET_LIMIT("Settings.Cache.Processing.GetLimit"),
|
|
||||||
@Deprecated PROCESS_SAVE_LIMIT("Settings.Cache.Processing.SaveLimit"),
|
|
||||||
@Deprecated PROCESS_CLEAR_LIMIT("Settings.Cache.Processing.ClearLimit"),
|
|
||||||
@Deprecated TPS_GRAPH_HIGH("Customization.Colors.HTML.TPSGraph.TPSHigh"),
|
|
||||||
@Deprecated TPS_GRAPH_MED("Customization.Colors.HTML.TPSGraph.TPSMedium"),
|
|
||||||
// String
|
// String
|
||||||
DEBUG("Plugin.Debug"),
|
DEBUG("Plugin.Debug"),
|
||||||
ALTERNATIVE_IP("Commands.AlternativeIP.Link"),
|
ALTERNATIVE_IP("Commands.AlternativeIP.Link"),
|
||||||
|
@ -26,10 +26,11 @@ public class ConditionUtils {
|
|||||||
*
|
*
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
|
// TODO Rewrite this method
|
||||||
public static boolean pluginHasViewCapability() {
|
public static boolean pluginHasViewCapability() {
|
||||||
final boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
final boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||||
final boolean webserverIsOn = Settings.WEBSERVER_ENABLED.isTrue();
|
final boolean webserverIsOn = true;
|
||||||
final boolean usingTextUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
final boolean usingTextUI = false;
|
||||||
return webserverIsOn || usingAlternativeIP || usingTextUI;
|
return webserverIsOn || usingAlternativeIP || usingTextUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,10 @@ import com.djrapitops.plugin.utilities.Verify;
|
|||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Permissions;
|
import main.java.com.djrapitops.plan.Permissions;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.command.ConditionUtils;
|
import main.java.com.djrapitops.plan.command.ConditionUtils;
|
||||||
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.locale.Locale;
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
import main.java.com.djrapitops.plan.locale.Msg;
|
import main.java.com.djrapitops.plan.locale.Msg;
|
||||||
import main.java.com.djrapitops.plan.ui.text.TextUI;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.Check;
|
import main.java.com.djrapitops.plan.utilities.Check;
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
@ -126,24 +124,16 @@ public class InspectCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendInspectMsg(ISender sender, String playerName, UUID uuid) {
|
private void sendInspectMsg(ISender sender, String playerName, UUID uuid) {
|
||||||
|
|
||||||
boolean usingTextUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
|
||||||
|
|
||||||
sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + playerName);
|
sender.sendMessage(Locale.get(Msg.CMD_HEADER_INSPECT) + playerName);
|
||||||
|
// Link
|
||||||
if (usingTextUI) {
|
String url = HtmlUtils.getInspectUrlWithProtocol(playerName);
|
||||||
sender.sendMessage(TextUI.getInspectMessages(uuid));
|
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||||
|
boolean console = !CommandUtils.isPlayer(sender);
|
||||||
|
if (console) {
|
||||||
|
sender.sendMessage(message + url);
|
||||||
} else {
|
} else {
|
||||||
// Link
|
sender.sendMessage(message);
|
||||||
String url = HtmlUtils.getInspectUrlWithProtocol(playerName);
|
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
||||||
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
|
||||||
boolean console = !CommandUtils.isPlayer(sender);
|
|
||||||
if (console) {
|
|
||||||
sender.sendMessage(message + url);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(message);
|
|
||||||
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||||
|
@ -49,8 +49,8 @@ public class AnalysisData extends RawData {
|
|||||||
geolocationPart = new GeolocationPart();
|
geolocationPart = new GeolocationPart();
|
||||||
joinInfoPart = new JoinInfoPart();
|
joinInfoPart = new JoinInfoPart();
|
||||||
playerCountPart = new PlayerCountPart();
|
playerCountPart = new PlayerCountPart();
|
||||||
playtimePart = new PlaytimePart(playerCountPart);
|
playtimePart = new PlaytimePart();
|
||||||
killPart = new KillPart(playerCountPart);
|
killPart = new KillPart();
|
||||||
gamemodePart = new GamemodePart();
|
gamemodePart = new GamemodePart();
|
||||||
tpsPart = new TPSPart(tpsData);
|
tpsPart = new TPSPart(tpsData);
|
||||||
activityPart = new ActivityPart(joinInfoPart, tpsPart);
|
activityPart = new ActivityPart(joinInfoPart, tpsPart);
|
||||||
@ -137,7 +137,7 @@ public class AnalysisData extends RawData {
|
|||||||
Verify.nullCheck(pluginsTabLayout);
|
Verify.nullCheck(pluginsTabLayout);
|
||||||
Verify.nullCheck(planVersion);
|
Verify.nullCheck(planVersion);
|
||||||
|
|
||||||
addValue("sortabletable", playersTable);
|
addValue("tableBodyPlayerList", playersTable);
|
||||||
addValue("version", planVersion);
|
addValue("version", planVersion);
|
||||||
|
|
||||||
final List<RawData> parts = getAllParts();
|
final List<RawData> parts = getAllParts();
|
||||||
|
@ -16,30 +16,31 @@ import java.util.stream.Collectors;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
// TODO Change to be only used for DB User Get Query responses.
|
||||||
public class UserData {
|
public class UserData {
|
||||||
|
|
||||||
private final List<SessionData> sessions;
|
private final List<SessionData> sessions;
|
||||||
private int accessing;
|
private int accessing;
|
||||||
private boolean clearAfterSave;
|
private boolean clearAfterSave;
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String name;
|
private String name; //TODO DB Update code to JoinListener
|
||||||
private Set<String> nicknames;
|
@Deprecated private Set<String> nicknames; //TODO DB Update code to ChatListener
|
||||||
private String lastNick;
|
@Deprecated private String lastNick; //TODO DB Update code to ChatListener
|
||||||
private String geolocation;
|
@Deprecated private String geolocation; //TODO DB Update code to JoinListener
|
||||||
private Set<InetAddress> ips;
|
@Deprecated private Set<InetAddress> ips; //TODO DB Update code to JoinListener
|
||||||
private int loginTimes;
|
@Deprecated private int loginTimes; // Moving to sessions.size
|
||||||
private int timesKicked;
|
@Deprecated private int timesKicked; //TODO DB Update code to KickListener
|
||||||
private boolean isOp;
|
@Deprecated private boolean isOp; //TODO DB Update code to JoinListener
|
||||||
private boolean isBanned;
|
@Deprecated private boolean isBanned; //TODO DB Update code to JoinListener
|
||||||
private boolean isOnline;
|
@Deprecated private boolean isOnline; //TODO New Class for getting online status of players
|
||||||
private int mobKills;
|
@Deprecated private int mobKills; //TODO Move to SessionData
|
||||||
private List<KillData> playerKills;
|
@Deprecated private List<KillData> playerKills; //TODO Move to SessionData
|
||||||
private int deaths;
|
@Deprecated private int deaths; //TODO Move to SessionData
|
||||||
private long registered;
|
@Deprecated private long registered; //TODO DB Update code to JoinListener (When registering)
|
||||||
private long lastPlayed;
|
@Deprecated private long lastPlayed; //TODO DB Update code to Join, Refresh, QuitListener
|
||||||
private long playTime;
|
@Deprecated private long playTime; //TODO Move to SessionData
|
||||||
private GMTimes gmTimes;
|
@Deprecated private GMTimes gmTimes; //TODO Move to WorldTimes
|
||||||
private WorldTimes worldTimes;
|
@Deprecated private WorldTimes worldTimes; //TODO Move to SessionData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new UserData object with given values and default values.
|
* Creates a new UserData object with given values and default values.
|
||||||
|
@ -154,7 +154,7 @@ public abstract class PluginData {
|
|||||||
* @see AnalysisType
|
* @see AnalysisType
|
||||||
*/
|
*/
|
||||||
public final String getPlaceholder(String modifier) {
|
public final String getPlaceholder(String modifier) {
|
||||||
return "%" + sourcePlugin + "_" + placeholder + modifier + "%";
|
return "${" + sourcePlugin + "_" + placeholder + modifier + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,13 +2,13 @@ package main.java.com.djrapitops.plan.data.analysis;
|
|||||||
|
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.SessionData;
|
import main.java.com.djrapitops.plan.data.SessionData;
|
||||||
import main.java.com.djrapitops.plan.data.TPS;
|
import main.java.com.djrapitops.plan.data.TPS;
|
||||||
import main.java.com.djrapitops.plan.ui.html.RecentPlayersButtonsCreator;
|
import main.java.com.djrapitops.plan.ui.html.RecentPlayersButtonsCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.PlayerActivityGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.PlayerActivityGraphCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.SessionLengthDistributionGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.SessionLengthDistributionGraphCreator;
|
||||||
|
import main.java.com.djrapitops.plan.ui.theme.Colors;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
@ -21,17 +21,22 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for all Player Activity related analysis.
|
* Part responsible for all Player Activity related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Online Graphs, Player-base pie-chart, Recent Players and Session
|
|
||||||
* visualisation.
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: recentlogins, sessionaverage,
|
* Contains following placeholders after analyzed:
|
||||||
* datapunchcard, datasessiondistribution, labelssessiondistribution,
|
* ${active} - (Number)
|
||||||
* datascatterday, datascatterweek, datascattermonth, playersonlinecolor,
|
* ${inactive} - (Number)
|
||||||
* playersgraphfill, activecol, inactivecol, joinleavecol, bannedcol,
|
* ${joinLeaver} - (Number)
|
||||||
* activitycolors, labelsactivity, dataaactivity, active, inactive, joinleaver,
|
* ${banned} - (Number)
|
||||||
* banned
|
* ${activityColors} - Color array
|
||||||
|
* ${playersGraphColor} - Color
|
||||||
|
* <p>
|
||||||
|
* ${playersOnlineSeries} - Data for HighCharts
|
||||||
|
* ${sessionLengthSeries} - Data for HighCharts
|
||||||
|
* ${punchCardSeries} - Data for HighCharts
|
||||||
|
* <p>
|
||||||
|
* ${sessionAverage} - Formatted Time amount
|
||||||
|
* //TODO ${tableBodyRecentLogins}
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
@ -61,6 +66,7 @@ public class ActivityPart extends RawData {
|
|||||||
Verify.nullCheck(recentPlayers);
|
Verify.nullCheck(recentPlayers);
|
||||||
Verify.nullCheck(recentPlayersUUIDs);
|
Verify.nullCheck(recentPlayersUUIDs);
|
||||||
|
|
||||||
|
// TODO Recent logins table
|
||||||
addValue("recentlogins", RecentPlayersButtonsCreator.createRecentLoginsButtons(recentPlayers, 15));
|
addValue("recentlogins", RecentPlayersButtonsCreator.createRecentLoginsButtons(recentPlayers, 15));
|
||||||
|
|
||||||
activityPiechart();
|
activityPiechart();
|
||||||
@ -71,45 +77,34 @@ public class ActivityPart extends RawData {
|
|||||||
|
|
||||||
List<Long> lengths = AnalysisUtils.transformSessionDataToLengths(sessions);
|
List<Long> lengths = AnalysisUtils.transformSessionDataToLengths(sessions);
|
||||||
long averageLength = MathUtils.averageLong(lengths);
|
long averageLength = MathUtils.averageLong(lengths);
|
||||||
addValue("sessionaverage", FormatUtils.formatTimeAmount(averageLength));
|
addValue("sessionAverage", FormatUtils.formatTimeAmount(averageLength));
|
||||||
|
|
||||||
List<SessionData> sessionsMonth = sessions.stream()
|
List<SessionData> sessionsMonth = sessions.stream()
|
||||||
.filter(s -> s.getSessionStart() > MiscUtils.getTime() - TimeAmount.MONTH.ms())
|
.filter(s -> s.getSessionStart() > MiscUtils.getTime() - TimeAmount.MONTH.ms())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
addValue("punchcardseries", PunchCardGraphCreator.createDataSeries(sessionsMonth));
|
addValue("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessionsMonth));
|
||||||
addValue("sessionlengthseries", SessionLengthDistributionGraphCreator.createDataSeries(lengths));
|
addValue("sessionLengthSeries", SessionLengthDistributionGraphCreator.createDataSeries(lengths));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playerActivityGraphs() {
|
private void playerActivityGraphs() {
|
||||||
List<TPS> tpsData = tpsPart.getTpsData();
|
List<TPS> tpsData = tpsPart.getTpsData();
|
||||||
addValue("playersonlineseries", PlayerActivityGraphCreator.buildSeriesDataString(tpsData));
|
addValue("playersOnlineSeries", PlayerActivityGraphCreator.buildSeriesDataString(tpsData));
|
||||||
addValue("playersgraphcolor", Settings.HCOLOR_ACT_ONL.toString());
|
addValue("playersGraphColor", Colors.PLAYERS_ONLINE.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activityPiechart() {
|
private void activityPiechart() {
|
||||||
int[] counts = new int[]{active.size(), inactive.size(), joinedOnce.size(), bans.size()};
|
int[] counts = new int[]{active.size(), inactive.size(), joinedOnce.size(), bans.size()};
|
||||||
final String colAct = Settings.HCOLOR_ACTP_ACT.toString();
|
|
||||||
final String colIna = Settings.HCOLOR_ACTP_INA.toString();
|
|
||||||
final String colJoi = Settings.HCOLOR_ACTP_JON.toString();
|
|
||||||
final String colBan = Settings.HCOLOR_ACTP_BAN.toString();
|
|
||||||
|
|
||||||
addValue("activecol", colAct);
|
|
||||||
addValue("inactivecol", colIna);
|
|
||||||
addValue("joinleavecol", colJoi);
|
|
||||||
addValue("bancol", colBan);
|
|
||||||
String activityColors = HtmlUtils.separateWithQuotes(
|
String activityColors = HtmlUtils.separateWithQuotes(
|
||||||
"#" + colAct, "#" + colIna, "#" + colJoi, "#" + colBan
|
"#55ffff", "#ff55ff", "#ff5555", "#ffff55" //TODO Write Colors (enums) for Activity pie.
|
||||||
);
|
);
|
||||||
addValue("activitycolors", activityColors);
|
addValue("activityColors", activityColors);
|
||||||
|
|
||||||
String activityLabels = "[" + HtmlUtils.separateWithQuotes(
|
// addValue("activitydata", Arrays.toString(counts)); // TODO Check if needed
|
||||||
"Active", "Inactive", "Unknown", "Banned") + "]";
|
addValue("playersActive", counts[0]);
|
||||||
addValue("labelsactivity", activityLabels);
|
|
||||||
|
|
||||||
addValue("activitydata", Arrays.toString(counts));
|
|
||||||
addValue("active", counts[0]);
|
addValue("active", counts[0]);
|
||||||
addValue("inactive", counts[1]);
|
addValue("inactive", counts[1]);
|
||||||
addValue("joinleaver", counts[2]);
|
addValue("joinLeaver", counts[2]);
|
||||||
addValue("banned", counts[3]);
|
addValue("banned", counts[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,11 +13,12 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for all CommandUsage related analysis.
|
* Part responsible for all CommandUsage related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Command Usage Table.
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: uniquecommands, totalcommands, commanduse
|
* Contains following placeholders after analyzed:
|
||||||
|
* ${commandCount} - (Number)
|
||||||
|
* ${commandUniqueCount} - (Number)
|
||||||
|
* ${tableBodyCommands} - Table body for CommandUsage table.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
@ -32,10 +33,10 @@ public class CommandUsagePart extends RawData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyse() {
|
public void analyse() {
|
||||||
addValue("uniquecommands", String.valueOf(getUniqueCommands()));
|
addValue("commandUniqueCount", String.valueOf(getUniqueCommands()));
|
||||||
addValue("totalcommands", String.valueOf(getCommandTotal()));
|
addValue("commandCount", String.valueOf(getCommandTotal()));
|
||||||
String commandUsageTable = CommandUseTableCreator.createSortedCommandUseTable(commandUsage);
|
String commandUsageTable = CommandUseTableCreator.createSortedCommandUseTable(commandUsage);
|
||||||
addValue("commanduse", HtmlUtils.removeXSS(commandUsageTable));
|
addValue("tableBodyCommands", HtmlUtils.removeXSS(commandUsageTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUniqueCommands() {
|
public int getUniqueCommands() {
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package main.java.com.djrapitops.plan.data.analysis;
|
package main.java.com.djrapitops.plan.data.analysis;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part responsible for all Gamemode usage related analysis.
|
* Part responsible for all Gamemode usage related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
@ -20,6 +16,7 @@ import java.util.Arrays;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class GamemodePart extends RawData {
|
public class GamemodePart extends RawData {
|
||||||
|
|
||||||
private long survivalTime;
|
private long survivalTime;
|
||||||
@ -41,51 +38,16 @@ public class GamemodePart extends RawData {
|
|||||||
|
|
||||||
private void gamemodePiechart() {
|
private void gamemodePiechart() {
|
||||||
long totalTime = survivalTime + creativeTime + adventureTime + spectatorTime;
|
long totalTime = survivalTime + creativeTime + adventureTime + spectatorTime;
|
||||||
|
|
||||||
addValue("gmtotal", FormatUtils.formatTimeAmount(totalTime));
|
|
||||||
|
|
||||||
double[] percentages = new double[]{
|
|
||||||
(survivalTime * 100.0) / totalTime,
|
|
||||||
(creativeTime * 100.0) / totalTime,
|
|
||||||
(adventureTime * 100.0) / totalTime,
|
|
||||||
(spectatorTime * 100.0) / totalTime
|
|
||||||
};
|
|
||||||
long[] times = new long[]{
|
|
||||||
survivalTime, creativeTime, adventureTime, spectatorTime
|
|
||||||
};
|
|
||||||
String col0 = Settings.HCOLOR_GMP_0.toString();
|
|
||||||
String col1 = Settings.HCOLOR_GMP_1.toString();
|
|
||||||
String col2 = Settings.HCOLOR_GMP_2.toString();
|
|
||||||
String col3 = Settings.HCOLOR_GMP_3.toString();
|
|
||||||
|
|
||||||
addValue("gm0col", col0);
|
|
||||||
addValue("gm1col", col1);
|
|
||||||
addValue("gm2col", col2);
|
|
||||||
addValue("gm3col", col3);
|
|
||||||
String gmColors = HtmlUtils.separateWithQuotes(
|
String gmColors = HtmlUtils.separateWithQuotes(
|
||||||
"#" + col0, "#" + col1, "#" + col2, "#" + col3
|
"#555", "#555", "#555", "#555" // TODO Write Colors (enum) variables for GameMode colors.
|
||||||
);
|
);
|
||||||
String gmLabels = "[" + HtmlUtils.separateWithQuotes(
|
addValue("gmColors", gmColors);
|
||||||
"Survival", "Creative", "Adventure", "Spectator") + "]";
|
|
||||||
addValue("gmcolors", gmColors);
|
|
||||||
addValue("gmlabel", gmLabels);
|
|
||||||
|
|
||||||
// Adds Percentage indicators
|
|
||||||
for (int i = 0; i < percentages.length; i++) {
|
|
||||||
addValue("gm" + i, (int) (percentages[i]) + "%");
|
|
||||||
}
|
|
||||||
// Adds Value array for graph
|
|
||||||
addValue("gmdata", Arrays.toString(times));
|
|
||||||
|
|
||||||
// Adds formatted time amounts for each gamemode
|
|
||||||
for (int i = 0; i < times.length; i++) {
|
|
||||||
addValue("gm" + i + "total", FormatUtils.formatTimeAmount(times[i]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds time to a gamemode.
|
* Adds time to a gamemode.
|
||||||
* @param gm Name of Gamemode
|
*
|
||||||
|
* @param gm Name of Gamemode
|
||||||
* @param amount milliseconds to add
|
* @param amount milliseconds to add
|
||||||
* @throws IllegalArgumentException if gm is null
|
* @throws IllegalArgumentException if gm is null
|
||||||
*/
|
*/
|
||||||
|
@ -8,11 +8,10 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for all Geolocation related analysis.
|
* Part responsible for all Geolocation related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Player location World Choropleth map.
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: geomapz, geomapcountries, geomapcodes
|
* Contains following placeholders after analyzed:
|
||||||
|
* ${geoMapSeries}
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
@ -39,7 +38,7 @@ public class GeolocationPart extends RawData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyse() {
|
public void analyse() {
|
||||||
addValue("geomapseries", WorldMapCreator.createDataSeries(geoCodeCounts));
|
addValue("geoMapSeries", WorldMapCreator.createDataSeries(geoCodeCounts));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGeolocation(String country) {
|
public void addGeolocation(String country) {
|
||||||
|
@ -12,15 +12,25 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for all Player login related analysis.
|
* Part responsible for all Player login related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Unique per Day, Unique, New Players, Logins
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: totallogins, uniquejoinsday,
|
* Contains following placeholders after analyzed:
|
||||||
* uniquejoinsweek, uniquejoinsmonth, avguniquejoins, avguniquejoinsday,
|
* ${playersAverage} - (Number)
|
||||||
* avguniquejoinsweek, avguniquejoinsmonth, npday, npweek, npmonth,
|
* ${playersNewAverage} - (Number)
|
||||||
* npdataday, npdataweek, npdatamonth, newperday, newperdayday, newperdayweek, newperdaymonth
|
* <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)
|
||||||
|
* //TODO ${tableBodySessions}, ${sessionCount}, ${lastPeakTime}, ${playersLastPeak}, ${bestPeakTime}, ${playersBestPeak}
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
*/
|
*/
|
||||||
@ -38,8 +48,6 @@ public class JoinInfoPart extends RawData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyse() {
|
public void analyse() {
|
||||||
addValue("totallogins", loginTimes);
|
|
||||||
|
|
||||||
newPlayers();
|
newPlayers();
|
||||||
uniquePlayers();
|
uniquePlayers();
|
||||||
uniquePlayersPerDay();
|
uniquePlayersPerDay();
|
||||||
@ -50,9 +58,9 @@ public class JoinInfoPart extends RawData {
|
|||||||
int uniqueWeek = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.WEEK.ms());
|
int uniqueWeek = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.WEEK.ms());
|
||||||
int uniqueMonth = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.MONTH.ms());
|
int uniqueMonth = AnalysisUtils.getUniqueJoins(sessions, TimeAmount.MONTH.ms());
|
||||||
|
|
||||||
addValue("uniquejoinsday", uniqueDay);
|
addValue("playersDay", uniqueDay);
|
||||||
addValue("uniquejoinsweek", uniqueWeek);
|
addValue("playersWeek", uniqueWeek);
|
||||||
addValue("uniquejoinsmonth", uniqueMonth);
|
addValue("playersMonth", uniqueMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uniquePlayersPerDay() {
|
private void uniquePlayersPerDay() {
|
||||||
@ -61,10 +69,10 @@ public class JoinInfoPart extends RawData {
|
|||||||
int perDayWeek = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.WEEK.ms());
|
int perDayWeek = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.WEEK.ms());
|
||||||
int perDayMonth = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.MONTH.ms());
|
int perDayMonth = AnalysisUtils.getUniqueJoinsPerDay(sessions, TimeAmount.MONTH.ms());
|
||||||
|
|
||||||
addValue("avguniquejoins", perDay);
|
addValue("playersAverage", perDay);
|
||||||
addValue("avguniquejoinsday", perDayDay);
|
addValue("playersAverageDay", perDayDay);
|
||||||
addValue("avguniquejoinsweek", perDayWeek);
|
addValue("playersAverageWeek", perDayWeek);
|
||||||
addValue("avguniquejoinsmonth", perDayMonth);
|
addValue("playersAverageMonth", perDayMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newPlayers() {
|
private void newPlayers() {
|
||||||
@ -73,19 +81,19 @@ public class JoinInfoPart extends RawData {
|
|||||||
long newWeek = AnalysisUtils.getNewPlayers(registered, TimeAmount.WEEK.ms(), now);
|
long newWeek = AnalysisUtils.getNewPlayers(registered, TimeAmount.WEEK.ms(), now);
|
||||||
long newMonth = AnalysisUtils.getNewPlayers(registered, TimeAmount.MONTH.ms(), now);
|
long newMonth = AnalysisUtils.getNewPlayers(registered, TimeAmount.MONTH.ms(), now);
|
||||||
|
|
||||||
addValue("npday", newDay);
|
addValue("playersNewDay", newDay);
|
||||||
addValue("npweek", newWeek);
|
addValue("playersNewWeek", newWeek);
|
||||||
addValue("npmonth", newMonth);
|
addValue("playersNewMonth", newMonth);
|
||||||
|
|
||||||
long newPerDay = AnalysisUtils.getNewUsersPerDay(registered, -1);
|
long newPerDay = AnalysisUtils.getNewUsersPerDay(registered, -1);
|
||||||
long newPerDayDay = AnalysisUtils.getNewUsersPerDay(registered, TimeAmount.DAY.ms());
|
long newPerDayDay = AnalysisUtils.getNewUsersPerDay(registered, TimeAmount.DAY.ms());
|
||||||
long newPerDayWeek = AnalysisUtils.getNewUsersPerDay(registered, TimeAmount.WEEK.ms());
|
long newPerDayWeek = AnalysisUtils.getNewUsersPerDay(registered, TimeAmount.WEEK.ms());
|
||||||
long newPerDayMonth = AnalysisUtils.getNewUsersPerDay(registered, TimeAmount.MONTH.ms());
|
long newPerDayMonth = AnalysisUtils.getNewUsersPerDay(registered, TimeAmount.MONTH.ms());
|
||||||
|
|
||||||
addValue("newperday", newPerDay);
|
addValue("playersNewAverage", newPerDay);
|
||||||
addValue("newperdayday", newPerDayDay);
|
addValue("playersNewAverageDay", newPerDayDay);
|
||||||
addValue("newperdayweek", newPerDayWeek);
|
addValue("playersNewAverageWeek", newPerDayWeek);
|
||||||
addValue("newperdaymonth", newPerDayMonth);
|
addValue("playersNewAverageMonth", newPerDayMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToLoginTimes() {
|
public void addToLoginTimes() {
|
||||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.data.analysis;
|
|||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.data.KillData;
|
import main.java.com.djrapitops.plan.data.KillData;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -13,24 +12,23 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for all Death related analysis.
|
* Part responsible for all Death related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Totals
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: deaths, mobkills, playerkills, avgdeaths, avgmobkills, avgplayerkills
|
* Contains following placeholders after analyzed:
|
||||||
|
* ${killCount} - (Number)
|
||||||
|
* ${mobKillCount} - (Number)
|
||||||
|
* ${deathCount} - (Number)
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
*/
|
*/
|
||||||
public class KillPart extends RawData {
|
public class KillPart extends RawData {
|
||||||
|
|
||||||
private final PlayerCountPart playerCountPart;
|
|
||||||
private final Map<UUID, List<KillData>> playerKills;
|
private final Map<UUID, List<KillData>> playerKills;
|
||||||
private long mobKills;
|
private long mobKills;
|
||||||
private long deaths;
|
private long deaths;
|
||||||
|
|
||||||
public KillPart(PlayerCountPart playerCountPart) {
|
public KillPart() {
|
||||||
this.playerCountPart = playerCountPart;
|
|
||||||
playerKills = new HashMap<>();
|
playerKills = new HashMap<>();
|
||||||
mobKills = 0;
|
mobKills = 0;
|
||||||
deaths = 0;
|
deaths = 0;
|
||||||
@ -38,14 +36,10 @@ public class KillPart extends RawData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyse() {
|
public void analyse() {
|
||||||
addValue("deaths", deaths);
|
addValue("deathCount", deaths);
|
||||||
addValue("mobkills", mobKills);
|
addValue("mobKillCount", mobKills);
|
||||||
int playerKillAmount = getAllPlayerKills().size();
|
int playerKillAmount = getAllPlayerKills().size();
|
||||||
addValue("playerkills", playerKillAmount);
|
addValue("killCount", playerKillAmount);
|
||||||
int playerCount = playerCountPart.getPlayerCount();
|
|
||||||
addValue("avgdeaths", MathUtils.averageLong(deaths, playerCount));
|
|
||||||
addValue("avgmobkills", MathUtils.averageLong(mobKills, playerCount));
|
|
||||||
addValue("avgplayerkills", MathUtils.averageLong(playerKillAmount, playerCount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,11 +10,11 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for counting players.
|
* Part responsible for counting players.
|
||||||
* <p>
|
* <p>
|
||||||
* Total player count, op count
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: activitytotal, ops
|
* Contains following placeholders after analyzed:
|
||||||
|
* ${playersTotal}
|
||||||
|
* //TODO ${playersOnline}, ${playersMax}
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
@ -31,8 +31,7 @@ public class PlayerCountPart extends RawData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyse() {
|
public void analyse() {
|
||||||
addValue("activitytotal", uuids.size());
|
addValue("playersTotal", uuids.size());
|
||||||
addValue("ops", ops.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(UUID uuid) {
|
public void addPlayer(UUID uuid) {
|
||||||
|
@ -1,33 +1,29 @@
|
|||||||
package main.java.com.djrapitops.plan.data.analysis;
|
package main.java.com.djrapitops.plan.data.analysis;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part responsible for all Playtime related analysis.
|
* Part responsible for all Playtime related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: totalplaytime, avgplaytime
|
* Contains following placeholders after analyzed:
|
||||||
|
* ${playtimeTotal} - Formatted time amount
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
*/
|
*/
|
||||||
public class PlaytimePart extends RawData {
|
public class PlaytimePart extends RawData {
|
||||||
|
|
||||||
private final PlayerCountPart playerCount;
|
|
||||||
private long totalPlaytime;
|
private long totalPlaytime;
|
||||||
|
|
||||||
public PlaytimePart(PlayerCountPart part) {
|
public PlaytimePart() {
|
||||||
playerCount = part;
|
|
||||||
totalPlaytime = 0;
|
totalPlaytime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analyse() {
|
public void analyse() {
|
||||||
addValue("totalplaytime", FormatUtils.formatTimeAmount(totalPlaytime));
|
addValue("playtimeTotal", FormatUtils.formatTimeAmount(totalPlaytime));
|
||||||
final long averagePlaytime = MathUtils.averageLong(totalPlaytime, playerCount.getPlayerCount());
|
|
||||||
addValue("avgplaytime", FormatUtils.formatTimeAmount(averagePlaytime));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToPlaytime(long amount) {
|
public void addToPlaytime(long amount) {
|
||||||
|
@ -87,7 +87,7 @@ public abstract class RawData {
|
|||||||
/**
|
/**
|
||||||
* Used to get the value for a placeholder without the placeholder prefix and suffix.
|
* Used to get the value for a placeholder without the placeholder prefix and suffix.
|
||||||
*
|
*
|
||||||
* @param key placeholder without the prefix and suffix
|
* @param key placeholder name without ${ and }
|
||||||
* @return Value the placeholder should be replaced with or null.
|
* @return Value the placeholder should be replaced with or null.
|
||||||
*/
|
*/
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
|
@ -7,6 +7,7 @@ import main.java.com.djrapitops.plan.ui.html.graphs.CPUGraphCreator;
|
|||||||
import main.java.com.djrapitops.plan.ui.html.graphs.RamGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.RamGraphCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.TPSGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.TPSGraphCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.WorldLoadGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.WorldLoadGraphCreator;
|
||||||
|
import main.java.com.djrapitops.plan.ui.theme.Colors;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||||
@ -16,13 +17,31 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Part responsible for all TPS related analysis.
|
* Part responsible for all TPS related analysis.
|
||||||
* <p>
|
* <p>
|
||||||
* Ticks Per Second Graphs
|
|
||||||
* <p>
|
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: tpsscatterday, tpsscatterweek, cpuscatterday, cpuscatterweek, averagetps(-week),
|
* Contains following placeholders after being analyzed:
|
||||||
* averagetpsday, averagecpuday, averagecpuweek, averagememoryday, averagememoryweek, averageentitiesday, averageentitiesweek,
|
* ${tpsSeries} - HighCharts data
|
||||||
* averagechunksday, averagechunkweek, ramscatterday, ramscatterweek
|
* ${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
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
@ -41,17 +60,17 @@ public class TPSPart extends RawData {
|
|||||||
List<TPS> week = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.WEEK.ms());
|
List<TPS> week = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.WEEK.ms());
|
||||||
List<TPS> day = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.DAY.ms());
|
List<TPS> day = TPSGraphCreator.filterTPS(tpsData, now - TimeAmount.DAY.ms());
|
||||||
|
|
||||||
addValue("tpshighcol", "#"+ Settings.HCOLOR_TPS_HIGH);
|
addValue("tpsHighColor", Colors.TPS_HIGH.getColor());
|
||||||
addValue("tpsmediumcol", "#"+ Settings.HCOLOR_TPS_MED);
|
addValue("tpsMediumColor", Colors.TPS_MED.getColor());
|
||||||
addValue("tpslowcol", "#"+ Settings.HCOLOR_TPS_LOW);
|
addValue("tpsLowColor", Colors.TPS_LOW.getColor());
|
||||||
addValue("tpsmedium", Settings.TPS_GRAPH_MED.getNumber());
|
addValue("tpsMedium", Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber());
|
||||||
addValue("tpshigh", Settings.TPS_GRAPH_HIGH.getNumber());
|
addValue("tpsHigh", Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH.getNumber());
|
||||||
|
|
||||||
addValue("tpsseries", TPSGraphCreator.buildSeriesDataString(tpsData));
|
addValue("tpsSeries", TPSGraphCreator.buildSeriesDataString(tpsData));
|
||||||
addValue("cpuseries", CPUGraphCreator.buildSeriesDataString(tpsData));
|
addValue("cpuSeries", CPUGraphCreator.buildSeriesDataString(tpsData));
|
||||||
addValue("ramseries", RamGraphCreator.buildSeriesDataString(tpsData));
|
addValue("ramSeries", RamGraphCreator.buildSeriesDataString(tpsData));
|
||||||
addValue("entityseries", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsData));
|
addValue("entitySeries", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsData));
|
||||||
addValue("chunkseries", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsData));
|
addValue("chunkSeries", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsData));
|
||||||
|
|
||||||
double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTicksPerSecond));
|
double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTicksPerSecond));
|
||||||
double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTicksPerSecond));
|
double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTicksPerSecond));
|
||||||
@ -68,21 +87,20 @@ public class TPSPart extends RawData {
|
|||||||
double averageChunksLoadedWeek = MathUtils.averageInt(week.stream().map(TPS::getChunksLoaded).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));
|
double averageChunksLoadedDay = MathUtils.averageInt(day.stream().map(TPS::getChunksLoaded).filter(i -> i != 0));
|
||||||
|
|
||||||
addValue("averagetps", FormatUtils.cutDecimals(averageTPSWeek)); //Staying for backwards compatibility
|
addValue("tpsAverageWeek", FormatUtils.cutDecimals(averageTPSWeek));
|
||||||
addValue("averagetpsweek", FormatUtils.cutDecimals(averageTPSWeek));
|
addValue("tpsAverageDay", FormatUtils.cutDecimals(averageTPSDay));
|
||||||
addValue("averagetpsday", FormatUtils.cutDecimals(averageTPSDay));
|
|
||||||
|
|
||||||
addValue("averagecpuweek", averageCPUWeek >= 0 ? FormatUtils.cutDecimals(averageCPUWeek) + "%" : "Unavailable");
|
addValue("cpuAverageWeek", averageCPUWeek >= 0 ? FormatUtils.cutDecimals(averageCPUWeek) + "%" : "Unavailable");
|
||||||
addValue("averagecpuday", averageCPUDay >= 0 ? FormatUtils.cutDecimals(averageCPUDay) + "%" : "Unavailable");
|
addValue("cpuAverageDay", averageCPUDay >= 0 ? FormatUtils.cutDecimals(averageCPUDay) + "%" : "Unavailable");
|
||||||
|
|
||||||
addValue("averagememoryweek", FormatUtils.cutDecimals(averageUsedMemoryWeek));
|
addValue("ramAverageWeek", FormatUtils.cutDecimals(averageUsedMemoryWeek));
|
||||||
addValue("averagememoryday", FormatUtils.cutDecimals(averageUsedMemoryDay));
|
addValue("ramAverageDay", FormatUtils.cutDecimals(averageUsedMemoryDay));
|
||||||
|
|
||||||
addValue("averageentitiesweek", FormatUtils.cutDecimals(averageEntityCountWeek));
|
addValue("entityAverageWeek", FormatUtils.cutDecimals(averageEntityCountWeek));
|
||||||
addValue("averageentitiesday", FormatUtils.cutDecimals(averageEntityCountDay));
|
addValue("entityAverageDay", FormatUtils.cutDecimals(averageEntityCountDay));
|
||||||
|
|
||||||
addValue("averagechunksweek", FormatUtils.cutDecimals(averageChunksLoadedWeek));
|
addValue("chunkAverageWeek", FormatUtils.cutDecimals(averageChunksLoadedWeek));
|
||||||
addValue("averagechunksday", FormatUtils.cutDecimals(averageChunksLoadedDay));
|
addValue("chunkAverageDay", FormatUtils.cutDecimals(averageChunksLoadedDay));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TPS> getTpsData() {
|
public List<TPS> getTpsData() {
|
||||||
|
@ -14,7 +14,9 @@ import java.util.Map;
|
|||||||
* <p>
|
* <p>
|
||||||
* Placeholder values can be retrieved using the get method.
|
* Placeholder values can be retrieved using the get method.
|
||||||
* <p>
|
* <p>
|
||||||
* Contains following place-holders: worldtotal, worldseries
|
* Contains following placeholders after analyzed:
|
||||||
|
* ${worldTotal} - Total playtime for all worlds
|
||||||
|
* ${worldSeries} - Data for HighCharts
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.6.0
|
* @since 3.6.0
|
||||||
@ -30,8 +32,8 @@ public class WorldPart extends RawData {
|
|||||||
@Override
|
@Override
|
||||||
protected void analyse() {
|
protected void analyse() {
|
||||||
WorldTimes t = new WorldTimes(worldTimes);
|
WorldTimes t = new WorldTimes(worldTimes);
|
||||||
addValue("worldtotal", FormatUtils.formatTimeAmount(t.getTotal()));
|
addValue("worldTotal", FormatUtils.formatTimeAmount(t.getTotal()));
|
||||||
addValue("worldseries", WorldPieCreator.createSeriesData(worldTimes));
|
addValue("worldSeries", WorldPieCreator.createSeriesData(worldTimes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToWorld(String worldName, long playTime) {
|
public void addToWorld(String worldName, long playTime) {
|
||||||
|
@ -4,11 +4,9 @@ import com.djrapitops.plugin.command.CommandUtils;
|
|||||||
import com.djrapitops.plugin.command.ISender;
|
import com.djrapitops.plugin.command.ISender;
|
||||||
import com.djrapitops.plugin.utilities.player.IPlayer;
|
import com.djrapitops.plugin.utilities.player.IPlayer;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||||
import main.java.com.djrapitops.plan.locale.Locale;
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
import main.java.com.djrapitops.plan.locale.Msg;
|
import main.java.com.djrapitops.plan.locale.Msg;
|
||||||
import main.java.com.djrapitops.plan.ui.text.TextUI;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -71,22 +69,19 @@ public class AnalysisCacheHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendAnalysisMessage(ISender sender) {
|
public void sendAnalysisMessage(ISender sender) {
|
||||||
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
|
||||||
sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString());
|
sender.sendMessage(Locale.get(Msg.CMD_HEADER_ANALYZE).toString());
|
||||||
if (textUI) {
|
|
||||||
sender.sendMessage(TextUI.getAnalysisMessages());
|
// Link
|
||||||
|
String url = HtmlUtils.getServerAnalysisUrlWithProtocol();
|
||||||
|
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
||||||
|
boolean console = !CommandUtils.isPlayer(sender);
|
||||||
|
if (console) {
|
||||||
|
sender.sendMessage(message + url);
|
||||||
} else {
|
} else {
|
||||||
// Link
|
sender.sendMessage(message);
|
||||||
String url = HtmlUtils.getServerAnalysisUrlWithProtocol();
|
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
||||||
String message = Locale.get(Msg.CMD_INFO_LINK).toString();
|
|
||||||
boolean console = !CommandUtils.isPlayer(sender);
|
|
||||||
if (console) {
|
|
||||||
sender.sendMessage(message + url);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(message);
|
|
||||||
sender.sendLink(" ", Locale.get(Msg.CMD_INFO_CLICK_ME).toString(), url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import com.djrapitops.plugin.task.AbsRunnable;
|
|||||||
import com.djrapitops.plugin.utilities.player.IPlayer;
|
import com.djrapitops.plugin.utilities.player.IPlayer;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.TPS;
|
import main.java.com.djrapitops.plan.data.TPS;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||||
@ -123,17 +122,6 @@ public class DataCacheHandler extends SessionCache {
|
|||||||
* @throws IllegalStateException BukkitScheduler is in a wrong state.
|
* @throws IllegalStateException BukkitScheduler is in a wrong state.
|
||||||
*/
|
*/
|
||||||
public void startAsyncPeriodicSaveTask() {
|
public void startAsyncPeriodicSaveTask() {
|
||||||
int minutes = Settings.SAVE_CACHE_MIN.getNumber();
|
|
||||||
if (minutes <= 0) {
|
|
||||||
minutes = 5;
|
|
||||||
}
|
|
||||||
final int clearAfterXsaves;
|
|
||||||
int configValue = Settings.CLEAR_CACHE_X_SAVES.getNumber();
|
|
||||||
if (configValue <= 1) {
|
|
||||||
clearAfterXsaves = 2;
|
|
||||||
} else {
|
|
||||||
clearAfterXsaves = configValue;
|
|
||||||
}
|
|
||||||
DataCacheHandler handler = this;
|
DataCacheHandler handler = this;
|
||||||
plugin.getRunnableFactory().createNew(new AbsRunnable("PeriodicCacheSaveTask") {
|
plugin.getRunnableFactory().createNew(new AbsRunnable("PeriodicCacheSaveTask") {
|
||||||
private int timesSaved = 0;
|
private int timesSaved = 0;
|
||||||
@ -148,9 +136,6 @@ public class DataCacheHandler extends SessionCache {
|
|||||||
Log.debug("Database", "Periodic Cache Save: " + dataCache.size());
|
Log.debug("Database", "Periodic Cache Save: " + dataCache.size());
|
||||||
handler.saveHandlerDataToCache();
|
handler.saveHandlerDataToCache();
|
||||||
handler.saveCachedUserData();
|
handler.saveCachedUserData();
|
||||||
if (timesSaved % clearAfterXsaves == 0) {
|
|
||||||
handler.clearCache();
|
|
||||||
}
|
|
||||||
saveCommandUse();
|
saveCommandUse();
|
||||||
saveUnsavedTPSHistory();
|
saveUnsavedTPSHistory();
|
||||||
timesSaved++;
|
timesSaved++;
|
||||||
@ -160,7 +145,7 @@ public class DataCacheHandler extends SessionCache {
|
|||||||
periodicTaskIsSaving = false;
|
periodicTaskIsSaving = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimerAsynchronously(60L * 20L * minutes, 60L * 20L * minutes);
|
}).runTaskTimerAsynchronously(60L * 20L * 5, 60L * 20L * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,11 +20,7 @@ public class PlaytimeHandling {
|
|||||||
data.setLastPlayed(time);
|
data.setLastPlayed(time);
|
||||||
|
|
||||||
GMTimes gmTimes = data.getGmTimes();
|
GMTimes gmTimes = data.getGmTimes();
|
||||||
if (gamemode != null) {
|
gmTimes.changeState(gamemode != null ? gamemode : gmTimes.getState(), playTime);
|
||||||
gmTimes.changeState(gamemode, playTime);
|
|
||||||
} else {
|
|
||||||
gmTimes.changeState(gmTimes.getState(), playTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldTimes worldTimes = data.getWorldTimes();
|
WorldTimes worldTimes = data.getWorldTimes();
|
||||||
worldTimes.changeState(worldName, playTime);
|
worldTimes.changeState(worldName, playTime);
|
||||||
|
@ -12,18 +12,16 @@ import java.util.UUID;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ServerInfo {
|
public class ServerInfo {
|
||||||
private final int id;
|
private int id;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private String name;
|
private String name;
|
||||||
private String webAddress;
|
private String webAddress;
|
||||||
private int port;
|
|
||||||
|
|
||||||
public ServerInfo(int id, UUID uuid, String name, String webAddress, int port) {
|
public ServerInfo(int id, UUID uuid, String name, String webAddress) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.webAddress = webAddress;
|
this.webAddress = webAddress;
|
||||||
this.port = port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@ -42,10 +40,6 @@ public class ServerInfo {
|
|||||||
return webAddress;
|
return webAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
@ -54,7 +48,7 @@ public class ServerInfo {
|
|||||||
this.webAddress = webAddress;
|
this.webAddress = webAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPort(int port) {
|
public void setId(int id) {
|
||||||
this.port = port;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,14 +5,17 @@
|
|||||||
package main.java.com.djrapitops.plan.data.server;
|
package main.java.com.djrapitops.plan.data.server;
|
||||||
|
|
||||||
import com.djrapitops.plugin.config.BukkitConfig;
|
import com.djrapitops.plugin.config.BukkitConfig;
|
||||||
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.FileConfigurationOptions;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,52 +28,48 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class ServerInfoFile extends BukkitConfig<Plan> {
|
public class ServerInfoFile extends BukkitConfig<Plan> {
|
||||||
public ServerInfoFile(Plan plugin) throws IOException, InvalidConfigurationException {
|
public ServerInfoFile(Plan plugin) throws IOException, InvalidConfigurationException {
|
||||||
super(plugin, "ServerInfo");
|
super(plugin, "ServerInfoFile");
|
||||||
FileConfiguration config = getConfig();
|
FileConfiguration config = getConfig();
|
||||||
config.options().copyDefaults(true);
|
FileConfigurationOptions options = config.options();
|
||||||
config.addDefault("Server.ID", "-1");
|
options.copyDefaults(true);
|
||||||
|
options.header("IMPORTANT: Do not edit this file unless you want to lose your data!");
|
||||||
config.addDefault("Server.UUID", "");
|
config.addDefault("Server.UUID", "");
|
||||||
config.addDefault("Bungee.WebAddress", "");
|
config.addDefault("Bungee.WebAddress", "");
|
||||||
config.addDefault("Bungee.Port", -1);
|
|
||||||
config.addDefault("Bungee.Fail", 0);
|
config.addDefault("Bungee.Fail", 0);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException {
|
public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException {
|
||||||
|
FileConfiguration config = getConfig();
|
||||||
Map<String, Serializable> serverMap = new HashMap<>();
|
Map<String, Serializable> serverMap = new HashMap<>();
|
||||||
Map<String, Serializable> bungeeMap = new HashMap<>();
|
Map<String, Serializable> bungeeMap = new HashMap<>();
|
||||||
|
|
||||||
serverMap.put("ID", thisServer.getId());
|
|
||||||
serverMap.put("UUID", thisServer.getUuid().toString());
|
serverMap.put("UUID", thisServer.getUuid().toString());
|
||||||
|
config.set("Server", serverMap);
|
||||||
|
|
||||||
bungeeMap.put("WebAddress", bungee.getWebAddress());
|
String oldAddress = config.getString("Bungee.WebAddress");
|
||||||
bungeeMap.put("Port", bungee.getPort());
|
String newAddress = bungee.getWebAddress();
|
||||||
|
|
||||||
getConfig().set("Server", serverMap);
|
if (!newAddress.equals(oldAddress)) {
|
||||||
getConfig().set("Bungee", bungeeMap);
|
bungeeMap.put("Fail", 0);
|
||||||
|
bungeeMap.put("WebAddress", newAddress);
|
||||||
|
config.set("Bungee", bungeeMap);
|
||||||
|
}
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getID() {
|
public Optional<UUID> getUUID() {
|
||||||
return getConfig().getInt("Server.ID");
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUUID() {
|
|
||||||
String uuidString = getConfig().getString("Server.UUID");
|
String uuidString = getConfig().getString("Server.UUID");
|
||||||
if (uuidString == null) {
|
if (Verify.isEmpty(uuidString)) {
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return UUID.fromString(uuidString);
|
return Optional.of(UUID.fromString(uuidString));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBungeeWebAddress() {
|
public String getBungeeWebAddress() {
|
||||||
return getConfig().getString("Bungee.WebAddress");
|
return getConfig().getString("Bungee.WebAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBungeePort() {
|
|
||||||
return getConfig().getInt("Bungee.Port");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markConnectionFail() throws IOException {
|
public void markConnectionFail() throws IOException {
|
||||||
FileConfiguration config = getConfig();
|
FileConfiguration config = getConfig();
|
||||||
int fails = config.getInt("Bungee.Fail");
|
int fails = config.getInt("Bungee.Fail");
|
||||||
|
@ -10,30 +10,33 @@ import main.java.com.djrapitops.plan.Plan;
|
|||||||
import main.java.com.djrapitops.plan.Settings;
|
import main.java.com.djrapitops.plan.Settings;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.database.tables.ServerTable;
|
import main.java.com.djrapitops.plan.database.tables.ServerTable;
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //TODO Class Javadoc Comment
|
* Manages the Server information required for Bungee-Bukkit WebAPI connection.
|
||||||
|
* <p>
|
||||||
|
* Also manages Server ID required for MySQL database independence.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ServerInfoManager {
|
public class ServerInfoManager {
|
||||||
|
|
||||||
|
private Plan plugin;
|
||||||
private ServerInfo serverInfo;
|
private ServerInfo serverInfo;
|
||||||
private ServerInfoFile serverInfoFile;
|
private ServerInfoFile serverInfoFile;
|
||||||
private ServerTable serverTable;
|
private ServerTable serverTable;
|
||||||
|
|
||||||
public ServerInfoManager(Plan plugin) {
|
public ServerInfoManager(Plan plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
Database db = plugin.getDB();
|
Database db = plugin.getDB();
|
||||||
if ("sqlite".equals(db.getConfigName())) {
|
serverTable = db.getServerTable();
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
serverInfoFile = new ServerInfoFile(plugin);
|
serverInfoFile = new ServerInfoFile(plugin);
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
@ -42,30 +45,84 @@ public class ServerInfoManager {
|
|||||||
plugin.disablePlugin();
|
plugin.disablePlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
serverTable = db.getServerTable();
|
Optional<UUID> serverUUID = serverInfoFile.getUUID();
|
||||||
|
|
||||||
int serverID = serverInfoFile.getID();
|
|
||||||
if (serverID == -1) {
|
|
||||||
registerServer(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerServer(Plan plugin) {
|
|
||||||
UUID serverUUID = generateNewUUID(plugin.getServer());
|
|
||||||
// TODO Clean Up HtmlUtils so this method can make sense
|
|
||||||
String[] address = (HtmlUtils.getProtocol() + "/" + HtmlUtils.getIP()).split(":");
|
|
||||||
String webAddress = address[0];
|
|
||||||
int port = Integer.parseInt(address[1]);
|
|
||||||
String name = Settings.SERVER_NAME.toString();
|
|
||||||
try {
|
try {
|
||||||
serverTable.saveCurrentServerInfo(new ServerInfo(-1, serverUUID, name, webAddress, port));
|
if (serverUUID.isPresent()) {
|
||||||
} catch (SQLException e) {
|
updateDbInfo(serverUUID.get());
|
||||||
|
} else {
|
||||||
|
registerServer();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
Log.error("Failed to register server info to database, disabling plugin.");
|
||||||
|
plugin.disablePlugin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID generateNewUUID(Server server) {
|
private void updateDbInfo(UUID serverUUID) throws SQLException {
|
||||||
|
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
|
||||||
|
if (!serverID.isPresent()) {
|
||||||
|
registerServer(serverUUID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String name = Settings.SERVER_NAME.toString();
|
||||||
|
String webAddress = plugin.getUiServer().getAccessAddress();
|
||||||
|
if ("plan".equalsIgnoreCase(name)) {
|
||||||
|
name = "Server" + serverID.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
serverInfo = new ServerInfo(serverID.get(), serverUUID, name, webAddress);
|
||||||
|
serverTable.saveCurrentServerInfo(serverInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerServer() throws SQLException {
|
||||||
|
registerServer(generateNewUUID(plugin.getServer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerServer(UUID serverUUID) throws SQLException {
|
||||||
|
String webAddress = plugin.getUiServer().getAccessAddress();
|
||||||
|
String name = Settings.SERVER_NAME.toString();
|
||||||
|
serverInfo = new ServerInfo(-1, serverUUID, name, webAddress);
|
||||||
|
serverTable.saveCurrentServerInfo(serverInfo);
|
||||||
|
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
|
||||||
|
if (serverID.isPresent()) {
|
||||||
|
serverInfo.setId(serverID.get());
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Failed to Register Server (ID not found)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private UUID generateNewUUID(Server server) {
|
||||||
String seed = server.getName() + server.getIp() + server.getPort() + server.getVersion() + server.getBukkitVersion();
|
String seed = server.getName() + server.getIp() + server.getPort() + server.getVersion() + server.getBukkitVersion();
|
||||||
return UUID.nameUUIDFromBytes(seed.getBytes());
|
return UUID.nameUUIDFromBytes(seed.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<String> getBungeeConnectionAddress() {
|
||||||
|
try {
|
||||||
|
String bungeeWebAddress = serverInfoFile.getBungeeWebAddress();
|
||||||
|
if (!bungeeWebAddress.isEmpty()) {
|
||||||
|
return Optional.of(bungeeWebAddress);
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
/* Ignored */
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveBungeeConnectionAddress(String address) throws IOException {
|
||||||
|
serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, "Bungee", address));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServerID() {
|
||||||
|
return serverInfo.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getServerUUID() {
|
||||||
|
return serverInfo.getUuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerName() {
|
||||||
|
return serverInfo.getName();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package main.java.com.djrapitops.plan.data.time;
|
package main.java.com.djrapitops.plan.data.time;
|
||||||
|
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.database.tables.GMTimesTable;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -13,6 +12,12 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class GMTimes extends TimeKeeper {
|
public class GMTimes extends TimeKeeper {
|
||||||
|
|
||||||
|
// TODO Make private once GMTimesTable is removed
|
||||||
|
public static final String SURVIVAL = "SURVIVAL";
|
||||||
|
public static final String CREATIVE = "CREATIVE";
|
||||||
|
public static final String ADVENTURE = "ADVENTURE";
|
||||||
|
public static final String SPECTATOR = "SPECTATOR";
|
||||||
|
|
||||||
public GMTimes(Map<String, Long> times, String lastState, long lastStateChange) {
|
public GMTimes(Map<String, Long> times, String lastState, long lastStateChange) {
|
||||||
super(times, lastState, lastStateChange);
|
super(times, lastState, lastStateChange);
|
||||||
}
|
}
|
||||||
@ -33,6 +38,10 @@ public class GMTimes extends TimeKeeper {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] getGMKeyArray() {
|
||||||
|
return new String[]{SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets times for all 4 gamemodes.
|
* Sets times for all 4 gamemodes.
|
||||||
* <p>
|
* <p>
|
||||||
@ -47,7 +56,7 @@ public class GMTimes extends TimeKeeper {
|
|||||||
*/
|
*/
|
||||||
public void setAllGMTimes(long... times) {
|
public void setAllGMTimes(long... times) {
|
||||||
Verify.nullCheck(times);
|
Verify.nullCheck(times);
|
||||||
String[] gms = GMTimesTable.getGMKeyArray();
|
String[] gms = getGMKeyArray();
|
||||||
int size = times.length;
|
int size = times.length;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (i >= size) {
|
if (i >= size) {
|
||||||
@ -59,15 +68,15 @@ public class GMTimes extends TimeKeeper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetTimes(long playtime) {
|
public void resetTimes(long playtime) {
|
||||||
resetState("SURVIVAL", playtime);
|
resetState(SURVIVAL, playtime);
|
||||||
resetState("CREATIVE");
|
resetState(CREATIVE);
|
||||||
resetState("ADVENTURE");
|
resetState(ADVENTURE);
|
||||||
resetState("SPECTATOR");
|
resetState(SPECTATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getState() {
|
public String getState() {
|
||||||
String state = super.getState();
|
String state = super.getState();
|
||||||
return state != null ? state : "SURVIVAL";
|
return state != null ? state : SURVIVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,6 +56,7 @@ public abstract class SQLDB extends Database {
|
|||||||
securityTable = new SecurityTable(this, usingMySQL);
|
securityTable = new SecurityTable(this, usingMySQL);
|
||||||
worldTable = new WorldTable(this, usingMySQL);
|
worldTable = new WorldTable(this, usingMySQL);
|
||||||
worldTimesTable = new WorldTimesTable(this, usingMySQL);
|
worldTimesTable = new WorldTimesTable(this, usingMySQL);
|
||||||
|
serverTable = new ServerTable(this, usingMySQL);
|
||||||
|
|
||||||
startConnectionPingTask();
|
startConnectionPingTask();
|
||||||
}
|
}
|
||||||
|
@ -20,28 +20,29 @@ public abstract class WhereParser extends SqlParser {
|
|||||||
private int conditions = 0;
|
private int conditions = 0;
|
||||||
|
|
||||||
public WhereParser where(String... conditions) {
|
public WhereParser where(String... conditions) {
|
||||||
return and(conditions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WhereParser and(String... conditions) {
|
|
||||||
return whereOperator("AND", conditions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public WhereParser or(String... conditions) {
|
|
||||||
return whereOperator("OR", conditions);
|
|
||||||
}
|
|
||||||
|
|
||||||
private WhereParser whereOperator(String operator, String... conditions) {
|
|
||||||
append(" WHERE ");
|
append(" WHERE ");
|
||||||
for (String condition : conditions) {
|
for (String condition : conditions) {
|
||||||
if (this.conditions > 0) {
|
if (this.conditions > 0) {
|
||||||
addSpace().append(operator).addSpace();
|
append(" AND ");
|
||||||
}
|
}
|
||||||
|
|
||||||
append("(").append(condition).append(")");
|
append("(").append(condition).append(")");
|
||||||
this.conditions++;
|
this.conditions++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WhereParser and(String condition) {
|
||||||
|
append(" AND ");
|
||||||
|
append("(").append(condition).append(")");
|
||||||
|
this.conditions++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WhereParser or(String condition) {
|
||||||
|
append(" OR ");
|
||||||
|
append("(").append(condition).append(")");
|
||||||
|
this.conditions++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,6 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
private final String columnAdventureTime;
|
private final String columnAdventureTime;
|
||||||
private final String columnSpectatorTime;
|
private final String columnSpectatorTime;
|
||||||
|
|
||||||
private static final String SURVIVAL = "SURVIVAL";
|
|
||||||
private static final String CREATIVE = "CREATIVE";
|
|
||||||
private static final String ADVENTURE = "ADVENTURE";
|
|
||||||
private static final String SPECTATOR = "SPECTATOR";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param db
|
* @param db
|
||||||
@ -45,10 +40,6 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
columnSpectatorTime = "SPECTATOR";
|
columnSpectatorTime = "SPECTATOR";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getGMKeyArray() {
|
|
||||||
return new String[]{SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -95,10 +86,10 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
HashMap<String, Long> times = new HashMap<>();
|
HashMap<String, Long> times = new HashMap<>();
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
times.put(SURVIVAL, set.getLong(columnSurvivalTime));
|
times.put(GMTimes.SURVIVAL, set.getLong(columnSurvivalTime));
|
||||||
times.put(CREATIVE, set.getLong(columnCreativeTime));
|
times.put(GMTimes.CREATIVE, set.getLong(columnCreativeTime));
|
||||||
times.put(ADVENTURE, set.getLong(columnAdventureTime));
|
times.put(GMTimes.ADVENTURE, set.getLong(columnAdventureTime));
|
||||||
times.put(SPECTATOR, set.getLong(columnSpectatorTime));
|
times.put(GMTimes.SPECTATOR, set.getLong(columnSpectatorTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
return times;
|
return times;
|
||||||
@ -123,10 +114,10 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmTimes.put(SURVIVAL, set.getLong(columnSurvivalTime));
|
gmTimes.put(GMTimes.SURVIVAL, set.getLong(columnSurvivalTime));
|
||||||
gmTimes.put(CREATIVE, set.getLong(columnCreativeTime));
|
gmTimes.put(GMTimes.CREATIVE, set.getLong(columnCreativeTime));
|
||||||
gmTimes.put(ADVENTURE, set.getLong(columnAdventureTime));
|
gmTimes.put(GMTimes.ADVENTURE, set.getLong(columnAdventureTime));
|
||||||
gmTimes.put(SPECTATOR, set.getLong(columnSpectatorTime));
|
gmTimes.put(GMTimes.SPECTATOR, set.getLong(columnSpectatorTime));
|
||||||
times.put(id, gmTimes);
|
times.put(id, gmTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +139,7 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
String[] gms = getGMKeyArray();
|
String[] gms = GMTimes.getGMKeyArray();
|
||||||
|
|
||||||
int update;
|
int update;
|
||||||
try {
|
try {
|
||||||
@ -233,7 +224,7 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] gms = getGMKeyArray();
|
String[] gms = GMTimes.getGMKeyArray();
|
||||||
Set<Integer> savedIDs = getSavedIDs();
|
Set<Integer> savedIDs = getSavedIDs();
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -300,7 +291,7 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] gms = getGMKeyArray();
|
String[] gms = GMTimes.getGMKeyArray();
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -338,7 +329,7 @@ public class GMTimesTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
String[] gms = getGMKeyArray();
|
String[] gms = GMTimes.getGMKeyArray();
|
||||||
try {
|
try {
|
||||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||||
+ columnUserID + ", "
|
+ columnUserID + ", "
|
||||||
|
@ -4,18 +4,24 @@
|
|||||||
*/
|
*/
|
||||||
package main.java.com.djrapitops.plan.database.tables;
|
package main.java.com.djrapitops.plan.database.tables;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.data.server.ServerInfo;
|
import main.java.com.djrapitops.plan.data.server.ServerInfo;
|
||||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||||
import main.java.com.djrapitops.plan.database.sql.Insert;
|
import main.java.com.djrapitops.plan.database.sql.*;
|
||||||
import main.java.com.djrapitops.plan.database.sql.Sql;
|
|
||||||
import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //TODO Class Javadoc Comment
|
* Table representing plan_servers in the database.
|
||||||
|
* <p>
|
||||||
|
* Used for managing multiple server's data in the database.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@ -25,15 +31,15 @@ public class ServerTable extends Table {
|
|||||||
private final String columnServerUUID;
|
private final String columnServerUUID;
|
||||||
private final String columnServerName;
|
private final String columnServerName;
|
||||||
private final String columnWebserverAddress;
|
private final String columnWebserverAddress;
|
||||||
private final String columnWebserverPort;
|
private final String columnInstalled;
|
||||||
|
|
||||||
public ServerTable(String name, SQLDB db, boolean usingMySQL) {
|
public ServerTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_servers", db, usingMySQL);
|
super("plan_servers", db, usingMySQL);
|
||||||
columnServerID = "id";
|
columnServerID = "id";
|
||||||
columnServerUUID = "uuid";
|
columnServerUUID = "uuid";
|
||||||
columnServerName = "name";
|
columnServerName = "name";
|
||||||
columnWebserverAddress = "web_address";
|
columnWebserverAddress = "web_address";
|
||||||
columnWebserverPort = "web_port";
|
columnInstalled = "is_installed";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +50,8 @@ public class ServerTable extends Table {
|
|||||||
.column(columnServerUUID, Sql.varchar(36)).notNull().unique()
|
.column(columnServerUUID, Sql.varchar(36)).notNull().unique()
|
||||||
.column(columnServerName, Sql.varchar(100))
|
.column(columnServerName, Sql.varchar(100))
|
||||||
.column(columnWebserverAddress, Sql.varchar(100))
|
.column(columnWebserverAddress, Sql.varchar(100))
|
||||||
.column(columnWebserverPort, Sql.INT)
|
.column(columnInstalled, Sql.BOOL).notNull().defaultValue(false)
|
||||||
|
.primaryKey(usingMySQL, columnServerID)
|
||||||
.toString());
|
.toString());
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@ -62,25 +69,161 @@ public class ServerTable extends Table {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateServerInfo(ServerInfo info) {
|
private void updateServerInfo(ServerInfo info) throws SQLException {
|
||||||
//TODO Continue here, create Update SqlParser.
|
PreparedStatement statement = null;
|
||||||
|
try {
|
||||||
|
statement = prepareStatement(Update.values(tableName,
|
||||||
|
columnServerUUID,
|
||||||
|
columnServerName,
|
||||||
|
columnWebserverAddress,
|
||||||
|
columnInstalled)
|
||||||
|
.where(columnServerID + "=?")
|
||||||
|
.toString()
|
||||||
|
);
|
||||||
|
statement.setString(1, info.getUuid().toString());
|
||||||
|
statement.setString(2, info.getName());
|
||||||
|
statement.setString(3, info.getWebAddress());
|
||||||
|
statement.setBoolean(4, true);
|
||||||
|
statement.setInt(5, info.getId());
|
||||||
|
statement.executeUpdate();
|
||||||
|
} finally {
|
||||||
|
close(statement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveNewServerInfo(ServerInfo info) throws SQLException {
|
/**
|
||||||
|
* Inserts new row for a server into the table.
|
||||||
|
*
|
||||||
|
* @param info Info to instert (All variables should be present.
|
||||||
|
* @throws IllegalStateException if one of the ServerInfo variables is null
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
private void saveNewServerInfo(ServerInfo info) throws SQLException {
|
||||||
|
UUID uuid = info.getUuid();
|
||||||
|
String name = info.getName();
|
||||||
|
String webAddress = info.getWebAddress();
|
||||||
|
Verify.nullCheck(uuid, name, webAddress);
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = prepareStatement(Insert.values(tableName,
|
statement = prepareStatement(Insert.values(tableName,
|
||||||
columnServerUUID,
|
columnServerUUID,
|
||||||
columnServerName,
|
columnServerName,
|
||||||
columnWebserverAddress,
|
columnWebserverAddress,
|
||||||
columnWebserverPort));
|
columnInstalled));
|
||||||
statement.setString(1, info.getUuid().toString());
|
|
||||||
statement.setString(2, info.getName());
|
statement.setString(1, uuid.toString());
|
||||||
statement.setString(3, info.getWebAddress());
|
statement.setString(2, name);
|
||||||
statement.setInt(4, info.getPort());
|
statement.setString(3, webAddress);
|
||||||
|
statement.setBoolean(4, true);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} finally {
|
} finally {
|
||||||
close(statement);
|
close(statement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns server ID for a matching UUID
|
||||||
|
*
|
||||||
|
* @param serverUUID UUID of the server.
|
||||||
|
* @return ID or or empty optional.
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public Optional<Integer> getServerID(UUID serverUUID) throws SQLException {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet set = null;
|
||||||
|
try {
|
||||||
|
statement = prepareStatement(Select.from(tableName,
|
||||||
|
columnServerID)
|
||||||
|
.where(columnServerUUID + "=?")
|
||||||
|
.toString());
|
||||||
|
statement.setString(1, serverUUID.toString());
|
||||||
|
set = statement.executeQuery();
|
||||||
|
if (set.next()) {
|
||||||
|
return Optional.of(set.getInt(columnServerID));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
close(set, statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns server Name for a matching UUID
|
||||||
|
*
|
||||||
|
* @param serverUUID UUID of the server.
|
||||||
|
* @return Name or empty optional.
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public Optional<String> getServerName(UUID serverUUID) throws SQLException {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet set = null;
|
||||||
|
try {
|
||||||
|
statement = prepareStatement(Select.from(tableName,
|
||||||
|
columnServerName)
|
||||||
|
.where(columnServerUUID + "=?")
|
||||||
|
.toString());
|
||||||
|
statement.setString(1, serverUUID.toString());
|
||||||
|
set = statement.executeQuery();
|
||||||
|
if (set.next()) {
|
||||||
|
return Optional.of(set.getString(columnServerName));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
close(set, statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get BungeeCord WebServer info if present.
|
||||||
|
*
|
||||||
|
* @return information about Bungee server.
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public Optional<ServerInfo> getBungeeInfo() throws SQLException {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet set = null;
|
||||||
|
try {
|
||||||
|
statement = prepareStatement(Select.from(tableName, "*")
|
||||||
|
.where(columnServerName + "=?")
|
||||||
|
.toString());
|
||||||
|
statement.setString(1, "BungeeCord");
|
||||||
|
set = statement.executeQuery();
|
||||||
|
if (set.next()) {
|
||||||
|
return Optional.of(new ServerInfo(
|
||||||
|
set.getInt(columnServerID),
|
||||||
|
UUID.fromString(set.getString(columnServerUUID)),
|
||||||
|
set.getString(columnServerName),
|
||||||
|
set.getString(columnWebserverAddress)));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
close(set, statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServerInfo> getBukkitServers() throws SQLException {
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet set = null;
|
||||||
|
try {
|
||||||
|
statement = prepareStatement(Select.from(tableName, "*")
|
||||||
|
.where(columnServerName + "!=?")
|
||||||
|
.toString());
|
||||||
|
statement.setString(1, "BungeeCord");
|
||||||
|
set = statement.executeQuery();
|
||||||
|
List<ServerInfo> servers = new ArrayList<>();
|
||||||
|
while (set.next()) {
|
||||||
|
servers.add(new ServerInfo(
|
||||||
|
set.getInt(columnServerID),
|
||||||
|
UUID.fromString(set.getString(columnServerUUID)),
|
||||||
|
set.getString(columnServerName),
|
||||||
|
set.getString(columnWebserverAddress)));
|
||||||
|
}
|
||||||
|
return servers;
|
||||||
|
} finally {
|
||||||
|
close(set, statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.queue;
|
|||||||
|
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.locale.Locale;
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
import main.java.com.djrapitops.plan.locale.Msg;
|
import main.java.com.djrapitops.plan.locale.Msg;
|
||||||
@ -55,7 +54,7 @@ public class DataCacheClearQueue extends Queue<UUID> {
|
|||||||
try {
|
try {
|
||||||
queue.addAll(uuids.stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
queue.addAll(uuids.stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Clear Queue", Settings.PROCESS_CLEAR_LIMIT.getNumber()));
|
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Clear Queue", 20000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.queue;
|
|||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
|
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.locale.Locale;
|
import main.java.com.djrapitops.plan.locale.Locale;
|
||||||
@ -46,7 +45,7 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
|
|||||||
map.put(uuid, Arrays.asList(processors));
|
map.put(uuid, Arrays.asList(processors));
|
||||||
queue.add(map);
|
queue.add(map);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Get Queue", Settings.PROCESS_GET_LIMIT.getNumber()));
|
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Get Queue", 20000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.queue;
|
|||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
@ -45,7 +44,7 @@ public class DataCacheSaveQueue extends Queue<UserData> {
|
|||||||
try {
|
try {
|
||||||
queue.add(data);
|
queue.add(data);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber()));
|
Log.error(Locale.get(Msg.RUN_WARN_QUEUE_SIZE).parse("Save Queue", 20000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@Deprecated // Not going to be used TODO REMOVE
|
||||||
public class SessionLengthDistributionGraphCreator {
|
public class SessionLengthDistributionGraphCreator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,10 +29,9 @@ public class CommandUseTableCreator {
|
|||||||
|
|
||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
if (sorted.isEmpty()) {
|
if (sorted.isEmpty()) {
|
||||||
html.append(Html.ERROR_TABLE_2.parse());
|
html.append(Html.TABLELINE_2.parse("No Commands", ""));
|
||||||
} else {
|
} else {
|
||||||
Collections.reverse(sorted);
|
Collections.reverse(sorted);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String[] values : sorted) {
|
for (String[] values : sorted) {
|
||||||
if (i >= 500) {
|
if (i >= 500) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package main.java.com.djrapitops.plan.ui.html.tables;
|
package main.java.com.djrapitops.plan.ui.html.tables;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.ui.html.Html;
|
import main.java.com.djrapitops.plan.ui.html.Html;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
@ -30,7 +29,6 @@ public class PlayersTableCreator {
|
|||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
|
|
||||||
long now = MiscUtils.getTime();
|
long now = MiscUtils.getTime();
|
||||||
boolean showImages = Settings.PLAYERLIST_SHOW_IMAGES.isTrue();
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (UserData uData : data) {
|
for (UserData uData : data) {
|
||||||
@ -45,10 +43,8 @@ public class PlayersTableCreator {
|
|||||||
|
|
||||||
String activityString = getActivityString(isBanned, isUnknown, isActive);
|
String activityString = getActivityString(isBanned, isUnknown, isActive);
|
||||||
|
|
||||||
String img = showImages ? Html.MINOTAR_SMALL_IMG.parse(uData.getName()) : "";
|
|
||||||
|
|
||||||
html.append(Html.TABLELINE_PLAYERS.parse(
|
html.append(Html.TABLELINE_PLAYERS.parse(
|
||||||
img + Html.LINK.parse(HtmlUtils.getInspectUrl(uData.getName()), uData.getName()),
|
Html.LINK.parse(HtmlUtils.getRelativeInspectUrl(uData.getName()), uData.getName()),
|
||||||
activityString,
|
activityString,
|
||||||
String.valueOf(uData.getPlayTime()), FormatUtils.formatTimeAmount(uData.getPlayTime()),
|
String.valueOf(uData.getPlayTime()), FormatUtils.formatTimeAmount(uData.getPlayTime()),
|
||||||
String.valueOf(uData.getLoginTimes()),
|
String.valueOf(uData.getLoginTimes()),
|
||||||
|
@ -5,13 +5,6 @@
|
|||||||
package main.java.com.djrapitops.plan.ui.theme;
|
package main.java.com.djrapitops.plan.ui.theme;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum that contains available themes.
|
* Enum that contains available themes.
|
||||||
@ -58,7 +51,7 @@ public enum Theme {
|
|||||||
|
|
||||||
Theme(String... colors) {
|
Theme(String... colors) {
|
||||||
int length = colors.length;
|
int length = colors.length;
|
||||||
if (length != 19) {
|
if (length < Colors.values().length) {
|
||||||
Log.error("Not All colors (" + length + ") were specified in the theme file: " + name());
|
Log.error("Not All colors (" + length + ") were specified in the theme file: " + name());
|
||||||
Log.error("If the theme is used it WILL CAUSE EXCEPTIONS.");
|
Log.error("If the theme is used it WILL CAUSE EXCEPTIONS.");
|
||||||
}
|
}
|
||||||
@ -78,20 +71,12 @@ public enum Theme {
|
|||||||
return replaced;
|
return replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove
|
public static String replaceColors(String resourceString) {
|
||||||
public static void test() throws IOException {
|
Theme def = Theme.DEFAULT;
|
||||||
String serverHtml = HtmlUtils.getStringFromResource("server - Example.html");
|
String replaced = resourceString;
|
||||||
String css = HtmlUtils.getStringFromResource("main.css");
|
for (Colors c : Colors.values()) {
|
||||||
|
replaced = replaced.replace("#" + def.getColor(c.getId()), c.getColor());
|
||||||
File folder = new File(Plan.getInstance().getDataFolder(), "themes");
|
|
||||||
folder.mkdirs();
|
|
||||||
for (Theme t : Theme.values()) {
|
|
||||||
File themeFolder = new File(folder, t.name());
|
|
||||||
themeFolder.mkdirs();
|
|
||||||
File themeHtml = new File(themeFolder, "server.html");
|
|
||||||
File themeCss = new File(themeFolder, "main.css");
|
|
||||||
Files.write(themeHtml.toPath(), Collections.singletonList(t.replaceThemeColors(serverHtml)));
|
|
||||||
Files.write(themeCss.toPath(), Collections.singletonList(t.replaceThemeColors(css)));
|
|
||||||
}
|
}
|
||||||
|
return replaced;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -124,7 +124,9 @@ public class WebServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response = getResponse(target, user);
|
response = getResponse(target, user);
|
||||||
|
if (response instanceof CSSResponse) {
|
||||||
|
responseHeaders.set("Content-Type", "text/css");
|
||||||
|
}
|
||||||
sendData(responseHeaders, exchange, response);
|
sendData(responseHeaders, exchange, response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
@ -306,11 +308,19 @@ public class WebServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> variables = readVariables(response);
|
Map<String, String> variables = readVariables(response);
|
||||||
|
String key = variables.get("key");
|
||||||
//TODO ADD CHECK IF SERVER KEY VALID
|
|
||||||
|
|
||||||
Plan plan = Plan.getInstance();
|
Plan plan = Plan.getInstance();
|
||||||
|
|
||||||
|
if (!checkKey(plan, key)) {
|
||||||
|
String error = "Server Key not given or invalid";
|
||||||
|
return PageCacheHandler.loadPage(error, () -> {
|
||||||
|
ForbiddenResponse forbidden = new ForbiddenResponse();
|
||||||
|
forbidden.setContent(error);
|
||||||
|
return forbidden;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
WebAPI api = WebAPIManager.getAPI(method);
|
WebAPI api = WebAPIManager.getAPI(method);
|
||||||
|
|
||||||
if (api == null) {
|
if (api == null) {
|
||||||
@ -326,6 +336,18 @@ public class WebServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkKey(Plan plan, String key) {
|
||||||
|
UUID uuid = plan.getServerInfoManager().getServerUUID();
|
||||||
|
UUID keyUUID;
|
||||||
|
try {
|
||||||
|
keyUUID = UUID.fromString(key);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuid.equals(keyUUID);
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, String> readVariables(String response) {
|
private Map<String, String> readVariables(String response) {
|
||||||
String[] variables = response.split("&");
|
String[] variables = response.split("&");
|
||||||
|
|
||||||
@ -352,11 +374,25 @@ public class WebServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean javaScriptRequest = target.endsWith(".js");
|
||||||
|
boolean cssRequest = target.endsWith(".css");
|
||||||
|
|
||||||
String[] args = target.split("/");
|
String[] args = target.split("/");
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
return rootPageResponse(user);
|
return rootPageResponse(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (javaScriptRequest) {
|
||||||
|
return getJSResponse(args[args.length - 1]);
|
||||||
|
}
|
||||||
|
if (cssRequest) {
|
||||||
|
try {
|
||||||
|
return new CSSResponse("main.css");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new InternalErrorResponse(e, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String page = args[1];
|
String page = args[1];
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case "players":
|
case "players":
|
||||||
@ -370,6 +406,14 @@ public class WebServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response getJSResponse(String fileName) {
|
||||||
|
try {
|
||||||
|
return new JavaScriptResponse(fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new InternalErrorResponse(e, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Response forbiddenResponse(int permLevel, int required) {
|
private Response forbiddenResponse(int permLevel, int required) {
|
||||||
return PageCacheHandler.loadPage("forbidden", () -> {
|
return PageCacheHandler.loadPage("forbidden", () -> {
|
||||||
ForbiddenResponse response403 = new ForbiddenResponse();
|
ForbiddenResponse response403 = new ForbiddenResponse();
|
||||||
@ -507,4 +551,8 @@ public class WebServer {
|
|||||||
public boolean isAuthRequired() {
|
public boolean isAuthRequired() {
|
||||||
return usingHttps;
|
return usingHttps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAccessAddress() {
|
||||||
|
return getProtocol()+":/"+ HtmlUtils.getIP();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class InspectWebAPI implements WebAPI {
|
|||||||
return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error));
|
return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
Plan.getInstance().getInspectCache().cache(uuid);
|
plan.getInspectCache().cache(uuid);
|
||||||
|
|
||||||
return PageCacheHandler.loadPage("success", SuccessResponse::new);
|
return PageCacheHandler.loadPage("success", SuccessResponse::new);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main.java.com.djrapitops.plan.ui.webserver.response;
|
package main.java.com.djrapitops.plan.ui.webserver.response;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.ui.html.DataRequestHandler;
|
import main.java.com.djrapitops.plan.ui.html.DataRequestHandler;
|
||||||
|
import main.java.com.djrapitops.plan.ui.theme.Theme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
@ -10,6 +11,6 @@ public class AnalysisPageResponse extends Response {
|
|||||||
|
|
||||||
public AnalysisPageResponse(DataRequestHandler h) {
|
public AnalysisPageResponse(DataRequestHandler h) {
|
||||||
super.setHeader("HTTP/1.1 200 OK");
|
super.setHeader("HTTP/1.1 200 OK");
|
||||||
super.setContent(h.getServerHtml());
|
super.setContent(Theme.replaceColors(h.getServerHtml()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package main.java.com.djrapitops.plan.ui.webserver.response;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.ui.theme.Theme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rsl1122
|
||||||
|
* @since 4.0.0
|
||||||
|
*/
|
||||||
|
public class CSSResponse extends FileResponse {
|
||||||
|
|
||||||
|
public CSSResponse(String fileName) {
|
||||||
|
super(fileName);
|
||||||
|
setContent(Theme.replaceColors(getContent()));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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 main.java.com.djrapitops.plan.ui.webserver.response;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.Log;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response class for returning file contents.
|
||||||
|
*
|
||||||
|
* Created to remove copy-paste.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
* @since 4.0.0
|
||||||
|
*/
|
||||||
|
public class FileResponse extends Response {
|
||||||
|
|
||||||
|
public FileResponse(String fileName) {
|
||||||
|
super.setHeader("HTTP/1.1 200 OK");
|
||||||
|
try {
|
||||||
|
super.setContent(FileUtil.getStringFromResource(fileName));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
super.setContent("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package main.java.com.djrapitops.plan.ui.webserver.response;
|
package main.java.com.djrapitops.plan.ui.webserver.response;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.ui.html.DataRequestHandler;
|
import main.java.com.djrapitops.plan.ui.html.DataRequestHandler;
|
||||||
|
import main.java.com.djrapitops.plan.ui.theme.Theme;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -12,6 +13,6 @@ public class InspectPageResponse extends Response {
|
|||||||
|
|
||||||
public InspectPageResponse(DataRequestHandler h, UUID uuid) {
|
public InspectPageResponse(DataRequestHandler h, UUID uuid) {
|
||||||
super.setHeader("HTTP/1.1 200 OK");
|
super.setHeader("HTTP/1.1 200 OK");
|
||||||
super.setContent(h.getInspectHtml(uuid));
|
super.setContent(Theme.replaceColors(h.getInspectHtml(uuid)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,12 @@
|
|||||||
package main.java.com.djrapitops.plan.ui.webserver.response;
|
package main.java.com.djrapitops.plan.ui.webserver.response;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.Log;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
*/
|
*/
|
||||||
public class JavaScriptResponse extends Response {
|
public class JavaScriptResponse extends FileResponse {
|
||||||
|
|
||||||
public JavaScriptResponse(String resource) {
|
public JavaScriptResponse(String fileName) {
|
||||||
super.setHeader("HTTP/1.1 200 OK");
|
super(fileName);
|
||||||
try {
|
|
||||||
super.setContent(HtmlUtils.getStringFromResource(resource));
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
Log.toLog(this.getClass().getName(), e);
|
|
||||||
super.setContent("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ public class HtmlUtils {
|
|||||||
* @param fileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
|
* @deprecated Use FileUtil
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String getStringFromResource(String fileName) throws FileNotFoundException {
|
public static String getStringFromResource(String fileName) throws FileNotFoundException {
|
||||||
return FileUtil.getStringFromResource(fileName);
|
return FileUtil.getStringFromResource(fileName);
|
||||||
}
|
}
|
||||||
@ -42,7 +44,7 @@ public class HtmlUtils {
|
|||||||
*/
|
*/
|
||||||
public static String replacePlaceholders(String html, Map<String, Serializable> replaceMap) {
|
public static String replacePlaceholders(String html, Map<String, Serializable> replaceMap) {
|
||||||
StrSubstitutor sub = new StrSubstitutor(replaceMap);
|
StrSubstitutor sub = new StrSubstitutor(replaceMap);
|
||||||
|
sub.setEnableSubstitutionInVariables(true);
|
||||||
return sub.replace(html);
|
return sub.replace(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +121,7 @@ public class HtmlUtils {
|
|||||||
* @param placeholders
|
* @param placeholders
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
// TODO REWRITE
|
||||||
public static String getPluginsTabLayout(List<String> pluginNames, Map<String, List<String>> placeholders) {
|
public static String getPluginsTabLayout(List<String> pluginNames, Map<String, List<String>> placeholders) {
|
||||||
boolean sizeIsEvenNumber = pluginNames.size() % 2 == 0;
|
boolean sizeIsEvenNumber = pluginNames.size() % 2 == 0;
|
||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
|
@ -5,18 +5,9 @@ import main.java.com.djrapitops.plan.Settings;
|
|||||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||||
import main.java.com.djrapitops.plan.data.SessionData;
|
import main.java.com.djrapitops.plan.data.SessionData;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
import main.java.com.djrapitops.plan.data.analysis.GamemodePart;
|
|
||||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||||
import main.java.com.djrapitops.plan.database.tables.GMTimesTable;
|
|
||||||
import main.java.com.djrapitops.plan.locale.Locale;
|
|
||||||
import main.java.com.djrapitops.plan.locale.Msg;
|
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.PlayerActivityGraphCreator;
|
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.SessionLengthDistributionGraphCreator;
|
|
||||||
import main.java.com.djrapitops.plan.ui.html.graphs.WorldPieCreator;
|
import main.java.com.djrapitops.plan.ui.html.graphs.WorldPieCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.html.tables.KillsTableCreator;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -42,23 +33,16 @@ public class PlaceholderUtils {
|
|||||||
public static Map<String, Serializable> getAnalysisReplaceRules(AnalysisData data) {
|
public static Map<String, Serializable> getAnalysisReplaceRules(AnalysisData data) {
|
||||||
HashMap<String, Serializable> replaceMap = new HashMap<>();
|
HashMap<String, Serializable> replaceMap = new HashMap<>();
|
||||||
replaceMap.putAll(data.getReplaceMap());
|
replaceMap.putAll(data.getReplaceMap());
|
||||||
replaceMap.put("plugins", data.replacePluginsTabLayout());
|
replaceMap.put("tabContentPlugins", data.replacePluginsTabLayout());
|
||||||
|
|
||||||
replaceMap.put("refresh", FormatUtils.formatTimeAmountDifference(data.getRefreshDate(), MiscUtils.getTime()));
|
// TODO Refresh time for Network pages
|
||||||
replaceMap.put("refreshlong", String.valueOf(data.getRefreshDate()));
|
// replaceMap.put("refresh", FormatUtils.formatTimeAmountDifference(data.getRefreshDate(), MiscUtils.getTime()));
|
||||||
|
// replaceMap.put("refreshlong", String.valueOf(data.getRefreshDate()));
|
||||||
|
|
||||||
replaceMap.put("servername", Settings.SERVER_NAME.toString());
|
replaceMap.put("serverName", Settings.SERVER_NAME.toString());
|
||||||
|
|
||||||
replaceMap.put("timezone", MiscUtils.getTimeZoneOffsetHours());
|
replaceMap.put("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||||
|
// TODO Add Theme Replace somewhere when getting
|
||||||
// Html Theme colors
|
|
||||||
String[] colors = new String[]{Settings.HCOLOR_MAIN.toString(), Settings.HCOLOR_MAIN_DARK.toString(), Settings.HCOLOR_SEC.toString(), Settings.HCOLOR_TER.toString(), Settings.HCOLOR_TER_DARK.toString()};
|
|
||||||
String[] defaultCols = new String[]{"348e0f", "267F00", "5cb239", "89c471", "5da341"};
|
|
||||||
for (int i = 0; i < colors.length; i++) {
|
|
||||||
if (!defaultCols[i].equals(colors[i])) {
|
|
||||||
replaceMap.put("#" + defaultCols[i], "#" + colors[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return replaceMap;
|
return replaceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,71 +55,39 @@ public class PlaceholderUtils {
|
|||||||
public static Map<String, Serializable> getInspectReplaceRules(UserData data) {
|
public static Map<String, Serializable> getInspectReplaceRules(UserData data) {
|
||||||
|
|
||||||
HashMap<String, Serializable> replaceMap = new HashMap<>();
|
HashMap<String, Serializable> replaceMap = new HashMap<>();
|
||||||
replaceMap.put("timezone", MiscUtils.getTimeZoneOffsetHours());
|
|
||||||
|
|
||||||
boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue();
|
|
||||||
UUID uuid = data.getUuid();
|
UUID uuid = data.getUuid();
|
||||||
replaceMap.put("uuid", (showIPandUUID ? uuid.toString() : "Hidden (Config)"));
|
replaceMap.put("playerName", data.getName());
|
||||||
replaceMap.put("lastseen", FormatUtils.formatTimeStampYear(data.getLastPlayed()));
|
replaceMap.put("serverName", Settings.SERVER_NAME.toString());
|
||||||
replaceMap.put("logintimes", data.getLoginTimes());
|
|
||||||
replaceMap.put("geoloc", data.getGeolocation());
|
|
||||||
long now = MiscUtils.getTime();
|
|
||||||
boolean isActive = AnalysisUtils.isActive(now, data.getLastPlayed(), data.getPlayTime(), data.getLoginTimes());
|
|
||||||
replaceMap.put("active", isActive ? Locale.get(Msg.HTML_ACTIVE).parse() : Locale.get(Msg.HTML_INACTIVE).parse());
|
|
||||||
GamemodePart gmPart = new GamemodePart();
|
|
||||||
Map<String, Long> gmTimes = data.getGmTimes().getTimes();
|
|
||||||
String[] gms = GMTimesTable.getGMKeyArray();
|
|
||||||
for (String gm : gms) {
|
|
||||||
Long time = gmTimes.get(gm);
|
|
||||||
if (time != null) {
|
|
||||||
gmPart.addTo(gm, time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gmPart.analyse();
|
|
||||||
replaceMap.putAll(gmPart.getReplaceMap());
|
|
||||||
|
|
||||||
replaceMap.put("ips", showIPandUUID ? data.getIps().toString() : "Hidden (Config)");
|
|
||||||
replaceMap.put("nicknames", HtmlUtils.removeXSS(HtmlUtils.swapColorsToSpan(data.getNicknames().toString())));
|
|
||||||
replaceMap.put("name", data.getName());
|
|
||||||
replaceMap.put("registered", FormatUtils.formatTimeStampYear(data.getRegistered()));
|
|
||||||
replaceMap.put("timeskicked", data.getTimesKicked());
|
|
||||||
replaceMap.put("playtime", FormatUtils.formatTimeAmount(data.getPlayTime()));
|
|
||||||
replaceMap.put("banned", data.isBanned() ? Locale.get(Msg.HTML_BANNED).parse() : "");
|
|
||||||
replaceMap.put("op", data.isOp() ? Locale.get(Msg.HTML_OP).parse() : "");
|
|
||||||
replaceMap.put("isonline", data.isOnline() ? Locale.get(Msg.HTML_ONLINE).parse() : Locale.get(Msg.HTML_OFFLINE).parse());
|
|
||||||
replaceMap.put("deaths", data.getDeaths());
|
|
||||||
replaceMap.put("playerkills", data.getPlayerKills().size());
|
|
||||||
replaceMap.put("mobkills", data.getMobKills());
|
|
||||||
replaceMap.put("sessionaverage", FormatUtils.formatTimeAmount(MathUtils.averageLong(AnalysisUtils.transformSessionDataToLengths(data.getSessions()))));
|
|
||||||
replaceMap.put("killstable", KillsTableCreator.createKillsTable(data.getPlayerKills()));
|
|
||||||
Plan plugin = Plan.getInstance();
|
Plan plugin = Plan.getInstance();
|
||||||
replaceMap.put("version", plugin.getDescription().getVersion());
|
replaceMap.put("version", plugin.getDescription().getVersion());
|
||||||
replaceMap.put("playersgraphcolor", Settings.HCOLOR_ACT_ONL.toString());
|
|
||||||
|
replaceMap.put("playerClassification", "TODO"); //TODO Playerclassification (Active • Offline etc)
|
||||||
|
replaceMap.put("nicknames", "TODO"); //TODO Nickname list creator • name<br>
|
||||||
|
replaceMap.put("geolocations", "TODO"); //TODO Geolocation list creator • name<br>
|
||||||
|
|
||||||
|
replaceMap.put("registered", FormatUtils.formatTimeStampYear(data.getRegistered()));
|
||||||
|
replaceMap.put("lastSeen", FormatUtils.formatTimeStampYear(data.getLastPlayed()));
|
||||||
|
|
||||||
|
replaceMap.put("sessionCount", data.getSessions().size());
|
||||||
|
replaceMap.put("playtimeTotal", FormatUtils.formatTimeAmount(data.getPlayTime()));
|
||||||
|
|
||||||
|
replaceMap.put("kickCount", data.getTimesKicked());
|
||||||
|
replaceMap.put("playerKillCount", data.getPlayerKills().size());
|
||||||
|
replaceMap.put("mobKillCount", data.getMobKills());
|
||||||
|
replaceMap.put("deathCount", data.getDeaths());
|
||||||
|
|
||||||
Set<SessionData> sessions = new HashSet<>(data.getSessions());
|
Set<SessionData> sessions = new HashSet<>(data.getSessions());
|
||||||
List<Long> lengths = AnalysisUtils.transformSessionDataToLengths(sessions);
|
replaceMap.put("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessions));
|
||||||
replaceMap.put("punchcardseries", PunchCardGraphCreator.createDataSeries(sessions));
|
|
||||||
replaceMap.put("sessionlengthseries", SessionLengthDistributionGraphCreator.createDataSeries(lengths));
|
|
||||||
replaceMap.put("playersonlineseries", PlayerActivityGraphCreator.buildSeriesDataStringSessions(sessions));
|
|
||||||
WorldTimes worldTimes = data.getWorldTimes();
|
WorldTimes worldTimes = data.getWorldTimes();
|
||||||
replaceMap.put("worldseries", WorldPieCreator.createSeriesData(worldTimes.getTimes()));
|
replaceMap.put("worldSeries", WorldPieCreator.createSeriesData(worldTimes.getTimes()));
|
||||||
replaceMap.put("worldtotal", FormatUtils.formatTimeAmount(worldTimes.getTotal()));
|
replaceMap.put("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal()));
|
||||||
|
|
||||||
String[] colors = new String[]{Settings.HCOLOR_MAIN.toString(), Settings.HCOLOR_MAIN_DARK.toString(), Settings.HCOLOR_SEC.toString(), Settings.HCOLOR_TER.toString(), Settings.HCOLOR_TER_DARK.toString()};
|
//TODO Plugin Tab content Web API
|
||||||
String[] defaultCols = new String[]{"348e0f", "267F00", "5cb239", "89c471", "5da341"};
|
//TODO Player Plugin tab code.
|
||||||
for (int i = 0; i < colors.length; i++) {
|
|
||||||
if (!defaultCols[i].equals(colors[i])) {
|
|
||||||
replaceMap.put("#" + defaultCols[i], "#" + colors[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long cacheTime = plugin.getInspectCache().getCacheTime(uuid);
|
|
||||||
replaceMap.put("refresh", FormatUtils.formatTimeAmountDifference(cacheTime, now));
|
|
||||||
replaceMap.put("refreshlong", cacheTime);
|
|
||||||
replaceMap.put("servername", Settings.SERVER_NAME.toString());
|
|
||||||
String pluginsTabHtml = plugin.getHookHandler().getPluginsTabLayoutForInspect();
|
String pluginsTabHtml = plugin.getHookHandler().getPluginsTabLayoutForInspect();
|
||||||
Map<String, Serializable> additionalReplaceRules = plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid);
|
Map<String, Serializable> additionalReplaceRules = plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid);
|
||||||
String replacedOnce = HtmlUtils.replacePlaceholders(pluginsTabHtml, additionalReplaceRules);
|
String replacedOnce = HtmlUtils.replacePlaceholders(pluginsTabHtml, additionalReplaceRules);
|
||||||
replaceMap.put("plugins", HtmlUtils.replacePlaceholders(replacedOnce, additionalReplaceRules));
|
replaceMap.put("tabContentPlugins", HtmlUtils.replacePlaceholders(replacedOnce, additionalReplaceRules));
|
||||||
return replaceMap;
|
return replaceMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.djrapitops.plugin.task.AbsRunnable;
|
|||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
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.*;
|
||||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
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.HookHandler;
|
||||||
@ -162,9 +161,7 @@ public class Analysis {
|
|||||||
|
|
||||||
Log.logDebug("Analysis", time);
|
Log.logDebug("Analysis", time);
|
||||||
|
|
||||||
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
|
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
|
||||||
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(String.valueOf(time), HtmlUtils.getServerAnalysisUrlWithProtocol()));
|
|
||||||
}
|
|
||||||
|
|
||||||
PageCacheHandler.removeIf(identifier -> identifier.startsWith("inspectPage: ") || identifier.startsWith("inspectionJson: "));
|
PageCacheHandler.removeIf(identifier -> identifier.startsWith("inspectPage: ") || identifier.startsWith("inspectionJson: "));
|
||||||
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
||||||
@ -182,9 +179,8 @@ public class Analysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void log(String msg) {
|
private void log(String msg) {
|
||||||
if (Settings.ANALYSIS_LOG_TO_CONSOLE.isTrue()) {
|
// TODO Send info to the command sender. (Needs a new system)
|
||||||
Log.info(msg);
|
Log.info(msg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Serializable> analyzeAdditionalPluginData(List<UUID> uuids) {
|
private Map<String, Serializable> analyzeAdditionalPluginData(List<UUID> uuids) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main.java.com.djrapitops.plan.utilities.analysis;
|
package main.java.com.djrapitops.plan.utilities.analysis;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
|
||||||
import main.java.com.djrapitops.plan.data.SessionData;
|
import main.java.com.djrapitops.plan.data.SessionData;
|
||||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||||
@ -33,14 +32,9 @@ public class AnalysisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isActive(long now, long lastPlayed, long playTime, int loginTimes) {
|
public static boolean isActive(long now, long lastPlayed, long playTime, int loginTimes) {
|
||||||
int timeToActive = Settings.ANALYSIS_MINUTES_FOR_ACTIVE.getNumber();
|
|
||||||
|
|
||||||
if (timeToActive < 0) {
|
|
||||||
timeToActive = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
int timeToActive = 10;
|
||||||
long twoWeeks = 1209600000;
|
long twoWeeks = 1209600000;
|
||||||
|
|
||||||
return now - lastPlayed < twoWeeks
|
return now - lastPlayed < twoWeeks
|
||||||
&& loginTimes > 3
|
&& loginTimes > 3
|
||||||
&& playTime > 60 * timeToActive;
|
&& playTime > 60 * timeToActive;
|
||||||
|
@ -198,11 +198,9 @@ public class DumpUtils {
|
|||||||
* @param plan The Plan instance
|
* @param plan The Plan instance
|
||||||
*/
|
*/
|
||||||
private static void addConfigurationDetails(DumpLog log, Plan plan) {
|
private static void addConfigurationDetails(DumpLog log, Plan plan) {
|
||||||
boolean webServerEnabled = Settings.WEBSERVER_ENABLED.isTrue();
|
|
||||||
boolean usingHTTPS = plan.getUiServer().usingHttps();
|
boolean usingHTTPS = plan.getUiServer().usingHttps();
|
||||||
boolean refreshAnalysisOnEnable = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue();
|
|
||||||
boolean analysisExport = Settings.ANALYSIS_EXPORT.isTrue();
|
boolean analysisExport = Settings.ANALYSIS_EXPORT.isTrue();
|
||||||
boolean usingAlternativeServerIP = Settings.USE_ALTERNATIVE_UI.isTrue();
|
boolean usingAlternativeServerIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||||
|
|
||||||
boolean combineAliases = Settings.COMBINE_COMMAND_ALIASES.isTrue();
|
boolean combineAliases = Settings.COMBINE_COMMAND_ALIASES.isTrue();
|
||||||
boolean unknownCommandLogging = Settings.LOG_UNKNOWN_COMMANDS.isTrue();
|
boolean unknownCommandLogging = Settings.LOG_UNKNOWN_COMMANDS.isTrue();
|
||||||
@ -212,9 +210,7 @@ public class DumpUtils {
|
|||||||
|
|
||||||
log.addHeader("Plan Configuration");
|
log.addHeader("Plan Configuration");
|
||||||
|
|
||||||
log.add("Webserver Enabled", webServerEnabled);
|
|
||||||
log.add("Webserver HTTPS", usingHTTPS);
|
log.add("Webserver HTTPS", usingHTTPS);
|
||||||
log.add("Refresh Analysis on Enable", refreshAnalysisOnEnable);
|
|
||||||
log.add("Analysis Export", analysisExport);
|
log.add("Analysis Export", analysisExport);
|
||||||
log.add("Alternative Server IP", usingAlternativeServerIP);
|
log.add("Alternative Server IP", usingAlternativeServerIP);
|
||||||
|
|
||||||
|
@ -21,13 +21,10 @@ public class BStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerConfigSettingGraphs() {
|
private void registerConfigSettingGraphs() {
|
||||||
boolean webserver = Settings.WEBSERVER_ENABLED.isTrue();
|
// TODO Write a Module bar graph
|
||||||
boolean analysisRefreshEnable = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue();
|
|
||||||
boolean analysisAutoRefresh = Settings.ANALYSIS_AUTO_REFRESH.getNumber() != -1;
|
boolean analysisAutoRefresh = Settings.ANALYSIS_AUTO_REFRESH.getNumber() != -1;
|
||||||
boolean export = Settings.ANALYSIS_EXPORT.isTrue();
|
boolean export = Settings.ANALYSIS_EXPORT.isTrue();
|
||||||
|
|
||||||
addEnabledDisabledPie("webserver_enabled", webserver);
|
|
||||||
addEnabledDisabledPie("analysis_enable_refresh", analysisRefreshEnable);
|
|
||||||
addEnabledDisabledPie("analysis_auto_refresh", analysisAutoRefresh);
|
addEnabledDisabledPie("analysis_auto_refresh", analysisAutoRefresh);
|
||||||
addEnabledDisabledPie("html_export", export);
|
addEnabledDisabledPie("html_export", export);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ ${playerKillCount} num
|
|||||||
${mobKillCount} num
|
${mobKillCount} num
|
||||||
${deathCount} num
|
${deathCount} num
|
||||||
|
|
||||||
|
// TODO All these after SessionData has been updated.
|
||||||
${sessionCountDay} num
|
${sessionCountDay} num
|
||||||
${sessionCountWeek} num
|
${sessionCountWeek} num
|
||||||
${playtimeDay} timeamount
|
${playtimeDay} timeamount
|
||||||
@ -57,17 +58,18 @@ ${playersNewWeek} num
|
|||||||
${contentServers} row[column[box-header, box, box-footer[p,button right, refresh button right]], column...], row...
|
${contentServers} row[column[box-header, box, box-footer[p,button right, refresh button right]], column...], row...
|
||||||
|
|
||||||
server.html:
|
server.html:
|
||||||
${serverName} String
|
${serverName} String //done
|
||||||
${timeZone} num
|
${timeZone} num //done
|
||||||
|
|
||||||
${playersOnline} num
|
${playersOnline} num
|
||||||
${playersMax} num
|
${playersMax} num
|
||||||
${playersTotal} num
|
${playersTotal} num //done
|
||||||
${playersActive} num
|
${playersActive} num // done
|
||||||
|
|
||||||
|
//done
|
||||||
${playersAverage} num
|
${playersAverage} num
|
||||||
${playersNewAverage} num
|
${playersNewAverage} num
|
||||||
|
//done
|
||||||
${playersDay} num
|
${playersDay} num
|
||||||
${playersWeek} num
|
${playersWeek} num
|
||||||
${playersMonth} num
|
${playersMonth} num
|
||||||
@ -86,14 +88,19 @@ ${playersLastPeak} num
|
|||||||
${bestPeakTime} time format full
|
${bestPeakTime} time format full
|
||||||
${playersBestPeak} num
|
${playersBestPeak} num
|
||||||
|
|
||||||
${sessionAverage} timeamount
|
${sessionAverage} timeamount // done
|
||||||
|
|
||||||
${playtimeTotal} timeamount
|
${playtimeTotal} timeamount // done
|
||||||
${sessionCount} num
|
${sessionCount} num
|
||||||
|
// done
|
||||||
${killCount} num
|
${killCount} num
|
||||||
${mobKillCount} num
|
${mobKillCount} num
|
||||||
${deathCount} num
|
${deathCount} num
|
||||||
|
|
||||||
|
${commandCount} num //TODO
|
||||||
|
${commandUniqueCount} num //TODO
|
||||||
|
|
||||||
|
//done
|
||||||
${tpsAverageDay} num
|
${tpsAverageDay} num
|
||||||
${tpsAverageWeek} num
|
${tpsAverageWeek} num
|
||||||
${cpuAverageDay} num%
|
${cpuAverageDay} num%
|
||||||
@ -107,9 +114,10 @@ ${chunkAverageWeek} num
|
|||||||
|
|
||||||
${tableBodyRecentLogins} tr th html (2) (15-20)
|
${tableBodyRecentLogins} tr th html (2) (15-20)
|
||||||
${tableBodySessions} tr th html (4) (50)
|
${tableBodySessions} tr th html (4) (50)
|
||||||
${tableBodyPlayerList} tr th html (7) (250)
|
${tableBodyPlayerList} tr th html (7) (250) // done
|
||||||
${tableBodyCommands} tr th html (2) (100)
|
${tableBodyCommands} tr th html (2) (100) // done
|
||||||
|
|
||||||
|
// done
|
||||||
${playersOnlineSeries}
|
${playersOnlineSeries}
|
||||||
${tpsSeries}
|
${tpsSeries}
|
||||||
${cpuSeries}
|
${cpuSeries}
|
||||||
@ -121,27 +129,31 @@ ${geoMapSeries}
|
|||||||
${sessionLengthSeries}
|
${sessionLengthSeries}
|
||||||
${punchCardSeries}
|
${punchCardSeries}
|
||||||
|
|
||||||
${playersGraphColor}
|
${playersGraphColor} // done
|
||||||
|
|
||||||
${gmData}
|
|
||||||
${gmTotal} timeamount
|
|
||||||
${gmColors}
|
|
||||||
|
|
||||||
|
${gmData} // TODO Remove
|
||||||
|
${gmTotal} timeamount // TODO Remove
|
||||||
|
${gmColors} // TODO Move to World Graph
|
||||||
|
|
||||||
|
// done
|
||||||
${active}
|
${active}
|
||||||
${inactive}
|
${inactive}
|
||||||
${joinLeaver}
|
${joinLeaver}
|
||||||
${banned}
|
${banned}
|
||||||
${activityColors}
|
${activityColors}
|
||||||
|
|
||||||
${worldTotal} timeamount
|
${worldTotal} timeamount //done
|
||||||
${worldColors} NOT IMPLEMENTED //TODO
|
${worldColors} //TODO NOT IMPLEMENTED
|
||||||
|
|
||||||
|
//done
|
||||||
${tpsMedium}
|
${tpsMedium}
|
||||||
${tpsHigh}
|
${tpsHigh}
|
||||||
${tpsLowColor}
|
${tpsLowColor}
|
||||||
${tpsMediumColor}
|
${tpsMediumColor}
|
||||||
${tpsHighColor}
|
${tpsHighColor}
|
||||||
|
|
||||||
|
// Replace done
|
||||||
${tabContentPlugins} row[column[box-header[h2[i, text]],box plugin], column...], row... + style="width: 200%;" <h2>That's all..</h2> <p>Do you have more plugins? ._.</p>
|
${tabContentPlugins} row[column[box-header[h2[i, text]],box plugin], column...], row... + style="width: 200%;" <h2>That's all..</h2> <p>Do you have more plugins? ._.</p>
|
||||||
|
|
||||||
STYLE:
|
STYLE:
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
<h2><i class="fa fa-bar-chart"></i> Players Online</h2>
|
<h2><i class="fa fa-bar-chart"></i> Players Online</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="playersOnlineDay" style="width: 100%; height: 700px;"></div>
|
<div id="playerChartDay" style="width: 100%; height: 400px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@ -116,7 +116,7 @@
|
|||||||
<h2><i class="fa fa-bar-chart"></i> Players Online</h2>
|
<h2><i class="fa fa-bar-chart"></i> Players Online</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="playersOnlineMonth" style="width: 100%; height: 700px;"></div>
|
<div id="playerChartMonth" style="width: 100%; height: 400px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@ -124,7 +124,7 @@
|
|||||||
<h2><i class="fa fa-braille"></i> Player Join PunchCard</h2>
|
<h2><i class="fa fa-braille"></i> Player Join PunchCard</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="punchcard" style="width: 100%; height: 700px;"></div>
|
<div id="punchcard" style="width: 100%; height: 400px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -193,26 +193,26 @@
|
|||||||
<h2><i class="fa fa-pie-chart"></i> World Playtime</h2>
|
<h2><i class="fa fa-pie-chart"></i> World Playtime</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="worldPie" style="width: 100%; height: 450px;"></div>
|
<div id="worldPie" style="width: 100%; height: 350px;"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-header">
|
<div class="box-header">
|
||||||
<h2><i class="fa fa-pie-chart"></i> Playerbase</h2>
|
<h2><i class="fa fa-pie-chart"></i> Playerbase</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="activityPie" style="width: 100%; height: 450px;"></div>
|
<div id="activityPie" style="width: 100%; height: 350px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tab-performance" class="tab">
|
<div id="tab-performance" class="tab">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="row"> <!--First row (horizontal)-->
|
<div class="row">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="box-header">
|
<div class="box-header">
|
||||||
<h2><i class="fa fa-bar-chart"></i> Ticks Per Second</h2>
|
<h2><i class="fa fa-bar-chart"></i> Ticks Per Second</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="tpsGraph" style="width: 100%; height: 700px;"></div>
|
<div id="tpsGraph" style="width: 100%; height: 350px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@ -220,17 +220,17 @@
|
|||||||
<h2><i class="fa fa-bar-chart"></i> Resource Usage</h2>
|
<h2><i class="fa fa-bar-chart"></i> Resource Usage</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="resourceGraph" style="width: 100%; height: 700px;"></div>
|
<div id="resourceGraph" style="width: 100%; height: 350px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!--First row (horizontal)-->
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="box-header">
|
<div class="box-header">
|
||||||
<h2><i class="fa fa-bar-chart"></i> World Load</h2>
|
<h2><i class="fa fa-bar-chart"></i> World Load</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div id="worldGraph" style="width: 100%; height: 700px;"></div>
|
<div id="worldGraph" style="width: 100%; height: 350px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -319,7 +319,7 @@
|
|||||||
<h2><i class="fa fa-globe"></i> Geolocations</h2>
|
<h2><i class="fa fa-globe"></i> Geolocations</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-footer" style="padding: 2px;">
|
<div class="box-footer" style="padding: 2px;">
|
||||||
<div id="choropleth" style="width: 100%; height: 700px;"></div>
|
<div id="choropleth" style="width: 100%; height: 600px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -333,11 +333,9 @@
|
|||||||
<script src="https://code.highcharts.com/maps/modules/map.js"></script>
|
<script src="https://code.highcharts.com/maps/modules/map.js"></script>
|
||||||
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>
|
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>
|
||||||
<script src="./js/activityPie.js"></script>
|
<script src="./js/activityPie.js"></script>
|
||||||
<script src="./js/gmPie.js"></script>
|
|
||||||
<script src="./js/playerGraph.js"></script>
|
<script src="./js/playerGraph.js"></script>
|
||||||
<script src="./js/punchCard.js"></script>
|
<script src="./js/punchCard.js"></script>
|
||||||
<script src="./js/resourceGraph.js"></script>
|
<script src="./js/resourceGraph.js"></script>
|
||||||
<script src="./js/sessionDistributionChart.js"></script>
|
|
||||||
<script src="./js/tpsGraph.js"></script>
|
<script src="./js/tpsGraph.js"></script>
|
||||||
<script src="./js/worldGraph.js"></script>
|
<script src="./js/worldGraph.js"></script>
|
||||||
<script src="./js/worldMap.js"></script>
|
<script src="./js/worldMap.js"></script>
|
||||||
@ -434,43 +432,18 @@
|
|||||||
y: ${banned}
|
y: ${banned}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
var gmData = ${gmData};
|
|
||||||
var gmSeries = {
|
|
||||||
name: 'GM Usage',
|
|
||||||
colorByPoint: true,
|
|
||||||
data: [{
|
|
||||||
name: 'Survival',
|
|
||||||
y: gmData[0],
|
|
||||||
sliced: true,
|
|
||||||
selected: true
|
|
||||||
}, {
|
|
||||||
name: 'Creative',
|
|
||||||
y: gmData[1]
|
|
||||||
}, {
|
|
||||||
name: 'Adventure',
|
|
||||||
y: gmData[2]
|
|
||||||
}, {
|
|
||||||
name: 'Spectator',
|
|
||||||
y: gmData[3]
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
var worldSeries = {
|
var worldSeries = {
|
||||||
name: 'World Playtime',
|
name: 'World Playtime',
|
||||||
colorByPoint: true,
|
colorByPoint: true,
|
||||||
data: ${worldSeries}
|
data: ${worldSeries}
|
||||||
};
|
};
|
||||||
var mapSeries = {
|
var mapSeries = {
|
||||||
name: 'Players',
|
name: 'Players',
|
||||||
type: 'map',
|
type: 'map',
|
||||||
mapData: Highcharts.maps['custom/world'],
|
mapData: Highcharts.maps['custom/world'],
|
||||||
data: ${geoMapSeries}
|
data: ${geoMapSeries},
|
||||||
joinBy: ['iso-a3', 'code']
|
joinBy: ['iso-a3', 'code']
|
||||||
};
|
};
|
||||||
var sessionLengthSeries = {
|
|
||||||
name: 'Sessions',
|
|
||||||
color: '#89c471',
|
|
||||||
data: ${sessionLengthSeries}
|
|
||||||
};
|
|
||||||
var punchcardSeries = {
|
var punchcardSeries = {
|
||||||
name: 'Relative Activity',
|
name: 'Relative Activity',
|
||||||
color: '#222',
|
color: '#222',
|
||||||
@ -494,7 +467,6 @@
|
|||||||
}
|
}
|
||||||
x.style.opacity = "1";
|
x.style.opacity = "1";
|
||||||
openFunc(slideIndex)();
|
openFunc(slideIndex)();
|
||||||
/*gmPie('gmPie', gmSeries, '${gmTotal}', [${gmColors}]);
|
|
||||||
activityPie('activityPie', activitySeries, ${playersTotal}, [${activityColors}]);
|
activityPie('activityPie', activitySeries, ${playersTotal}, [${activityColors}]);
|
||||||
worldPie('worldPie', worldSeries, '${worldTotal}');
|
worldPie('worldPie', worldSeries, '${worldTotal}');
|
||||||
playersChart('playerChartDay', playersOnlineSeries, 1);
|
playersChart('playerChartDay', playersOnlineSeries, 1);
|
||||||
@ -503,9 +475,8 @@
|
|||||||
resourceChart('resourceGraph', cpuSeries, ramSeries);
|
resourceChart('resourceGraph', cpuSeries, ramSeries);
|
||||||
worldChart('worldGraph', entitySeries, chunkSeries);
|
worldChart('worldGraph', entitySeries, chunkSeries);
|
||||||
worldMap('choropleth', '#EEFFEE', '#267f00', mapSeries);
|
worldMap('choropleth', '#EEFFEE', '#267f00', mapSeries);
|
||||||
sessionDistributionChart('sessionDistribution', sessionLengthSeries);
|
|
||||||
punchCard('punchcard', punchcardSeries);
|
punchCard('punchcard', punchcardSeries);
|
||||||
countUpTimer();*/
|
/*countUpTimer();*/
|
||||||
|
|
||||||
function openFunc(i) {
|
function openFunc(i) {
|
||||||
return function() {
|
return function() {
|
||||||
|
@ -28,5 +28,4 @@ public class PermissionsTest {
|
|||||||
public void testGetPermission() {
|
public void testGetPermission() {
|
||||||
assertEquals("plan.inspect.other", Permissions.INSPECT_OTHER.getPerm());
|
assertEquals("plan.inspect.other", Permissions.INSPECT_OTHER.getPerm());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import main.java.com.djrapitops.plan.data.UserData;
|
|||||||
import main.java.com.djrapitops.plan.data.WebUser;
|
import main.java.com.djrapitops.plan.data.WebUser;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||||
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
||||||
import main.java.com.djrapitops.plan.database.tables.GMTimesTable;
|
import main.java.com.djrapitops.plan.data.time.GMTimes;
|
||||||
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
|
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
||||||
import org.apache.commons.lang.RandomStringUtils;
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
@ -29,7 +29,7 @@ public class RandomData {
|
|||||||
List<UserData> test = new ArrayList<>();
|
List<UserData> test = new ArrayList<>();
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
String randomName = randomString(10);
|
String randomName = randomString(10);
|
||||||
UserData uD = new UserData(UUID.randomUUID(), r.nextLong(), r.nextBoolean(), GMTimesTable.getGMKeyArray()[r.nextInt(3)], randomName, r.nextBoolean());
|
UserData uD = new UserData(UUID.randomUUID(), r.nextLong(), r.nextBoolean(), GMTimes.getGMKeyArray()[r.nextInt(3)], randomName, r.nextBoolean());
|
||||||
uD.setLastPlayed(r.nextLong());
|
uD.setLastPlayed(r.nextLong());
|
||||||
test.add(uD);
|
test.add(uD);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user