Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/net/tfminecraft/geminfusion/Permissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down