diff --git a/src/main/java/net/tfminecraft/geigercounters/handlers/SourceHandler.java b/src/main/java/net/tfminecraft/geigercounters/handlers/SourceHandler.java index a556dcc..58600b6 100644 --- a/src/main/java/net/tfminecraft/geigercounters/handlers/SourceHandler.java +++ b/src/main/java/net/tfminecraft/geigercounters/handlers/SourceHandler.java @@ -305,13 +305,23 @@ private void collectSource(Player player, UUID hunter, Location collected, Equip dropLimits.recordCollection(player); UsageStats.getInstance().recordSourceCollected(); Bukkit.getPluginManager().callEvent(new GeigerSourceCollectEvent(player, collected)); - notifyPlayerOfCollection(player); replaceGeigerWithDeadVersion(player, geigerSlot); + notifyPlayerOfCollection(player); giveReward(player); } + // One line: the find, then the spent counter. A blank half is left out. private void notifyPlayerOfCollection(Player player) { - player.sendMessage(config.getMessages().get("player.found-source")); + String found = config.getMessages().get("player.found-source"); + String spent = config.getMessages().get("player.dead-geiger"); + if (found.isBlank() || spent.isBlank()) { + String only = found.isBlank() ? spent : found; + if (!only.isBlank()) { + player.sendMessage(only); + } + return; + } + player.sendMessage(found + " " + spent); } private void replaceGeigerWithDeadVersion(Player player, EquipmentSlot geigerSlot) { @@ -336,7 +346,6 @@ private void replaceGeigerWithDeadVersion(Player player, EquipmentSlot geigerSlo deadGeiger.setAmount(1); giveItemOrDropLeftovers(player, deadGeiger); player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1f, 1f); - player.sendMessage(config.getMessages().get("player.dead-geiger")); } catch (Exception e) { plugin.getLogger().warning("Failed to give dead Geiger Counter to " + player.getName() + ": " + e.getMessage()); } diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 54cfb5a..cacb050 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -12,14 +12,15 @@ # PLAYER - seen by anyone hunting a source # ==================================== player: - # Shown when a player finds their radioactive source - found-source: "&#AA00FFYou have found the source of Arcane Radiation!" + # Shown when a player finds their radioactive source, followed on the same + # line by dead-geiger. Leave either blank to drop that half. + found-source: "&#AA00FFYou found the arcane source!" # Title of the signal bar shown while holding a detector signal-bar: "&#AA00FFArcane signal" - # Shown when the Geiger Counter burns out after finding the source - dead-geiger: "&7Your Arcane Trace Detector has run out of fuel." + # Second half of the found-source line: the counter burns out + dead-geiger: "&7Your detector is spent." # Shown when a player has used up their drops for the current window # %max% = drops allowed per window diff --git a/src/test/java/net/tfminecraft/geigercounters/handlers/SourceHandlerTest.java b/src/test/java/net/tfminecraft/geigercounters/handlers/SourceHandlerTest.java index 99e0173..4723105 100644 --- a/src/test/java/net/tfminecraft/geigercounters/handlers/SourceHandlerTest.java +++ b/src/test/java/net/tfminecraft/geigercounters/handlers/SourceHandlerTest.java @@ -361,6 +361,29 @@ void collectionConsumesCounterRecordsLimitAndPublishesOriginalLocation() { assertFalse(handler.isPlacing(hunter)); } + @Test + void collectionSendsTheFindAndTheSpentCounterAsOneLine() { + when(messages.get("player.found-source")).thenReturn("Found!"); + when(messages.get("player.dead-geiger")).thenReturn("Spent."); + place(); + collect(EquipmentSlot.HAND); + verify(player).sendMessage("Found! Spent."); + verify(player, times(1)).sendMessage(anyString()); + } + + @Test + void aBlankHalfOfTheCollectionLineIsLeftOut() { + when(messages.get("player.found-source")).thenReturn("Found!", " ", ""); + when(messages.get("player.dead-geiger")).thenReturn("", "Spent.", ""); + for (int run = 0; run < 3; run++) { + place(); + collect(EquipmentSlot.HAND); + } + verify(player).sendMessage("Found!"); + verify(player).sendMessage("Spent."); + verify(player, times(2)).sendMessage(anyString()); + } + @Test void offhandCollectionAlsoGrantsClonedRewardWithConfiguredAmount() { TierReward tier = new TierReward("rare", 1);