diff --git a/src/main/java/net/tfminecraft/geminfusion/Permissions.java b/src/main/java/net/tfminecraft/geminfusion/Permissions.java index 25a6e4f..79054e2 100644 --- a/src/main/java/net/tfminecraft/geminfusion/Permissions.java +++ b/src/main/java/net/tfminecraft/geminfusion/Permissions.java @@ -8,6 +8,9 @@ public class Permissions { public static final String ADMIN = "geminfusion.admin"; + /** Shown when a player without the goldsmith profession tries to use a goldsmithing table. */ + public static final String NOT_SKILLED_GOLDSMITH = "§cYou are not skilled enough to practise goldsmithing."; + public static boolean isAdmin(final CommandSender commandSender) { return commandSender.hasPermission(ADMIN); } @@ -27,7 +30,7 @@ public static boolean requireAdmin(CommandSender sender) { public static boolean requireUseGoldsmith(Player player) { if (canUseGoldsmith(player)) return true; - player.sendMessage("§cYou do not have permission to use goldsmithing."); + player.sendMessage(NOT_SKILLED_GOLDSMITH); return false; } } diff --git a/src/main/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManager.java b/src/main/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManager.java index 7e5409a..f65bf1a 100644 --- a/src/main/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManager.java +++ b/src/main/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManager.java @@ -129,7 +129,7 @@ public void onInteract(PlayerInteractEvent e) { e.setCancelled(true); if (!Permissions.canUseGoldsmith(player)) { if (!onCooldown(player)) { - player.sendMessage("§cYou do not have permission to use goldsmithing."); + player.sendMessage(Permissions.NOT_SKILLED_GOLDSMITH); markCooldown(player); } return; @@ -145,7 +145,7 @@ public void onInteract(PlayerInteractEvent e) { e.setCancelled(true); if (!Permissions.canUseGoldsmith(player)) { if (!onCooldown(player)) { - player.sendMessage("§cYou do not have permission to use goldsmithing."); + player.sendMessage(Permissions.NOT_SKILLED_GOLDSMITH); markCooldown(player); } return; @@ -162,7 +162,7 @@ public void onMenuClick(InventoryClickEvent e) { e.setCancelled(true); if (!(e.getWhoClicked() instanceof Player p)) return; if (!Permissions.canUseGoldsmith(p)) { - p.sendMessage("§cYou do not have permission to use goldsmithing."); + p.sendMessage(Permissions.NOT_SKILLED_GOLDSMITH); p.closeInventory(); return; } @@ -282,11 +282,11 @@ private void handleRightClick(PlayerInteractEvent e) { p.getWorld().playSound(existing.getLoc(), Sound.ITEM_AXE_WAX_OFF, 0.7f, 2f); break; case CAPACITY: - p.sendMessage("§cYou already have the needed amount of this type"); + p.sendMessage("§cThe piece already has enough of that material"); p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 0.5f); break; case WRONG_TYPE: - p.sendMessage("§cThis item type is not needed for the project"); + p.sendMessage("§cThis piece does not call for that material"); p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 1f, 1f); break; case NO_PROJECT: @@ -358,7 +358,7 @@ private void handleLeftClick(PlayerInteractEvent e) { p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 1f, 1f); break; case WRONG_TYPE: - p.sendMessage("§cThis item cannot be used for goldsmithing hits"); + p.sendMessage("§cYou cannot work the piece with that tool"); p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_NO, 1f, 1f); break; default: diff --git a/src/test/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManagerTest.java b/src/test/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManagerTest.java index 09bc2bd..ad0c847 100644 --- a/src/test/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManagerTest.java +++ b/src/test/java/net/tfminecraft/geminfusion/goldsmith/GoldsmithStationManagerTest.java @@ -197,18 +197,18 @@ void permissionDenialsAreCancelledAndThrottledForBothActions() { manager.onInteract(right); manager.onInteract(right); assertTrue(right.isCancelled()); - verify(player, times(1)).sendMessage(contains("permission")); + verify(player, times(1)).sendMessage(Permissions.NOT_SKILLED_GOLDSMITH); manager.clear(); branding(true); PlayerInteractEvent left = click(Action.LEFT_CLICK_BLOCK); manager.onInteract(left); manager.onInteract(left); assertTrue(left.isCancelled()); - verify(player, times(2)).sendMessage(contains("permission")); + verify(player, times(2)).sendMessage(Permissions.NOT_SKILLED_GOLDSMITH); manager.clear(); branding(false); manager.onInteract(click(Action.LEFT_CLICK_BLOCK)); - verify(player, times(2)).sendMessage(contains("permission")); + verify(player, times(2)).sendMessage(Permissions.NOT_SKILLED_GOLDSMITH); } @Test