Live map: plugin/mod chunk+player sync, admin panel Live Map section, launcher transport
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjMbLQujBHunCCu5GpsHaT
This commit is contained in:
14 files changed
+769
-8
No files matched your search
@@ -13,6 +13,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
public final class Bridge {
|
||||
private static volatile Integration integration;
|
||||
private static final Map<UUID, String> online = new HashMap<>();
|
||||
private static int mapTicks;
|
||||
private Bridge() {}
|
||||
|
||||
public static void start(MinecraftServer server) {
|
||||
@@ -24,12 +25,25 @@ public final class Bridge {
|
||||
ServerPlayer player = server.getPlayerList().getPlayer(id);
|
||||
if (player != null) player.connection.disconnect(Component.literal(message));
|
||||
}));
|
||||
Path config = Path.of("config/scopenet.properties");
|
||||
if (Settings.liveMapEnabled(config)) integration.enableLiveMap(worldFolder());
|
||||
} catch (Exception e) {
|
||||
// Throwing aborts startup; silently disabling an auth mod is unsafe.
|
||||
throw new IllegalStateException("SCOPENET cannot start: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/** The level folder: `level-name` from server.properties, like the game itself reads it. */
|
||||
private static Path worldFolder() {
|
||||
Properties props = new Properties();
|
||||
try (var in = java.nio.file.Files.newBufferedReader(Path.of("server.properties"))) {
|
||||
props.load(in);
|
||||
} catch (java.io.IOException ignored) {
|
||||
// Fall back to the default level name.
|
||||
}
|
||||
return Path.of(props.getProperty("level-name", "world"));
|
||||
}
|
||||
|
||||
public static CompletableFuture<String> login(UUID uuid, String name, SocketAddress address) {
|
||||
Integration current = integration;
|
||||
if (current == null) return CompletableFuture.completedFuture(Integration.UNAVAILABLE);
|
||||
@@ -59,6 +73,16 @@ public final class Bridge {
|
||||
return true;
|
||||
});
|
||||
current.tick();
|
||||
if (++mapTicks >= 20) {
|
||||
mapTicks = 0;
|
||||
List<LiveMapSync.Player> positions = new ArrayList<>();
|
||||
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||
positions.add(new LiveMapSync.Player(player.getUUID().toString(), player.getName().getString(), Compat.dimension(player),
|
||||
Math.round(player.getX() * 10) / 10.0, Math.round(player.getY() * 10) / 10.0, Math.round(player.getZ() * 10) / 10.0,
|
||||
Math.round(player.getYRot()), Math.round(player.getXRot())));
|
||||
}
|
||||
current.liveMapPlayers(positions);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stat(ServerPlayer player, String key, int amount) {
|
||||
|
||||
Reference in new issue
Block a user