From 2dd7a0a9c2091d3ded5a2753ac46ec0b1bf85631 Mon Sep 17 00:00:00 2001 From: TechnicJelle <22576047+TechnicJelle@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:23:27 +0100 Subject: [PATCH] Log user-added Scrips & Styles when they load in (#506) --- .../bluecolored/bluemap/common/WebFilesManager.java | 13 +++++++++++-- .../bluecolored/bluemap/common/api/WebAppImpl.java | 3 +++ BlueMapCommon/webapp/src/js/BlueMapApp.js | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java index 729c7759..106378d5 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java @@ -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 scripts = config.getScripts(); + for (String script : scripts) { + this.scripts.add(script); + Logger.global.logDebug("Registering script from Webapp Config: " + script); + } + + Set styles = config.getStyles(); + for (String style : styles) { + this.styles.add(style); + Logger.global.logDebug("Registering style from Webapp Config: " + style); + } } } diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/api/WebAppImpl.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/api/WebAppImpl.java index 88fb11ea..a58abd08 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/api/WebAppImpl.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/api/WebAppImpl.java @@ -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); } diff --git a/BlueMapCommon/webapp/src/js/BlueMapApp.js b/BlueMapCommon/webapp/src/js/BlueMapApp.js index 18896468..5d2cf60d 100644 --- a/BlueMapCommon/webapp/src/js/BlueMapApp.js +++ b/BlueMapCommon/webapp/src/js/BlueMapApp.js @@ -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); } }