Java Code Examples for org.bukkit.permissions.Permission#addParent()
The following examples show how to use
org.bukkit.permissions.Permission#addParent() .
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: RandomTeleport.java From RandomTeleport with GNU General Public License v3.0 | 5 votes |
/** * 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 2
Source File: MySubCommand.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
void setupPermissions(String name, Permission parent) { String permName = parent.getName(); if (permName.endsWith(".*")) { permName = permName.substring(0, permName.length() - 2); } _perm = new Permission(permName + "." + name); _perm.addParent(parent, true); for (Entry<String, MySubCommand> entry : _subCommands.entrySet()) { entry.getValue().setupPermissions(entry.getKey(), _perm); } Bukkit.getPluginManager().addPermission(_perm); parent.recalculatePermissibles(); }
Example 3
Source File: ChannelMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
protected Permission createChannelPermission(Party party) { Permission permission = new Permission("pgm.chat.team." + this.match.getId() + '-' + party.hashCode() + ".receive", PermissionDefault.FALSE); getMatch().getPluginManager().addPermission(permission); permission.addParent(matchListeningPermission, true); return permission; }
Example 4
Source File: Main.java From ce with GNU Lesser General Public License v3.0 | 4 votes |
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); } }
Example 5
Source File: CustomItemManager.java From NBTEditor with GNU General Public License v3.0 | 4 votes |
public static void initialize() { // Find NBTEditor plugin... if (_plugin != null || (_plugin = Bukkit.getPluginManager().getPlugin("NBTEditor")) == null) { return; } Permission mainPermission = new Permission("nbteditor.customitems.*"); mainPermission.addParent(UtilsMc.getRootPermission(_plugin), true); _usePermission = new Permission("nbteditor.customitems.use.*"); _usePermission.addParent(mainPermission, true); Bukkit.getPluginManager().addPermission(_usePermission); _worldOverridePermission = new Permission("nbteditor.customitems.world-override.*"); _worldOverridePermission.addParent(mainPermission, true); Bukkit.getPluginManager().addPermission(_worldOverridePermission); _mainListener = new Listener() { @EventHandler private void onInventoryClick(InventoryClickEvent event) { if (event.getInventory().getType() == InventoryType.ANVIL && getCustomItem(event.getCurrentItem()) != null) { event.setCancelled(true); } } @EventHandler private void onPluginDisable(PluginDisableEvent event) { Plugin plugin = event.getPlugin(); if (plugin == _plugin) { HandlerList.unregisterAll(_mainListener); HandlerList.unregisterAll(_listener); _plugin = null; _mainListener = null; _container.clear(); _configsByGroup.clear(); } else { _container.remove(plugin); } } }; Bukkit.getPluginManager().registerEvents(_mainListener, _plugin); Bukkit.getPluginManager().registerEvents(_listener, _plugin); }