mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 08:30:59 +00:00
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.
This commit is contained in:
@@ -111,12 +111,13 @@ public class PermissionManageGUI extends AbstractGroupGUI {
|
||||
ClickableInventory ci = new ClickableInventory(54, g.getName());
|
||||
final List<Clickable> clicks = new ArrayList<Clickable>();
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user