mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-10 13:49:17 +01:00
Bukkit ServerInfo
This commit is contained in:
parent
45ba9d02c0
commit
34198543ff
@ -32,6 +32,9 @@ import com.djrapitops.plan.system.cache.GeolocationCache;
|
|||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
|
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||||
import com.djrapitops.plan.system.processing.processors.importing.importers.OfflinePlayerImporter;
|
import com.djrapitops.plan.system.processing.processors.importing.importers.OfflinePlayerImporter;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
@ -42,13 +45,11 @@ import com.djrapitops.plan.system.webserver.WebServerSystem;
|
|||||||
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||||
import com.djrapitops.plan.systems.info.ImporterManager;
|
import com.djrapitops.plan.systems.info.ImporterManager;
|
||||||
import com.djrapitops.plan.systems.info.InformationManager;
|
import com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import com.djrapitops.plan.system.info.server.BukkitServerInfoManager;
|
|
||||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||||
import com.djrapitops.plan.utilities.metrics.BStats;
|
import com.djrapitops.plan.utilities.metrics.BStats;
|
||||||
import com.djrapitops.plugin.BukkitPlugin;
|
import com.djrapitops.plugin.BukkitPlugin;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
import com.djrapitops.plugin.api.Benchmark;
|
||||||
import com.djrapitops.plugin.api.config.Config;
|
|
||||||
import com.djrapitops.plugin.api.systems.TaskCenter;
|
import com.djrapitops.plugin.api.systems.TaskCenter;
|
||||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
@ -76,9 +77,9 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
private HookHandler hookHandler; // Manages 3rd party data sources
|
private HookHandler hookHandler; // Manages 3rd party data sources
|
||||||
|
|
||||||
private BukkitInformationManager infoManager;
|
private BukkitInformationManager infoManager;
|
||||||
private BukkitServerInfoManager serverInfoManager;
|
private BukkitServerInfo serverInfoManager;
|
||||||
|
|
||||||
private ServerVariableHolder serverVariableHolder;
|
private ServerProperties serverProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to get the plugin-instance singleton.
|
* Used to get the plugin-instance singleton.
|
||||||
@ -94,7 +95,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UUID getServerUuid() {
|
public UUID getServerUuid() {
|
||||||
return serverInfoManager.getServerUUID();
|
return ServerInfo.getServerUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,14 +129,14 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
Theme.getInstance().enable();
|
Theme.getInstance().enable();
|
||||||
|
|
||||||
Benchmark.start("Reading server variables");
|
Benchmark.start("Reading server variables");
|
||||||
serverVariableHolder = new ServerVariableHolder(getServer());
|
serverProperties = new ServerProperties(getServer());
|
||||||
Benchmark.stop("Enable", "Reading server variables");
|
Benchmark.stop("Enable", "Reading server variables");
|
||||||
|
|
||||||
DBSystem.getInstance().enable();
|
DBSystem.getInstance().enable();
|
||||||
|
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
|
|
||||||
serverInfoManager = new BukkitServerInfoManager(this);
|
serverInfoManager = new BukkitServerInfo(this);
|
||||||
infoManager = new BukkitInformationManager(this);
|
infoManager = new BukkitInformationManager(this);
|
||||||
WebServerSystem.getInstance().enable();
|
WebServerSystem.getInstance().enable();
|
||||||
if (!WebServerSystem.isWebServerEnabled()) {
|
if (!WebServerSystem.isWebServerEnabled()) {
|
||||||
@ -156,7 +157,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
boolean usingBungeeWebServer = infoManager.isUsingAnotherWebServer();
|
boolean usingBungeeWebServer = infoManager.isUsingAnotherWebServer();
|
||||||
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||||
|
|
||||||
if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) {
|
if (!usingAlternativeIP && serverProperties.getIp().isEmpty()) {
|
||||||
Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString());
|
Log.infoColor(Locale.get(Msg.ENABLE_NOTIFY_EMPTY_IP).toString());
|
||||||
}
|
}
|
||||||
if (usingBungeeWebServer && usingAlternativeIP) {
|
if (usingBungeeWebServer && usingAlternativeIP) {
|
||||||
@ -259,28 +260,25 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
|||||||
* Used to get the object storing server variables that are constant after
|
* Used to get the object storing server variables that are constant after
|
||||||
* boot.
|
* boot.
|
||||||
*
|
*
|
||||||
* @return ServerVariableHolder
|
* @return ServerProperties
|
||||||
* @see ServerVariableHolder
|
* @see ServerProperties
|
||||||
*/
|
*/
|
||||||
public ServerVariableHolder getVariable() {
|
@Deprecated
|
||||||
return serverVariableHolder;
|
public ServerProperties getVariable() {
|
||||||
|
return serverProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to get the object storing server info
|
* Used to get the object storing server info
|
||||||
*
|
*
|
||||||
* @return BukkitServerInfoManager
|
* @return BukkitServerInfo
|
||||||
* @see BukkitServerInfoManager
|
* @see BukkitServerInfo
|
||||||
*/
|
*/
|
||||||
public BukkitServerInfoManager getServerInfoManager() {
|
@Deprecated
|
||||||
|
public BukkitServerInfo getServerInfoManager() {
|
||||||
return serverInfoManager;
|
return serverInfoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Config getMainConfig() {
|
|
||||||
return ConfigSystem.getInstance().getConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public InformationManager getInfoManager() {
|
public InformationManager getInfoManager() {
|
||||||
return infoManager;
|
return infoManager;
|
||||||
|
@ -13,6 +13,8 @@ import com.djrapitops.plan.system.BungeeSystem;
|
|||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
|
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||||
@ -21,7 +23,6 @@ import com.djrapitops.plan.system.webserver.WebServer;
|
|||||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||||
import com.djrapitops.plan.systems.info.BungeeInformationManager;
|
import com.djrapitops.plan.systems.info.BungeeInformationManager;
|
||||||
import com.djrapitops.plan.systems.info.InformationManager;
|
import com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import com.djrapitops.plan.system.info.server.BungeeServerInfoManager;
|
|
||||||
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
import com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||||
import com.djrapitops.plugin.BungeePlugin;
|
import com.djrapitops.plugin.BungeePlugin;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
@ -45,9 +46,9 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
|
|
||||||
private BungeeSystem system;
|
private BungeeSystem system;
|
||||||
|
|
||||||
private BungeeServerInfoManager serverInfoManager;
|
private BungeeServerInfo serverInfoManager;
|
||||||
private BungeeInformationManager infoManager;
|
private BungeeInformationManager infoManager;
|
||||||
private ServerVariableHolder variableHolder;
|
private ServerProperties variableHolder;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private boolean setupAllowed = false;
|
private boolean setupAllowed = false;
|
||||||
@ -71,7 +72,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
|
|
||||||
VersionCheckSystem.getInstance().enable();
|
VersionCheckSystem.getInstance().enable();
|
||||||
|
|
||||||
variableHolder = new ServerVariableHolder(getProxy());
|
variableHolder = new ServerProperties(getProxy());
|
||||||
|
|
||||||
new Locale().loadLocale();
|
new Locale().loadLocale();
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
|
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
|
|
||||||
serverInfoManager = new BungeeServerInfoManager(this);
|
serverInfoManager = new BungeeServerInfo(this);
|
||||||
infoManager = new BungeeInformationManager(this);
|
infoManager = new BungeeInformationManager(this);
|
||||||
|
|
||||||
WebServerSystem.getInstance().enable();
|
WebServerSystem.getInstance().enable();
|
||||||
@ -132,7 +133,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
return DBSystem.getInstance().getActiveDatabase();
|
return DBSystem.getInstance().getActiveDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BungeeServerInfoManager getServerInfoManager() {
|
public BungeeServerInfo getServerInfoManager() {
|
||||||
return serverInfoManager;
|
return serverInfoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerVariableHolder getVariable() {
|
public ServerProperties getVariable() {
|
||||||
return variableHolder;
|
return variableHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package com.djrapitops.plan;
|
package com.djrapitops.plan;
|
||||||
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||||
import com.djrapitops.plan.system.webserver.WebServer;
|
import com.djrapitops.plan.system.webserver.WebServer;
|
||||||
import com.djrapitops.plan.systems.info.InformationManager;
|
import com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import com.djrapitops.plugin.IPlugin;
|
import com.djrapitops.plugin.IPlugin;
|
||||||
@ -38,7 +39,7 @@ public interface PlanPlugin extends IPlugin {
|
|||||||
Database getDB();
|
Database getDB();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
ServerVariableHolder getVariable();
|
ServerProperties getVariable();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
UUID getServerUuid();
|
UUID getServerUuid();
|
||||||
|
@ -4,7 +4,7 @@ import com.djrapitops.plan.Plan;
|
|||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.Msg;
|
import com.djrapitops.plan.settings.locale.Msg;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.system.settings.Permissions;
|
import com.djrapitops.plan.system.settings.Permissions;
|
||||||
import com.djrapitops.plan.systems.info.InformationManager;
|
import com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
@ -86,8 +86,8 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
UUID serverUUID = Plan.getServerUUID();
|
UUID serverUUID = Plan.getServerUUID();
|
||||||
if (args.length >= 1 && plugin.getInfoManager().isUsingAnotherWebServer()) {
|
if (args.length >= 1 && plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||||
try {
|
try {
|
||||||
List<ServerInfo> bukkitServers = plugin.getDB().getServerTable().getBukkitServers();
|
List<Server> bukkitServers = plugin.getDB().getServerTable().getBukkitServers();
|
||||||
Optional<ServerInfo> server = bukkitServers.stream().filter(info -> {
|
Optional<Server> server = bukkitServers.stream().filter(info -> {
|
||||||
StringBuilder idBuilder = new StringBuilder(args[0]);
|
StringBuilder idBuilder = new StringBuilder(args[0]);
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
@ -8,6 +8,7 @@ import com.djrapitops.plan.Plan;
|
|||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.settings.locale.Msg;
|
import com.djrapitops.plan.settings.locale.Msg;
|
||||||
|
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI;
|
||||||
import com.djrapitops.plan.utilities.Condition;
|
import com.djrapitops.plan.utilities.Condition;
|
||||||
@ -48,9 +49,10 @@ public class DevCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "web":
|
case "web":
|
||||||
Optional<String> bungeeConnectionAddress = plugin.getServerInfoManager().getBungeeConnectionAddress();
|
ConnectionSystem connectionSystem = ConnectionSystem.getInstance();
|
||||||
|
Optional<String> bungeeConnectionAddress = connectionSystem.getMainAddress();
|
||||||
String accessAddress = plugin.getWebServer().getAccessAddress();
|
String accessAddress = plugin.getWebServer().getAccessAddress();
|
||||||
sender.sendMessage((plugin.getInfoManager().isUsingAnotherWebServer() && bungeeConnectionAddress.isPresent())
|
sender.sendMessage((connectionSystem.isMainServerAvailable() && bungeeConnectionAddress.isPresent())
|
||||||
? "Bungee: " + bungeeConnectionAddress.get() : "Local: " + accessAddress);
|
? "Bungee: " + bungeeConnectionAddress.get() : "Local: " + accessAddress);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -6,12 +6,12 @@ package com.djrapitops.plan.data;
|
|||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
|
||||||
import com.djrapitops.plan.data.container.GeoInfo;
|
import com.djrapitops.plan.data.container.GeoInfo;
|
||||||
import com.djrapitops.plan.data.container.PlayerKill;
|
import com.djrapitops.plan.data.container.PlayerKill;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.data.container.TPS;
|
import com.djrapitops.plan.data.container.TPS;
|
||||||
import com.djrapitops.plan.data.time.WorldTimes;
|
import com.djrapitops.plan.data.time.WorldTimes;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
import com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||||
@ -118,7 +118,7 @@ public class ServerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getPlayersMax() {
|
public static int getPlayersMax() {
|
||||||
return PlanPlugin.getInstance().getVariable().getMaxPlayers();
|
return ServerInfo.getServerProperties().getMaxPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long serverDownTime(List<TPS> tpsData) {
|
public static long serverDownTime(List<TPS> tpsData) {
|
||||||
|
@ -9,13 +9,13 @@ import com.djrapitops.plan.system.cache.CacheSystem;
|
|||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
import com.djrapitops.plan.system.info.InfoSystem;
|
import com.djrapitops.plan.system.info.InfoSystem;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||||
import com.djrapitops.plan.system.processing.ProcessingQueue;
|
import com.djrapitops.plan.system.processing.ProcessingQueue;
|
||||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
|
||||||
import com.djrapitops.plan.utilities.NullCheck;
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
|
|
||||||
protected ListenerSystem listenerSystem;
|
protected ListenerSystem listenerSystem;
|
||||||
protected TaskSystem taskSystem;
|
protected TaskSystem taskSystem;
|
||||||
|
protected ServerInfo serverInfo;
|
||||||
|
|
||||||
public PlanSystem() {
|
public PlanSystem() {
|
||||||
processingQueue = new ProcessingQueue();
|
processingQueue = new ProcessingQueue();
|
||||||
@ -72,6 +73,7 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
configSystem,
|
configSystem,
|
||||||
databaseSystem,
|
databaseSystem,
|
||||||
webServerSystem,
|
webServerSystem,
|
||||||
|
serverInfo,
|
||||||
infoSystem,
|
infoSystem,
|
||||||
processingQueue,
|
processingQueue,
|
||||||
cacheSystem,
|
cacheSystem,
|
||||||
@ -90,8 +92,9 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
listenerSystem,
|
listenerSystem,
|
||||||
processingQueue,
|
processingQueue,
|
||||||
databaseSystem,
|
databaseSystem,
|
||||||
infoSystem,
|
|
||||||
webServerSystem,
|
webServerSystem,
|
||||||
|
infoSystem,
|
||||||
|
serverInfo,
|
||||||
taskSystem,
|
taskSystem,
|
||||||
configSystem,
|
configSystem,
|
||||||
fileSystem,
|
fileSystem,
|
||||||
@ -153,7 +156,7 @@ public abstract class PlanSystem implements SubSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerInfo getServerInfo() {
|
public ServerInfo getServerInfo() {
|
||||||
return null; // TODO
|
return serverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CacheSystem getCacheSystem() {
|
public CacheSystem getCacheSystem() {
|
||||||
|
@ -5,6 +5,7 @@ import com.djrapitops.plan.data.PlayerProfile;
|
|||||||
import com.djrapitops.plan.data.ServerProfile;
|
import com.djrapitops.plan.data.ServerProfile;
|
||||||
import com.djrapitops.plan.data.WebUser;
|
import com.djrapitops.plan.data.WebUser;
|
||||||
import com.djrapitops.plan.data.container.*;
|
import com.djrapitops.plan.data.container.*;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -34,6 +35,14 @@ public interface FetchOperations {
|
|||||||
|
|
||||||
WebUser getWebUser(String username) throws DBException;
|
WebUser getWebUser(String username) throws DBException;
|
||||||
|
|
||||||
|
// Servers
|
||||||
|
|
||||||
|
Optional<String> getServerName(UUID serverUUID) throws DBException;
|
||||||
|
|
||||||
|
Optional<Server> getBungeeInformation() throws DBException;
|
||||||
|
|
||||||
|
Optional<Integer> getServerID(UUID serverUUID);
|
||||||
|
|
||||||
// Raw Data
|
// Raw Data
|
||||||
|
|
||||||
List<TPS> getTPSData(UUID serverUUID) throws DBException;
|
List<TPS> getTPSData(UUID serverUUID) throws DBException;
|
||||||
@ -66,7 +75,5 @@ public interface FetchOperations {
|
|||||||
|
|
||||||
String getPlayerName(UUID playerUUID) throws DBException;
|
String getPlayerName(UUID playerUUID) throws DBException;
|
||||||
|
|
||||||
Optional<String> getServerName(UUID serverUUID) throws DBException;
|
|
||||||
|
|
||||||
List<String> getNicknames(UUID uuid) throws DBException;
|
List<String> getNicknames(UUID uuid) throws DBException;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ package com.djrapitops.plan.system.database.databases.operation;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.container.*;
|
import com.djrapitops.plan.data.container.*;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -64,4 +65,6 @@ public interface SaveOperations {
|
|||||||
void insertTPSforThisServer(TPS tps) throws DBException;
|
void insertTPSforThisServer(TPS tps) throws DBException;
|
||||||
|
|
||||||
void session(UUID uuid, Session session) throws DBException;
|
void session(UUID uuid, Session session) throws DBException;
|
||||||
|
|
||||||
|
void serverInfoForThisServer(Server server) throws DBException;
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.ExecStatemen
|
|||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.statements.*;
|
import com.djrapitops.plan.system.database.databases.sql.statements.*;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -77,7 +77,7 @@ public class ServerTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCurrentServerInfo(ServerInfo info) throws SQLException {
|
public void saveCurrentServerInfo(Server info) throws SQLException {
|
||||||
if (getServerID(info.getUuid()).isPresent()) {
|
if (getServerID(info.getUuid()).isPresent()) {
|
||||||
updateServerInfo(info);
|
updateServerInfo(info);
|
||||||
} else {
|
} else {
|
||||||
@ -85,7 +85,7 @@ public class ServerTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateServerInfo(ServerInfo info) throws SQLException {
|
private void updateServerInfo(Server info) throws SQLException {
|
||||||
String sql = Update.values(tableName,
|
String sql = Update.values(tableName,
|
||||||
columnServerUUID,
|
columnServerUUID,
|
||||||
columnServerName,
|
columnServerName,
|
||||||
@ -112,10 +112,10 @@ public class ServerTable extends Table {
|
|||||||
* Inserts new row for a server into the table.
|
* Inserts new row for a server into the table.
|
||||||
*
|
*
|
||||||
* @param info Info to instert (All variables should be present.
|
* @param info Info to instert (All variables should be present.
|
||||||
* @throws IllegalStateException if one of the ServerInfo variables is null
|
* @throws IllegalStateException if one of the Server variables is null
|
||||||
* @throws SQLException DB Error
|
* @throws SQLException DB Error
|
||||||
*/
|
*/
|
||||||
private void saveNewServerInfo(ServerInfo info) throws SQLException {
|
private void saveNewServerInfo(Server info) throws SQLException {
|
||||||
UUID uuid = info.getUuid();
|
UUID uuid = info.getUuid();
|
||||||
String name = info.getName();
|
String name = info.getName();
|
||||||
String webAddress = info.getWebAddress();
|
String webAddress = info.getWebAddress();
|
||||||
@ -253,21 +253,21 @@ public class ServerTable extends Table {
|
|||||||
* @return information about Bungee server.
|
* @return information about Bungee server.
|
||||||
* @throws SQLException DB Error
|
* @throws SQLException DB Error
|
||||||
*/
|
*/
|
||||||
public Optional<ServerInfo> getBungeeInfo() throws SQLException {
|
public Optional<Server> getBungeeInfo() throws SQLException {
|
||||||
String sql = Select.from(tableName, "*")
|
String sql = Select.from(tableName, "*")
|
||||||
.where(columnServerName + "=?")
|
.where(columnServerName + "=?")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
return query(new QueryStatement<Optional<ServerInfo>>(sql) {
|
return query(new QueryStatement<Optional<Server>>(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, "BungeeCord");
|
statement.setString(1, "BungeeCord");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ServerInfo> processResults(ResultSet set) throws SQLException {
|
public Optional<Server> processResults(ResultSet set) throws SQLException {
|
||||||
if (set.next()) {
|
if (set.next()) {
|
||||||
return Optional.of(new ServerInfo(
|
return Optional.of(new Server(
|
||||||
set.getInt(columnServerID),
|
set.getInt(columnServerID),
|
||||||
UUID.fromString(set.getString(columnServerUUID)),
|
UUID.fromString(set.getString(columnServerUUID)),
|
||||||
set.getString(columnServerName),
|
set.getString(columnServerName),
|
||||||
@ -280,22 +280,22 @@ public class ServerTable extends Table {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ServerInfo> getBukkitServers() throws SQLException {
|
public List<Server> getBukkitServers() throws SQLException {
|
||||||
String sql = Select.from(tableName, "*")
|
String sql = Select.from(tableName, "*")
|
||||||
.where(columnServerName + "!=?")
|
.where(columnServerName + "!=?")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
return query(new QueryStatement<List<ServerInfo>>(sql, 100) {
|
return query(new QueryStatement<List<Server>>(sql, 100) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, "BungeeCord");
|
statement.setString(1, "BungeeCord");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ServerInfo> processResults(ResultSet set) throws SQLException {
|
public List<Server> processResults(ResultSet set) throws SQLException {
|
||||||
List<ServerInfo> servers = new ArrayList<>();
|
List<Server> servers = new ArrayList<>();
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
servers.add(new ServerInfo(
|
servers.add(new Server(
|
||||||
set.getInt(columnServerID),
|
set.getInt(columnServerID),
|
||||||
UUID.fromString(set.getString(columnServerUUID)),
|
UUID.fromString(set.getString(columnServerUUID)),
|
||||||
set.getString(columnServerName),
|
set.getString(columnServerName),
|
||||||
@ -315,15 +315,15 @@ public class ServerTable extends Table {
|
|||||||
return columnServerUUID;
|
return columnServerUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAllServers(List<ServerInfo> allServerInfo) throws SQLException {
|
public void insertAllServers(List<Server> allServer) throws SQLException {
|
||||||
if (Verify.isEmpty(allServerInfo)) {
|
if (Verify.isEmpty(allServer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
executeBatch(new ExecStatement(insertStatement) {
|
executeBatch(new ExecStatement(insertStatement) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
for (ServerInfo info : allServerInfo) {
|
for (Server info : allServer) {
|
||||||
UUID uuid = info.getUuid();
|
UUID uuid = info.getUuid();
|
||||||
String name = info.getName();
|
String name = info.getName();
|
||||||
String webAddress = info.getWebAddress();
|
String webAddress = info.getWebAddress();
|
||||||
@ -382,21 +382,21 @@ public class ServerTable extends Table {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ServerInfo> getServerInfo(UUID serverUUID) throws SQLException {
|
public Optional<Server> getServerInfo(UUID serverUUID) throws SQLException {
|
||||||
String sql = Select.from(tableName, "*")
|
String sql = Select.from(tableName, "*")
|
||||||
.where(columnServerUUID + "=?")
|
.where(columnServerUUID + "=?")
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
return query(new QueryStatement<Optional<ServerInfo>>(sql) {
|
return query(new QueryStatement<Optional<Server>>(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, serverUUID.toString());
|
statement.setString(1, serverUUID.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ServerInfo> processResults(ResultSet set) throws SQLException {
|
public Optional<Server> processResults(ResultSet set) throws SQLException {
|
||||||
if (set.next()) {
|
if (set.next()) {
|
||||||
return Optional.of(new ServerInfo(
|
return Optional.of(new Server(
|
||||||
set.getInt(columnServerID),
|
set.getInt(columnServerID),
|
||||||
UUID.fromString(set.getString(columnServerUUID)),
|
UUID.fromString(set.getString(columnServerUUID)),
|
||||||
set.getString(columnServerName),
|
set.getString(columnServerName),
|
||||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryStateme
|
|||||||
import com.djrapitops.plan.system.database.databases.sql.statements.Select;
|
import com.djrapitops.plan.system.database.databases.sql.statements.Select;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.statements.Sql;
|
import com.djrapitops.plan.system.database.databases.sql.statements.Sql;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
@ -267,7 +267,7 @@ public class TPSTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<TPS> getNetworkOnlineData() throws SQLException {
|
public List<TPS> getNetworkOnlineData() throws SQLException {
|
||||||
Optional<ServerInfo> bungeeInfo = serverTable.getBungeeInfo();
|
Optional<Server> bungeeInfo = serverTable.getBungeeInfo();
|
||||||
if (!bungeeInfo.isPresent()) {
|
if (!bungeeInfo.isPresent()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|||||||
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.Table;
|
import com.djrapitops.plan.system.database.databases.sql.tables.Table;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable;
|
import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -140,7 +140,7 @@ public class BatchOperationTable extends Table {
|
|||||||
}
|
}
|
||||||
Log.debug("Batch Copy Servers");
|
Log.debug("Batch Copy Servers");
|
||||||
ServerTable serverTable = db.getServerTable();
|
ServerTable serverTable = db.getServerTable();
|
||||||
List<ServerInfo> servers = serverTable.getBukkitServers();
|
List<Server> servers = serverTable.getBukkitServers();
|
||||||
serverTable.getBungeeInfo().ifPresent(servers::add);
|
serverTable.getBungeeInfo().ifPresent(servers::add);
|
||||||
toDB.getDb().getServerTable().insertAllServers(servers);
|
toDB.getDb().getServerTable().insertAllServers(servers);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public abstract class InfoSystem implements SubSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendRequest(InfoRequest infoRequest) throws WebException {
|
public void sendRequest(InfoRequest infoRequest) throws WebException {
|
||||||
if (!connectionSystem.isServerAvailable()) {
|
if (!connectionSystem.isMainServerAvailable()) {
|
||||||
runLocally(infoRequest);
|
runLocally(infoRequest);
|
||||||
}
|
}
|
||||||
connectionSystem.sendInfoRequest(infoRequest);
|
connectionSystem.sendInfoRequest(infoRequest);
|
||||||
|
@ -10,11 +10,12 @@ import com.djrapitops.plan.system.SubSystem;
|
|||||||
import com.djrapitops.plan.system.info.InfoSystem;
|
import com.djrapitops.plan.system.info.InfoSystem;
|
||||||
import com.djrapitops.plan.system.info.request.CacheInspectPageRequest;
|
import com.djrapitops.plan.system.info.request.CacheInspectPageRequest;
|
||||||
import com.djrapitops.plan.system.info.request.InfoRequest;
|
import com.djrapitops.plan.system.info.request.InfoRequest;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.utilities.NullCheck;
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +29,7 @@ public abstract class ConnectionSystem implements SubSystem {
|
|||||||
|
|
||||||
protected final Map<String, InfoRequest> dataRequests;
|
protected final Map<String, InfoRequest> dataRequests;
|
||||||
protected final UUID serverUUID;
|
protected final UUID serverUUID;
|
||||||
protected Map<UUID, ServerInfo> servers;
|
protected Map<UUID, Server> servers;
|
||||||
|
|
||||||
public ConnectionSystem(UUID serverUUID) {
|
public ConnectionSystem(UUID serverUUID) {
|
||||||
this.serverUUID = serverUUID;
|
this.serverUUID = serverUUID;
|
||||||
@ -53,14 +54,16 @@ public abstract class ConnectionSystem implements SubSystem {
|
|||||||
requests.put(request.getClass().getSimpleName(), request);
|
requests.put(request.getClass().getSimpleName(), request);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ServerInfo selectServerForRequest(InfoRequest infoRequest) throws NoServersException;
|
protected abstract Server selectServerForRequest(InfoRequest infoRequest) throws NoServersException;
|
||||||
|
|
||||||
public void sendInfoRequest(InfoRequest infoRequest) throws WebException {
|
public void sendInfoRequest(InfoRequest infoRequest) throws WebException {
|
||||||
ServerInfo serverInfo = selectServerForRequest(infoRequest);
|
Server server = selectServerForRequest(infoRequest);
|
||||||
String address = serverInfo.getWebAddress();
|
String address = server.getWebAddress();
|
||||||
|
|
||||||
new ConnectionOut(address, serverUUID, infoRequest).sendRequest();
|
new ConnectionOut(address, serverUUID, infoRequest).sendRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isServerAvailable();
|
public abstract boolean isMainServerAvailable();
|
||||||
|
|
||||||
|
public abstract Optional<String> getMainAddress();
|
||||||
}
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.Plan;
|
||||||
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||||
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages the Server information required for Bungee-Bukkit WebAPI connection.
|
||||||
|
* <p>
|
||||||
|
* Also manages Server ID required for MySQL database independence.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class BukkitServerInfo extends ServerInfo {
|
||||||
|
|
||||||
|
private ServerInfoFile serverInfoFile;
|
||||||
|
private Database database;
|
||||||
|
|
||||||
|
public BukkitServerInfo(Plan plugin) {
|
||||||
|
serverProperties = new ServerProperties(plugin.getServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() throws EnableException {
|
||||||
|
database = Database.getActive();
|
||||||
|
|
||||||
|
try {
|
||||||
|
serverInfoFile = new ServerInfoFile(FileSystem.getDataFolder());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
||||||
|
}
|
||||||
|
super.enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Server loadServerInfo() throws EnableException {
|
||||||
|
Optional<UUID> serverUUID = serverInfoFile.getUUID();
|
||||||
|
try {
|
||||||
|
return serverUUID.isPresent() ? updateDbInfo(serverUUID.get()) : registerServer();
|
||||||
|
} catch (DBException e) {
|
||||||
|
throw new EnableException("Failed to read Server information from Database", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Server updateDbInfo(UUID serverUUID) throws IOException, DBException {
|
||||||
|
Optional<Integer> serverID = database.fetch().getServerID(serverUUID);
|
||||||
|
if (!serverID.isPresent()) {
|
||||||
|
return registerServer(serverUUID);
|
||||||
|
}
|
||||||
|
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||||
|
String webAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
||||||
|
if ("plan".equalsIgnoreCase(name)) {
|
||||||
|
name = "Server " + serverID.get();
|
||||||
|
}
|
||||||
|
int maxPlayers = serverProperties.getMaxPlayers();
|
||||||
|
|
||||||
|
Server server = new Server(serverID.get(), serverUUID, name, webAddress, maxPlayers);
|
||||||
|
database.save().serverInfoForThisServer(server);
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Server registerServer() throws DBException, IOException {
|
||||||
|
return registerServer(generateNewUUID(serverProperties));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Server registerServer(UUID serverUUID) throws DBException, IOException {
|
||||||
|
String webAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
|
||||||
|
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||||
|
int maxPlayers = ServerInfo.getServerProperties().getMaxPlayers();
|
||||||
|
|
||||||
|
Server server = new Server(-1, serverUUID, name, webAddress, maxPlayers);
|
||||||
|
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();
|
||||||
|
server.setId(id);
|
||||||
|
|
||||||
|
serverInfoFile.saveServerUUID(serverUUID);
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UUID generateNewUUID(ServerProperties serverProperties) {
|
||||||
|
String seed = serverProperties.getServerId() + serverProperties.getName() + serverProperties.getIp() + serverProperties.getPort() + serverProperties.getVersion() + serverProperties.getImplVersion();
|
||||||
|
return UUID.nameUUIDFromBytes(seed.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public Optional<String> getBungeeConnectionAddress() {
|
||||||
|
try {
|
||||||
|
Optional<Server> bungeeInfo = Database.getActive().fetch().getBungeeInformation();
|
||||||
|
if (bungeeInfo.isPresent()) {
|
||||||
|
return Optional.of(bungeeInfo.get().getWebAddress());
|
||||||
|
}
|
||||||
|
} catch (DBException e) {
|
||||||
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
@ -1,148 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licence is provided in the jar as license.yml also here:
|
|
||||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
|
||||||
*/
|
|
||||||
package com.djrapitops.plan.system.info.server;
|
|
||||||
|
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
|
||||||
import com.djrapitops.plan.ServerVariableHolder;
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manages the Server information required for Bungee-Bukkit WebAPI connection.
|
|
||||||
* <p>
|
|
||||||
* Also manages Server ID required for MySQL database independence.
|
|
||||||
*
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class BukkitServerInfoManager {
|
|
||||||
|
|
||||||
private final Plan plugin;
|
|
||||||
private final ServerTable serverTable;
|
|
||||||
private ServerInfo serverInfo;
|
|
||||||
private ServerInfoFile serverInfoFile;
|
|
||||||
|
|
||||||
public BukkitServerInfoManager(Plan plugin) throws EnableException {
|
|
||||||
this.plugin = plugin;
|
|
||||||
Database db = plugin.getDB();
|
|
||||||
serverTable = db.getServerTable();
|
|
||||||
|
|
||||||
try {
|
|
||||||
serverInfoFile = new ServerInfoFile(plugin);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new EnableException("Failed to read ServerInfoFile.yml", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateServerInfo() throws SQLException, IOException {
|
|
||||||
Optional<UUID> serverUUID = serverInfoFile.getUUID();
|
|
||||||
if (serverUUID.isPresent()) {
|
|
||||||
updateDbInfo(serverUUID.get());
|
|
||||||
} else {
|
|
||||||
registerServer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDbInfo(UUID serverUUID) throws SQLException, IOException {
|
|
||||||
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
|
|
||||||
if (!serverID.isPresent()) {
|
|
||||||
registerServer(serverUUID);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
|
||||||
String webAddress = plugin.getWebServer().getAccessAddress();
|
|
||||||
if ("plan".equalsIgnoreCase(name)) {
|
|
||||||
name = "Server " + serverID.get();
|
|
||||||
}
|
|
||||||
int maxPlayers = plugin.getVariable().getMaxPlayers();
|
|
||||||
|
|
||||||
serverInfo = new ServerInfo(serverID.get(), serverUUID, name, webAddress, maxPlayers);
|
|
||||||
serverTable.saveCurrentServerInfo(serverInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerServer() throws SQLException, IOException {
|
|
||||||
registerServer(generateNewUUID(plugin.getVariable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerServer(UUID serverUUID) throws SQLException, IOException {
|
|
||||||
String webAddress = plugin.getWebServer().getAccessAddress();
|
|
||||||
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
|
||||||
int maxPlayers = plugin.getVariable().getMaxPlayers();
|
|
||||||
serverInfo = new ServerInfo(-1, serverUUID, name, webAddress, maxPlayers);
|
|
||||||
serverTable.saveCurrentServerInfo(serverInfo);
|
|
||||||
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
|
|
||||||
if (!serverID.isPresent()) {
|
|
||||||
throw new IllegalStateException("Failed to Register Server (ID not found)");
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = serverID.get();
|
|
||||||
serverInfo.setId(id);
|
|
||||||
|
|
||||||
serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, name, "", 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private UUID generateNewUUID(ServerVariableHolder variableHolder) {
|
|
||||||
String seed = plugin.getServer().getServerId() + variableHolder.getName() + variableHolder.getIp() + variableHolder.getPort() + variableHolder.getVersion() + variableHolder.getImplVersion();
|
|
||||||
return UUID.nameUUIDFromBytes(seed.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<String> getBungeeConnectionAddress() {
|
|
||||||
try {
|
|
||||||
String bungeeWebAddress = serverInfoFile.getBungeeWebAddress();
|
|
||||||
if (!bungeeWebAddress.isEmpty()) {
|
|
||||||
return Optional.of(bungeeWebAddress);
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
/* Ignored */
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Optional<ServerInfo> bungeeInfo = plugin.getDB().getServerTable().getBungeeInfo();
|
|
||||||
if (bungeeInfo.isPresent()) {
|
|
||||||
return Optional.of(bungeeInfo.get().getWebAddress());
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Log.toLog(this.getClass().getName(), e);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves Bungee connection information to local file on Bukkit servers.
|
|
||||||
*
|
|
||||||
* @param address Address to save
|
|
||||||
* @throws IOException If ServerInfo file can not be written to.
|
|
||||||
*/
|
|
||||||
public void saveBungeeConnectionAddress(String address) throws IOException {
|
|
||||||
serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, "Bungee", address, -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markConnectionFail() {
|
|
||||||
serverInfoFile.markConnectionFail();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetConnectionFails() {
|
|
||||||
serverInfoFile.resetConnectionFails();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getServerID() {
|
|
||||||
return serverInfo.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getServerUUID() {
|
|
||||||
return serverInfo.getUuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerName() {
|
|
||||||
return serverInfo.getName();
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,13 +5,11 @@
|
|||||||
package com.djrapitops.plan.system.info.server;
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.ServerVariableHolder;
|
|
||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI;
|
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
@ -26,16 +24,16 @@ import java.util.stream.Collectors;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class BungeeServerInfoManager {
|
public class BungeeServerInfo extends ServerInfo {
|
||||||
|
|
||||||
private final PlanBungee plugin;
|
private final PlanBungee plugin;
|
||||||
private final Database db;
|
private final Database db;
|
||||||
private final Map<UUID, ServerInfo> bukkitServers;
|
private final Map<UUID, Server> bukkitServers;
|
||||||
private final Set<UUID> onlineServers;
|
private final Set<UUID> onlineServers;
|
||||||
private ServerInfo serverInfo;
|
private Server server;
|
||||||
private ServerTable serverTable;
|
private ServerTable serverTable;
|
||||||
|
|
||||||
public BungeeServerInfoManager(PlanBungee plugin) {
|
public BungeeServerInfo(PlanBungee plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.db = plugin.getDB();
|
this.db = plugin.getDB();
|
||||||
serverTable = db.getServerTable();
|
serverTable = db.getServerTable();
|
||||||
@ -46,62 +44,56 @@ public class BungeeServerInfoManager {
|
|||||||
|
|
||||||
public void loadServerInfo() throws EnableException {
|
public void loadServerInfo() throws EnableException {
|
||||||
try {
|
try {
|
||||||
Optional<ServerInfo> bungeeInfo = db.getServerTable().getBungeeInfo();
|
Optional<Server> bungeeInfo = db.getServerTable().getBungeeInfo();
|
||||||
if (bungeeInfo.isPresent()) {
|
if (bungeeInfo.isPresent()) {
|
||||||
serverInfo = bungeeInfo.get();
|
server = bungeeInfo.get();
|
||||||
String accessAddress = plugin.getWebServer().getAccessAddress();
|
String accessAddress = plugin.getWebServer().getAccessAddress();
|
||||||
if (!accessAddress.equals(serverInfo.getWebAddress())) {
|
if (!accessAddress.equals(server.getWebAddress())) {
|
||||||
serverInfo.setWebAddress(accessAddress);
|
server.setWebAddress(accessAddress);
|
||||||
serverTable.saveCurrentServerInfo(serverInfo);
|
serverTable.saveCurrentServerInfo(server);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
serverInfo = registerBungeeInfo();
|
server = registerBungeeInfo();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new EnableException("Failed to read Database for ServerInfo");
|
throw new EnableException("Failed to read Database for Server");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerInfo registerBungeeInfo() throws SQLException, EnableException {
|
private Server registerBungeeInfo() throws SQLException, EnableException {
|
||||||
ServerVariableHolder variable = plugin.getVariable();
|
ServerProperties variable = plugin.getVariable();
|
||||||
UUID serverUUID = generateNewUUID(variable);
|
UUID serverUUID = generateNewUUID(variable);
|
||||||
String accessAddress = plugin.getWebServer().getAccessAddress();
|
String accessAddress = plugin.getWebServer().getAccessAddress();
|
||||||
|
|
||||||
serverTable.saveCurrentServerInfo(
|
serverTable.saveCurrentServerInfo(
|
||||||
new ServerInfo(-1, serverUUID, "BungeeCord", accessAddress, variable.getMaxPlayers())
|
new Server(-1, serverUUID, "BungeeCord", accessAddress, variable.getMaxPlayers())
|
||||||
);
|
);
|
||||||
|
|
||||||
Optional<ServerInfo> bungeeInfo = db.getServerTable().getBungeeInfo();
|
Optional<Server> bungeeInfo = db.getServerTable().getBungeeInfo();
|
||||||
if (bungeeInfo.isPresent()) {
|
if (bungeeInfo.isPresent()) {
|
||||||
return bungeeInfo.get();
|
return bungeeInfo.get();
|
||||||
}
|
}
|
||||||
throw new EnableException("BungeeCord registration failed (DB)");
|
throw new EnableException("BungeeCord registration failed (DB)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID generateNewUUID(ServerVariableHolder variableHolder) {
|
private UUID generateNewUUID(ServerProperties variableHolder) {
|
||||||
String seed = variableHolder.getName() + variableHolder.getIp() + variableHolder.getPort() + variableHolder.getVersion() + variableHolder.getImplVersion();
|
String seed = variableHolder.getName() + variableHolder.getIp() + variableHolder.getPort() + variableHolder.getVersion() + variableHolder.getImplVersion();
|
||||||
return UUID.nameUUIDFromBytes(seed.getBytes());
|
return UUID.nameUUIDFromBytes(seed.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getServerUUID() {
|
public UUID getServerUUID() {
|
||||||
return serverInfo.getUuid();
|
return server.getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean attemptConnection(ServerInfo server, String accessCode) {
|
public boolean attemptConnection(Server server, String accessCode) {
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
Log.debug("Attempted a connection to a null ServerInfo");
|
Log.debug("Attempted a connection to a null Server");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String webAddress = server.getWebAddress();
|
String webAddress = server.getWebAddress();
|
||||||
Log.debug("Attempting to connect to Bukkit server.. (" + webAddress + ")");
|
Log.debug("Attempting to connect to Bukkit server.. (" + webAddress + ")");
|
||||||
PingWebAPI pingApi = plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class);
|
|
||||||
if (accessCode != null) {
|
|
||||||
pingApi.sendRequest(webAddress, accessCode);
|
|
||||||
plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, server.getUuid(), accessCode);
|
plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, server.getUuid(), accessCode);
|
||||||
} else {
|
|
||||||
pingApi.sendRequest(webAddress);
|
|
||||||
}
|
|
||||||
connectedToServer(server);
|
connectedToServer(server);
|
||||||
return true;
|
return true;
|
||||||
} catch (WebException e) {
|
} catch (WebException e) {
|
||||||
@ -111,14 +103,14 @@ public class BungeeServerInfoManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean attemptConnection(ServerInfo server) {
|
public boolean attemptConnection(Server server) {
|
||||||
return attemptConnection(server, null);
|
return attemptConnection(server, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendConfigSettings(UUID serverUUID) {
|
public void sendConfigSettings(UUID serverUUID) {
|
||||||
String webAddress = null;
|
String webAddress = null;
|
||||||
try {
|
try {
|
||||||
ServerInfo server = bukkitServers.get(serverUUID);
|
Server server = bukkitServers.get(serverUUID);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,7 +123,7 @@ public class BungeeServerInfoManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connectedToServer(ServerInfo server) {
|
public void connectedToServer(Server server) {
|
||||||
Log.info("Connection to Bukkit (" + server.getWebAddress() + ") OK");
|
Log.info("Connection to Bukkit (" + server.getWebAddress() + ") OK");
|
||||||
bukkitServers.put(server.getUuid(), server);
|
bukkitServers.put(server.getUuid(), server);
|
||||||
onlineServers.add(server.getUuid());
|
onlineServers.add(server.getUuid());
|
||||||
@ -154,9 +146,9 @@ public class BungeeServerInfoManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Optional<ServerInfo> serverInfo = db.getServerTable().getServerInfo(serverUUID);
|
Optional<Server> serverInfo = db.getServerTable().getServerInfo(serverUUID);
|
||||||
if (serverInfo.isPresent()) {
|
if (serverInfo.isPresent()) {
|
||||||
ServerInfo server = serverInfo.get();
|
Server server = serverInfo.get();
|
||||||
Log.info("Server Info found from DB: " + server.getName());
|
Log.info("Server Info found from DB: " + server.getName());
|
||||||
RunnableFactory.createNew("BukkitConnectionTask: " + server.getName(), new AbsRunnable() {
|
RunnableFactory.createNew("BukkitConnectionTask: " + server.getName(), new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -174,14 +166,14 @@ public class BungeeServerInfoManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ServerInfo> getOnlineBukkitServers() {
|
public Collection<Server> getOnlineBukkitServers() {
|
||||||
return bukkitServers.entrySet().stream()
|
return bukkitServers.entrySet().stream()
|
||||||
.filter(entry -> onlineServers.contains(entry.getKey()))
|
.filter(entry -> onlineServers.contains(entry.getKey()))
|
||||||
.map(Map.Entry::getValue)
|
.map(Map.Entry::getValue)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ServerInfo> getBukkitServers() {
|
public Collection<Server> getBukkitServers() {
|
||||||
return bukkitServers.values();
|
return bukkitServers.values();
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a Server that is running Plan.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class Server {
|
||||||
|
private final UUID uuid;
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private String webAddress;
|
||||||
|
private int maxPlayers = -1;
|
||||||
|
|
||||||
|
public Server(int id, UUID uuid, String name, String webAddress, int maxPlayers) {
|
||||||
|
this.id = id;
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.name = name;
|
||||||
|
this.webAddress = webAddress;
|
||||||
|
this.maxPlayers = maxPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWebAddress() {
|
||||||
|
return webAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWebAddress(String webAddress) {
|
||||||
|
this.webAddress = webAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxPlayers() {
|
||||||
|
return maxPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Server that = (Server) o;
|
||||||
|
return id == that.id &&
|
||||||
|
Objects.equals(uuid, that.uuid) &&
|
||||||
|
Objects.equals(name, that.name) &&
|
||||||
|
Objects.equals(webAddress, that.webAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(uuid, id, name, webAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Server{" +
|
||||||
|
"uuid=" + uuid +
|
||||||
|
", id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", webAddress='" + webAddress + '\'' +
|
||||||
|
", maxPlayers=" + maxPlayers +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -4,85 +4,63 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.info.server;
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
import java.util.Objects;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
|
import com.djrapitops.plan.system.PlanSystem;
|
||||||
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
|
import com.djrapitops.plan.utilities.NullCheck;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Server that is running Plan.
|
* SubSystem for managing Server information.
|
||||||
|
*
|
||||||
|
* Most information is accessible via static methods.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ServerInfo {
|
public abstract class ServerInfo implements SubSystem {
|
||||||
private final UUID uuid;
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
private String webAddress;
|
|
||||||
private int maxPlayers = -1;
|
|
||||||
|
|
||||||
public ServerInfo(int id, UUID uuid, String name, String webAddress, int maxPlayers) {
|
protected Server server;
|
||||||
this.id = id;
|
protected ServerProperties serverProperties;
|
||||||
this.uuid = uuid;
|
|
||||||
this.name = name;
|
public static ServerInfo getInstance() {
|
||||||
this.webAddress = webAddress;
|
ServerInfo serverInfo = PlanSystem.getInstance().getServerInfo();
|
||||||
this.maxPlayers = maxPlayers;
|
NullCheck.check(serverInfo, new IllegalStateException("ServerInfo was not initialized."));
|
||||||
|
return serverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public static Server getServer() {
|
||||||
return id;
|
return getInstance().server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public static ServerProperties getServerProperties() {
|
||||||
this.id = id;
|
return getInstance().serverProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public static UUID getServerUUID() {
|
||||||
return uuid;
|
return getServer().getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public static String getServerName() {
|
||||||
return name;
|
return getServer().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public static int getServerID() {
|
||||||
this.name = name;
|
return getServer().getId();
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebAddress() {
|
|
||||||
return webAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebAddress(String webAddress) {
|
|
||||||
this.webAddress = webAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxPlayers() {
|
|
||||||
return maxPlayers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public void enable() throws EnableException {
|
||||||
if (this == o) return true;
|
// ServerProperties are required when creating Server
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
NullCheck.check(serverProperties, new IllegalStateException("Server Properties did not load!"));
|
||||||
ServerInfo that = (ServerInfo) o;
|
server = loadServerInfo();
|
||||||
return id == that.id &&
|
NullCheck.check(server, new IllegalStateException("Server information did not load!"));
|
||||||
Objects.equals(uuid, that.uuid) &&
|
|
||||||
Objects.equals(name, that.name) &&
|
|
||||||
Objects.equals(webAddress, that.webAddress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected abstract Server loadServerInfo() throws EnableException;
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(uuid, id, name, webAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public void disable() {
|
||||||
return "ServerInfo{" +
|
|
||||||
"uuid=" + uuid +
|
|
||||||
", id=" + id +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
", webAddress='" + webAddress + '\'' +
|
|
||||||
", maxPlayers=" + maxPlayers +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,8 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.info.server;
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
|
||||||
import com.djrapitops.plugin.api.config.Config;
|
import com.djrapitops.plugin.api.config.Config;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
@ -18,28 +17,20 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Manages local server info file.
|
* Manages local server info file.
|
||||||
* <p>
|
* <p>
|
||||||
* ServerInfo.yml contains current server's ID, UUID and Bungee WebServer connection information.
|
* Server.yml contains current server's ID, UUID and Bungee WebServer connection information.
|
||||||
* It
|
* It
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ServerInfoFile extends Config {
|
public class ServerInfoFile extends Config {
|
||||||
public ServerInfoFile(Plan plugin) throws IOException {
|
public ServerInfoFile(File dataFolder) throws IOException {
|
||||||
super(new File(plugin.getDataFolder(), "ServerInfoFile.yml"));
|
super(new File(dataFolder, "ServerInfoFile.yml"));
|
||||||
copyDefaults(FileUtil.lines(plugin, "DefaultServerInfoFile.yml"));
|
copyDefaults(FileSystem.readFromResource("DefaultServerInfoFile.yml"));
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException {
|
public void saveServerUUID(UUID serverUUID) throws IOException {
|
||||||
set("Server.UUID", thisServer.getUuid().toString());
|
set("Server.UUID", serverUUID.toString());
|
||||||
|
|
||||||
String oldAddress = getString("Bungee.WebAddress");
|
|
||||||
String newAddress = bungee.getWebAddress();
|
|
||||||
|
|
||||||
if (!newAddress.equals(oldAddress)) {
|
|
||||||
set("Bungee.Fail", 0);
|
|
||||||
set("Bungee.WebAddress", newAddress);
|
|
||||||
}
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
package com.djrapitops.plan.system.info.server;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class responsible for holding server variable values that do not change
|
||||||
|
* without a reload.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
* @since 3.4.1
|
||||||
|
*/
|
||||||
|
public class ServerProperties {
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
private final int port;
|
||||||
|
private final String version;
|
||||||
|
private final String implVersion;
|
||||||
|
private final String ip;
|
||||||
|
private final int maxPlayers;
|
||||||
|
|
||||||
|
public ServerProperties(Server server) {
|
||||||
|
id = server.getServerId();
|
||||||
|
ip = server.getIp();
|
||||||
|
name = server.getName();
|
||||||
|
port = server.getPort();
|
||||||
|
version = server.getVersion();
|
||||||
|
implVersion = server.getBukkitVersion();
|
||||||
|
|
||||||
|
maxPlayers = server.getMaxPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor, grabs the variables.
|
||||||
|
*
|
||||||
|
* @param server instance the plugin is running on.
|
||||||
|
*/
|
||||||
|
public ServerProperties(ProxyServer server) {
|
||||||
|
id = server.getServers().toString();
|
||||||
|
ip = Settings.BUNGEE_IP.toString();
|
||||||
|
name = "BungeeCord";
|
||||||
|
port = -1;
|
||||||
|
version = server.getVersion();
|
||||||
|
implVersion = server.getVersion();
|
||||||
|
|
||||||
|
maxPlayers = server.getConfig().getPlayerLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ip string in server.properties.
|
||||||
|
*
|
||||||
|
* @return the ip.
|
||||||
|
*/
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImplVersion() {
|
||||||
|
return implVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxPlayers() {
|
||||||
|
return maxPlayers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,12 @@ package com.djrapitops.plan.system.webserver.response.pages;
|
|||||||
|
|
||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
import com.djrapitops.plan.ServerVariableHolder;
|
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||||
import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse;
|
import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse;
|
||||||
import com.djrapitops.plan.system.info.server.BungeeServerInfoManager;
|
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
|
||||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
import com.djrapitops.plan.utilities.html.Html;
|
import com.djrapitops.plan.utilities.html.Html;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
import com.djrapitops.plugin.api.Benchmark;
|
||||||
@ -66,7 +66,7 @@ public class DebugPageResponse extends ErrorResponse {
|
|||||||
|
|
||||||
private void appendServerInformation(StringBuilder content) {
|
private void appendServerInformation(StringBuilder content) {
|
||||||
PlanPlugin plugin = PlanPlugin.getInstance();
|
PlanPlugin plugin = PlanPlugin.getInstance();
|
||||||
ServerVariableHolder variable = plugin.getVariable();
|
ServerProperties variable = plugin.getVariable();
|
||||||
|
|
||||||
content.append("<pre>### Server Information<br>")
|
content.append("<pre>### Server Information<br>")
|
||||||
.append("**Plan Version:** ").append(plugin.getVersion()).append("<br>");
|
.append("**Plan Version:** ").append(plugin.getVersion()).append("<br>");
|
||||||
@ -134,13 +134,13 @@ public class DebugPageResponse extends ErrorResponse {
|
|||||||
private void appendBungeeConfiguration(StringBuilder content) {
|
private void appendBungeeConfiguration(StringBuilder content) {
|
||||||
|
|
||||||
PlanBungee plugin = PlanBungee.getInstance();
|
PlanBungee plugin = PlanBungee.getInstance();
|
||||||
BungeeServerInfoManager serverInfoManager = plugin.getServerInfoManager();
|
BungeeServerInfo serverInfoManager = plugin.getServerInfoManager();
|
||||||
Collection<ServerInfo> online = serverInfoManager.getOnlineBukkitServers();
|
Collection<Server> online = serverInfoManager.getOnlineBukkitServers();
|
||||||
Collection<ServerInfo> bukkitServers = serverInfoManager.getBukkitServers();
|
Collection<Server> bukkitServers = serverInfoManager.getBukkitServers();
|
||||||
|
|
||||||
if (!bukkitServers.isEmpty()) {
|
if (!bukkitServers.isEmpty()) {
|
||||||
content.append("<p>If your issue is about Bungee-Bukkit connection relations, please include the following debug information of available servers as well:</p>");
|
content.append("<p>If your issue is about Bungee-Bukkit connection relations, please include the following debug information of available servers as well:</p>");
|
||||||
for (ServerInfo info : bukkitServers) {
|
for (Server info : bukkitServers) {
|
||||||
String link = Html.LINK.parse(info.getWebAddress() + "/debug", info.getWebAddress() + "/debug");
|
String link = Html.LINK.parse(info.getWebAddress() + "/debug", info.getWebAddress() + "/debug");
|
||||||
content.append("<p>").append(link).append("</p>");
|
content.append("<p>").append(link).append("</p>");
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ public class DebugPageResponse extends ErrorResponse {
|
|||||||
|
|
||||||
content.append("Server name | Online | Address | UUID<br>")
|
content.append("Server name | Online | Address | UUID<br>")
|
||||||
.append("-- | -- | -- | --<br>");
|
.append("-- | -- | -- | --<br>");
|
||||||
for (ServerInfo info : bukkitServers) {
|
for (Server info : bukkitServers) {
|
||||||
content.append(info.getName()).append(" | ")
|
content.append(info.getName()).append(" | ")
|
||||||
.append(online.contains(info) ? "Online" : "Offline").append(" | ")
|
.append(online.contains(info) ? "Online" : "Offline").append(" | ")
|
||||||
.append(info.getWebAddress()).append(" | ")
|
.append(info.getWebAddress()).append(" | ")
|
||||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee;
|
|||||||
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
import com.djrapitops.plan.system.processing.processors.Processor;
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
import com.djrapitops.plan.system.webserver.response.Response;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||||
@ -62,8 +62,8 @@ public class RequestPluginsTabWebAPI extends WebAPI {
|
|||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
try {
|
try {
|
||||||
List<ServerInfo> bukkitServers = plugin.getDB().getServerTable().getBukkitServers();
|
List<Server> bukkitServers = plugin.getDB().getServerTable().getBukkitServers();
|
||||||
for (ServerInfo server : bukkitServers) {
|
for (Server server : bukkitServers) {
|
||||||
String webAddress = server.getWebAddress();
|
String webAddress = server.getWebAddress();
|
||||||
try {
|
try {
|
||||||
plugin.getWebServer().getWebAPI().getAPI(RequestInspectPluginsTabBukkitWebAPI.class).sendRequest(webAddress, uuid);
|
plugin.getWebServer().getWebAPI().getAPI(RequestInspectPluginsTabBukkitWebAPI.class).sendRequest(webAddress, uuid);
|
||||||
|
@ -9,10 +9,10 @@ import com.djrapitops.plan.Plan;
|
|||||||
import com.djrapitops.plan.PlanBungee;
|
import com.djrapitops.plan.PlanBungee;
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
import com.djrapitops.plan.PlanPlugin;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
import com.djrapitops.plan.system.webserver.response.Response;
|
||||||
import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse;
|
import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
|
||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
@ -43,9 +43,9 @@ public class RequestSetupWebAPI extends WebAPI {
|
|||||||
if (!Verify.notNull(serverUUIDS, webAddress, accessCode)) {
|
if (!Verify.notNull(serverUUIDS, webAddress, accessCode)) {
|
||||||
return badRequest("Variable was null");
|
return badRequest("Variable was null");
|
||||||
}
|
}
|
||||||
ServerInfo serverInfo = new ServerInfo(-1, UUID.fromString(serverUUIDS), "", webAddress, 0);
|
Server server = new Server(-1, UUID.fromString(serverUUIDS), "", webAddress, 0);
|
||||||
|
|
||||||
((PlanBungee) plugin).getServerInfoManager().attemptConnection(serverInfo, accessCode);
|
((PlanBungee) plugin).getServerInfoManager().attemptConnection(server, accessCode);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licence is provided in the jar as license.yml also here:
|
|
||||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
|
||||||
*/
|
|
||||||
package com.djrapitops.plan.system.webserver.webapi.universal;
|
|
||||||
|
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
|
||||||
import com.djrapitops.plan.PlanBungee;
|
|
||||||
import com.djrapitops.plan.PlanPlugin;
|
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
|
||||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
|
||||||
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
|
||||||
import com.djrapitops.plugin.api.Check;
|
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rsl1122
|
|
||||||
*/
|
|
||||||
public class PingWebAPI extends WebAPI {
|
|
||||||
@Override
|
|
||||||
public Response onRequest(PlanPlugin plugin, Map<String, String> variables) {
|
|
||||||
if (Check.isBungeeAvailable()) {
|
|
||||||
if (!((PlanBungee) plugin).getServerInfoManager().serverConnected(UUID.fromString(variables.get("sender")))) {
|
|
||||||
return fail("Server info not found from the database");
|
|
||||||
}
|
|
||||||
} else if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
|
|
||||||
try {
|
|
||||||
String webAddress = variables.get("webAddress");
|
|
||||||
if (webAddress != null) {
|
|
||||||
((Plan) plugin).getServerInfoManager().saveBungeeConnectionAddress(webAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
((BukkitInformationManager) plugin.getInfoManager()).updateConnection();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.toLog(this.getClass().getName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRequest(String address) throws WebException {
|
|
||||||
if (Check.isBukkitAvailable()) {
|
|
||||||
super.sendRequest(address);
|
|
||||||
} else {
|
|
||||||
addVariable("webAddress", PlanBungee.getInstance().getWebServer().getAccessAddress());
|
|
||||||
super.sendRequest(address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendRequest(String address, String accessCode) throws WebException {
|
|
||||||
addVariable("accessKey", accessCode);
|
|
||||||
addVariable("version", PlanPlugin.getInstance().getVersion());
|
|
||||||
sendRequest(address);
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,7 +34,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalysisReadyWebAPI;
|
|||||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI;
|
import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.bungee.*;
|
import com.djrapitops.plan.system.webserver.webapi.bungee.*;
|
||||||
import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI;
|
|
||||||
import com.djrapitops.plan.systems.info.parsing.AnalysisPage;
|
import com.djrapitops.plan.systems.info.parsing.AnalysisPage;
|
||||||
import com.djrapitops.plan.systems.info.parsing.InspectPage;
|
import com.djrapitops.plan.systems.info.parsing.InspectPage;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
@ -336,9 +335,9 @@ public class BukkitInformationManager extends InformationManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")");
|
Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")");
|
||||||
PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
|
// PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
|
||||||
try {
|
try {
|
||||||
api.sendRequest(webServerAddress);
|
// api.sendRequest(webServerAddress);
|
||||||
getWebAPI().getAPI(PostOriginalBukkitSettingsWebAPI.class).sendRequest(webServerAddress);
|
getWebAPI().getAPI(PostOriginalBukkitSettingsWebAPI.class).sendRequest(webServerAddress);
|
||||||
Log.info("Bungee Connection OK");
|
Log.info("Bungee Connection OK");
|
||||||
plugin.getServerInfoManager().resetConnectionFails();
|
plugin.getServerInfoManager().resetConnectionFails();
|
||||||
|
@ -11,8 +11,8 @@ import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException;
|
|||||||
import com.djrapitops.plan.api.exceptions.connection.NotFoundException;
|
import com.djrapitops.plan.api.exceptions.connection.NotFoundException;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
import com.djrapitops.plan.system.cache.DataCache;
|
import com.djrapitops.plan.system.cache.DataCache;
|
||||||
import com.djrapitops.plan.system.info.server.BungeeServerInfoManager;
|
import com.djrapitops.plan.system.info.server.BungeeServerInfo;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.system.webserver.response.Response;
|
import com.djrapitops.plan.system.webserver.response.Response;
|
||||||
import com.djrapitops.plan.system.webserver.response.cache.PageId;
|
import com.djrapitops.plan.system.webserver.response.cache.PageId;
|
||||||
@ -50,8 +50,8 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
private final PlanBungee plugin;
|
private final PlanBungee plugin;
|
||||||
private final Map<UUID, String> networkPageContent;
|
private final Map<UUID, String> networkPageContent;
|
||||||
private final Map<UUID, Map<UUID, String[]>> pluginsTabContent;
|
private final Map<UUID, Map<UUID, String[]>> pluginsTabContent;
|
||||||
private final BungeeServerInfoManager serverInfoManager;
|
private final BungeeServerInfo serverInfoManager;
|
||||||
private Map<UUID, ServerInfo> bukkitServers;
|
private Map<UUID, Server> bukkitServers;
|
||||||
|
|
||||||
public BungeeInformationManager(PlanBungee plugin) {
|
public BungeeInformationManager(PlanBungee plugin) {
|
||||||
usingAnotherWebServer = false;
|
usingAnotherWebServer = false;
|
||||||
@ -68,7 +68,7 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
* @throws SQLException If DB Error occurs.
|
* @throws SQLException If DB Error occurs.
|
||||||
*/
|
*/
|
||||||
private void refreshBukkitServerMap() {
|
private void refreshBukkitServerMap() {
|
||||||
bukkitServers = plugin.getDB().getServerTable().getBukkitServers().stream().collect(Collectors.toMap(ServerInfo::getUuid, Function.identity()));
|
bukkitServers = plugin.getDB().getServerTable().getBukkitServers().stream().collect(Collectors.toMap(Server::getUuid, Function.identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,14 +83,14 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
if (PlanBungee.getServerUUID().equals(serverUUID)) {
|
if (PlanBungee.getServerUUID().equals(serverUUID)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ServerInfo serverInfo = getOnlineServerInfo(serverUUID);
|
Server server = getOnlineServerInfo(serverUUID);
|
||||||
if (serverInfo == null) {
|
if (server == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyzeWebAPI api = plugin.getWebServer().getWebAPI().getAPI(AnalyzeWebAPI.class);
|
AnalyzeWebAPI api = plugin.getWebServer().getWebAPI().getAPI(AnalyzeWebAPI.class);
|
||||||
try {
|
try {
|
||||||
api.sendRequest(serverInfo.getWebAddress(), serverUUID);
|
api.sendRequest(server.getWebAddress(), serverUUID);
|
||||||
} catch (ConnectionFailException e) {
|
} catch (ConnectionFailException e) {
|
||||||
attemptConnection();
|
attemptConnection();
|
||||||
} catch (WebException e) {
|
} catch (WebException e) {
|
||||||
@ -104,24 +104,24 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
* Returns null if server doesn't exist.
|
* Returns null if server doesn't exist.
|
||||||
*
|
*
|
||||||
* @param serverUUID UUID of server
|
* @param serverUUID UUID of server
|
||||||
* @return Online ServerInfo or null
|
* @return Online Server or null
|
||||||
*/
|
*/
|
||||||
private ServerInfo getOnlineServerInfo(UUID serverUUID) {
|
private Server getOnlineServerInfo(UUID serverUUID) {
|
||||||
ServerInfo serverInfo = bukkitServers.get(serverUUID);
|
Server server = bukkitServers.get(serverUUID);
|
||||||
if (serverInfo == null) {
|
if (server == null) {
|
||||||
try {
|
try {
|
||||||
refreshBukkitServerMap();
|
refreshBukkitServerMap();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
serverInfo = bukkitServers.get(serverUUID);
|
server = bukkitServers.get(serverUUID);
|
||||||
}
|
}
|
||||||
if (serverInfo == null) {
|
if (server == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverInfoManager.getOnlineBukkitServers().contains(serverInfo) || serverInfoManager.attemptConnection(serverInfo)) {
|
if (serverInfoManager.getOnlineBukkitServers().contains(server) || serverInfoManager.attemptConnection(server)) {
|
||||||
return serverInfo;
|
return server;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void cachePlayer(UUID uuid) {
|
public void cachePlayer(UUID uuid) {
|
||||||
ServerInfo inspectServer = null;
|
Server inspectServer = null;
|
||||||
try {
|
try {
|
||||||
inspectServer = getInspectRequestProcessorServer(uuid);
|
inspectServer = getInspectRequestProcessorServer(uuid);
|
||||||
|
|
||||||
@ -153,17 +153,17 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get ServerInfo of an online server that should process an inspect request.
|
* Get Server of an online server that should process an inspect request.
|
||||||
* <p>
|
* <p>
|
||||||
* If the player is online, an attempt to use the server where the player resides is made.
|
* If the player is online, an attempt to use the server where the player resides is made.
|
||||||
* <p>
|
* <p>
|
||||||
* If the player is offline or in the lobby, any server can be used.
|
* If the player is offline or in the lobby, any server can be used.
|
||||||
*
|
*
|
||||||
* @param uuid UUID of the player
|
* @param uuid UUID of the player
|
||||||
* @return ServerInfo of the server that should handle the request.
|
* @return Server of the server that should handle the request.
|
||||||
* @throws IllegalStateException If no Bukkit servers are online.
|
* @throws IllegalStateException If no Bukkit servers are online.
|
||||||
*/
|
*/
|
||||||
private ServerInfo getInspectRequestProcessorServer(UUID uuid) {
|
private Server getInspectRequestProcessorServer(UUID uuid) {
|
||||||
if (bukkitServers.isEmpty()) {
|
if (bukkitServers.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
refreshBukkitServerMap();
|
refreshBukkitServerMap();
|
||||||
@ -175,9 +175,9 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<ServerInfo> onlineServers = serverInfoManager.getOnlineBukkitServers();
|
Collection<Server> onlineServers = serverInfoManager.getOnlineBukkitServers();
|
||||||
if (plugin.getProxy().getPlayer(uuid) != null) {
|
if (plugin.getProxy().getPlayer(uuid) != null) {
|
||||||
for (ServerInfo server : onlineServers) {
|
for (Server server : onlineServers) {
|
||||||
try {
|
try {
|
||||||
getWebAPI().getAPI(IsOnlineWebAPI.class).sendRequest(server.getWebAddress(), uuid);
|
getWebAPI().getAPI(IsOnlineWebAPI.class).sendRequest(server.getWebAddress(), uuid);
|
||||||
return server;
|
return server;
|
||||||
@ -191,7 +191,7 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<ServerInfo> bukkitServer = serverInfoManager.getOnlineBukkitServers().stream().findAny();
|
Optional<Server> bukkitServer = serverInfoManager.getOnlineBukkitServers().stream().findAny();
|
||||||
if (bukkitServer.isPresent()) {
|
if (bukkitServer.isPresent()) {
|
||||||
return bukkitServer.get();
|
return bukkitServer.get();
|
||||||
}
|
}
|
||||||
@ -218,8 +218,8 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean attemptConnection() {
|
public boolean attemptConnection() {
|
||||||
try {
|
try {
|
||||||
List<ServerInfo> bukkitServers = plugin.getDB().getServerTable().getBukkitServers();
|
List<Server> bukkitServers = plugin.getDB().getServerTable().getBukkitServers();
|
||||||
for (ServerInfo server : bukkitServers) {
|
for (Server server : bukkitServers) {
|
||||||
serverInfoManager.attemptConnection(server);
|
serverInfoManager.attemptConnection(server);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -361,9 +361,9 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
@Override
|
@Override
|
||||||
public void analysisReady(UUID serverUUID) {
|
public void analysisReady(UUID serverUUID) {
|
||||||
AnalysisReadyWebAPI api = getWebAPI().getAPI(AnalysisReadyWebAPI.class);
|
AnalysisReadyWebAPI api = getWebAPI().getAPI(AnalysisReadyWebAPI.class);
|
||||||
for (ServerInfo serverInfo : serverInfoManager.getOnlineBukkitServers()) {
|
for (Server server : serverInfoManager.getOnlineBukkitServers()) {
|
||||||
try {
|
try {
|
||||||
api.sendRequest(serverInfo.getWebAddress(), serverUUID);
|
api.sendRequest(server.getWebAddress(), serverUUID);
|
||||||
} catch (WebException ignored) {
|
} catch (WebException ignored) {
|
||||||
/*Ignored*/
|
/*Ignored*/
|
||||||
}
|
}
|
||||||
@ -380,8 +380,8 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendConfigSettings() {
|
public void sendConfigSettings() {
|
||||||
Collection<ServerInfo> online = serverInfoManager.getOnlineBukkitServers();
|
Collection<Server> online = serverInfoManager.getOnlineBukkitServers();
|
||||||
online.stream().map(ServerInfo::getUuid)
|
online.stream().map(Server::getUuid)
|
||||||
.forEach(serverInfoManager::sendConfigSettings);
|
.forEach(serverInfoManager::sendConfigSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ public class InspectPage extends Page {
|
|||||||
|
|
||||||
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
|
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
|
||||||
|
|
||||||
if (!InfoSystem.getInstance().getConnectionSystem().isServerAvailable()) {
|
if (!InfoSystem.getInstance().getConnectionSystem().isMainServerAvailable()) {
|
||||||
addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
package com.djrapitops.plan.utilities.html;
|
package com.djrapitops.plan.utilities.html;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.ServerVariableHolder;
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||||
import com.djrapitops.plan.utilities.FormatUtils;
|
import com.djrapitops.plan.utilities.FormatUtils;
|
||||||
@ -107,13 +108,13 @@ public class HtmlStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String createServerContainer(Plan plugin) {
|
public static String createServerContainer(Plan plugin) {
|
||||||
ServerVariableHolder variable = plugin.getVariable();
|
ServerProperties variable = plugin.getVariable();
|
||||||
int maxPlayers = variable.getMaxPlayers();
|
int maxPlayers = variable.getMaxPlayers();
|
||||||
int online = plugin.getServer().getOnlinePlayers().size();
|
int online = plugin.getServer().getOnlinePlayers().size();
|
||||||
Optional<Long> analysisRefreshDate = ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisRefreshDate();
|
Optional<Long> analysisRefreshDate = ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisRefreshDate();
|
||||||
String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStamp).orElse("-");
|
String refresh = analysisRefreshDate.map(FormatUtils::formatTimeStamp).orElse("-");
|
||||||
|
|
||||||
String serverName = plugin.getServerInfoManager().getServerName();
|
String serverName = ServerInfo.getServerName();
|
||||||
String serverType = variable.getVersion();
|
String serverType = variable.getVersion();
|
||||||
String address = "../server/" + serverName;
|
String address = "../server/" + serverName;
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ package com.djrapitops.plan.utilities.html.structure;
|
|||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.data.element.InspectContainer;
|
import com.djrapitops.plan.data.element.InspectContainer;
|
||||||
import com.djrapitops.plan.data.plugin.PluginData;
|
import com.djrapitops.plan.data.plugin.PluginData;
|
||||||
import com.djrapitops.plan.system.info.server.BukkitServerInfoManager;
|
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -22,9 +23,9 @@ import java.util.Map;
|
|||||||
public class InspectPluginsTabContentCreator {
|
public class InspectPluginsTabContentCreator {
|
||||||
|
|
||||||
public static String[] createContent(Map<PluginData, InspectContainer> containers) {
|
public static String[] createContent(Map<PluginData, InspectContainer> containers) {
|
||||||
BukkitServerInfoManager serverInfoManager = Plan.getInstance().getServerInfoManager();
|
BukkitServerInfo serverInfoManager = Plan.getInstance().getServerInfoManager();
|
||||||
String serverName = serverInfoManager.getServerName();
|
String serverName = ServerInfo.getServerName();
|
||||||
String actualServerName = serverName.equals("Plan") ? "Server " + serverInfoManager.getServerID() : serverName;
|
String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName;
|
||||||
|
|
||||||
if (containers.isEmpty()) {
|
if (containers.isEmpty()) {
|
||||||
return new String[]{"<li><a>" + actualServerName + "(No Data)</a></li>",
|
return new String[]{"<li><a>" + actualServerName + "(No Data)</a></li>",
|
||||||
|
@ -2,6 +2,3 @@
|
|||||||
# Thread with caution.
|
# Thread with caution.
|
||||||
Server:
|
Server:
|
||||||
UUID:
|
UUID:
|
||||||
Bungee:
|
|
||||||
WebAddress: ''
|
|
||||||
Fail: 1
|
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package com.djrapitops.plan;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
|
||||||
import test.utilities.TestInit;
|
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Fuzzlemann
|
|
||||||
*/
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest(JavaPlugin.class)
|
|
||||||
public class ServerVariableHolderTest {
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
TestInit.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testServerVariable() {
|
|
||||||
boolean usingPaper = Plan.getInstance().getVariable().isUsingPaper();
|
|
||||||
assertFalse(usingPaper);
|
|
||||||
|
|
||||||
String exp = Plan.getInstance().getVariable().getIp();
|
|
||||||
assertEquals(exp, "0.0.0.0");
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,8 +19,8 @@ import com.djrapitops.plan.system.database.databases.sql.MySQLDB;
|
|||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor;
|
import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
|
||||||
import com.djrapitops.plan.utilities.ManageUtils;
|
import com.djrapitops.plan.utilities.ManageUtils;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
import com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||||
@ -83,7 +83,7 @@ public class DatabaseTest {
|
|||||||
};
|
};
|
||||||
when(plan.getDataCache()).thenReturn(dataCache);
|
when(plan.getDataCache()).thenReturn(dataCache);
|
||||||
|
|
||||||
db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20));
|
db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20));
|
||||||
|
|
||||||
File f = new File(plan.getDataFolder(), "Errors.txt");
|
File f = new File(plan.getDataFolder(), "Errors.txt");
|
||||||
rows = FileUtil.lines(f).size();
|
rows = FileUtil.lines(f).size();
|
||||||
@ -691,11 +691,11 @@ public class DatabaseTest {
|
|||||||
public void testServerTableBungeeSave() throws SQLException, DBInitException {
|
public void testServerTableBungeeSave() throws SQLException, DBInitException {
|
||||||
ServerTable serverTable = db.getServerTable();
|
ServerTable serverTable = db.getServerTable();
|
||||||
|
|
||||||
Optional<ServerInfo> bungeeInfo = serverTable.getBungeeInfo();
|
Optional<Server> bungeeInfo = serverTable.getBungeeInfo();
|
||||||
assertFalse(bungeeInfo.isPresent());
|
assertFalse(bungeeInfo.isPresent());
|
||||||
|
|
||||||
UUID bungeeUUID = UUID.randomUUID();
|
UUID bungeeUUID = UUID.randomUUID();
|
||||||
ServerInfo bungeeCord = new ServerInfo(-1, bungeeUUID, "BungeeCord", "Random:1234", 20);
|
Server bungeeCord = new Server(-1, bungeeUUID, "BungeeCord", "Random:1234", 20);
|
||||||
serverTable.saveCurrentServerInfo(bungeeCord);
|
serverTable.saveCurrentServerInfo(bungeeCord);
|
||||||
|
|
||||||
commitTest();
|
commitTest();
|
||||||
@ -716,7 +716,7 @@ public class DatabaseTest {
|
|||||||
testServerTableBungeeSave();
|
testServerTableBungeeSave();
|
||||||
ServerTable serverTable = db.getServerTable();
|
ServerTable serverTable = db.getServerTable();
|
||||||
|
|
||||||
List<ServerInfo> bukkitServers = serverTable.getBukkitServers();
|
List<Server> bukkitServers = serverTable.getBukkitServers();
|
||||||
assertEquals(1, bukkitServers.size());
|
assertEquals(1, bukkitServers.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import com.djrapitops.plan.Plan;
|
|||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable;
|
import com.djrapitops.plan.system.database.databases.sql.tables.UsersTable;
|
||||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
import com.djrapitops.plugin.command.ISender;
|
import com.djrapitops.plugin.command.ISender;
|
||||||
import com.djrapitops.plugin.command.bukkit.BukkitCMDSender;
|
import com.djrapitops.plugin.command.bukkit.BukkitCMDSender;
|
||||||
@ -166,7 +166,7 @@ public class MiscUtilsTest {
|
|||||||
db = new SQLiteDB("debug" + MiscUtils.getTime());
|
db = new SQLiteDB("debug" + MiscUtils.getTime());
|
||||||
db.init();
|
db.init();
|
||||||
|
|
||||||
db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20));
|
db.getServerTable().saveCurrentServerInfo(new Server(-1, TestInit.getServerUUID(), "ServerName", "", 20));
|
||||||
|
|
||||||
when(plan.getDB()).thenReturn(db);
|
when(plan.getDB()).thenReturn(db);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package test.utilities;
|
package test.utilities;
|
||||||
|
|
||||||
import com.djrapitops.plan.Plan;
|
import com.djrapitops.plan.Plan;
|
||||||
import com.djrapitops.plan.ServerVariableHolder;
|
|
||||||
import com.djrapitops.plan.settings.locale.Locale;
|
import com.djrapitops.plan.settings.locale.Locale;
|
||||||
import com.djrapitops.plan.system.cache.DataCache;
|
import com.djrapitops.plan.system.cache.DataCache;
|
||||||
import com.djrapitops.plan.system.info.server.BukkitServerInfoManager;
|
import com.djrapitops.plan.system.info.server.BukkitServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerProperties;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
import com.djrapitops.plugin.IPlugin;
|
import com.djrapitops.plugin.IPlugin;
|
||||||
@ -119,10 +120,10 @@ public class TestInit {
|
|||||||
when(planMock.getLogger()).thenReturn(Logger.getGlobal());
|
when(planMock.getLogger()).thenReturn(Logger.getGlobal());
|
||||||
Settings.DEBUG.setTemporaryValue(true);
|
Settings.DEBUG.setTemporaryValue(true);
|
||||||
|
|
||||||
ServerVariableHolder serverVariableHolder = new ServerVariableHolder(mockServer);
|
ServerProperties serverProperties = new ServerProperties(mockServer);
|
||||||
|
|
||||||
when(planMock.getVariable()).thenReturn(serverVariableHolder);
|
when(planMock.getVariable()).thenReturn(serverProperties);
|
||||||
BukkitServerInfoManager bukkitServerInfoManager = PowerMockito.mock(BukkitServerInfoManager.class);
|
BukkitServerInfo bukkitServerInfo = PowerMockito.mock(BukkitServerInfo.class);
|
||||||
|
|
||||||
DataCache dataCache = new DataCache(planMock) {
|
DataCache dataCache = new DataCache(planMock) {
|
||||||
@Override
|
@Override
|
||||||
@ -132,9 +133,9 @@ public class TestInit {
|
|||||||
};
|
};
|
||||||
when(planMock.getDataCache()).thenReturn(dataCache);
|
when(planMock.getDataCache()).thenReturn(dataCache);
|
||||||
|
|
||||||
when(bukkitServerInfoManager.getServerUUID()).thenReturn(serverUUID);
|
when(ServerInfo.getServerUUID()).thenReturn(serverUUID);
|
||||||
when(planMock.getServerUuid()).thenReturn(serverUUID);
|
when(planMock.getServerUuid()).thenReturn(serverUUID);
|
||||||
when(planMock.getServerInfoManager()).thenReturn(bukkitServerInfoManager);
|
when(planMock.getServerInfoManager()).thenReturn(bukkitServerInfo);
|
||||||
ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK);
|
ColorScheme cs = new ColorScheme(ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK, ChatColor.BLACK);
|
||||||
when(planMock.getColorScheme()).thenReturn(cs);
|
when(planMock.getColorScheme()).thenReturn(cs);
|
||||||
initLocale(null);
|
initLocale(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user