Log user-added Scrips & Styles when they load in (#506)

This commit is contained in:
TechnicJelle 2024-02-14 21:23:27 +01:00 committed by GitHub
parent cc50e05262
commit 2dd7a0a9c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -203,8 +203,17 @@ public void setFrom(WebappConfig config) {
}
public void addFrom(WebappConfig config) {
this.scripts.addAll(config.getScripts());
this.styles.addAll(config.getStyles());
Set<String> scripts = config.getScripts();
for (String script : scripts) {
this.scripts.add(script);
Logger.global.logDebug("Registering script from Webapp Config: " + script);
}
Set<String> styles = config.getStyles();
for (String style : styles) {
this.styles.add(style);
Logger.global.logDebug("Registering style from Webapp Config: " + style);
}
}
}

View File

@ -26,6 +26,7 @@
import de.bluecolored.bluemap.api.WebApp;
import de.bluecolored.bluemap.common.plugin.Plugin;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.util.FileHelper;
import javax.imageio.ImageIO;
@ -68,11 +69,13 @@ public boolean getPlayerVisibility(UUID player) {
@Override
public void registerScript(String url) {
Logger.global.logDebug("Registering script from API: " + url);
plugin.getBlueMap().getWebFilesManager().getScripts().add(url);
}
@Override
public void registerStyle(String url) {
Logger.global.logDebug("Registering style from API: " + url);
plugin.getBlueMap().getWebFilesManager().getStyles().add(url);
}

View File

@ -146,6 +146,7 @@ export class BlueMapApp {
let styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.href = styleUrl;
alert(this.events, "Loading style: " + styleUrl, "fine");
document.head.appendChild(styleElement);
}
@ -189,6 +190,7 @@ export class BlueMapApp {
if (this.settings.scripts) for (let scriptUrl of this.settings.scripts) {
let scriptElement = document.createElement("script");
scriptElement.src = scriptUrl;
alert(this.events, "Loading script: " + scriptUrl, "fine");
document.body.appendChild(scriptElement);
}
}