From 99e43dd19b6c6efccbee8e4e7d558b77fb26ec08 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sat, 3 Dec 2022 23:16:01 +0100 Subject: [PATCH] Add methods to register script and style files --- .../de/bluecolored/bluemap/api/WebApp.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main/java/de/bluecolored/bluemap/api/WebApp.java b/src/main/java/de/bluecolored/bluemap/api/WebApp.java index 2d2569d..2d89519 100644 --- a/src/main/java/de/bluecolored/bluemap/api/WebApp.java +++ b/src/main/java/de/bluecolored/bluemap/api/WebApp.java @@ -31,6 +31,7 @@ import java.nio.file.Path; import java.util.Map; import java.util.UUID; +import java.util.function.Consumer; public interface WebApp { @@ -55,6 +56,42 @@ public interface WebApp { */ boolean getPlayerVisibility(UUID player); + /** + * Registers a css-style so the webapp loads it.
+ * This method should only be used inside the {@link Consumer} that got registered to {@link BlueMapAPI#onEnable(Consumer)}.
+ * Invoking this method at any other time is not supported.
+ * Style-registrations are not persistent, register your style each time bluemap enables! + *

+ * Example: + *

+     * BlueMapAPI.onEnable(api -> {
+     *    api.getWebApp().registerStyle("js/my-custom-style.css");
+     * });
+     * 
+ *

+ * @param url The (relative) URL that links to the style.css file. The {@link #getWebRoot()}-method can be used to + * create the custom file in the correct location and make it available to the web-app. + */ + void registerStyle(String url); + + /** + * Registers a js-script so the webapp loads it.
+ * This method should only be used inside the {@link Consumer} that got registered to {@link BlueMapAPI#onEnable(Consumer)}.
+ * Invoking this method at any other time is not supported.
+ * Script-registrations are not persistent, register your script each time bluemap enables! + *

+ * Example: + *

+     * BlueMapAPI.onEnable(api -> {
+     *    api.getWebApp().registerScript("js/my-custom-script.js");
+     * });
+     * 
+ *

+ * @param url The (relative) URL that links to the script.js file. The {@link #getWebRoot()}-method can be used to + * create the custom file in the correct location and make it available to the web-app. + */ + void registerScript(String url); + /** * @deprecated You should use the {@link #getWebRoot()} method to create the image-files you need, or store map/marker * specific images in the map's storage (See: {@link BlueMapMap#getAssetStorage()})!