use of org.bukkit.permissions.Permission in project Bukkit by Bukkit.
the class DefaultPermissions method registerPermission.
public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children, Permission parent) {
Permission perm = registerPermission(name, desc, def, children);
parent.getChildren().put(perm.getName(), true);
return perm;
}
use of org.bukkit.permissions.Permission in project Bukkit by Bukkit.
the class DefaultPermissions method registerPermission.
public static Permission registerPermission(Permission perm, boolean withLegacy) {
Permission result = perm;
try {
Bukkit.getPluginManager().addPermission(perm);
} catch (IllegalArgumentException ex) {
result = Bukkit.getPluginManager().getPermission(perm.getName());
}
if (withLegacy) {
Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
legacy.getChildren().put(result.getName(), true);
registerPermission(perm, false);
}
return result;
}
use of org.bukkit.permissions.Permission in project Jobs by GamingMesh.
the class JobsListener method onWorldLoad.
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldLoad(WorldLoadEvent event) {
World world = event.getWorld();
PluginManager pm = plugin.getServer().getPluginManager();
if (pm.getPermission("jobs.world." + world.getName().toLowerCase()) == null)
pm.addPermission(new Permission("jobs.world." + world.getName().toLowerCase(), PermissionDefault.TRUE));
}
use of org.bukkit.permissions.Permission in project Glowstone by GlowstoneMC.
the class GlowServer method enablePlugins.
/**
* Enable all plugins of the given load order type.
*
* @param type The type of plugin to enable.
*/
private void enablePlugins(PluginLoadOrder type) {
if (type == PluginLoadOrder.STARTUP) {
helpMap.clear();
helpMap.loadConfig(config.getConfigFile(Key.HELP_FILE));
}
// load all the plugins
Plugin[] plugins = pluginManager.getPlugins();
for (Plugin plugin : plugins) {
if (!plugin.isEnabled() && plugin.getDescription().getLoad() == type) {
List<Permission> perms = plugin.getDescription().getPermissions();
for (Permission perm : perms) {
try {
pluginManager.addPermission(perm);
} catch (IllegalArgumentException ex) {
getLogger().log(Level.WARNING, "Plugin " + plugin.getDescription().getFullName() + " tried to register permission '" + perm.getName() + "' but it's already registered", ex);
}
}
try {
pluginManager.enablePlugin(plugin);
} catch (Throwable ex) {
logger.log(Level.SEVERE, "Error loading " + plugin.getDescription().getFullName(), ex);
}
}
}
if (type == PluginLoadOrder.POSTWORLD) {
commandMap.setFallbackCommands();
commandMap.registerServerAliases();
DefaultPermissions.registerCorePermissions();
helpMap.initializeCommands();
helpMap.amendTopics(config.getConfigFile(Key.HELP_FILE));
// load permissions.yml
ConfigurationSection permConfig = config.getConfigFile(Key.PERMISSIONS_FILE);
Map<String, Map<String, Object>> data = new HashMap<>();
permConfig.getValues(false).forEach((key, value) -> data.put(key, ((MemorySection) value).getValues(false)));
List<Permission> perms = Permission.loadPermissions(data, "Permission node '%s' in permissions config is invalid", PermissionDefault.OP);
for (Permission perm : perms) {
try {
pluginManager.addPermission(perm);
} catch (IllegalArgumentException ex) {
getLogger().log(Level.WARNING, "Permission config tried to register '" + perm.getName() + "' but it's already registered", ex);
}
}
}
}
use of org.bukkit.permissions.Permission in project BKCommonLib by bergerhealer.
the class PluginBase method setPermissions.
private static void setPermissions(ConfigurationNode node) {
for (ConfigurationNode subNode : node.getNodes()) {
setPermissions(subNode);
}
PermissionDefault def = node.get("default", PermissionDefault.class);
String desc = node.get("description", String.class);
if (def != null || desc != null) {
Permission permission = getPermission(node.getPath().toLowerCase());
if (def != null) {
permission.setDefault(def);
}
if (desc != null) {
permission.setDescription(desc);
}
}
}
Aggregations