summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-01-13 01:38:54 +0100
committersnowleo <schneeleo@gmail.com>2012-01-13 01:38:54 +0100
commit9006183de4aa7ac69f77ad3bbd88995f7307b89d (patch)
treec16d07fb30be099d4df0414589ebb6e2f9aa8954
parentd09343a6030bcd10a3929b1f2d843b72ef3b0c9c (diff)
parent49a19a771757da2bd0b73ed91ec8549f16810c9c (diff)
downloadEssentials-9006183de4aa7ac69f77ad3bbd88995f7307b89d.tar
Essentials-9006183de4aa7ac69f77ad3bbd88995f7307b89d.tar.gz
Essentials-9006183de4aa7ac69f77ad3bbd88995f7307b89d.tar.lz
Essentials-9006183de4aa7ac69f77ad3bbd88995f7307b89d.tar.xz
Essentials-9006183de4aa7ac69f77ad3bbd88995f7307b89d.zip
Merge branch 'refs/heads/groupmanager'
-rw-r--r--EssentialsGroupManager/src/Changelog.txt14
-rw-r--r--EssentialsGroupManager/src/config.yml4
-rw-r--r--EssentialsGroupManager/src/globalgroups.yml64
-rw-r--r--EssentialsGroupManager/src/groups.yml3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java59
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java2
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java19
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java22
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java8
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java117
-rw-r--r--EssentialsGroupManager/src/plugin.yml2
-rw-r--r--EssentialsGroupManager/src/users.yml4
13 files changed, 224 insertions, 97 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 47a0f6b79..6ac58e8ff 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -85,4 +85,16 @@ v 1.7:
- Offline player checks now support partial name matches.
- 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. \ No newline at end of file
+ - 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. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml
index 2fe5e509c..17ffc5b6e 100644
--- a/EssentialsGroupManager/src/config.yml
+++ b/EssentialsGroupManager/src/config.yml
@@ -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.
diff --git a/EssentialsGroupManager/src/globalgroups.yml b/EssentialsGroupManager/src/globalgroups.yml
index 9662baf43..c9ecc2673 100644
--- a/EssentialsGroupManager/src/globalgroups.yml
+++ b/EssentialsGroupManager/src/globalgroups.yml
@@ -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 \ No newline at end of file
diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml
index 81fb4f030..e50054c9f 100644
--- a/EssentialsGroupManager/src/groups.yml
+++ b/EssentialsGroupManager/src/groups.yml
@@ -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
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index 2d46e74c8..4ba2624bf 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -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,29 +787,29 @@ 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]);
- 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.");
- } else {
- sender.sendMessage(ChatColor.YELLOW + "The user has directly this permission.");
- }
- 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());
- } else {
- sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName());
+
+ } 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.");
+ } else {
+ sender.sendMessage(ChatColor.YELLOW + "The user has directly this permission.");
+ }
+ 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 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);
}
- sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
}
// superperms
@@ -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());
@@ -1837,15 +1839,6 @@ public class GroupManager extends JavaPlugin {
return match;
}
-
- /**
- * 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
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
index f4b805c35..8788fc83b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
@@ -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!");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 25eaf8526..dbdd17f34 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -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();
- }
- }
}
/**
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java
index 856abbc28..0834b3ada 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java
@@ -1,6 +1,8 @@
package org.anjocaido.groupmanager.events;
+import org.anjocaido.groupmanager.GroupManager;
+import org.bukkit.Bukkit;
import org.bukkit.event.Event;
/**
@@ -13,10 +15,28 @@ public abstract class GroupManagerEvent extends Event {
*
*/
private static final long serialVersionUID = 8790362185329926951L;
-
+
protected GroupManagerEvent(String name) {
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.");
+ }
+
} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
index 83cac393d..3c077b6c6 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
@@ -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) {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index 6e18bf3f8..b23fc01d4 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -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;
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 202e27e3a..7c157a2f7 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -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 {
@@ -62,13 +62,25 @@ public class BukkitPermissions {
protected boolean dumpAllPermissions = true;
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,43 +113,56 @@ 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
*
* 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,35 +189,47 @@ 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;
if (permission.startsWith("-")) {
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();
}
diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml
index 115e92ba2..da5164ce1 100644
--- a/EssentialsGroupManager/src/plugin.yml
+++ b/EssentialsGroupManager/src/plugin.yml
@@ -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.
diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml
index 28fa79910..72a7b652f 100644
--- a/EssentialsGroupManager/src/users.yml
+++ b/EssentialsGroupManager/src/users.yml
@@ -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