mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 20:17:42 +01:00
[Test] Fixed BukkitSystemTest
This test was tougher than usual to fix, since Database could not be provided during object construction due to config setting default not being loaded. This would have lead to new installs not functioning. Fixed by replacing all Database injections with DBSystem
This commit is contained in:
parent
2e4464b558
commit
55c49bd220
@ -95,7 +95,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
|
||||
new BStatsBungee(
|
||||
this,
|
||||
system.getDatabaseSystem().getActiveDatabase(),
|
||||
system.getDatabaseSystem().getDatabase(),
|
||||
system.getInfoSystem().getConnectionSystem()
|
||||
).registerMetrics();
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||
|
||||
new BStatsSponge(
|
||||
metrics,
|
||||
system.getDatabaseSystem().getActiveDatabase()
|
||||
system.getDatabaseSystem().getDatabase()
|
||||
).registerMetrics();
|
||||
|
||||
slf4jLogger.info(locale.getString(PluginLang.ENABLED));
|
||||
|
@ -10,6 +10,7 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -29,12 +30,12 @@ import java.util.UUID;
|
||||
public class ShutdownHook extends Thread {
|
||||
|
||||
private static ShutdownHook activated;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public ShutdownHook(Database database, ErrorHandler errorHandler) {
|
||||
this.database = database;
|
||||
public ShutdownHook(DBSystem dbSystem, ErrorHandler errorHandler) {
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@ -71,7 +72,7 @@ public class ShutdownHook extends Thread {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
} finally {
|
||||
try {
|
||||
database.close();
|
||||
dbSystem.getDatabase().close();
|
||||
} catch (DBException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
@ -86,6 +87,7 @@ public class ShutdownHook extends Thread {
|
||||
if (!end.isPresent()) {
|
||||
session.endSession(now);
|
||||
}
|
||||
Database database = dbSystem.getDatabase();
|
||||
if (!database.isOpen()) {
|
||||
database.init();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -24,18 +24,18 @@ import java.util.UUID;
|
||||
public class ProxyAPI extends CommonAPI {
|
||||
|
||||
private final HookHandler hookHandler;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
@Inject
|
||||
public ProxyAPI(
|
||||
UUIDUtility uuidUtility,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
HookHandler hookHandler,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(uuidUtility, errorHandler);
|
||||
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.hookHandler = hookHandler;
|
||||
}
|
||||
|
||||
@ -46,11 +46,11 @@ public class ProxyAPI extends CommonAPI {
|
||||
|
||||
@Override
|
||||
public String getPlayerName(UUID uuid) {
|
||||
return database.fetch().getPlayerName(uuid);
|
||||
return dbSystem.getDatabase().fetch().getPlayerName(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchOperations fetchFromPlanDB() {
|
||||
return database.fetch();
|
||||
return dbSystem.getDatabase().fetch();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -24,18 +24,18 @@ import java.util.UUID;
|
||||
public class ServerAPI extends CommonAPI {
|
||||
|
||||
private final HookHandler hookHandler;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
@Inject
|
||||
public ServerAPI(
|
||||
UUIDUtility uuidUtility,
|
||||
HookHandler hookHandler,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(uuidUtility, errorHandler);
|
||||
this.hookHandler = hookHandler;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,11 +45,11 @@ public class ServerAPI extends CommonAPI {
|
||||
|
||||
@Override
|
||||
public String getPlayerName(UUID uuid) {
|
||||
return database.fetch().getPlayerName(uuid);
|
||||
return dbSystem.getDatabase().fetch().getPlayerName(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchOperations fetchFromPlanDB() {
|
||||
return database.fetch();
|
||||
return dbSystem.getDatabase().fetch();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
@ -42,7 +42,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
private final InfoSystem infoSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final WebServer webServer;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -53,7 +53,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
InfoSystem infoSystem,
|
||||
ServerInfo serverInfo,
|
||||
WebServer webServer,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("analyze|analyse|analysis|a", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||
@ -64,7 +64,7 @@ public class AnalyzeCommand extends CommandNode {
|
||||
connectionSystem = infoSystem.getConnectionSystem();
|
||||
this.serverInfo = serverInfo;
|
||||
this.webServer = webServer;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.ANALYZE));
|
||||
@ -110,14 +110,14 @@ public class AnalyzeCommand extends CommandNode {
|
||||
private void sendWebUserNotificationIfNecessary(Sender sender) {
|
||||
if (webServer.isAuthRequired() &&
|
||||
CommandUtils.isPlayer(sender) &&
|
||||
!database.check().doesWebUserExists(sender.getName())) {
|
||||
!dbSystem.getDatabase().check().doesWebUserExists(sender.getName())) {
|
||||
sender.sendMessage("§e" + locale.getString(CommandLang.NO_WEB_USER_NOTIFY));
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1 && connectionSystem.isServerAvailable()) {
|
||||
Map<UUID, Server> bukkitServers = database.fetch().getBukkitServers();
|
||||
Map<UUID, Server> bukkitServers = dbSystem.getDatabase().fetch().getBukkitServers();
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
for (Map.Entry<UUID, Server> entry : bukkitServers.entrySet()) {
|
||||
Server server = entry.getValue();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -25,7 +25,7 @@ public class InfoCommand extends CommandNode {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
|
||||
@ -33,7 +33,7 @@ public class InfoCommand extends CommandNode {
|
||||
public InfoCommand(
|
||||
PlanPlugin plugin,
|
||||
Locale locale,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ConnectionSystem connectionSystem,
|
||||
VersionCheckSystem versionCheckSystem
|
||||
) {
|
||||
@ -41,7 +41,7 @@ public class InfoCommand extends CommandNode {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
|
||||
@ -60,7 +60,7 @@ public class InfoCommand extends CommandNode {
|
||||
"",
|
||||
locale.getString(CommandLang.INFO_VERSION, plugin.getVersion()),
|
||||
locale.getString(CommandLang.INFO_UPDATE, updateAvailable),
|
||||
locale.getString(CommandLang.INFO_DATABASE, database.getName()),
|
||||
locale.getString(CommandLang.INFO_DATABASE, dbSystem.getDatabase().getName()),
|
||||
locale.getString(CommandLang.INFO_BUNGEE_CONNECTION, connectedToBungee),
|
||||
"",
|
||||
">"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -32,7 +32,7 @@ import java.util.UUID;
|
||||
public class InspectCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
private final InfoProcessors processorFactory;
|
||||
private final Processing processing;
|
||||
@ -45,7 +45,7 @@ public class InspectCommand extends CommandNode {
|
||||
Locale locale,
|
||||
InfoProcessors processorFactory,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer,
|
||||
ConnectionSystem connectionSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
@ -58,7 +58,7 @@ public class InspectCommand extends CommandNode {
|
||||
setArguments("<player>");
|
||||
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
this.uuidUtility = uuidUtility;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -87,7 +87,7 @@ public class InspectCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!database.check().isPlayerRegistered(uuid)) {
|
||||
if (!dbSystem.getDatabase().check().isPlayerRegistered(uuid)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
|
||||
return;
|
||||
}
|
||||
@ -103,7 +103,7 @@ public class InspectCommand extends CommandNode {
|
||||
|
||||
private void checkWebUserAndNotify(Sender sender) {
|
||||
if (CommandUtils.isPlayer(sender) && webServer.isAuthRequired()) {
|
||||
boolean senderHasWebUser = database.check().doesWebUserExists(sender.getName());
|
||||
boolean senderHasWebUser = dbSystem.getDatabase().check().doesWebUserExists(sender.getName());
|
||||
|
||||
if (!senderHasWebUser) {
|
||||
sender.sendMessage("§e" + locale.getString(CommandLang.NO_WEB_USER_NOTIFY));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -28,16 +28,21 @@ public class ListServersCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ColorScheme colorScheme;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public ListServersCommand(Locale locale, ColorScheme colorScheme, Database database, ErrorHandler errorHandler) {
|
||||
public ListServersCommand(
|
||||
Locale locale,
|
||||
ColorScheme colorScheme,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("servers|serverlist|listservers|sl|ls", Permissions.MANAGE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.colorScheme = colorScheme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.SERVERS));
|
||||
@ -60,7 +65,7 @@ public class ListServersCommand extends CommandNode {
|
||||
}
|
||||
|
||||
private void sendServers(Sender sender, Formatter<Server> serverFormatter) {
|
||||
List<Server> servers = database.fetch().getServers();
|
||||
List<Server> servers = dbSystem.getDatabase().fetch().getServers();
|
||||
for (Server server : servers) {
|
||||
sender.sendMessage(serverFormatter.apply(server));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.data.store.mutators.ActivityIndex;
|
||||
import com.djrapitops.plan.data.store.mutators.GeoInfoMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -45,7 +45,7 @@ import java.util.UUID;
|
||||
public class QInspectCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final Formatters formatters;
|
||||
@ -57,7 +57,7 @@ public class QInspectCommand extends CommandNode {
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
Formatters formatters,
|
||||
ErrorHandler errorHandler
|
||||
@ -69,7 +69,7 @@ public class QInspectCommand extends CommandNode {
|
||||
setArguments("<player>");
|
||||
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.uuidUtility = uuidUtility;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
@ -98,7 +98,7 @@ public class QInspectCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerContainer container = database.fetch().getPlayerContainer(uuid);
|
||||
PlayerContainer container = dbSystem.getDatabase().fetch().getPlayerContainer(uuid);
|
||||
if (!container.getValue(PlayerKeys.REGISTERED).isPresent()) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
|
||||
return;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -40,7 +41,7 @@ public class RegisterCommand extends CommandNode {
|
||||
private final String notEnoughArgsMsg;
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -48,16 +49,17 @@ public class RegisterCommand extends CommandNode {
|
||||
public RegisterCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler) {
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
// No Permission Requirement
|
||||
super("register", "", CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.logger = logger;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<password>", "[name]", "[lvl]");
|
||||
@ -131,6 +133,7 @@ public class RegisterCommand extends CommandNode {
|
||||
processing.submitCritical(() -> {
|
||||
String userName = webUser.getName();
|
||||
try {
|
||||
Database database = dbSystem.getDatabase();
|
||||
boolean userExists = database.check().doesWebUserExists(userName);
|
||||
if (userExists) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_EXISTS));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -33,20 +33,20 @@ public class SearchCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public SearchCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler) {
|
||||
super("search", Permissions.SEARCH.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setArguments("<text>");
|
||||
@ -68,7 +68,7 @@ public class SearchCommand extends CommandNode {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
String searchTerm = args[0];
|
||||
List<String> names = database.search().matchingPlayers(searchTerm);
|
||||
List<String> names = dbSystem.getDatabase().search().matchingPlayers(searchTerm);
|
||||
Collections.sort(names);
|
||||
boolean empty = Verify.isEmpty(names);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.request.InfoRequestFactory;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
@ -41,7 +41,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final InfoRequestFactory infoRequestFactory;
|
||||
private final WebServer webServer;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
@Inject
|
||||
public ManageConDebugCommand(
|
||||
@ -52,7 +52,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
ConnectionSystem connectionSystem,
|
||||
InfoRequestFactory infoRequestFactory,
|
||||
WebServer webServer,
|
||||
Database database
|
||||
DBSystem dbSystem
|
||||
) {
|
||||
super("con", Permissions.MANAGE.getPermission(), CommandType.ALL);
|
||||
|
||||
@ -63,7 +63,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.infoRequestFactory = infoRequestFactory;
|
||||
this.webServer = webServer;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
setShortHelp(locale.getString(Check.isBungeeAvailable() ? CmdHelpLang.CON : CmdHelpLang.MANAGE_CON));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.MANAGE_CON));
|
||||
@ -114,7 +114,7 @@ public class ManageConDebugCommand extends CommandNode {
|
||||
}
|
||||
|
||||
private void testServers(Sender sender) {
|
||||
List<Server> servers = database.fetch().getServers();
|
||||
List<Server> servers = dbSystem.getDatabase().fetch().getServers();
|
||||
|
||||
if (servers.isEmpty()) {
|
||||
sender.sendMessage(locale.getString(ManageLang.CON_NO_SERVERS));
|
||||
|
@ -61,7 +61,7 @@ public class ManageHotSwapCommand extends CommandNode {
|
||||
Verify.isTrue(isCorrectDB,
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_INCORRECT_DB, dbName)));
|
||||
|
||||
Verify.isFalse(dbName.equals(dbSystem.getActiveDatabase().getConfigName()),
|
||||
Verify.isFalse(dbName.equals(dbSystem.getDatabase().getConfigName()),
|
||||
() -> new IllegalArgumentException(locale.getString(ManageLang.FAIL_SAME_DB)));
|
||||
|
||||
try {
|
||||
|
@ -99,7 +99,7 @@ public class ManageMoveCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
|
||||
boolean movingToCurrentDB = toDatabase.getConfigName().equalsIgnoreCase(dbSystem.getActiveDatabase().getConfigName());
|
||||
boolean movingToCurrentDB = toDatabase.getConfigName().equalsIgnoreCase(dbSystem.getDatabase().getConfigName());
|
||||
if (movingToCurrentDB) {
|
||||
sender.sendMessage(locale.getString(ManageLang.HOTSWAP_REMINDER, toDatabase.getConfigName()));
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -25,7 +26,7 @@ import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to remove a single player's data from the
|
||||
* database.
|
||||
* dbSystem.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -34,7 +35,7 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final UUIDUtility uuidUtility;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -42,7 +43,7 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
public ManageRemoveCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
@ -50,7 +51,7 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.uuidUtility = uuidUtility;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
@ -84,19 +85,24 @@ public class ManageRemoveCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!database.check().isPlayerRegistered(uuid)) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
if (!db.check().isPlayerRegistered(uuid)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_USERNAME_NOT_KNOWN));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Verify.contains("-a", args)) {
|
||||
sender.sendMessage(locale.getString(ManageLang.CONFIRMATION, locale.getString(ManageLang.CONFIRM_REMOVAL, database.getName())));
|
||||
sender.sendMessage(
|
||||
locale.getString(ManageLang.CONFIRMATION,
|
||||
locale.getString(ManageLang.CONFIRM_REMOVAL, db.getName())
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||
|
||||
database.remove().player(uuid);
|
||||
db.remove().player(uuid);
|
||||
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -33,7 +33,7 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
private final ServerInfo serverInfo;
|
||||
|
||||
@ -41,7 +41,7 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
public ManageUninstalledCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
@ -49,7 +49,7 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
@ -76,7 +76,7 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
return;
|
||||
}
|
||||
|
||||
database.save().setAsUninstalled(serverUUID);
|
||||
dbSystem.getDatabase().save().setAsUninstalled(serverUUID);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cError occurred: " + e.toString());
|
||||
@ -87,7 +87,7 @@ public class ManageUninstalledCommand extends CommandNode {
|
||||
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1) {
|
||||
Map<UUID, Server> bukkitServers = database.fetch().getBukkitServers();
|
||||
Map<UUID, Server> bukkitServers = dbSystem.getDatabase().fetch().getBukkitServers();
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
for (Map.Entry<UUID, Server> entry : bukkitServers.entrySet()) {
|
||||
Server server = entry.getValue();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -30,20 +31,21 @@ public class WebCheckCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public WebCheckCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
ErrorHandler errorHandler) {
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("check", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_CHECK));
|
||||
@ -59,11 +61,12 @@ public class WebCheckCommand extends CommandNode {
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
if (!database.check().doesWebUserExists(user)) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
if (!db.check().doesWebUserExists(user)) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_WEB_USER_NOT_EXISTS));
|
||||
return;
|
||||
}
|
||||
WebUser info = database.fetch().getWebUser(user);
|
||||
WebUser info = db.fetch().getWebUser(user);
|
||||
sender.sendMessage(locale.getString(CommandLang.WEB_USER_LIST, info.getName(), info.getPermLevel()));
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
@ -29,21 +30,21 @@ public class WebDeleteCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public WebDeleteCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("delete|remove", Permissions.MANAGE_WEB.getPerm(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_DELETE));
|
||||
@ -59,11 +60,12 @@ public class WebDeleteCommand extends CommandNode {
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
if (!database.check().doesWebUserExists(user)) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
if (!db.check().doesWebUserExists(user)) {
|
||||
sender.sendMessage("§c[Plan] User Doesn't exist.");
|
||||
return;
|
||||
}
|
||||
database.remove().webUser(user);
|
||||
db.remove().webUser(user);
|
||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.command.commands.webuser;
|
||||
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -30,21 +30,21 @@ public class WebListUsersCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public WebListUsersCommand(
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("list", Permissions.MANAGE_WEB.getPerm(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.WEB_LIST));
|
||||
@ -54,7 +54,7 @@ public class WebListUsersCommand extends CommandNode {
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
List<WebUser> users = database.fetch().getWebUsers();
|
||||
List<WebUser> users = dbSystem.getDatabase().fetch().getWebUsers();
|
||||
users.sort(new WebUserComparator());
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_WEB_USERS, users.size()));
|
||||
for (WebUser user : users) {
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.data.store.keys.ServerKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.*;
|
||||
import com.djrapitops.plan.data.store.mutators.health.HealthInformation;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
@ -48,7 +48,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
private final String version;
|
||||
private final PlanConfig config;
|
||||
private final Theme theme;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerProperties serverProperties;
|
||||
private final Formatters formatters;
|
||||
private final Graphs graphs;
|
||||
@ -63,7 +63,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
String version,
|
||||
PlanConfig config,
|
||||
Theme theme,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerProperties serverProperties,
|
||||
Formatters formatters,
|
||||
Graphs graphs,
|
||||
@ -75,7 +75,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
this.version = version;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverProperties = serverProperties;
|
||||
this.formatters = formatters;
|
||||
this.graphs = graphs;
|
||||
@ -283,7 +283,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
|
||||
private void addSessionSuppliers() {
|
||||
Key<SessionAccordion> sessionAccordion = new Key<>(SessionAccordion.class, "SESSION_ACCORDION");
|
||||
putCachingSupplier(serverNames, () -> database.fetch().getServerNames());
|
||||
putCachingSupplier(serverNames, () -> dbSystem.getDatabase().fetch().getServerNames());
|
||||
putCachingSupplier(sessionAccordion, () -> accordions.serverSessionAccordion(
|
||||
getUnsafe(AnalysisKeys.SESSIONS_MUTATOR).all(),
|
||||
getSupplier(serverNames),
|
||||
@ -471,7 +471,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
private final String version;
|
||||
private final PlanConfig config;
|
||||
private final Theme theme;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerProperties serverProperties;
|
||||
private final Formatters formatters;
|
||||
private final Graphs graphs;
|
||||
@ -484,7 +484,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
@Named("currentVersion") String version,
|
||||
PlanConfig config,
|
||||
Theme theme,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerProperties serverProperties,
|
||||
Formatters formatters,
|
||||
Graphs graphs,
|
||||
@ -495,7 +495,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
this.version = version;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverProperties = serverProperties;
|
||||
this.formatters = formatters;
|
||||
this.graphs = graphs;
|
||||
@ -510,7 +510,7 @@ public class AnalysisContainer extends DataContainer {
|
||||
version,
|
||||
config,
|
||||
theme,
|
||||
database,
|
||||
dbSystem,
|
||||
serverProperties,
|
||||
formatters,
|
||||
graphs,
|
||||
|
@ -7,7 +7,7 @@ import com.djrapitops.plan.data.store.keys.ServerKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.health.NetworkHealthInformation;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
@ -45,7 +45,7 @@ public class NetworkContainer extends DataContainer {
|
||||
private final String version;
|
||||
private final PlanConfig config;
|
||||
private final Theme theme;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerProperties serverProperties;
|
||||
private final Formatters formatters;
|
||||
private final Graphs graphs;
|
||||
@ -55,7 +55,7 @@ public class NetworkContainer extends DataContainer {
|
||||
String version,
|
||||
PlanConfig config,
|
||||
Theme theme,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerProperties serverProperties,
|
||||
Formatters formatters,
|
||||
Graphs graphs
|
||||
@ -64,7 +64,7 @@ public class NetworkContainer extends DataContainer {
|
||||
this.version = version;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverProperties = serverProperties;
|
||||
this.formatters = formatters;
|
||||
this.graphs = graphs;
|
||||
@ -78,7 +78,7 @@ public class NetworkContainer extends DataContainer {
|
||||
}
|
||||
|
||||
private void addServerBoxes() {
|
||||
putSupplier(NetworkKeys.NETWORK_PLAYER_ONLINE_DATA, () -> database.fetch().getPlayersOnlineForServers(
|
||||
putSupplier(NetworkKeys.NETWORK_PLAYER_ONLINE_DATA, () -> dbSystem.getDatabase().fetch().getPlayersOnlineForServers(
|
||||
getValue(NetworkKeys.BUKKIT_SERVERS).orElse(new ArrayList<>()))
|
||||
);
|
||||
putSupplier(NetworkKeys.SERVERS_TAB, () -> {
|
||||
@ -213,7 +213,7 @@ public class NetworkContainer extends DataContainer {
|
||||
private final Lazy<String> version;
|
||||
private final Lazy<PlanConfig> config;
|
||||
private final Lazy<Theme> theme;
|
||||
private final Lazy<Database> database;
|
||||
private final Lazy<DBSystem> dbSystem;
|
||||
private final Lazy<ServerProperties> serverProperties;
|
||||
private final Lazy<Formatters> formatters;
|
||||
private final Lazy<Graphs> graphs;
|
||||
@ -223,7 +223,7 @@ public class NetworkContainer extends DataContainer {
|
||||
@Named("currentVersion") Lazy<String> version,
|
||||
Lazy<PlanConfig> config,
|
||||
Lazy<Theme> theme,
|
||||
Lazy<Database> database,
|
||||
Lazy<DBSystem> dbSystem,
|
||||
Lazy<ServerProperties> serverProperties,
|
||||
Lazy<Formatters> formatters,
|
||||
Lazy<Graphs> graphs
|
||||
@ -231,7 +231,7 @@ public class NetworkContainer extends DataContainer {
|
||||
this.version = version;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverProperties = serverProperties;
|
||||
this.formatters = formatters;
|
||||
this.graphs = graphs;
|
||||
@ -243,7 +243,7 @@ public class NetworkContainer extends DataContainer {
|
||||
version.get(),
|
||||
config.get(),
|
||||
theme.get(),
|
||||
database.get(),
|
||||
dbSystem.get(),
|
||||
serverProperties.get(),
|
||||
formatters.get(),
|
||||
graphs.get()
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.djrapitops.plan.modules;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.PluginsConfigSection;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.LocaleSystem;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
@ -25,12 +23,6 @@ public class SystemObjectBindingModule {
|
||||
return localeSystem.getLocale();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Database provideDatabase(DBSystem dbSystem) {
|
||||
return dbSystem.getActiveDatabase();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
PluginsConfigSection providePluginsConfigSection(PlanConfig config) {
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
@ -20,7 +20,6 @@ import java.util.UUID;
|
||||
* <ul>
|
||||
* <li>PlayerName cache, used for reducing database calls on chat events</li>
|
||||
* <li>DisplayName cache, used for reducing database calls on chat events</li>
|
||||
* <li>FirstSession MessageCount Map, used for tracking first session and message count on that session.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -30,7 +29,6 @@ import java.util.UUID;
|
||||
public class DataCache extends SessionCache implements SubSystem {
|
||||
|
||||
private final ErrorHandler errorHandler;
|
||||
private Database database;
|
||||
|
||||
private final Map<UUID, String> playerNames;
|
||||
private final Map<String, UUID> uuids;
|
||||
@ -38,16 +36,14 @@ public class DataCache extends SessionCache implements SubSystem {
|
||||
|
||||
@Inject
|
||||
public DataCache(
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(database);
|
||||
super(dbSystem);
|
||||
this.errorHandler = errorHandler;
|
||||
playerNames = new HashMap<>();
|
||||
displayNames = new HashMap<>();
|
||||
uuids = new HashMap<>();
|
||||
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,7 +89,7 @@ public class DataCache extends SessionCache implements SubSystem {
|
||||
String name = playerNames.get(uuid);
|
||||
if (name == null) {
|
||||
try {
|
||||
name = database.fetch().getPlayerName(uuid);
|
||||
name = dbSystem.getDatabase().fetch().getPlayerName(uuid);
|
||||
playerNames.put(uuid, name);
|
||||
} catch (DBOpException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
@ -116,7 +112,7 @@ public class DataCache extends SessionCache implements SubSystem {
|
||||
if (cached == null) {
|
||||
List<String> nicknames;
|
||||
try {
|
||||
nicknames = database.fetch().getNicknames(uuid);
|
||||
nicknames = dbSystem.getDatabase().fetch().getNicknames(uuid);
|
||||
if (!nicknames.isEmpty()) {
|
||||
return nicknames.get(nicknames.size() - 1);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -18,8 +18,8 @@ import java.util.UUID;
|
||||
public class ProxyDataCache extends DataCache {
|
||||
|
||||
@Inject
|
||||
public ProxyDataCache(Database database, ErrorHandler errorHandler) {
|
||||
super(database, errorHandler);
|
||||
public ProxyDataCache(DBSystem dbSystem, ErrorHandler errorHandler) {
|
||||
super(dbSystem, errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.store.keys.SessionKeys;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -19,10 +19,10 @@ public class SessionCache {
|
||||
|
||||
private static final Map<UUID, Session> activeSessions = new HashMap<>();
|
||||
|
||||
private final Database database;
|
||||
protected final DBSystem dbSystem;
|
||||
|
||||
public SessionCache(Database database) {
|
||||
this.database = database;
|
||||
public SessionCache(DBSystem dbSystem) {
|
||||
this.dbSystem = dbSystem;
|
||||
}
|
||||
|
||||
public static Map<UUID, Session> getActiveSessions() {
|
||||
@ -74,7 +74,7 @@ public class SessionCache {
|
||||
try {
|
||||
session.endSession(time);
|
||||
// Might throw a DBOpException
|
||||
database.save().session(uuid, session);
|
||||
dbSystem.getDatabase().save().session(uuid, session);
|
||||
} finally {
|
||||
removeSessionFromCache(uuid);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.system.database;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.database.databases.sql.MySQLDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -24,15 +25,29 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
public class BukkitDBSystem extends DBSystem {
|
||||
|
||||
private final PlanConfig config;
|
||||
|
||||
@Inject
|
||||
public BukkitDBSystem(Locale locale, MySQLDB mySQLDB, SQLiteDB.Factory sqLiteDB, PlanConfig config,
|
||||
PluginLogger logger, Timings timings, ErrorHandler errorHandler) {
|
||||
public BukkitDBSystem(
|
||||
Locale locale,
|
||||
MySQLDB mySQLDB,
|
||||
SQLiteDB.Factory sqLiteDB,
|
||||
PlanConfig config,
|
||||
PluginLogger logger,
|
||||
Timings timings,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(locale, logger, timings, errorHandler);
|
||||
this.config = config;
|
||||
|
||||
databases.add(mySQLDB);
|
||||
databases.add(sqLiteDB.usingDefaultFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
String dbType = config.getString(Settings.DB_TYPE).toLowerCase().trim();
|
||||
db = getActiveDatabaseByName(dbType);
|
||||
super.enable();
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public abstract class DBSystem implements SubSystem {
|
||||
}
|
||||
}
|
||||
|
||||
public Database getActiveDatabase() {
|
||||
public Database getDatabase() {
|
||||
return db;
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,13 @@ import javax.inject.Singleton;
|
||||
public class ProxyDBSystem extends DBSystem {
|
||||
|
||||
@Inject
|
||||
public ProxyDBSystem(Locale locale, MySQLDB mySQLDB,
|
||||
PluginLogger logger, Timings timings, ErrorHandler errorHandler) {
|
||||
public ProxyDBSystem(
|
||||
Locale locale,
|
||||
MySQLDB mySQLDB,
|
||||
PluginLogger logger,
|
||||
Timings timings,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(locale, logger, timings, errorHandler);
|
||||
databases.add(mySQLDB);
|
||||
db = mySQLDB;
|
||||
|
@ -13,7 +13,8 @@ import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
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.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
||||
import com.djrapitops.plan.system.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.system.importing.data.UserImportData;
|
||||
@ -38,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
public abstract class Importer {
|
||||
|
||||
private final GeolocationCache geolocationCache;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
protected final Supplier<UUID> serverUUID;
|
||||
|
||||
private final String name;
|
||||
@ -47,12 +48,12 @@ public abstract class Importer {
|
||||
protected Importer(
|
||||
Plan plugin,
|
||||
GeolocationCache geolocationCache,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
String name
|
||||
) {
|
||||
this.geolocationCache = geolocationCache;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverUUID = serverInfo::getServerUUID;
|
||||
|
||||
this.name = name;
|
||||
@ -97,7 +98,7 @@ public abstract class Importer {
|
||||
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
|
||||
SaveOperations save = database.save();
|
||||
SaveOperations save = dbSystem.getDatabase().save();
|
||||
submitTo(service, () -> save.insertTPS(ImmutableMap.of(serverUUID.get(), serverImportData.getTpsData())));
|
||||
submitTo(service, () -> save.insertCommandUsage(ImmutableMap.of(serverUUID.get(), serverImportData.getCommandUsages())));
|
||||
|
||||
@ -120,8 +121,9 @@ public abstract class Importer {
|
||||
UserImportRefiner userImportRefiner = new UserImportRefiner(plugin, userImportData);
|
||||
userImportData = userImportRefiner.refineData();
|
||||
|
||||
Set<UUID> existingUUIDs = database.fetch().getSavedUUIDs();
|
||||
Set<UUID> existingUserInfoTableUUIDs = database.fetch().getSavedUUIDs(serverUUID.get());
|
||||
FetchOperations fetch = dbSystem.getDatabase().fetch();
|
||||
Set<UUID> existingUUIDs = fetch.getSavedUUIDs();
|
||||
Set<UUID> existingUserInfoTableUUIDs = fetch.getSavedUUIDs(serverUUID.get());
|
||||
|
||||
Map<UUID, UserInfo> users = new HashMap<>();
|
||||
List<UserInfo> userInfo = new ArrayList<>();
|
||||
@ -150,7 +152,7 @@ public abstract class Importer {
|
||||
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
|
||||
SaveOperations save = database.save();
|
||||
SaveOperations save = dbSystem.getDatabase().save();
|
||||
|
||||
save.insertUsers(users);
|
||||
submitTo(service, () -> save.insertSessions(ImmutableMap.of(serverUUID.get(), sessions), true));
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.importing.importers;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.importing.data.ServerImportData;
|
||||
import com.djrapitops.plan.system.importing.data.UserImportData;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
@ -31,10 +31,10 @@ public class OfflinePlayerImporter extends Importer {
|
||||
public OfflinePlayerImporter(
|
||||
Plan plugin,
|
||||
GeolocationCache geolocationCache,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo
|
||||
) {
|
||||
super(plugin, geolocationCache, database, serverInfo, "offline");
|
||||
super(plugin, geolocationCache, dbSystem, serverInfo, "offline");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.NotFoundException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.request.InfoRequest;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.pages.PageHandler;
|
||||
@ -32,18 +32,18 @@ import java.util.List;
|
||||
@Singleton
|
||||
public class InfoRequestPageHandler implements PageHandler {
|
||||
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ResponseFactory responseFactory;
|
||||
private final PluginLogger logger;
|
||||
|
||||
@Inject
|
||||
public InfoRequestPageHandler(
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ConnectionSystem connectionSystem,
|
||||
ResponseFactory responseFactory, PluginLogger logger
|
||||
) {
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.responseFactory = responseFactory;
|
||||
this.logger = logger;
|
||||
@ -68,7 +68,7 @@ public class InfoRequestPageHandler implements PageHandler {
|
||||
Verify.nullCheck(infoRequest, () -> new NotFoundException("Info Request has not been registered."));
|
||||
|
||||
logger.debug("ConnectionIn: " + infoRequest.getClass().getSimpleName());
|
||||
return new ConnectionIn(request, infoRequest, database, connectionSystem).handleRequest();
|
||||
return new ConnectionIn(request, infoRequest, dbSystem.getDatabase(), connectionSystem).handleRequest();
|
||||
} catch (WebException e) {
|
||||
responseCode = getResponseCodeFor(e);
|
||||
throw e;
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.request.*;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class ProxyConnectionSystem extends ConnectionSystem {
|
||||
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final Lazy<WebServer> webServer;
|
||||
private final ErrorHandler errorHandler;
|
||||
private final WebExceptionLogger webExceptionLogger;
|
||||
@ -38,7 +38,7 @@ public class ProxyConnectionSystem extends ConnectionSystem {
|
||||
|
||||
@Inject
|
||||
public ProxyConnectionSystem(
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
Lazy<WebServer> webServer,
|
||||
ConnectionLog connectionLog,
|
||||
InfoRequests infoRequests,
|
||||
@ -48,7 +48,7 @@ public class ProxyConnectionSystem extends ConnectionSystem {
|
||||
WebExceptionLogger webExceptionLogger
|
||||
) {
|
||||
super(connectionLog, infoRequests, infoSystem, serverInfo);
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
this.errorHandler = errorHandler;
|
||||
this.webExceptionLogger = webExceptionLogger;
|
||||
@ -58,7 +58,7 @@ public class ProxyConnectionSystem extends ConnectionSystem {
|
||||
private void refreshServerMap() {
|
||||
if (latestServerMapRefresh < System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(15L)) {
|
||||
try {
|
||||
bukkitServers = database.fetch().getBukkitServers();
|
||||
bukkitServers = dbSystem.getDatabase().fetch().getBukkitServers();
|
||||
latestServerMapRefresh = System.currentTimeMillis();
|
||||
} catch (DBOpException e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
|
@ -6,7 +6,8 @@ package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.request.*;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
@ -23,7 +24,6 @@ import dagger.Lazy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -38,7 +38,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
private final Locale locale;
|
||||
private final PlanConfig config;
|
||||
private final Processing processing;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final Lazy<WebServer> webServer;
|
||||
private final PluginLogger pluginLogger;
|
||||
private final WebExceptionLogger webExceptionLogger;
|
||||
@ -52,7 +52,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
Locale locale,
|
||||
PlanConfig config,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
Lazy<WebServer> webServer,
|
||||
ConnectionLog connectionLog,
|
||||
InfoRequests infoRequests,
|
||||
@ -65,7 +65,7 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
this.locale = locale;
|
||||
this.config = config;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
this.pluginLogger = pluginLogger;
|
||||
this.webExceptionLogger = webExceptionLogger;
|
||||
@ -75,9 +75,9 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
private void refreshServerMap() {
|
||||
processing.submitNonCritical(() -> {
|
||||
if (latestServerMapRefresh < System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(15L)) {
|
||||
Optional<Server> bungeeInformation = database.fetch().getBungeeInformation();
|
||||
bungeeInformation.ifPresent(server -> mainServer = server);
|
||||
bukkitServers = database.fetch().getBukkitServers();
|
||||
FetchOperations fetch = dbSystem.getDatabase().fetch();
|
||||
mainServer = fetch.getBungeeInformation().orElse(null);
|
||||
bukkitServers = fetch.getBukkitServers();
|
||||
latestServerMapRefresh = System.currentTimeMillis();
|
||||
}
|
||||
});
|
||||
|
@ -6,6 +6,7 @@ package com.djrapitops.plan.system.info.server;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
@ -32,19 +33,19 @@ public class BukkitServerInfo extends ServerInfo {
|
||||
private final Lazy<WebServer> webServer;
|
||||
private final PlanConfig config;
|
||||
private ServerInfoFile serverInfoFile;
|
||||
private Database database;
|
||||
private DBSystem dbSystem;
|
||||
|
||||
@Inject
|
||||
public BukkitServerInfo(
|
||||
ServerProperties serverProperties,
|
||||
ServerInfoFile serverInfoFile,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
Lazy<WebServer> webServer,
|
||||
PlanConfig config
|
||||
) {
|
||||
super(serverProperties);
|
||||
this.serverInfoFile = serverInfoFile;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
this.config = config;
|
||||
}
|
||||
@ -73,6 +74,7 @@ public class BukkitServerInfo extends ServerInfo {
|
||||
}
|
||||
|
||||
private Server updateDbInfo(UUID serverUUID) throws IOException {
|
||||
Database database = dbSystem.getDatabase();
|
||||
Optional<Integer> serverID = database.fetch().getServerID(serverUUID);
|
||||
if (!serverID.isPresent()) {
|
||||
return registerServer(serverUUID);
|
||||
@ -99,14 +101,12 @@ public class BukkitServerInfo extends ServerInfo {
|
||||
int maxPlayers = serverProperties.getMaxPlayers();
|
||||
|
||||
Server server = new Server(-1, serverUUID, name, webAddress, maxPlayers);
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
database.save().serverInfoForThisServer(server);
|
||||
|
||||
Optional<Integer> serverID = database.fetch().getServerID(serverUUID);
|
||||
if (!serverID.isPresent()) {
|
||||
throw new IllegalStateException("Failed to Register Server (ID not found)");
|
||||
}
|
||||
|
||||
int id = serverID.get();
|
||||
int id = serverID.orElseThrow(() -> new IllegalStateException("Failed to Register Server (ID not found)"));
|
||||
server.setId(id);
|
||||
|
||||
serverInfoFile.saveServerUUID(serverUUID);
|
||||
|
@ -6,6 +6,7 @@ package com.djrapitops.plan.system.info.server;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
@ -25,19 +26,19 @@ import java.util.UUID;
|
||||
@Singleton
|
||||
public class BungeeServerInfo extends ServerInfo {
|
||||
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final Lazy<WebServer> webServer;
|
||||
private final PluginLogger logger;
|
||||
|
||||
@Inject
|
||||
public BungeeServerInfo(
|
||||
ServerProperties serverProperties,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
Lazy<WebServer> webServer,
|
||||
PluginLogger logger
|
||||
) {
|
||||
super(serverProperties);
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
this.logger = logger;
|
||||
}
|
||||
@ -47,6 +48,7 @@ public class BungeeServerInfo extends ServerInfo {
|
||||
checkIfDefaultIP();
|
||||
|
||||
try {
|
||||
Database database = dbSystem.getDatabase();
|
||||
Optional<Server> bungeeInfo = database.fetch().getBungeeInformation();
|
||||
if (bungeeInfo.isPresent()) {
|
||||
server = bungeeInfo.get();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.djrapitops.plan.system.info.server;
|
||||
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
@ -14,10 +14,10 @@ public class SpongeServerInfo extends BukkitServerInfo {
|
||||
public SpongeServerInfo(
|
||||
ServerProperties serverProperties,
|
||||
ServerInfoFile serverInfoFile,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
Lazy<WebServer> webServer,
|
||||
PlanConfig config
|
||||
) {
|
||||
super(serverProperties, serverInfoFile, database, webServer, config);
|
||||
super(serverProperties, serverInfoFile, dbSystem, webServer, config);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ package com.djrapitops.plan.system.info.server;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
@ -25,19 +26,19 @@ import java.util.UUID;
|
||||
@Singleton
|
||||
public class VelocityServerInfo extends ServerInfo {
|
||||
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final Lazy<WebServer> webServer;
|
||||
private final PluginLogger logger;
|
||||
|
||||
@Inject
|
||||
public VelocityServerInfo(
|
||||
ServerProperties serverProperties,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
Lazy<WebServer> webServer,
|
||||
PluginLogger logger
|
||||
) {
|
||||
super(serverProperties);
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
this.logger = logger;
|
||||
}
|
||||
@ -47,6 +48,7 @@ public class VelocityServerInfo extends ServerInfo {
|
||||
checkIfDefaultIP();
|
||||
|
||||
try {
|
||||
Database database = dbSystem.getDatabase();
|
||||
Optional<Server> bungeeInfo = database.fetch().getBungeeInformation();
|
||||
if (bungeeInfo.isPresent()) {
|
||||
server = bungeeInfo.get();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.system.processing.processors;
|
||||
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.processing.processors.info.InfoProcessors;
|
||||
import com.djrapitops.plan.system.processing.processors.player.PlayerProcessors;
|
||||
import dagger.Lazy;
|
||||
@ -21,26 +21,26 @@ public class Processors {
|
||||
private final PlayerProcessors playerProcessors;
|
||||
private final InfoProcessors infoProcessors;
|
||||
|
||||
private final Lazy<Database> database;
|
||||
private final Lazy<DBSystem> dbSystem;
|
||||
|
||||
@Inject
|
||||
public Processors(
|
||||
PlayerProcessors playerProcessors,
|
||||
InfoProcessors infoProcessors,
|
||||
|
||||
Lazy<Database> database
|
||||
Lazy<DBSystem> dbSystem
|
||||
) {
|
||||
this.playerProcessors = playerProcessors;
|
||||
this.infoProcessors = infoProcessors;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
}
|
||||
|
||||
public TPSInsertProcessor tpsInsertProcessor(List<TPS> tpsList) {
|
||||
return new TPSInsertProcessor(tpsList, database.get());
|
||||
return new TPSInsertProcessor(tpsList, dbSystem.get().getDatabase());
|
||||
}
|
||||
|
||||
public CommandProcessor commandProcessor(String command) {
|
||||
return new CommandProcessor(command, database.get());
|
||||
return new CommandProcessor(command, dbSystem.get().getDatabase());
|
||||
}
|
||||
|
||||
public PlayerProcessors player() {
|
||||
|
@ -4,7 +4,7 @@ import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import dagger.Lazy;
|
||||
@ -26,7 +26,7 @@ public class PlayerProcessors {
|
||||
|
||||
private final Lazy<Processing> processing;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final Lazy<Database> database;
|
||||
private final Lazy<DBSystem> dbSystem;
|
||||
private final Lazy<DataCache> dataCache;
|
||||
private final Lazy<GeolocationCache> geolocationCache;
|
||||
|
||||
@ -34,23 +34,23 @@ public class PlayerProcessors {
|
||||
public PlayerProcessors(
|
||||
Lazy<Processing> processing,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
Lazy<Database> database,
|
||||
Lazy<DBSystem> dbSystem,
|
||||
Lazy<DataCache> dataCache,
|
||||
Lazy<GeolocationCache> geolocationCache
|
||||
) {
|
||||
this.processing = processing;
|
||||
this.serverInfo = serverInfo;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.dataCache = dataCache;
|
||||
this.geolocationCache = geolocationCache;
|
||||
}
|
||||
|
||||
public BanAndOpProcessor banAndOpProcessor(UUID uuid, Supplier<Boolean> banned, boolean op) {
|
||||
return new BanAndOpProcessor(uuid, banned, op, database.get());
|
||||
return new BanAndOpProcessor(uuid, banned, op, dbSystem.get().getDatabase());
|
||||
}
|
||||
|
||||
public ProxyRegisterProcessor proxyRegisterProcessor(UUID uuid, String name, long registered, Runnable... afterProcess) {
|
||||
return new ProxyRegisterProcessor(uuid, name, registered, processing.get(), database.get(), afterProcess);
|
||||
return new ProxyRegisterProcessor(uuid, name, registered, processing.get(), dbSystem.get().getDatabase(), afterProcess);
|
||||
}
|
||||
|
||||
public EndSessionProcessor endSessionProcessor(UUID uuid, long time) {
|
||||
@ -58,24 +58,24 @@ public class PlayerProcessors {
|
||||
}
|
||||
|
||||
public IPUpdateProcessor ipUpdateProcessor(UUID uuid, InetAddress ip, long time) {
|
||||
return new IPUpdateProcessor(uuid, ip, time, database.get(), geolocationCache.get());
|
||||
return new IPUpdateProcessor(uuid, ip, time, dbSystem.get().getDatabase(), geolocationCache.get());
|
||||
}
|
||||
|
||||
public KickProcessor kickProcessor(UUID uuid) {
|
||||
return new KickProcessor(uuid, database.get());
|
||||
return new KickProcessor(uuid, dbSystem.get().getDatabase());
|
||||
}
|
||||
|
||||
public NameProcessor nameProcessor(UUID uuid, String playerName, String displayName) {
|
||||
Nickname nickname = new Nickname(displayName, System.currentTimeMillis(), serverInfo.get().getServerUUID());
|
||||
return new NameProcessor(uuid, playerName, nickname, database.get(), dataCache.get());
|
||||
return new NameProcessor(uuid, playerName, nickname, dbSystem.get().getDatabase(), dataCache.get());
|
||||
}
|
||||
|
||||
public PingInsertProcessor pingInsertProcessor(UUID uuid, List<DateObj<Integer>> pingList) {
|
||||
return new PingInsertProcessor(uuid, serverInfo.get().getServerUUID(), pingList, database.get());
|
||||
return new PingInsertProcessor(uuid, serverInfo.get().getServerUUID(), pingList, dbSystem.get().getDatabase());
|
||||
}
|
||||
|
||||
public RegisterProcessor registerProcessor(UUID uuid, Supplier<Long> registered, String name, Runnable... afterProcess) {
|
||||
return new RegisterProcessor(uuid, registered, name, processing.get(), database.get(), afterProcess);
|
||||
return new RegisterProcessor(uuid, registered, name, processing.get(), dbSystem.get().getDatabase(), afterProcess);
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.system.settings.network;
|
||||
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.ServerSpecificSettings;
|
||||
@ -42,7 +42,7 @@ public class NetworkSettings {
|
||||
private final Lazy<PlanConfig> config;
|
||||
private final ServerSpecificSettings serverSpecificSettings;
|
||||
private final Processing processing;
|
||||
private final Lazy<Database> database;
|
||||
private final Lazy<DBSystem> dbSystem;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
@ -52,7 +52,7 @@ public class NetworkSettings {
|
||||
Lazy<PlanConfig> config,
|
||||
ServerSpecificSettings serverSpecificSettings,
|
||||
Processing processing,
|
||||
Lazy<Database> database,
|
||||
Lazy<DBSystem> dbSystem,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
@ -60,7 +60,7 @@ public class NetworkSettings {
|
||||
this.config = config;
|
||||
this.serverSpecificSettings = serverSpecificSettings;
|
||||
this.processing = processing;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -90,7 +90,7 @@ public class NetworkSettings {
|
||||
|
||||
void loadFromDatabase() {
|
||||
logger.debug("NetworkSettings: Fetch Config settings from database..");
|
||||
Optional<String> encodedConfigSettings = database.get().transfer().getEncodedConfigSettings();
|
||||
Optional<String> encodedConfigSettings = dbSystem.get().getDatabase().transfer().getEncodedConfigSettings();
|
||||
|
||||
if (!encodedConfigSettings.isPresent()) {
|
||||
logger.debug("NetworkSettings: No Config settings in database.");
|
||||
@ -157,7 +157,7 @@ public class NetworkSettings {
|
||||
String base64 = Base64Util.encode(transferBuilder.toString());
|
||||
|
||||
logger.debug("NetworkSettings: Saving Config settings to database..");
|
||||
database.get().transfer().storeConfigSettings(base64);
|
||||
dbSystem.get().getDatabase().transfer().storeConfigSettings(base64);
|
||||
}
|
||||
|
||||
private Map<String, Object> getConfigValues() {
|
||||
@ -230,7 +230,7 @@ public class NetworkSettings {
|
||||
private void addServerSpecificValues(Map<String, Object> configValues) {
|
||||
logger.debug("NetworkSettings: Adding Server-specific Config Values..");
|
||||
|
||||
for (UUID serverUUID : database.get().fetch().getServerUUIDs()) {
|
||||
for (UUID serverUUID : dbSystem.get().getDatabase().fetch().getServerUUIDs()) {
|
||||
String theme = serverSpecificSettings.getString(serverUUID, THEME_BASE);
|
||||
Integer port = serverSpecificSettings.getInt(serverUUID, WEBSERVER_PORT);
|
||||
String name = serverSpecificSettings.getString(serverUUID, SERVER_NAME);
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver;
|
||||
|
||||
import com.djrapitops.plan.system.DebugChannels;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
@ -39,7 +39,7 @@ public class RequestHandler implements HttpHandler {
|
||||
private final Locale locale;
|
||||
private final PlanConfig config;
|
||||
private final Theme theme;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ResponseHandler responseHandler;
|
||||
private final Timings timings;
|
||||
private final PluginLogger logger;
|
||||
@ -50,7 +50,7 @@ public class RequestHandler implements HttpHandler {
|
||||
Locale locale,
|
||||
PlanConfig config,
|
||||
Theme theme,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ResponseHandler responseHandler,
|
||||
Timings timings,
|
||||
PluginLogger logger,
|
||||
@ -59,7 +59,7 @@ public class RequestHandler implements HttpHandler {
|
||||
this.locale = locale;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.responseHandler = responseHandler;
|
||||
this.timings = timings;
|
||||
this.logger = logger;
|
||||
@ -111,7 +111,7 @@ public class RequestHandler implements HttpHandler {
|
||||
|
||||
String authLine = authorization.get(0);
|
||||
if (authLine.contains("Basic ")) {
|
||||
return new BasicAuthentication(authLine.split(" ")[1], database);
|
||||
return new BasicAuthentication(authLine.split(" ")[1], dbSystem.getDatabase());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||
@ -33,19 +33,19 @@ import java.util.UUID;
|
||||
public class PlayerPageHandler implements PageHandler {
|
||||
|
||||
private final ResponseFactory responseFactory;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final InfoSystem infoSystem;
|
||||
private final UUIDUtility uuidUtility;
|
||||
|
||||
@Inject
|
||||
public PlayerPageHandler(
|
||||
ResponseFactory responseFactory,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
InfoSystem infoSystem,
|
||||
UUIDUtility uuidUtility
|
||||
) {
|
||||
this.responseFactory = responseFactory;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.infoSystem = infoSystem;
|
||||
this.uuidUtility = uuidUtility;
|
||||
}
|
||||
@ -66,7 +66,7 @@ public class PlayerPageHandler implements PageHandler {
|
||||
}
|
||||
try {
|
||||
// TODO Move this Database dependency to PlayerPage generation in PageFactory instead.
|
||||
if (database.check().isPlayerRegistered(uuid)) {
|
||||
if (dbSystem.getDatabase().check().isPlayerRegistered(uuid)) {
|
||||
if (raw) {
|
||||
return ResponseCache.loadResponse(PageId.RAW_PLAYER.of(uuid), () -> responseFactory.rawPlayerPageResponse(uuid));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
@ -36,7 +36,7 @@ public class ServerPageHandler implements PageHandler {
|
||||
|
||||
private final Processing processing;
|
||||
private final ResponseFactory responseFactory;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final InfoSystem infoSystem;
|
||||
|
||||
@ -44,13 +44,13 @@ public class ServerPageHandler implements PageHandler {
|
||||
public ServerPageHandler(
|
||||
Processing processing,
|
||||
ResponseFactory responseFactory,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
InfoSystem infoSystem
|
||||
) {
|
||||
this.processing = processing;
|
||||
this.responseFactory = responseFactory;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.infoSystem = infoSystem;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class ServerPageHandler implements PageHandler {
|
||||
if (!target.isEmpty()) {
|
||||
try {
|
||||
String serverName = target.get(0).replace("%20", " ");
|
||||
Optional<UUID> serverUUIDOptional = database.fetch().getServerUUID(serverName);
|
||||
Optional<UUID> serverUUIDOptional = dbSystem.getDatabase().fetch().getServerUUID(serverName);
|
||||
if (serverUUIDOptional.isPresent()) {
|
||||
serverUUID = serverUUIDOptional.get();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.system.webserver.response;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.ErrorPageLang;
|
||||
@ -30,7 +30,7 @@ public class ResponseFactory {
|
||||
private final PlanFiles files;
|
||||
private final PageFactory pageFactory;
|
||||
private final Locale locale;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
@ -39,14 +39,14 @@ public class ResponseFactory {
|
||||
PlanFiles files,
|
||||
PageFactory pageFactory,
|
||||
Locale locale,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.version = version;
|
||||
this.files = files;
|
||||
this.pageFactory = pageFactory;
|
||||
this.locale = locale;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@ -88,11 +88,11 @@ public class ResponseFactory {
|
||||
}
|
||||
|
||||
public RawDataResponse rawPlayerPageResponse(UUID uuid) {
|
||||
return new RawPlayerDataResponse(database.fetch().getPlayerContainer(uuid));
|
||||
return new RawPlayerDataResponse(dbSystem.getDatabase().fetch().getPlayerContainer(uuid));
|
||||
}
|
||||
|
||||
public RawDataResponse rawServerPageResponse(UUID serverUUID) {
|
||||
return new RawServerDataResponse(database.fetch().getServerContainer(serverUUID));
|
||||
return new RawServerDataResponse(dbSystem.getDatabase().fetch().getServerContainer(serverUUID));
|
||||
}
|
||||
|
||||
public Response javaScriptResponse(String fileName) {
|
||||
|
@ -8,7 +8,7 @@ import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
@ -43,7 +43,7 @@ public class HtmlExport extends SpecificExport {
|
||||
private final Theme theme;
|
||||
private final Processing processing;
|
||||
private final PlanFiles files;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final PageFactory pageFactory;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
@ -55,7 +55,7 @@ public class HtmlExport extends SpecificExport {
|
||||
PlanConfig config,
|
||||
Theme theme,
|
||||
Processing processing,
|
||||
Database database,
|
||||
DBSystem dbSystem,
|
||||
PageFactory pageFactory,
|
||||
ServerInfo serverInfo,
|
||||
ConnectionSystem connectionSystem,
|
||||
@ -66,7 +66,7 @@ public class HtmlExport extends SpecificExport {
|
||||
this.theme = theme;
|
||||
this.processing = processing;
|
||||
this.files = files;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.pageFactory = pageFactory;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -76,7 +76,7 @@ public class HtmlExport extends SpecificExport {
|
||||
if (Check.isBukkitAvailable() && connectionSystem.isServerAvailable()) {
|
||||
return;
|
||||
}
|
||||
Optional<String> serverName = database.fetch().getServerName(serverUUID);
|
||||
Optional<String> serverName = dbSystem.getDatabase().fetch().getServerName(serverUUID);
|
||||
serverName.ifPresent(name -> processing.submitNonCritical(() -> {
|
||||
try {
|
||||
exportAvailableServerPage(serverUUID, name);
|
||||
@ -90,7 +90,7 @@ public class HtmlExport extends SpecificExport {
|
||||
if (Check.isBukkitAvailable() && connectionSystem.isServerAvailable()) {
|
||||
return;
|
||||
}
|
||||
String playerName = database.fetch().getPlayerName(uuid);
|
||||
String playerName = dbSystem.getDatabase().fetch().getPlayerName(uuid);
|
||||
if (playerName != null) {
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
@ -137,13 +137,13 @@ public class HtmlExport extends SpecificExport {
|
||||
}
|
||||
|
||||
private void exportAvailablePlayers() throws IOException {
|
||||
for (Map.Entry<UUID, UserInfo> entry : database.fetch().getUsers().entrySet()) {
|
||||
for (Map.Entry<UUID, UserInfo> entry : dbSystem.getDatabase().fetch().getUsers().entrySet()) {
|
||||
exportAvailablePlayerPage(entry.getKey(), entry.getValue().getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void exportAvailableServerPages() throws IOException {
|
||||
Map<UUID, String> serverNames = database.fetch().getServerNames();
|
||||
Map<UUID, String> serverNames = dbSystem.getDatabase().fetch().getServerNames();
|
||||
|
||||
for (Map.Entry<UUID, String> entry : serverNames.entrySet()) {
|
||||
exportAvailableServerPage(entry.getKey(), entry.getValue());
|
||||
|
@ -4,7 +4,8 @@ import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.store.containers.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.store.containers.NetworkContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
@ -39,7 +40,7 @@ public class PageFactory {
|
||||
private final Lazy<PlanFiles> fileSystem;
|
||||
private final Lazy<PlanConfig> config;
|
||||
private final Lazy<Theme> theme;
|
||||
private final Lazy<Database> database;
|
||||
private final Lazy<DBSystem> dbSystem;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final Lazy<ConnectionSystem> connectionSystem;
|
||||
private final Lazy<Graphs> graphs;
|
||||
@ -59,7 +60,7 @@ public class PageFactory {
|
||||
Lazy<PlanFiles> fileSystem,
|
||||
Lazy<PlanConfig> config,
|
||||
Lazy<Theme> theme,
|
||||
Lazy<Database> database,
|
||||
Lazy<DBSystem> dbSystem,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
Lazy<ConnectionSystem> connectionSystem,
|
||||
Lazy<Graphs> graphs,
|
||||
@ -77,7 +78,7 @@ public class PageFactory {
|
||||
this.fileSystem = fileSystem;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.graphs = graphs;
|
||||
@ -95,26 +96,27 @@ public class PageFactory {
|
||||
public DebugPage debugPage() {
|
||||
return new DebugPage(
|
||||
version,
|
||||
database.get(), serverInfo.get(), connectionSystem.get(), formatters.get(),
|
||||
dbSystem.get().getDatabase(), serverInfo.get(), connectionSystem.get(), formatters.get(),
|
||||
debugLogger.get(), timings.get(), errorHandler.get()
|
||||
);
|
||||
}
|
||||
|
||||
public PlayersPage playersPage() {
|
||||
return new PlayersPage(version, fileSystem.get(), config.get(),
|
||||
database.get(), serverInfo.get(), tables.get(),
|
||||
dbSystem.get().getDatabase(), serverInfo.get(), tables.get(),
|
||||
timings.get());
|
||||
}
|
||||
|
||||
public AnalysisPage analysisPage(UUID serverUUID) {
|
||||
AnalysisContainer analysisContainer = analysisContainerFactory.get()
|
||||
.forServerContainer(database.get().fetch().getServerContainer(serverUUID));
|
||||
.forServerContainer(dbSystem.get().getDatabase().fetch().getServerContainer(serverUUID));
|
||||
return new AnalysisPage(analysisContainer, fileSystem.get(), formatters.get().decimals(), timings.get());
|
||||
}
|
||||
|
||||
public InspectPage inspectPage(UUID uuid) {
|
||||
PlayerContainer player = database.get().fetch().getPlayerContainer(uuid);
|
||||
Map<UUID, String> serverNames = database.get().fetch().getServerNames();
|
||||
FetchOperations fetch = dbSystem.get().getDatabase().fetch();
|
||||
PlayerContainer player = fetch.getPlayerContainer(uuid);
|
||||
Map<UUID, String> serverNames = fetch.getServerNames();
|
||||
return new InspectPage(
|
||||
player, serverNames,
|
||||
version,
|
||||
@ -129,7 +131,7 @@ public class PageFactory {
|
||||
}
|
||||
|
||||
public NetworkPage networkPage() {
|
||||
NetworkContainer networkContainer = database.get().fetch().getNetworkContainer(); // Not cached, big.
|
||||
NetworkContainer networkContainer = dbSystem.get().getDatabase().fetch().getNetworkContainer(); // Not cached, big.
|
||||
return new NetworkPage(networkContainer,
|
||||
analysisPluginsTabContentCreator.get(),
|
||||
fileSystem.get(), serverInfo.get().getServerProperties());
|
||||
|
@ -25,7 +25,7 @@ public class BStatsBukkit {
|
||||
if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) {
|
||||
serverType = "Spigot";
|
||||
}
|
||||
String databaseType = plugin.getSystem().getDatabaseSystem().getActiveDatabase().getName();
|
||||
String databaseType = plugin.getSystem().getDatabaseSystem().getDatabase().getName();
|
||||
|
||||
addStringSettingPie("server_type", serverType);
|
||||
addStringSettingPie("database_type", databaseType);
|
||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.utilities.uuid;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plugin.api.utility.UUIDFetcher;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -23,13 +23,13 @@ import java.util.UUID;
|
||||
public class UUIDUtility {
|
||||
|
||||
private final DataCache dataCache;
|
||||
private final Database database;
|
||||
private final DBSystem dbSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public UUIDUtility(DataCache dataCache, Database database, ErrorHandler errorHandler) {
|
||||
public UUIDUtility(DataCache dataCache, DBSystem dbSystem, ErrorHandler errorHandler) {
|
||||
this.dataCache = dataCache;
|
||||
this.database = database;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class UUIDUtility {
|
||||
return uuidOf;
|
||||
}
|
||||
try {
|
||||
uuid = database.fetch().getUuidOf(playerName);
|
||||
uuid = dbSystem.getDatabase().fetch().getUuidOf(playerName);
|
||||
} catch (DBOpException e) {
|
||||
errorHandler.log(L.ERROR, UUIDUtility.class, e);
|
||||
}
|
||||
|
@ -2,10 +2,12 @@
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package com.djrapitops.plan.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -22,18 +24,22 @@ public class BukkitSystemTest {
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
private static Plan planMock;
|
||||
private PlanSystem bukkitSystem;
|
||||
private static PlanComponent COMPONENT;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
PlanBukkitMocker mockUtil = PlanBukkitMocker.setUp()
|
||||
.withDataFolder(temporaryFolder.getRoot())
|
||||
.withLogging()
|
||||
.withDataFolder(temporaryFolder.newFolder())
|
||||
.withPluginDescription()
|
||||
.withResourceFetchingFromJar()
|
||||
.withServer();
|
||||
planMock = mockUtil.getPlanMock();
|
||||
COMPONENT = DaggerPlanComponent.builder().plan(mockUtil.getPlanMock()).build();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
bukkitSystem = COMPONENT.system();
|
||||
}
|
||||
|
||||
@After
|
||||
@ -44,11 +50,9 @@ public class BukkitSystemTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEnable() throws EnableException {
|
||||
// Settings.WEBSERVER_PORT.setTemporaryValue(9005);
|
||||
|
||||
bukkitSystem = null; //TODO
|
||||
PlanConfig config = bukkitSystem.getConfigSystem().getConfig();
|
||||
config.set(Settings.WEBSERVER_PORT, 9005);
|
||||
bukkitSystem.enable();
|
||||
}
|
||||
}
|
@ -2,11 +2,10 @@
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package com.djrapitops.plan.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
@ -2,10 +2,10 @@
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package com.djrapitops.plan.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
@ -2,10 +2,10 @@
|
||||
* License is provided in the jar as LICENSE also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/LICENSE
|
||||
*/
|
||||
package com.djrapitops.plan.system;
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.PlanSponge;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
@ -49,7 +49,7 @@ public class HTTPSWebServerAuthTest {
|
||||
bukkitSystem = null; //TODO
|
||||
// bukkitSystem.enable();
|
||||
//
|
||||
// bukkitSystem.getDatabaseSystem().getActiveDatabase().save()
|
||||
// bukkitSystem.getDatabaseSystem().getDatabase().save()
|
||||
// .webUser(new WebUser("test", PassEncryptUtil.createHash("testPass"), 0));
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,15 @@
|
||||
package utilities.mocks;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.debug.CombineDebugLogger;
|
||||
import com.djrapitops.plugin.logging.debug.DebugLogger;
|
||||
import com.djrapitops.plugin.logging.debug.MemoryDebugLogger;
|
||||
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plugin.task.thread.ThreadRunnableFactory;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -21,7 +28,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import static org.mockito.Mockito.doCallRealMethod;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
/**
|
||||
@ -44,11 +50,22 @@ public class PlanBukkitMocker extends Mocker {
|
||||
planMock = Mockito.mock(Plan.class);
|
||||
super.planMock = planMock;
|
||||
|
||||
doCallRealMethod().when(planMock).getVersion();
|
||||
doCallRealMethod().when(planMock).getColorScheme();
|
||||
doReturn(new ColorScheme("§1", "§2", "§3")).when(planMock).getColorScheme();
|
||||
doReturn("1.0.0").when(planMock).getVersion();
|
||||
|
||||
TestLogger testLogger = new TestLogger();
|
||||
ThreadRunnableFactory runnableFactory = new ThreadRunnableFactory();
|
||||
PluginLogger testPluginLogger = new TestPluginLogger();
|
||||
DebugLogger debugLogger = new CombineDebugLogger(new MemoryDebugLogger());
|
||||
ErrorHandler consoleErrorLogger = new ConsoleErrorLogger(testPluginLogger);
|
||||
Timings timings = new Timings(debugLogger);
|
||||
|
||||
doReturn(testLogger).when(planMock).getLogger();
|
||||
doReturn(runnableFactory).when(planMock).getRunnableFactory();
|
||||
doReturn(testPluginLogger).when(planMock).getPluginLogger();
|
||||
doReturn(debugLogger).when(planMock).getDebugLogger();
|
||||
doReturn(consoleErrorLogger).when(planMock).getErrorHandler();
|
||||
doReturn(timings).when(planMock).getTimings();
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -58,13 +75,8 @@ public class PlanBukkitMocker extends Mocker {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PlanBukkitMocker withLogging() {
|
||||
TestLogger testLogger = new TestLogger();
|
||||
doReturn(testLogger).when(planMock).getLogger();
|
||||
TestPluginLogger testPluginLogger = new TestPluginLogger();
|
||||
doReturn(testPluginLogger).when(planMock).getPluginLogger();
|
||||
ConsoleErrorLogger consoleErrorLogger = new ConsoleErrorLogger(testPluginLogger);
|
||||
doReturn(consoleErrorLogger).when(planMock).getErrorHandler();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package module;
|
||||
package utilities.module;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plugin.IPlugin;
|
Loading…
Reference in New Issue
Block a user