Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -41,7 +41,7 @@ If BlueMap stores its maps in SQL, set `tiles.source: http`.
| `/hud share <names>`, `/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 <name>\|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. |
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "com.extantape"
version = "0.5.1"
version = "0.5.2"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
Expand Down
7 changes: 7 additions & 0 deletions docs/releases/v0.5.2.md
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 16 additions & 0 deletions src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/com/extantape/bluemapmini/hud/HudManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class HudManager {
private final Plugin plugin;
private final PackService packs;
private final Map<UUID, HudSession> sessions = new ConcurrentHashMap<>();
private final Map<String, String> worldMaps = new HashMap<>();
private final WorldMapCache worldMaps = new WorldMapCache(System::currentTimeMillis);
private final Map<UUID, Boolean> bedrock = new ConcurrentHashMap<>();
private final ExecutorService builders = Executors.newFixedThreadPool(2, runnable -> {
Thread thread = new Thread(runnable, "BlueMapMini-build");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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));
}

Expand Down
45 changes: 45 additions & 0 deletions src/main/java/com/extantape/bluemapmini/hud/WorldMapCache.java
Original file line number Diff line number Diff line change
@@ -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<String, String> found = new HashMap<>();
private final Map<String, Long> 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<String, String> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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));
}
}
Loading
Loading