WebServer can now be disabled on Bukkit

This commit is contained in:
Rsl1122 2017-12-02 14:52:19 +02:00
parent 813b7a3f5c
commit c4e8b7d948
9 changed files with 214 additions and 200 deletions

View File

@ -1,21 +1,21 @@
/*
* Player Analytics Bukkit plugin for monitoring server activity.
* Copyright (C) 2017 Risto Lahtela / Rsl1122
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Plan License. (licence.yml)
* Modified software can only be redistributed if allowed in the licence.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License for more details.
*
* You should have received a copy of the License
* along with this program.
* If not it should be visible on the distribution page.
* Or here
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/licence.yml
* Player Analytics Bukkit plugin for monitoring server activity.
* Copyright (C) 2017 Risto Lahtela / Rsl1122
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Plan License. (licence.yml)
* Modified software can only be redistributed if allowed in the licence.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License for more details.
*
* You should have received a copy of the License
* along with this program.
* If not it should be visible on the distribution page.
* Or here
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/licence.yml
*/
package main.java.com.djrapitops.plan;
@ -206,7 +206,12 @@ public class Plan extends BukkitPlugin implements IPlan {
webServer.initServer();
if (!webServer.isEnabled()) {
Log.error("WebServer was not successfully initialized. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
if (Settings.WEBSERVER_DISABLED.isTrue()) {
Log.warn("WebServer was not initialized. (WebServer.DisableWebServer: true)");
} else {
Log.error("WebServer was not initialized successfully. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
}
}
serverInfoManager.updateServerInfo();
@ -248,7 +253,7 @@ public class Plan extends BukkitPlugin implements IPlan {
StaticHolder.saveInstance(ShutdownHook.class, this.getClass());
new ShutdownHook(this);
if (Settings.ANALYSIS_EXPORT.isTrue()) {
RunnableFactory.createNew(new HtmlExport(this));
RunnableFactory.createNew(new HtmlExport(this)).runTaskAsynchronously();
}
} catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly.");

View File

@ -28,6 +28,7 @@ public enum Settings {
DISPLAY_SESSIONS_AS_TABLE("Customization.Display.SessionsAsTable"),
APPEND_WORLD_PERC("Customization.Display.LargestWorldPercInSessionTitle"),
ORDER_WORLD_PIE_BY_PERC("Customization.Display.OrderWorldPieByPercentage"),
WEBSERVER_DISABLED("WebServer.DisableWebServer"),
// Integer
WEBSERVER_PORT("WebServer.Port"),
@ -54,7 +55,7 @@ public enum Settings {
WEBSERVER_CERTIFICATE_KEYPASS("WebServer.Security.SSL-Certificate.KeyPass"),
WEBSERVER_CERTIFICATE_STOREPASS("WebServer.Security.SSL-Certificate.StorePass"),
WEBSERVER_CERTIFICATE_ALIAS("WebServer.Security.SSL-Certificate.Alias"),
EXTERNAL_WEBSERVER_LINK_PROTOCOL("Analysis.Export.ExternalWebServerLinkProtocol"),
EXTERNAL_WEBSERVER_LINK("WebServer.ExternalWebServerAddress"),
//
SERVER_NAME("Server.ServerName"),
//

View File

@ -1,4 +1,4 @@
/*
/*
* 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
*/
@ -34,6 +34,7 @@ import main.java.com.djrapitops.plan.utilities.html.tables.ActionsTableCreator;
import main.java.com.djrapitops.plan.utilities.html.tables.IpTableCreator;
import main.java.com.djrapitops.plan.utilities.html.tables.NicknameTableCreator;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@ -60,181 +61,184 @@ public class InspectPageParser extends PageParser {
Log.logDebug("Database", "Inspect Parse Fetch");
Benchmark.start("Inspect Parse, Fetch");
Database db = plugin.getDB();
UUID serverUuid = MiscUtils.getIPlan().getServerUuid();
Map<UUID, String> serverNames = db.getServerTable().getServerNames();
long now = MiscUtils.getTime();
addValue("refresh", FormatUtils.formatTimeStamp(now));
addValue("version", MiscUtils.getPlanVersion());
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
PlayerProfile profile = db.getPlayerProfile(uuid);
if (profile == null) {
throw new IllegalStateException("Player profile was null!");
}
String online = "Offline";
Optional<Session> activeSession = plugin.getInfoManager().getDataCache().getCachedSession(uuid);
if (activeSession.isPresent()) {
Session session = activeSession.get();
session.setSessionID(Integer.MAX_VALUE);
profile.addActiveSession(session);
online = serverNames.get(serverUuid);
}
UUID serverUUID = MiscUtils.getIPlan().getServerUuid();
Map<UUID, String> serverNames = db.getServerTable().getServerNames();
Benchmark.stop("Inspect Parse, Fetch");
String playerName = profile.getName();
long registered = profile.getRegistered();
int timesKicked = profile.getTimesKicked();
long lastSeen = profile.getLastSeen();
addValue("registered", FormatUtils.formatTimeStampYear(registered));
addValue("playerName", playerName);
addValue("kickCount", timesKicked);
if (lastSeen != 0) {
addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen));
} else {
addValue("lastSeen", "-");
}
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
addValue("serverPieSeries", ServerPreferencePieCreator.createSeriesData(serverNames, worldTimesPerServer));
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
String favoriteServer = serverNames.get(profile.getFavoriteServer());
addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown");
addValue("tableBodyNicknames", NicknameTableCreator.createTable(profile.getNicknames(), serverNames));
addValue("tableBodyIPs", IpTableCreator.createTable(profile.getGeoInformation()));
Map<UUID, List<Session>> sessions = profile.getSessions();
Map<String, List<Session>> sessionsByServerName = sessions.entrySet().stream()
.collect(Collectors.toMap(entry -> serverNames.get(entry.getKey()), Map.Entry::getValue));
List<Session> allSessions = profile.getAllSessions()
.sorted(new SessionStartComparator())
.collect(Collectors.toList());
String[] sessionsAccordion = HtmlStructure.createSessionsTabContentInspectPage(sessionsByServerName, allSessions, uuid);
String[] serverAccordion = ServerAccordionCreator.createAccordion(profile, serverNames);
addValue("accordionSessions", sessionsAccordion[0]);
addValue("accordionServers", serverAccordion[0]);
addValue("sessionTabGraphViewFunctions", sessionsAccordion[1] + serverAccordion[1]);
long dayAgo = now - TimeAmount.DAY.ms();
long weekAgo = now - TimeAmount.WEEK.ms();
long monthAgo = now - TimeAmount.MONTH.ms();
List<Session> sessionsDay = profile.getSessions(dayAgo, now).collect(Collectors.toList());
List<Session> sessionsWeek = profile.getSessions(weekAgo, now).collect(Collectors.toList());
List<Session> sessionsMonth = profile.getSessions(monthAgo, now).collect(Collectors.toList());
long playtime = PlayerProfile.getPlaytime(allSessions.stream());
long playtimeDay = PlayerProfile.getPlaytime(sessionsDay.stream());
long playtimeWeek = PlayerProfile.getPlaytime(sessionsWeek.stream());
long playtimeMonth = PlayerProfile.getPlaytime(sessionsMonth.stream());
long longestSession = PlayerProfile.getLongestSession(allSessions.stream());
long longestSessionDay = PlayerProfile.getLongestSession(sessionsDay.stream());
long longestSessionWeek = PlayerProfile.getLongestSession(sessionsWeek.stream());
long longestSessionMonth = PlayerProfile.getLongestSession(sessionsMonth.stream());
long sessionMedian = PlayerProfile.getSessionMedian(allSessions.stream());
long sessionMedianDay = PlayerProfile.getSessionMedian(sessionsDay.stream());
long sessionMedianWeek = PlayerProfile.getSessionMedian(sessionsWeek.stream());
long sessionMedianMonth = PlayerProfile.getSessionMedian(sessionsMonth.stream());
int sessionCount = allSessions.size();
int sessionCountDay = sessionsDay.size();
int sessionCountWeek = sessionsWeek.size();
int sessionCountMonth = sessionsMonth.size();
long sessionAverage = MathUtils.averageLong(playtime, sessionCount);
long sessionAverageDay = MathUtils.averageLong(playtimeDay, sessionCountDay);
long sessionAverageWeek = MathUtils.averageLong(playtimeWeek, sessionCountWeek);
long sessionAverageMonth = MathUtils.averageLong(playtimeMonth, sessionCountMonth);
addValue("playtimeTotal", playtime > 0L ? FormatUtils.formatTimeAmount(playtime) : "-");
addValue("playtimeDay", playtimeDay > 0L ? FormatUtils.formatTimeAmount(playtimeDay) : "-");
addValue("playtimeWeek", playtimeWeek > 0L ? FormatUtils.formatTimeAmount(playtimeWeek) : "-");
addValue("playtimeMonth", playtimeMonth > 0L ? FormatUtils.formatTimeAmount(playtimeMonth) : "-");
addValue("sessionLengthLongest", longestSession > 0L ? FormatUtils.formatTimeAmount(longestSession) : "-");
addValue("sessionLongestDay", longestSessionDay > 0L ? FormatUtils.formatTimeAmount(longestSessionDay) : "-");
addValue("sessionLongestWeek", longestSessionWeek > 0L ? FormatUtils.formatTimeAmount(longestSessionWeek) : "-");
addValue("sessionLongestMonth", longestSessionMonth > 0L ? FormatUtils.formatTimeAmount(longestSessionMonth) : "-");
addValue("sessionLengthMedian", sessionMedian > 0L ? FormatUtils.formatTimeAmount(sessionMedian) : "-");
addValue("sessionMedianDay", sessionMedianDay > 0L ? FormatUtils.formatTimeAmount(sessionMedianDay) : "-");
addValue("sessionMedianWeek", sessionMedianWeek > 0L ? FormatUtils.formatTimeAmount(sessionMedianWeek) : "-");
addValue("sessionMedianMonth", sessionMedianMonth > 0L ? FormatUtils.formatTimeAmount(sessionMedianMonth) : "-");
addValue("sessionAverage", sessionAverage > 0L ? FormatUtils.formatTimeAmount(sessionAverage) : "-");
addValue("sessionAverageDay", sessionAverageDay > 0L ? FormatUtils.formatTimeAmount(sessionAverageDay) : "-");
addValue("sessionAverageWeek", sessionAverageWeek > 0L ? FormatUtils.formatTimeAmount(sessionAverageWeek) : "-");
addValue("sessionAverageMonth", sessionAverageMonth > 0L ? FormatUtils.formatTimeAmount(sessionAverageMonth) : "-");
addValue("sessionCount", sessionCount);
addValue("sessionCountDay", sessionCountDay);
addValue("sessionCountWeek", sessionCountWeek);
addValue("sessionCountMonth", sessionCountMonth);
List<Action> actions = profile.getAllActions();
addValue("tableBodyActions", ActionsTableCreator.createTable(actions));
String punchCardData = PunchCardGraphCreator.createDataSeries(allSessions);
WorldTimes worldTimes = profile.getWorldTimes();
AnalysisUtils.addMissingWorlds(worldTimes);
String[] worldPieData = WorldPieCreator.createSeriesData(worldTimes);
addValue("worldPieSeries", worldPieData[0]);
addValue("gmSeries", worldPieData[1]);
addValue("punchCardSeries", punchCardData);
List<Session> sessionsInLengthOrder = allSessions.stream()
.sorted(new SessionLengthComparator())
.collect(Collectors.toList());
if (sessionsInLengthOrder.isEmpty()) {
addValue("sessionLengthMedian", "-");
addValue("sessionLengthLongest", "-");
} else {
Session medianSession = sessionsInLengthOrder.get(sessionsInLengthOrder.size() / 2);
addValue("sessionLengthMedian", FormatUtils.formatTimeAmount(medianSession.getLength()));
addValue("sessionLengthLongest", FormatUtils.formatTimeAmount(sessionsInLengthOrder.get(0).getLength()));
}
long playerKillCount = allSessions.stream().map(Session::getPlayerKills).mapToLong(Collection::size).sum();
long mobKillCount = allSessions.stream().mapToLong(Session::getMobKills).sum();
long deathCount = allSessions.stream().mapToLong(Session::getDeaths).sum();
addValue("playerKillCount", playerKillCount);
addValue("mobKillCount", mobKillCount);
addValue("deathCount", deathCount);
double activityIndex = profile.getActivityIndex(now);
String[] activityIndexFormat = FormatUtils.readableActivityIndex(activityIndex);
addValue("activityIndexNumber", FormatUtils.cutDecimals(activityIndex));
addValue("activityIndexColor", activityIndexFormat[0]);
addValue("activityIndex", activityIndexFormat[1]);
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
addValue("networkName", Settings.SERVER_NAME.toString());
}
return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("web/player.html"), placeHolders);
return parse(profile, serverUUID, serverNames);
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
throw new ParseException(e);
}
}
public String parse(PlayerProfile profile, UUID serverUUID, Map<UUID, String> serverNames) throws IOException {
long now = MiscUtils.getTime();
addValue("refresh", FormatUtils.formatTimeStamp(now));
addValue("version", MiscUtils.getPlanVersion());
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
String online = "Offline";
Optional<Session> activeSession = plugin.getInfoManager().getDataCache().getCachedSession(uuid);
if (activeSession.isPresent()) {
Session session = activeSession.get();
session.setSessionID(Integer.MAX_VALUE);
profile.addActiveSession(session);
online = serverNames.get(serverUUID);
}
String playerName = profile.getName();
long registered = profile.getRegistered();
int timesKicked = profile.getTimesKicked();
long lastSeen = profile.getLastSeen();
addValue("registered", FormatUtils.formatTimeStampYear(registered));
addValue("playerName", playerName);
addValue("kickCount", timesKicked);
if (lastSeen != 0) {
addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen));
} else {
addValue("lastSeen", "-");
}
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
addValue("serverPieSeries", ServerPreferencePieCreator.createSeriesData(serverNames, worldTimesPerServer));
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
String favoriteServer = serverNames.get(profile.getFavoriteServer());
addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown");
addValue("tableBodyNicknames", NicknameTableCreator.createTable(profile.getNicknames(), serverNames));
addValue("tableBodyIPs", IpTableCreator.createTable(profile.getGeoInformation()));
Map<UUID, List<Session>> sessions = profile.getSessions();
Map<String, List<Session>> sessionsByServerName = sessions.entrySet().stream()
.collect(Collectors.toMap(entry -> serverNames.get(entry.getKey()), Map.Entry::getValue));
List<Session> allSessions = profile.getAllSessions()
.sorted(new SessionStartComparator())
.collect(Collectors.toList());
String[] sessionsAccordion = HtmlStructure.createSessionsTabContentInspectPage(sessionsByServerName, allSessions, uuid);
String[] serverAccordion = ServerAccordionCreator.createAccordion(profile, serverNames);
addValue("accordionSessions", sessionsAccordion[0]);
addValue("accordionServers", serverAccordion[0]);
addValue("sessionTabGraphViewFunctions", sessionsAccordion[1] + serverAccordion[1]);
long dayAgo = now - TimeAmount.DAY.ms();
long weekAgo = now - TimeAmount.WEEK.ms();
long monthAgo = now - TimeAmount.MONTH.ms();
List<Session> sessionsDay = profile.getSessions(dayAgo, now).collect(Collectors.toList());
List<Session> sessionsWeek = profile.getSessions(weekAgo, now).collect(Collectors.toList());
List<Session> sessionsMonth = profile.getSessions(monthAgo, now).collect(Collectors.toList());
long playtime = PlayerProfile.getPlaytime(allSessions.stream());
long playtimeDay = PlayerProfile.getPlaytime(sessionsDay.stream());
long playtimeWeek = PlayerProfile.getPlaytime(sessionsWeek.stream());
long playtimeMonth = PlayerProfile.getPlaytime(sessionsMonth.stream());
long longestSession = PlayerProfile.getLongestSession(allSessions.stream());
long longestSessionDay = PlayerProfile.getLongestSession(sessionsDay.stream());
long longestSessionWeek = PlayerProfile.getLongestSession(sessionsWeek.stream());
long longestSessionMonth = PlayerProfile.getLongestSession(sessionsMonth.stream());
long sessionMedian = PlayerProfile.getSessionMedian(allSessions.stream());
long sessionMedianDay = PlayerProfile.getSessionMedian(sessionsDay.stream());
long sessionMedianWeek = PlayerProfile.getSessionMedian(sessionsWeek.stream());
long sessionMedianMonth = PlayerProfile.getSessionMedian(sessionsMonth.stream());
int sessionCount = allSessions.size();
int sessionCountDay = sessionsDay.size();
int sessionCountWeek = sessionsWeek.size();
int sessionCountMonth = sessionsMonth.size();
long sessionAverage = MathUtils.averageLong(playtime, sessionCount);
long sessionAverageDay = MathUtils.averageLong(playtimeDay, sessionCountDay);
long sessionAverageWeek = MathUtils.averageLong(playtimeWeek, sessionCountWeek);
long sessionAverageMonth = MathUtils.averageLong(playtimeMonth, sessionCountMonth);
addValue("playtimeTotal", playtime > 0L ? FormatUtils.formatTimeAmount(playtime) : "-");
addValue("playtimeDay", playtimeDay > 0L ? FormatUtils.formatTimeAmount(playtimeDay) : "-");
addValue("playtimeWeek", playtimeWeek > 0L ? FormatUtils.formatTimeAmount(playtimeWeek) : "-");
addValue("playtimeMonth", playtimeMonth > 0L ? FormatUtils.formatTimeAmount(playtimeMonth) : "-");
addValue("sessionLengthLongest", longestSession > 0L ? FormatUtils.formatTimeAmount(longestSession) : "-");
addValue("sessionLongestDay", longestSessionDay > 0L ? FormatUtils.formatTimeAmount(longestSessionDay) : "-");
addValue("sessionLongestWeek", longestSessionWeek > 0L ? FormatUtils.formatTimeAmount(longestSessionWeek) : "-");
addValue("sessionLongestMonth", longestSessionMonth > 0L ? FormatUtils.formatTimeAmount(longestSessionMonth) : "-");
addValue("sessionLengthMedian", sessionMedian > 0L ? FormatUtils.formatTimeAmount(sessionMedian) : "-");
addValue("sessionMedianDay", sessionMedianDay > 0L ? FormatUtils.formatTimeAmount(sessionMedianDay) : "-");
addValue("sessionMedianWeek", sessionMedianWeek > 0L ? FormatUtils.formatTimeAmount(sessionMedianWeek) : "-");
addValue("sessionMedianMonth", sessionMedianMonth > 0L ? FormatUtils.formatTimeAmount(sessionMedianMonth) : "-");
addValue("sessionAverage", sessionAverage > 0L ? FormatUtils.formatTimeAmount(sessionAverage) : "-");
addValue("sessionAverageDay", sessionAverageDay > 0L ? FormatUtils.formatTimeAmount(sessionAverageDay) : "-");
addValue("sessionAverageWeek", sessionAverageWeek > 0L ? FormatUtils.formatTimeAmount(sessionAverageWeek) : "-");
addValue("sessionAverageMonth", sessionAverageMonth > 0L ? FormatUtils.formatTimeAmount(sessionAverageMonth) : "-");
addValue("sessionCount", sessionCount);
addValue("sessionCountDay", sessionCountDay);
addValue("sessionCountWeek", sessionCountWeek);
addValue("sessionCountMonth", sessionCountMonth);
List<Action> actions = profile.getAllActions();
addValue("tableBodyActions", ActionsTableCreator.createTable(actions));
String punchCardData = PunchCardGraphCreator.createDataSeries(allSessions);
WorldTimes worldTimes = profile.getWorldTimes();
AnalysisUtils.addMissingWorlds(worldTimes);
String[] worldPieData = WorldPieCreator.createSeriesData(worldTimes);
addValue("worldPieSeries", worldPieData[0]);
addValue("gmSeries", worldPieData[1]);
addValue("punchCardSeries", punchCardData);
List<Session> sessionsInLengthOrder = allSessions.stream()
.sorted(new SessionLengthComparator())
.collect(Collectors.toList());
if (sessionsInLengthOrder.isEmpty()) {
addValue("sessionLengthMedian", "-");
addValue("sessionLengthLongest", "-");
} else {
Session medianSession = sessionsInLengthOrder.get(sessionsInLengthOrder.size() / 2);
addValue("sessionLengthMedian", FormatUtils.formatTimeAmount(medianSession.getLength()));
addValue("sessionLengthLongest", FormatUtils.formatTimeAmount(sessionsInLengthOrder.get(0).getLength()));
}
long playerKillCount = allSessions.stream().map(Session::getPlayerKills).mapToLong(Collection::size).sum();
long mobKillCount = allSessions.stream().mapToLong(Session::getMobKills).sum();
long deathCount = allSessions.stream().mapToLong(Session::getDeaths).sum();
addValue("playerKillCount", playerKillCount);
addValue("mobKillCount", mobKillCount);
addValue("deathCount", deathCount);
double activityIndex = profile.getActivityIndex(now);
String[] activityIndexFormat = FormatUtils.readableActivityIndex(activityIndex);
addValue("activityIndexNumber", FormatUtils.cutDecimals(activityIndex));
addValue("activityIndexColor", activityIndexFormat[0]);
addValue("activityIndex", activityIndexFormat[1]);
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
addValue("networkName", Settings.SERVER_NAME.toString());
}
return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("web/player.html"), placeHolders);
}
}

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.systems.webserver;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpsConfigurator;
@ -82,7 +83,12 @@ public class WebServer {
* Starts up the WebServer in a new Thread Pool.
*/
public void initServer() {
//Server is already enabled stop code
// Check if Bukkit WebServer has been disabled.
if (!Check.isBungeeAvailable() && Settings.WEBSERVER_DISABLED.isTrue()) {
return;
}
// Server is already enabled stop code
if (enabled) {
return;
}
@ -206,7 +212,7 @@ public class WebServer {
}
public String getAccessAddress() {
return getProtocol() + "://" + HtmlUtils.getIP();
return isEnabled() ? getProtocol() + "://" + HtmlUtils.getIP() : Settings.EXTERNAL_WEBSERVER_LINK.toString();
}
public WebAPIManager getWebAPI() {

View File

@ -23,7 +23,7 @@ import java.util.List;
import java.util.UUID;
/**
* //TODO Class Javadoc Comment
* Abstract Html Export Task.
*
* @author Rsl1122
*/
@ -79,11 +79,7 @@ public abstract class SpecificExport extends AbsRunnable {
return;
}
String html = response.getContent()
.replace("href=\"plugins/", "href=\"../plugins/")
.replace("href=\"css/", "href=\"../css/")
.replace("src=\"plugins/", "src=\"../plugins/")
.replace("src=\"js/", "src=\"../js/");
String html = response.getContent().replace("../", "../../");
List<String> lines = Arrays.asList(html.split("\n"));
File htmlLocation = new File(getPlayerFolder(), name.replace(" ", "%20").replace(".", "%2E"));

View File

@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.utilities.html;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import org.apache.commons.lang3.text.StrSubstitutor;
@ -52,8 +51,7 @@ public class HtmlUtils {
}
public static String getProtocol() {
WebServer uiServer = Plan.getInstance().getWebServer();
return uiServer.isEnabled() ? uiServer.getProtocol() : Settings.EXTERNAL_WEBSERVER_LINK_PROTOCOL.toString();
return MiscUtils.getIPlan().getWebServer().getProtocol();
}
public static String getRelativeInspectUrl(String playerName) {

View File

@ -48,7 +48,6 @@ Analysis:
AutoRefreshPeriod: 60
Export:
Enabled: false
ExternalWebServerLinkProtocol: http
DestinationFolder: 'Analysis Results'
Data:

View File

@ -33,6 +33,12 @@ WebServer:
KeyPass: 'default'
StorePass: 'default'
Alias: 'alias'
# For those that want to serve Html from their own WebServer instead.
# Set up Html Export (https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/External-WebServer-Use)
# ATTENTION: On BungeeCord systems it is not possible to disable the WebServer on the plugin due to WebAPI requirements.
# If the WebServer is disabled with this setting BungeeCord systems will cease to function.
DisableWebServer: false
ExternalWebServerAddress: "https://www.example.address/"
# -----------------------------------------------------
Database:
Type: SQLite
@ -62,7 +68,6 @@ Analysis:
LogProgress: true
Export:
Enabled: false
ExternalWebServerLinkProtocol: http
DestinationFolder: 'Analysis Results'
Data:
Commands:

View File

@ -674,7 +674,7 @@
</script>
<!-- Demo Js -->
<script src="js/demo.js"></script>
<script src="../js/demo.js"></script>
</body>
</html>