diff --git a/CHANGELOG.md b/CHANGELOG.md index 22a848b..f84fde8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.8.1 + +- **Pigs, cows, chickens and frogs also glow in their coat.** They have only three looks each, so a look repeats for three or four coats; now they also glow in the coat's color and leave its trail, so every coat looks different. Wolves and cats keep the variant only. The list is `glow-too` in `coats.yml`. A copy of `coats.yml` already in `plugins/MobSquad` without that line gets the built-in list. A name that isn't a variant critter is skipped with a warning. +- **No-glow worlds.** A glow outline shows through walls, so in a kids' world it could lead others to where a kid is building. Worlds listed under `spirit-coats.no-glow-worlds` in `config.yml` show coats without the outline: critters keep their variant and their coat's trail, and particles don't show through blocks. The outline goes off as soon as the owner enters such a world, the trail there is sent only within 32 blocks, and a no-glow world that isn't also a coat world (a likely typo) is warned about in the log. Empty by default. +- Tested: unit tests (46). The bot suite's coat checks were updated for the chicken's glow and no-glow worlds but haven't been rerun yet; that run comes before any live install. Not seen in a real game client. + ## 0.8.0 Spirit coats. diff --git a/README.md b/README.md index 3e91e18..943a573 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Coax mobs into critters for Paper: they follow you, fight only hostile mobs, and live safely in a shared Bunkhouse. No client mods. Gotta coax em all... Pokemob! -**Status:** 0.8.0. Spirit coats. Passed with bots on throwaway Paper 26.1.2 and 26.2 servers (the full suite, 197 checks each) and on 26.3 (95 checks), then the Bunkhouse and coats parts again on all three after a last small change (43 checks on 26.1.2 and 26.2, 26 on 26.3). On 26.3 the bots can't use blocks, so the Bunkhouse menu, picking a coat in it and everything sent out from it didn't run there; the coats themselves ran, with the sidekick getting critters out. Bots can't crouch where the server sees it, so the creeper and fox puzzles were tested with a test-only stand-in for crouching; real crouching is untested. The daily sidekick roll is covered by unit tests only, since it needs 10 hours out. Nothing has been seen in a real game client yet, so how the glow, the particle trail and the chicken variants look is unchecked. Wolves, cats, pigs, cows and frogs aren't critters yet; only the chicken's variants ran on a server. The AuraSkills and Multiverse checks from 0.6.0 weren't rerun. +**Status:** 0.8.1. Spirit coats; in 0.8.1 pigs, cows, chickens and frogs also glow and worlds can be set to no glow, checked by unit tests only so far. 0.8.0 passed with bots on throwaway Paper 26.1.2 and 26.2 servers (the full suite, 197 checks each) and on 26.3 (95 checks), then the Bunkhouse and coats parts again on all three after a last small change (43 checks on 26.1.2 and 26.2, 26 on 26.3). On 26.3 the bots can't use blocks, so the Bunkhouse menu, picking a coat in it and everything sent out from it didn't run there; the coats themselves ran, with the sidekick getting critters out. Bots can't crouch where the server sees it, so the creeper and fox puzzles were tested with a test-only stand-in for crouching; real crouching is untested. The daily sidekick roll is covered by unit tests only, since it needs 10 hours out. Nothing has been seen in a real game client yet, so how the glow, the particle trail and the chicken variants look is unchecked. Wolves, cats, pigs, cows and frogs aren't critters yet; only the chicken's variants ran on a server. The AuraSkills and Multiverse checks from 0.6.0 weren't rerun. ## What it does @@ -20,7 +20,7 @@ Coax mobs into critters for Paper: they follow you, fight only hostile mobs, and - Skeleton: covering fire from 15 blocks, reaching further and shooting faster at each milestone. From level 25 it shares two arrows every 2 minutes while you carry a bow or crossbow. - Iron golem: takes a quarter of any hostile mob's hit on you within 8 blocks, and throws the mobs it hits back. - **La Ménagerie.** Your journal, with a page for each critter: its Critterbook number, a line about it, how to coax it and its special. A page opens the first time you're within 10 blocks of that critter and can see it, or when you get one. `/mobsquad journal` or the book in the Bunkhouse menu opens it. Critterbook numbers follow the order each mob first appeared in Minecraft Java Edition, so the creeper is No. 1 and the allay No. 75. Every mob in the game has a number already, and the numbers never change. -- **Spirit coats.** A critter earns a new coat every 10 levels, ten in all, and keeps them. Coats show only in the worlds listed under `spirit-coats.worlds` in `config.yml`, which is empty to start with, so critters look normal everywhere until an admin lists a world. Wolves, cats, pigs, cows, chickens and frogs wear a real variant; every other critter glows in the coat's color and leaves a light particle trail, only for players who haven't turned particles to minimal. Right-click a critter in the Bunkhouse to pick the coat it wears from the ones it has earned; the default is the newest. The names, colors, particles and variants are in `plugins/MobSquad/coats.yml`. The journal lists each critter's coats, with the locked ones as the level that earns them. +- **Spirit coats.** A critter earns a new coat every 10 levels, ten in all, and keeps them. Coats show only in the worlds listed under `spirit-coats.worlds` in `config.yml`, which is empty to start with, so critters look normal everywhere until an admin lists a world. Wolves, cats, pigs, cows, chickens and frogs wear a real variant. Every other critter glows in the coat's color and leaves a light particle trail, and so do pigs, cows, chickens and frogs, whose three looks repeat across coats (`glow-too` in `coats.yml`). The trail shows only for players who haven't turned particles to minimal. Worlds under `spirit-coats.no-glow-worlds` show coats without the glow outline, which shows through walls; list kids' worlds there. Right-click a critter in the Bunkhouse to pick the coat it wears from the ones it has earned; the default is the newest. The names, colors, particles and variants are in `plugins/MobSquad/coats.yml`. The journal lists each critter's coats, with the locked ones as the level that earns them. - **The sidekick.** A critter that has spent 10 hours out with you has a 1 in 10 chance each day of becoming your sidekick. It goes everywhere with you: it comes out when you join, after a world change and after a rest, and the Bunkhouse menu, its bell and the dinnerbell leave it be. It doesn't count toward your posse. One per player. - **Vittles.** Right-click them to perk up a tuckered-out critter on the spot. Craft two from bread, a carrot and sweet berries. - **Bunkhouses.** An admin marks a vault block as a Bunkhouse. Anyone who right-clicks it sees only their own critters. Click one to send it out or call it back. Critters never exist as items, so they can't be dropped, traded or duplicated. @@ -36,7 +36,7 @@ Coax mobs into critters for Paper: they follow you, fight only hostile mobs, and Paper 26.1 or newer, Java 25. Drop `MobSquad-.jar` into `plugins` and restart. To build it yourself: `./gradlew build`, and the jar is in `build/libs`. -Settings are in `plugins/MobSquad/config.yml`: worlds where MobSquad is off, the rest time after tuckering out, the Wranglin' experience for a coax, and `spirit-coats.worlds`, the worlds where spirit coats show. `coats.yml` beside it holds each coat's name, glow color, particle and variants; a line you get wrong is skipped with a warning and the built-in one stays. +Settings are in `plugins/MobSquad/config.yml`: worlds where MobSquad is off, the rest time after tuckering out, the Wranglin' experience for a coax, `spirit-coats.worlds`, the worlds where spirit coats show, and `spirit-coats.no-glow-worlds`, the ones among them where coats show without the glow outline. `coats.yml` beside it holds each coat's name, glow color, particle and variants; a line you get wrong is skipped with a warning and the built-in one stays. ## Commands diff --git a/build.gradle.kts b/build.gradle.kts index 3f0e713..6f12074 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "com.extantape" -version = "0.8.0" +version = "0.8.1" java { toolchain.languageVersion.set(JavaLanguageVersion.of(25)) diff --git a/docs/decisions.md b/docs/decisions.md index 358417b..a440bec 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -41,11 +41,16 @@ Dated decisions for this repo, newest last. - **Spirit coats (0.8.0), from the owner's brief ("Levels and spirit coats").** A coat every 10 levels, coat 1 at level 10 to coat 10 at level 100, shown only in worlds listed under `spirit-coats.worlds` (empty by default). Written by the lead for the owner's say, so they stand unless he changes them: - The ten names and glow colors: Ember (red), Marigold (gold), Sunbeam (yellow), Meadow (green), Pine (dark green), Lagoon (aqua), Frost (blue), Twilight (dark purple), Blossom (light purple), Starlight (white). Names are plain and always shown with the color. Dark colors are written in a lighter color in text, so every coat name reads on the dark menu. - The trail particles (flame, wax_on, glow, happy_villager, composter, bubble_pop, snowflake, witch, cherry_leaves, end_rod) are about 4 a second per critter. - - Pigs, cows, chickens and frogs have three variants, so each look lasts for 3 or 4 coats in a row; wolves have nine (coat 10 repeats the pale wolf) and cats eleven. Variant critters get no glow or trail, as the brief says. + - Pigs, cows, chickens and frogs have three variants, so each look lasts for 3 or 4 coats in a row; wolves have nine (coat 10 repeats the pale wolf) and cats eleven. Variant critters got no glow or trail in 0.8.0, as the brief said; see the 2026-11-22 picks below for pigs, cows, chickens and frogs. - A pick is stored with the critter as a ninth field; 0 means "the newest earned", so older files and critters that never picked keep following new coats. A pick the critter hasn't earned (an admin lowered its level) shows the newest earned instead. - Choosing is a right-click on the critter in the Bunkhouse. Left-click still sends it out. - Glow uses scoreboard teams named `ms_coat_1` to `ms_coat_10` on the main scoreboard, removed on start and stop. - `/mobsquad level` can lower a critter's level, which hides coats it no longer has the level for. Normal play never lowers a level. +- **Spirit coat picks (owner, Simon chat, 2026-11-22), relayed by the chief of staff:** + - Coat names: "Keep them (Recommended)". The ten names and colors above stand. + - Pigs, cows, chickens and frogs: "Add glow and trail (Recommended)". They wear their variant and also glow in the coat's color with its trail, so each coat looks different even where the three looks repeat. Wolves and cats keep the variant only. It's the `glow-too` list in `coats.yml` (0.8.1), so an admin can change it. + - Magic worlds: "We have two magic worlds…? One adult and one kid one." On Sonoran those are `magic` and `ninos_magic` (both exist there; checked 2026-11-22). Listing them in `spirit-coats.worlds` is a live change and waits for the owner's go. +- **No-glow worlds (lead, 2026-11-22, kids first).** The trust-and-safety review found the glow outline shows through walls to everyone tracking the critter in that world, and a coated critter is always near its owner, so in `ninos_magic` it could point to a kid's hidden base. 0.8.1 adds `spirit-coats.no-glow-worlds` (empty by default): coats there keep their variant and trail but get no outline. The outline goes off when the owner enters, before the critter follows; the trail there is sent only within 32 blocks; a no-glow entry that isn't a coat world is warned about at start, since the setting fails open on a typo. The live go request proposes `ninos_magic` there; the owner decides. ## 2026-11-15 diff --git a/docs/test-audit.md b/docs/test-audit.md index 2f3a198..854961e 100644 --- a/docs/test-audit.md +++ b/docs/test-audit.md @@ -86,6 +86,8 @@ Kept by this repo's owning session, per `~/Code/CLAUDE.md`, "Test self-audits". | Leaving or unlisting a world takes the look off at once; entering applies it | bot: unlist and relist, and the nether hop | | Real variants for chickens (and the other five, in the data file) | bot (chicken, 26.1.2, 26.2, 26.3); unit data tests for the rest | | Glow and trail for the others; cheap; none beyond view distance or on minimal | bot: team and glow, packet counts, a far bot, minimal particles | +| Pigs, cows, chickens and frogs also glow (glow-too, 0.8.1); wolves and cats don't; the list can be changed and bad entries are skipped | unit `theBundledCoatsLoadCleanlyAndReadWell`, `glowTooCanBeChangedAndBadEntriesAreSkipped`; bot: the chicken's glow and team (written 2026-11-22, not yet run) | +| No-glow worlds drop only the outline, keeping the coat and trail (kids' safety) | unit `noGlowWorldsTurnOnlyTheOutlineOff`, `theBundledConfigListsNoWorlds`; bot: no-glow on and off with the bee and chicken (written 2026-11-22, not yet run) | | Bad lines in coats.yml are skipped with a warning, never a crash | unit `badEntriesAreSkippedWithAWarningAndTheRestLoad`, `aFileThatIsNotYamlLeavesTheBuiltInCoats`, `theBundledCoatsLoadCleanlyAndReadWell` | | Journal shows earned coats by name and locked ones as "Level 30" | unit `CoatJournalTest` | | Names and menu text readable, never color alone | unit `theBundledCoatsLoadCleanlyAndReadWell` (readable colors, distinct names); every coat line carries its name | diff --git a/src/main/java/com/extantape/mobsquad/Settings.java b/src/main/java/com/extantape/mobsquad/Settings.java index 996617e..4e0b636 100644 --- a/src/main/java/com/extantape/mobsquad/Settings.java +++ b/src/main/java/com/extantape/mobsquad/Settings.java @@ -6,12 +6,17 @@ import org.bukkit.configuration.file.FileConfiguration; /** The settings in config.yml, read once and checked. */ -public record Settings(Set disabledWorlds, int recoveryMinutes, int coaxXp, Set coatWorlds) { +public record Settings(Set disabledWorlds, int recoveryMinutes, int coaxXp, Set coatWorlds, Set noGlowWorlds) { public static Settings read(FileConfiguration c, Logger log) { - return new Settings(new HashSet<>(c.getStringList("disabled-worlds")), + Settings s = new Settings(new HashSet<>(c.getStringList("disabled-worlds")), clamp(c.getInt("recovery-minutes", 5), 0, 1440, "recovery-minutes", log), clamp(c.getInt("coax-xp", 100), 0, 100000, "coax-xp", log), - new HashSet<>(c.getStringList("spirit-coats.worlds"))); + new HashSet<>(c.getStringList("spirit-coats.worlds")), + new HashSet<>(c.getStringList("spirit-coats.no-glow-worlds"))); + for (String w : s.noGlowWorlds) + if (!s.coatWorlds.contains(w)) + log.warning("spirit-coats.no-glow-worlds lists \"" + w + "\", which isn't under spirit-coats.worlds. Check the spelling: a world that's misspelled there gets the glow."); + return s; } public boolean enabledIn(String world) { @@ -23,6 +28,15 @@ public boolean coatsIn(String world) { return coatWorlds.contains(world); } + /** + * Whether coats may glow in this world. A glow outline shows through walls, so it can lead others to where a + * critter's owner is; worlds under spirit-coats.no-glow-worlds (such as a kids' world) show the coat's look and + * trail without it. + */ + public boolean glowIn(String world) { + return !noGlowWorlds.contains(world); + } + static int clamp(int v, int min, int max, String key, Logger log) { if (v >= min && v <= max) return v; int to = Math.max(min, Math.min(max, v)); diff --git a/src/main/java/com/extantape/mobsquad/model/CoatData.java b/src/main/java/com/extantape/mobsquad/model/CoatData.java index 4ca4e07..60dc131 100644 --- a/src/main/java/com/extantape/mobsquad/model/CoatData.java +++ b/src/main/java/com/extantape/mobsquad/model/CoatData.java @@ -1,6 +1,8 @@ package com.extantape.mobsquad.model; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -13,8 +15,10 @@ /** * What each spirit coat looks like, read from {@code coats.yml} (bundled in the jar, overridable from the plugin * folder). Each of the ten coats has a plain name, a glow color and a particle; the six critters with real variants - * (wolf, cat, pig, cow, chicken, frog) also name the variant each coat wears. A bad entry is skipped with a warning and - * the rest still load, so a typo in the data file never stops the plugin. + * (wolf, cat, pig, cow, chicken, frog) also name the variant each coat wears, and {@code glow-too} lists the variant + * critters that also get the glow and trail (the owner's pick, 2026-11-22: pigs, cows, chickens and frogs, whose three + * looks repeat across coats). A bad entry is skipped with a warning and the rest still load, so a typo in the data file + * never stops the plugin. */ public final class CoatData { /** The critters that have real data-driven variants. */ @@ -30,14 +34,16 @@ public interface Validator { boolean variant(String species, String key); } - public static final CoatData EMPTY = new CoatData(Map.of(), Map.of()); + public static final CoatData EMPTY = new CoatData(Map.of(), Map.of(), Set.of()); private final Map coats; private final Map> variants; + private final Set glowToo; - private CoatData(Map coats, Map> variants) { + private CoatData(Map coats, Map> variants, Set glowToo) { this.coats = coats; this.variants = variants; + this.glowToo = glowToo; } /** The coat's data; a plain "Coat 3" with no particle when the file has nothing usable for it. */ @@ -56,11 +62,16 @@ public String variant(String species, int coat) { return m == null ? null : m.get(coat); } - /** Whether a species has any variant set, so it wears variants instead of a glow. */ + /** Whether a species has any variant set, so it wears a variant in each coat. */ public boolean hasVariants(String species) { return variants.containsKey(species); } + /** Whether a species glows and leaves a trail in its coats: every critter without variants, plus those in glow-too. */ + public boolean glows(String species) { + return !hasVariants(species) || glowToo.contains(species); + } + /** * Reads {@code yaml} over {@code base}: each good entry replaces the base's, each bad one is skipped with a warning. * A file that isn't YAML at all is skipped whole, leaving the base. @@ -92,6 +103,20 @@ public static CoatData parse(String yaml, Validator v, Logger log, CoatData base } coats.put(i, new Coat(i, name.strip(), color, particle)); } + Set glowToo = base.glowToo; + if (y.contains("glow-too")) { + if (!y.isList("glow-too")) { + log.warning("coats.yml: glow-too should be a list of critters, such as [pig, cow]. Skipped."); + } else { + Set g = new HashSet<>(); + for (String species : y.getStringList("glow-too")) { + String sp = species.strip().toLowerCase(Locale.ROOT); + if (!VARIANT_SPECIES.contains(sp)) { log.warning("coats.yml: glow-too names \"" + species + "\", which isn't a critter with variants (it glows anyway). Skipped."); continue; } + g.add(sp); + } + glowToo = Set.copyOf(g); + } + } ConfigurationSection vs = y.getConfigurationSection("variants"); if (vs != null) for (String species : vs.getKeys(false)) { if (!VARIANT_SPECIES.contains(species)) { log.warning("coats.yml: \"" + species + "\" has no variants to set. Skipped."); continue; } @@ -107,7 +132,7 @@ public static CoatData parse(String yaml, Validator v, Logger log, CoatData base } Map> frozen = new HashMap<>(); variants.forEach((k, m) -> frozen.put(k, Map.copyOf(m))); - return new CoatData(Map.copyOf(coats), Map.copyOf(frozen)); + return new CoatData(Map.copyOf(coats), Map.copyOf(frozen), glowToo); } private static Integer index(String k) { diff --git a/src/main/java/com/extantape/mobsquad/world/SpiritCoats.java b/src/main/java/com/extantape/mobsquad/world/SpiritCoats.java index e61345b..c82d04b 100644 --- a/src/main/java/com/extantape/mobsquad/world/SpiritCoats.java +++ b/src/main/java/com/extantape/mobsquad/world/SpiritCoats.java @@ -24,8 +24,10 @@ /** * Shows each out critter's spirit coat, only in the worlds listed under {@code spirit-coats.worlds}. Wolves, cats, pigs, - * cows, chickens and frogs wear a real variant; every other critter gets a glow in the coat's color (a scoreboard team - * color) and a light particle trail. Nothing here is saved: the look is put on when a critter goes out and whenever its + * cows, chickens and frogs wear a real variant. Every other critter, and the variant critters listed under glow-too + * (pigs, cows, chickens and frogs by default), gets a glow in the coat's color (a scoreboard team color) and a light + * particle trail; in worlds under spirit-coats.no-glow-worlds they keep the trail but get no outline, which shows + * through walls. Nothing here is saved: the look is put on when a critter goes out and whenever its * coat or world changes, and taken off at once when its owner leaves a magic world. * * The trail is a couple of particles every half second, sent only to players within their own view distance, and never @@ -34,6 +36,8 @@ public final class SpiritCoats implements Runnable, Listener { public static final long PERIOD = 10; private static final String TEAM = "ms_coat_"; + /** How far a trail is sent in a no-glow world, in blocks. */ + static final double NO_GLOW_TRAIL_RANGE = 32; private final Squads squads; private final Posse posse; private CoatData data = CoatData.EMPTY; @@ -41,7 +45,10 @@ public final class SpiritCoats implements Runnable, Listener { private final Map shown = new HashMap<>(); /** A variant critter's look before the coat, to put back. */ private final Map originals = new HashMap<>(); + /** Critters with the outline glow on (never in a no-glow world). */ private final Set glowing = new HashSet<>(); + /** Critters that leave their coat's trail. */ + private final Set trailing = new HashSet<>(); private final Map particles = new HashMap<>(); private int beat; @@ -82,22 +89,29 @@ private int wanted(Posse.Out o) { public void apply(Posse.Out o) { UUID id = o.critter().id(); int want = wanted(o); - if (want == shown.getOrDefault(id, 0)) return; + Player owner = Bukkit.getPlayer(o.owner()); + // Both the critter's world and its owner's, so the outline is off the moment the owner enters a no-glow world, + // before the critter follows. + boolean glow = want != 0 && data.glows(o.critter().species().id()) && squads.settings().glowIn(o.mob().getWorld().getName()) + && owner != null && squads.settings().glowIn(owner.getWorld().getName()); + if (want == shown.getOrDefault(id, 0) && glow == glowing.contains(id)) return; take(o); - if (want != 0) put(o, want); + if (want != 0) put(o, want, glow); if (want == 0) shown.remove(id); else shown.put(id, want); } - private void put(Posse.Out o, int coat) { + private void put(Posse.Out o, int coat, boolean glow) { Mob m = o.mob(); String species = o.critter().species().id(); if (data.hasVariants(species)) { String key = data.variant(species, coat); String before = Variants.current(m); if (key != null && Variants.set(m, key)) originals.putIfAbsent(o.critter().id(), before); - return; } + if (!data.glows(species)) return; + trailing.add(o.critter().id()); + if (!glow) return; m.setGlowing(true); glowing.add(o.critter().id()); Team t = team(coat); @@ -111,6 +125,7 @@ private void take(Posse.Out o) { String was = originals.remove(id); if (was != null && m.isValid()) Variants.set(m, was); } + trailing.remove(id); if (glowing.remove(id)) { Integer coat = shown.get(id); if (m.isValid()) m.setGlowing(false); @@ -163,14 +178,14 @@ private Particle particle(String key) { return particles.computeIfAbsent(key, k -> Registry.PARTICLE_TYPE.get(NamespacedKey.minecraft(k))); } - /** Every half second: checks each critter's look, then leaves a light trail behind the ones that glow. */ + /** Every half second: checks each critter's look, then leaves a light trail behind the ones that have one. */ @Override public void run() { beat++; for (Posse.Out o : List.copyOf(posse.all())) { apply(o); UUID id = o.critter().id(); - if (!glowing.contains(id)) continue; + if (!trailing.contains(id)) continue; String key = data.coat(shown.getOrDefault(id, 0)).particle(); Particle particle = key == null ? null : particle(key); Mob m = o.mob(); @@ -181,6 +196,8 @@ public void run() { if (vis == ClientOption.ParticleVisibility.MINIMAL) continue; if (vis == ClientOption.ParticleVisibility.DECREASED && beat % 2 == 0) continue; double range = Math.min(p.getViewDistance(), Bukkit.getViewDistance()) * 16.0; + // In a no-glow world (a kids' world) the trail is kept close, so it can't mark an owner from far off. + if (!squads.settings().glowIn(m.getWorld().getName())) range = Math.min(range, NO_GLOW_TRAIL_RANGE); if (p.getLocation().distanceSquared(at) > range * range || !p.canSee(m)) continue; p.spawnParticle(particle, at, 2, 0.3, 0.3, 0.3, 0); } diff --git a/src/main/resources/coats.yml b/src/main/resources/coats.yml index 27e6bc1..1445280 100644 --- a/src/main/resources/coats.yml +++ b/src/main/resources/coats.yml @@ -11,6 +11,8 @@ # chat, so no one has to tell colors apart. # variants: for wolves, cats, pigs, cows, chickens and frogs, the real variant each coat wears, by coat number. # A coat left out wears the critter's normal look. +# glow-too: critters from that list that also glow in the coat's color and leave its trail. Pigs, cows, chickens and +# frogs have only three looks, so the glow tells one coat from the next. Wolves and cats have enough looks without it. coats: 1: { name: Ember, color: red, particle: flame } @@ -24,6 +26,8 @@ coats: 9: { name: Blossom, color: light_purple, particle: cherry_leaves } 10: { name: Starlight, color: white, particle: end_rod } +glow-too: [pig, cow, chicken, frog] + variants: # Wolves have nine variants, so coat 10 repeats the pale wolf. wolf: { 1: rusty, 2: chestnut, 3: woods, 4: striped, 5: spotted, 6: ashen, 7: snowy, 8: black, 9: pale, 10: pale } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dabd4dc..7a9a836 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -13,5 +13,9 @@ coax-xp: 100 # Magic worlds, by folder name: the only places critters show their spirit coats. Empty means coats show nowhere, and # critters look normal. Coats are still earned, chosen and listed in the journal. Leaving a magic world removes the look # at once; entering one applies it. Each coat's name, color, particle and variants are in coats.yml. +# no-glow-worlds: magic worlds where coats show without the glow outline. The outline shows through walls, so it can +# lead other players to where a critter's owner is building. Critters there still wear their variant and leave their +# coat's trail. List kids' worlds here. spirit-coats: worlds: [] + no-glow-worlds: [] diff --git a/src/test/java/com/extantape/mobsquad/CoatTest.java b/src/test/java/com/extantape/mobsquad/CoatTest.java index eca55ec..a7940a5 100644 --- a/src/test/java/com/extantape/mobsquad/CoatTest.java +++ b/src/test/java/com/extantape/mobsquad/CoatTest.java @@ -172,6 +172,26 @@ void coatsShowNowhereUntilAnAdminListsAWorld() { assertFalse(some.coatsIn("Storybook"), "world names match exactly"); } + @Test + void noGlowWorldsTurnOnlyTheOutlineOff() { + Settings none = Settings.read(new YamlConfiguration(), Logger.getAnonymousLogger()); + assertTrue(none.glowIn("magic"), "glow is allowed unless a world is listed"); + YamlConfiguration y = new YamlConfiguration(); + y.set("spirit-coats.worlds", List.of("magic", "ninos_magic")); + y.set("spirit-coats.no-glow-worlds", List.of("ninos_magic")); + Settings s = Settings.read(y, Logger.getAnonymousLogger()); + assertTrue(s.coatsIn("ninos_magic"), "coats still show there"); + assertFalse(s.glowIn("ninos_magic"), "without the outline"); + assertTrue(s.glowIn("magic")); + + Warnings warn = new Warnings(); + YamlConfiguration typo = new YamlConfiguration(); + typo.set("spirit-coats.worlds", List.of("ninos_magic")); + typo.set("spirit-coats.no-glow-worlds", List.of("ninos_majic")); + Settings.read(typo, logger(warn)); + assertEquals(1, warn.messages.size(), "a no-glow world that isn't a coat world is warned about: " + warn.messages); + } + @Test void theBundledConfigListsNoWorlds() throws Exception { YamlConfiguration y = new YamlConfiguration(); @@ -180,6 +200,8 @@ void theBundledConfigListsNoWorlds() throws Exception { } assertTrue(y.contains("spirit-coats.worlds")); assertTrue(Settings.read(y, Logger.getAnonymousLogger()).coatWorlds().isEmpty()); + assertTrue(y.contains("spirit-coats.no-glow-worlds")); + assertTrue(Settings.read(y, Logger.getAnonymousLogger()).noGlowWorlds().isEmpty()); } // ---- the data file ---- @@ -207,6 +229,9 @@ void theBundledCoatsLoadCleanlyAndReadWell() throws Exception { for (int i = 1; i <= Coats.COUNT; i++) assertNotNull(d.variant(species, i), species + " coat " + i); } assertFalse(d.hasVariants("creeper"), "a creeper glows instead"); + assertTrue(d.glows("creeper"), "a critter without variants glows"); + for (String species : Set.of("pig", "cow", "chicken", "frog")) assertTrue(d.glows(species), species + " glows too (owner, 2026-11-22)"); + for (String species : Set.of("wolf", "cat")) assertFalse(d.glows(species), species + " wears its variant only"); assertNull(d.variant("creeper", 1)); } @@ -259,4 +284,26 @@ void anEmptyDataSetStillNamesEveryCoat() { assertNull(CoatData.EMPTY.coat(3).particle()); assertNull(CoatData.EMPTY.variant("wolf", 3)); } + + @Test + void glowTooCanBeChangedAndBadEntriesAreSkipped() throws Exception { + CoatData base = CoatData.parse(bundled(), allow(Set.of()), logger(new Warnings()), CoatData.EMPTY); + Warnings warn = new Warnings(); + CoatData d = CoatData.parse("glow-too: [wolf, Cow, creeper, dragon]\n", allow(Set.of()), logger(warn), base); + assertTrue(d.glows("wolf")); + assertTrue(d.glows("cow"), "names are read without regard to case"); + assertFalse(d.glows("pig"), "a list replaces the built-in one"); + assertTrue(d.glows("creeper"), "a critter without variants glows anyway"); + assertEquals(2, warn.messages.size(), "creeper and dragon are skipped with a warning: " + warn.messages); + + Warnings warn2 = new Warnings(); + CoatData kept = CoatData.parse("glow-too: pig\n", allow(Set.of()), logger(warn2), base); + assertTrue(kept.glows("frog"), "a value that isn't a list keeps the built-in list"); + assertEquals(1, warn2.messages.size()); + + CoatData none = CoatData.parse("glow-too: []\n", allow(Set.of()), logger(new Warnings()), base); + assertFalse(none.glows("pig"), "an empty list turns it off"); + assertTrue(CoatData.parse("coats: {}\n", allow(Set.of()), logger(new Warnings()), base).glows("pig"), + "a file without glow-too keeps the built-in list"); + } } diff --git a/test/suite.mjs b/test/suite.mjs index 19e4373..cc90fde 100644 --- a/test/suite.mjs +++ b/test/suite.mjs @@ -858,8 +858,8 @@ if (want('sidekick')) { if (want('coats')) { section('Spirit coats') const CX = X + 40, CZ = Z - 40 - const writeWorlds = async list => { - writeFileSync(cfgFile, baseConfig.replace(/^ worlds: .*$/m, ` worlds: [${list}]`)) + const writeWorlds = async (list, noGlow = '') => { + writeFileSync(cfgFile, baseConfig.replace(/^ worlds: .*$/m, ` worlds: [${list}]`).replace(/^ no-glow-worlds: .*$/m, ` no-glow-worlds: [${noGlow}]`)) const out = (await s.ask('mobsquad reload', 900)).join(' ') if (!/reloaded/.test(out)) throw new Error('reload failed: ' + out) } @@ -890,15 +890,21 @@ if (want('coats')) { check('and the bee', await until(async () => (await s.count(sel('bee'))) === 1, 6000, 300)) const plain = await variantOf() check('by default no world is magic, so a level 45 chicken looks as it spawned', !!plain, plain) - check('and a level 45 bee doesn\'t glow, wear a team or leave a trail', !(await glows('bee')) && !(await teamOf('bee', 4)) && (await trail(2500)) === 0, `packets ${packets}`) + check('and a level 45 bee or chicken doesn\'t glow, wear a team or leave a trail', !(await glows('bee')) && !(await teamOf('bee', 4)) && !(await glows('chicken')) && (await trail(2500)) === 0, `packets ${packets}`) // magic worlds await writeWorlds('testworld') check('listing the world gives the chicken its level 45 coat (coat 4) at once', await until(async () => (await variantOf()) === 'minecraft:warm', 3000, 200), await variantOf()) check('the bee glows in coat 4\'s team (Meadow)', await until(() => glows('bee'), 3000, 200) && await teamOf('bee', 4)) - check('a variant critter wears no glow', !(await glows('chicken'))) + check('a chicken wears its variant and also glows in coat 4\'s team (glow-too, owner 2026-11-22)', await until(() => glows('chicken'), 3000, 200) && await teamOf('chicken', 4)) + // a no-glow world (for kids' worlds): coat and trail stay, the outline that shows through walls goes + await writeWorlds('testworld', 'testworld') + check('in a no-glow world the bee and chicken lose the outline', await until(async () => !(await glows('bee')) && !(await glows('chicken')), 3000, 200)) + check('but keep their coat: the chicken\'s variant and both trails', (await variantOf()) === 'minecraft:warm' && (await trail(3000)) > 0) + await writeWorlds('testworld') + check('taking it off the no-glow list brings the outline back', await until(async () => (await glows('bee')) && (await glows('chicken')), 3000, 200)) const n = await trail(3000) - check('the bee\'s trail is a few particles a second, not a flood', n >= 2 && n <= 20, `${n} packets in 3 s`) + check('the bee\'s and chicken\'s trails are a few particles a second each, not a flood', n >= 4 && n <= 40, `${n} packets in 3 s for two critters`) await level('chicken', 100) check('level 100 earns coat 10 and the chicken wears it', await until(async () => (await variantOf()) === 'minecraft:cold', 3000, 200), await variantOf()) await level('bee', 100) @@ -934,7 +940,7 @@ if (want('coats')) { // leaving a magic world takes the look off at once, entering applies it await writeWorlds('') check('unlisting the world takes the chicken\'s coat off at once', await until(async () => (await variantOf()) === plain, 3000, 200), `${await variantOf()} vs ${plain}`) - check('and the bee\'s glow, team and trail', !(await glows('bee')) && !(await teamOf('bee', 4)) && (await trail(2500)) === 0) + check('and the bee\'s and chicken\'s glow, team and trail', !(await glows('bee')) && !(await teamOf('bee', 4)) && !(await glows('chicken')) && !(await teamOf('chicken', 4)) && (await trail(2500)) === 0) await writeWorlds('testworld') check('listing it again brings them back', await until(() => glows('bee'), 3000, 200) && await variantOf() === 'minecraft:cold') const hop = async dim => { await s.ask(`execute in minecraft:${dim} run tp Coater 8 100 8`, 800); await sleep(2500) }