From 30cc61166fc54f8f8ba93d263bb2f9258559ad37 Mon Sep 17 00:00:00 2001 From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:08:00 +0000 Subject: [PATCH 1/2] fix: readable pet and pet house labels on the will screen Pet houses were listed by their storage key (TFMC_Map,6077,238,5231). They now read "Pet house at 6077 238 5231", naming the world only when it is not the first one, and pets are listed by name. Co-Authored-By: Claude Opus 5.5 --- .../tfminecraft/companionpets/estate/PetEstate.java | 12 ++++++++++-- .../companionpets/estate/PetEstateTest.java | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java b/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java index d6a7b1e..dfe60b6 100644 --- a/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java +++ b/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java @@ -43,10 +43,18 @@ public static void start(Plugin plugin, PetRuntime runtime, PetActions actions) @Override public String id() { return "companionpets"; } @Override public Holdings describe(UUID character) { List labels = new ArrayList<>(); - runtime.store().ofCharacter(character).forEach(pet -> labels.add("Pet: " + pet.name())); - runtime.store().kennelCharacters().forEach((key, owner) -> { if (character.equals(owner)) labels.add("Pet House: " + key); }); + runtime.store().ofCharacter(character).forEach(pet -> labels.add(pet.name())); + runtime.store().kennelCharacters().forEach((key, owner) -> { if (character.equals(owner)) labels.add(houseLabel(key, mainWorld.get())); }); return labels.isEmpty() ? Holdings.NONE : new Holdings(Map.of("pets-and-houses", labels.size()), labels); } + /** The first world's name, or null; a house elsewhere names its world. */ + static Supplier mainWorld = () -> Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().getFirst().getName(); + /** {@code world,x,y,z} as "Pet house at x y z", adding the world when it is not {@code main}. */ + static String houseLabel(String key, String main) { + String[] part = key.split(","); + if (part.length != 4) return "Pet house " + key; + return "Pet house at " + part[1] + " " + part[2] + " " + part[3] + (part[0].equals(main) ? "" : " (" + part[0] + ")"); + } @Override public Outcome settle(EstateDecision decision) { if (runtime.store().persistenceConflict()) return Outcome.blocked("Pet source changed outside its current writer; review is required"); if (!net.tfminecraft.companionpets.ownership.CharacterAccess.heirReady() || !runtime.store().ownershipReady()) diff --git a/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java b/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java index 69d81ea..1d0fbf7 100644 --- a/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java +++ b/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java @@ -387,4 +387,17 @@ void unrelatedIncompleteDeathDoesNotBlockThisExactHeldIntentResume() throws Exce assertInstanceOf(Outcome.Blocked.class,estate.settle(decision(1,Recipient.character(to)))); assertEquals(changed,Files.readString(file));assertEquals(from.characterId(),pet.ownerCharacterId());assertTrue(pet.ownershipHeld()); } + @Test void willLabelsNamePetsAndPlaceHouses() { + assertEquals("Pet house at 6077 238 5231", PetEstate.houseLabel("TFMC_Map,6077,238,5231", "TFMC_Map")); + assertEquals("Pet house at 1 2 3 (nether)", PetEstate.houseLabel("nether,1,2,3", "TFMC_Map")); + assertEquals("Pet house at 1 2 3 (nether)", PetEstate.houseLabel("nether,1,2,3", null)); + assertEquals("Pet house odd", PetEstate.houseLabel("odd", "TFMC_Map")); + var original = PetEstate.mainWorld; + assertEquals(org.bukkit.Bukkit.getWorlds().isEmpty() ? null : org.bukkit.Bukkit.getWorlds().getFirst().getName(), original.get()); + PetEstate.mainWorld = () -> "unloaded"; + try { + assertTrue(estate.describe(from.characterId()).labels().contains("Pet house at 1 2 3"), estate.describe(from.characterId()).labels().toString()); + assertTrue(estate.describe(from.characterId()).labels().contains(pet.name())); + } finally { PetEstate.mainWorld = original; } + } } From 5422ee72c8f91ffc27dd7917d057bff1233643dd Mon Sep 17 00:00:00 2001 From: Ryan Barlow <7389646+ryanbarlow97@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:33:39 +0000 Subject: [PATCH 2/2] fix: keep commas in pet house world names Co-Authored-By: Claude Opus 5.5 --- .../net/tfminecraft/companionpets/estate/PetEstate.java | 7 +++++-- .../tfminecraft/companionpets/estate/PetEstateTest.java | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java b/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java index dfe60b6..4e71bf4 100644 --- a/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java +++ b/src/main/java/net/tfminecraft/companionpets/estate/PetEstate.java @@ -52,8 +52,11 @@ public static void start(Plugin plugin, PetRuntime runtime, PetActions actions) /** {@code world,x,y,z} as "Pet house at x y z", adding the world when it is not {@code main}. */ static String houseLabel(String key, String main) { String[] part = key.split(","); - if (part.length != 4) return "Pet house " + key; - return "Pet house at " + part[1] + " " + part[2] + " " + part[3] + (part[0].equals(main) ? "" : " (" + part[0] + ")"); + if (part.length < 4) return "Pet house " + key; + // A world name may hold commas; the last three fields are the coordinates. + int n = part.length; + String world = String.join(",", java.util.Arrays.copyOf(part, n - 3)); + return "Pet house at " + part[n - 3] + " " + part[n - 2] + " " + part[n - 1] + (world.equals(main) ? "" : " (" + world + ")"); } @Override public Outcome settle(EstateDecision decision) { if (runtime.store().persistenceConflict()) return Outcome.blocked("Pet source changed outside its current writer; review is required"); diff --git a/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java b/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java index 1d0fbf7..fd5c3ff 100644 --- a/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java +++ b/src/test/java/net/tfminecraft/companionpets/estate/PetEstateTest.java @@ -392,6 +392,8 @@ void unrelatedIncompleteDeathDoesNotBlockThisExactHeldIntentResume() throws Exce assertEquals("Pet house at 1 2 3 (nether)", PetEstate.houseLabel("nether,1,2,3", "TFMC_Map")); assertEquals("Pet house at 1 2 3 (nether)", PetEstate.houseLabel("nether,1,2,3", null)); assertEquals("Pet house odd", PetEstate.houseLabel("odd", "TFMC_Map")); + assertEquals("Pet house at 1 2 3", PetEstate.houseLabel("build,world,1,2,3", "build,world")); + assertEquals("Pet house at 1 2 3 (build,world)", PetEstate.houseLabel("build,world,1,2,3", "TFMC_Map")); var original = PetEstate.mainWorld; assertEquals(org.bukkit.Bukkit.getWorlds().isEmpty() ? null : org.bukkit.Bukkit.getWorlds().getFirst().getName(), original.get()); PetEstate.mainWorld = () -> "unloaded";