From bc8c106f8f0582b42a4e90da020081d915b686dc Mon Sep 17 00:00:00 2001 From: AngrySoundTech Date: Fri, 20 Mar 2020 00:01:03 -0400 Subject: [PATCH] Disallow toggling permissions for blacklist via gui that cannot be blacklisted Adds another check before adding click functionality, which will also append a message why it can't in this specific case. Logic for checking canEdit moved inside the loop to refresh every time, but if this turns out to be an expensive call and I'm not realising that we we can pop it back out and just store what it has. --- .../mc/namelayer/gui/PermissionManageGUI.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/gui/PermissionManageGUI.java b/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/gui/PermissionManageGUI.java index 3d98a9be0..6ee52e4ac 100644 --- a/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/gui/PermissionManageGUI.java +++ b/plugins/namelayer-paper/namelayer-spigot/src/main/java/vg/civcraft/mc/namelayer/gui/PermissionManageGUI.java @@ -111,12 +111,13 @@ public class PermissionManageGUI extends AbstractGroupGUI { ClickableInventory ci = new ClickableInventory(54, g.getName()); final List clicks = new ArrayList(); final GroupPermission gp = gm.getPermissionforGroup(g); - boolean canEdit = gm.hasAccess(g, p.getUniqueId(), - PermissionType.getPermission("PERMS")); for (final PermissionType perm : PermissionType.getAllPermissions()) { ItemStack is; Clickable c; final boolean hasPerm = gp.hasPermission(pType, perm); + boolean canEdit = gm.hasAccess(g, p.getUniqueId(), + PermissionType.getPermission("PERMS")); + if (hasPerm) { is = new ItemStack(Material.INK_SACK, 1, (short) 10); // green // dye @@ -140,6 +141,18 @@ public class PermissionManageGUI extends AbstractGroupGUI { if (desc != null) { ISUtils.addLore(is, ChatColor.GREEN + desc); } + + if (pType == PlayerType.NOT_BLACKLISTED && !perm.getCanBeBlacklisted()) { + canEdit = false; + + ISUtils.addLore( + is, + ChatColor.AQUA + + "This permission cannot be toggled for " + + PlayerType.getNiceRankName(pType) + ); + } + if (canEdit) { ISUtils.addLore(is, ChatColor.AQUA + "Click to toggle"); c = new Clickable(is) {