From 576af68cd2b50521a039e55910719849ec12fcbb Mon Sep 17 00:00:00 2001 From: XxFran10xX <318299142+XxFran10xX@users.noreply.github.com> Date: Thu, 8 Oct 2026 14:41:14 +0200 Subject: [PATCH] fix: stop the branding status listing hit counts The branding tool's right-click status listed how often each configured hit had been used, which helps players track the hit split they are meant to work out themselves. It now shows only the recipe, the material groups still to fill and how to finish or cancel. Co-Authored-By: Claude Opus 5.5 --- .../objects/crafting/CraftingStation.java | 14 ++++---------- .../CraftingManagerCoverageTest.java | 4 ++-- .../advancedcrafting/StationCoverageTest.java | 12 +++--------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java b/src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java index 8a576fc..7b270fd 100644 --- a/src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java +++ b/src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java @@ -247,7 +247,10 @@ public StationFeedback addMaterial(Player p, ItemStack i) { return StationFeedback.SUCCESS; } - /** Lines the branding tool shows on right-click: recipe, materials, and the current count of every configured hit. */ + /** + * Lines the branding tool shows on right-click: the recipe and the material groups still to fill. + * Players have to find the hits themselves, so per-hit counts stay out of it. + */ public List getStatusLines() { List lines = new ArrayList<>(); lines.add("§7Recipe: " + recipe.getCleanedName()); @@ -255,15 +258,6 @@ public List getStatusLines() { if (e.getKey() == null) continue; lines.add(e.getKey().getName() + "§7: §e" + e.getValue().getCurrent() + "/" + e.getValue().getNeeded()); } - // Counted by id: a reload replaces the hit objects this station was keyed with. - Map done = new HashMap<>(); - for (Map.Entry e : hits.entrySet()) { - if (e.getKey() == null) continue; - done.merge(e.getKey().getId(), e.getValue().getCurrent(), Integer::sum); - } - for (CraftingHit hit : HitLoader.get().values()) { - lines.add(hit.getName() + "§7: §e" + done.getOrDefault(hit.getId(), 0)); - } lines.add("§7Left-click branding to finish"); lines.add("§cSHIFT + LEFT CLICK with the branding tool to cancel the project!"); return lines; diff --git a/src/test/java/net/tfminecraft/advancedcrafting/CraftingManagerCoverageTest.java b/src/test/java/net/tfminecraft/advancedcrafting/CraftingManagerCoverageTest.java index 6db7391..fd18915 100644 --- a/src/test/java/net/tfminecraft/advancedcrafting/CraftingManagerCoverageTest.java +++ b/src/test/java/net/tfminecraft/advancedcrafting/CraftingManagerCoverageTest.java @@ -142,14 +142,14 @@ void rightClickWithBrandingShowsStatusInsteadOfAddingIt() throws Exception { var m = new CraftingManager(); var s = station(m, b); when(s.hasRecipe()).thenReturn(true); - when(s.getStatusLines()).thenReturn(List.of("§7Recipe: Sword", "Strike§7: §e3")); + when(s.getStatusLines()).thenReturn(List.of("§7Recipe: Sword", "Metal§7: §e1/2")); p.getInventory().setItemInMainHand(new ItemStack(Material.STICK)); Cache.brandingTool = "v.stick"; when(items.getChecker().checkItemWithPath(any(), eq(Cache.brandingTool))).thenReturn(true); m.openStation(event(p, b, Action.RIGHT_CLICK_BLOCK)); verify(s, never()).addMaterial(any(), any()); verify(p).sendMessage("§7Recipe: Sword"); - verify(p).sendMessage("Strike§7: §e3"); + verify(p).sendMessage("Metal§7: §e1/2"); when(items.getChecker().checkItemWithPath(any(), eq(Cache.brandingTool))).thenReturn(false); when(s.addMaterial(eq(p), any())).thenReturn(StationFeedback.NOT_INGREDIENT); map(m, "cooldown").clear(); diff --git a/src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.java b/src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.java index 4113232..1739e82 100644 --- a/src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.java +++ b/src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.java @@ -95,27 +95,21 @@ void materialAdmissionChecksItemTypePermissionsRecipeAndCapacity() throws Except } @Test - void statusLinesListEveryConfiguredHitWithItsCount() throws Exception { + void statusLinesShowMaterialsButNoHitCounts() throws Exception { var p = server.addPlayer(); - HitLoader.map.put("tap", new CraftingHit("tap", yaml("name: Tap\ntype: hammer\ntool: v.stick"))); var station = new CraftingStation(loc()); station.setRecipe(recipe("recipe: ['metal.2']")); var item = ingredient("iron", "hits: ['strike.2']").build(); p.getInventory().setItemInMainHand(item); assertEquals(StationFeedback.SUCCESS, station.addMaterial(p, item)); station.getHits().get(HitLoader.map.get("strike")).setCurrent(3); - // A reload swaps in new hit objects; counts must still match by id. - HitLoader.map.put( - "strike", new CraftingHit("strike", yaml("name: Strike\ntype: hammer\ntool: v.iron_axe"))); - // Unknown types or hits from a stale config are skipped, not printed as "null". + // Unknown types from a stale config are skipped, not printed as "null". station.getTypes().put(null, new IntCounter()); - station.getHits().put(null, new IntCounter()); + // Players have to find the hits themselves, so no hit counts are listed. assertEquals( List.of( "§7Recipe: Sword", "Metal§7: §e1/2", - "Strike§7: §e3", - "Tap§7: §e0", "§7Left-click branding to finish", "§cSHIFT + LEFT CLICK with the branding tool to cancel the project!"), station.getStatusLines());