Java Code Examples for org.bukkit.permissions.PermissionDefault#OP

The following examples show how to use org.bukkit.permissions.PermissionDefault#OP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PGMConfig.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public Group(ConfigurationSection config) throws TextException {
  this.id = config.getName();
  final String prefix = config.getString("prefix");
  this.prefix = prefix == null ? null : parseComponentLegacy(prefix);
  final PermissionDefault def =
      id.equalsIgnoreCase("op")
          ? PermissionDefault.OP
          : id.equalsIgnoreCase("default") ? PermissionDefault.TRUE : PermissionDefault.FALSE;
  this.permission = getPermission(config, id, def, "permissions");
  this.observerPermission =
      getPermission(config, id, PermissionDefault.FALSE, "observer-permissions");
  this.participantPermission =
      getPermission(config, id, PermissionDefault.FALSE, "participant-permissions");
}
 
Example 2
Source File: SimplePluginManager.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private void calculatePermissionDefault(Permission perm, boolean dirty) {
    if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
        defaultPerms.get(true).add(perm);
        if (dirty) {
            dirtyPermissibles(true);
        }
    }
    if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
        defaultPerms.get(false).add(perm);
        if (dirty) {
            dirtyPermissibles(false);
        }
    }
}
 
Example 3
Source File: RandomTeleport.java    From RandomTeleport with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add an option parser to this plugin
 * @param parser The parser to add
 */
public void addOptionParser(OptionParser parser) {
    optionParsers.add(parser);
    if (parser instanceof SimpleOptionParser) {
        Permission parent = getServer().getPluginManager().getPermission("randomteleport.manual.option.*");
        for (String alias : ((SimpleOptionParser) parser).getAliases()) {
            Permission perm = new Permission("randomteleport.manual.option." + alias, PermissionDefault.OP);
            perm.addParent(parent, true);
            try {
                getServer().getPluginManager().addPermission(perm);
            } catch (IllegalArgumentException ignored) {} // duplicate
        }
    }
}
 
Example 4
Source File: AdminChannel.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Inject AdminChannel(ConsoleCommandSender console, OnlinePlayers players, SettingManagerProvider settings) {
    super(FORMAT, BROADCAST_FORMAT, new Permission(PERM_RECEIVE, PermissionDefault.OP));
    this.players = players;
    this.settings = settings;
    this.console = console;
}
 
Example 5
Source File: Main.java    From ce with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void writePermissions() {
    Permission mainNode = new Permission("ce.*", "The main permission node for Custom Enchantments.", PermissionDefault.OP);

    Permission runecrafting = new Permission("ce.runecrafting", "The permission for Runecrafting.", PermissionDefault.OP);
    runecrafting.addParent(mainNode, true);

    Permission cmdNode = new Permission("ce.cmd.*", "The permission node for CE's commands.", PermissionDefault.OP);
    Permission enchNode = new Permission("ce.ench.*", "The permission node for CE's EnchantManager.getEnchantments().", PermissionDefault.OP);
    Permission itemNode = new Permission("ce.item.*", "The permission node for CE's  items.", PermissionDefault.OP);

    cmdNode.addParent(mainNode, true);
    enchNode.addParent(mainNode, true);
    itemNode.addParent(mainNode, true);

    Permission cmdMenu = new Permission("ce.cmd.menu", "The permission for the CE command 'menu'");
    Permission cmdList = new Permission("ce.cmd.reload", "The permission for the CE command 'reload'");
    Permission cmdGive = new Permission("ce.cmd.give", "The permission for the CE command 'give'");
    Permission cmdChange = new Permission("ce.cmd.change", "The permission for the CE command 'change'");
    Permission cmdEnchant = new Permission("ce.cmd.enchant", "The permission for the CE command 'enchant'");
    Permission cmdRunecraft = new Permission("ce.cmd.runecrafting", "The permission for the CE command 'runecrafting'");

    cmdMenu.addParent(cmdNode, true);
    cmdList.addParent(cmdNode, true);
    cmdGive.addParent(cmdNode, true);
    cmdChange.addParent(cmdNode, true);
    cmdEnchant.addParent(cmdNode, true);
    cmdRunecraft.addParent(cmdNode, true);

    Bukkit.getServer().getPluginManager().addPermission(mainNode);

    Bukkit.getServer().getPluginManager().addPermission(runecrafting);

    Bukkit.getServer().getPluginManager().addPermission(cmdNode);
    Bukkit.getServer().getPluginManager().addPermission(enchNode);
    Bukkit.getServer().getPluginManager().addPermission(itemNode);

    Bukkit.getServer().getPluginManager().addPermission(cmdMenu);
    Bukkit.getServer().getPluginManager().addPermission(cmdList);
    Bukkit.getServer().getPluginManager().addPermission(cmdGive);
    Bukkit.getServer().getPluginManager().addPermission(cmdChange);
    Bukkit.getServer().getPluginManager().addPermission(cmdEnchant);
    Bukkit.getServer().getPluginManager().addPermission(cmdRunecraft);

    for (CItem ci : items) {
        Permission itemTemp = new Permission("ce.item." + ci.getPermissionName(), "The permission for the CE Item '" + ci.getOriginalName() + "'.");
        itemTemp.addParent(itemNode, true);
        Bukkit.getServer().getPluginManager().addPermission(itemTemp);
    }

    for (CEnchantment ce : EnchantManager.getEnchantments()) {
        Permission enchTemp = new Permission("ce.ench." + ce.getPermissionName(), "The permission for the CE Enchantment '" + ce.getOriginalName() + "'.");
        enchTemp.addParent(enchNode, true);
        Bukkit.getServer().getPluginManager().addPermission(enchTemp);
    }

}