mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-04 22:41:41 +01:00
Sonar Code smell clean-up
This commit is contained in:
parent
d813aa547e
commit
922562989a
@ -20,17 +20,12 @@
|
|||||||
package com.djrapitops.plan;
|
package com.djrapitops.plan;
|
||||||
|
|
||||||
import com.djrapitops.plan.command.PlanCommand;
|
import com.djrapitops.plan.command.PlanCommand;
|
||||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
|
||||||
import com.djrapitops.plan.system.BukkitSystem;
|
import com.djrapitops.plan.system.BukkitSystem;
|
||||||
import com.djrapitops.plan.system.database.DBSystem;
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
|
||||||
import com.djrapitops.plan.system.processing.importing.ImporterManager;
|
import com.djrapitops.plan.system.processing.importing.ImporterManager;
|
||||||
import com.djrapitops.plan.system.processing.importing.importers.OfflinePlayerImporter;
|
import com.djrapitops.plan.system.processing.importing.importers.OfflinePlayerImporter;
|
||||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||||
import com.djrapitops.plan.system.webserver.WebServer;
|
|
||||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
|
||||||
import com.djrapitops.plan.utilities.metrics.BStats;
|
import com.djrapitops.plan.utilities.metrics.BStats;
|
||||||
import com.djrapitops.plugin.BukkitPlugin;
|
import com.djrapitops.plugin.BukkitPlugin;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
@ -51,8 +46,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
|
|
||||||
private BukkitSystem system;
|
private BukkitSystem system;
|
||||||
|
|
||||||
private HookHandler hookHandler; // Manages 3rd party data sources
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to get the plugin-instance singleton.
|
* Used to get the plugin-instance singleton.
|
||||||
*
|
*
|
||||||
@ -120,34 +113,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to access active Database.
|
|
||||||
*
|
|
||||||
* @return the Current Database
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Database getDB() {
|
|
||||||
return DBSystem.getInstance().getActiveDatabase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to access WebServer.
|
|
||||||
*
|
|
||||||
* @return the WebServer
|
|
||||||
*/
|
|
||||||
public WebServer getWebServer() {
|
|
||||||
return WebServerSystem.getInstance().getWebServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to access HookHandler.
|
|
||||||
*
|
|
||||||
* @return HookHandler that manages Hooks to other plugins.
|
|
||||||
*/
|
|
||||||
public HookHandler getHookHandler() {
|
|
||||||
return hookHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReloading() {
|
public boolean isReloading() {
|
||||||
return reloading;
|
return reloading;
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,9 @@ package com.djrapitops.plan;
|
|||||||
|
|
||||||
import com.djrapitops.plan.command.PlanBungeeCommand;
|
import com.djrapitops.plan.command.PlanBungeeCommand;
|
||||||
import com.djrapitops.plan.system.BungeeSystem;
|
import com.djrapitops.plan.system.BungeeSystem;
|
||||||
import com.djrapitops.plan.system.database.DBSystem;
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
|
||||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||||
import com.djrapitops.plan.system.webserver.WebServer;
|
|
||||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
|
||||||
import com.djrapitops.plugin.BungeePlugin;
|
import com.djrapitops.plugin.BungeePlugin;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
import com.djrapitops.plugin.api.Benchmark;
|
||||||
@ -32,9 +28,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
|
|
||||||
private BungeeSystem system;
|
private BungeeSystem system;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private boolean setupAllowed = false;
|
|
||||||
|
|
||||||
public static PlanBungee getInstance() {
|
public static PlanBungee getInstance() {
|
||||||
return (PlanBungee) StaticHolder.getInstance(PlanBungee.class);
|
return (PlanBungee) StaticHolder.getInstance(PlanBungee.class);
|
||||||
}
|
}
|
||||||
@ -73,18 +66,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
public void onReload() {
|
public void onReload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public Database getDB() {
|
|
||||||
return DBSystem.getInstance().getActiveDatabase();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public WebServer getWebServer() {
|
|
||||||
return WebServerSystem.getInstance().getWebServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getResource(String resource) {
|
public InputStream getResource(String resource) {
|
||||||
return getResourceAsStream(resource);
|
return getResourceAsStream(resource);
|
||||||
@ -95,16 +76,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
return PlanColorScheme.create();
|
return PlanColorScheme.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public boolean isSetupAllowed() {
|
|
||||||
return setupAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setSetupAllowed(boolean setupAllowed) {
|
|
||||||
this.setupAllowed = setupAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BungeeSystem getSystem() {
|
public BungeeSystem getSystem() {
|
||||||
return system;
|
return system;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan;
|
package com.djrapitops.plan;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
|
||||||
import com.djrapitops.plan.system.webserver.WebServer;
|
|
||||||
import com.djrapitops.plugin.IPlugin;
|
import com.djrapitops.plugin.IPlugin;
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.settings.ColorScheme;
|
import com.djrapitops.plugin.settings.ColorScheme;
|
||||||
@ -43,12 +41,6 @@ public interface PlanPlugin extends IPlugin {
|
|||||||
throw new IllegalAccessError("Plugin instance not available");
|
throw new IllegalAccessError("Plugin instance not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
Database getDB();
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
WebServer getWebServer();
|
|
||||||
|
|
||||||
File getDataFolder();
|
File getDataFolder();
|
||||||
|
|
||||||
InputStream getResource(String resource);
|
InputStream getResource(String resource);
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licence is provided in the jar as license.yml also here:
|
|
||||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
|
||||||
*/
|
|
||||||
package com.djrapitops.plan.api.exceptions.database;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Thrown when something goes wrong with creating tables with {@code Table#createTable}.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class DBCreateTableException extends DBInitException {
|
|
||||||
|
|
||||||
public DBCreateTableException(String tableName, String message, Throwable cause) {
|
|
||||||
super(tableName + ": " + message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DBCreateTableException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,7 @@ import com.djrapitops.plan.system.processing.processors.info.InspectCacheRequest
|
|||||||
import com.djrapitops.plan.system.settings.Permissions;
|
import com.djrapitops.plan.system.settings.Permissions;
|
||||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||||
|
import com.djrapitops.plan.system.webserver.WebServer;
|
||||||
import com.djrapitops.plan.utilities.Condition;
|
import com.djrapitops.plan.utilities.Condition;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||||
@ -75,7 +76,7 @@ public class InspectCommand extends SubCommand {
|
|||||||
if (!Condition.isTrue(activeDB.check().isPlayerRegistered(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) {
|
if (!Condition.isTrue(activeDB.check().isPlayerRegistered(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) {
|
if (CommandUtils.isPlayer(sender) && WebServer.getInstance().isAuthRequired()) {
|
||||||
boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName());
|
boolean senderHasWebUser = activeDB.check().doesWebUserExists(sender.getName());
|
||||||
|
|
||||||
if (!senderHasWebUser) {
|
if (!senderHasWebUser) {
|
||||||
|
@ -58,7 +58,7 @@ public class ManageHotswapCommand extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Condition.isTrue(dbName.equals(plugin.getDB().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
|
if (Condition.isTrue(dbName.equals(Database.getActive().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class ManageMoveCommand extends SubCommand {
|
|||||||
|
|
||||||
ManageUtils.clearAndCopy(toDatabase, fromDatabase);
|
ManageUtils.clearAndCopy(toDatabase, fromDatabase);
|
||||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString());
|
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString());
|
||||||
boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName());
|
boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), Database.getActive().getConfigName());
|
||||||
Condition.isTrue(!movedToCurrentDatabase, Locale.get(Msg.MANAGE_INFO_CONFIG_REMINDER).toString(), sender);
|
Condition.isTrue(!movedToCurrentDatabase, Locale.get(Msg.MANAGE_INFO_CONFIG_REMINDER).toString(), sender);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
|
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
|
||||||
|
@ -85,7 +85,7 @@ public class ManageRemoveCommand extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(plugin.getDB().getConfigName()));
|
message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(Database.getActive().getConfigName()));
|
||||||
if (!Condition.isTrue(Verify.contains("-a", args), message, sender)) {
|
if (!Condition.isTrue(Verify.contains("-a", args), message, sender)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public class ManageRemoveCommand extends SubCommand {
|
|||||||
SessionCache.getActiveSessions().remove(uuid);
|
SessionCache.getActiveSessions().remove(uuid);
|
||||||
SessionCache.getInstance().cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name()));
|
SessionCache.getInstance().cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name()));
|
||||||
}
|
}
|
||||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName()));
|
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, Database.getActive().getConfigName()));
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
||||||
|
@ -10,6 +10,7 @@ import com.djrapitops.plan.system.settings.Permissions;
|
|||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||||
|
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||||
import com.djrapitops.plan.utilities.Condition;
|
import com.djrapitops.plan.utilities.Condition;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.command.CommandType;
|
import com.djrapitops.plugin.command.CommandType;
|
||||||
@ -52,7 +53,7 @@ public class ManageSetupCommand extends SubCommand {
|
|||||||
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
|
if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plugin.getWebServer().isEnabled()) {
|
if (!WebServerSystem.isWebServerEnabled()) {
|
||||||
sender.sendMessage("§cWebServer is not enabled on this server! Make sure it enables on boot!");
|
sender.sendMessage("§cWebServer is not enabled on this server! Make sure it enables on boot!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,16 +24,16 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class HealthNotes {
|
public class HealthNotes {
|
||||||
|
|
||||||
private final List<String> healthNotes;
|
private final List<String> notes;
|
||||||
private final AnalysisData analysisData;
|
private final AnalysisData analysisData;
|
||||||
private final TreeMap<Long, Map<String, Set<UUID>>> activityData;
|
private final SortedMap<Long, Map<String, Set<UUID>>> activityData;
|
||||||
private final List<TPS> tpsDataMonth;
|
private final List<TPS> tpsDataMonth;
|
||||||
private final long now;
|
private final long now;
|
||||||
private final long fourWeeksAgo;
|
private final long fourWeeksAgo;
|
||||||
private double serverHealth;
|
private double serverHealth;
|
||||||
|
|
||||||
public HealthNotes(AnalysisData analysisData, TreeMap<Long, Map<String, Set<UUID>>> activityData, List<TPS> tpsDataMonth, long now) {
|
public HealthNotes(AnalysisData analysisData, SortedMap<Long, Map<String, Set<UUID>>> activityData, List<TPS> tpsDataMonth, long now) {
|
||||||
this.healthNotes = new ArrayList<>();
|
this.notes = new ArrayList<>();
|
||||||
serverHealth = 100.0;
|
serverHealth = 100.0;
|
||||||
|
|
||||||
this.analysisData = analysisData;
|
this.analysisData = analysisData;
|
||||||
@ -52,7 +52,7 @@ public class HealthNotes {
|
|||||||
|
|
||||||
public String parse() {
|
public String parse() {
|
||||||
StringBuilder healthNoteBuilder = new StringBuilder();
|
StringBuilder healthNoteBuilder = new StringBuilder();
|
||||||
for (String healthNote : healthNotes) {
|
for (String healthNote : notes) {
|
||||||
healthNoteBuilder.append(healthNote);
|
healthNoteBuilder.append(healthNote);
|
||||||
}
|
}
|
||||||
return healthNoteBuilder.toString();
|
return healthNoteBuilder.toString();
|
||||||
@ -105,20 +105,20 @@ public class HealthNotes {
|
|||||||
+ remain + "/" + activeFWAGNum + ")";
|
+ remain + "/" + activeFWAGNum + ")";
|
||||||
}
|
}
|
||||||
if (change > 0) {
|
if (change > 0) {
|
||||||
healthNotes.add(
|
notes.add(
|
||||||
"<p>" + Html.GREEN_THUMB.parse() + " Number of regular players has increased (+" + change + ")<br>" +
|
"<p>" + Html.GREEN_THUMB.parse() + " Number of regular players has increased (+" + change + ")<br>" +
|
||||||
remainNote + "</p>");
|
remainNote + "</p>");
|
||||||
} else if (change == 0) {
|
} else if (change == 0) {
|
||||||
healthNotes.add(
|
notes.add(
|
||||||
"<p>" + Html.GREEN_THUMB.parse() + " Number of regular players has stayed the same (+" + change + ")<br>" +
|
"<p>" + Html.GREEN_THUMB.parse() + " Number of regular players has stayed the same (+" + change + ")<br>" +
|
||||||
remainNote + "</p>");
|
remainNote + "</p>");
|
||||||
} else if (change > -20) {
|
} else if (change > -20) {
|
||||||
healthNotes.add(
|
notes.add(
|
||||||
"<p>" + Html.YELLOW_FLAG.parse() + " Number of regular players has decreased (" + change + ")<br>" +
|
"<p>" + Html.YELLOW_FLAG.parse() + " Number of regular players has decreased (" + change + ")<br>" +
|
||||||
remainNote + "</p>");
|
remainNote + "</p>");
|
||||||
serverHealth -= 5;
|
serverHealth -= 5;
|
||||||
} else {
|
} else {
|
||||||
healthNotes.add(
|
notes.add(
|
||||||
"<p>" + Html.RED_WARN.parse() + " Number of regular players has decreased (" + change + ")<br>" +
|
"<p>" + Html.RED_WARN.parse() + " Number of regular players has decreased (" + change + ")<br>" +
|
||||||
remainNote + "</p>");
|
remainNote + "</p>");
|
||||||
serverHealth -= 10;
|
serverHealth -= 10;
|
||||||
@ -128,10 +128,10 @@ public class HealthNotes {
|
|||||||
private void newPlayerNote() {
|
private void newPlayerNote() {
|
||||||
double avgOnlineOnRegister = MathUtils.averageInt(analysisData.getStickyMonthData().stream().map(StickyData::getOnlineOnJoin));
|
double avgOnlineOnRegister = MathUtils.averageInt(analysisData.getStickyMonthData().stream().map(StickyData::getOnlineOnJoin));
|
||||||
if (avgOnlineOnRegister >= 1) {
|
if (avgOnlineOnRegister >= 1) {
|
||||||
healthNotes.add("<p>" + Html.GREEN_THUMB.parse() + " New Players have players to play with when they join ("
|
notes.add("<p>" + Html.GREEN_THUMB.parse() + " New Players have players to play with when they join ("
|
||||||
+ FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)</p>");
|
+ FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)</p>");
|
||||||
} else {
|
} else {
|
||||||
healthNotes.add("<p>" + Html.YELLOW_FLAG.parse() + " New Players may not have players to play with when they join ("
|
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " New Players may not have players to play with when they join ("
|
||||||
+ FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)</p>");
|
+ FormatUtils.cutDecimals(avgOnlineOnRegister) + " on average)</p>");
|
||||||
serverHealth -= 5;
|
serverHealth -= 5;
|
||||||
}
|
}
|
||||||
@ -142,10 +142,10 @@ public class HealthNotes {
|
|||||||
if (newM != 0) {
|
if (newM != 0) {
|
||||||
double stuckPerc = MathUtils.averageDouble(stuckPerM, newM) * 100;
|
double stuckPerc = MathUtils.averageDouble(stuckPerM, newM) * 100;
|
||||||
if (stuckPerc >= 25) {
|
if (stuckPerc >= 25) {
|
||||||
healthNotes.add("<p>" + Html.GREEN_THUMB.parse() + " " + FormatUtils.cutDecimals(stuckPerc)
|
notes.add("<p>" + Html.GREEN_THUMB.parse() + " " + FormatUtils.cutDecimals(stuckPerc)
|
||||||
+ "% of new players have stuck around (" + stuckPerM + "/" + newM + ")</p>");
|
+ "% of new players have stuck around (" + stuckPerM + "/" + newM + ")</p>");
|
||||||
} else {
|
} else {
|
||||||
healthNotes.add("<p>" + Html.YELLOW_FLAG.parse() + " " + FormatUtils.cutDecimals(stuckPerc)
|
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " " + FormatUtils.cutDecimals(stuckPerc)
|
||||||
+ "% of new players have stuck around (" + stuckPerM + "/" + newM + ")</p>");
|
+ "% of new players have stuck around (" + stuckPerM + "/" + newM + ")</p>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,16 +171,16 @@ public class HealthNotes {
|
|||||||
String avgLastTwoWeeksString = FormatUtils.formatTimeAmount(avgLastTwoWeeks);
|
String avgLastTwoWeeksString = FormatUtils.formatTimeAmount(avgLastTwoWeeks);
|
||||||
String avgFourToTwoWeeksString = FormatUtils.formatTimeAmount(avgFourToTwoWeeks);
|
String avgFourToTwoWeeksString = FormatUtils.formatTimeAmount(avgFourToTwoWeeks);
|
||||||
if (avgFourToTwoWeeks >= avgLastTwoWeeks) {
|
if (avgFourToTwoWeeks >= avgLastTwoWeeks) {
|
||||||
healthNotes.add("<p>" + Html.GREEN_THUMB.parse() + " Active players seem to have things to do (Played "
|
notes.add("<p>" + Html.GREEN_THUMB.parse() + " Active players seem to have things to do (Played "
|
||||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||||
+ ", last two weeks vs weeks 2-4)</p>");
|
+ ", last two weeks vs weeks 2-4)</p>");
|
||||||
} else if (avgFourToTwoWeeks - avgLastTwoWeeks > TimeAmount.HOUR.ms() * 2L) {
|
} else if (avgFourToTwoWeeks - avgLastTwoWeeks > TimeAmount.HOUR.ms() * 2L) {
|
||||||
healthNotes.add("<p>" + Html.RED_WARN.parse() + " Active players might be running out of things to do (Played "
|
notes.add("<p>" + Html.RED_WARN.parse() + " Active players might be running out of things to do (Played "
|
||||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||||
+ ", last two weeks vs weeks 2-4)</p>");
|
+ ", last two weeks vs weeks 2-4)</p>");
|
||||||
serverHealth -= 5;
|
serverHealth -= 5;
|
||||||
} else {
|
} else {
|
||||||
healthNotes.add("<p>" + Html.YELLOW_FLAG.parse() + " Active players might be running out of things to do (Played "
|
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " Active players might be running out of things to do (Played "
|
||||||
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
+ avgLastTwoWeeksString + " vs " + avgFourToTwoWeeksString
|
||||||
+ ", last two weeks vs weeks 2-4)</p>");
|
+ ", last two weeks vs weeks 2-4)</p>");
|
||||||
}
|
}
|
||||||
@ -206,18 +206,18 @@ public class HealthNotes {
|
|||||||
+ FormatUtils.cutDecimals(aboveThreshold * 100.0) + "% of the time";
|
+ FormatUtils.cutDecimals(aboveThreshold * 100.0) + "% of the time";
|
||||||
|
|
||||||
if (tpsSpikeMonth <= 5) {
|
if (tpsSpikeMonth <= 5) {
|
||||||
healthNotes.add("<p>" + Html.GREEN_THUMB.parse()
|
notes.add("<p>" + Html.GREEN_THUMB.parse()
|
||||||
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
||||||
" " + tpsSpikeMonth + " times<br>" +
|
" " + tpsSpikeMonth + " times<br>" +
|
||||||
avgLowThresholdString + "</p>");
|
avgLowThresholdString + "</p>");
|
||||||
} else if (tpsSpikeMonth <= 25) {
|
} else if (tpsSpikeMonth <= 25) {
|
||||||
healthNotes.add("<p>" + Html.YELLOW_FLAG.parse()
|
notes.add("<p>" + Html.YELLOW_FLAG.parse()
|
||||||
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
||||||
" " + tpsSpikeMonth + " times<br>" +
|
" " + tpsSpikeMonth + " times<br>" +
|
||||||
avgLowThresholdString + "</p>");
|
avgLowThresholdString + "</p>");
|
||||||
serverHealth *= 0.95;
|
serverHealth *= 0.95;
|
||||||
} else {
|
} else {
|
||||||
healthNotes.add("<p>" + Html.RED_WARN.parse()
|
notes.add("<p>" + Html.RED_WARN.parse()
|
||||||
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
+ " Average TPS dropped below Low Threshold (" + Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber() + ")" +
|
||||||
" " + tpsSpikeMonth + " times<br>" +
|
" " + tpsSpikeMonth + " times<br>" +
|
||||||
avgLowThresholdString + "</p>");
|
avgLowThresholdString + "</p>");
|
||||||
@ -225,14 +225,14 @@ public class HealthNotes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (serverDownTime <= TimeAmount.DAY.ms()) {
|
if (serverDownTime <= TimeAmount.DAY.ms()) {
|
||||||
healthNotes.add("<p>" + Html.GREEN_THUMB.parse() + " Total Server downtime (No Data) was "
|
notes.add("<p>" + Html.GREEN_THUMB.parse() + " Total Server downtime (No Data) was "
|
||||||
+ FormatUtils.formatTimeAmount(serverDownTime) + "</p>");
|
+ FormatUtils.formatTimeAmount(serverDownTime) + "</p>");
|
||||||
} else if (serverDownTime <= TimeAmount.WEEK.ms()) {
|
} else if (serverDownTime <= TimeAmount.WEEK.ms()) {
|
||||||
healthNotes.add("<p>" + Html.YELLOW_FLAG.parse() + " Total Server downtime (No Data) was "
|
notes.add("<p>" + Html.YELLOW_FLAG.parse() + " Total Server downtime (No Data) was "
|
||||||
+ FormatUtils.formatTimeAmount(serverDownTime) + "</p>");
|
+ FormatUtils.formatTimeAmount(serverDownTime) + "</p>");
|
||||||
serverHealth *= (TimeAmount.WEEK.ms() - serverDownTime) * 1.0 / TimeAmount.WEEK.ms();
|
serverHealth *= (TimeAmount.WEEK.ms() - serverDownTime) * 1.0 / TimeAmount.WEEK.ms();
|
||||||
} else {
|
} else {
|
||||||
healthNotes.add("<p>" + Html.RED_WARN.parse() + " Total Server downtime (No Data) was "
|
notes.add("<p>" + Html.RED_WARN.parse() + " Total Server downtime (No Data) was "
|
||||||
+ FormatUtils.formatTimeAmount(serverDownTime) + "</p>");
|
+ FormatUtils.formatTimeAmount(serverDownTime) + "</p>");
|
||||||
serverHealth *= (TimeAmount.MONTH.ms() - serverDownTime) * 1.0 / TimeAmount.MONTH.ms();
|
serverHealth *= (TimeAmount.MONTH.ms() - serverDownTime) * 1.0 / TimeAmount.MONTH.ms();
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,11 @@ public class InspectContainer {
|
|||||||
return html.toString();
|
return html.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if InspectContainer has only values, and not HTML or Tables.
|
||||||
|
*
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
public final boolean hasOnlyValues() {
|
public final boolean hasOnlyValues() {
|
||||||
return html.isEmpty() && tables.isEmpty();
|
return html.isEmpty() && tables.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ public class SQLiteDB extends SQLDB {
|
|||||||
|
|
||||||
String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath();
|
String dbFilePath = new File(PlanPlugin.getInstance().getDataFolder(), dbName + ".db").getAbsolutePath();
|
||||||
|
|
||||||
Connection connection = getConnectionFor(dbFilePath);
|
Connection newConnection = getConnectionFor(dbFilePath);
|
||||||
connection.setAutoCommit(false);
|
newConnection.setAutoCommit(false);
|
||||||
return connection;
|
return newConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection getConnectionFor(String dbFilePath) throws SQLException {
|
private Connection getConnectionFor(String dbFilePath) throws SQLException {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.Actions;
|
import com.djrapitops.plan.data.Actions;
|
||||||
import com.djrapitops.plan.data.container.Action;
|
import com.djrapitops.plan.data.container.Action;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
@ -38,10 +38,10 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class ActionsTable extends UserIDTable {
|
public class ActionsTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnServerID = "server_id";
|
private static final String columnServerID = "server_id";
|
||||||
private final String columnDate = "date";
|
private static final String columnDate = "date";
|
||||||
private final String columnActionID = "action_id";
|
private static final String columnActionID = "action_id";
|
||||||
private final String columnAdditionalInfo = "additional_info";
|
private static final String columnAdditionalInfo = "additional_info";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -62,7 +62,7 @@ public class ActionsTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
ServerTable serverTable = db.getServerTable();
|
ServerTable serverTable = db.getServerTable();
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnUserID, Sql.INT).notNull()
|
.column(columnUserID, Sql.INT).notNull()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -23,10 +23,10 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class CommandUseTable extends Table {
|
public class CommandUseTable extends Table {
|
||||||
|
|
||||||
private final String columnCommandId = "id";
|
private static final String columnCommandId = "id";
|
||||||
private final String columnCommand = "command";
|
private static final String columnCommand = "command";
|
||||||
private final String columnTimesUsed = "times_used";
|
private static final String columnTimesUsed = "times_used";
|
||||||
private final String columnServerID = "server_id";
|
private static final String columnServerID = "server_id";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -42,7 +42,7 @@ public class CommandUseTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
ServerTable serverTable = db.getServerTable();
|
ServerTable serverTable = db.getServerTable();
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.primaryKeyIDColumn(usingMySQL, columnCommandId)
|
.primaryKeyIDColumn(usingMySQL, columnCommandId)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.GeoInfo;
|
import com.djrapitops.plan.data.container.GeoInfo;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
@ -21,9 +21,9 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class GeoInfoTable extends UserIDTable {
|
public class GeoInfoTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnIP = "ip";
|
private static final String columnIP = "ip";
|
||||||
private final String columnGeolocation = "geolocation";
|
private static final String columnGeolocation = "geolocation";
|
||||||
private final String columnLastUsed = "last_used";
|
private static final String columnLastUsed = "last_used";
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
|
|
||||||
public GeoInfoTable(SQLDB db) {
|
public GeoInfoTable(SQLDB db) {
|
||||||
@ -39,7 +39,7 @@ public class GeoInfoTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnUserID, Sql.INT).notNull()
|
.column(columnUserID, Sql.INT).notNull()
|
||||||
.column(columnIP, Sql.varchar(39)).notNull()
|
.column(columnIP, Sql.varchar(39)).notNull()
|
||||||
@ -111,7 +111,6 @@ public class GeoInfoTable extends UserIDTable {
|
|||||||
" AND " + columnIP + "=?" +
|
" AND " + columnIP + "=?" +
|
||||||
" AND " + columnGeolocation + "=?";
|
" AND " + columnGeolocation + "=?";
|
||||||
|
|
||||||
|
|
||||||
execute(new ExecStatement(sql) {
|
execute(new ExecStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.PlayerKill;
|
import com.djrapitops.plan.data.container.PlayerKill;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
@ -21,11 +21,11 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class KillsTable extends UserIDTable {
|
public class KillsTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnKillerUserID = "killer_id";
|
private static final String columnKillerUserID = "killer_id";
|
||||||
private final String columnVictimUserID = "victim_id";
|
private static final String columnVictimUserID = "victim_id";
|
||||||
private final String columnWeapon = "weapon";
|
private static final String columnWeapon = "weapon";
|
||||||
private final String columnDate = "date";
|
private static final String columnDate = "date";
|
||||||
private final String columnSessionID = "session_id";
|
private static final String columnSessionID = "session_id";
|
||||||
|
|
||||||
private final SessionsTable sessionsTable;
|
private final SessionsTable sessionsTable;
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -46,7 +46,7 @@ public class KillsTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnKillerUserID, Sql.INT).notNull()
|
.column(columnKillerUserID, Sql.INT).notNull()
|
||||||
.column(columnVictimUserID, Sql.INT).notNull()
|
.column(columnVictimUserID, Sql.INT).notNull()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -20,8 +20,8 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class NicknamesTable extends UserIDTable {
|
public class NicknamesTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnNick = "nickname";
|
private static final String columnNick = "nickname";
|
||||||
private final String columnServerID = "server_id";
|
private static final String columnServerID = "server_id";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -40,7 +40,7 @@ public class NicknamesTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnUserID, Sql.INT).notNull()
|
.column(columnUserID, Sql.INT).notNull()
|
||||||
.column(columnNick, Sql.varchar(75)).notNull()
|
.column(columnNick, Sql.varchar(75)).notNull()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.WebUser;
|
import com.djrapitops.plan.data.WebUser;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
@ -28,9 +28,9 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class SecurityTable extends Table {
|
public class SecurityTable extends Table {
|
||||||
|
|
||||||
private final String columnUser = "username";
|
private static final String columnUser = "username";
|
||||||
private final String columnSaltedHash = "salted_pass_hash";
|
private static final String columnSaltedHash = "salted_pass_hash";
|
||||||
private final String columnPermLevel = "permission_level";
|
private static final String columnPermLevel = "permission_level";
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
|
|
||||||
public SecurityTable(SQLDB db) {
|
public SecurityTable(SQLDB db) {
|
||||||
@ -42,7 +42,7 @@ public class SecurityTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnUser, Sql.varchar(100)).notNull().unique()
|
.column(columnUser, Sql.varchar(100)).notNull().unique()
|
||||||
.column(columnSaltedHash, Sql.varchar(100)).notNull().unique()
|
.column(columnSaltedHash, Sql.varchar(100)).notNull().unique()
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -37,12 +37,12 @@ public class ServerTable extends Table {
|
|||||||
|
|
||||||
public final String statementSelectServerID;
|
public final String statementSelectServerID;
|
||||||
public final String statementSelectServerNameID;
|
public final String statementSelectServerNameID;
|
||||||
private final String columnServerID = "id";
|
private static final String columnServerID = "id";
|
||||||
private final String columnServerUUID = "uuid";
|
private static final String columnServerUUID = "uuid";
|
||||||
private final String columnServerName = "name";
|
private static final String columnServerName = "name";
|
||||||
private final String columnWebserverAddress = "web_address";
|
private static final String columnWebserverAddress = "web_address";
|
||||||
private final String columnInstalled = "is_installed";
|
private static final String columnInstalled = "is_installed";
|
||||||
private final String columnMaxPlayers = "max_players";
|
private static final String columnMaxPlayers = "max_players";
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
|
|
||||||
public ServerTable(SQLDB db) {
|
public ServerTable(SQLDB db) {
|
||||||
@ -58,7 +58,7 @@ public class ServerTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.primaryKeyIDColumn(usingMySQL, columnServerID)
|
.primaryKeyIDColumn(usingMySQL, columnServerID)
|
||||||
.column(columnServerUUID, Sql.varchar(36)).notNull().unique()
|
.column(columnServerUUID, Sql.varchar(36)).notNull().unique()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
@ -24,12 +24,12 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class SessionsTable extends UserIDTable {
|
public class SessionsTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnID = "id";
|
private static final String columnID = "id";
|
||||||
private final String columnSessionStart = "session_start";
|
private static final String columnSessionStart = "session_start";
|
||||||
private final String columnSessionEnd = "session_end";
|
private static final String columnSessionEnd = "session_end";
|
||||||
private final String columnServerID = "server_id";
|
private static final String columnServerID = "server_id";
|
||||||
private final String columnMobKills = "mob_kills";
|
private static final String columnMobKills = "mob_kills";
|
||||||
private final String columnDeaths = "deaths";
|
private static final String columnDeaths = "deaths";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -51,7 +51,7 @@ public class SessionsTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(this.tableName)
|
createTable(TableSqlParser.createTable(this.tableName)
|
||||||
.primaryKeyIDColumn(usingMySQL, columnID)
|
.primaryKeyIDColumn(usingMySQL, columnID)
|
||||||
.column(columnUserID, Sql.INT).notNull()
|
.column(columnUserID, Sql.INT).notNull()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
@ -28,14 +28,14 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class TPSTable extends Table {
|
public class TPSTable extends Table {
|
||||||
|
|
||||||
private final String columnServerID = "server_id";
|
private static final String columnServerID = "server_id";
|
||||||
private final String columnDate = "date";
|
private static final String columnDate = "date";
|
||||||
private final String columnTPS = "tps";
|
private static final String columnTPS = "tps";
|
||||||
private final String columnPlayers = "players_online";
|
private static final String columnPlayers = "players_online";
|
||||||
private final String columnCPUUsage = "cpu_usage";
|
private static final String columnCPUUsage = "cpu_usage";
|
||||||
private final String columnRAMUsage = "ram_usage";
|
private static final String columnRAMUsage = "ram_usage";
|
||||||
private final String columnEntities = "entities";
|
private static final String columnEntities = "entities";
|
||||||
private final String columnChunksLoaded = "chunks_loaded";
|
private static final String columnChunksLoaded = "chunks_loaded";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -58,7 +58,7 @@ public class TPSTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnServerID, Sql.INT).notNull()
|
.column(columnServerID, Sql.INT).notNull()
|
||||||
.column(columnDate, Sql.LONG).notNull()
|
.column(columnDate, Sql.LONG).notNull()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||||
@ -50,13 +50,13 @@ public abstract class Table {
|
|||||||
this.usingMySQL = db.isUsingMySQL();
|
this.usingMySQL = db.isUsingMySQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void createTable() throws DBCreateTableException;
|
public abstract void createTable() throws DBInitException;
|
||||||
|
|
||||||
protected void createTable(String sql) throws DBCreateTableException {
|
protected void createTable(String sql) throws DBInitException {
|
||||||
try {
|
try {
|
||||||
execute(sql);
|
execute(sql);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DBCreateTableException(tableName, "Failed to create table", e);
|
throw new DBInitException("Failed to create table: " + tableName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||||
@ -33,16 +33,16 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class TransferTable extends Table {
|
public class TransferTable extends Table {
|
||||||
|
|
||||||
private final String columnSenderID = "sender_server_id";
|
private static final String columnSenderID = "sender_server_id";
|
||||||
private final String columnExpiry = "expiry_date";
|
private static final String columnExpiry = "expiry_date";
|
||||||
private final String columnInfoType = "type";
|
private static final String columnInfoType = "type";
|
||||||
private final String columnContent = "content_64";
|
private static final String columnContent = "content_64";
|
||||||
private final String columnExtraVariables = "extra_variables";
|
private static final String columnExtraVariables = "extra_variables";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
|
|
||||||
private final String insertStatement;
|
private final String insertStatement;
|
||||||
private String selectStatement;
|
private final String selectStatement;
|
||||||
|
|
||||||
public TransferTable(SQLDB db) {
|
public TransferTable(SQLDB db) {
|
||||||
super("plan_transfer", db);
|
super("plan_transfer", db);
|
||||||
@ -64,7 +64,7 @@ public class TransferTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnSenderID, Sql.INT).notNull()
|
.column(columnSenderID, Sql.INT).notNull()
|
||||||
.column(columnExpiry, Sql.LONG).notNull().defaultValue("0")
|
.column(columnExpiry, Sql.LONG).notNull().defaultValue("0")
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.UserInfo;
|
import com.djrapitops.plan.data.container.UserInfo;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
@ -31,10 +31,10 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class UserInfoTable extends UserIDTable {
|
public class UserInfoTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnRegistered = "registered";
|
private static final String columnRegistered = "registered";
|
||||||
private final String columnOP = "opped";
|
private static final String columnOP = "opped";
|
||||||
private final String columnBanned = "banned";
|
private static final String columnBanned = "banned";
|
||||||
private final String columnServerID = "server_id";
|
private static final String columnServerID = "server_id";
|
||||||
|
|
||||||
private final ServerTable serverTable;
|
private final ServerTable serverTable;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ public class UserInfoTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnUserID, Sql.INT).notNull()
|
.column(columnUserID, Sql.INT).notNull()
|
||||||
.column(columnRegistered, Sql.LONG).notNull()
|
.column(columnRegistered, Sql.LONG).notNull()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.UserInfo;
|
import com.djrapitops.plan.data.container.UserInfo;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
@ -20,11 +20,11 @@ import java.util.*;
|
|||||||
public class UsersTable extends UserIDTable {
|
public class UsersTable extends UserIDTable {
|
||||||
|
|
||||||
public final String statementSelectID;
|
public final String statementSelectID;
|
||||||
private final String columnID = "id";
|
private static final String columnID = "id";
|
||||||
private final String columnUUID = "uuid";
|
private static final String columnUUID = "uuid";
|
||||||
private final String columnRegistered = "registered";
|
private static final String columnRegistered = "registered";
|
||||||
private final String columnName = "name";
|
private static final String columnName = "name";
|
||||||
private final String columnTimesKicked = "times_kicked";
|
private static final String columnTimesKicked = "times_kicked";
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
|
|
||||||
public UsersTable(SQLDB db) {
|
public UsersTable(SQLDB db) {
|
||||||
@ -37,7 +37,7 @@ public class UsersTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.primaryKeyIDColumn(usingMySQL, columnID)
|
.primaryKeyIDColumn(usingMySQL, columnID)
|
||||||
.column(columnUUID, Sql.varchar(36)).notNull().unique()
|
.column(columnUUID, Sql.varchar(36)).notNull().unique()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -22,7 +22,7 @@ public class VersionTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column("version", Sql.INT).notNull()
|
.column("version", Sql.INT).notNull()
|
||||||
.toString()
|
.toString()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -26,8 +26,8 @@ import java.util.*;
|
|||||||
public class WorldTable extends Table {
|
public class WorldTable extends Table {
|
||||||
|
|
||||||
public final String statementSelectID;
|
public final String statementSelectID;
|
||||||
private final String columnWorldId = "id";
|
private static final String columnWorldId = "id";
|
||||||
private final String columnWorldName = "world_name";
|
private static final String columnWorldName = "world_name";
|
||||||
|
|
||||||
public WorldTable(SQLDB db) {
|
public WorldTable(SQLDB db) {
|
||||||
super("plan_worlds", db);
|
super("plan_worlds", db);
|
||||||
@ -35,7 +35,7 @@ public class WorldTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.primaryKeyIDColumn(usingMySQL, columnWorldId)
|
.primaryKeyIDColumn(usingMySQL, columnWorldId)
|
||||||
.column(columnWorldName, Sql.varchar(100)).notNull()
|
.column(columnWorldName, Sql.varchar(100)).notNull()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.djrapitops.plan.system.database.databases.sql.tables;
|
package com.djrapitops.plan.system.database.databases.sql.tables;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.data.time.GMTimes;
|
import com.djrapitops.plan.data.time.GMTimes;
|
||||||
import com.djrapitops.plan.data.time.WorldTimes;
|
import com.djrapitops.plan.data.time.WorldTimes;
|
||||||
@ -27,12 +27,12 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class WorldTimesTable extends UserIDTable {
|
public class WorldTimesTable extends UserIDTable {
|
||||||
|
|
||||||
private final String columnSessionID = "session_id";
|
private static final String columnSessionID = "session_id";
|
||||||
private final String columnWorldId = "world_id";
|
private static final String columnWorldId = "world_id";
|
||||||
private final String columnSurvival = "survival_time";
|
private static final String columnSurvival = "survival_time";
|
||||||
private final String columnCreative = "creative_time";
|
private static final String columnCreative = "creative_time";
|
||||||
private final String columnAdventure = "adventure_time";
|
private static final String columnAdventure = "adventure_time";
|
||||||
private final String columnSpectator = "spectator_time";
|
private static final String columnSpectator = "spectator_time";
|
||||||
|
|
||||||
private final WorldTable worldTable;
|
private final WorldTable worldTable;
|
||||||
private final SessionsTable sessionsTable;
|
private final SessionsTable sessionsTable;
|
||||||
@ -57,7 +57,7 @@ public class WorldTimesTable extends UserIDTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable(TableSqlParser.createTable(tableName)
|
createTable(TableSqlParser.createTable(tableName)
|
||||||
.column(columnUserID, Sql.INT).notNull()
|
.column(columnUserID, Sql.INT).notNull()
|
||||||
.column(columnWorldId, Sql.INT).notNull()
|
.column(columnWorldId, Sql.INT).notNull()
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.database.databases.sql.tables.move;
|
package com.djrapitops.plan.system.database.databases.sql.tables.move;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
@ -48,7 +48,7 @@ public class Version8TransferTable extends Table {
|
|||||||
return "DROP TABLE " + name;
|
return "DROP TABLE " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alterTablesToV10() throws SQLException, DBCreateTableException {
|
public void alterTablesToV10() throws SQLException, DBInitException {
|
||||||
Benchmark.start("Schema copy from 8 to 10");
|
Benchmark.start("Schema copy from 8 to 10");
|
||||||
copyCommandUsage();
|
copyCommandUsage();
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public class Version8TransferTable extends Table {
|
|||||||
Benchmark.stop("Schema copy from 8 to 10");
|
Benchmark.stop("Schema copy from 8 to 10");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyUsers() throws SQLException, DBCreateTableException {
|
private void copyUsers() throws SQLException, DBInitException {
|
||||||
String tempTableName = "temp_users";
|
String tempTableName = "temp_users";
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
execute(tableRenameSql("plan_users", tempTableName));
|
execute(tableRenameSql("plan_users", tempTableName));
|
||||||
@ -137,7 +137,7 @@ public class Version8TransferTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyCommandUsage() throws SQLException, DBCreateTableException {
|
private void copyCommandUsage() throws SQLException, DBInitException {
|
||||||
String tempTableName = "temp_cmdusg";
|
String tempTableName = "temp_cmdusg";
|
||||||
CommandUseTable commandUseTable = db.getCommandUseTable();
|
CommandUseTable commandUseTable = db.getCommandUseTable();
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public class Version8TransferTable extends Table {
|
|||||||
execute(dropTableSql(tempTableName));
|
execute(dropTableSql(tempTableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyTPS() throws SQLException, DBCreateTableException {
|
private void copyTPS() throws SQLException, DBInitException {
|
||||||
String tempTableName = "temp_tps";
|
String tempTableName = "temp_tps";
|
||||||
TPSTable tpsTable = db.getTpsTable();
|
TPSTable tpsTable = db.getTpsTable();
|
||||||
|
|
||||||
|
@ -27,15 +27,15 @@ public class UserImportRefiner {
|
|||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
private final boolean onlineMode;
|
private final boolean onlineMode;
|
||||||
|
|
||||||
private final List<UserImportData> importers = new Vector<>();
|
private final List<UserImportData> importers = new ArrayList<>();
|
||||||
|
|
||||||
private final Map<String, Boolean> worlds = new Hashtable<>();
|
private final Map<String, Boolean> worlds = new HashMap<>();
|
||||||
|
|
||||||
private final Map<UserImportData, String> uuidsMissing = new Hashtable<>();
|
private final Map<UserImportData, String> uuidsMissing = new HashMap<>();
|
||||||
private final Map<UserImportData, String> namesMissing = new Hashtable<>();
|
private final Map<UserImportData, String> namesMissing = new HashMap<>();
|
||||||
|
|
||||||
private final Map<UserImportData, String> foundUUIDs = new Hashtable<>();
|
private final Map<UserImportData, String> foundUUIDs = new HashMap<>();
|
||||||
private final Map<UserImportData, String> foundNames = new Hashtable<>();
|
private final Map<UserImportData, String> foundNames = new HashMap<>();
|
||||||
|
|
||||||
public UserImportRefiner(Plan plugin, List<UserImportData> importers) {
|
public UserImportRefiner(Plan plugin, List<UserImportData> importers) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -92,7 +92,7 @@ public class UserImportRefiner {
|
|||||||
|
|
||||||
Benchmark.start(benchmarkName);
|
Benchmark.start(benchmarkName);
|
||||||
|
|
||||||
List<UserImportData> invalidData = new Vector<>();
|
List<UserImportData> invalidData = new ArrayList<>();
|
||||||
|
|
||||||
importers.parallelStream().forEach(importer -> {
|
importers.parallelStream().forEach(importer -> {
|
||||||
String name = importer.getName();
|
String name = importer.getName();
|
||||||
@ -161,7 +161,7 @@ public class UserImportRefiner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addMissingUUIDsOverOfflinePlayer() {
|
private void addMissingUUIDsOverOfflinePlayer() {
|
||||||
Map<String, String> result = new Hashtable<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
|
|
||||||
for (String name : uuidsMissing.values()) {
|
for (String name : uuidsMissing.values()) {
|
||||||
String uuid = getUuidByOfflinePlayer(name);
|
String uuid = getUuidByOfflinePlayer(name);
|
||||||
@ -177,7 +177,7 @@ public class UserImportRefiner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addFoundUUIDs(Map<String, String> foundUUIDs) {
|
private void addFoundUUIDs(Map<String, String> foundUUIDs) {
|
||||||
List<UserImportData> found = new Vector<>();
|
List<UserImportData> found = new ArrayList<>();
|
||||||
|
|
||||||
uuidsMissing.entrySet().parallelStream().forEach((entry) -> {
|
uuidsMissing.entrySet().parallelStream().forEach((entry) -> {
|
||||||
UserImportData importer = entry.getKey();
|
UserImportData importer = entry.getKey();
|
||||||
@ -218,7 +218,7 @@ public class UserImportRefiner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addMissingNames() {
|
private void addMissingNames() {
|
||||||
Map<String, String> result = new Hashtable<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
|
|
||||||
namesMissing.values().parallelStream().forEach(uuid -> {
|
namesMissing.values().parallelStream().forEach(uuid -> {
|
||||||
String name = getNameByOfflinePlayer(uuid);
|
String name = getNameByOfflinePlayer(uuid);
|
||||||
@ -230,7 +230,7 @@ public class UserImportRefiner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addFoundNames(Map<String, String> foundNames) {
|
private void addFoundNames(Map<String, String> foundNames) {
|
||||||
List<UserImportData> found = new Vector<>();
|
List<UserImportData> found = new ArrayList<>();
|
||||||
|
|
||||||
namesMissing.entrySet().parallelStream().forEach(entry -> {
|
namesMissing.entrySet().parallelStream().forEach(entry -> {
|
||||||
UserImportData importer = entry.getKey();
|
UserImportData importer = entry.getKey();
|
||||||
|
@ -12,6 +12,7 @@ import com.djrapitops.plan.data.container.UserInfo;
|
|||||||
import com.djrapitops.plan.data.time.WorldTimes;
|
import com.djrapitops.plan.data.time.WorldTimes;
|
||||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
|
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.processing.importing.ServerImportData;
|
import com.djrapitops.plan.system.processing.importing.ServerImportData;
|
||||||
import com.djrapitops.plan.system.processing.importing.UserImportData;
|
import com.djrapitops.plan.system.processing.importing.UserImportData;
|
||||||
@ -49,23 +50,17 @@ public abstract class Importer {
|
|||||||
|
|
||||||
ExecutorService service = Executors.newCachedThreadPool();
|
ExecutorService service = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
submitTo(service, () -> {
|
||||||
@Override
|
Benchmark.start(serverBenchmarkName);
|
||||||
void execute() {
|
processServerData();
|
||||||
Benchmark.start(serverBenchmarkName);
|
Benchmark.stop(serverBenchmarkName);
|
||||||
processServerData();
|
});
|
||||||
Benchmark.stop(serverBenchmarkName);
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
submitTo(service, () -> {
|
||||||
@Override
|
Benchmark.start(userDataBenchmarkName);
|
||||||
void execute() throws DBException {
|
processUserData();
|
||||||
Benchmark.start(userDataBenchmarkName);
|
Benchmark.stop(userDataBenchmarkName);
|
||||||
processUserData();
|
});
|
||||||
Benchmark.stop(userDataBenchmarkName);
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
|
|
||||||
@ -96,27 +91,16 @@ public abstract class Importer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plan plugin = Plan.getInstance();
|
|
||||||
UUID uuid = ServerInfo.getServerUUID();
|
UUID uuid = ServerInfo.getServerUUID();
|
||||||
Database db = plugin.getDB();
|
Database db = Database.getActive();
|
||||||
|
|
||||||
ExecutorService service = Executors.newCachedThreadPool();
|
ExecutorService service = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
Benchmark.start(insertDataIntoDatabaseBenchmarkName);
|
Benchmark.start(insertDataIntoDatabaseBenchmarkName);
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
SaveOperations save = db.save();
|
||||||
@Override
|
submitTo(service, () -> save.insertTPS(ImmutableMap.of(uuid, serverImportData.getTpsData())));
|
||||||
void execute() throws DBException {
|
submitTo(service, () -> save.insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages())));
|
||||||
db.save().insertTPS(ImmutableMap.of(uuid, serverImportData.getTpsData()));
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
|
||||||
@Override
|
|
||||||
void execute() throws DBException {
|
|
||||||
db.save().insertCommandUsage(ImmutableMap.of(uuid, serverImportData.getCommandUsages()));
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
|
|
||||||
@ -148,25 +132,23 @@ public abstract class Importer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plan plugin = Plan.getInstance();
|
UserImportRefiner userImportRefiner = new UserImportRefiner(Plan.getInstance(), userImportData);
|
||||||
|
|
||||||
UserImportRefiner userImportRefiner = new UserImportRefiner(plugin, userImportData);
|
|
||||||
userImportData = userImportRefiner.refineData();
|
userImportData = userImportRefiner.refineData();
|
||||||
|
|
||||||
UUID serverUUID = ServerInfo.getServerUUID();
|
UUID serverUUID = ServerInfo.getServerUUID();
|
||||||
Database db = plugin.getDB();
|
Database db = Database.getActive();
|
||||||
|
|
||||||
Set<UUID> existingUUIDs = db.fetch().getSavedUUIDs();
|
Set<UUID> existingUUIDs = db.fetch().getSavedUUIDs();
|
||||||
Set<UUID> existingUserInfoTableUUIDs = db.fetch().getSavedUUIDs(serverUUID);
|
Set<UUID> existingUserInfoTableUUIDs = db.fetch().getSavedUUIDs(serverUUID);
|
||||||
|
|
||||||
Benchmark.start(insertDataIntoCollectionsBenchmarkName);
|
Benchmark.start(insertDataIntoCollectionsBenchmarkName);
|
||||||
|
|
||||||
Map<UUID, UserInfo> users = new Hashtable<>();
|
Map<UUID, UserInfo> users = new HashMap<>();
|
||||||
List<UserInfo> userInfo = new Vector<>();
|
List<UserInfo> userInfo = new ArrayList<>();
|
||||||
Map<UUID, List<String>> nickNames = new Hashtable<>();
|
Map<UUID, List<String>> nickNames = new HashMap<>();
|
||||||
Map<UUID, List<Session>> sessions = new Hashtable<>();
|
Map<UUID, List<Session>> sessions = new HashMap<>();
|
||||||
Map<UUID, List<GeoInfo>> geoInfo = new Hashtable<>();
|
Map<UUID, List<GeoInfo>> geoInfo = new HashMap<>();
|
||||||
Map<UUID, Integer> timesKicked = new Hashtable<>();
|
Map<UUID, Integer> timesKicked = new HashMap<>();
|
||||||
|
|
||||||
userImportData.parallelStream().forEach(data -> {
|
userImportData.parallelStream().forEach(data -> {
|
||||||
UUID uuid = data.getUuid();
|
UUID uuid = data.getUuid();
|
||||||
@ -192,42 +174,14 @@ public abstract class Importer {
|
|||||||
|
|
||||||
Benchmark.start(insertDataIntoDatabaseBenchmarkName);
|
Benchmark.start(insertDataIntoDatabaseBenchmarkName);
|
||||||
|
|
||||||
db.save().insertUsers(users);
|
SaveOperations save = db.save();
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
save.insertUsers(users);
|
||||||
@Override
|
submitTo(service, () -> save.insertSessions(ImmutableMap.of(serverUUID, sessions), true));
|
||||||
void execute() throws DBException {
|
submitTo(service, () -> save.kickAmount(timesKicked));
|
||||||
db.save().insertSessions(ImmutableMap.of(serverUUID, sessions), true);
|
submitTo(service, () -> save.insertUserInfo(ImmutableMap.of(serverUUID, userInfo)));
|
||||||
}
|
submitTo(service, () -> save.insertNicknames(ImmutableMap.of(serverUUID, nickNames)));
|
||||||
}.submit(service);
|
submitTo(service, () -> save.insertAllGeoInfo(geoInfo));
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
|
||||||
@Override
|
|
||||||
void execute() throws DBException {
|
|
||||||
db.save().kickAmount(timesKicked);
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
|
||||||
@Override
|
|
||||||
void execute() throws DBException {
|
|
||||||
db.save().insertUserInfo(ImmutableMap.of(serverUUID, userInfo));
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
|
||||||
@Override
|
|
||||||
void execute() throws DBException {
|
|
||||||
db.save().insertNicknames(ImmutableMap.of(serverUUID, nickNames));
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
new ImportExecutorHelper() {
|
|
||||||
@Override
|
|
||||||
void execute() throws DBException {
|
|
||||||
db.save().insertAllGeoInfo(geoInfo);
|
|
||||||
}
|
|
||||||
}.submit(service);
|
|
||||||
|
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
|
|
||||||
@ -242,6 +196,10 @@ public abstract class Importer {
|
|||||||
Benchmark.stop(benchmarkName);
|
Benchmark.stop(benchmarkName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void submitTo(ExecutorService service, ImportExecutorHelper helper) {
|
||||||
|
helper.submit(service);
|
||||||
|
}
|
||||||
|
|
||||||
private UserInfo toUserInfo(UserImportData userImportData) {
|
private UserInfo toUserInfo(UserImportData userImportData) {
|
||||||
UUID uuid = userImportData.getUuid();
|
UUID uuid = userImportData.getUuid();
|
||||||
String name = userImportData.getName();
|
String name = userImportData.getName();
|
||||||
@ -274,10 +232,10 @@ public abstract class Importer {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract class ImportExecutorHelper {
|
private interface ImportExecutorHelper {
|
||||||
abstract void execute() throws DBException;
|
void execute() throws DBException;
|
||||||
|
|
||||||
void submit(ExecutorService service) {
|
default void submit(ExecutorService service) {
|
||||||
service.submit(new Runnable() {
|
service.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -9,10 +9,10 @@ import com.djrapitops.plan.system.processing.importing.UserImportData;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fuzzlemann
|
* @author Fuzzlemann
|
||||||
@ -32,7 +32,7 @@ public class OfflinePlayerImporter extends Importer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserImportData> getUserImportData() {
|
public List<UserImportData> getUserImportData() {
|
||||||
List<UserImportData> dataList = new Vector<>();
|
List<UserImportData> dataList = new ArrayList<>();
|
||||||
|
|
||||||
Set<OfflinePlayer> operators = Bukkit.getOperators();
|
Set<OfflinePlayer> operators = Bukkit.getOperators();
|
||||||
Set<OfflinePlayer> banned = Bukkit.getBannedPlayers();
|
Set<OfflinePlayer> banned = Bukkit.getBannedPlayers();
|
||||||
|
@ -69,17 +69,14 @@ public class ThemeConfig extends Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static File getConfigFile() throws IOException {
|
private static File getConfigFile() throws IOException {
|
||||||
File folder = PlanPlugin.getInstance().getDataFolder();
|
File folder = PlanPlugin.getInstance().getDataFolder();
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
}
|
}
|
||||||
File themeFile = new File(folder, "theme.yml");
|
File themeFile = new File(folder, "theme.yml");
|
||||||
if (!themeFile.exists()) {
|
if (!themeFile.exists() && !themeFile.createNewFile()) {
|
||||||
if (!themeFile.createNewFile()) {
|
throw new FileNotFoundException("Failed to create theme.yml");
|
||||||
throw new FileNotFoundException("Failed to create theme.yml");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return themeFile;
|
return themeFile;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.djrapitops.plan.system.file.FileSystem;
|
|||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||||
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
import com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
@ -44,6 +45,12 @@ public class WebServer implements SubSystem {
|
|||||||
private RequestHandler requestHandler;
|
private RequestHandler requestHandler;
|
||||||
private ResponseHandler responseHandler;
|
private ResponseHandler responseHandler;
|
||||||
|
|
||||||
|
public static WebServer getInstance() {
|
||||||
|
WebServer webServer = WebServerSystem.getInstance().getWebServer();
|
||||||
|
NullCheck.check(webServer, new IllegalStateException("WebServer was not initialized."));
|
||||||
|
return webServer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() throws EnableException {
|
public void enable() throws EnableException {
|
||||||
this.port = Settings.WEBSERVER_PORT.getNumber();
|
this.port = Settings.WEBSERVER_PORT.getNumber();
|
||||||
|
@ -115,7 +115,7 @@ public class DebugPageResponse extends ErrorResponse {
|
|||||||
.append(" ").append(variable.getVersion());
|
.append(" ").append(variable.getVersion());
|
||||||
content.append("<br>");
|
content.append("<br>");
|
||||||
|
|
||||||
Database database = plugin.getDB();
|
Database database = Database.getActive();
|
||||||
content.append("**Database:** ").append(database.getName());
|
content.append("**Database:** ").append(database.getName());
|
||||||
|
|
||||||
if (database instanceof SQLDB) {
|
if (database instanceof SQLDB) {
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.PlanBungee;
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
import com.djrapitops.plan.system.settings.ServerSpecificSettings;
|
import com.djrapitops.plan.system.settings.ServerSpecificSettings;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
|
import com.djrapitops.plan.system.webserver.WebServer;
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
import com.djrapitops.plan.system.webserver.response.Response;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
@ -50,7 +50,7 @@ public class ConfigurationWebAPI extends WebAPI {
|
|||||||
if (accessKey != null) {
|
if (accessKey != null) {
|
||||||
addVariable("accessKey", accessKey);
|
addVariable("accessKey", accessKey);
|
||||||
}
|
}
|
||||||
addVariable("webAddress", PlanBungee.getInstance().getWebServer().getAccessAddress());
|
addVariable("webAddress", WebServer.getInstance().getAccessAddress());
|
||||||
|
|
||||||
sendRequest(address, serverUUID);
|
sendRequest(address, serverUUID);
|
||||||
}
|
}
|
||||||
|
@ -70,49 +70,8 @@ public class Analysis {
|
|||||||
return analyze();
|
return analyze();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnalysisData analyze() throws Exception {
|
private static void updateRefreshDate() {
|
||||||
log(Locale.get(Msg.ANALYSIS_FETCH).toString());
|
Analysis.refreshDate = MiscUtils.getTime();
|
||||||
Benchmark.start("Fetch Phase");
|
|
||||||
Log.logDebug("Database", "Analysis Fetch");
|
|
||||||
Log.logDebug("Analysis", "Analysis Fetch Phase");
|
|
||||||
try {
|
|
||||||
Benchmark.start("Create Empty dataset");
|
|
||||||
|
|
||||||
AnalysisData analysisData = new AnalysisData();
|
|
||||||
|
|
||||||
Benchmark.stop("Analysis", "Create Empty dataset");
|
|
||||||
Benchmark.start("Fetch Phase");
|
|
||||||
ServerProfile profile = database.fetch().getServerProfile(serverUUID);
|
|
||||||
if (analysingThisServer) {
|
|
||||||
profile.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions()));
|
|
||||||
}
|
|
||||||
serverProfile = profile;
|
|
||||||
|
|
||||||
updatePlayerNameCache(profile);
|
|
||||||
|
|
||||||
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
|
|
||||||
setBannedByPlugins(profile);
|
|
||||||
|
|
||||||
Benchmark.start("Analysis Phase");
|
|
||||||
Log.logDebug("Analysis", "Analysis Phase");
|
|
||||||
|
|
||||||
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(profile.getPlayerCount(), fetchPhaseLength));
|
|
||||||
|
|
||||||
analysisData.analyze(profile);
|
|
||||||
|
|
||||||
Benchmark.stop("Analysis", "Analysis Phase");
|
|
||||||
|
|
||||||
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
|
|
||||||
Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)");
|
|
||||||
analysisData.parsePluginsSection(analyzeAdditionalPluginData(profile.getUuids()));
|
|
||||||
return analysisData;
|
|
||||||
} finally {
|
|
||||||
refreshDate = MiscUtils.getTime();
|
|
||||||
long time = Benchmark.stop("Analysis", "Analysis");
|
|
||||||
Log.logDebug("Analysis");
|
|
||||||
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, ""));
|
|
||||||
serverProfile = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlayerNameCache(ServerProfile profile) {
|
private void updatePlayerNameCache(ServerProfile profile) {
|
||||||
@ -185,4 +144,53 @@ public class Analysis {
|
|||||||
public static boolean isAnalysisBeingRun() {
|
public static boolean isAnalysisBeingRun() {
|
||||||
return serverProfile != null;
|
return serverProfile != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setServerProfile(ServerProfile serverProfile) {
|
||||||
|
Analysis.serverProfile = serverProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AnalysisData analyze() throws Exception {
|
||||||
|
log(Locale.get(Msg.ANALYSIS_FETCH).toString());
|
||||||
|
Benchmark.start("Fetch Phase");
|
||||||
|
Log.logDebug("Database", "Analysis Fetch");
|
||||||
|
Log.logDebug("Analysis", "Analysis Fetch Phase");
|
||||||
|
try {
|
||||||
|
Benchmark.start("Create Empty dataset");
|
||||||
|
|
||||||
|
AnalysisData analysisData = new AnalysisData();
|
||||||
|
|
||||||
|
Benchmark.stop("Analysis", "Create Empty dataset");
|
||||||
|
Benchmark.start("Fetch Phase");
|
||||||
|
ServerProfile server = database.fetch().getServerProfile(serverUUID);
|
||||||
|
if (analysingThisServer) {
|
||||||
|
server.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions()));
|
||||||
|
}
|
||||||
|
Analysis.setServerProfile(server);
|
||||||
|
|
||||||
|
updatePlayerNameCache(server);
|
||||||
|
|
||||||
|
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
|
||||||
|
setBannedByPlugins(server);
|
||||||
|
|
||||||
|
Benchmark.start("Analysis Phase");
|
||||||
|
Log.logDebug("Analysis", "Analysis Phase");
|
||||||
|
|
||||||
|
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(server.getPlayerCount(), fetchPhaseLength));
|
||||||
|
|
||||||
|
analysisData.analyze(server);
|
||||||
|
|
||||||
|
Benchmark.stop("Analysis", "Analysis Phase");
|
||||||
|
|
||||||
|
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
|
||||||
|
Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)");
|
||||||
|
analysisData.parsePluginsSection(analyzeAdditionalPluginData(server.getUuids()));
|
||||||
|
return analysisData;
|
||||||
|
} finally {
|
||||||
|
Analysis.updateRefreshDate();
|
||||||
|
long time = Benchmark.stop("Analysis", "Analysis");
|
||||||
|
Log.logDebug("Analysis");
|
||||||
|
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, ""));
|
||||||
|
Analysis.setServerProfile(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.djrapitops.plugin.task.RunnableFactory;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +117,7 @@ public class HtmlExport extends SpecificExport {
|
|||||||
"web/css/style.css",
|
"web/css/style.css",
|
||||||
"web/css/themes/all-themes.css"
|
"web/css/themes/all-themes.css"
|
||||||
};
|
};
|
||||||
copyFromJar(resources, true);
|
copyFromJar(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportJs() {
|
private void exportJs() {
|
||||||
@ -138,7 +139,7 @@ public class HtmlExport extends SpecificExport {
|
|||||||
"web/js/charts/worldPie.js",
|
"web/js/charts/worldPie.js",
|
||||||
"web/js/charts/healthGauge.js"
|
"web/js/charts/healthGauge.js"
|
||||||
};
|
};
|
||||||
copyFromJar(resources, false);
|
copyFromJar(resources);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String demo = FileUtil.getStringFromResource("web/js/demo.js")
|
String demo = FileUtil.getStringFromResource("web/js/demo.js")
|
||||||
@ -164,27 +165,28 @@ public class HtmlExport extends SpecificExport {
|
|||||||
"web/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js",
|
"web/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js",
|
||||||
"web/plugins/jquery-datatable/jquery.dataTables.js"
|
"web/plugins/jquery-datatable/jquery.dataTables.js"
|
||||||
};
|
};
|
||||||
copyFromJar(resources, true);
|
copyFromJar(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFromJar(String[] resources, boolean overwrite) {
|
private void copyFromJar(String[] resources) {
|
||||||
for (String resource : resources) {
|
for (String resource : resources) {
|
||||||
try {
|
try {
|
||||||
copyFromJar(resource, overwrite);
|
copyFromJar(resource);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFromJar(String resource, boolean overwrite) throws IOException {
|
private void copyFromJar(String resource) throws IOException {
|
||||||
String possibleFile = resource.replace("web/", "").replace("/", File.separator);
|
String possibleFile = resource.replace("web/", "").replace("/", File.separator);
|
||||||
List<String> lines = FileUtil.lines(plugin, new File(plugin.getDataFolder(), possibleFile), resource);
|
List<String> lines = FileUtil.lines(plugin, new File(plugin.getDataFolder(), possibleFile), resource);
|
||||||
String outputFile = possibleFile.replace("web/", "");
|
String outputFile = possibleFile.replace("web/", "");
|
||||||
File to = new File(outputFolder, outputFile);
|
File to = new File(outputFolder, outputFile);
|
||||||
to.getParentFile().mkdirs();
|
to.getParentFile().mkdirs();
|
||||||
if (to.exists()) {
|
if (to.exists()) {
|
||||||
if (!to.delete() || !to.createNewFile()) {
|
Files.delete(to.toPath());
|
||||||
|
if (to.createNewFile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class AnalysisPluginsTabContentCreator {
|
|||||||
|
|
||||||
generalTab.append("<div class=\"tab\"><div class=\"row clearfix\">");
|
generalTab.append("<div class=\"tab\"><div class=\"row clearfix\">");
|
||||||
|
|
||||||
boolean hasGeneralBoxes = false;
|
boolean displayGeneralTab = false;
|
||||||
|
|
||||||
for (PluginData pluginData : order) {
|
for (PluginData pluginData : order) {
|
||||||
AnalysisContainer container = containers.get(pluginData);
|
AnalysisContainer container = containers.get(pluginData);
|
||||||
@ -48,20 +48,19 @@ public class AnalysisPluginsTabContentCreator {
|
|||||||
case WHOLE:
|
case WHOLE:
|
||||||
if (!container.hasOnlyValues()) {
|
if (!container.hasOnlyValues()) {
|
||||||
appendWhole(pluginData, container, generalTab);
|
appendWhole(pluginData, container, generalTab);
|
||||||
hasGeneralBoxes = true;
|
displayGeneralTab = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case TWO_THIRDS:
|
case TWO_THIRDS:
|
||||||
if (!container.hasOnlyValues()) {
|
if (!container.hasOnlyValues()) {
|
||||||
appendTwoThirds(pluginData, container, generalTab);
|
appendTwoThirds(pluginData, container, generalTab);
|
||||||
hasGeneralBoxes = true;
|
displayGeneralTab = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case THIRD:
|
case THIRD:
|
||||||
default:
|
default:
|
||||||
appendThird(pluginData, container, generalTab);
|
appendThird(pluginData, container, generalTab);
|
||||||
hasGeneralBoxes = true;
|
displayGeneralTab = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,9 +79,9 @@ public class AnalysisPluginsTabContentCreator {
|
|||||||
"</div></div></div>";
|
"</div></div></div>";
|
||||||
|
|
||||||
return new String[]{
|
return new String[]{
|
||||||
(hasGeneralBoxes ? "<li><a class=\"nav-button\" href=\"javascript:void(0)\">General</a></li>" : "")
|
(displayGeneralTab ? "<li><a class=\"nav-button\" href=\"javascript:void(0)\">General</a></li>" : "")
|
||||||
+ "<li><a class=\"nav-button\" href=\"javascript:void(0)\">Player Data</a></li>" + nav.toString(),
|
+ "<li><a class=\"nav-button\" href=\"javascript:void(0)\">Player Data</a></li>" + nav.toString(),
|
||||||
(hasGeneralBoxes ? generalTab.toString() : "") + playerListTab + otherTabs.toString()
|
(displayGeneralTab ? generalTab.toString() : "") + playerListTab + otherTabs.toString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.djrapitops.plan.utilities.metrics;
|
package com.djrapitops.plan.utilities.metrics;
|
||||||
|
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import com.djrapitops.plan.system.webserver.WebServer;
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public class BStats {
|
|||||||
if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) {
|
if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) {
|
||||||
serverType = "Spigot";
|
serverType = "Spigot";
|
||||||
}
|
}
|
||||||
String databaseType = plugin.getDB().getName();
|
String databaseType = Database.getActive().getName();
|
||||||
String analysisRefreshPeriod = Integer.toString(Settings.ANALYSIS_AUTO_REFRESH.getNumber());
|
String analysisRefreshPeriod = Integer.toString(Settings.ANALYSIS_AUTO_REFRESH.getNumber());
|
||||||
String themeBase = Settings.THEME_BASE.toString();
|
String themeBase = Settings.THEME_BASE.toString();
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public class BStats {
|
|||||||
metrics.addCustomChart(new Metrics.AdvancedBarChart(id, () -> {
|
metrics.addCustomChart(new Metrics.AdvancedBarChart(id, () -> {
|
||||||
Map<String, int[]> map = new HashMap<>();
|
Map<String, int[]> map = new HashMap<>();
|
||||||
|
|
||||||
map.put("HTTPS", isEnabled("HTTPS".equals(plugin.getWebServer().getProtocol().toUpperCase())));
|
map.put("HTTPS", isEnabled("HTTPS".equals(WebServer.getInstance().getProtocol().toUpperCase())));
|
||||||
map.put("HTML Export", isEnabled(Settings.ANALYSIS_EXPORT.isTrue()));
|
map.put("HTML Export", isEnabled(Settings.ANALYSIS_EXPORT.isTrue()));
|
||||||
boolean isConnectedToBungee = ConnectionSystem.getInstance().isServerAvailable();
|
boolean isConnectedToBungee = ConnectionSystem.getInstance().isServerAvailable();
|
||||||
map.put("BungeeCord Connected", isEnabled(isConnectedToBungee));
|
map.put("BungeeCord Connected", isEnabled(isConnectedToBungee));
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
package com.djrapitops.pluginbridge.plan.aac;
|
package com.djrapitops.pluginbridge.plan.aac;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
@ -35,7 +35,7 @@ public class AdvancedAntiCheatHook extends Hook {
|
|||||||
HackerTable table = new HackerTable((SQLDB) Database.getActive());
|
HackerTable table = new HackerTable((SQLDB) Database.getActive());
|
||||||
try {
|
try {
|
||||||
table.createTable();
|
table.createTable();
|
||||||
} catch (DBCreateTableException e) {
|
} catch (DBException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.pluginbridge.plan.aac;
|
package com.djrapitops.pluginbridge.plan.aac;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -41,7 +41,7 @@ public class HackerTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
createTable("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
||||||
+ columnUUID + " varchar(36) NOT NULL, "
|
+ columnUUID + " varchar(36) NOT NULL, "
|
||||||
+ columnDate + " bigint NOT NULL, "
|
+ columnDate + " bigint NOT NULL, "
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
package com.djrapitops.pluginbridge.plan.protocolsupport;
|
package com.djrapitops.pluginbridge.plan.protocolsupport;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
@ -35,7 +35,7 @@ public class ProtocolSupportHook extends Hook {
|
|||||||
ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive());
|
ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive());
|
||||||
try {
|
try {
|
||||||
table.createTable();
|
table.createTable();
|
||||||
} catch (DBCreateTableException e) {
|
} catch (DBException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.pluginbridge.plan.viaversion;
|
package com.djrapitops.pluginbridge.plan.viaversion;
|
||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
@ -38,7 +38,7 @@ public class ProtocolTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTable() throws DBCreateTableException {
|
public void createTable() throws DBInitException {
|
||||||
createTable("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
createTable("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
||||||
+ columnUUID + " varchar(36) NOT NULL UNIQUE, "
|
+ columnUUID + " varchar(36) NOT NULL UNIQUE, "
|
||||||
+ columnProtocolVersion + " integer NOT NULL"
|
+ columnProtocolVersion + " integer NOT NULL"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.djrapitops.pluginbridge.plan.viaversion;
|
package com.djrapitops.pluginbridge.plan.viaversion;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBCreateTableException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
@ -40,7 +40,7 @@ public class ViaVersionHook extends Hook {
|
|||||||
ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive());
|
ProtocolTable table = new ProtocolTable((SQLDB) Database.getActive());
|
||||||
try {
|
try {
|
||||||
table.createTable();
|
table.createTable();
|
||||||
} catch (DBCreateTableException e) {
|
} catch (DBException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user