BlueMap addon, shop points, map actions wired into Paper and Fabric; client opens shop windows

This commit is contained in:
Claude committed 2026-09-30 20:24:02 +00:00
1 parent ad7285efac
commit 2817ad2ac5
33 files changed
+754 -13

No files matched your search

@@ -40,6 +40,8 @@ public final class ClientState {
public volatile List<ShopItem> shop = List.of();
public volatile Held held;
public volatile long marketAt, shopAt;
/** A window the server asked us to open ("market" or "shop"), taken once by the screen code. */
public volatile String pendingOpen;
/** Called on the client thread with a server message; returns a toast (kind, title, text) or null. */
public String[] handle(String json) {
@@ -94,6 +96,7 @@ public final class ClientState {
shopAt = System.currentTimeMillis();
}
case "notify" -> { return new String[]{str(m, "kind"), str(m, "title"), str(m, "text")}; }
case "open" -> pendingOpen = str(m, "screen");
default -> { }
}
return null;
@@ -23,7 +23,16 @@ public final class Link {
void register() {
ClientPlayNetworking.registerGlobalReceiver(TO_CLIENT, (client, handler, buf, sender) -> {
String json = buf.readUtf(32767 * 3);
client.execute(() -> toast(state.handle(json)));
client.execute(() -> {
toast(state.handle(json));
String open = state.pendingOpen;
state.pendingOpen = null;
// A right-clicked shop point opens its window, unless another screen is already up.
if (open != null && config.enabled && client.screen == null) {
if (open.equals("market")) client.setScreen(new net.scopenet.client.screen.MarketScreen());
else if (open.equals("shop")) client.setScreen(new net.scopenet.client.screen.ShopScreen());
}
});
});
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> send("hello"));
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> state.reset());