From 66b1df657e4a5cc1c1509698960e99a628ebfbd9 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 25 Aug 2017 09:38:55 +0300 Subject: [PATCH] Moved registerWebAPI to WebServer class --- .../main/java/com/djrapitops/plan/Plan.java | 15 ------- .../plan/systems/webserver/WebServer.java | 13 ++++++ .../api/bukkit/InspectionWebAPI.java | 45 ------------------- 3 files changed, 13 insertions(+), 60 deletions(-) delete mode 100644 Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 833770319..ed372abcc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -44,13 +44,7 @@ import main.java.com.djrapitops.plan.systems.processing.Processor; import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue; import main.java.com.djrapitops.plan.systems.tasks.PeriodicDBCommitTask; import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer; -import main.java.com.djrapitops.plan.systems.webapi.WebAPIManager; -import main.java.com.djrapitops.plan.systems.webapi.bukkit.AnalyticsWebAPI; -import main.java.com.djrapitops.plan.systems.webapi.bukkit.AnalyzeWebAPI; -import main.java.com.djrapitops.plan.systems.webapi.bukkit.ConfigureWebAPI; -import main.java.com.djrapitops.plan.systems.webapi.bukkit.InspectWebAPI; import main.java.com.djrapitops.plan.systems.webserver.WebServer; -import main.java.com.djrapitops.plan.ui.webserver.api.bukkit.InspectionWebAPI; import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.Check; import org.apache.logging.log4j.LogManager; @@ -161,7 +155,6 @@ public class Plan extends BukkitPlugin { Benchmark.start("WebServer Initialization"); webServer = new WebServer(this); - registerWebAPIs(); // TODO Move to WebServer class webServer.initServer(); if (!webServer.isEnabled()) { @@ -303,14 +296,6 @@ public class Plan extends BukkitPlugin { Benchmark.stop("Enable", "Register Listeners"); } - private void registerWebAPIs() { - WebAPIManager.registerNewAPI("analytics", new AnalyticsWebAPI()); - WebAPIManager.registerNewAPI("analyze", new AnalyzeWebAPI()); - WebAPIManager.registerNewAPI("configure", new ConfigureWebAPI()); - WebAPIManager.registerNewAPI("inspection", new InspectionWebAPI()); - WebAPIManager.registerNewAPI("inspect", new InspectWebAPI()); - } - /** * Initializes the database according to settings in the config. *

diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java index 7dd05df27..094e59ef2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/WebServer.java @@ -13,6 +13,10 @@ import main.java.com.djrapitops.plan.systems.cache.PageCache; import main.java.com.djrapitops.plan.systems.info.InformationManager; import main.java.com.djrapitops.plan.systems.webapi.WebAPI; import main.java.com.djrapitops.plan.systems.webapi.WebAPIManager; +import main.java.com.djrapitops.plan.systems.webapi.bukkit.AnalyticsWebAPI; +import main.java.com.djrapitops.plan.systems.webapi.bukkit.AnalyzeWebAPI; +import main.java.com.djrapitops.plan.systems.webapi.bukkit.ConfigureWebAPI; +import main.java.com.djrapitops.plan.systems.webapi.bukkit.InspectWebAPI; import main.java.com.djrapitops.plan.systems.webserver.response.*; import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse; import main.java.com.djrapitops.plan.systems.webserver.response.api.JsonResponse; @@ -60,12 +64,21 @@ public class WebServer { public WebServer(Plan plugin) { this.plugin = plugin; this.port = Settings.WEBSERVER_PORT.getNumber(); + + registerWebAPIs(); } public void setInfoManager(InformationManager infoManager) { this.infoManager = infoManager; } + private void registerWebAPIs() { + WebAPIManager.registerNewAPI("analytics", new AnalyticsWebAPI()); + WebAPIManager.registerNewAPI("analyze", new AnalyzeWebAPI()); + WebAPIManager.registerNewAPI("configure", new ConfigureWebAPI()); + WebAPIManager.registerNewAPI("inspect", new InspectWebAPI()); + } + /** * Starts up the Webserver in a Asynchronous thread. */ diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java deleted file mode 100644 index 6059696bb..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java +++ /dev/null @@ -1,45 +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 main.java.com.djrapitops.plan.ui.webserver.api.bukkit; - -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.systems.webapi.WebAPI; -import main.java.com.djrapitops.plan.systems.webserver.response.Response; -import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse; - -import java.util.Map; - -/** - * @author Fuzzlemann - */ -@Deprecated // UserData objects should not be sent between servers. -public class InspectionWebAPI implements WebAPI { - @Override - public Response onResponse(Plan plan, Map variables) { -// String playerString = variables.get("player"); -// -// if (playerString == null) { -// String error = "Player String not included"; -// return PageCache.loadPage(error, () -> new BadRequestResponse(error)); -// } -// -// UUID uuid = UUIDUtility.getUUIDOf(playerString); -// -// if (uuid == null) { -// String error = "UUID not found"; -// return PageCache.loadPage(error, () -> new BadRequestResponse(error)); -// } -// -// UserInfo userInfo = plan.getInspectCache().getFromCache(uuid); -// -// if (userInfo == null) { -// String error = "User not cached"; -// return PageCache.loadPage(error, () -> new BadRequestResponse(error)); -// } -// -// return PageCache.loadPage("inspectionJson: " + uuid, () -> new JsonResponse(plan.getInspectCache().getFromCache(uuid))); - return new BadRequestResponse("Not implemented"); - } -}