mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 03:27:37 +01:00
More BugFixing:
- Fixed error when viewing inspect page with 0 bukkit servers - Fixed html caching with PostHtmlWebAPI - Fixed css serving on API mode WebServer - Fixed UUIDFetcher NoClassDefFoundError on Bungee Notable bugs that need fixing: - PostHtmlWebAPI html is cut short because of & or = signs
This commit is contained in:
parent
ccc562913c
commit
ad23d1e60d
@ -102,10 +102,12 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
List<Processor> processors = processingQueue.stopAndReturnLeftovers();
|
if (processingQueue != null) {
|
||||||
Log.info("Processing unprocessed processors. (" + processors.size() + ")");
|
List<Processor> processors = processingQueue.stopAndReturnLeftovers();
|
||||||
for (Processor processor : processors) {
|
Log.info("Processing unprocessed processors. (" + processors.size() + ")");
|
||||||
processor.process();
|
for (Processor processor : processors) {
|
||||||
|
processor.process();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class BukkitInformationManager extends InformationManager {
|
|||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PageCache.isCached("analysisPage");
|
return PageCache.isCached("analysisPage:" + serverUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebAPIManager getWebAPI() {
|
private WebAPIManager getWebAPI() {
|
||||||
@ -208,7 +208,7 @@ public class BukkitInformationManager extends InformationManager {
|
|||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PageCache.cachePage("analysisPage", () -> new AnalysisPageResponse(this));
|
PageCache.cachePage("analysisPage:" + Plan.getServerUUID(), () -> new AnalysisPageResponse(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ public class BukkitInformationManager extends InformationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean attemptConnection() {
|
public boolean attemptConnection() {
|
||||||
Log.info("Attempting Bungee Connection.. ("+webServerAddress+")");
|
Log.info("Attempting Bungee Connection.. (" + webServerAddress + ")");
|
||||||
PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
|
PingWebAPI api = getWebAPI().getAPI(PingWebAPI.class);
|
||||||
try {
|
try {
|
||||||
api.sendRequest(webServerAddress);
|
api.sendRequest(webServerAddress);
|
||||||
|
@ -12,6 +12,9 @@ import main.java.com.djrapitops.plan.api.exceptions.WebAPINotFoundException;
|
|||||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||||
import main.java.com.djrapitops.plan.systems.info.server.ServerInfo;
|
import main.java.com.djrapitops.plan.systems.info.server.ServerInfo;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||||
|
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
|
||||||
|
import main.java.com.djrapitops.plan.systems.webserver.response.NotFoundResponse;
|
||||||
|
import main.java.com.djrapitops.plan.systems.webserver.response.Response;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager;
|
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.AnalyzeWebAPI;
|
import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.AnalyzeWebAPI;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebAPI;
|
import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebAPI;
|
||||||
@ -111,7 +114,11 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bukkitServers.stream().findAny().get();
|
Optional<ServerInfo> bukkitServer = bukkitServers.stream().findAny();
|
||||||
|
if (bukkitServer.isPresent()) {
|
||||||
|
return bukkitServer.get();
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("No Bukkit servers online");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -143,12 +150,17 @@ public class BungeeInformationManager extends InformationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerHtml(UUID uuid) {
|
public String getPlayerHtml(UUID uuid) {
|
||||||
return null;
|
Response response = PageCache.loadPage("inspectPage:" + uuid,
|
||||||
|
() -> new NotFoundResponse("No Bukkit Servers were online to process this request"));
|
||||||
|
if (response instanceof InspectPageResponse) {
|
||||||
|
((InspectPageResponse) response).setInspectPagePluginsTab(pluginsTabContent.get(uuid));
|
||||||
|
}
|
||||||
|
return response.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAnalysisHtml() {
|
public String getAnalysisHtml() {
|
||||||
return null;
|
return new NotFoundResponse("Network page not yet created").getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,8 +83,9 @@ public class BungeeServerInfoManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Log.info("Attempting to connect to Bukkit server.. (" + server.getWebAddress() + ")");
|
String webAddress = server.getWebAddress();
|
||||||
plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(server.getWebAddress());
|
Log.info("Attempting to connect to Bukkit server.. (" + webAddress + ")");
|
||||||
|
plugin.getWebServer().getWebAPI().getAPI(PingWebAPI.class).sendRequest(webAddress);
|
||||||
connectedToServer(server);
|
connectedToServer(server);
|
||||||
} catch (WebAPIException e) {
|
} catch (WebAPIException e) {
|
||||||
serverHasGoneOffline(server.getUuid());
|
serverHasGoneOffline(server.getUuid());
|
||||||
@ -92,7 +93,7 @@ public class BungeeServerInfoManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void connectedToServer(ServerInfo server) {
|
public void connectedToServer(ServerInfo server) {
|
||||||
Log.info("Connection to Bukkit (" + server.getWebAddress() + ") succeeded.");
|
Log.info("Connection to Bukkit (" + server.getWebAddress() + ") OK");
|
||||||
bukkitServers.put(server.getUuid(), server);
|
bukkitServers.put(server.getUuid(), server);
|
||||||
onlineServers.add(server.getUuid());
|
onlineServers.add(server.getUuid());
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
package main.java.com.djrapitops.plan.systems.webserver;
|
package main.java.com.djrapitops.plan.systems.webserver;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.response.ForbiddenResponse;
|
import main.java.com.djrapitops.plan.systems.webserver.response.*;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.response.NotFoundResponse;
|
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.response.Response;
|
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse;
|
import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI;
|
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager;
|
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager;
|
||||||
@ -42,6 +40,13 @@ public class APIResponseHandler {
|
|||||||
String target = request.getTarget();
|
String target = request.getTarget();
|
||||||
String[] args = target.split("/");
|
String[] args = target.split("/");
|
||||||
|
|
||||||
|
if ("/favicon.ico".equals(target)) {
|
||||||
|
return PageCache.loadPage("Redirect: favicon", () -> new RedirectResponse("https://puu.sh/tK0KL/6aa2ba141b.ico"));
|
||||||
|
}
|
||||||
|
if (target.endsWith(".css")) {
|
||||||
|
return PageCache.loadPage(target + "css", () -> new CSSResponse("main.css"));
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length < 2 || !"api".equals(args[1])) {
|
if (args.length < 2 || !"api".equals(args[1])) {
|
||||||
String address = MiscUtils.getIPlan().getInfoManager().getWebServerAddress() + target;
|
String address = MiscUtils.getIPlan().getInfoManager().getWebServerAddress() + target;
|
||||||
String link = Html.LINK.parse(address, address);
|
String link = Html.LINK.parse(address, address);
|
||||||
@ -85,9 +90,6 @@ public class APIResponseHandler {
|
|||||||
return PageCache.loadPage(error, () -> new BadRequestResponse(error));
|
return PageCache.loadPage(error, () -> new BadRequestResponse(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.debug(request.toString());
|
|
||||||
Log.debug(requestBody);
|
|
||||||
|
|
||||||
Response response = api.processRequest(MiscUtils.getIPlan(), variables);
|
Response response = api.processRequest(MiscUtils.getIPlan(), variables);
|
||||||
|
|
||||||
Log.debug(response.toString());
|
Log.debug(response.toString());
|
||||||
|
@ -88,7 +88,7 @@ public class ResponseHandler extends APIResponseHandler {
|
|||||||
case "server":
|
case "server":
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
try {
|
try {
|
||||||
Optional<UUID> serverUUIDOptional = plugin.getDB().getServerTable().getServerUUID(args[2]);
|
Optional<UUID> serverUUIDOptional = plugin.getDB().getServerTable().getServerUUID(args[2].replace("%20", " "));
|
||||||
if (serverUUIDOptional.isPresent()) {
|
if (serverUUIDOptional.isPresent()) {
|
||||||
serverUUID = serverUUIDOptional.get();
|
serverUUID = serverUUIDOptional.get();
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ public class ResponseHandler extends APIResponseHandler {
|
|||||||
PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
|
PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
return PageCache.loadPage("analysisPage", () -> new AnalysisPageResponse(plugin.getInfoManager()));
|
return PageCache.loadPage("analysisPage:" + serverUUID, () -> new AnalysisPageResponse(plugin.getInfoManager()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response playerResponse(String[] args) {
|
private Response playerResponse(String[] args) {
|
||||||
|
@ -89,9 +89,9 @@ public class WebServer {
|
|||||||
Log.infoColor("§eUser Authorization Disabled! (Not possible over http)");
|
Log.infoColor("§eUser Authorization Disabled! (Not possible over http)");
|
||||||
server = HttpServer.create(new InetSocketAddress(port), 10);
|
server = HttpServer.create(new InetSocketAddress(port), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
|
if (plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||||
server.createContext("/", new APIRequestHandler(getWebAPI()));
|
server.createContext("/", new APIRequestHandler(getWebAPI()));
|
||||||
|
Log.infoColor("§aWebServer Running in WebAPI-only Mode");
|
||||||
} else {
|
} else {
|
||||||
server.createContext("/", new RequestHandler(plugin, this));
|
server.createContext("/", new RequestHandler(plugin, this));
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.systems.webserver.response;
|
|||||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import main.java.com.djrapitops.plan.systems.webserver.theme.Theme;
|
import main.java.com.djrapitops.plan.systems.webserver.theme.Theme;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,4 +34,8 @@ public class InspectPageResponse extends Response {
|
|||||||
}
|
}
|
||||||
this.inspectPagePluginsTab = inspectPagePluginsTab;
|
this.inspectPagePluginsTab = inspectPagePluginsTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInspectPagePluginsTab(Map<UUID, String> uuidStringMap) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ public abstract class WebAPI {
|
|||||||
connection.setInstanceFollowRedirects(false);
|
connection.setInstanceFollowRedirects(false);
|
||||||
connection.setRequestMethod("POST");
|
connection.setRequestMethod("POST");
|
||||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
connection.setRequestProperty("charset", "ISO-8859-1");
|
connection.setRequestProperty("charset", "ISO-8859-1");
|
||||||
|
|
||||||
StringBuilder parameters = new StringBuilder();
|
StringBuilder parameters = new StringBuilder();
|
||||||
@ -98,10 +99,14 @@ public abstract class WebAPI {
|
|||||||
for (Map.Entry<String, String> entry : variables.entrySet()) {
|
for (Map.Entry<String, String> entry : variables.entrySet()) {
|
||||||
parameters.append("&").append(entry.getKey()).append("=").append(entry.getValue());
|
parameters.append("&").append(entry.getKey()).append("=").append(entry.getValue());
|
||||||
}
|
}
|
||||||
byte[] toSend = parameters.toString().getBytes();
|
String params = parameters.toString();
|
||||||
|
|
||||||
|
connection.setRequestProperty("Content-Length", Integer.toString(params.length()));
|
||||||
|
|
||||||
|
byte[] toSend = params.getBytes();
|
||||||
int length = toSend.length;
|
int length = toSend.length;
|
||||||
|
|
||||||
connection.setRequestProperty("Content-Length", Integer.toString(length));
|
// connection.setRequestProperty("Content-Length", Integer.toString(length));
|
||||||
|
|
||||||
connection.setUseCaches(false);
|
connection.setUseCaches(false);
|
||||||
Log.debug("Sending WebAPI Request: " + this.getClass().getSimpleName() + " to " + address);
|
Log.debug("Sending WebAPI Request: " + this.getClass().getSimpleName() + " to " + address);
|
||||||
|
@ -32,10 +32,10 @@ public class PostHtmlWebAPI extends WebAPI {
|
|||||||
switch (target) {
|
switch (target) {
|
||||||
case "inspectPage":
|
case "inspectPage":
|
||||||
String uuid = variables.get("uuid");
|
String uuid = variables.get("uuid");
|
||||||
PageCache.loadPage("inspectPage:" + uuid, () -> new InspectPageResponse(infoManager, UUID.fromString(uuid), html));
|
PageCache.cachePage("inspectPage:" + uuid, () -> new InspectPageResponse(infoManager, UUID.fromString(uuid), html));
|
||||||
break;
|
break;
|
||||||
case "analysisPage":
|
case "analysisPage":
|
||||||
PageCache.loadPage("analysisPage:" + variables.get("sender"), () -> new AnalysisPageResponse(html));
|
PageCache.cachePage("analysisPage:" + variables.get("sender"), () -> new AnalysisPageResponse(html));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return badRequest("Faulty Target");
|
return badRequest("Faulty Target");
|
||||||
|
@ -53,7 +53,7 @@ public class UUIDUtility {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
uuid = UUIDFetcher.getUUIDOf(playername);
|
uuid = UUIDFetcher.getUUIDOf(playername);
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception | NoClassDefFoundError ignored) {
|
||||||
/* Ignored */
|
/* Ignored */
|
||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
|
Loading…
Reference in New Issue
Block a user