Some parts to BungeeInformationManager

This commit is contained in:
Rsl1122 2017-09-16 19:03:33 +03:00
parent 116675f8a6
commit 8ffcd302df
2 changed files with 25 additions and 14 deletions

View File

@ -11,8 +11,9 @@ import main.java.com.djrapitops.plan.bungee.PlanBungee;
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.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.bungee.RequestPluginsTabWebAPI;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
@ -75,8 +76,9 @@ public class BungeeInformationManager extends InformationManager {
@Override @Override
public void cachePlayer(UUID uuid) { public void cachePlayer(UUID uuid) {
PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid)); // TODO Request Inspect from server where the player is online or any if offline
// TODO Player page plugin tab request // PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid));
getWebAPI().getAPI(RequestPluginsTabWebAPI.class).sendRequestsToBukkitServers(plugin, uuid);
} }
@Override @Override
@ -114,4 +116,9 @@ public class BungeeInformationManager extends InformationManager {
perServerPluginsTab.put(serverUUID, html); perServerPluginsTab.put(serverUUID, html);
pluginsTabContent.put(uuid, perServerPluginsTab); pluginsTabContent.put(uuid, perServerPluginsTab);
} }
private WebAPIManager getWebAPI() {
return plugin.getWebServer().getWebAPI();
}
} }

View File

@ -42,6 +42,21 @@ public class RequestPluginsTabWebAPI extends WebAPI {
} }
UUID uuid = UUID.fromString(uuidS); UUID uuid = UUID.fromString(uuidS);
sendRequestsToBukkitServers(plugin, uuid);
return PageCache.loadPage("success", SuccessResponse::new);
}
@Override
public void sendRequest(String address) throws WebAPIException {
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
}
public void sendRequest(String address, UUID uuid) throws WebAPIException {
addVariable("uuid", uuid.toString());
super.sendRequest(address);
}
public void sendRequestsToBukkitServers(IPlan plugin, UUID uuid) {
plugin.addToProcessQueue(new Processor<UUID>(uuid) { plugin.addToProcessQueue(new Processor<UUID>(uuid) {
@Override @Override
public void process() { public void process() {
@ -60,16 +75,5 @@ public class RequestPluginsTabWebAPI extends WebAPI {
} }
} }
}); });
return PageCache.loadPage("success", SuccessResponse::new);
}
@Override
public void sendRequest(String address) throws WebAPIException {
throw new IllegalStateException("Wrong method call for this WebAPI, call sendRequest(String, UUID, UUID) instead.");
}
public void sendRequest(String address, UUID uuid) throws WebAPIException {
addVariable("uuid", uuid.toString());
super.sendRequest(address);
} }
} }