BlueMap docs, command guide entries, early BlueMap hook on Fabric

This commit is contained in:
Claude committed 2026-09-30 20:24:42 +00:00
1 parent 2817ad2ac5
commit 228727a395
4 files changed
+95 -7

No files matched your search

@@ -10,10 +10,17 @@ import java.util.logging.Logger;
final class BlueMapHook {
private BlueMapHook() {}
static Object start(MapService service, Logger log) {
/**
* Registered while the mod initialises (BlueMap reads its script list when it starts), so the data comes from
* {@code service}, which only exists once the server is running: until then the map is simply empty.
*/
static Object start(java.util.function.Supplier<MapService> service, Logger log) {
return MapAddon.start(new MapAddon.Feed() {
@Override public MapData snapshot() { return service.snapshot(); }
@Override public com.google.gson.JsonObject playersJson() { return service.playersJson(); }
@Override public MapData snapshot() { MapService s = service.get(); return s == null ? MapData.empty() : s.snapshot(); }
@Override public com.google.gson.JsonObject playersJson() {
MapService s = service.get();
return s == null ? net.scopenet.core.map.MapModel.playersJson("", java.util.List.of(), System.currentTimeMillis()) : s.playersJson();
}
}, log);
}
@@ -63,6 +63,10 @@ public final class FabricFeatures implements Runnable {
CommandSet commandSet() { return commands; }
@Override public void run() {
// Hook into BlueMap early: it reads the list of web scripts when it starts.
if (FabricConfig.load().bool("bluemap.enabled", true) && net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("bluemap")) {
try { blueMap = BlueMapHook.start(() -> map, LOG); } catch (Throwable t) { LOG.warning("BlueMap addon could not start: " + t); }
}
ServerLifecycleEvents.SERVER_STARTED.register(this::started);
ServerLifecycleEvents.SERVER_STOPPING.register(s -> stopping());
ServerTickEvents.END_SERVER_TICK.register(s -> tick());
@@ -116,10 +120,6 @@ public final class FabricFeatures implements Runnable {
poller = new ActionPoller(env, (from, to) -> commands.essentials.tpa(from, new String[]{to.name()}));
map = new MapService(env, integration.client().claims(), commands.mapSource(), cache, integration.settings().panel().toString(),
config.bool("bluemap.show_homes", false), s.getMotd());
if (config.bool("bluemap.enabled", true) && net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("bluemap")) {
try { blueMap = BlueMapHook.start(map, LOG); } catch (Throwable t) { LOG.warning("BlueMap addon could not start: " + t); }
}
registerCommands(s.getCommands().getDispatcher());
registerPlaceholders();
ScopenetEconomy.install(new ScopenetEconomy(env.panel, r -> platform.runAsync(r)));
@@ -133,6 +133,7 @@ public final class FabricFeatures implements Runnable {
if (blueMap != null) { try { BlueMapHook.stop(blueMap); } catch (Throwable ignored) { } blueMap = null; }
if (platform != null) platform.shutdown();
commands = null;
map = null;
}
private void registerPlaceholders() {