mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Merge branch 'refs/heads/groupmanager'
This commit is contained in:
commit
4884bed117
@ -86,3 +86,15 @@ v 1.7:
|
||||
- Added custom events so plugins can now be notified of changes within GroupManager.
|
||||
- GM now registers with Bukkits ServicesManager.
|
||||
- deleting the contents of GlobalGroups.yml will no longer thrown a NullPointerException.
|
||||
- Removed op permissions from admins in the default GloblaGroups.yml.
|
||||
v 1.8:
|
||||
- Changed ServicesManager registration to lowest from normal.
|
||||
- Fixed 'manucheckp' returning a null for the searched node when it's a group/subgroup.
|
||||
- manpromote and mandemote now correctly send the notification to the console if the command was issued there.
|
||||
- Expanded GlobalGroups.yml and Groups.yml to include Towny permissions.
|
||||
- Delayed GroupManager events so Superperms will be fully updated before plugins receive the events.
|
||||
- Changed the way events are raised to prevent variable corruption.
|
||||
- Reload GlobalGroups when you perform a world load.
|
||||
- Changed GlobalGroups to save/load before local groups in the scheduled data saving/loading
|
||||
- Fix 'manucheckp' to correctly report if a permission is available from GroupManager or Bukkit.
|
||||
- Changed over to a reflection method for populating superperms as Bukkit lags when you handle permissions one at a time.
|
@ -4,9 +4,9 @@ settings:
|
||||
# The user will be able to promote players to the same group or even above.
|
||||
opOverrides: true
|
||||
|
||||
# If enabled any plugins bukkit permissions which default to true will be left enabled.
|
||||
# If enabled any bukkit permissiosn which default to true will be left enabled.
|
||||
# If the player is op any permissions set to Op will follow suit.
|
||||
bukkit_perms_override: false
|
||||
bukkit_perms_override: true
|
||||
|
||||
# Default setting for 'mantoglevalidate'
|
||||
# true will cause GroupManager to attempt name matching by default.
|
||||
|
@ -1,9 +1,5 @@
|
||||
groups:
|
||||
|
||||
g:bukkit_default:
|
||||
permissions:
|
||||
- bukkit.broadcast.user
|
||||
|
||||
g:essentials_default:
|
||||
permissions:
|
||||
- essentials.help
|
||||
@ -129,6 +125,11 @@ groups:
|
||||
- groupmanager.manucheckp
|
||||
- groupmanager.manulistp
|
||||
|
||||
g:bukkit_default:
|
||||
permissions:
|
||||
- bukkit.broadcast.user
|
||||
- -bukkit.command.plugins
|
||||
|
||||
g:bukkit_moderator:
|
||||
permissions:
|
||||
- bukkit.command.ban
|
||||
@ -150,9 +151,9 @@ groups:
|
||||
- bukkit.command.kill
|
||||
- bukkit.command.list
|
||||
- bukkit.command.me
|
||||
- bukkit.command.op
|
||||
- bukkit.command.op.give
|
||||
- bukkit.command.op.take
|
||||
- -bukkit.command.op
|
||||
- -bukkit.command.op.give
|
||||
- -bukkit.command.op.take
|
||||
- bukkit.command.plugins
|
||||
- bukkit.command.reload
|
||||
- bukkit.command.save
|
||||
@ -174,3 +175,52 @@ groups:
|
||||
- bukkit.command.whitelist.list
|
||||
- bukkit.command.whitelist.reload
|
||||
- bukkit.command.whitelist.remove
|
||||
|
||||
g:towny_builder:
|
||||
permissions:
|
||||
- towny.town.*
|
||||
- towny.nation.*
|
||||
- towny.chat.tc
|
||||
- towny.chat.nc
|
||||
- towny.wild.block.6.*
|
||||
- towny.wild.block.14.destroy
|
||||
- towny.wild.block.15.destroy
|
||||
- towny.wild.block.16.destroy
|
||||
- towny.wild.block.17.*
|
||||
- towny.wild.block.18.destroy
|
||||
- towny.wild.block.21.destroy
|
||||
- towny.wild.block.31.destroy
|
||||
- towny.wild.block.37.destroy
|
||||
- towny.wild.block.38.destroy
|
||||
- towny.wild.block.39.destroy
|
||||
- towny.wild.block.40.destroy
|
||||
- towny.wild.block.50.destroy
|
||||
- towny.wild.block.56.destroy
|
||||
- towny.wild.block.73.destroy
|
||||
- towny.wild.block.74.destroy
|
||||
- towny.wild.block.78.destroy
|
||||
- towny.wild.block.81.destroy
|
||||
- towny.wild.block.82.destroy
|
||||
- towny.wild.block.83.destroy
|
||||
- towny.wild.block.86.destroy
|
||||
- towny.wild.block.103.destroy
|
||||
- towny.wild.block.106.destroy
|
||||
- towny.wild.block.111.destroy
|
||||
- towny.wild.block.115.destroy
|
||||
|
||||
g:towny_moderator:
|
||||
permissions:
|
||||
- towny.chat.mod
|
||||
- towny.wild.block.64.switch
|
||||
- towny.wild.block.83.build
|
||||
- towny.wild.block.86.build
|
||||
- towny.wild.block.103.build
|
||||
- towny.wild.block.111.build
|
||||
- towny.wild.block.115.build
|
||||
|
||||
g:towny_admin:
|
||||
permissions:
|
||||
- towny.admin
|
||||
- -towny.wild.block.119.destroy
|
||||
- -towny.wild.block.120.destroy
|
||||
- towny.chat.admin
|
@ -24,6 +24,7 @@ groups:
|
||||
inheritance:
|
||||
- default
|
||||
- g:essentials_builder
|
||||
- g:towny_moderator
|
||||
info:
|
||||
prefix: '&2'
|
||||
build: true
|
||||
@ -35,6 +36,7 @@ groups:
|
||||
- builder
|
||||
- g:essentials_moderator
|
||||
- g:bukkit_moderator
|
||||
- g:towny_moderator
|
||||
info:
|
||||
prefix: '&5'
|
||||
build: true
|
||||
@ -46,6 +48,7 @@ groups:
|
||||
- moderator
|
||||
- g:essentials_admin
|
||||
- g:bukkit_admin
|
||||
- g:towny_admin
|
||||
info:
|
||||
prefix: '&c'
|
||||
build: true
|
||||
|
@ -161,7 +161,7 @@ public class GroupManager extends JavaPlugin {
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
||||
|
||||
// Register as a service
|
||||
this.getServer().getServicesManager().register(AnjoPermissionsHandler.class, this.permissionHandler, this, ServicePriority.Normal);
|
||||
this.getServer().getServicesManager().register(AnjoPermissionsHandler.class, this.permissionHandler, this, ServicePriority.Lowest);
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
@ -415,7 +415,7 @@ public class GroupManager extends JavaPlugin {
|
||||
|
||||
// PARECE OK
|
||||
auxUser.setGroup(auxGroup);
|
||||
if (!sender.hasPermission("groupmanager.notify.other"))
|
||||
if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
|
||||
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
@ -787,15 +787,14 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
// VALIDANDO PERMISSAO
|
||||
permissionResult = permissionHandler.checkFullUserPermission(auxUser, args[1]);
|
||||
permissionResult = permissionHandler.checkFullGMPermission(auxUser, args[1], false);
|
||||
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
|
||||
//No permissions found in GM so fall through and check Bukkit.
|
||||
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
|
||||
sender.sendMessage(ChatColor.YELLOW + "SuperPerms reports Node: " + targetPlayer.hasPermission(args[1]));
|
||||
return false;
|
||||
}
|
||||
// PARECE OK
|
||||
// auxString =
|
||||
// permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
||||
|
||||
} else {
|
||||
// This permission was found in groupmanager.
|
||||
if (permissionResult.owner instanceof User) {
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||
sender.sendMessage(ChatColor.RED + "The user has directly a negation node for that permission.");
|
||||
@ -805,12 +804,13 @@ public class GroupManager extends JavaPlugin {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
|
||||
} else if (permissionResult.owner instanceof Group) {
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||
sender.sendMessage(ChatColor.RED + "The user inherits the a negation permission from group: " + permissionResult.owner.getName());
|
||||
sender.sendMessage(ChatColor.RED + "The user inherits a negation permission from group: " + permissionResult.owner.getName());
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName());
|
||||
}
|
||||
sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
|
||||
}
|
||||
}
|
||||
|
||||
// superperms
|
||||
if (targetPlayer != null) {
|
||||
@ -1504,7 +1504,9 @@ public class GroupManager extends JavaPlugin {
|
||||
|
||||
isLoaded = false; // Disable Bukkit Perms update
|
||||
|
||||
globalGroups.load();
|
||||
worldsHolder.loadWorld(auxString);
|
||||
|
||||
sender.sendMessage("The request to world '" + auxString + "' was sent.");
|
||||
|
||||
isLoaded = true;
|
||||
@ -1610,7 +1612,7 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
// PARECE OK
|
||||
auxUser.setGroup(auxGroup);
|
||||
if (!sender.hasPermission("groupmanager.notify.other"))
|
||||
if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
|
||||
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
@ -1666,7 +1668,7 @@ public class GroupManager extends JavaPlugin {
|
||||
}
|
||||
// PARECE OK
|
||||
auxUser.setGroup(auxGroup);
|
||||
if (!sender.hasPermission("groupmanager.notify.other"))
|
||||
if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
|
||||
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
@ -1838,15 +1840,6 @@ public class GroupManager extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers all GroupManager events for other plugins to see.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public static void callEvent(GroupManagerEvent event) {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the config
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ public class BukkitPermsUpdateTask implements Runnable {
|
||||
public void run() {
|
||||
// Signal loaded and update BukkitPermissions.
|
||||
GroupManager.setLoaded(true);
|
||||
GroupManager.BukkitPermissions.collectPermissions();
|
||||
//GroupManager.BukkitPermissions.collectPermissions();
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
|
||||
GroupManager.logger.info("Bukkit Permissions Updated!");
|
||||
|
@ -176,6 +176,16 @@ public class WorldsHolder {
|
||||
ArrayList<WorldDataHolder> alreadyDone = new ArrayList<WorldDataHolder>();
|
||||
Tasks.removeOldFiles(plugin, plugin.getBackupFolder());
|
||||
|
||||
// Write Global Groups
|
||||
if (GroupManager.getGlobalGroups().haveGroupsChanged()) {
|
||||
GroupManager.getGlobalGroups().writeGroups(overwrite);
|
||||
} else {
|
||||
if (GroupManager.getGlobalGroups().getTimeStampGroups() < GroupManager.getGlobalGroups().getGlobalGroupsFile().lastModified()) {
|
||||
System.out.print("Newer GlobalGroups file found (Loading changes)!");
|
||||
GroupManager.getGlobalGroups().load();
|
||||
}
|
||||
}
|
||||
|
||||
for (OverloadedWorldHolder w : worldsData.values()) {
|
||||
if (alreadyDone.contains(w)) {
|
||||
continue;
|
||||
@ -228,15 +238,6 @@ public class WorldsHolder {
|
||||
}
|
||||
alreadyDone.add(w);
|
||||
}
|
||||
// Write Global Groups
|
||||
if (GroupManager.getGlobalGroups().haveGroupsChanged()) {
|
||||
GroupManager.getGlobalGroups().writeGroups(overwrite);
|
||||
} else {
|
||||
if (GroupManager.getGlobalGroups().getTimeStampGroups() < GroupManager.getGlobalGroups().getGlobalGroupsFile().lastModified()) {
|
||||
System.out.print("Newer GlobalGroups file found (Loading changes)!");
|
||||
GroupManager.getGlobalGroups().load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
@ -18,5 +20,23 @@ public abstract class GroupManagerEvent extends Event {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers all GroupManager events for other plugins to see.
|
||||
* Schedules events for 1 tick later to allow GM to finish populating super perms.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void schedule(final GroupManagerEvent event) {
|
||||
|
||||
if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}, 1) == -1)
|
||||
GroupManager.logger.warning("Could not schedule GM Event.");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
@ -13,13 +11,13 @@ import org.anjocaido.groupmanager.data.User;
|
||||
public class GroupManagerEventHandler {
|
||||
|
||||
protected static void callEvent(GMGroupEvent event) {
|
||||
GroupManager.callEvent(event);
|
||||
event.schedule(event);
|
||||
}
|
||||
protected static void callEvent(GMUserEvent event) {
|
||||
GroupManager.callEvent(event);
|
||||
event.schedule(event);
|
||||
}
|
||||
protected static void callEvent(GMSystemEvent event) {
|
||||
GroupManager.callEvent(event);
|
||||
event.schedule(event);
|
||||
}
|
||||
|
||||
public static void callEvent(Group group, GMGroupEvent.Action action) {
|
||||
|
@ -711,12 +711,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
|
||||
PermissionCheckResult resultUser = checkUserOnlyPermission(user, targetPermission);
|
||||
if (resultUser.resultType != PermissionCheckResult.Type.NOTFOUND) {
|
||||
resultUser.accessLevel = targetPermission;
|
||||
return resultUser;
|
||||
}
|
||||
|
||||
// IT ONLY CHECKS GROUPS PERMISSIONS IF RESULT FOR USER IS NOT FOUND
|
||||
PermissionCheckResult resultGroup = checkGroupPermissionWithInheritance(user.getGroup(), targetPermission);
|
||||
if (resultGroup.resultType != PermissionCheckResult.Type.NOTFOUND) {
|
||||
resultGroup.accessLevel = targetPermission;
|
||||
return resultGroup;
|
||||
}
|
||||
|
||||
@ -724,6 +726,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
for (Group subGroup : user.subGroupListCopy()) {
|
||||
PermissionCheckResult resultSubGroup = checkGroupPermissionWithInheritance(subGroup, targetPermission);
|
||||
if (resultSubGroup.resultType != PermissionCheckResult.Type.NOTFOUND) {
|
||||
resultSubGroup.accessLevel = targetPermission;
|
||||
return resultSubGroup;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.anjocaido.groupmanager.permissions;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -23,9 +24,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
//import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||
//import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -43,8 +44,7 @@ import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
//import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
*
|
||||
* BukkitPermissions overrides to force GM reponses to Superperms
|
||||
*
|
||||
* @author ElgarL, based upon PermissionsEX implementation
|
||||
* @author ElgarL, originally based upon PermissionsEX implementation
|
||||
*/
|
||||
public class BukkitPermissions {
|
||||
|
||||
@ -63,12 +63,24 @@ public class BukkitPermissions {
|
||||
protected boolean dumpMatchedPermissions = true;
|
||||
public boolean player_join = false;
|
||||
|
||||
private static Field permissions;
|
||||
|
||||
// Setup reflection (Thanks to Codename_B for the reflection source)
|
||||
static {
|
||||
try {
|
||||
permissions = PermissionAttachment.class.getDeclaredField("permissions");
|
||||
permissions.setAccessible(true);
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public BukkitPermissions(GroupManager plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
this.collectPermissions();
|
||||
//this.collectPermissions();
|
||||
this.registerEvents();
|
||||
|
||||
this.updateAllPlayers();
|
||||
|
||||
GroupManager.logger.info("Superperms support enabled.");
|
||||
@ -93,6 +105,7 @@ public class BukkitPermissions {
|
||||
manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin);
|
||||
}
|
||||
|
||||
/*
|
||||
public void collectPermissions() {
|
||||
registeredPermissions.clear();
|
||||
for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) {
|
||||
@ -100,34 +113,47 @@ public class BukkitPermissions {
|
||||
registeredPermissions.push(permission);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public void updatePermissions(Player player) {
|
||||
this.updatePermissions(player, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Push all permissions which are registered with GM for this player, on this world to Bukkit
|
||||
* and make it update for the child nodes.
|
||||
*
|
||||
* @param player
|
||||
* @param world
|
||||
*/
|
||||
public void updatePermissions(Player player, String world) {
|
||||
if (player == null || !GroupManager.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.attachments.containsKey(player)) {
|
||||
this.attachments.put(player, player.addAttachment(plugin));
|
||||
PermissionAttachment attachment;
|
||||
// Find the players current attachment, or add a new one.
|
||||
if (this.attachments.containsKey(player)) {
|
||||
attachment = this.attachments.get(player);
|
||||
} else {
|
||||
attachment = player.addAttachment(plugin);
|
||||
this.attachments.put(player, attachment);;
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
world = player.getWorld().getName();
|
||||
}
|
||||
|
||||
// All permissions registered with Bukkit for this player
|
||||
PermissionAttachment attachment = this.attachments.get(player);
|
||||
|
||||
OverloadedWorldHolder worldData = plugin.getWorldsHolder().getWorldData(world);
|
||||
Boolean value = false;
|
||||
//User user = worldData.getUser(player.getName());
|
||||
|
||||
User user = worldData.getUser(player.getName());
|
||||
|
||||
/*
|
||||
// clear permissions
|
||||
for (String permission : attachment.getPermissions().keySet())
|
||||
attachment.unsetPermission(permission);
|
||||
*/
|
||||
|
||||
/*
|
||||
* find matching permissions
|
||||
@ -135,8 +161,8 @@ public class BukkitPermissions {
|
||||
* and base bukkit perms if we are set to allow bukkit permissions to
|
||||
* override.
|
||||
*/
|
||||
Boolean value = false;
|
||||
|
||||
/*
|
||||
for (Permission permission : registeredPermissions) {
|
||||
|
||||
PermissionCheckResult result = worldData.getPermissionsHandler().checkFullGMPermission(user, permission.getName(), false);
|
||||
@ -163,22 +189,13 @@ public class BukkitPermissions {
|
||||
if ((value == true) || (result.resultType == PermissionCheckResult.Type.NEGATION)) {
|
||||
attachment.setPermission(permission, value);
|
||||
}
|
||||
/*
|
||||
if ((value == true) || (result.resultType == PermissionCheckResult.Type.NOTFOUND)) {
|
||||
// fetch and set all children of this permission node
|
||||
Map<String, Boolean> children = permission.getChildren();
|
||||
if (children != null) {
|
||||
for (String child : children.keySet()) {
|
||||
if (children.get(child))
|
||||
attachment.setPermission(child, value);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// Add any missing permissions for this player (non bukkit plugins and child nodes)
|
||||
// Add all permissions for this player (GM only)
|
||||
// child nodes will be calculated by Bukkit.
|
||||
List<String> playerPermArray = worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName());
|
||||
Map<String, Boolean> newPerms = new HashMap<String, Boolean>();
|
||||
|
||||
for (String permission : playerPermArray) {
|
||||
value = true;
|
||||
@ -186,12 +203,33 @@ public class BukkitPermissions {
|
||||
permission = permission.substring(1); // cut off -
|
||||
value = false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!attachment.getPermissions().containsKey(permission)) {
|
||||
attachment.setPermission(permission, value);
|
||||
}
|
||||
*/
|
||||
newPerms.put(permission, value);
|
||||
}
|
||||
//player.recalculatePermissions();
|
||||
|
||||
/**
|
||||
* This is put in place until such a time as Bukkit pull 466 is implemented
|
||||
* https://github.com/Bukkit/Bukkit/pull/466
|
||||
*/
|
||||
try { // Codename_B source
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Boolean> orig = (Map<String, Boolean>) permissions.get(attachment);
|
||||
// Clear the map (faster than removing the attachment and recalculating)
|
||||
orig.clear();
|
||||
// Then whack our map into there
|
||||
orig.putAll(newPerms);
|
||||
// That's all folks!
|
||||
attachment.getPermissible().recalculatePermissions();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
player.recalculatePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,6 +283,12 @@ public class BukkitPermissions {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List all effective permissions for this player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public List<String> listPerms(Player player) {
|
||||
List<String> perms = new ArrayList<String>();
|
||||
|
||||
@ -266,6 +310,9 @@ public class BukkitPermissions {
|
||||
return perms;
|
||||
}
|
||||
|
||||
/**
|
||||
* force Bukkit to update every OnlinePlayers permissions.
|
||||
*/
|
||||
public void updateAllPlayers() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
updatePermissions(player);
|
||||
@ -326,7 +373,7 @@ public class BukkitPermissions {
|
||||
if (!GroupManager.isLoaded())
|
||||
return;
|
||||
|
||||
collectPermissions();
|
||||
//collectPermissions();
|
||||
updateAllPlayers();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: GroupManager
|
||||
version: "1.7 (Phoenix)"
|
||||
version: "1.8 (Phoenix)"
|
||||
main: org.anjocaido.groupmanager.GroupManager
|
||||
website: http://www.anjocaido.info/
|
||||
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.
|
||||
|
@ -3,7 +3,7 @@ users:
|
||||
snowleo:
|
||||
subgroups: []
|
||||
permissions: []
|
||||
group: Admin
|
||||
group: Builder
|
||||
KHobbits:
|
||||
subgroups: []
|
||||
permissions: []
|
||||
@ -11,5 +11,5 @@ users:
|
||||
ElgarL:
|
||||
subgroups: []
|
||||
permissions: []
|
||||
group: Owner
|
||||
group: Moderator
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user