From e51568f9980a6d71c0a09ab6e2420aa1c7ab54a1 Mon Sep 17 00:00:00 2001 From: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Date: Sat, 28 Nov 2026 11:01:29 -0700 Subject: [PATCH] Show coordinates in map mode where BlueMap has no map (0.5.2) Map mode drew nothing at all in a world without a BlueMap map. It now draws the coordinate line under the same rules as coordinates mode, respecting /hud hide coords and /hud off, and goes back to the minimap where there is a map. A world without a map is checked again every 10 seconds instead of being cached as mapless until a BlueMap reload. Tested: unit tests (one new test fails on the old rule); live groups coordsonly and dimensions 45/45 on Paper 26.2. Not tested: full live suite, 26.1.2 and 26.3, a real client. Co-Authored-By: Claude Opus 5.5 --- README.md | 6 +- build.gradle.kts | 2 +- docs/releases/v0.5.2.md | 7 +++ .../bluemapmini/BlueMapMiniPlugin.java | 16 +++++ .../bluemapmini/command/HudCommands.java | 2 +- .../extantape/bluemapmini/hud/HudManager.java | 27 +++++--- .../bluemapmini/hud/WorldMapCache.java | 45 ++++++++++++++ .../bluemapmini/hud/MapModeFallbackTest.java | 61 +++++++++++++++++++ test/live/suite.js | 27 +++++--- 9 files changed, 171 insertions(+), 22 deletions(-) create mode 100644 docs/releases/v0.5.2.md create mode 100644 src/main/java/com/extantape/bluemapmini/hud/WorldMapCache.java create mode 100644 src/test/java/com/extantape/bluemapmini/hud/MapModeFallbackTest.java diff --git a/README.md b/README.md index f600fb2..673a80f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ BlueMapMini: a BlueMap minimap and coordinates HUD for Paper, rendered in game f It's an unofficial add-on for BlueMap and isn't affiliated with BlueMap's authors. -**Status:** pre-release, version 0.5.1, for Posse 0.11.0. 0.5.1 only drops a load-order entry that looped with Posse (unit tests and a server rehearsal on a copy of a live server). 0.5.0 passed the full live suite and the real-Posse test (8 checks) on throwaway Paper 26.3 (337 checks, the client font check skipped), 2026-11-25, and on 26.1.2 and 26.2 (337 each) just before the old share keys were dropped; the config change is covered by unit tests there. 0.3.0 passed a full test suite on live Paper 26.1.2, 26.2 and 26.3 servers with real BlueMap tiles, using a protocol bot. 0.4.1 (the share audience setting) passed it again on 26.3 only, 334 of 335 with the client font check skipped, plus the real Posse test. It hasn't been seen in a real game client yet. See [Testing](#testing). +**Status:** pre-release, version 0.5.2, for Posse 0.11.0. 0.5.2 makes map mode show the coordinate line where BlueMap has no map, instead of nothing. It passed unit tests and the live `coordsonly` and `dimensions` groups (45 checks) on throwaway Paper 26.2; the full live suite wasn't rerun. 0.5.1 only drops a load-order entry that looped with Posse (unit tests and a server rehearsal on a copy of a live server). 0.5.0 passed the full live suite and the real-Posse test (8 checks) on throwaway Paper 26.3 (337 checks, the client font check skipped), 2026-11-25, and on 26.1.2 and 26.2 (337 each) just before the old share keys were dropped; the config change is covered by unit tests there. 0.3.0 passed a full test suite on live Paper 26.1.2, 26.2 and 26.3 servers with real BlueMap tiles, using a protocol bot. 0.4.1 (the share audience setting) passed it again on 26.3 only, 334 of 335 with the client font check skipped, plus the real Posse test. It hasn't been seen in a real game client yet. See [Testing](#testing). - Requires Paper 26.1 or newer, Java 25, and a BlueMap version that matches your server (see below). Java Edition only. Paper 1.21.11 and older aren't supported. - Works alongside other resource packs, because it never overrides a shader and only adds its own files. @@ -41,7 +41,7 @@ If BlueMap stores its maps in SQL, set `tiles.source: http`. | `/hud share `, `/hud share everyone` | The same without the dialog. Names are separated by spaces or commas. | | `/hud hide\|show shares` | Stops or restarts receiving coordinates other players share. | | `/hud theme`, `/hud theme \|default` | Lists the themes, with yours marked and each one clickable, or switches to one. `default` goes back to the server's. The choice is saved per player. | -| `/hud mode coords\|map` | `coords` shows only the X, Y, Z and facing line, in the same bar, and works in worlds BlueMap doesn't map. `map` brings the minimap back. Both turn the HUD on, and `/hud mode` alone says which one you have. New players start in `hud.default-mode`, which is `map` unless the config says `coords`. | +| `/hud mode coords\|map` | `coords` shows only the X, Y, Z and facing line, in the same bar, and works in worlds BlueMap doesn't map. `map` brings the minimap back, and where BlueMap has no map it shows the coordinate line instead (unless you've hidden coordinates with `/hud hide coords`). Both turn the HUD on, and `/hud mode` alone says which one you have. New players start in `hud.default-mode`, which is `map` unless the config says `coords`. | | `/bluemapmini help` | Shows help. | | `/bluemapmini reload` | Reloads the config, and re-sends the pack if it changed. | | `/bluemapmini debug` | Shows cache sizes, build times and update sizes. | @@ -121,7 +121,7 @@ The plugin sends its pack alongside any others using the multi-pack API, and pla - **Screen position:** the server can't see a player's screen size, so the map starts at top center. Players can move it with `/hud offset` or `/hud corner`. - **Other boss bars:** the minimap hides for Adventure boss bars, registered Bukkit bars and the Wither and Ender Dragon. A bar made with Bukkit's unregistered `createBossBar` can't be detected, so the minimap stays up and the two share the screen. - **Clock:** it shows the in-game time of the world you're in, in steps of `hud.clock.step-minutes`. It doesn't show in worlds where time stands still. -- **Coordinates:** the coordinate line is part of the minimap, so it hides whenever the minimap does, including during boss fights and with `/hud off`. In `/hud mode coords` it follows the same rules, apart from also showing where BlueMap has no map. The fullscreen map always shows it. +- **Coordinates:** the coordinate line is part of the minimap, so it hides whenever the minimap does, including during boss fights and with `/hud off`. Where BlueMap has no map, both modes show the coordinate line alone, with the same rules. In map mode `/hud hide coords` keeps it hidden there too, and when a map appears later, or the player walks into a world with one, the minimap comes back without a restart (BlueMapMini checks a mapless world again every 10 seconds). The fullscreen map always shows it. - **Vertical position:** `/hud offset y` moves in whole map cells, up to `hud.max-offset-y`. - **Action bar mode:** the map sits above the hotbar and can flicker if another plugin also uses the action bar. The fullscreen map still uses a boss bar. - **Other pink boss bars:** the pack makes one boss bar color transparent, so another plugin's bar in that color disappears too. Choose a color with `pack.boss-bar-color` that nothing else uses. diff --git a/build.gradle.kts b/build.gradle.kts index e369849..210a3bb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "com.extantape" -version = "0.5.1" +version = "0.5.2" java { toolchain.languageVersion.set(JavaLanguageVersion.of(25)) diff --git a/docs/releases/v0.5.2.md b/docs/releases/v0.5.2.md new file mode 100644 index 0000000..a7f57b9 --- /dev/null +++ b/docs/releases/v0.5.2.md @@ -0,0 +1,7 @@ +# BlueMapMini 0.5.2 + +- **Map mode falls back to coordinates.** In map mode, a world BlueMap has no map for used to show nothing at all, not even coordinates. Now it shows the coordinate line, drawn as coordinates mode draws it and under the same rules: hidden by `/hud off`, in spectator, and behind another boss bar. In map mode, `/hud hide coords` keeps it hidden there too. The minimap comes back as soon as the player is somewhere with a map. A world without a map is checked again every 10 seconds, so a map BlueMap adds later shows up without a restart. Before, a world found without a map stayed that way until BlueMap reloaded. +- `/hud on` and `/hud mode map` in such a world now say "BlueMap has no map for this world, so you'll see your coordinates here, and the minimap where there's a map." If coordinates are hidden, they say so and point to `/hud show coords`. These are new player-facing lines. The fullscreen map's message is unchanged. +- Player dots are unchanged. + +Tested: 77 unit tests, including 8 new ones for the fallback and the map cache. One of the new tests fails with the old rule. On a throwaway Paper 26.2 server with BlueMap 5.29 and a protocol bot, the live groups `coordsonly` and `dimensions` passed 45 of 45. Those checks: the coordinate line in a world with its map removed, map mode included; `/hud hide coords`, `/hud show coords` and `/hud off` there; and the minimap coming back when the map does (after a BlueMap reload) without a server restart. Not tested: the full live suite, 26.1.2 and 26.3, the 10-second recheck on a server without a BlueMap reload (unit test only), and a real game client. diff --git a/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java b/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java index a1bfeb0..06d491c 100644 --- a/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java +++ b/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java @@ -149,6 +149,22 @@ public void explainIfNoMap(Player player) { } } + /** + * For the minimap (/hud on, /hud mode map): where BlueMap has no map, map mode shows the coordinate line instead, + * so say that rather than leave the player wondering where the minimap went. + */ + public void explainMinimapIfNoMap(Player player, boolean showCoords) { + if (!hud.mapFor(player.getWorld()).isEmpty()) { + explainIfNoPack(player); + return; + } + String why = BlueMapAPI.getInstance().isPresent() ? "BlueMap has no map for this world" : "BlueMap isn't ready yet"; + player.sendMessage(Component.text(showCoords + ? why + ", so you'll see your coordinates here, and the minimap where there's a map." + : why + ", and your coordinates are hidden, so nothing shows here. /hud show coords brings them back.", NamedTextColor.YELLOW)); + if (showCoords) explainIfNoPack(player); + } + /** Coordinates need the pack but not a map, so this is all that can stop them appearing. */ public void explainIfNoPack(Player player) { if (!packs.ready(player)) { diff --git a/src/main/java/com/extantape/bluemapmini/command/HudCommands.java b/src/main/java/com/extantape/bluemapmini/command/HudCommands.java index 5df47e8..cc15549 100644 --- a/src/main/java/com/extantape/bluemapmini/command/HudCommands.java +++ b/src/main/java/com/extantape/bluemapmini/command/HudCommands.java @@ -307,7 +307,7 @@ private void setCoordsOnly(Player player, HudSession session, boolean coordsOnly private void explainIfHidden(Player player, HudSession session) { if (session.settings().coordsOnly) plugin.explainIfNoPack(player); - else plugin.explainIfNoMap(player); + else plugin.explainMinimapIfNoMap(player, session.settings().showCoords); } private static String hudName(HudSession session) { diff --git a/src/main/java/com/extantape/bluemapmini/hud/HudManager.java b/src/main/java/com/extantape/bluemapmini/hud/HudManager.java index 6a1de07..d0cb12f 100644 --- a/src/main/java/com/extantape/bluemapmini/hud/HudManager.java +++ b/src/main/java/com/extantape/bluemapmini/hud/HudManager.java @@ -43,7 +43,7 @@ public final class HudManager { private final Plugin plugin; private final PackService packs; private final Map sessions = new ConcurrentHashMap<>(); - private final Map worldMaps = new HashMap<>(); + private final WorldMapCache worldMaps = new WorldMapCache(System::currentTimeMillis); private final Map bedrock = new ConcurrentHashMap<>(); private final ExecutorService builders = Executors.newFixedThreadPool(2, runnable -> { Thread thread = new Thread(runnable, "BlueMapMini-build"); @@ -146,7 +146,7 @@ public String debugLine() { /** The map a world's HUD draws: a configured override, or else its first map by ID. */ public String mapFor(World world) { if (!rendering) return ""; - return worldMaps.computeIfAbsent(world.getName(), name -> { + return worldMaps.get(world.getName(), name -> { String override = config.tiles().mapOverrides().get(name); if (override != null) return override; BlueMapAPI api = BlueMapAPI.getInstance().orElse(null); @@ -183,22 +183,31 @@ private void tick() { String mapId = mapFor(player.getWorld()); boolean hasMap = !mapId.isEmpty() || session.pattern; + boolean coordsLine = drawsCoordsLine(session.settings.coordsOnly, session.settings.showCoords, hasMap, session.pattern); boolean canFull = hasMap && session.fullscreen && com.extantape.bluemapmini.Perms.has(player, "bluemapmini.fullscreen") && config.fullscreen().enabled(); - if (!shouldShow(player, session, hasMap, canFull)) { + if (!shouldShow(player, session, hasMap, coordsLine, canFull)) { hide(player, session); continue; } resendActionBar(player, session, canFull); if (session.building.compareAndSet(false, true)) { - Snapshot snapshot = snapshot(player, session, mapId, canFull); + Snapshot snapshot = snapshot(player, session, mapId, canFull, coordsLine); submit(builder, session, snapshot); } } } - private boolean shouldShow(Player player, HudSession session, boolean hasMap, boolean canFull) { - boolean coordsOnly = session.settings.coordsOnly && !session.pattern; - if (!hasMap && !coordsOnly) return false; // A dimension BlueMap doesn't map. Coordinates don't need one. + /** + * Whether the HUD draws only the coordinate line: in coordinates mode, and in map mode where the world has no + * BlueMap map, unless the player hid the coordinates. The test pattern always draws the map. + */ + static boolean drawsCoordsLine(boolean coordsMode, boolean showCoords, boolean hasMap, boolean pattern) { + if (pattern) return false; + return coordsMode || !hasMap && showCoords; + } + + private boolean shouldShow(Player player, HudSession session, boolean hasMap, boolean coordsOnly, boolean canFull) { + if (!hasMap && !coordsOnly) return false; // No map here, and the player hid the coordinates too. if (isBedrock(player) || !packs.ready(player)) return false; if (!com.extantape.bluemapmini.Perms.has(player, "bluemapmini.use")) return false; if (canFull) return true; // Fullscreen is an explicit request, and it works while the minimap is off. @@ -225,7 +234,7 @@ private void resendActionBar(Player player, HudSession session, boolean full) { } } - private Snapshot snapshot(Player player, HudSession session, String mapId, boolean full) { + private Snapshot snapshot(Player player, HudSession session, String mapId, boolean full, boolean coordsLine) { PlayerSettings settings = session.settings; Location location = player.getLocation(); int[] death = null; @@ -236,7 +245,7 @@ private Snapshot snapshot(Player player, HudSession session, String mapId, boole return new Snapshot(mapId, location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getYaw(), full, full ? settings.fullscreenZoom : settings.zoom, settings.size, settings.offsetX, settings.offsetY, settings.showCoords, settings.showMarkers, visiblePlayers(player, session, location), death, session.pattern, - settings.coordsOnly && !full && !session.pattern, frames.themes().resolve(settings.theme), + coordsLine && !full, frames.themes().resolve(settings.theme), clockMinutes(player.getWorld(), settings)); } diff --git a/src/main/java/com/extantape/bluemapmini/hud/WorldMapCache.java b/src/main/java/com/extantape/bluemapmini/hud/WorldMapCache.java new file mode 100644 index 0000000..65bb4f4 --- /dev/null +++ b/src/main/java/com/extantape/bluemapmini/hud/WorldMapCache.java @@ -0,0 +1,45 @@ +package com.extantape.bluemapmini.hud; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.LongSupplier; + +/** + * Which BlueMap map each world's HUD draws. A world with a map is remembered until the cache is cleared. A world + * without one is asked again after {@link #RETRY_MS}, so a map BlueMap adds later (a new world, a render finished, + * a BlueMap reload) shows up without a restart. Used from the main thread only. + */ +final class WorldMapCache { + static final long RETRY_MS = 10_000; + + private final Map found = new HashMap<>(); + private final Map missedAt = new HashMap<>(); + private final LongSupplier clock; + + WorldMapCache(LongSupplier clock) { + this.clock = clock; + } + + /** The world's map ID, or "" when it has none (yet). {@code lookup} returns "" or null for no map. */ + String get(String world, Function lookup) { + String hit = found.get(world); + if (hit != null) return hit; + long now = clock.getAsLong(); + Long missed = missedAt.get(world); + if (missed != null && now - missed < RETRY_MS) return ""; + String id = lookup.apply(world); + if (id == null || id.isEmpty()) { + missedAt.put(world, now); + return ""; + } + found.put(world, id); + missedAt.remove(world); + return id; + } + + void clear() { + found.clear(); + missedAt.clear(); + } +} diff --git a/src/test/java/com/extantape/bluemapmini/hud/MapModeFallbackTest.java b/src/test/java/com/extantape/bluemapmini/hud/MapModeFallbackTest.java new file mode 100644 index 0000000..bd931af --- /dev/null +++ b/src/test/java/com/extantape/bluemapmini/hud/MapModeFallbackTest.java @@ -0,0 +1,61 @@ +package com.extantape.bluemapmini.hud; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import org.junit.jupiter.api.Test; + +/** Map mode in a world with no BlueMap map falls back to the coordinate line, and finds a map added later. */ +class MapModeFallbackTest { + @Test void mapModeWithAMapDrawsTheMinimap() { + assertFalse(HudManager.drawsCoordsLine(false, true, true, false)); + } + + @Test void mapModeWithNoMapDrawsTheCoordinateLine() { + assertTrue(HudManager.drawsCoordsLine(false, true, false, false), "before 0.5.2 this drew nothing at all"); + } + + @Test void mapModeWithNoMapRespectsHiddenCoordinates() { + assertFalse(HudManager.drawsCoordsLine(false, false, false, false), "/hud hide coords keeps them hidden there too"); + } + + @Test void coordinatesModeIsUnchanged() { + assertTrue(HudManager.drawsCoordsLine(true, true, true, false)); + assertTrue(HudManager.drawsCoordsLine(true, true, false, false)); + } + + @Test void theTestPatternAlwaysDrawsTheMap() { + assertFalse(HudManager.drawsCoordsLine(true, true, true, true)); + assertFalse(HudManager.drawsCoordsLine(false, true, true, true)); + } + + @Test void aWorldWithoutAMapIsAskedAgainSoAMapAddedLaterShowsUp() { + AtomicLong now = new AtomicLong(0); + AtomicInteger asked = new AtomicInteger(); + String[] map = {""}; + WorldMapCache cache = new WorldMapCache(now::get); + assertEquals("", cache.get("nether", w -> { asked.incrementAndGet(); return map[0]; })); + map[0] = "nether_map"; + now.set(WorldMapCache.RETRY_MS - 1); + assertEquals("", cache.get("nether", w -> { asked.incrementAndGet(); return map[0]; }), "not asked again every tick"); + assertEquals(1, asked.get()); + now.set(WorldMapCache.RETRY_MS); + assertEquals("nether_map", cache.get("nether", w -> { asked.incrementAndGet(); return map[0]; }), "found without a restart"); + assertEquals(2, asked.get()); + } + + @Test void aWorldWithAMapIsRememberedUntilCleared() { + AtomicInteger asked = new AtomicInteger(); + WorldMapCache cache = new WorldMapCache(() -> 0); + assertEquals("world", cache.get("world", w -> { asked.incrementAndGet(); return "world"; })); + assertEquals("world", cache.get("world", w -> { asked.incrementAndGet(); return "other"; })); + assertEquals(1, asked.get()); + cache.clear(); + assertEquals("other", cache.get("world", w -> "other")); + } + + @Test void aNullAnswerCountsAsNoMap() { + assertEquals("", new WorldMapCache(() -> 0).get("void", w -> null)); + } +} diff --git a/test/live/suite.js b/test/live/suite.js index ec61799..9cefd9c 100644 --- a/test/live/suite.js +++ b/test/live/suite.js @@ -445,10 +445,19 @@ const GROUPS = { await sleep(800); check('/map there explains and leaves the coordinates up', !!lineOf() && b.hudFrame(pk()).fontName === 'bluemapmini:hud', lineOf()); await chat(b, '/map'); - const noMap = await chat(b, '/hud mode map', /no map/); - check('/hud mode map there explains why nothing shows', noMap && await until(() => !b.hudFrame(pk()), 3000), noMap); + // 0.5.2: map mode falls back to the coordinate line where BlueMap has no map. + const noMap = await chat(b, '/hud mode map', /coordinates here/); + check('/hud mode map there says the coordinates stand in for the minimap', noMap, noMap); + check('In map mode with no map, the coordinate line still shows', await until(() => lineOf()?.startsWith('0 100 0 '), 4000), lineOf()); + await chat(b, '/hud hide coords'); await sleep(400); + check('/hud hide coords hides it there too', await until(() => !b.hudFrame(pk()), 3000)); + await chat(b, '/hud show coords'); await sleep(400); + check('/hud show coords brings it back there', await until(() => lineOf()?.startsWith('0 100 0 '), 3000), lineOf()); + await chat(b, '/hud off'); await sleep(400); + check('/hud off still hides everything there', await until(() => !b.hudFrame(pk()), 3000)); + await chat(b, '/hud on', /coordinates here/); await chat(b, '/hud mode coords', /only coordinates/); - check('/hud mode coords brings it back there', await until(() => lineOf(), 3000)); + check('/hud mode coords keeps it there', await until(() => lineOf(), 3000)); } finally { fs.renameSync(path.join(confs, end + '.off'), path.join(confs, end)); s.cmd('bluemap reload'); await sleep(9000); @@ -789,13 +798,15 @@ const GROUPS = { const confs = s.path('plugins/BlueMap/maps'); const end = fs.readdirSync(confs).find((f) => /end/i.test(f)); fs.renameSync(path.join(confs, end), path.join(confs, end + '.off')); s.cmd('bluemap reload'); await s.waitLog(/Reloaded|reloaded|Reload/, 30000, s.mark() - 200); await sleep(6000); - check('A dimension BlueMap does not map hides the HUD', await until(() => !b.hudFrame(packOf(b)), 6000)); - const why = await chat(b, '/hud on', /no map|isn't ready/); - check('/hud on explains why', why, why); + // 0.5.2: in map mode a dimension BlueMap doesn't map shows the coordinate line instead of nothing. + const coordsLine = () => { const fr = b.hudFrame(packOf(b)); return fr && fr.runs.length === 0 && fr.icons.length === 0 ? textLines(fr)[0]?.s : null; }; + check('A dimension BlueMap does not map shows the coordinate line instead', await until(() => coordsLine()?.startsWith('0 100 0 '), 6000), coordsLine()); + const why = await chat(b, '/hud on', /coordinates here/); + check('/hud on explains it', why, why); fs.renameSync(path.join(confs, end + '.off'), path.join(confs, end)); s.cmd('bluemap reload'); await sleep(9000); - await until(() => b.hudFrame(packOf(b)), 8000); - check('The map returns after BlueMap reloads', !!b.hudFrame(packOf(b))); + await until(() => { const fr = b.hudFrame(packOf(b)); return fr && fr.runs.length > 0; }, 15000); + check('The minimap returns when the map comes back, without a restart', (b.hudFrame(packOf(b))?.runs.length ?? 0) > 0); s.cmd('execute in minecraft:overworld run tp Tester 0 120 0'); await sleep(1200); await expectMap('Back in the Overworld', b, OVER, 2, 0, 0, 32, 32, 2); baseConfig(); fs.writeFileSync(CFG, fs.readFileSync(CFG, 'utf8').replace('map-overrides: {}', `map-overrides:\n world: ${netherMap}`)); await reload();