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 | 79004c7098f96247f798d9f04d26cb0d9594d65d (patch) | |
tree | 427858cc3e03dc749d2c04dc745c695691a72815 /EssentialsGroupManager/src/org/anjocaido/groupmanager/events | |
parent | 2988db08cabac2848c85dec26aa53dcb033b41fb (diff) | |
parent | f25693026905df423b8e92f9cb252a292c50fcab (diff) | |
download | Essentials-79004c7098f96247f798d9f04d26cb0d9594d65d.tar Essentials-79004c7098f96247f798d9f04d26cb0d9594d65d.tar.gz Essentials-79004c7098f96247f798d9f04d26cb0d9594d65d.tar.lz Essentials-79004c7098f96247f798d9f04d26cb0d9594d65d.tar.xz Essentials-79004c7098f96247f798d9f04d26cb0d9594d65d.zip |
Merge branch 'groupmanager' into 2.9
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/events')
4 files changed, 68 insertions, 37 deletions
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 |