Fixed Plugins tab for Inspect page

This commit is contained in:
Rsl1122 2018-01-28 13:51:28 +02:00
parent 1f0d74b127
commit da95ed2583
9 changed files with 21 additions and 46 deletions

View File

@ -75,12 +75,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
system = new BukkitSystem(this);
system.enable();
registerCommand("plan", new PlanCommand(this));
Benchmark.start("Hook to 3rd party plugins");
hookHandler = new HookHandler();
Benchmark.stop("Enable", "Hook to 3rd party plugins");
ImporterManager.registerImporter(new OfflinePlayerImporter());
BStats bStats = new BStats(this);
@ -91,10 +85,11 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
Log.logDebug("Enable");
Log.info(Locale.get(Msg.ENABLED).toString());
} catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly.");
Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload");
Log.toLog(this.getClass().getName(), e);
onDisable();
}
registerCommand("plan", new PlanCommand(this));
}
@Override

View File

@ -50,6 +50,8 @@ public abstract class PlanSystem implements SubSystem {
protected ServerInfo serverInfo;
protected HookHandler hookHandler;
// Not a SubSystem.
protected PlanAPI planAPI;
public PlanSystem() {
@ -86,7 +88,8 @@ public abstract class PlanSystem implements SubSystem {
processingQueue,
cacheSystem,
listenerSystem,
taskSystem
taskSystem,
hookHandler
};
for (SubSystem system : systems) {
system.enable();
@ -96,6 +99,7 @@ public abstract class PlanSystem implements SubSystem {
@Override
public void disable() {
SubSystem[] systems = new SubSystem[]{
hookHandler,
cacheSystem,
listenerSystem,
processingQueue,

View File

@ -87,7 +87,7 @@ public abstract class Response {
exchange.sendResponseHeaders(getCode(), 0);
try (GZIPOutputStream out = new GZIPOutputStream(exchange.getResponseBody());
ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes())) {
ByteArrayInputStream bis = new ByteArrayInputStream(getContent().getBytes())) {
byte[] buffer = new byte[2048];
int count;
while ((count = bis.read(buffer)) != -1) {

View File

@ -1,7 +1,6 @@
package com.djrapitops.plan.system.webserver.response.cache;
import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse;
import java.util.HashMap;
import java.util.Map;
@ -63,22 +62,6 @@ public class ResponseCache {
return cache.get(identifier);
}
/**
* Returns a copy some responses
* <p>
* Currently supported copyable responses: InspectPageResponse
*
* @param identifier The identifier of the page
* @return Copied Response of loadResponse, so that cache contents are not changed.
*/
public static Response copyResponse(String identifier, ResponseLoader loader) {
Response response = loadResponse(identifier, loader);
if (response instanceof InspectPageResponse) {
return InspectPageResponse.copyOf((InspectPageResponse) response);
}
return response;
}
/**
* Puts the page into the page cache.
* <p>

View File

@ -33,7 +33,7 @@ public class AnalysisPageResponse extends Response {
public static String getRefreshingHtml() {
ErrorResponse refreshPage = new ErrorResponse();
refreshPage.setTitle("Analysis is being refreshed..");
refreshPage.setParagraph("<meta http-equiv=\"refresh\" content=\"25\" /><i class=\"fa fa-refresh fa-spin\" aria-hidden=\"true\"></i> Analysis is being run, refresh the page after a few seconds.. (F5)");
refreshPage.setParagraph("<meta http-equiv=\"refresh\" content=\"5\" /><i class=\"fa fa-refresh fa-spin\" aria-hidden=\"true\"></i> Analysis is being run, refresh the page after a few seconds.. (F5)");
refreshPage.replacePlaceholders();
return refreshPage.getContent();
}

View File

@ -18,34 +18,27 @@ import java.util.UUID;
public class InspectPageResponse extends Response {
private final UUID uuid;
private InspectPagePluginsContent pluginsTab;
public InspectPageResponse(UUID uuid, String html) {
this.uuid = uuid;
super.setHeader("HTTP/1.1 200 OK");
super.setContent(Theme.replaceColors(html));
pluginsTab = (InspectPagePluginsContent)
ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid), InspectPagePluginsContent::new);
}
private InspectPageResponse(InspectPageResponse response) {
this.uuid = response.uuid;
super.setHeader(response.getHeader());
super.setContent(response.getContent());
}
public static InspectPageResponse copyOf(InspectPageResponse response) {
return new InspectPageResponse(response);
this.uuid = uuid;
}
@Override
public String getContent() {
Map<String, String> replaceMap = new HashMap<>();
String[] inspectPagePluginsTab = pluginsTab.getContents();
InspectPagePluginsContent pluginsTab = (InspectPagePluginsContent)
ResponseCache.loadResponse(PageId.PLAYER_PLUGINS_TAB.of(uuid));
String[] inspectPagePluginsTab = pluginsTab != null ? pluginsTab.getContents() : getCalculating();
replaceMap.put("navPluginsTabs", inspectPagePluginsTab[0]);
replaceMap.put("pluginsTabs", inspectPagePluginsTab[1]);
return StrSubstitutor.replace(super.getContent(), replaceMap);
}
private String[] getCalculating() {
return new String[]{"<meta http-equiv=\"refresh\" content=\"5\" /><li><a><i class=\"fa fa-spin fa-refresh\"></i> Calculating...</a></li>", ""};
}
}

View File

@ -32,7 +32,7 @@ public class InspectPagePluginsContent extends Response {
}
public InspectPagePluginsContent(UUID serverUUID, String nav, String html) {
this();
pluginsTab = new HashMap<>();
addTab(serverUUID, nav, html);
}
@ -42,7 +42,7 @@ public class InspectPagePluginsContent extends Response {
String serverName = ServerInfo.getServerName();
String actualServerName = serverName.equals("Plan") ? "Server " + ServerInfo.getServerID() : serverName;
if (containers.isEmpty()) {
new InspectPagePluginsContent(playerUUID, "<li><a>" + actualServerName + "(No Data)</a></li>", "");
return new InspectPagePluginsContent(playerUUID, "<li><a>" + actualServerName + " (No Data)</a></li>", "");
}
String nav = "<li><a class=\"nav-button\" href=\"javascript:void(0)\">" + actualServerName + "</a></li>";

View File

@ -1,4 +1,4 @@
name: Plan
author: Rsl1122
main: com.djrapitops.plan.PlanBungee
version: 4.1.4
version: 4.1.5-DEV

View File

@ -1,7 +1,7 @@
name: Plan
author: Rsl1122
main: com.djrapitops.plan.Plan
version: 4.1.4
version: 4.1.5-DEV
softdepend:
- EssentialsX
- Towny