Use uuid instead of name on player page for data request

Affects issues:
- Fixed #2226
This commit is contained in:
Risto Lahtela 2022-01-30 09:25:15 +02:00
parent d831bdc9e5
commit 957b7f400f
5 changed files with 16 additions and 14 deletions

View File

@ -121,7 +121,7 @@ public class PlayerPageExporter extends FileExporter {
String jsonResourceName = toFileName(toJSONResourceName(resource)) + ".json";
export(toDirectory.resolve(jsonResourceName), found.get().getBytes());
exportPaths.put("../v1/player?player=${encodeURIComponent(playerName)}", "./" + jsonResourceName);
exportPaths.put("../v1/player?player=${encodeURIComponent(playerUUID)}", "./" + jsonResourceName);
}
private String toJSONResourceName(String resource) {

View File

@ -100,6 +100,7 @@ public class PlayerPage implements Page {
String playerName = player.getValue(PlayerKeys.NAME).orElse(playerUUID.toString());
placeholders.put("playerName", playerName);
placeholders.put("playerUUID", playerUUID);
placeholders.put("timeZone", config.getTimeZoneOffsetHours());
placeholders.put("gmPieColors", theme.getValue(ThemeVal.GRAPH_GM_PIE));

View File

@ -60,28 +60,29 @@ public class ActiveCookieExpiryCleanupTask extends TaskSystem.Task {
@Override
public void run() {
long time = System.currentTimeMillis();
Set<String> removed = new HashSet<>();
Set<String> cookiesToRemove = new HashSet<>();
for (Map.Entry<String, Long> entry : expiryDates.entrySet()) {
Long expiryTime = entry.getValue();
if (config.isTrue(PluginSettings.DEV_MODE)) {
logger.info("Cookie " + entry.getKey() + " will expire " + expiryTime);
}
if (expiryTime <= time) {
String cookie = entry.getKey();
activeCookieStore.get().removeCookie(cookie);
removed.add(cookie);
cookiesToRemove.add(cookie);
}
}
for (String removedCookie : removed) {
expiryDates.remove(removedCookie);
for (String cookie : cookiesToRemove) {
activeCookieStore.get().removeCookie(cookie);
expiryDates.remove(cookie);
if (config.isTrue(PluginSettings.DEV_MODE)) {
logger.info("Cookie " + removedCookie + " has expired: " + time);
logger.info("Cookie " + cookie + " has expired: " + time);
}
}
}
public void addExpiry(String cookie, Long time) {
expiryDates.put(cookie, time);
if (config.isTrue(PluginSettings.DEV_MODE)) {
logger.info("Cookie " + cookie + " will expire " + time);
}
}
}

View File

@ -110,13 +110,13 @@ function newConfiguredXHR(callback) {
callback(null, "Request did not reach the server. (Server offline / Adblocker?)")
}
} catch (e) {
callback(null, e.message + " (See " + address + ")")
callback(null, e.message)
}
}
};
xhr.timeout = 45000;
xhr.ontimeout = function () {
callback(null, "Timed out after 45 seconds. (" + address + ")")
callback(null, "Timed out after 45 seconds.")
};
return xhr;

View File

@ -717,9 +717,9 @@
Highcharts.setOptions({
lang: {noData: "No Data to Display"}, time: {timezoneOffset: ${timeZone} * 60}
});
const playerName = '${playerName}';
const playerUUID = '${playerUUID}';
setLoadingText('Loading player values..');
jsonRequest(`../v1/player?player=${encodeURIComponent(playerName)}`, function (json, error) {
jsonRequest(`../v1/player?player=${encodeURIComponent(playerUUID)}`, function (json, error) {
loadPlayerOverviewValues(json, error);
loadSessionAccordion(json, error);
loadserverAccordion(json, error);