mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 15:44:49 +08:00
Moved registerWebAPI to WebServer class
This commit is contained in:
parent
47f500c3c3
commit
66b1df657e
@ -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<Plan> {
|
||||
|
||||
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<Plan> {
|
||||
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.
|
||||
* <p>
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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<String, String> 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");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user