mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-09 04:11:50 +01:00
Begun coding new Information transfer system
This commit is contained in:
parent
47f061edcb
commit
dc15c61953
@ -27,6 +27,8 @@ import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.BukkitSystem;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.file.FileSystem;
|
||||
@ -37,8 +39,6 @@ import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.system.webserver.WebServerSystem;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import com.djrapitops.plan.systems.info.ImporterManager;
|
||||
import com.djrapitops.plan.systems.info.InformationManager;
|
||||
|
@ -8,10 +8,10 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.data.Actions;
|
||||
import com.djrapitops.plan.data.container.Action;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.tables.SessionsTable;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when Connection fails to connect to an address.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ConnectionFailException extends WebException {
|
||||
|
||||
public ConnectionFailException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ConnectionFailException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NoServersException extends WebException {
|
||||
|
||||
public NoServersException() {
|
||||
}
|
||||
|
||||
public NoServersException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NoServersException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public NoServersException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class TransferDatabaseException extends WebException {
|
||||
|
||||
public TransferDatabaseException(DBException cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class UnsupportedTransferDatabaseException extends WebException {
|
||||
|
||||
public UnsupportedTransferDatabaseException() {
|
||||
}
|
||||
|
||||
public UnsupportedTransferDatabaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when Connection POST-request fails, general Exception.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebException extends Exception {
|
||||
|
||||
public WebException() {
|
||||
}
|
||||
|
||||
public WebException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public WebException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Group of WebExceptions that can be considered a failed connection state on some occasions.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebFailException extends WebException {
|
||||
|
||||
public WebFailException() {
|
||||
}
|
||||
|
||||
public WebFailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public WebFailException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebFailException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -2,15 +2,15 @@
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.webapi;
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when WebAPI gets a 403 response.
|
||||
* Thrown when Connection gets a 403 response.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebAPIForbiddenException extends WebAPIFailException {
|
||||
public WebAPIForbiddenException(String url) {
|
||||
public class WebForbiddenException extends WebFailException {
|
||||
public WebForbiddenException(String url) {
|
||||
super("Forbidden: " + url);
|
||||
}
|
||||
}
|
@ -2,15 +2,15 @@
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.webapi;
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when WebAPI returns 404, usually when response is supposed to be false.
|
||||
* Thrown when Connection returns 500.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebAPIInternalErrorException extends WebAPIFailException {
|
||||
public WebAPIInternalErrorException() {
|
||||
public class WebInternalErrorException extends WebFailException {
|
||||
public WebInternalErrorException() {
|
||||
super("Internal Error occurred on receiving server");
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when Connection returns 404, when page is not found.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebNotFoundException extends WebFailException {
|
||||
public WebNotFoundException() {
|
||||
super("Not Found");
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when Connection gets a 412 response due to ServerUUID not being in the database.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebUnauthorizedServerException extends WebFailException {
|
||||
|
||||
public WebUnauthorizedServerException() {
|
||||
}
|
||||
|
||||
public WebUnauthorizedServerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public WebUnauthorizedServerException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebUnauthorizedServerException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.webapi;
|
||||
|
||||
/**
|
||||
* Thrown when WebAPI fails to connect to an address.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebAPIConnectionFailException extends WebAPIException {
|
||||
|
||||
public WebAPIConnectionFailException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebAPIConnectionFailException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.webapi;
|
||||
|
||||
/**
|
||||
* Thrown when WebAPI POST-request fails, general Exception.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebAPIException extends Exception {
|
||||
|
||||
public WebAPIException() {
|
||||
}
|
||||
|
||||
public WebAPIException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public WebAPIException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebAPIException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.webapi;
|
||||
|
||||
/**
|
||||
* Group of WebAPIExceptions that can be considered a failed connection state on some occasions.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebAPIFailException extends WebAPIException {
|
||||
|
||||
public WebAPIFailException() {
|
||||
}
|
||||
|
||||
public WebAPIFailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public WebAPIFailException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebAPIFailException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.webapi;
|
||||
|
||||
/**
|
||||
* Thrown when WebAPI returns 404, usually when response is supposed to be false.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebAPINotFoundException extends WebAPIFailException {
|
||||
public WebAPINotFoundException() {
|
||||
super("Not Found");
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
@ -39,11 +39,11 @@ public class DevCommand extends SubCommand {
|
||||
}
|
||||
String feature = args[0];
|
||||
switch (feature) {
|
||||
case "webapi":
|
||||
case "connection":
|
||||
if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
|
||||
break;
|
||||
}
|
||||
if (!webapi(args[1] + "webapi", args.length >= 3)) {
|
||||
if (!webapi(args[1] + "connection", args.length >= 3)) {
|
||||
sender.sendMessage("[Plan] No such API / Exception occurred.");
|
||||
}
|
||||
break;
|
||||
@ -78,7 +78,7 @@ public class DevCommand extends SubCommand {
|
||||
api.sendRequest(address);
|
||||
}
|
||||
return true;
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
|
@ -7,10 +7,10 @@ import com.djrapitops.plan.api.exceptions.database.FatalDBException;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plan.utilities.Condition;
|
||||
import com.djrapitops.plan.utilities.ManageUtils;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
@ -5,10 +5,10 @@ import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plan.utilities.Condition;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIForbiddenException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebForbiddenException;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
@ -71,9 +71,9 @@ public class ManageSetupCommand extends SubCommand {
|
||||
// plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(address);
|
||||
plugin.getWebServer().getWebAPI().getAPI(RequestSetupWebAPI.class).sendRequest(address);
|
||||
sender.sendMessage("§eConnection successful, Plan may restart in a few seconds, if it doesn't something has gone wrong.");
|
||||
} catch (WebAPIForbiddenException e) {
|
||||
} catch (WebForbiddenException e) {
|
||||
sender.sendMessage("§eConnection succeeded, but Bungee has set-up mode disabled - use '/planbungee setup' to enable it.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
sender.sendMessage("§cConnection to Bungee WebServer failed: More info on console");
|
||||
}
|
||||
|
@ -5,8 +5,10 @@
|
||||
package com.djrapitops.plan.system;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.cache.CacheSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.system.processing.ProcessingQueue;
|
||||
import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
@ -29,12 +31,14 @@ public abstract class PlanSystem implements SubSystem {
|
||||
// Initialized in this class
|
||||
protected final ProcessingQueue processingQueue;
|
||||
protected final WebServerSystem webServerSystem;
|
||||
protected final CacheSystem cacheSystem;
|
||||
|
||||
// These need to be initialized in the sub class.
|
||||
protected VersionCheckSystem versionCheckSystem;
|
||||
protected FileSystem fileSystem;
|
||||
protected ConfigSystem configSystem;
|
||||
protected DBSystem databaseSystem;
|
||||
protected InfoSystem infoSystem;
|
||||
|
||||
protected ListenerSystem listenerSystem;
|
||||
protected TaskSystem taskSystem;
|
||||
@ -42,6 +46,7 @@ public abstract class PlanSystem implements SubSystem {
|
||||
public PlanSystem() {
|
||||
processingQueue = new ProcessingQueue();
|
||||
webServerSystem = new WebServerSystem();
|
||||
cacheSystem = new CacheSystem(this);
|
||||
}
|
||||
|
||||
public static PlanSystem getInstance() {
|
||||
@ -66,7 +71,10 @@ public abstract class PlanSystem implements SubSystem {
|
||||
fileSystem,
|
||||
configSystem,
|
||||
databaseSystem,
|
||||
webServerSystem,
|
||||
infoSystem,
|
||||
processingQueue,
|
||||
cacheSystem,
|
||||
listenerSystem,
|
||||
taskSystem
|
||||
};
|
||||
@ -78,9 +86,12 @@ public abstract class PlanSystem implements SubSystem {
|
||||
@Override
|
||||
public void disable() {
|
||||
SubSystem[] systems = new SubSystem[]{
|
||||
cacheSystem,
|
||||
listenerSystem,
|
||||
processingQueue,
|
||||
databaseSystem,
|
||||
infoSystem,
|
||||
webServerSystem,
|
||||
taskSystem,
|
||||
configSystem,
|
||||
fileSystem,
|
||||
@ -99,6 +110,7 @@ public abstract class PlanSystem implements SubSystem {
|
||||
NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized."));
|
||||
NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized."));
|
||||
NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized."));
|
||||
NullCheck.check(infoSystem, new IllegalStateException("Info system was not initialized."));
|
||||
NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized."));
|
||||
NullCheck.check(taskSystem, new IllegalStateException("Task system was not initialized."));
|
||||
} catch (Exception e) {
|
||||
@ -143,4 +155,12 @@ public abstract class PlanSystem implements SubSystem {
|
||||
public ServerInfo getServerInfo() {
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
public CacheSystem getCacheSystem() {
|
||||
return cacheSystem;
|
||||
}
|
||||
|
||||
public InfoSystem getInfoSystem() {
|
||||
return infoSystem;
|
||||
}
|
||||
}
|
60
Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java
vendored
Normal file
60
Plan/src/main/java/com/djrapitops/plan/system/cache/CacheSystem.java
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.cache;
|
||||
|
||||
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 com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class CacheSystem implements SubSystem {
|
||||
|
||||
private final DataCache dataCache;
|
||||
private final GeolocationCache geolocationCache;
|
||||
|
||||
public CacheSystem(PlanSystem system) {
|
||||
dataCache = new DataCache(system);
|
||||
geolocationCache = new GeolocationCache();
|
||||
}
|
||||
|
||||
public static CacheSystem getInstance() {
|
||||
CacheSystem cacheSystem = PlanSystem.getInstance().getCacheSystem();
|
||||
NullCheck.check(cacheSystem, new IllegalStateException("Cache System was not initialized."));
|
||||
return cacheSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
try {
|
||||
GeolocationCache.checkDB();
|
||||
} catch (UnknownHostException e) {
|
||||
Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database.");
|
||||
} catch (IOException e) {
|
||||
throw new EnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
geolocationCache.clearCache();
|
||||
}
|
||||
|
||||
public DataCache getDataCache() {
|
||||
return dataCache;
|
||||
}
|
||||
|
||||
public GeolocationCache getGeolocationCache() {
|
||||
return geolocationCache;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.djrapitops.plan.systems.cache;
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
@ -22,7 +22,6 @@ import java.util.*;
|
||||
*/
|
||||
public class DataCache extends SessionCache {
|
||||
|
||||
private static final Map<UUID, Integer> firstSessionInformation = new HashMap<>();
|
||||
private final Database db;
|
||||
private final Map<UUID, String> playerNames;
|
||||
private final Map<String, UUID> uuids;
|
||||
@ -31,11 +30,11 @@ public class DataCache extends SessionCache {
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
* @param system Instance of PlanSystem
|
||||
*/
|
||||
public DataCache(Plan plugin) {
|
||||
super(plugin);
|
||||
db = plugin.getDB();
|
||||
public DataCache(PlanSystem system) {
|
||||
super(system);
|
||||
db = system.getDatabaseSystem().getActiveDatabase();
|
||||
|
||||
playerNames = new HashMap<>();
|
||||
displayNames = new HashMap<>();
|
||||
@ -115,47 +114,10 @@ public class DataCache extends SessionCache {
|
||||
return cached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for marking first Session Actions to be saved.
|
||||
*
|
||||
* @param uuid UUID of the new player.
|
||||
*/
|
||||
public void markFirstSession(UUID uuid) {
|
||||
firstSessionInformation.put(uuid, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition if a session is player's first session on the server.
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @return true / false
|
||||
*/
|
||||
public boolean isFirstSession(UUID uuid) {
|
||||
return firstSessionInformation.containsKey(uuid);
|
||||
}
|
||||
|
||||
public void endFirstSessionActionTracking(UUID uuid) {
|
||||
firstSessionInformation.remove(uuid);
|
||||
}
|
||||
|
||||
public void firstSessionMessageSent(UUID uuid) {
|
||||
Integer msgCount = firstSessionInformation.getOrDefault(uuid, 0);
|
||||
msgCount++;
|
||||
firstSessionInformation.put(uuid, msgCount);
|
||||
}
|
||||
|
||||
public int getFirstSessionMsgCount(UUID uuid) {
|
||||
return firstSessionInformation.getOrDefault(uuid, 0);
|
||||
}
|
||||
|
||||
public Set<UUID> getUuids() {
|
||||
return playerNames.keySet();
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> getFirstSessionMsgCounts() {
|
||||
return firstSessionInformation;
|
||||
}
|
||||
|
||||
public UUID getUUIDof(String playerName) {
|
||||
return uuids.get(playerName);
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.djrapitops.plan.systems.cache;
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.file.FileSystem;
|
||||
import com.djrapitops.plan.utilities.NullCheck;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.maxmind.geoip2.DatabaseReader;
|
||||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
@ -30,14 +31,18 @@ import java.util.zip.GZIPInputStream;
|
||||
*/
|
||||
public class GeolocationCache {
|
||||
|
||||
private static final Map<String, String> geolocationCache = new HashMap<>();
|
||||
private static File geolocationDB = new File(PlanPlugin.getInstance().getDataFolder(), "GeoIP.dat");
|
||||
private final Map<String, String> geolocationCache;
|
||||
private final File geolocationDB;
|
||||
|
||||
/**
|
||||
* Constructor used to hide the public constructor
|
||||
*/
|
||||
private GeolocationCache() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
public GeolocationCache() {
|
||||
geolocationCache = new HashMap<>();
|
||||
geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat");
|
||||
}
|
||||
|
||||
private static GeolocationCache getInstance() {
|
||||
GeolocationCache geolocationCache = CacheSystem.getInstance().getGeolocationCache();
|
||||
NullCheck.check(geolocationCache, new IllegalStateException("GeolocationCache was not initialized."));
|
||||
return geolocationCache;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +64,7 @@ public class GeolocationCache {
|
||||
return country;
|
||||
} else {
|
||||
country = getUnCachedCountry(ipAddress);
|
||||
geolocationCache.put(ipAddress, country);
|
||||
getInstance().geolocationCache.put(ipAddress, country);
|
||||
|
||||
return country;
|
||||
}
|
||||
@ -86,7 +91,7 @@ public class GeolocationCache {
|
||||
try {
|
||||
checkDB();
|
||||
|
||||
try (DatabaseReader reader = new DatabaseReader.Builder(geolocationDB).build()) {
|
||||
try (DatabaseReader reader = new DatabaseReader.Builder(getInstance().geolocationDB).build()) {
|
||||
InetAddress inetAddress = InetAddress.getByName(ipAddress);
|
||||
|
||||
CountryResponse response = reader.country(inetAddress);
|
||||
@ -106,12 +111,12 @@ public class GeolocationCache {
|
||||
* @throws IOException when an error at download or saving the DB happens
|
||||
*/
|
||||
public static void checkDB() throws IOException {
|
||||
if (geolocationDB.exists()) {
|
||||
if (getInstance().geolocationDB.exists()) {
|
||||
return;
|
||||
}
|
||||
URL downloadSite = new URL("http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(new GZIPInputStream(downloadSite.openStream()));
|
||||
FileOutputStream fos = new FileOutputStream(geolocationDB.getAbsoluteFile())) {
|
||||
FileOutputStream fos = new FileOutputStream(getInstance().geolocationDB.getAbsoluteFile())) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
@ -123,7 +128,7 @@ public class GeolocationCache {
|
||||
* @return The cached country, {@code null} if the country is not cached
|
||||
*/
|
||||
private static String getCachedCountry(String ipAddress) {
|
||||
return geolocationCache.get(ipAddress);
|
||||
return getInstance().geolocationCache.get(ipAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,13 +138,13 @@ public class GeolocationCache {
|
||||
* @return true if the IP Address is cached
|
||||
*/
|
||||
public static boolean isCached(String ipAddress) {
|
||||
return geolocationCache.containsKey(ipAddress);
|
||||
return getInstance().geolocationCache.containsKey(ipAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the cache
|
||||
*/
|
||||
public static void clearCache() {
|
||||
public void clearCache() {
|
||||
geolocationCache.clear();
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.djrapitops.plan.systems.cache;
|
||||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
@ -21,14 +21,15 @@ import java.util.UUID;
|
||||
*/
|
||||
public class SessionCache {
|
||||
|
||||
private static final Map<UUID, Integer> firstSessionInformation = new HashMap<>();
|
||||
private static final Map<UUID, Session> activeSessions = new HashMap<>();
|
||||
protected final Plan plugin;
|
||||
protected final PlanSystem system;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*/
|
||||
public SessionCache(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
public SessionCache(PlanSystem system) {
|
||||
this.system = system;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,12 +49,12 @@ public class SessionCache {
|
||||
|
||||
public void cacheSession(UUID uuid, Session session) {
|
||||
activeSessions.put(uuid, session);
|
||||
plugin.addToProcessQueue(new Processor<Plan>(plugin) {
|
||||
new Processor<PlanSystem>(system) {
|
||||
@Override
|
||||
public void process() {
|
||||
plugin.getInfoManager().cachePlayer(uuid);
|
||||
system.getInfoManager().cachePlayer(uuid);
|
||||
}
|
||||
});
|
||||
}.queue();
|
||||
}
|
||||
|
||||
public void endSession(UUID uuid, long time) {
|
||||
@ -68,7 +69,7 @@ public class SessionCache {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} finally {
|
||||
activeSessions.remove(uuid);
|
||||
plugin.getInfoManager().cachePlayer(uuid);
|
||||
system.getInfoManager().cachePlayer(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,4 +92,41 @@ public class SessionCache {
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for marking first Session Actions to be saved.
|
||||
*
|
||||
* @param uuid UUID of the new player.
|
||||
*/
|
||||
public void markFirstSession(UUID uuid) {
|
||||
firstSessionInformation.put(uuid, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition if a session is player's first session on the server.
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @return true / false
|
||||
*/
|
||||
public boolean isFirstSession(UUID uuid) {
|
||||
return firstSessionInformation.containsKey(uuid);
|
||||
}
|
||||
|
||||
public void endFirstSessionActionTracking(UUID uuid) {
|
||||
firstSessionInformation.remove(uuid);
|
||||
}
|
||||
|
||||
public void firstSessionMessageSent(UUID uuid) {
|
||||
Integer msgCount = firstSessionInformation.getOrDefault(uuid, 0);
|
||||
msgCount++;
|
||||
firstSessionInformation.put(uuid, msgCount);
|
||||
}
|
||||
|
||||
public int getFirstSessionMsgCount(UUID uuid) {
|
||||
return firstSessionInformation.getOrDefault(uuid, 0);
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> getFirstSessionMsgCounts() {
|
||||
return firstSessionInformation;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.system.database.databases;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.UnsupportedTransferDatabaseException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
@ -67,4 +68,6 @@ public abstract class Database {
|
||||
}
|
||||
|
||||
public abstract void scheduleClean(long delay);
|
||||
|
||||
public abstract TransferOperations transfer() throws UnsupportedTransferDatabaseException;
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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.database.databases.operation;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface TransferOperations {
|
||||
void playerHtml(UUID player, String html) throws DBException;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.utilities.NullCheck;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class InfoSystem implements SubSystem {
|
||||
|
||||
protected final ConnectionSystem connectionSystem;
|
||||
|
||||
public InfoSystem(ConnectionSystem connectionSystem) {
|
||||
this.connectionSystem = connectionSystem;
|
||||
}
|
||||
|
||||
public static InfoSystem getInstance() {
|
||||
InfoSystem infoSystem = PlanSystem.getInstance().getInfoSystem();
|
||||
NullCheck.check(infoSystem, new IllegalStateException("Info System was not initialized."));
|
||||
return infoSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
|
||||
public ConnectionSystem getConnectionSystem() {
|
||||
return connectionSystem;
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.info.request.InfoRequest;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents an outbound action request to another Plan server.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ConnectionOut {
|
||||
|
||||
private static final TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
|
||||
//No need to implement.
|
||||
}
|
||||
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
|
||||
//No need to implement.
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final String address;
|
||||
private final UUID serverUUID;
|
||||
private final InfoRequest infoRequest;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param address Full address to another Plan webserver. (http://something:port)
|
||||
* @param serverUUID UUID of server this outbound connection.
|
||||
* @param infoRequest Type of the action this connection wants to be performed.
|
||||
*/
|
||||
public ConnectionOut(String address, UUID serverUUID, InfoRequest infoRequest) {
|
||||
Verify.nullCheck(address, serverUUID, infoRequest);
|
||||
this.address = address;
|
||||
this.serverUUID = serverUUID;
|
||||
this.infoRequest = infoRequest;
|
||||
}
|
||||
|
||||
public void sendRequest() throws WebException {
|
||||
try {
|
||||
URL url = new URL(address + "/api/" + this.getClass().getSimpleName().toLowerCase());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
if (address.startsWith("https")) {
|
||||
HttpsURLConnection httpsConn = (HttpsURLConnection) connection;
|
||||
|
||||
// Disables unsigned certificate & hostname check, because we're trusting the user given certificate.
|
||||
|
||||
// This allows https connections internally to local ports.
|
||||
httpsConn.setHostnameVerifier((hostname, session) -> true);
|
||||
|
||||
// This allows connecting to connections with invalid certificate
|
||||
// Drawback: MitM attack possible between connections to servers that are not local.
|
||||
// Scope: WebAPI transmissions
|
||||
// Risk: Attacker sets up a server between Bungee and Bukkit WebServers
|
||||
// - Negotiates SSL Handshake with both servers
|
||||
// - Receives the SSL encrypted data, but decrypts it in the MitM server.
|
||||
// -> Access to valid ServerUUID for POST requests
|
||||
// -> Access to sending Html to the (Bungee) WebServer
|
||||
// Mitigating factors:
|
||||
// - If Server owner has access to all routing done on the domain (IP/Address)
|
||||
// - If Direct IPs are used to transfer between servers
|
||||
// Alternative solution: WebAPI run only on HTTP, HTTP can be read during transmission,
|
||||
// would require running two WebServers when HTTPS is used.
|
||||
httpsConn.setSSLSocketFactory(getRelaxedSocketFactory());
|
||||
}
|
||||
connection.setConnectTimeout(10000);
|
||||
connection.setDoOutput(true);
|
||||
connection.setInstanceFollowRedirects(false);
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
connection.setRequestProperty("charset", "UTF-8");
|
||||
|
||||
String parameters = parseVariables();
|
||||
infoRequest.placeDataToDatabase();
|
||||
|
||||
connection.setRequestProperty("Content-Length", Integer.toString(parameters.length()));
|
||||
|
||||
byte[] toSend = parameters.getBytes();
|
||||
|
||||
connection.setUseCaches(false);
|
||||
Log.debug("ConnectionOut: " + infoRequest.getClass().getSimpleName() + " to " + address);
|
||||
try (DataOutputStream out = new DataOutputStream(connection.getOutputStream())) {
|
||||
out.write(toSend);
|
||||
}
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
Log.debug("Response: " + responseCode);
|
||||
switch (responseCode) {
|
||||
case 200:
|
||||
return;
|
||||
case 400:
|
||||
throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters);
|
||||
case 403:
|
||||
throw new WebForbiddenException(url.toString());
|
||||
case 404:
|
||||
throw new WebNotFoundException();
|
||||
case 412:
|
||||
throw new WebUnauthorizedServerException();
|
||||
case 500:
|
||||
throw new WebInternalErrorException();
|
||||
default:
|
||||
throw new WebException(url.toString() + "| Wrong response code " + responseCode);
|
||||
}
|
||||
} catch (SocketTimeoutException e) {
|
||||
throw new ConnectionFailException("Connection timed out after 10 seconds.", e);
|
||||
} catch (NoSuchAlgorithmException | KeyManagementException | IOException e) {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
throw new ConnectionFailException("Connection failed. address: " + address, e);
|
||||
}
|
||||
}
|
||||
|
||||
private String parseVariables() {
|
||||
return "sender=" + serverUUID + ";&variable;" +
|
||||
"type=" + infoRequest.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private SSLSocketFactory getRelaxedSocketFactory() throws NoSuchAlgorithmException, KeyManagementException {
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
return sc.getSocketFactory();
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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.connection;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.info.InfoSystem;
|
||||
import com.djrapitops.plan.system.info.request.CacheInspectPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.InfoRequest;
|
||||
import com.djrapitops.plan.systems.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.NullCheck;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ConnectionSystem manages out- and inbound InfoRequest connections.
|
||||
* <p>
|
||||
* It decides what server to use for each request.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class ConnectionSystem {
|
||||
|
||||
protected final Map<String, InfoRequest> dataRequests;
|
||||
protected final UUID serverUUID;
|
||||
protected Map<UUID, ServerInfo> servers;
|
||||
|
||||
public ConnectionSystem(UUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
|
||||
servers = new HashMap<>();
|
||||
dataRequests = loadDataRequests();
|
||||
}
|
||||
|
||||
public static ConnectionSystem getInstance() {
|
||||
ConnectionSystem connectionSystem = InfoSystem.getInstance().getConnectionSystem();
|
||||
NullCheck.check(connectionSystem, new IllegalStateException("Connection System was not initialized"));
|
||||
return connectionSystem;
|
||||
}
|
||||
|
||||
private Map<String, InfoRequest> loadDataRequests() {
|
||||
Map<String, InfoRequest> requests = new HashMap<>();
|
||||
putRequest(requests, CacheInspectPageRequest.createHandler());
|
||||
return requests;
|
||||
}
|
||||
|
||||
private void putRequest(Map<String, InfoRequest> requests, InfoRequest request) {
|
||||
requests.put(request.getClass().getSimpleName(), request);
|
||||
}
|
||||
|
||||
protected abstract ServerInfo selectServerForRequest(InfoRequest infoRequest) throws NoServersException;
|
||||
|
||||
public void sendInfoRequest(InfoRequest infoRequest) throws WebException {
|
||||
ServerInfo serverInfo = selectServerForRequest(infoRequest);
|
||||
String address = serverInfo.getWebAddress();
|
||||
|
||||
new ConnectionOut(address, serverUUID, infoRequest).sendRequest();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.request;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* InfoRequest used to place HTML of a player to ResponseCache.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class CacheInspectPageRequest implements InfoRequest {
|
||||
|
||||
private final UUID player;
|
||||
private final String html;
|
||||
|
||||
private CacheInspectPageRequest() {
|
||||
player = null;
|
||||
html = null;
|
||||
}
|
||||
|
||||
public CacheInspectPageRequest(UUID player, String html) {
|
||||
this.player = player;
|
||||
this.html = html;
|
||||
}
|
||||
|
||||
public static CacheInspectPageRequest createHandler() {
|
||||
return new CacheInspectPageRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeDataToDatabase() throws WebException {
|
||||
Verify.nullCheck(player, html);
|
||||
|
||||
String encodedHtml = Base64Util.encode(html);
|
||||
try {
|
||||
Database.getActive().transfer().playerHtml(player, encodedHtml);
|
||||
} catch (DBException e) {
|
||||
throw new TransferDatabaseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response handleRequest(Map<String, String> variables) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.request;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface InfoRequest {
|
||||
|
||||
void placeDataToDatabase() throws WebException;
|
||||
|
||||
Response handleRequest(Map<String, String> variables);
|
||||
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.djrapitops.plan.system.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.processing.processors.player.NameProcessor;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -2,10 +2,10 @@ package com.djrapitops.plan.system.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
|
||||
import com.djrapitops.plan.system.processing.processors.player.*;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.api.systems.NotificationCenter;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
@ -10,11 +10,11 @@ import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.container.UserInfo;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.processing.processors.importing.ServerImportData;
|
||||
import com.djrapitops.plan.system.processing.processors.importing.UserImportData;
|
||||
import com.djrapitops.plan.system.processing.processors.importing.UserImportRefiner;
|
||||
import com.djrapitops.plan.systems.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
@ -8,8 +8,8 @@ import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
|
@ -6,8 +6,8 @@ package com.djrapitops.plan.system.processing.processors.player;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.data.container.GeoInfo;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.systems.cache.GeolocationCache;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -6,10 +6,10 @@ package com.djrapitops.plan.system.processing.processors.player;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.processing.ProcessingQueue;
|
||||
import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -9,10 +9,9 @@ import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
@ -30,9 +29,8 @@ public class BasicAuthentication implements Authentication {
|
||||
|
||||
@Override
|
||||
public WebUser getWebUser() throws WebUserAuthException {
|
||||
Base64.Decoder decoder = Base64.getDecoder();
|
||||
byte[] decoded = decoder.decode(authenticationString);
|
||||
String[] userInfo = new String(decoded).split(":");
|
||||
String decoded = Base64Util.decode(authenticationString);
|
||||
String[] userInfo = decoded.split(":");
|
||||
if (userInfo.length != 2) {
|
||||
throw new WebUserAuthException(FailReason.USER_AND_PASS_NOT_SPECIFIED);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.*;
|
||||
import com.djrapitops.plan.api.exceptions.connection.*;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.ResponseCache;
|
||||
@ -84,7 +84,7 @@ public abstract class WebAPI {
|
||||
|
||||
public abstract Response onRequest(PlanPlugin plugin, Map<String, String> variables);
|
||||
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
Verify.nullCheck(address);
|
||||
|
||||
try {
|
||||
@ -139,23 +139,23 @@ public abstract class WebAPI {
|
||||
case 200:
|
||||
return;
|
||||
case 400:
|
||||
throw new WebAPIFailException("Bad Request: " + url.toString() + "|" + parameters);
|
||||
throw new WebFailException("Bad Request: " + url.toString() + "|" + parameters);
|
||||
case 403:
|
||||
throw new WebAPIForbiddenException(url.toString());
|
||||
throw new WebForbiddenException(url.toString());
|
||||
case 404:
|
||||
throw new WebAPINotFoundException();
|
||||
throw new WebNotFoundException();
|
||||
case 500:
|
||||
throw new WebAPIInternalErrorException();
|
||||
throw new WebInternalErrorException();
|
||||
default:
|
||||
throw new WebAPIException(url.toString() + "| Wrong response code " + responseCode);
|
||||
throw new WebException(url.toString() + "| Wrong response code " + responseCode);
|
||||
}
|
||||
} catch (SocketTimeoutException e) {
|
||||
throw new WebAPIConnectionFailException("Connection timed out after 10 seconds.", e);
|
||||
throw new ConnectionFailException("Connection timed out after 10 seconds.", e);
|
||||
} catch (NoSuchAlgorithmException | KeyManagementException | IOException e) {
|
||||
if (Settings.DEV_MODE.isTrue()) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
throw new WebAPIConnectionFailException("API connection failed. address: " + address, e);
|
||||
throw new ConnectionFailException("API connection failed. address: " + address, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
|
||||
@ -28,11 +28,11 @@ public class AnalysisReadyWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID serverUUID) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID serverUUID) throws WebException {
|
||||
addVariable("serverUUID", serverUUID.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
|
||||
@ -28,11 +28,11 @@ public class AnalyzeWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID serverUUID) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID serverUUID) throws WebException {
|
||||
addVariable("serverUUID", serverUUID.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.settings.ServerSpecificSettings;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
@ -41,11 +41,11 @@ public class ConfigurationWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID serverUUID, String accessKey) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID serverUUID, String accessKey) throws WebException {
|
||||
if (accessKey != null) {
|
||||
addVariable("accessKey", accessKey);
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class ConfigurationWebAPI extends WebAPI {
|
||||
sendRequest(address, serverUUID);
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID serverUUID) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID serverUUID) throws WebException {
|
||||
Map<String, Object> configValues = getConfigValues(serverUUID);
|
||||
for (Map.Entry<String, Object> entry : configValues.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
@ -73,10 +73,10 @@ public class ConfigurationWebAPI extends WebAPI {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> getConfigValues(UUID serverUUID) throws WebAPIException {
|
||||
private Map<String, Object> getConfigValues(UUID serverUUID) throws WebException {
|
||||
Map<String, Object> configValues = new HashMap<>();
|
||||
if (!Check.isBungeeAvailable()) {
|
||||
throw new WebAPIException("Attempted to send config values from Bukkit to Bungee.");
|
||||
throw new WebException("Attempted to send config values from Bukkit to Bungee.");
|
||||
}
|
||||
addConfigValue(configValues, Settings.DB_TYPE, "mysql");
|
||||
Settings[] sameStrings = new Settings[]{
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
|
||||
@ -30,11 +30,11 @@ public class InspectWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID uuid) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID uuid) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
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 org.bukkit.entity.Player;
|
||||
@ -36,11 +36,11 @@ public class IsOnlineWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID uuid) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID uuid) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bukkit;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
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;
|
||||
@ -44,11 +44,11 @@ public class RequestInspectPluginsTabBukkitWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID uuid) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID uuid) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
import com.djrapitops.plan.systems.info.InformationManager;
|
||||
@ -52,28 +52,28 @@ public class IsCachedWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public boolean isInspectCached(String address, UUID uuid) throws WebAPIException {
|
||||
public boolean isInspectCached(String address, UUID uuid) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
addVariable("target", "inspectPage");
|
||||
try {
|
||||
super.sendRequest(address);
|
||||
return true;
|
||||
} catch (WebAPINotFoundException e) {
|
||||
} catch (WebNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAnalysisCached(String address, UUID serverUUID) throws WebAPIException {
|
||||
public boolean isAnalysisCached(String address, UUID serverUUID) throws WebException {
|
||||
addVariable("serverUUID", serverUUID.toString());
|
||||
addVariable("target", "analysisPage");
|
||||
try {
|
||||
super.sendRequest(address);
|
||||
return true;
|
||||
} catch (WebAPINotFoundException e) {
|
||||
} catch (WebNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.ResponseCache;
|
||||
@ -77,18 +77,18 @@ public class PostHtmlWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendInspectHtml(String address, UUID uuid, String html) throws WebAPIException {
|
||||
public void sendInspectHtml(String address, UUID uuid, String html) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
addVariable("target", "inspectPage");
|
||||
addVariable("html", html);
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
||||
public void sendAnalysisHtml(String address, String html) throws WebAPIException {
|
||||
public void sendAnalysisHtml(String address, String html) throws WebException {
|
||||
addVariable("html", html);
|
||||
addVariable("target", "analysisPage");
|
||||
super.sendRequest(address);
|
||||
|
@ -5,7 +5,7 @@
|
||||
package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
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.BungeeInformationManager;
|
||||
@ -49,11 +49,11 @@ public class PostInspectPluginsTabWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendPluginsTab(String address, UUID uuid, String[] html) throws WebAPIException {
|
||||
public void sendPluginsTab(String address, UUID uuid, String[] html) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
addVariable("nav", html[0]);
|
||||
addVariable("html", html[1]);
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
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.BungeeInformationManager;
|
||||
@ -38,11 +38,11 @@ public class PostNetworkPageContentWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendNetworkContent(String address, String html) throws WebAPIException {
|
||||
public void sendNetworkContent(String address, String html) throws WebException {
|
||||
addVariable("html", html);
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
@ -48,7 +48,7 @@ public class PostOriginalBukkitSettingsWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
addVariable("WebServerPort", Integer.toString(Settings.WEBSERVER_PORT.getNumber()));
|
||||
addVariable("ServerName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
addVariable("ThemeBase", Settings.THEME_BASE.toString());
|
||||
|
@ -6,7 +6,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
@ -49,11 +49,11 @@ public class RequestPluginsTabWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
|
||||
}
|
||||
|
||||
public void sendRequest(String address, UUID uuid) throws WebAPIException {
|
||||
public void sendRequest(String address, UUID uuid) throws WebException {
|
||||
addVariable("uuid", uuid.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class RequestPluginsTabWebAPI extends WebAPI {
|
||||
String webAddress = server.getWebAddress();
|
||||
try {
|
||||
plugin.getWebServer().getWebAPI().getAPI(RequestInspectPluginsTabBukkitWebAPI.class).sendRequest(webAddress, uuid);
|
||||
} catch (WebAPIException ignore) {
|
||||
} catch (WebException ignore) {
|
||||
/* ignored */
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ package com.djrapitops.plan.system.webserver.webapi.bungee;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.ForbiddenResponse;
|
||||
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
|
||||
@ -50,7 +50,7 @@ public class RequestSetupWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
if (!Check.isBukkitAvailable()) {
|
||||
throw new IllegalStateException("Not supposed to be called on Bungee");
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ 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.webapi.WebAPIException;
|
||||
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;
|
||||
@ -45,7 +45,7 @@ public class PingWebAPI extends WebAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
public void sendRequest(String address) throws WebException {
|
||||
if (Check.isBukkitAvailable()) {
|
||||
super.sendRequest(address);
|
||||
} else {
|
||||
@ -54,7 +54,7 @@ public class PingWebAPI extends WebAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendRequest(String address, String accessCode) throws WebAPIException {
|
||||
public void sendRequest(String address, String accessCode) throws WebException {
|
||||
addVariable("accessKey", accessCode);
|
||||
addVariable("version", PlanPlugin.getInstance().getVersion());
|
||||
sendRequest(address);
|
||||
|
@ -6,16 +6,17 @@ package com.djrapitops.plan.systems.info;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIFailException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebFailException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException;
|
||||
import com.djrapitops.plan.command.commands.AnalyzeCommand;
|
||||
import com.djrapitops.plan.data.AnalysisData;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.processing.processors.Processor;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
@ -34,7 +35,6 @@ 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.bungee.*;
|
||||
import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.info.parsing.AnalysisPage;
|
||||
import com.djrapitops.plan.systems.info.parsing.InspectPage;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
@ -93,9 +93,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
} else if (usingAnotherWebServer) {
|
||||
try {
|
||||
getWebAPI().getAPI(AnalyzeWebAPI.class).sendRequest(webServerAddress, serverUUID);
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed to request Analysis refresh from Bungee.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
refreshAnalysis(serverUUID);
|
||||
}
|
||||
@ -112,9 +112,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
getWebAPI().getAPI(PostHtmlWebAPI.class).sendInspectHtml(webServerAddress, uuid, getPlayerHtml(uuid));
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed to request Inspect from Bungee.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
cachePlayer(uuid);
|
||||
} catch (ParseException e) {
|
||||
@ -156,9 +156,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer && !origin.equals(RequestInspectPluginsTabBukkitWebAPI.class)) {
|
||||
try {
|
||||
getWebAPI().getAPI(RequestPluginsTabWebAPI.class).sendRequest(webServerAddress, uuid);
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed send Player Plugins tab contents to BungeeCord.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
cacheInspectPluginsTab(uuid, origin);
|
||||
}
|
||||
@ -188,9 +188,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
getWebAPI().getAPI(PostInspectPluginsTabWebAPI.class).sendPluginsTab(webServerAddress, uuid, contents);
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed send Player HTML to BungeeCord.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
cacheInspectPluginsTab(uuid, contents);
|
||||
}
|
||||
@ -214,9 +214,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
return getWebAPI().getAPI(IsCachedWebAPI.class).isInspectCached(webServerAddress, uuid);
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed check Bungee Player Cache status.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
return isCached(uuid);
|
||||
}
|
||||
@ -232,9 +232,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
return getWebAPI().getAPI(IsCachedWebAPI.class).isAnalysisCached(webServerAddress, serverUUID);
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed check Bungee Analysis Cache status.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
return isAnalysisCached(serverUUID);
|
||||
}
|
||||
@ -289,9 +289,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
getWebAPI().getAPI(AnalysisReadyWebAPI.class).sendRequest(webServerAddress, serverUUID);
|
||||
updateNetworkPageContent();
|
||||
return;
|
||||
} catch (WebAPIFailException ignored) {
|
||||
} catch (WebFailException ignored) {
|
||||
Log.error("Failed to notify Bungee of Analysis Completion.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
}
|
||||
}
|
||||
@ -306,9 +306,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
getWebAPI().getAPI(PostHtmlWebAPI.class).sendAnalysisHtml(webServerAddress, html);
|
||||
} catch (WebAPIFailException e) {
|
||||
} catch (WebFailException e) {
|
||||
Log.error("Failed to send Analysis HTML to Bungee Server.");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
attemptConnection();
|
||||
cacheAnalysisHtml(html);
|
||||
}
|
||||
@ -344,11 +344,11 @@ public class BukkitInformationManager extends InformationManager {
|
||||
plugin.getServerInfoManager().resetConnectionFails();
|
||||
usingAnotherWebServer = true;
|
||||
return true;
|
||||
} catch (WebAPIConnectionFailException e) {
|
||||
} catch (ConnectionFailException e) {
|
||||
plugin.getServerInfoManager().markConnectionFail();
|
||||
} catch (WebAPINotFoundException e) {
|
||||
} catch (WebNotFoundException e) {
|
||||
Log.info("Bungee reported that UUID of this server is not in the MySQL-database. Try using '/plan m setup " + webServerAddress + "' again");
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
Log.info("Bungee Connection Failed.");
|
||||
@ -384,9 +384,9 @@ public class BukkitInformationManager extends InformationManager {
|
||||
if (usingAnotherWebServer) {
|
||||
try {
|
||||
getWebAPI().getAPI(PostNetworkPageContentWebAPI.class).sendNetworkContent(webServerAddress, HtmlStructure.createServerContainer(plugin));
|
||||
} catch (WebAPIFailException ignored) {
|
||||
} catch (WebFailException ignored) {
|
||||
/* Do nothing */
|
||||
} catch (WebAPIException ignored) {
|
||||
} catch (WebException ignored) {
|
||||
attemptConnection();
|
||||
updateNetworkPageContent();
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.djrapitops.plan.systems.info;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPINotFoundException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.ConnectionFailException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebNotFoundException;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.ResponseCache;
|
||||
@ -24,7 +25,6 @@ import com.djrapitops.plan.system.webserver.webapi.bukkit.AnalyzeWebAPI;
|
||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.InspectWebAPI;
|
||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.IsOnlineWebAPI;
|
||||
import com.djrapitops.plan.system.webserver.webapi.bungee.RequestPluginsTabWebAPI;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.info.parsing.NetworkPage;
|
||||
import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
|
||||
import com.djrapitops.plan.systems.info.server.ServerInfo;
|
||||
@ -91,9 +91,9 @@ public class BungeeInformationManager extends InformationManager {
|
||||
AnalyzeWebAPI api = plugin.getWebServer().getWebAPI().getAPI(AnalyzeWebAPI.class);
|
||||
try {
|
||||
api.sendRequest(serverInfo.getWebAddress(), serverUUID);
|
||||
} catch (WebAPIConnectionFailException e) {
|
||||
} catch (ConnectionFailException e) {
|
||||
attemptConnection();
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ public class BungeeInformationManager extends InformationManager {
|
||||
apiManager.getAPI(RequestPluginsTabWebAPI.class).sendRequestsToBukkitServers(plugin, uuid);
|
||||
} catch (IllegalStateException ignored) {
|
||||
/* Ignored */
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
plugin.getServerInfoManager().attemptConnection(inspectServer);
|
||||
}
|
||||
}
|
||||
@ -181,11 +181,11 @@ public class BungeeInformationManager extends InformationManager {
|
||||
try {
|
||||
getWebAPI().getAPI(IsOnlineWebAPI.class).sendRequest(server.getWebAddress(), uuid);
|
||||
return server;
|
||||
} catch (WebAPIConnectionFailException e) {
|
||||
} catch (ConnectionFailException e) {
|
||||
serverInfoManager.serverHasGoneOffline(server.getUuid());
|
||||
} catch (WebAPINotFoundException ignored) {
|
||||
} catch (WebNotFoundException ignored) {
|
||||
/*continue*/
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
@ -364,7 +364,7 @@ public class BungeeInformationManager extends InformationManager {
|
||||
for (ServerInfo serverInfo : serverInfoManager.getOnlineBukkitServers()) {
|
||||
try {
|
||||
api.sendRequest(serverInfo.getWebAddress(), serverUUID);
|
||||
} catch (WebAPIException ignored) {
|
||||
} catch (WebException ignored) {
|
||||
/*Ignored*/
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
package com.djrapitops.plan.systems.info;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.pagecache.ResponseCache;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -7,7 +7,7 @@ package com.djrapitops.plan.systems.info.server;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.ServerVariableHolder;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.api.exceptions.webapi.WebAPIException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
||||
import com.djrapitops.plan.system.webserver.webapi.bukkit.ConfigurationWebAPI;
|
||||
@ -105,7 +105,7 @@ public class BungeeServerInfoManager {
|
||||
}
|
||||
connectedToServer(server);
|
||||
return true;
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
Log.debug(e.toString());
|
||||
serverHasGoneOffline(server.getUuid());
|
||||
return false;
|
||||
@ -126,7 +126,7 @@ public class BungeeServerInfoManager {
|
||||
webAddress = server.getWebAddress();
|
||||
Log.debug("Sending config settings to " + webAddress + "");
|
||||
plugin.getWebServer().getWebAPI().getAPI(ConfigurationWebAPI.class).sendRequest(webAddress, serverUUID);
|
||||
} catch (WebAPIException e) {
|
||||
} catch (WebException e) {
|
||||
Log.info("Connection to Bukkit (" + webAddress + ") did not succeed.");
|
||||
serverHasGoneOffline(serverUUID);
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.utilities;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Base64Util {
|
||||
|
||||
public static String encode(String decoded) {
|
||||
byte[] encoded = Base64.getEncoder().encode(decoded.getBytes());
|
||||
return new String(encoded);
|
||||
}
|
||||
|
||||
public static String decode(String encoded) {
|
||||
byte[] decoded = Base64.getDecoder().decode(encoded.getBytes());
|
||||
return new String(decoded);
|
||||
}
|
||||
|
||||
}
|
@ -9,14 +9,14 @@ import com.djrapitops.plan.data.plugin.BanData;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.tasks.BukkitTaskSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse;
|
||||
import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import com.djrapitops.plan.systems.info.InformationManager;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
|
@ -9,9 +9,9 @@ import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.settings.WorldAliasSettings;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plan.utilities.FormatUtils;
|
||||
import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package com.djrapitops.plan.data.cache;
|
||||
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.djrapitops.plan.data.cache;
|
||||
|
||||
import com.djrapitops.plan.systems.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.data.cache;
|
||||
|
||||
import com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -13,13 +13,13 @@ import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.data.container.*;
|
||||
import com.djrapitops.plan.data.time.GMTimes;
|
||||
import com.djrapitops.plan.data.time.WorldTimes;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
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.SQLiteDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
||||
import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.ManageUtils;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
@ -1,44 +0,0 @@
|
||||
package com.djrapitops.plan.systems.cache;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
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.MockUtils;
|
||||
import test.utilities.TestInit;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(JavaPlugin.class)
|
||||
public class SessionCacheTest {
|
||||
|
||||
private final UUID uuid = MockUtils.getPlayerUUID();
|
||||
private SessionCache sessionCache;
|
||||
private Session session;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
TestInit t = TestInit.init();
|
||||
sessionCache = new SessionCache(null);
|
||||
session = new Session(12345L, "World1", "SURVIVAL");
|
||||
sessionCache.cacheSession(uuid, session);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Ignored, Requires more mocks")
|
||||
public void testAtomity() {
|
||||
SessionCache reloaded = new SessionCache(null);
|
||||
Optional<Session> cachedSession = reloaded.getCachedSession(uuid);
|
||||
assertTrue(cachedSession.isPresent());
|
||||
assertEquals(session, cachedSession.get());
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@ package test.utilities;
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.ServerVariableHolder;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.systems.cache.DataCache;
|
||||
import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
import com.djrapitops.plugin.IPlugin;
|
||||
|
Loading…
Reference in New Issue
Block a user