diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-01-14 07:37:11 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-01-14 07:37:11 +0000 |
commit | 115c4fa1d098ba31c2d5408d2563a0c90c56f105 (patch) | |
tree | 2e7b50b5b55d25172e2c142d9b646cf10fed1f67 | |
parent | 0c19b2feed9f44e08086a573fc2dc232d8d1d729 (diff) | |
parent | 675c4b7897d906f1d8ca0ef0176b88dc09049419 (diff) | |
download | Essentials-115c4fa1d098ba31c2d5408d2563a0c90c56f105.tar Essentials-115c4fa1d098ba31c2d5408d2563a0c90c56f105.tar.gz Essentials-115c4fa1d098ba31c2d5408d2563a0c90c56f105.tar.lz Essentials-115c4fa1d098ba31c2d5408d2563a0c90c56f105.tar.xz Essentials-115c4fa1d098ba31c2d5408d2563a0c90c56f105.zip |
Merge remote-tracking branch 'remotes/origin/groupmanager' into 2.9
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 |