<commit_before>package com.dumptruckman.tools.permission;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Perm {

    /**
     * Permission for debug command.
     */
    public static final Perm COMMAND_DEBUG = new Perm.Builder("debug")
            .desc("Spams the console a bunch.").def(PermissionDefault.OP).build();
    /**
     * Permission for reload command.
     */
    public static final Perm COMMAND_RELOAD = new Perm.Builder("reload")
            .desc("Reloads the config file.").def(PermissionDefault.OP).build();

    private String name;
    private final String description;
    private final Map<String, Boolean> children;
    private final PermissionDefault permissionDefault;
    
    private Permission permission = null;
    
    private Perm(String name, String description, Map<String, Boolean> children, PermissionDefault permissionDefault) {
        this.name = name;
        this.description = description;
        this.children = children;
        this.permissionDefault = permissionDefault;
    }

    public final void setName(String name) {
        if (permission != null) {
            throw new IllegalStateException("Permission already finalized!");
        }
        this.name = name;
    }

    public final String getName() {
        return this.name;
    }
    
    public final String getDescription() {
        return this.description;
    }

    public final Map<String, Boolean> getChildren() {
        return this.children;
    }

    public final PermissionDefault getPermissionDefault() {
        return this.permissionDefault;
    }

    /**
     * Checks if the sender has the node in question.
     *
     * @param sender CommandSender to check permission for.
     * @return True if sender has the permission.
     */
    public final boolean hasPermission(CommandSender sender) throws IllegalStateException {
        return sender.hasPermission(getPermission());
    }

    public final Permission getPermission() throws IllegalStateException {
        if (!Perm.isRegistered(this)) {
            if (plugin == null) {
                throw new IllegalStateException("Plugin must be registered first!");
            }
            setName(plugin.getDescription().getName() + "." + getName());
            this.permission = new Permission(this.name, this.description, this.permissionDefault, this.children);
            Bukkit.getPluginManager().addPermission(this.permission);
            registeredPerms.add(this);
        }
        return this.permission;
    }

    public static class Builder {

        String name;
        private String description = "";
        private Map<String, Boolean> children = new HashMap<String, Boolean>();
        private PermissionDefault permissionDefault = PermissionDefault.OP;
<commit_msg>Fixed Perm.<commit_after>package com.dumptruckman.tools.permission;

import org.bukkit.Bukkit;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Perm {

    /**
     * Permission for debug command.
     */
    public static final Perm COMMAND_DEBUG = new Perm.Builder("debug")
            .desc("Spams the console a bunch.").def(PermissionDefault.OP).build();
    /**
     * Permission for reload command.
     */
    public static final Perm COMMAND_RELOAD = new Perm.Builder("reload")
            .desc("Reloads the config file.").def(PermissionDefault.OP).build();

    private String name;
    private final String description;
    private final Map<String, Boolean> children;
    private final PermissionDefault permissionDefault;
    
    private Permission permission = null;
    
    private Perm(String name, String description, Map<String, Boolean> children, PermissionDefault permissionDefault) {
        this.name = name;
        this.description = description;
        this.children = children;
        this.permissionDefault = permissionDefault;
    }

    public final void setName(String name) {
        if (permission != null) {
            throw new IllegalStateException("Permission already finalized!");
        }
        this.name = name;
    }

    public final String getName() {
        return this.name;
    }
    
    public final String getDescription() {
        return this.description;
    }

    public final Map<String, Boolean> getChildren() {
        return this.children;
    }

    public final PermissionDefault getPermissionDefault() {
        return this.permissionDefault;
    }

    /**
     * Checks if the sender has the node in question.
     *
     * @param permissible Permissible to check permission for.
     * @return True if sender has the permission.
     */
    public final boolean hasPermission(Permissible permissible) throws IllegalStateException {
        return permissible.hasPermission(getPermission());
    }

    public final Permission getPermission() throws IllegalStateException {
        if (!Perm.isRegistered(this)) {
            if (plugin == null) {
                throw new IllegalStateException("Plugin must be registered first!");
            }
            setName(plugin.getDescription().getName() + "." + getName());
            this.permission = new Permission(this.name, this.description, this.permissionDefault, this.children);
            Bukkit.getPluginManager().addPermission(this.permission);
            registeredPerms.add(this);
        }
        return this.permission;
    }

    public static class Builder {

        String name;
        private String description = "";
        private Map<String, Boolean> children = new HashMap<String, Boolean>();
        private PermissionDefault permissionDefault = PermissionDefault.OP;

{'fraction_non_alphanumeric': 0.09192567012004604, 'fraction_numerical': 0.0, 'mean_word_length': 2.803627267041901, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '528713', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1475, 'n_words': 429}