Skip to content

Commit

Permalink
Narrow shift click in inventory GUI to viewers
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Oct 8, 2022
1 parent 285b1bd commit da9be4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ public boolean hasCommand(String... parts) {

private boolean hasPermission(CommandInfo method, CommandSender sender) {
Command cmd = method.commandAnnotation;
return cmd.permission().isEmpty() || hasPermission(sender, cmd.permission()) || hasPermission(sender, "admin");
return cmd.permission().isEmpty() || hasPermission(sender, cmd.permission())
|| hasPermission(sender, "citizens.admin");
}

private boolean hasPermission(CommandSender sender, String perm) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/citizensnpcs/api/gui/InventoryMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ private int getInventorySize(InventoryType type, int[] dim) {
private void handleClick(InventoryClickEvent event) {
Inventory clicked = event.getClickedInventory() != null ? event.getClickedInventory() : event.getInventory();
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
if (!views.stream().anyMatch(v -> event.getWhoClicked().equals(v.getPlayer())))
return;
event.setCancelled(true);
Inventory dest = event.getInventory() == event.getClickedInventory() ? event.getWhoClicked().getInventory()
: page.ctx.getInventory();
Expand Down

0 comments on commit da9be4f

Please sign in to comment.