Merge remote-tracking branch 'remotes/origin/groupmanager' into 2.9

This commit is contained in:
KHobbits 2013-01-14 07:37:11 +00:00
commit 115c4fa1d0
6 changed files with 53 additions and 24 deletions

View File

@ -205,4 +205,6 @@ v 2.0:
- Add support for Rcon.
- Prevent GM commands from being used on CommandBlocks.
- Clear our attachment map upon a manload so we correctly reconfigure a players new permissions.
- Synchronize the raising of GroupManager events to Bukkit.getServer() (should prevent deadlocks).
- Synchronize the raising of GroupManager events to Bukkit.getServer() (should prevent deadlocks).
- Synchronize pushing to Bukkit perms to prevent any ConcurrentModificationException.
- Do not grant any permissions (nor update Bukkit) if the server is in offline mode and the player has the permission node 'groupmanager.noofflineperms'.

View File

@ -112,7 +112,7 @@ public class GMConfiguration {
Object level = ((Map<String, String>) getElement("settings", GMconfig).get("logging")).get("level");
if (level instanceof String)
level = (String) level;
loggerLevel = (String) level;
/*
* Store our mirrors map for parsing later.

View File

@ -152,7 +152,7 @@ public class GroupManager extends JavaPlugin {
ch = new GMLoggerHandler();
GroupManager.logger.addHandler(ch);
}
logger.setLevel(Level.ALL);
GroupManager.logger.setLevel(Level.ALL);
// Create the backup folder, if it doesn't exist.
prepareFileFields();

View File

@ -16,6 +16,7 @@ import org.anjocaido.groupmanager.data.Group;
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
import org.anjocaido.groupmanager.data.User;
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
@ -784,6 +785,15 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if (user == null || targetPermission == null || targetPermission.isEmpty()) {
return result;
}
/*
* Do not push any perms to bukkit if...
* We are in offline mode
* and the player has the 'groupmanager.noofflineperms' permission.
*/
if (!Bukkit.getServer().getOnlineMode()
&& (checkFullGMPermission(user, "groupmanager.noofflineperms", true).resultType == PermissionCheckResult.Type.FOUND))
return result;
if (checkBukkit) {
// Check Bukkit perms to support plugins which add perms via code

View File

@ -31,7 +31,6 @@ import java.util.WeakHashMap;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.User;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -137,8 +136,7 @@ public class BukkitPermissions {
/**
* Push all permissions which are registered with GM for this player, on
* this world to Bukkit
* and make it update for the child nodes.
* this world to Bukkit and make it update for the child nodes.
*
* @param player
* @param world
@ -148,9 +146,9 @@ public class BukkitPermissions {
if (player == null || !GroupManager.isLoaded()) {
return;
}
String name = player.getName();
// Reset the User objects player reference.
User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(name);
if (user != null)
@ -175,7 +173,8 @@ public class BukkitPermissions {
List<String> playerPermArray = new ArrayList<String>(plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getAllPlayersPermissions(name, false));
LinkedHashMap<String, Boolean> newPerms = new LinkedHashMap<String, Boolean>();
// Sort the perm list by parent/child, so it will push to superperms correctly.
// Sort the perm list by parent/child, so it will push to superperms
// correctly.
playerPermArray = sort(playerPermArray);
Boolean value = false;
@ -183,28 +182,43 @@ public class BukkitPermissions {
value = (!permission.startsWith("-"));
newPerms.put((value ? permission : permission.substring(1)), value);
}
/*
* Do not push any perms to bukkit if...
* We are in offline mode
* and the player has the 'groupmanager.noofflineperms' permission.
*/
if (!Bukkit.getServer().getOnlineMode()
&& (newPerms.containsKey("groupmanager.noofflineperms") && (newPerms.get("groupmanager.noofflineperms") == true))) {
removeAttachment(name);
return;
}
/**
* This is put in place until such a time as Bukkit pull 466 is
* implemented
* https://github.com/Bukkit/Bukkit/pull/466
* 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();
//player.recalculatePermissions();
synchronized (attachment.getPermissible()) {
@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();
}
GroupManager.logger.finest("Attachment updated for: " + name);
}

View File

@ -3,13 +3,16 @@ users:
snowleo:
group: Builder
subgroups: []
permissions: []
permissions:
- groupmanager.noofflineperms
KHobbits:
group: Moderator
subgroups: []
permissions: []
permissions:
- groupmanager.noofflineperms
ElgarL:
group: Moderator
subgroups: []
permissions: []
permissions:
- groupmanager.noofflineperms