summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org/anjocaido/groupmanager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2011-10-12 00:16:53 +0100
committerElgarL <ElgarL@palmergames.com>2011-10-12 00:16:53 +0100
commit03adb56d256315924fd3cb14e5281dec28967195 (patch)
tree154cf9058b93da1e157ffa438357ec5c14a84e80 /EssentialsGroupManager/src/org/anjocaido/groupmanager
parent1543bfd5504eeaa83c48b27077bdf7a66f5bc715 (diff)
downloadEssentials-03adb56d256315924fd3cb14e5281dec28967195.tar
Essentials-03adb56d256315924fd3cb14e5281dec28967195.tar.gz
Essentials-03adb56d256315924fd3cb14e5281dec28967195.tar.lz
Essentials-03adb56d256315924fd3cb14e5281dec28967195.tar.xz
Essentials-03adb56d256315924fd3cb14e5281dec28967195.zip
Added a config setting - bukkit_perms_override: false
Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java13
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java29
3 files changed, 34 insertions, 11 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index 0d9f927d9..af21b31bb 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -52,6 +52,9 @@ public class GMConfiguration {
}
public boolean isOpOverride() {
+ return GMconfig.getBoolean("settings.config.bukkit_perms_override", true);
+ }
+ public boolean isBukkitPermsOverride() {
return GMconfig.getBoolean("settings.config.opOverrides", true);
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index 92d50ca5d..1f55f73ad 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -57,7 +57,7 @@ public class GroupManager extends JavaPlugin {
private boolean validateOnlinePlayer = true;
private boolean isReady = false;
private static boolean isLoaded = false;
- private GMConfiguration config;
+ protected GMConfiguration config;
private GMLoggerHandler ch;
public static BukkitPermissions BukkitPermissions;
private static WorldListener WorldEvents;
@@ -369,7 +369,8 @@ public class GroupManager extends JavaPlugin {
//PARECE OK
auxUser.setGroup(auxGroup);
- sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
+ if (!sender.hasPermission("groupmanager.notify.other"))
+ sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
@@ -1590,7 +1591,8 @@ public class GroupManager extends JavaPlugin {
}
//PARECE OK
auxUser.setGroup(auxGroup);
- sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
+ if (!sender.hasPermission("groupmanager.notify.other"))
+ sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
@@ -1648,7 +1650,8 @@ public class GroupManager extends JavaPlugin {
}
//PARECE OK
auxUser.setGroup(auxGroup);
- sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
+ if (!sender.hasPermission("groupmanager.notify.other"))
+ sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
@@ -1773,7 +1776,7 @@ public class GroupManager extends JavaPlugin {
test.sendMessage(ChatColor.YELLOW + name +" was" + msg);
} else
if ((player != null) && ((player.hasPermission("groupmanager.notify.self")) || (player.hasPermission("groupmanager.notify.other"))))
- player.sendMessage(ChatColor.YELLOW + "You we're" + msg);
+ player.sendMessage(ChatColor.YELLOW + "You were" + msg);
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 19d90854b..6a5968c22 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -43,6 +43,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.plugin.PluginManager;
@@ -124,15 +125,31 @@ public class BukkitPermissions {
User user = worldData.getUser(player.getName());
- // clear permissions
- for (String permission : attachment.getPermissions().keySet()) {
- attachment.unsetPermission(permission);
- }
+ // clear permissions
+ for (String permission : attachment.getPermissions().keySet())
+ attachment.unsetPermission(permission);
- // find matching permissions
+ /*
+ * find matching permissions
+ *
+ * and base bukkit perms if we are set to allow bukkit permissions to override.
+ */
Boolean value;
for (Permission permission : registeredPermissions) {
- value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
+
+ value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
+
+ // Only check bukkit override IF we don't have the permission directly.
+ if (value = false) {
+ PermissionDefault permDefault = permission.getDefault();
+
+ if ((plugin.getGMConfig().isBukkitPermsOverride())
+ && ((permDefault == PermissionDefault.TRUE)
+ || ((permDefault == PermissionDefault.NOT_OP) && !player.isOp())
+ || ((permDefault == PermissionDefault.OP) && player.isOp())))
+ value = true;
+ }
+
if (value == true)
attachment.setPermission(permission, value);
}