<commit_before>package stream.flarebot.flarebot.permissions;

import net.dv8tion.jda.core.entities.Member;
import stream.flarebot.flarebot.FlareBot;
import stream.flarebot.flarebot.util.Constants;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class PerGuildPermissions {

    private final List<Group> groups = Collections.synchronizedList(new ArrayList<>());
    private final ConcurrentHashMap<String, User> users = new ConcurrentHashMap<>();

    public boolean hasPermission(Member user, Permission permission) {
        // So we can go into servers and figure out any issues they have.
        if (isCreator(user.getUser()))
            return true;
        if (user.isOwner())
            return true;
//        if (user.getPermissions().contains(net.dv8tion.jda.core.Permission.ADMINISTRATOR))
//            return true;
//        // Change done by Walshy: Internal review needed
//        if (isContributor(user.getUser()) && FlareBot.instance().isTestBot())
//            return true;
        if (getUser(user).hasPermission(permission) == Permission.Reply.ALLOW)
            return true;
        if (getUser(user).hasPermission(permission) == Permission.Reply.DENY) {
            return false;
        }
        Permission.Reply hasPerm = Permission.Reply.NEUTRAL;
        synchronized (groups) {
            for (Group g : groups) {
                if (g.hasPermission(permission) == Permission.Reply.NEUTRAL) continue;
                if (g.getRoleId() != null && user.getGuild().getRoleById(g.getRoleId()) != null) {
                    if (user.getRoles().contains(user.getGuild().getRoleById(g.getRoleId()))) {
                        hasPerm = g.hasPermission(permission);
                    }
                }
                if (getUser(user).getGroups().contains(g.getName())) {
                    hasPerm = g.hasPermission(permission);
                }
            }
        }
        if (hasPerm == Permission.Reply.NEUTRAL) {
            return permission.isDefaultPerm();
        } else {
            return hasPerm == Permission.Reply.ALLOW;
        }
    }
<commit_msg>Woops<commit_after>package stream.flarebot.flarebot.permissions;

import net.dv8tion.jda.core.entities.Member;
import stream.flarebot.flarebot.FlareBot;
import stream.flarebot.flarebot.util.Constants;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class PerGuildPermissions {

    private final List<Group> groups = Collections.synchronizedList(new ArrayList<>());
    private final ConcurrentHashMap<String, User> users = new ConcurrentHashMap<>();

    public boolean hasPermission(Member user, Permission permission) {
        // So we can go into servers and figure out any issues they have.
        if (isCreator(user.getUser()))
            return true;
        if (user.isOwner())
            return true;
        if (user.getPermissions().contains(net.dv8tion.jda.core.Permission.ADMINISTRATOR))
            return true;
        // Change done by Walshy: Internal review needed
        if (isContributor(user.getUser()) && FlareBot.instance().isTestBot())
            return true;
        if (getUser(user).hasPermission(permission) == Permission.Reply.ALLOW)
            return true;
        if (getUser(user).hasPermission(permission) == Permission.Reply.DENY) {
            return false;
        }
        Permission.Reply hasPerm = Permission.Reply.NEUTRAL;
        synchronized (groups) {
            for (Group g : groups) {
                if (g.hasPermission(permission) == Permission.Reply.NEUTRAL) continue;
                if (g.getRoleId() != null && user.getGuild().getRoleById(g.getRoleId()) != null) {
                    if (user.getRoles().contains(user.getGuild().getRoleById(g.getRoleId()))) {
                        hasPerm = g.hasPermission(permission);
                    }
                }
                if (getUser(user).getGroups().contains(g.getName())) {
                    hasPerm = g.hasPermission(permission);
                }
            }
        }
        if (hasPerm == Permission.Reply.NEUTRAL) {
            return permission.isDefaultPerm();
        } else {
            return hasPerm == Permission.Reply.ALLOW;
        }
    }

{'fraction_non_alphanumeric': 0.11513761467889909, 'fraction_numerical': 0.0009174311926605505, 'mean_word_length': 2.306292645943897, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6080846', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1173, 'n_words': 240}