mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +01:00
Sanitized Server.Name setting in a shit way that will need refactoring at some point #472
This commit is contained in:
parent
2e6d01eab3
commit
598fdc5d72
@ -69,7 +69,7 @@ public class AnalysisData extends RawData {
|
||||
addValue("version", MiscUtils.getIPlan().getVersion());
|
||||
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
||||
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
||||
addValue("serverName", Settings.SERVER_NAME.toString());
|
||||
addValue("serverName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||
addValue("refresh", FormatUtils.formatTimeStamp(refreshDate));
|
||||
|
||||
|
@ -155,7 +155,6 @@ public class BukkitInformationManager extends InformationManager {
|
||||
cacheInspectPluginsTab(uuid, origin);
|
||||
}
|
||||
} else {
|
||||
String serverName = plugin.getServerInfoManager().getServerName();
|
||||
HookHandler hookHandler = plugin.getHookHandler();
|
||||
List<PluginData> plugins = hookHandler.getAdditionalDataSources();
|
||||
Map<PluginData, InspectContainer> containers = new HashMap<>();
|
||||
|
@ -235,7 +235,7 @@ public class InspectPageParser extends PageParser {
|
||||
addValue("playerStatus", HtmlStructure.playerStatus(online, profile.getBannedOnServers(), profile.isOp()));
|
||||
|
||||
if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
|
||||
addValue("networkName", Settings.SERVER_NAME.toString());
|
||||
addValue("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
}
|
||||
|
||||
return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("web/player.html"), placeHolders);
|
||||
|
@ -59,7 +59,7 @@ public class BukkitServerInfoManager {
|
||||
registerServer(serverUUID);
|
||||
return;
|
||||
}
|
||||
String name = Settings.SERVER_NAME.toString();
|
||||
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
String webAddress = plugin.getWebServer().getAccessAddress();
|
||||
if ("plan".equalsIgnoreCase(name)) {
|
||||
name = "Server " + serverID.get();
|
||||
@ -76,7 +76,7 @@ public class BukkitServerInfoManager {
|
||||
|
||||
private void registerServer(UUID serverUUID) throws SQLException, IOException {
|
||||
String webAddress = plugin.getWebServer().getAccessAddress();
|
||||
String name = Settings.SERVER_NAME.toString();
|
||||
String name = Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_");
|
||||
int maxPlayers = plugin.getVariable().getMaxPlayers();
|
||||
serverInfo = new ServerInfo(-1, serverUUID, name, webAddress, maxPlayers);
|
||||
serverTable.saveCurrentServerInfo(serverInfo);
|
||||
|
@ -37,7 +37,7 @@ public class PlayersPageResponse extends Response {
|
||||
Collections.sort(names);
|
||||
Map<String, String> replace = new HashMap<>();
|
||||
if (Check.isBukkitAvailable()) {
|
||||
replace.put("networkName", Settings.SERVER_NAME.toString());
|
||||
replace.put("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
} else {
|
||||
replace.put("networkName", Settings.BUNGEE_NETWORK_NAME.toString());
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class PostOriginalBukkitSettingsWebAPI extends WebAPI {
|
||||
@Override
|
||||
public void sendRequest(String address) throws WebAPIException {
|
||||
addVariable("WebServerPort", Integer.toString(Settings.WEBSERVER_PORT.getNumber()));
|
||||
addVariable("ServerName", Settings.SERVER_NAME.toString());
|
||||
addVariable("ServerName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
addVariable("ThemeBase", Settings.THEME_BASE.toString());
|
||||
super.sendRequest(address);
|
||||
}
|
||||
|
@ -38,9 +38,10 @@ public class ServerAccordionCreator {
|
||||
"</div>", ""};
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Map.Entry<UUID, WorldTimes> entry : worldTimesPerServer.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
String serverName = serverNames.getOrDefault(serverUUID, "Unknown");
|
||||
WorldTimes worldTimes = entry.getValue();
|
||||
|
||||
List<Session> sessions = profile.getSessions(serverUUID);
|
||||
@ -60,7 +61,8 @@ public class ServerAccordionCreator {
|
||||
String longest = sessionCount != 0 ? FormatUtils.formatTimeAmount(longestSession) : "-";
|
||||
|
||||
String sanitizedServerName = new Format(serverName)
|
||||
.removeSymbols().removeWhitespace().toString();
|
||||
.removeSymbols()
|
||||
.removeWhitespace().toString() + i;
|
||||
String htmlID = "server_" + sanitizedServerName;
|
||||
|
||||
String worldId = "worldPieServer" + sanitizedServerName;
|
||||
@ -116,6 +118,8 @@ public class ServerAccordionCreator {
|
||||
.append(worldId).append("series, ")
|
||||
.append(worldId).append("gmseries")
|
||||
.append(");");
|
||||
|
||||
i++;
|
||||
}
|
||||
return new String[]{html.append("</div>").toString(), viewScript.toString()};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user