Fixed Inspect & Analysis request handling on Bungee

This commit is contained in:
Rsl1122 2018-01-28 15:09:31 +02:00
parent a55b17246a
commit 58f2d7f02c
5 changed files with 17 additions and 3 deletions

View File

@ -54,6 +54,8 @@ public class BungeeConnectionSystem extends ConnectionSystem {
Optional<UUID> serverUUID = getServerWherePlayerIsOnline((GenerateInspectPageRequest) infoRequest);
if (serverUUID.isPresent()) {
server = bukkitServers.getOrDefault(serverUUID.get(), getOneBukkitServer());
} else {
server = getOneBukkitServer();
}
}
if (server == null) {

View File

@ -8,6 +8,7 @@ import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException;
import com.djrapitops.plan.api.exceptions.connection.WebException;
import com.djrapitops.plan.api.exceptions.database.DBException;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processor;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
@ -18,7 +19,9 @@ import com.djrapitops.plan.system.webserver.response.pages.InspectPageResponse;
import com.djrapitops.plan.utilities.Base64Util;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import com.djrapitops.plugin.utilities.Verify;
import org.apache.commons.lang3.text.StrSubstitutor;
import java.util.Collections;
import java.util.Map;
import java.util.UUID;
@ -71,7 +74,9 @@ public class CacheInspectPageRequest implements CacheRequest {
UUID uuid = entry.getKey();
String html = Base64Util.decode(entry.getValue());
cache(export, uuid, html);
Map<String, String> replace = Collections.singletonMap("networkName", ServerInfo.getServerName());
cache(export, uuid, StrSubstitutor.replace(html, replace));
}
} catch (DBException e) {
throw new TransferDatabaseException(e);

View File

@ -69,6 +69,7 @@ public class GenerateAnalysisPageRequest extends InfoRequestWithVariables implem
InfoSystem infoSystem = InfoSystem.getInstance();
infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, AnalysisPageResponse.getRefreshingHtml()));
infoSystem.sendRequest(new CacheAnalysisPageRequest(serverUUID, analyseAndGetHtml()));
infoSystem.updateNetworkPage();
}
@Override

View File

@ -1,11 +1,15 @@
package com.djrapitops.plan.system.webserver.response.pages;
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
import com.djrapitops.plan.api.exceptions.connection.WebException;
import com.djrapitops.plan.system.info.InfoSystem;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.processing.Processor;
import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.response.cache.PageId;
import com.djrapitops.plan.system.webserver.response.cache.ResponseCache;
import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse;
import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse;
import com.djrapitops.plugin.api.utility.log.Log;
import java.util.UUID;
@ -24,9 +28,11 @@ public class AnalysisPageResponse extends Response {
Processor.queue(() -> {
try {
InfoSystem.getInstance().generateAnalysisPage(serverUUID);
} catch (NoServersException e) {
ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new NotFoundResponse(e.getMessage()));
} catch (WebException e) {
// TODO Exception handling
Log.toLog(AnalysisPageResponse.class, e);
Log.toLog(AnalysisPageResponse.class.getName(), e);
}
});
return new AnalysisPageResponse(getRefreshingHtml());

View File

@ -93,7 +93,7 @@ public class DebugPageResponse extends ErrorResponse {
for (Server server : servers) {
content.append(server.getName()).append(" | ")
.append(server.getWebAddress()).append(" | ")
.append(server.getUuid()).append(" | ").append("<br>");
.append(server.getUuid()).append("<br>");
}
content.append("</pre>");