diff options
author | Chris Ward <chris@chrisgward.com> | 2013-01-10 04:57:10 +1100 |
---|---|---|
committer | Chris Ward <chris@chrisgward.com> | 2013-01-10 04:57:10 +1100 |
commit | 8a7866ecca2db4491670cd6b73071eec8862b816 (patch) | |
tree | eb5069aec2161d270b9cc38133044a1fbf48d1f9 /EssentialsGroupManager/src | |
parent | 1908054d099178ae5bf2da8b1c99b4fe35711224 (diff) | |
parent | 767057512abbba410631ea2a29068b6fc79c92d0 (diff) | |
download | Essentials-8a7866ecca2db4491670cd6b73071eec8862b816.tar Essentials-8a7866ecca2db4491670cd6b73071eec8862b816.tar.gz Essentials-8a7866ecca2db4491670cd6b73071eec8862b816.tar.lz Essentials-8a7866ecca2db4491670cd6b73071eec8862b816.tar.xz Essentials-8a7866ecca2db4491670cd6b73071eec8862b816.zip |
Merge branch 'groupmanager' into 2.9
Diffstat (limited to 'EssentialsGroupManager/src')
11 files changed, 131 insertions, 76 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 4ea195a5d..175d59959 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -203,4 +203,6 @@ v 2.0: - Add alphabetically sorted user lists.
- allWorldsDataList now returns fully mirrored worlds which are not identical mirrors (fixes the /manselect list).
- Add support for Rcon.
- - Prevent GM commands from being used on CommandBlocks.
\ No newline at end of file + - 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 diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java index cf63dd8d7..ea0e5bc7c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java @@ -16,7 +16,6 @@ import java.util.logging.Level; import org.anjocaido.groupmanager.data.Group;
import org.anjocaido.groupmanager.events.GMGroupEvent;
-import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.anjocaido.groupmanager.utils.Tasks;
import org.yaml.snakeyaml.DumperOptions;
@@ -308,7 +307,7 @@ public class GlobalGroups { newGroup(groupToAdd);
haveGroupsChanged = true;
if (GroupManager.isLoaded())
- GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
+ GroupManager.getGMEventHandler().callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
}
/**
@@ -339,7 +338,7 @@ public class GlobalGroups { groups.remove(groupName.toLowerCase());
this.setGroupsChanged(true);
if (GroupManager.isLoaded())
- GroupManagerEventHandler.callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED);
+ GroupManager.getGMEventHandler().callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED);
return true;
}
return false;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index fe7808238..42b48ba74 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -65,6 +65,8 @@ public class GroupManager extends JavaPlugin { protected static GlobalGroups globalGroups; private GMLoggerHandler ch; + + private static GroupManagerEventHandler GMEventHandler; public static BukkitPermissions BukkitPermissions; private static GMWorldListener WorldEvents; public static final Logger logger = Logger.getLogger(GroupManager.class.getName()); @@ -83,7 +85,10 @@ public class GroupManager extends JavaPlugin { @Override public void onEnable() { - + /* + * Initialize the event handler + */ + setGMEventHandler(new GroupManagerEventHandler(this.getServer())); onEnable(false); } @@ -399,7 +404,7 @@ public class GroupManager extends JavaPlugin { senderPlayer = (Player) sender; if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) { - sender.sendMessage(ChatColor.RED + "All commands are locked due to an error." + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + " and then try a '/manload'."); + sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. " + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + "" + ChatColor.RED + " and then try a '/manload'."); return true; } @@ -414,7 +419,7 @@ public class GroupManager extends JavaPlugin { } else if ((sender instanceof ConsoleCommandSender) || (sender instanceof RemoteConsoleCommandSender)) { if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) { - sender.sendMessage(ChatColor.RED + "All commands are locked due to an error." + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + " and then try a '/manload'."); + sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. " + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + "" + ChatColor.RED + " and then try a '/manload'."); return true; } @@ -726,7 +731,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating your permissions - if (!isConsole && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify player with same group than you, or higher."); return false; } @@ -959,7 +964,7 @@ public class GroupManager extends JavaPlugin { } // Validating your permissions permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]); - if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { + if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { sender.sendMessage(ChatColor.RED + "You can't add a permission you don't have."); return false; } @@ -1112,7 +1117,7 @@ public class GroupManager extends JavaPlugin { // auxString = permissionHandler.checkUserOnlyPermission(auxUser, args[1]); if (permissionResult.owner instanceof Group) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { - sender.sendMessage(ChatColor.RED + "The group inherits the a negation permission from group: " + permissionResult.owner.getName()); + sender.sendMessage(ChatColor.RED + "The group inherits the negation permission from group: " + permissionResult.owner.getName()); } else { sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName()); } @@ -1550,7 +1555,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating permission - if (!isConsole && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher."); return false; } @@ -1584,7 +1589,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating permission - if (!isConsole && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return false; } @@ -1681,7 +1686,7 @@ public class GroupManager extends JavaPlugin { if (args.length > 0) { if (!lastError.isEmpty()) { - sender.sendMessage(ChatColor.RED + "All commands are locked due to an error." + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + " and then try a '/manload'."); + sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. " + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + "" + ChatColor.RED + " and then try a '/manload'."); return true; } @@ -1702,7 +1707,7 @@ public class GroupManager extends JavaPlugin { isLoaded = true; - BukkitPermissions.updateAllPlayers(); + BukkitPermissions.reset(); } else { @@ -1723,7 +1728,7 @@ public class GroupManager extends JavaPlugin { * Fire an event as none will have been triggered in the reload. */ if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED); + GroupManager.getGMEventHandler().callEvent(GMSystemEvent.Action.RELOADED); return true; @@ -2050,4 +2055,14 @@ public class GroupManager extends JavaPlugin { return globalGroups; } -}
\ No newline at end of file + + public static GroupManagerEventHandler getGMEventHandler() { + + return GMEventHandler; + } + + public static void setGMEventHandler(GroupManagerEventHandler gMEventHandler) { + + GMEventHandler = gMEventHandler; + } +} diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java index 8da6ba85a..c0c19c997 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java @@ -7,8 +7,6 @@ package org.anjocaido.groupmanager.data; import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import org.anjocaido.groupmanager.events.GMGroupEvent.Action; -import org.anjocaido.groupmanager.events.GroupManagerEventHandler; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -144,7 +142,7 @@ public class Group extends DataUnit implements Cloneable { flagAsChanged(); if (GroupManager.isLoaded()) { GroupManager.BukkitPermissions.updateAllPlayers(); - GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.GROUP_INHERITANCE_CHANGED); } } } @@ -157,7 +155,7 @@ public class Group extends DataUnit implements Cloneable { clone.remove(inherit.toLowerCase()); inherits = Collections.unmodifiableList(clone); flagAsChanged(); - GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.GROUP_INHERITANCE_CHANGED); return true; } } @@ -187,7 +185,7 @@ public class Group extends DataUnit implements Cloneable { flagAsChanged(); if (GroupManager.isLoaded()) { GroupManager.BukkitPermissions.updateAllPlayers(); - GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.GROUP_INFO_CHANGED); } } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index a829bfa14..bbb2ae03a 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -12,8 +12,6 @@ import java.util.List; import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import org.anjocaido.groupmanager.events.GMUserEvent.Action; -import org.anjocaido.groupmanager.events.GroupManagerEventHandler; - import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -148,7 +146,7 @@ public class User extends DataUnit implements Cloneable { if (notify) GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName())); - GroupManagerEventHandler.callEvent(this, Action.USER_GROUP_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED); } } @@ -172,7 +170,7 @@ public class User extends DataUnit implements Cloneable { if (GroupManager.isLoaded()) { if (!GroupManager.BukkitPermissions.isPlayer_join()) GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); - GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED); } return true; @@ -204,7 +202,7 @@ public class User extends DataUnit implements Cloneable { if (GroupManager.isLoaded()) if (!GroupManager.BukkitPermissions.isPlayer_join()) GroupManager.BukkitPermissions.updatePlayer(getBukkitPlayer()); - GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.USER_SUBGROUP_CHANGED); return true; } } catch (Exception e) { @@ -257,7 +255,7 @@ public class User extends DataUnit implements Cloneable { if (GroupManager.isLoaded()) { //if (!GroupManager.BukkitPermissions.isPlayer_join()) // GroupManager.BukkitPermissions.updatePlayer(this.getName()); - GroupManagerEventHandler.callEvent(this, Action.USER_INFO_CHANGED); + GroupManager.getGMEventHandler().callEvent(this, Action.USER_INFO_CHANGED); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 263ad0cce..04efd384e 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -28,7 +28,6 @@ import org.anjocaido.groupmanager.events.GMGroupEvent; import org.anjocaido.groupmanager.events.GMSystemEvent; import org.anjocaido.groupmanager.events.GMUserEvent; import org.anjocaido.groupmanager.events.GMUserEvent.Action; -import org.anjocaido.groupmanager.events.GroupManagerEventHandler; import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler; import org.bukkit.Server; import org.bukkit.plugin.Plugin; @@ -137,7 +136,7 @@ public class WorldDataHolder { getUsers().put(theUser.getName().toLowerCase(), theUser); setUsersChanged(true); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(theUser, Action.USER_ADDED); + GroupManager.getGMEventHandler().callEvent(theUser, Action.USER_ADDED); } /** @@ -152,7 +151,7 @@ public class WorldDataHolder { getUsers().remove(userName.toLowerCase()); setUsersChanged(true); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(userName, GMUserEvent.Action.USER_REMOVED); + GroupManager.getGMEventHandler().callEvent(userName, GMUserEvent.Action.USER_REMOVED); return true; } return false; @@ -181,7 +180,7 @@ public class WorldDataHolder { groups.setDefaultGroup(getGroup(group.getName())); setGroupsChanged(true); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(GMSystemEvent.Action.DEFAULT_GROUP_CHANGED); + GroupManager.getGMEventHandler().callEvent(GMSystemEvent.Action.DEFAULT_GROUP_CHANGED); } /** @@ -232,7 +231,7 @@ public class WorldDataHolder { if (groupToAdd.getName().toLowerCase().startsWith("g:")) { GroupManager.getGlobalGroups().addGroup(groupToAdd); - GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED); + GroupManager.getGMEventHandler().callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED); return; } @@ -243,7 +242,7 @@ public class WorldDataHolder { getGroups().put(groupToAdd.getName().toLowerCase(), groupToAdd); setGroupsChanged(true); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED); + GroupManager.getGMEventHandler().callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED); } /** @@ -266,7 +265,7 @@ public class WorldDataHolder { getGroups().remove(groupName.toLowerCase()); setGroupsChanged(true); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED); + GroupManager.getGMEventHandler().callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED); return true; } return false; @@ -374,7 +373,7 @@ public class WorldDataHolder { Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex); } GroupManager.setLoaded(true); - GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED); + GroupManager.getGMEventHandler().callEvent(GMSystemEvent.Action.RELOADED); } /** @@ -406,7 +405,7 @@ public class WorldDataHolder { Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex); } GroupManager.setLoaded(true); - GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED); + GroupManager.getGMEventHandler().callEvent(GMSystemEvent.Action.RELOADED); } public void loadGroups(File groupsFile) { @@ -1002,7 +1001,7 @@ public class WorldDataHolder { ph.removeGroupsChangedFlag(); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED); + GroupManager.getGMEventHandler().callEvent(GMSystemEvent.Action.SAVED); /* * FileWriter tx = null; try { tx = new FileWriter(groupsFile, false); @@ -1081,7 +1080,7 @@ public class WorldDataHolder { ph.removeUsersChangedFlag(); if (GroupManager.isLoaded()) - GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED); + GroupManager.getGMEventHandler().callEvent(GMSystemEvent.Action.SAVED); /* * FileWriter tx = null; try { tx = new FileWriter(usersFile, false); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java index af3fb6135..b0e5e1755 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java @@ -74,14 +74,16 @@ public class GMGroupEvent extends Event { public void schedule(final GMGroupEvent 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.");
+ synchronized (GroupManager.getGMEventHandler().getServer()) {
+ 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/GMSystemEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java index d11581356..b89db6147 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java @@ -1,7 +1,7 @@ package org.anjocaido.groupmanager.events;
import org.anjocaido.groupmanager.GroupManager;
-import org.bukkit.Bukkit;
+import org.bukkit.Server;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -30,11 +30,12 @@ public class GMSystemEvent extends Event { //////////////////////////////
protected Action action;
+ protected Server server;
public GMSystemEvent(Action action) {
super();
-
+
this.action = action;
}
@@ -49,14 +50,16 @@ public class GMSystemEvent extends Event { public void schedule(final GMSystemEvent 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.");
+ synchronized (GroupManager.getGMEventHandler().getServer()) {
+ if (server.getScheduler().scheduleSyncDelayedTask(server.getPluginManager().getPlugin("GroupManager"), new Runnable() {
+
+ @Override
+ public void run() {
+
+ server.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/GMUserEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java index 361e7d4cc..b4392a3e1 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java @@ -74,14 +74,16 @@ public class GMUserEvent extends Event { public void schedule(final GMUserEvent 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.");
+ synchronized (GroupManager.getGMEventHandler().getServer()) {
+ 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 5fc555cc4..dd24dffdb 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java @@ -2,6 +2,7 @@ package org.anjocaido.groupmanager.events; import org.anjocaido.groupmanager.data.Group;
import org.anjocaido.groupmanager.data.User;
+import org.bukkit.Server;
/**
* @author ElgarL
@@ -10,44 +11,67 @@ import org.anjocaido.groupmanager.data.User; *
*/
public class GroupManagerEventHandler {
+
+ protected Server server;
+
+ public GroupManagerEventHandler(Server server) {
+ this.server = server;
+ }
- protected static void callEvent(GMGroupEvent event) {
+ protected void callEvent(GMGroupEvent event) {
event.schedule(event);
}
- protected static void callEvent(GMUserEvent event) {
+ protected void callEvent(GMUserEvent event) {
event.schedule(event);
}
- protected static void callEvent(GMSystemEvent event) {
+ protected void callEvent(GMSystemEvent event) {
event.schedule(event);
}
- public static void callEvent(Group group, GMGroupEvent.Action action) {
+ public void callEvent(Group group, GMGroupEvent.Action action) {
callEvent(new GMGroupEvent(group, action));
}
- public static void callEvent(String groupName, GMGroupEvent.Action action) {
+ public void callEvent(String groupName, GMGroupEvent.Action action) {
callEvent(new GMGroupEvent(groupName, action));
}
- public static void callEvent(User user, GMUserEvent.Action action) {
+ public void callEvent(User user, GMUserEvent.Action action) {
callEvent(new GMUserEvent(user, action));
}
- public static void callEvent(String userName, GMUserEvent.Action action) {
+ public void callEvent(String userName, GMUserEvent.Action action) {
callEvent(new GMUserEvent(userName, action));
}
- public static void callEvent(GMSystemEvent.Action action) {
+ public void callEvent(GMSystemEvent.Action action) {
callEvent(new GMSystemEvent(action));
}
+
+ /**
+ * @return the server
+ */
+ public Server getServer() {
+
+ return server;
+ }
+
+
+ /**
+ * @param server the server to set
+ */
+ public void setServer(Server server) {
+
+ this.server = server;
+ }
}
\ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index a4ddcf279..6b02a2286 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -103,6 +103,11 @@ public class BukkitPermissions { }
public void reset() {
+
+ /*
+ * collect new permissions
+ * and register all attachments.
+ */
this.collectPermissions();
this.updateAllPlayers();
}
@@ -382,8 +387,10 @@ public class BukkitPermissions { */
private void removeAttachment(String playerName) {
- if (attachments.containsKey(playerName))
+ if (attachments.containsKey(playerName)) {
+ attachments.get(playerName).remove();
attachments.remove(playerName);
+ }
}
/**
@@ -391,6 +398,12 @@ public class BukkitPermissions { */
public void removeAllAttachments() {
+ /*
+ * Remove all attachments.
+ */
+ for (String key : attachments.keySet()) {
+ attachments.get(key).remove();
+ }
attachments.clear();
}
|