diff options
author | Iaccidentally <coryhuckaby@gmail.com> | 2013-01-14 17:25:32 -0500 |
---|---|---|
committer | Iaccidentally <coryhuckaby@gmail.com> | 2013-01-14 17:25:32 -0500 |
commit | b757d96fd82cf33e60ab9abbf025cc25f9ff249f (patch) | |
tree | 3fc9203912fb0a8cbdf3dc1784cc0f650f7a8de1 /EssentialsGroupManager | |
parent | 825611eb07f7ce1ba2f0b73703814257752119a4 (diff) | |
parent | 631a35dc821306e766b6c16e9eab2a95c890090c (diff) | |
download | Essentials-b757d96fd82cf33e60ab9abbf025cc25f9ff249f.tar Essentials-b757d96fd82cf33e60ab9abbf025cc25f9ff249f.tar.gz Essentials-b757d96fd82cf33e60ab9abbf025cc25f9ff249f.tar.lz Essentials-b757d96fd82cf33e60ab9abbf025cc25f9ff249f.tar.xz Essentials-b757d96fd82cf33e60ab9abbf025cc25f9ff249f.zip |
Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9
Diffstat (limited to 'EssentialsGroupManager')
6 files changed, 53 insertions, 24 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 175d59959..bbdab6a4f 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -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).
\ No newline at end of file + - 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'.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java index 95fd35eb0..4fcd0a554 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java @@ -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. diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index a148ed728..474ceae84 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -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(); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index e954a88fd..59efb33dc 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -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 diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 6b02a2286..03742b023 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -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);
}
diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml index 19496ad84..eaea6232d 100644 --- a/EssentialsGroupManager/src/users.yml +++ b/EssentialsGroupManager/src/users.yml @@ -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 |