Fix Group-Commands

This commit is contained in:
RayzsYT committed 2024-06-02 02:05:17 +02:00
1 parent e4434c2102
commit 33e12561d2
3 files changed
+8 -8

No files matched your search

@@ -170,7 +170,7 @@ public class Storage {
public static boolean isListed(String command, String server) {
boolean blocked = isBlocked(command, server);
if(!blocked) for (GeneralBlacklist blacklist : getBlacklists(server)) {
blocked = blacklist.isBlocked(command, server);
blocked = blacklist.isBlocked(command, server, !ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if(blocked) break;
}
return blocked;
@@ -201,11 +201,11 @@ public class Storage {
}
public static boolean isBlocked(Object playerObj, String command, String server) {
if(GroupManager.getGroupsByServer(server).stream().anyMatch(group -> isInListed(command, group.getCommands(server), false) && group.hasPermission(playerObj))) return false;
if(GroupManager.getGroupsByServer(server).stream().anyMatch(group -> isInListed(command, group.getCommands(server), !ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) && group.hasPermission(playerObj))) return false;
boolean blocked = isBlocked(playerObj, command);
if(!blocked) for (GeneralBlacklist blacklist : getBlacklists(server)) {
blocked = blacklist.isBlocked(playerObj, command);
blocked = blacklist.isBlocked(playerObj, command, !ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
if(blocked) break;
}
return blocked;
@@ -71,20 +71,20 @@ public class Group implements Serializable {
}
public boolean contains(String command) {
return this.generalGroupBlacklist.isListed(command);
return this.generalGroupBlacklist.isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
}
public boolean contains(String command, String server) {
return (this.generalGroupBlacklist.isListed(command) || getOrCreateGroupBlacklist(server).isListed(command));
return (this.generalGroupBlacklist.isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) || getOrCreateGroupBlacklist(server).isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED));
}
public boolean containsOnServer(String command, String server) {
GroupBlacklist serverGroupBlacklist = getOrCreateGroupBlacklist(server);
return (serverGroupBlacklist != null && serverGroupBlacklist.isListed(command));
return (serverGroupBlacklist != null && serverGroupBlacklist.isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED));
}
public GroupBlacklist getOrCreateGroupBlacklist(String server) {
return getOrCreateGroupBlacklist(server, false);
return getOrCreateGroupBlacklist(server, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
}
public GroupBlacklist getOrCreateGroupBlacklist(String server, boolean ignoreExist) {
@@ -15,7 +15,7 @@ public class GroupManager {
}
public static boolean canAccessCommand(Object targetObj, String command) {
command = Storage.Blacklist.getBlacklist().convertCommand(command, true, false);
command = Storage.Blacklist.getBlacklist().convertCommand(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, false);
for (Group group : GROUPS)
if(group.contains(command))