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