Map: game servers send tiles, players and overlay; BlueMap and LiveMapSync removed from the Java side
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjMbLQujBHunCCu5GpsHaT
This commit is contained in:
31 files changed
+268
-596
No files matched your search
@@ -16,7 +16,6 @@ dependencies {
|
||||
implementation project(':common')
|
||||
if (features) {
|
||||
modImplementation 'net.fabricmc.fabric-api:fabric-api:0.92.2+1.20.1'
|
||||
implementation project(':bluemap')
|
||||
// Optional at runtime: present only when the LuckPerms mod is installed.
|
||||
compileOnly 'net.luckperms:api:5.4'
|
||||
}
|
||||
@@ -32,6 +31,5 @@ processResources {
|
||||
jar {
|
||||
archiveBaseName = "scopenet-fabric-${mc}"
|
||||
from project(':common').sourceSets.main.output
|
||||
if (features) from project(':bluemap').sourceSets.main.output
|
||||
}
|
||||
base.archivesName = "scopenet-fabric-${mc}"
|
||||
@@ -7,5 +7,5 @@
|
||||
"entrypoints": { "server": ["net.scopenet.fabric.ScopenetFabric"] },
|
||||
"mixins": ["scopenet.mixins.json"],
|
||||
"depends": { "fabricloader": ">=0.16.10", "minecraft": "${mc}", "java": ">=${java}" },
|
||||
"suggests": { "fabric-api": "*", "luckperms": "*", "placeholder-api": "*", "bluemap": "*" }
|
||||
"suggests": { "fabric-api": "*", "luckperms": "*", "placeholder-api": "*" }
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package net.scopenet.fabric.features;
|
||||
|
||||
import net.scopenet.bluemap.MapAddon;
|
||||
import net.scopenet.core.map.MapData;
|
||||
import net.scopenet.core.map.MapService;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/** Kept apart so BlueMap's classes are only loaded when BlueMap is installed. */
|
||||
final class BlueMapHook {
|
||||
private BlueMapHook() {}
|
||||
|
||||
/**
|
||||
* 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() { 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);
|
||||
}
|
||||
|
||||
static void stop(Object handle) { ((MapAddon) handle).stop(); }
|
||||
}
|
||||
+3
-8
@@ -56,17 +56,12 @@ public final class FabricFeatures implements Runnable {
|
||||
private FabricConfig config;
|
||||
private ActionPoller poller;
|
||||
private MapService map;
|
||||
private Object blueMap;
|
||||
private int ticks;
|
||||
private String placeholderStatus = "off";
|
||||
|
||||
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 +111,11 @@ public final class FabricFeatures implements Runnable {
|
||||
integration.onNotifications(events -> link.onPanelEvents(events));
|
||||
Bridge.claimBypass = p -> perms.has(p, "scopenet.claims.bypass");
|
||||
|
||||
// Actions from the map, and the BlueMap addon (claims, pins, player panel) when BlueMap is installed.
|
||||
// Actions from the map, and the claims and pins the SCOPENET Map draws.
|
||||
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());
|
||||
config.bool("map.show_homes", false), s.getMotd());
|
||||
integration.setMapOverlay(() -> { MapService current = map; return current == null ? "{\"claims\":[],\"pins\":[]}" : net.scopenet.core.map.MapOverlay.toJson(current.snapshot()).toString(); });
|
||||
registerCommands(s.getCommands().getDispatcher());
|
||||
registerPlaceholders();
|
||||
ScopenetEconomy.install(new ScopenetEconomy(env.panel, r -> platform.runAsync(r)));
|
||||
@@ -130,7 +126,6 @@ public final class FabricFeatures implements Runnable {
|
||||
private void stopping() {
|
||||
ScopenetEconomy.uninstall();
|
||||
Bridge.claimBypass = p -> false;
|
||||
if (blueMap != null) { try { BlueMapHook.stop(blueMap); } catch (Throwable ignored) { } blueMap = null; }
|
||||
if (platform != null) platform.shutdown();
|
||||
commands = null;
|
||||
map = null;
|
||||
|
||||
Reference in new issue
Block a user