mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 01:17:45 +01:00
Removed ConnectionSystem
This commit is contained in:
parent
e46ab76173
commit
a68ac696c4
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* 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, ResponseCode.CONNECTION_REFUSED);
|
||||
}
|
||||
|
||||
public ConnectionFailException(Throwable cause) {
|
||||
super(cause, ResponseCode.CONNECTION_REFUSED);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ForbiddenException extends WebFailException {
|
||||
public class ForbiddenException extends WebException {
|
||||
public ForbiddenException(String url) {
|
||||
super("Forbidden: " + url, ResponseCode.FORBIDDEN);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class InternalErrorException extends WebFailException {
|
||||
public class InternalErrorException extends WebException {
|
||||
public InternalErrorException() {
|
||||
super("Internal Error occurred on receiving server", ResponseCode.INTERNAL_ERROR);
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
/**
|
||||
* Thrown when ConnectionSystem can not find any servers to send request to.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NoServersException extends WebException {
|
||||
|
||||
public NoServersException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NoServersException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public NoServersException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class NotFoundException extends WebFailException {
|
||||
public class NotFoundException extends WebException {
|
||||
public NotFoundException(String message) {
|
||||
super(message, ResponseCode.NOT_FOUND);
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.api.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.system.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Group of WebExceptions that can be considered a failed connection state on some occasions.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WebFailException extends WebException {
|
||||
|
||||
public WebFailException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public WebFailException(String message, ResponseCode responseCode) {
|
||||
super(message, responseCode);
|
||||
}
|
||||
|
||||
public WebFailException(String message, Throwable cause, ResponseCode responseCode) {
|
||||
super(message, cause, responseCode);
|
||||
}
|
||||
|
||||
public WebFailException(Throwable cause, ResponseCode responseCode) {
|
||||
super(cause, responseCode);
|
||||
}
|
||||
}
|
@ -20,9 +20,9 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.HtmlExport;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
@ -57,7 +57,6 @@ public class AnalyzeCommand extends CommandNode {
|
||||
private final ServerInfo serverInfo;
|
||||
private final WebServer webServer;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
@ -66,7 +65,6 @@ public class AnalyzeCommand extends CommandNode {
|
||||
Processing processing,
|
||||
HtmlExport export,
|
||||
ServerInfo serverInfo,
|
||||
ConnectionSystem connectionSystem,
|
||||
WebServer webServer,
|
||||
DBSystem dbSystem,
|
||||
ErrorHandler errorHandler
|
||||
@ -77,7 +75,6 @@ public class AnalyzeCommand extends CommandNode {
|
||||
this.processing = processing;
|
||||
this.export = export;
|
||||
this.serverInfo = serverInfo;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.webServer = webServer;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -89,7 +86,8 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
@Override
|
||||
public void onCommand(Sender sender, String commandLabel, String[] args) {
|
||||
Database.State dbState = dbSystem.getDatabase().getState();
|
||||
Database database = dbSystem.getDatabase();
|
||||
Database.State dbState = database.getState();
|
||||
if (dbState != Database.State.OPEN) {
|
||||
sender.sendMessage(locale.getString(CommandLang.FAIL_DATABASE_NOT_OPEN, dbState.name()));
|
||||
return;
|
||||
@ -97,11 +95,9 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
processing.submitNonCritical(() -> {
|
||||
try {
|
||||
Server server = getServer(args).orElseGet(serverInfo::getServer);
|
||||
Server server = getServer(args);
|
||||
sendWebUserNotificationIfNecessary(sender);
|
||||
if (connectionSystem.isServerAvailable()) {
|
||||
export.exportServer(server.getUuid());
|
||||
}
|
||||
export.exportServer(server.getUuid());
|
||||
sendLink(server, sender);
|
||||
} catch (DBOpException e) {
|
||||
sender.sendMessage("§cError occurred: " + e.toString());
|
||||
@ -112,7 +108,8 @@ public class AnalyzeCommand extends CommandNode {
|
||||
|
||||
private void sendLink(Server server, Sender sender) {
|
||||
String target = "/server/" + server.getName();
|
||||
String url = connectionSystem.getMainAddress() + target;
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + target;
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_ANALYSIS));
|
||||
// Link
|
||||
@ -134,22 +131,24 @@ public class AnalyzeCommand extends CommandNode {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<Server> getServer(String[] args) {
|
||||
if (args.length >= 1 && connectionSystem.isServerAvailable()) {
|
||||
String serverIdentifier = getGivenIdentifier(args);
|
||||
return dbSystem.getDatabase().query(ServerQueries.fetchServerMatchingIdentifier(serverIdentifier))
|
||||
.filter(server -> !server.isProxy());
|
||||
}
|
||||
return Optional.empty();
|
||||
private Server getServer(String[] args) {
|
||||
return getGivenIdentifier(args)
|
||||
.flatMap(serverIdentifier -> dbSystem.getDatabase()
|
||||
.query(ServerQueries.fetchServerMatchingIdentifier(serverIdentifier))
|
||||
).filter(server -> !server.isProxy())
|
||||
.orElseGet(serverInfo::getServer);
|
||||
}
|
||||
|
||||
private String getGivenIdentifier(String[] args) {
|
||||
private Optional<String> getGivenIdentifier(String[] args) {
|
||||
if (args.length < 1) {
|
||||
return Optional.empty();
|
||||
}
|
||||
StringBuilder idBuilder = new StringBuilder(args[0]);
|
||||
if (args.length > 1) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
idBuilder.append(" ").append(args[i]);
|
||||
}
|
||||
}
|
||||
return idBuilder.toString();
|
||||
return Optional.of(idBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
@ -42,7 +42,6 @@ public class InfoCommand extends CommandNode {
|
||||
private final PlanPlugin plugin;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
|
||||
@Inject
|
||||
@ -50,7 +49,6 @@ public class InfoCommand extends CommandNode {
|
||||
PlanPlugin plugin,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
ConnectionSystem connectionSystem,
|
||||
VersionCheckSystem versionCheckSystem
|
||||
) {
|
||||
super("info", Permissions.INFO.getPermission(), CommandType.CONSOLE);
|
||||
@ -58,7 +56,6 @@ public class InfoCommand extends CommandNode {
|
||||
this.plugin = plugin;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
|
||||
setShortHelp(locale.get(CmdHelpLang.INFO).toString());
|
||||
@ -69,18 +66,19 @@ public class InfoCommand extends CommandNode {
|
||||
String yes = locale.getString(GenericLang.YES);
|
||||
String no = locale.getString(GenericLang.NO);
|
||||
|
||||
String updateAvailable = versionCheckSystem.isNewVersionAvailable() ? yes : no;
|
||||
String connectedToBungee = connectionSystem.isServerAvailable() ? yes : no;
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
|
||||
String updateAvailable = versionCheckSystem.isNewVersionAvailable() ? yes : no;
|
||||
String proxyAvailable = database.query(ServerQueries.fetchProxyServerInformation()).isPresent() ? yes : no;
|
||||
|
||||
|
||||
String[] messages = {
|
||||
locale.getString(CommandLang.HEADER_INFO),
|
||||
"",
|
||||
locale.getString(CommandLang.INFO_VERSION, plugin.getVersion()),
|
||||
locale.getString(CommandLang.INFO_UPDATE, updateAvailable),
|
||||
locale.getString(CommandLang.INFO_DATABASE, database.getType().getName() + " (" + database.getState().name() + ")"),
|
||||
locale.getString(CommandLang.INFO_PROXY_CONNECTION, connectedToBungee),
|
||||
locale.getString(CommandLang.INFO_PROXY_CONNECTION, proxyAvailable),
|
||||
"",
|
||||
">"
|
||||
};
|
||||
|
@ -20,14 +20,13 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.PlayerFetchQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.info.InfoProcessors;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
@ -52,27 +51,21 @@ public class InspectCommand extends CommandNode {
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
private final InfoProcessors processorFactory;
|
||||
private final Processing processing;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final UUIDUtility uuidUtility;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public InspectCommand(
|
||||
Locale locale,
|
||||
InfoProcessors processorFactory,
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer,
|
||||
ConnectionSystem connectionSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super("inspect", Permissions.INSPECT.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
this.processorFactory = processorFactory;
|
||||
this.processing = processing;
|
||||
this.connectionSystem = connectionSystem;
|
||||
setArguments("<player>");
|
||||
|
||||
this.locale = locale;
|
||||
@ -138,7 +131,8 @@ public class InspectCommand extends CommandNode {
|
||||
private void sendInspectMsg(Sender sender, String playerName) {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||
|
||||
String url = connectionSystem.getMainAddress() + "/player/" + playerName;
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/player/" + playerName;
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
|
@ -16,12 +16,14 @@
|
||||
*/
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -37,14 +39,20 @@ import javax.inject.Inject;
|
||||
public class ListPlayersCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
|
||||
@Inject
|
||||
public ListPlayersCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
public ListPlayersCommand(
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer
|
||||
) {
|
||||
super("players|pl|playerlist|list", Permissions.INSPECT_OTHER.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.PLAYERS));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.PLAYERS));
|
||||
@ -59,7 +67,8 @@ public class ListPlayersCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_PLAYERS));
|
||||
|
||||
// Link
|
||||
String url = connectionSystem.getMainAddress() + "/players/";
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/players/";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -16,12 +16,14 @@
|
||||
*/
|
||||
package com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
@ -37,14 +39,20 @@ import javax.inject.Inject;
|
||||
public class NetworkCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
|
||||
@Inject
|
||||
public NetworkCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
public NetworkCommand(
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
WebServer webServer
|
||||
) {
|
||||
super("network|n|netw", Permissions.ANALYZE.getPermission(), CommandType.CONSOLE);
|
||||
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
|
||||
setShortHelp(locale.getString(CmdHelpLang.NETWORK));
|
||||
setInDepthHelp(locale.getArray(DeepHelpLang.NETWORK));
|
||||
@ -59,7 +67,8 @@ public class NetworkCommand extends CommandNode {
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_NETWORK));
|
||||
|
||||
// Link
|
||||
String url = connectionSystem.getMainAddress() + "/network/";
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/network/";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -21,14 +21,15 @@ import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WebUserQueries;
|
||||
import com.djrapitops.plan.db.access.transactions.commands.RegisterWebUserTransaction;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
@ -61,7 +62,7 @@ public class RegisterCommand extends CommandNode {
|
||||
private final Locale locale;
|
||||
private final Processing processing;
|
||||
private final DBSystem dbSystem;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final WebServer webServer;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -70,7 +71,7 @@ public class RegisterCommand extends CommandNode {
|
||||
Locale locale,
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
ConnectionSystem connectionSystem,
|
||||
WebServer webServer,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
@ -79,7 +80,7 @@ public class RegisterCommand extends CommandNode {
|
||||
|
||||
this.locale = locale;
|
||||
this.processing = processing;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.webServer = webServer;
|
||||
this.logger = logger;
|
||||
this.dbSystem = dbSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -181,7 +182,7 @@ public class RegisterCommand extends CommandNode {
|
||||
}
|
||||
|
||||
private void sendLink(Sender sender) {
|
||||
String url = connectionSystem.getMainAddress();
|
||||
String url = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
// Link
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
|
@ -16,12 +16,14 @@
|
||||
*/
|
||||
package com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.locale.lang.CmdHelpLang;
|
||||
import com.djrapitops.plan.system.locale.lang.CommandLang;
|
||||
import com.djrapitops.plan.system.locale.lang.DeepHelpLang;
|
||||
import com.djrapitops.plan.system.settings.Permissions;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
@ -41,14 +43,16 @@ import java.util.Arrays;
|
||||
public class ManageRawDataCommand extends CommandNode {
|
||||
|
||||
private final Locale locale;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final DBSystem dbSystem;
|
||||
private final WebServer webServer;
|
||||
|
||||
@Inject
|
||||
public ManageRawDataCommand(Locale locale, ConnectionSystem connectionSystem) {
|
||||
public ManageRawDataCommand(Locale locale, DBSystem dbSystem, WebServer webServer) {
|
||||
super("raw", Permissions.MANAGE.getPermission(), CommandType.PLAYER_OR_ARGS);
|
||||
|
||||
this.locale = locale;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.dbSystem = dbSystem;
|
||||
this.webServer = webServer;
|
||||
|
||||
setArguments("<player>");
|
||||
setShortHelp(locale.getString(CmdHelpLang.MANAGE_RAW_DATA));
|
||||
@ -64,7 +68,8 @@ public class ManageRawDataCommand extends CommandNode {
|
||||
|
||||
sender.sendMessage(locale.getString(CommandLang.HEADER_INSPECT, playerName));
|
||||
// Link
|
||||
String url = connectionSystem.getMainAddress() + "/player/" + playerName + "/raw";
|
||||
String address = PlanSystem.getMainAddress(webServer, dbSystem);
|
||||
String url = address + "/player/" + playerName + "/raw";
|
||||
String linkPrefix = locale.getString(CommandLang.LINK_PREFIX);
|
||||
boolean console = !CommandUtils.isPlayer(sender);
|
||||
if (console) {
|
||||
|
@ -22,8 +22,6 @@ import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.database.ProxyDBSystem;
|
||||
import com.djrapitops.plan.system.importing.EmptyImportSystem;
|
||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ProxyConnectionSystem;
|
||||
import com.djrapitops.plan.system.settings.ConfigSystem;
|
||||
import com.djrapitops.plan.system.settings.ProxyConfigSystem;
|
||||
import dagger.Binds;
|
||||
@ -49,7 +47,4 @@ public interface ProxySuperClassBindingModule {
|
||||
@Binds
|
||||
ImportSystem bindImportSystem(EmptyImportSystem emptyImportSystem);
|
||||
|
||||
@Binds
|
||||
ConnectionSystem bindServerConnectionSystem(ProxyConnectionSystem connectionSystem);
|
||||
|
||||
}
|
@ -18,8 +18,6 @@ package com.djrapitops.plan.modules;
|
||||
|
||||
import com.djrapitops.plan.api.CommonAPI;
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ServerConnectionSystem;
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
|
||||
@ -34,7 +32,4 @@ public interface ServerSuperClassBindingModule {
|
||||
@Binds
|
||||
PlanAPI bindServerPlanAPI(CommonAPI serverAPI);
|
||||
|
||||
@Binds
|
||||
ConnectionSystem bindServerConnectionSystem(ServerConnectionSystem connectionSystem);
|
||||
|
||||
}
|
@ -20,6 +20,7 @@ import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.capability.CapabilityServiceImplementation;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.extension.ExtensionService;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
import com.djrapitops.plan.query.QueryServiceImplementation;
|
||||
@ -28,6 +29,7 @@ import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.export.ExportSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.importing.ImportSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.system.locale.LocaleSystem;
|
||||
@ -35,6 +37,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.ConfigSystem;
|
||||
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.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -119,6 +122,16 @@ public class PlanSystem implements SubSystem {
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public static String getMainAddress(WebServer webServer, DBSystem dbSystem) {
|
||||
return dbSystem.getDatabase().query(ServerQueries.fetchProxyServerInformation())
|
||||
.map(Server::getWebAddress)
|
||||
.orElse(webServer.getAccessAddress());
|
||||
}
|
||||
|
||||
public String getMainAddress() {
|
||||
return PlanSystem.getMainAddress(webServerSystem.getWebServer(), databaseSystem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
CapabilityServiceImplementation.initialize();
|
||||
|
@ -16,8 +16,10 @@
|
||||
*/
|
||||
package com.djrapitops.plan.system.export;
|
||||
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
@ -35,31 +37,34 @@ import javax.inject.Singleton;
|
||||
public class ExportSystem implements SubSystem {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final Processing processing;
|
||||
private final HtmlExport htmlExport;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
|
||||
@Inject
|
||||
public ExportSystem(
|
||||
PlanConfig config,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
Processing processing,
|
||||
HtmlExport htmlExport,
|
||||
ConnectionSystem connectionSystem
|
||||
HtmlExport htmlExport
|
||||
) {
|
||||
this.config = config;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.processing = processing;
|
||||
this.htmlExport = htmlExport;
|
||||
this.connectionSystem = connectionSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
if (serverInfo.getServer().isNotProxy() && connectionSystem.isServerAvailable()) {
|
||||
Database database = dbSystem.getDatabase();
|
||||
boolean hasProxy = database.query(ServerQueries.fetchProxyServerInformation()).isPresent();
|
||||
if (serverInfo.getServer().isNotProxy() && hasProxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.isTrue(ExportSettings.JS_AND_CSS)) {
|
||||
processing.submitNonCritical(htmlExport::exportJs);
|
||||
processing.submitNonCritical(htmlExport::exportCss);
|
||||
|
@ -19,12 +19,12 @@ package com.djrapitops.plan.system.export;
|
||||
import com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.container.BaseUser;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.BaseUserQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.UserIdentifierQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.json.JSONFactory;
|
||||
@ -63,7 +63,6 @@ public class HtmlExport extends SpecificExport {
|
||||
private final PlanFiles files;
|
||||
private final DBSystem dbSystem;
|
||||
private final PageFactory pageFactory;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
@ -75,7 +74,6 @@ public class HtmlExport extends SpecificExport {
|
||||
PageFactory pageFactory,
|
||||
JSONFactory jsonFactory,
|
||||
ServerInfo serverInfo,
|
||||
ConnectionSystem connectionSystem,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(files, jsonFactory, serverInfo);
|
||||
@ -84,7 +82,6 @@ public class HtmlExport extends SpecificExport {
|
||||
this.files = files;
|
||||
this.dbSystem = dbSystem;
|
||||
this.pageFactory = pageFactory;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@ -94,10 +91,12 @@ public class HtmlExport extends SpecificExport {
|
||||
}
|
||||
|
||||
public void exportServer(UUID serverUUID) {
|
||||
if (serverInfo.getServer().isNotProxy() && connectionSystem.isServerAvailable()) {
|
||||
Database database = dbSystem.getDatabase();
|
||||
boolean hasProxy = database.query(ServerQueries.fetchProxyServerInformation()).isPresent();
|
||||
if (serverInfo.getServer().isNotProxy() && hasProxy) {
|
||||
return;
|
||||
}
|
||||
dbSystem.getDatabase().query(ServerQueries.fetchServerMatchingIdentifier(serverUUID))
|
||||
database.query(ServerQueries.fetchServerMatchingIdentifier(serverUUID))
|
||||
.map(Server::getName)
|
||||
.ifPresent(serverName -> {
|
||||
try {
|
||||
@ -123,11 +122,13 @@ public class HtmlExport extends SpecificExport {
|
||||
}
|
||||
|
||||
public void exportCachedPlayerPage(UUID playerUUID) {
|
||||
if (serverInfo.getServer().isNotProxy() && connectionSystem.isServerAvailable()) {
|
||||
Database database = dbSystem.getDatabase();
|
||||
boolean hasProxy = database.query(ServerQueries.fetchProxyServerInformation()).isPresent();
|
||||
if (serverInfo.getServer().isNotProxy() && hasProxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
dbSystem.getDatabase().query(UserIdentifierQueries.fetchPlayerNameOf(playerUUID))
|
||||
database.query(UserIdentifierQueries.fetchPlayerNameOf(playerUUID))
|
||||
.ifPresent(playerName -> {
|
||||
try {
|
||||
exportAvailablePlayerPage(playerUUID, playerName);
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
|
||||
/**
|
||||
* ConnectionSystem manages proxy server status.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @deprecated Usage should be replaced with Database query {@link ServerQueries#fetchProxyServerInformation()}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ConnectionSystem {
|
||||
|
||||
protected final ServerInfo serverInfo;
|
||||
|
||||
public ConnectionSystem(
|
||||
ServerInfo serverInfo
|
||||
) {
|
||||
this.serverInfo = serverInfo;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public abstract boolean isServerAvailable();
|
||||
|
||||
@Deprecated
|
||||
public abstract String getMainAddress();
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.webserver.WebServer;
|
||||
import dagger.Lazy;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* ConnectionSystem for proxy servers.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ProxyConnectionSystem extends ConnectionSystem {
|
||||
|
||||
private final Lazy<WebServer> webServer;
|
||||
|
||||
@Inject
|
||||
public ProxyConnectionSystem(
|
||||
Lazy<WebServer> webServer,
|
||||
ServerInfo serverInfo
|
||||
) {
|
||||
super(serverInfo);
|
||||
this.webServer = webServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainAddress() {
|
||||
return webServer.get().getAccessAddress();
|
||||
}
|
||||
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.info.connection;
|
||||
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Connection system for Bukkit servers.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class ServerConnectionSystem extends ConnectionSystem {
|
||||
|
||||
private final Processing processing;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private long latestServerMapRefresh;
|
||||
|
||||
private Server mainServer;
|
||||
|
||||
@Inject
|
||||
public ServerConnectionSystem(
|
||||
Processing processing,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo
|
||||
) {
|
||||
super(serverInfo);
|
||||
this.processing = processing;
|
||||
this.dbSystem = dbSystem;
|
||||
latestServerMapRefresh = 0;
|
||||
}
|
||||
|
||||
private void refreshServerMap() {
|
||||
processing.submitNonCritical(() -> {
|
||||
if (latestServerMapRefresh < System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(15L)) {
|
||||
|
||||
Database database = dbSystem.getDatabase();
|
||||
Map<UUID, Server> servers = database.query(ServerQueries.fetchPlanServerInformation());
|
||||
Optional<Server> proxy = servers.values().stream()
|
||||
.filter(Server::isProxy)
|
||||
.findFirst();
|
||||
mainServer = proxy.orElse(null);
|
||||
|
||||
proxy.ifPresent(proxyServer -> servers.remove(proxyServer.getUuid()));
|
||||
latestServerMapRefresh = System.currentTimeMillis();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerAvailable() {
|
||||
refreshServerMap();
|
||||
return mainServer != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainAddress() {
|
||||
refreshServerMap();
|
||||
return isServerAvailable() ? mainServer.getWebAddress() : serverInfo.getServer().getWebAddress();
|
||||
|
||||
}
|
||||
}
|
@ -172,9 +172,10 @@ public class PlayerJSONParser {
|
||||
int worstPing = ping.max();
|
||||
int bestPing = ping.min();
|
||||
|
||||
info.put("average_ping", averagePing != -1.0 ? decimals.apply(averagePing) + " ms" : "Unavailable");
|
||||
info.put("worst_ping", worstPing != -1.0 ? worstPing + " ms" : "Unavailable");
|
||||
info.put("best_ping", bestPing != -1.0 ? bestPing + " ms" : "Unavailable");
|
||||
String unavailable = "Unavailable";
|
||||
info.put("average_ping", averagePing != -1.0 ? decimals.apply(averagePing) + " ms" : unavailable);
|
||||
info.put("worst_ping", worstPing != -1.0 ? worstPing + " ms" : unavailable);
|
||||
info.put("best_ping", bestPing != -1.0 ? bestPing + " ms" : unavailable);
|
||||
info.put("registered", player.getValue(PlayerKeys.REGISTERED).map(year).orElse("-"));
|
||||
info.put("last_seen", player.getValue(PlayerKeys.LAST_SEEN).map(year).orElse("-"));
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class ResponseHandler extends TreePageHandler {
|
||||
public Response getResponse(Request request) {
|
||||
try {
|
||||
return tryToGetResponse(request);
|
||||
} catch (NoServersException | NotFoundException e) {
|
||||
} catch (NotFoundException e) {
|
||||
return responseFactory.notFound404(e.getMessage());
|
||||
} catch (WebUserAuthException e) {
|
||||
return responseFactory.basicAuthFail(e);
|
||||
|
@ -57,4 +57,5 @@ public class WebServerSystem implements SubSystem {
|
||||
public WebServer getWebServer() {
|
||||
return webServer;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,11 +18,9 @@ package com.djrapitops.plan.system.webserver.pages;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.ForbiddenException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.data.WebUser;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.PlayerFetchQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.webserver.Request;
|
||||
import com.djrapitops.plan.system.webserver.RequestTarget;
|
||||
@ -67,37 +65,22 @@ public class PlayerPageHandler implements PageHandler {
|
||||
}
|
||||
|
||||
String playerName = target.get(0);
|
||||
UUID uuid = uuidUtility.getUUIDOf(playerName);
|
||||
UUID playerUUID = uuidUtility.getUUIDOf(playerName);
|
||||
|
||||
boolean raw = target.size() >= 2 && target.get(1).equalsIgnoreCase("raw");
|
||||
|
||||
if (uuid == null) {
|
||||
if (playerUUID == null) {
|
||||
return responseFactory.uuidNotFound404();
|
||||
}
|
||||
try {
|
||||
Database.State dbState = dbSystem.getDatabase().getState();
|
||||
if (dbState != Database.State.OPEN) {
|
||||
throw new ForbiddenException("Database is " + dbState.name() + " - Please try again later. You can check database status with /plan info");
|
||||
}
|
||||
// TODO Move this Database dependency to PlayerPage generation in PageFactory instead.
|
||||
if (dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(uuid))) {
|
||||
if (raw) {
|
||||
return ResponseCache.loadResponse(PageId.RAW_PLAYER.of(uuid), () -> responseFactory.rawPlayerPageResponse(uuid));
|
||||
}
|
||||
return playerResponseOrNotFound(uuid);
|
||||
} else {
|
||||
return responseFactory.playerNotFound404();
|
||||
}
|
||||
} catch (NoServersException e) {
|
||||
ResponseCache.loadResponse(PageId.PLAYER.of(uuid), () -> responseFactory.notFound404(e.getMessage()));
|
||||
Database.State dbState = dbSystem.getDatabase().getState();
|
||||
if (dbState != Database.State.OPEN) {
|
||||
throw new ForbiddenException("Database is " + dbState.name() + " - Please try again later. You can check database status with /plan info");
|
||||
}
|
||||
return responseFactory.serverNotFound404();
|
||||
}
|
||||
|
||||
private Response playerResponseOrNotFound(UUID playerUUID) throws WebException {
|
||||
Response response = ResponseCache.loadResponse(PageId.PLAYER.of(playerUUID),
|
||||
if (raw) {
|
||||
return ResponseCache.loadResponse(PageId.RAW_PLAYER.of(playerUUID), () -> responseFactory.rawPlayerPageResponse(playerUUID));
|
||||
}
|
||||
return ResponseCache.loadResponse(PageId.PLAYER.of(playerUUID),
|
||||
() -> responseFactory.playerPageResponse(playerUUID));
|
||||
return response != null ? response : responseFactory.playerNotFound404();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,7 +22,6 @@ import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.file.FileResource;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
@ -55,7 +54,6 @@ public class DebugPage implements Page {
|
||||
|
||||
private final Database database;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final CombineDebugLogger debugLogger;
|
||||
private final Timings timings;
|
||||
private final ErrorHandler errorHandler;
|
||||
@ -66,7 +64,6 @@ public class DebugPage implements Page {
|
||||
DebugPage(
|
||||
Database database,
|
||||
ServerInfo serverInfo,
|
||||
ConnectionSystem connectionSystem,
|
||||
Formatters formatters,
|
||||
DebugLogger debugLogger,
|
||||
Timings timings,
|
||||
@ -74,7 +71,6 @@ public class DebugPage implements Page {
|
||||
) {
|
||||
this.database = database;
|
||||
this.serverInfo = serverInfo;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.debugLogger = (CombineDebugLogger) debugLogger;
|
||||
this.timings = timings;
|
||||
this.errorHandler = errorHandler;
|
||||
|
@ -27,7 +27,6 @@ import com.djrapitops.plan.extension.implementation.results.player.ExtensionPlay
|
||||
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
@ -35,8 +34,6 @@ import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.structure.Accordions;
|
||||
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
@ -62,10 +59,7 @@ public class PageFactory {
|
||||
private final Lazy<Theme> theme;
|
||||
private final Lazy<DBSystem> dbSystem;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final Lazy<ConnectionSystem> connectionSystem;
|
||||
private final Lazy<Graphs> graphs;
|
||||
private final Lazy<HtmlTables> tables;
|
||||
private final Lazy<Accordions> accordions;
|
||||
private final Lazy<Formatters> formatters;
|
||||
private final Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator;
|
||||
private final Lazy<HookHandler> hookHandler;
|
||||
@ -81,10 +75,7 @@ public class PageFactory {
|
||||
Lazy<Theme> theme,
|
||||
Lazy<DBSystem> dbSystem,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
Lazy<ConnectionSystem> connectionSystem,
|
||||
Lazy<Graphs> graphs,
|
||||
Lazy<HtmlTables> tables,
|
||||
Lazy<Accordions> accordions,
|
||||
Lazy<Formatters> formatters,
|
||||
Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator,
|
||||
Lazy<HookHandler> hookHandler,
|
||||
@ -98,10 +89,7 @@ public class PageFactory {
|
||||
this.theme = theme;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.graphs = graphs;
|
||||
this.tables = tables;
|
||||
this.accordions = accordions;
|
||||
this.formatters = formatters;
|
||||
this.analysisPluginsTabContentCreator = analysisPluginsTabContentCreator;
|
||||
this.hookHandler = hookHandler;
|
||||
@ -112,7 +100,7 @@ public class PageFactory {
|
||||
|
||||
public DebugPage debugPage() {
|
||||
return new DebugPage(
|
||||
dbSystem.get().getDatabase(), serverInfo.get(), connectionSystem.get(), formatters.get(),
|
||||
dbSystem.get().getDatabase(), serverInfo.get(), formatters.get(),
|
||||
debugLogger.get(), timings.get(), errorHandler.get()
|
||||
);
|
||||
}
|
||||
@ -129,7 +117,6 @@ public class PageFactory {
|
||||
server,
|
||||
config.get(),
|
||||
theme.get(),
|
||||
connectionSystem.get(),
|
||||
versionCheckSystem.get(),
|
||||
fileSystem.get(),
|
||||
formatters.get()
|
||||
|
@ -76,11 +76,10 @@ public class PlayerPage implements Page {
|
||||
|
||||
@Override
|
||||
public String toHtml() throws ParseException {
|
||||
if (!player.getValue(PlayerKeys.REGISTERED).isPresent()) {
|
||||
throw new IllegalStateException("Player is not registered");
|
||||
}
|
||||
try {
|
||||
if (!player.getValue(PlayerKeys.REGISTERED).isPresent()) {
|
||||
throw new IllegalStateException("Player is not registered");
|
||||
}
|
||||
|
||||
return parse(player);
|
||||
} catch (Exception e) {
|
||||
throw new ParseException(e);
|
||||
|
@ -21,7 +21,6 @@ import com.djrapitops.plan.data.store.containers.DataContainer;
|
||||
import com.djrapitops.plan.data.store.containers.RawDataContainer;
|
||||
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DisplaySettings;
|
||||
@ -45,7 +44,6 @@ public class ServerPage implements Page {
|
||||
private final Server server;
|
||||
private PlanConfig config;
|
||||
private Theme theme;
|
||||
private final ConnectionSystem connectionSystem;
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
private final PlanFiles files;
|
||||
private Formatters formatters;
|
||||
@ -54,7 +52,6 @@ public class ServerPage implements Page {
|
||||
Server server,
|
||||
PlanConfig config,
|
||||
Theme theme,
|
||||
ConnectionSystem connectionSystem,
|
||||
VersionCheckSystem versionCheckSystem,
|
||||
PlanFiles files,
|
||||
Formatters formatters
|
||||
@ -62,7 +59,6 @@ public class ServerPage implements Page {
|
||||
this.server = server;
|
||||
this.config = config;
|
||||
this.theme = theme;
|
||||
this.connectionSystem = connectionSystem;
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
this.files = files;
|
||||
this.formatters = formatters;
|
||||
@ -113,7 +109,7 @@ public class ServerPage implements Page {
|
||||
AVG_PING_COLOR, MAX_PING_COLOR, MIN_PING_COLOR
|
||||
);
|
||||
|
||||
if (connectionSystem.isServerAvailable()) {
|
||||
if (server.isProxy()) {
|
||||
placeholderReplacer.put("backButton", "<li><a title=\"to Network page\" href=\"/network\"><i class=\"material-icons\">arrow_back</i><i class=\"material-icons\">cloud</i></a></li>");
|
||||
} else {
|
||||
placeholderReplacer.put("backButton", "");
|
||||
|
Loading…
Reference in New Issue
Block a user