diff --git a/README.md b/README.md index 6f96434..62f83c8 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.4.1. 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 Mayor test. It hasn't been seen in a real game client yet. See [Testing](#testing). +**Status:** pre-release, version 0.5.0, for Posse 0.11.0. 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. @@ -92,17 +92,17 @@ Up to 8 themes fit in the pack. Every built-in theme passes the same readability `/hud share` sends your current coordinates to people you choose, as a chat message with the coordinates and the dimension, such as `Alex shared where they are: 120 64 -35 in the Overworld`. Clicking the numbers copies them. Nothing is shared unless a player asks, and there's no teleport link. - **Who can receive:** set by `share.audience`, which is `off` by default, so nothing can be shared until an admin picks one: - - `mayor`: whoever Mayor's player groups allow, the same as chat. Needs Mayor 0.5.0 or newer. Without it, sharing stays off and the console says why. - - `mayor-world-group`: players in the same world group whom Mayor's groups also allow. Needs Mayor 0.5.0 or newer. + - `posse`: whoever Posse's player groups allow, the same as chat. Needs Posse 0.11.0 or newer. Without it, sharing stays off and the console says why. + - `posse-world-group`: players in the same world group whom Posse's groups also allow. Needs Posse 0.11.0 or newer. - `world`: players in the same world. - `world-group`: players in the same world, counting its `_nether` and `_the_end` as the same world. - `server`: anyone online. - In every mode a receiver must be able to see the sender, have `bluemapmini.share.receive`, and not have turned shares off with `/hud hide shares`. An unknown value counts as `off`. A Mayor older than 0.5.0 turns sharing off in every mode. A config from before 0.4.0 gets the narrowest mode matching its old `enabled`, `candidates` and `require-mayor` keys, so an upgrade never widens sharing: the old defaults become `mayor-world-group`. + In every mode a receiver must be able to see the sender, have `bluemapmini.share.receive`, and not have turned shares off with `/hud hide shares`. An unknown value counts as `off`. A Posse older than 0.11.0 turns sharing off in every mode. A config with no `share.audience` is `off`; the older `enabled`, `candidates` and `require-*` keys aren't read. - **Feedback:** the sender is told exactly who got their coordinates, and who couldn't. - **Limits:** a player waits `share.cooldown-seconds` (30 by default) between shares, and each share is logged to the console. -**Your server's own rules.** BlueMapMini fires `com.extantape.bluemapmini.api.CoordinateShareEvent` on the main thread before each share. It carries the sender, the world, the block coordinates and a mutable set of recipients. A plugin can remove recipients, for example to match who may chat with whom, or cancel the share. In the `mayor` and `server` modes, recipients start as everyone online, so such a plugin can follow rules that reach across worlds. To build against it, depend on BlueMapMini as a server dependency with `join-classpath: true` in your `paper-plugin.yml`. +**Your server's own rules.** BlueMapMini fires `com.extantape.bluemapmini.api.CoordinateShareEvent` on the main thread before each share. It carries the sender, the world, the block coordinates and a mutable set of recipients. A plugin can remove recipients, for example to match who may chat with whom, or cancel the share. In the `posse` and `server` modes, recipients start as everyone online, so such a plugin can follow rules that reach across worlds. To build against it, depend on BlueMapMini as a server dependency with `join-classpath: true` in your `paper-plugin.yml`. ## Resource packs diff --git a/build.gradle.kts b/build.gradle.kts index db71617..454344b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "com.extantape" -version = "0.4.1" +version = "0.5.0" java { toolchain.languageVersion.set(JavaLanguageVersion.of(25)) diff --git a/docs/decisions.md b/docs/decisions.md index 417e3cb..249afe3 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -4,6 +4,7 @@ Owner decisions for BlueMapHUD, newest first. | Date | Decision | Why | | --- | --- | --- | +| 2026-11-25 | Mayor is now Posse (D196, D292). `share.audience` takes `posse` and `posse-world-group`. The old values `mayor` and `mayor-world-group` are unknown and turn sharing off, and no old key is read, including the pre-0.4.0 `share.enabled`, `share.candidates` and `share.require-mayor`: a config with no `share.audience` is off. | The owner: "Get rid of mayor yes" and D295. An unknown or missing value fails closed. | | 2026-11-21 | `share.audience` sets who coordinates can go to: off (the default), Mayor's groups, Mayor's groups within the world group, the same world, the world group, or the whole server. Mayor's modes fail closed without Mayor, and old configs migrate to the narrowest matching mode (D254). | The owner: "Should have configurability for all scenarios, including full server, etc". | | 2026-11-07 | A failed pack download never kicks. The player stays with the map off and a clear message, admins are warned (at most every five minutes), and the pack is offered again on their next world change or rejoin. Only a deliberate decline follows `pack.required`. | Never kick a player over a hosting problem: it isn't their fault, and kicking them can't fix it. | | 2026-11-07 | `/hud share` reaches the same people as chat. A cancellable `CoordinateShareEvent` with a mutable recipient set lets the server's rules plugin filter shares. Without one, shares need the send and receive permissions, stay in the sender's world group, and players can opt out. `share.candidates: all-online` only widens shares while a plugin listens to the event. | Children on the server should only reach the people they can already chat with. Keeping the rules in one plugin means BlueMapHUD doesn't hard-code any server's groups. | diff --git a/docs/releases/v0.5.0.md b/docs/releases/v0.5.0.md new file mode 100644 index 0000000..a58563d --- /dev/null +++ b/docs/releases/v0.5.0.md @@ -0,0 +1,16 @@ +Works with Posse 0.11.0 (formerly Mayor); the Mayor name is no longer recognized (D196, D292). + +## What changed + +- **`share.audience` values `mayor` and `mayor-world-group` are now `posse` and `posse-world-group`.** The old values are unknown, and an unknown value turns sharing off with a console warning. A server that has `mayor` set shares nothing until its config is edited. Nothing widens. +- **Posse 0.11.0 or newer is required for the two Posse modes.** With no Posse, or an older one, sharing is off in those modes and the console says why. The older-version check now refuses any Posse before 0.11.0, which cannot exist, so in practice it means "install Posse". +- **No old key is read.** A config with no `share.audience` is off, and the pre-0.4.0 keys (`share.enabled`, `share.candidates` and `share.require-mayor`) are ignored, so an old file can't switch sharing on. Posse is also now an optional load-before dependency in `paper-plugin.yml`. +- The shipped `config.yml`, the README, the console messages and the live test (`posse.js`, run with `BMM_POSSE_JAR`) use the new name. + +## Upgrading from 0.4.1 + +A config that still has only the old keys has sharing off. Before the first start, change `share.audience: mayor` to `posse` and `mayor-world-group` to `posse-world-group` in `plugins/BlueMapMini/config.yml`. Install Posse 0.11.0 in the same stop. Nothing else changes. + +## Tested + +Unit tests, including the old values being unknown. Live bot suite (the client font check skipped, no client classpath) and the real-Posse test (8 checks, Posse 0.11.0 from its release) on throwaway Paper servers: 337/337 on 26.3 with the final code, and 337/337 on 26.1.2 and 26.2 just before the old share keys were dropped (unit tests cover that change). Not yet seen in a real game client. diff --git a/docs/test-audit.md b/docs/test-audit.md index 3ad645e..ff311cf 100644 --- a/docs/test-audit.md +++ b/docs/test-audit.md @@ -2,6 +2,17 @@ Kept by this repo's owning session (Minecraft: Plugins Lead), per `~/Code/CLAUDE.md`, "Test self-audits". Newest first. +## 2026-11-25: Posse rename (0.5.0) + +| Promise | Covered by | +| --- | --- | +| `posse` and `posse-world-group` read; the old `mayor` values are unknown, so sharing is off | unit `PosseGuardTest.theOldMayorNameIsNotAnAudience`; live "The old audience ... is unknown" (26.1.2 and 26.2) | +| Posse modes fail closed with no Posse or one older than 0.11.0 | unit `PosseGuardTest`; live "audience: posse with no Posse installed stays off" | +| No old key is read: only the old keys means off | unit `ShareConfigTest.olderShareKeysAloneMeanOff` | +| Shares follow Posse's circles | live `posse.js` (8 checks, real Posse 0.11.0), on 26.1.2, 26.2 and 26.3 | + +Gaps skipped: 26.1.2 and 26.2 weren't rerun after the old share keys were dropped; unit tests cover that parse, and 26.3 reran with the final code. + ## 2026-11-24: share.audience (0.4.1) | Promise | Covered by | diff --git a/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java b/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java index 87f39bc..a1bfeb0 100644 --- a/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java +++ b/src/main/java/com/extantape/bluemapmini/BlueMapMiniPlugin.java @@ -271,11 +271,11 @@ public void onServerLoad(ServerLoadEvent event) { /** Says who coordinates can be shared with, and warns about a bad setting. Also run after a reload. */ private void logShareAudience() { var share = config.share(); - if (share.audienceUnknown()) getLogger().warning("share.audience isn't one of off, mayor, mayor-world-group, world, world-group or server, so sharing is off."); + if (share.audienceUnknown()) getLogger().warning("share.audience isn't one of off, posse, posse-world-group, world, world-group or server, so sharing is off."); getLogger().info("Coordinate sharing: " + switch (share.audience()) { case OFF -> "off."; - case MAYOR -> "to whoever Mayor's player groups allow."; - case MAYOR_WORLD_GROUP -> "to players in the same world group whom Mayor's player groups allow."; + case POSSE -> "to whoever Posse's player groups allow."; + case POSSE_WORLD_GROUP -> "to players in the same world group whom Posse's player groups allow."; case WORLD -> "to players in the same world."; case WORLD_GROUP -> "to players in the same world, counting its Nether and End."; case SERVER -> "to anyone online."; diff --git a/src/main/java/com/extantape/bluemapmini/api/CoordinateShareEvent.java b/src/main/java/com/extantape/bluemapmini/api/CoordinateShareEvent.java index 1d0174e..07c1438 100644 --- a/src/main/java/com/extantape/bluemapmini/api/CoordinateShareEvent.java +++ b/src/main/java/com/extantape/bluemapmini/api/CoordinateShareEvent.java @@ -13,7 +13,7 @@ * server's chat rules, can decide who may receive them. Remove recipients to narrow the share, or cancel it * to send nothing. Players who turned shares off, or lack {@code bluemapmini.share.receive}, are already gone. * - *
In the {@code mayor} and {@code server} modes of {@code share.audience}, the recipients start as everyone + *
In the {@code posse} and {@code server} modes of {@code share.audience}, the recipients start as everyone
* online, including players in other worlds.
*/
public final class CoordinateShareEvent extends Event implements Cancellable {
diff --git a/src/main/java/com/extantape/bluemapmini/config/HudConfig.java b/src/main/java/com/extantape/bluemapmini/config/HudConfig.java
index 1dc03a8..d7ecf7b 100644
--- a/src/main/java/com/extantape/bluemapmini/config/HudConfig.java
+++ b/src/main/java/com/extantape/bluemapmini/config/HudConfig.java
@@ -26,10 +26,10 @@ public enum Channel { BOSS_BAR, ACTION_BAR }
public enum ShareAudience {
/** Nobody: sharing is off. The default. */
OFF("off"),
- /** Whoever Mayor's player groups allow, the same as chat. Off (fail closed) if Mayor 0.5.0+ isn't running. */
- MAYOR("mayor"),
- /** Players in the sender's world group whom Mayor's player groups also allow. Off without Mayor 0.5.0+. */
- MAYOR_WORLD_GROUP("mayor-world-group"),
+ /** Whoever Posse's player groups allow, the same as chat. Off (fail closed) if Posse 0.5.0+ isn't running. */
+ POSSE("posse"),
+ /** Players in the sender's world group whom Posse's player groups also allow. Off without Posse 0.5.0+. */
+ POSSE_WORLD_GROUP("posse-world-group"),
/** Players in the sender's exact world. */
WORLD("world"),
/** Players in the sender's world, counting its _nether and _the_end as the same world. */
@@ -52,22 +52,11 @@ public static ShareAudience of(String key) {
return null;
}
- /**
- * share.audience, or for a config written before it existed, the narrowest mode matching the older keys, so an
- * upgrade never widens sharing: enabled false is off; require-mayor true (their default) is mayor with
- * all-online and mayor-world-group otherwise; require-mayor false is world-group, because all-online without a
- * filtering plugin stayed in the world group. With none of them set, off. An unknown value is off.
- */
- public static ShareAudience resolve(String audience, Boolean enabled, Boolean requireMayor, String candidates) {
- if (audience != null) {
- ShareAudience a = of(audience);
- return a == null ? OFF : a;
- }
- if (enabled == null && requireMayor == null && candidates == null) return OFF;
- if (Boolean.FALSE.equals(enabled)) return OFF;
- boolean allOnline = "all-online".equalsIgnoreCase(candidates);
- if (!Boolean.FALSE.equals(requireMayor)) return allOnline ? MAYOR : MAYOR_WORLD_GROUP;
- return WORLD_GROUP;
+ /** share.audience. Nothing set is off, and so is an unknown value, which fails closed. */
+ public static ShareAudience resolve(String audience) {
+ if (audience == null) return OFF;
+ ShareAudience a = of(audience);
+ return a == null ? OFF : a;
}
}
@@ -177,13 +166,10 @@ public static HudConfig from(FileConfiguration c) {
c.getBoolean("pack.bedrock-exempt", true),
c.getBoolean("pack.re-send-on-removal", true));
- // Read without the jar's defaults, so an older config with no share.audience keeps what its old keys said.
+ // Read without the jar's defaults, so a config with no share.audience is off. Older share keys aren't read.
String audienceKey = c.contains("share.audience", true) ? c.getString("share.audience") : null;
Share share = new Share(
- ShareAudience.resolve(audienceKey,
- c.contains("share.enabled", true) ? c.getBoolean("share.enabled") : null,
- c.contains("share.require-mayor", true) ? c.getBoolean("share.require-mayor") : null,
- c.contains("share.candidates", true) ? c.getString("share.candidates") : null),
+ ShareAudience.resolve(audienceKey),
audienceKey != null && ShareAudience.of(audienceKey) == null,
clamp(c.getInt("share.cooldown-seconds", 30), 0, 3600),
c.getBoolean("share.log", true));
diff --git a/src/main/java/com/extantape/bluemapmini/share/ShareService.java b/src/main/java/com/extantape/bluemapmini/share/ShareService.java
index 7417bf6..4fd4da0 100644
--- a/src/main/java/com/extantape/bluemapmini/share/ShareService.java
+++ b/src/main/java/com/extantape/bluemapmini/share/ShareService.java
@@ -52,14 +52,14 @@ public static String worldGroup(String world) {
/**
* Whether a player in {@code otherWorld} can be offered a share from {@code senderWorld} under this audience
- * (D254). Mayor's mode offers everyone and leaves narrowing to Mayor through the share event; off offers nobody.
+ * (D254). Posse's mode offers everyone and leaves narrowing to Posse through the share event; off offers nobody.
*/
static boolean offered(HudConfig.ShareAudience audience, String senderWorld, String otherWorld) {
return switch (audience) {
case OFF -> false;
case WORLD -> senderWorld.equals(otherWorld);
- case WORLD_GROUP, MAYOR_WORLD_GROUP -> worldGroup(senderWorld).equals(worldGroup(otherWorld));
- case MAYOR, SERVER -> true;
+ case WORLD_GROUP, POSSE_WORLD_GROUP -> worldGroup(senderWorld).equals(worldGroup(otherWorld));
+ case POSSE, SERVER -> true;
};
}
@@ -90,7 +90,7 @@ public static Player findVisible(Player sender, String name) {
public String blocked(Player sender) {
if (config().audience() == HudConfig.ShareAudience.OFF) return "Sharing coordinates is turned off on this server.";
if (!com.extantape.bluemapmini.Perms.has(sender, SEND)) return "You can't share your coordinates here.";
- String guard = olderMayor();
+ String guard = olderPosse();
if (guard != null) {
plugin.getLogger().warning(guard);
return "Sharing coordinates is off on this server for now. An admin has been told why.";
@@ -188,28 +188,28 @@ private static String place(World world) {
}
/**
- * In Mayor's modes, shares follow Mayor's player groups, so they're off (fail closed) unless Mayor 0.5.0 or newer
- * is running. In every mode, a Mayor older than 0.5.0 turns sharing off, because it listens for a share event
- * BlueMapMini doesn't send and would let shares skip its groups. The version is null when Mayor isn't running.
+ * In Posse's modes, shares follow Posse's player groups, so they're off (fail closed) unless Posse 0.11.0 or newer
+ * is running. In every mode, a Posse older than 0.11.0 turns sharing off, because it listens for a share event
+ * BlueMapMini doesn't send and would let shares skip its groups. The version is null when Posse isn't running.
* Returns why sharing is off, or null.
*/
- static String mayorGuard(HudConfig.ShareAudience audience, String version) {
- boolean needsMayor = audience == HudConfig.ShareAudience.MAYOR || audience == HudConfig.ShareAudience.MAYOR_WORLD_GROUP;
- if (version == null && !needsMayor) return null;
- if (version == null) return "Coordinate sharing is off: share.audience follows Mayor's player groups, and Mayor isn't running. Install Mayor 0.5.0 or newer, or pick another share.audience.";
+ static String posseGuard(HudConfig.ShareAudience audience, String version) {
+ boolean needsPosse = audience == HudConfig.ShareAudience.POSSE || audience == HudConfig.ShareAudience.POSSE_WORLD_GROUP;
+ if (version == null && !needsPosse) return null;
+ if (version == null) return "Coordinate sharing is off: share.audience follows Posse's player groups, and Posse isn't running. Install Posse 0.11.0 or newer, or pick another share.audience.";
String[] p = version.split("[.-]");
try {
int major = Integer.parseInt(p[0]), minor = p.length > 1 ? Integer.parseInt(p[1]) : 0;
- if (major > 0 || minor >= 5) return null;
+ if (major > 0 || minor >= 11) return null;
} catch (NumberFormatException e) {
// Unreadable version: treat it as too old.
}
- return "Coordinate sharing is off because Mayor " + version + " can't see BlueMapMini's shares, so they'd skip its player groups. Update Mayor to 0.5.0 or newer.";
+ return "Coordinate sharing is off because Posse " + version + " can't see BlueMapMini's shares, so they'd skip its player groups. Update Posse to 0.11.0 or newer.";
}
- private String olderMayor() {
- org.bukkit.plugin.Plugin mayor = plugin.getServer().getPluginManager().getPlugin("Mayor");
- boolean on = mayor != null && mayor.isEnabled();
- return mayorGuard(config().audience(), on ? mayor.getPluginMeta().getVersion() : null);
+ private String olderPosse() {
+ org.bukkit.plugin.Plugin posse = plugin.getServer().getPluginManager().getPlugin("Posse");
+ boolean on = posse != null && posse.isEnabled();
+ return posseGuard(config().audience(), on ? posse.getPluginMeta().getVersion() : null);
}
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index bddfae1..908b166 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -129,16 +129,16 @@ share:
# /hud share sends a player's coordinates to people they choose. Nothing is ever shared automatically.
# Who they can send to:
# off nobody, sharing is off (the default)
- # mayor whoever Mayor's player groups allow, the same as chat. Needs Mayor 0.5.0 or newer; without it,
+ # posse whoever Posse's player groups allow, the same as chat. Needs Posse 0.11.0 or newer; without it,
# sharing stays off and the console says why
- # mayor-world-group players in the same world group (its _nether and _the_end count) whom Mayor's groups
- # also allow. Needs Mayor 0.5.0 or newer, like mayor
+ # posse-world-group players in the same world group (its _nether and _the_end count) whom Posse's groups
+ # also allow. Needs Posse 0.11.0 or newer, like posse
# world players in the same world
# world-group players in the same world, counting its _nether and _the_end as the same world
# server anyone online
# Any plugin that listens to the share event can still narrow a share. Players who turned shares off
# (/hud hide shares) or lack bluemapmini.share.receive are never offered. An unknown value counts as off.
- # A Mayor older than 0.5.0 turns sharing off in every mode.
+ # A Posse older than 0.11.0 turns sharing off in every mode.
audience: "off"
# Seconds a player waits between shares, so it can't be used to spam.
cooldown-seconds: 30
diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml
index fcd5406..e2ae176 100644
--- a/src/main/resources/paper-plugin.yml
+++ b/src/main/resources/paper-plugin.yml
@@ -17,6 +17,11 @@ dependencies:
load: BEFORE
required: false
join-classpath: true
+ # Optional. Its chat rules decide who may receive a share when share.audience is posse or posse-world-group.
+ Posse:
+ load: BEFORE
+ required: false
+ join-classpath: false
permissions:
bluemapmini.use:
description: See and control the minimap.
diff --git a/src/test/java/com/extantape/bluemapmini/config/ShareConfigTest.java b/src/test/java/com/extantape/bluemapmini/config/ShareConfigTest.java
index 72d0b48..26eeed1 100644
--- a/src/test/java/com/extantape/bluemapmini/config/ShareConfigTest.java
+++ b/src/test/java/com/extantape/bluemapmini/config/ShareConfigTest.java
@@ -24,11 +24,6 @@ void shippedDefaultIsOff() throws Exception {
assertEquals(HudConfig.ShareAudience.OFF, HudConfig.from(withJarDefaults("")).share().audience());
}
- @Test
- void olderFileWithRequireMayorBecomesMayorWithinTheWorldGroup() throws Exception {
- var c = withJarDefaults("share:\n enabled: true\n candidates: world-group\n require-mayor: true\n");
- assertEquals(HudConfig.ShareAudience.MAYOR_WORLD_GROUP, HudConfig.from(c).share().audience());
- }
@Test
void explicitAudienceIsRead() throws Exception {
@@ -52,9 +47,9 @@ void bareOffIsOffWithoutAWarning() throws Exception {
}
@Test
- void serverWithOldDefaultsAndAllOnlineBecomesMayor() throws Exception {
- // A live server's 0.3.0 file: enabled, all-online, require-mayor left at its old default (true).
- var c = withJarDefaults("share:\n enabled: true\n candidates: all-online\n cooldown-seconds: 30\n log: true\n");
- assertEquals(HudConfig.ShareAudience.MAYOR, HudConfig.from(c).share().audience());
+ void olderShareKeysAloneMeanOff() throws Exception {
+ // D196, D295: no old key is read. A file with only the pre-0.4.0 keys has no share.audience, so sharing is off.
+ var c = withJarDefaults("share:\n enabled: true\n candidates: all-online\n require-mayor: true\n cooldown-seconds: 30\n");
+ assertEquals(HudConfig.ShareAudience.OFF, HudConfig.from(c).share().audience());
}
}
diff --git a/src/test/java/com/extantape/bluemapmini/share/MayorGuardTest.java b/src/test/java/com/extantape/bluemapmini/share/MayorGuardTest.java
deleted file mode 100644
index ec8ff27..0000000
--- a/src/test/java/com/extantape/bluemapmini/share/MayorGuardTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.extantape.bluemapmini.share;
-
-import com.extantape.bluemapmini.config.HudConfig.ShareAudience;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-/** D254: who coordinates can be shared with, per share.audience, and Mayor's mode failing closed. */
-class MayorGuardTest {
- @Test
- void mayorModeIsOffWithoutMayorOrWithOneOlderThan05() {
- assertNotNull(ShareService.mayorGuard(ShareAudience.MAYOR, null), "no Mayor: fail closed");
- assertNotNull(ShareService.mayorGuard(ShareAudience.MAYOR, "0.4.0"), "0.4.x hooks a share event BlueMapMini no longer sends");
- assertNotNull(ShareService.mayorGuard(ShareAudience.MAYOR, "something odd"), "an unreadable version fails closed");
- }
-
- @Test
- void mayorModeIsOnWithMayor05OrNewer() {
- assertNull(ShareService.mayorGuard(ShareAudience.MAYOR, "0.5.0"));
- assertNull(ShareService.mayorGuard(ShareAudience.MAYOR, "0.7.0-SNAPSHOT"));
- assertNull(ShareService.mayorGuard(ShareAudience.MAYOR, "1.0.0"));
- }
-
- @Test
- void mayorWorldGroupFailsClosedLikeMayor() {
- assertNotNull(ShareService.mayorGuard(ShareAudience.MAYOR_WORLD_GROUP, null));
- assertNull(ShareService.mayorGuard(ShareAudience.MAYOR_WORLD_GROUP, "0.7.0"));
- assertTrue(ShareService.offered(ShareAudience.MAYOR_WORLD_GROUP, "survival", "survival_nether"));
- assertFalse(ShareService.offered(ShareAudience.MAYOR_WORLD_GROUP, "kids", "survival"));
- }
-
- @Test
- void anOldMayorTurnsEveryModeOff() {
- for (ShareAudience a : new ShareAudience[] {ShareAudience.WORLD, ShareAudience.WORLD_GROUP, ShareAudience.SERVER}) {
- assertNotNull(ShareService.mayorGuard(a, "0.4.0"), a.key);
- }
- }
-
- @Test
- void otherModesDoNotNeedMayor() {
- for (ShareAudience a : new ShareAudience[] {ShareAudience.WORLD, ShareAudience.WORLD_GROUP, ShareAudience.SERVER}) {
- assertNull(ShareService.mayorGuard(a, null), a.key);
- }
- }
-
- @Test
- void offOffersNobody() {
- assertFalse(ShareService.offered(ShareAudience.OFF, "survival", "survival"));
- }
-
- @Test
- void worldOffersOnlyTheSameWorld() {
- assertTrue(ShareService.offered(ShareAudience.WORLD, "survival", "survival"));
- assertFalse(ShareService.offered(ShareAudience.WORLD, "survival", "survival_nether"));
- assertFalse(ShareService.offered(ShareAudience.WORLD, "kids", "survival"));
- }
-
- @Test
- void worldGroupCountsNetherAndEnd() {
- assertTrue(ShareService.offered(ShareAudience.WORLD_GROUP, "survival", "survival_nether"));
- assertTrue(ShareService.offered(ShareAudience.WORLD_GROUP, "survival_the_end", "survival"));
- assertFalse(ShareService.offered(ShareAudience.WORLD_GROUP, "kids", "survival"));
- }
-
- @Test
- void serverAndMayorOfferEveryoneAndMayorNarrowsLater() {
- assertTrue(ShareService.offered(ShareAudience.SERVER, "kids", "survival"));
- assertTrue(ShareService.offered(ShareAudience.MAYOR, "kids", "survival"));
- }
-
- @Test
- void defaultsAndTyposAreOff() {
- assertEquals(ShareAudience.OFF, ShareAudience.resolve(null, null, null, null), "nothing set: off");
- assertEquals(ShareAudience.OFF, ShareAudience.resolve("everyone", null, null, null), "unknown value: off");
- assertEquals(ShareAudience.SERVER, ShareAudience.resolve(" Server ", null, null, null));
- }
-
- @Test
- void olderConfigsKeepWhatTheyHad() {
- assertEquals(ShareAudience.OFF, ShareAudience.resolve(null, false, true, "world-group"));
- assertEquals(ShareAudience.MAYOR_WORLD_GROUP, ShareAudience.resolve(null, true, null, "world-group"), "old defaults: Mayor AND world group");
- assertEquals(ShareAudience.MAYOR_WORLD_GROUP, ShareAudience.resolve(null, null, null, "world-group"));
- assertEquals(ShareAudience.MAYOR, ShareAudience.resolve(null, true, true, "all-online"));
- assertEquals(ShareAudience.WORLD_GROUP, ShareAudience.resolve(null, true, false, "world-group"));
- assertEquals(ShareAudience.WORLD_GROUP, ShareAudience.resolve(null, true, false, "all-online"), "all-online without a filter stayed in the world group");
- }
-
- @Test
- void migrationNeverOffersMoreThanTheOldSettingsDid() {
- // Old reach: world group always, all-online only through Mayor. Check who's offered, kid in kids to adult in survival.
- String[][] old = {{"true", "world-group"}, {"true", "all-online"}, {"false", "world-group"}, {"false", "all-online"}};
- for (String[] o : old) {
- ShareAudience a = ShareAudience.resolve(null, true, Boolean.parseBoolean(o[0]), o[1]);
- boolean crossWorldBefore = o[0].equals("true") && o[1].equals("all-online");
- assertEquals(crossWorldBefore, ShareService.offered(a, "kids", "survival"), String.join(",", o) + " -> " + a.key);
- assertTrue(ShareService.offered(a, "kids", "kids_nether"), "the world group was always offered");
- }
- }
-
- @Test
- void newSettingWinsOverOldKeys() {
- assertEquals(ShareAudience.WORLD, ShareAudience.resolve("world", true, true, "all-online"));
- }
-}
diff --git a/src/test/java/com/extantape/bluemapmini/share/PosseGuardTest.java b/src/test/java/com/extantape/bluemapmini/share/PosseGuardTest.java
new file mode 100644
index 0000000..9b2879c
--- /dev/null
+++ b/src/test/java/com/extantape/bluemapmini/share/PosseGuardTest.java
@@ -0,0 +1,96 @@
+package com.extantape.bluemapmini.share;
+
+import com.extantape.bluemapmini.config.HudConfig.ShareAudience;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/** D254: who coordinates can be shared with, per share.audience, and Posse's mode failing closed. */
+class PosseGuardTest {
+ @Test
+ void posseModeIsOffWithoutPosseOrWithOneOlderThan011() {
+ assertNotNull(ShareService.posseGuard(ShareAudience.POSSE, null), "no Posse: fail closed");
+ assertNotNull(ShareService.posseGuard(ShareAudience.POSSE, "0.4.0"), "0.4.x hooks a share event BlueMapMini no longer sends");
+ assertNotNull(ShareService.posseGuard(ShareAudience.POSSE, "something odd"), "an unreadable version fails closed");
+ }
+
+ @Test
+ void theOldMayorNameIsNotAnAudience() {
+ // D196: the old values are unknown, and an unknown value is off, so sharing stays off until the config is edited.
+ assertNull(ShareAudience.of("mayor"));
+ assertNull(ShareAudience.of("mayor-world-group"));
+ assertEquals(ShareAudience.OFF, ShareAudience.resolve("mayor"));
+ assertEquals(ShareAudience.OFF, ShareAudience.resolve("mayor-world-group"));
+ assertEquals(ShareAudience.POSSE, ShareAudience.of("posse"));
+ assertEquals(ShareAudience.POSSE_WORLD_GROUP, ShareAudience.of("posse-world-group"));
+ }
+
+ @Test
+ void aPosseOlderThanItsFirstReleaseUnderThatNameStaysOff() {
+ assertNotNull(ShareService.posseGuard(ShareAudience.POSSE, "0.10.0"));
+ }
+
+ @Test
+ void posseModeIsOnWithPosse011OrNewer() {
+ assertNull(ShareService.posseGuard(ShareAudience.POSSE, "0.11.0"));
+ assertNull(ShareService.posseGuard(ShareAudience.POSSE, "0.12.0-SNAPSHOT"));
+ assertNull(ShareService.posseGuard(ShareAudience.POSSE, "1.0.0"));
+ }
+
+ @Test
+ void posseWorldGroupFailsClosedLikePosse() {
+ assertNotNull(ShareService.posseGuard(ShareAudience.POSSE_WORLD_GROUP, null));
+ assertNull(ShareService.posseGuard(ShareAudience.POSSE_WORLD_GROUP, "0.11.0"));
+ assertTrue(ShareService.offered(ShareAudience.POSSE_WORLD_GROUP, "survival", "survival_nether"));
+ assertFalse(ShareService.offered(ShareAudience.POSSE_WORLD_GROUP, "kids", "survival"));
+ }
+
+ @Test
+ void anOldPosseTurnsEveryModeOff() {
+ for (ShareAudience a : new ShareAudience[] {ShareAudience.WORLD, ShareAudience.WORLD_GROUP, ShareAudience.SERVER}) {
+ assertNotNull(ShareService.posseGuard(a, "0.4.0"), a.key);
+ }
+ }
+
+ @Test
+ void otherModesDoNotNeedPosse() {
+ for (ShareAudience a : new ShareAudience[] {ShareAudience.WORLD, ShareAudience.WORLD_GROUP, ShareAudience.SERVER}) {
+ assertNull(ShareService.posseGuard(a, null), a.key);
+ }
+ }
+
+ @Test
+ void offOffersNobody() {
+ assertFalse(ShareService.offered(ShareAudience.OFF, "survival", "survival"));
+ }
+
+ @Test
+ void worldOffersOnlyTheSameWorld() {
+ assertTrue(ShareService.offered(ShareAudience.WORLD, "survival", "survival"));
+ assertFalse(ShareService.offered(ShareAudience.WORLD, "survival", "survival_nether"));
+ assertFalse(ShareService.offered(ShareAudience.WORLD, "kids", "survival"));
+ }
+
+ @Test
+ void worldGroupCountsNetherAndEnd() {
+ assertTrue(ShareService.offered(ShareAudience.WORLD_GROUP, "survival", "survival_nether"));
+ assertTrue(ShareService.offered(ShareAudience.WORLD_GROUP, "survival_the_end", "survival"));
+ assertFalse(ShareService.offered(ShareAudience.WORLD_GROUP, "kids", "survival"));
+ }
+
+ @Test
+ void serverAndPosseOfferEveryoneAndPosseNarrowsLater() {
+ assertTrue(ShareService.offered(ShareAudience.SERVER, "kids", "survival"));
+ assertTrue(ShareService.offered(ShareAudience.POSSE, "kids", "survival"));
+ }
+
+ @Test
+ void defaultsAndTyposAreOff() {
+ assertEquals(ShareAudience.OFF, ShareAudience.resolve(null), "nothing set: off");
+ assertEquals(ShareAudience.OFF, ShareAudience.resolve("everyone"), "unknown value: off");
+ assertEquals(ShareAudience.SERVER, ShareAudience.resolve(" Server "));
+ }
+
+
+
+}
diff --git a/test/live/README.md b/test/live/README.md
index 74fbd46..4f2ab69 100644
--- a/test/live/README.md
+++ b/test/live/README.md
@@ -8,7 +8,7 @@ These run BlueMapMini on a real Paper server with real BlueMap tiles, and drive
- **Real:** Paper, BlueMap, the plugin jar, the generated pack, BlueMap's tiles and SQL storage.
- **A bot, not the game:** the client is [mineflayer](https://github.com/PrismarineJS/mineflayer), which speaks the 1.21.11 protocol, so it joins 26.x through ViaVersion and ViaBackwards. It doesn't draw anything. Frames are decoded with a model of the client's font rules.
-- **Real Mayor** in the `mayor` test only.
+- **Real Posse** in the `posse` test only.
- **Simulated:** the helper plugin acts like other plugins: vanish, boss bars, permissions, POI markers, a pack sent with the old one-pack method the way Magic does it, and a chat rules plugin that filters `CoordinateShareEvent`. The pack host for `public-url` is a local stand-in.
- **Not covered:** pressing the buttons in the `/hud share` dialog. The bot checks the dialog it's sent, but its protocol library has no packet for clicking one. The buttons run Paper's own callbacks into the same code `/hud share