summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2013-01-11 00:53:48 +0000
committerElgarL <ElgarL@palmergames.com>2013-01-11 00:53:48 +0000
commit999d922fb972651fd45f4cccb42d76f29da1e8ce (patch)
tree35b4601dc794b93d3e3db9799ed49397b31ece57 /EssentialsGroupManager
parentf25693026905df423b8e92f9cb252a292c50fcab (diff)
downloadEssentials-999d922fb972651fd45f4cccb42d76f29da1e8ce.tar
Essentials-999d922fb972651fd45f4cccb42d76f29da1e8ce.tar.gz
Essentials-999d922fb972651fd45f4cccb42d76f29da1e8ce.tar.lz
Essentials-999d922fb972651fd45f4cccb42d76f29da1e8ce.tar.xz
Essentials-999d922fb972651fd45f4cccb42d76f29da1e8ce.zip
Store a plugin and server reference.
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java2
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java5
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java6
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java5
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java27
5 files changed, 24 insertions, 21 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index e8e157d1d..8298988e6 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -88,7 +88,7 @@ public class GroupManager extends JavaPlugin {
/*
* Initialize the event handler
*/
- setGMEventHandler(new GroupManagerEventHandler(this.getServer()));
+ setGMEventHandler(new GroupManagerEventHandler(this));
onEnable(false);
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java
index b0e5e1755..fe7c98640 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMGroupEvent.java
@@ -2,7 +2,6 @@ package org.anjocaido.groupmanager.events;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
-import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -75,12 +74,12 @@ public class GMGroupEvent extends Event {
public void schedule(final GMGroupEvent event) {
synchronized (GroupManager.getGMEventHandler().getServer()) {
- if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
+ if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() {
@Override
public void run() {
- Bukkit.getServer().getPluginManager().callEvent(event);
+ GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event);
}
}, 1) == -1)
GroupManager.logger.warning("Could not schedule GM Event.");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java
index b89db6147..a04190d99 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMSystemEvent.java
@@ -1,7 +1,6 @@
package org.anjocaido.groupmanager.events;
import org.anjocaido.groupmanager.GroupManager;
-import org.bukkit.Server;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -30,7 +29,6 @@ public class GMSystemEvent extends Event {
//////////////////////////////
protected Action action;
- protected Server server;
public GMSystemEvent(Action action) {
@@ -51,12 +49,12 @@ public class GMSystemEvent extends Event {
public void schedule(final GMSystemEvent event) {
synchronized (GroupManager.getGMEventHandler().getServer()) {
- if (server.getScheduler().scheduleSyncDelayedTask(server.getPluginManager().getPlugin("GroupManager"), new Runnable() {
+ if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() {
@Override
public void run() {
- server.getPluginManager().callEvent(event);
+ GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event);
}
}, 1) == -1)
GroupManager.logger.warning("Could not schedule GM Event.");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java
index b4392a3e1..12c9baa0e 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GMUserEvent.java
@@ -2,7 +2,6 @@ package org.anjocaido.groupmanager.events;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.User;
-import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -75,12 +74,12 @@ public class GMUserEvent extends Event {
public void schedule(final GMUserEvent event) {
synchronized (GroupManager.getGMEventHandler().getServer()) {
- if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
+ if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() {
@Override
public void run() {
- Bukkit.getServer().getPluginManager().callEvent(event);
+ GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event);
}
}, 1) == -1)
GroupManager.logger.warning("Could not schedule GM Event.");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
index dd24dffdb..d0df57aa7 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
@@ -1,5 +1,6 @@
package org.anjocaido.groupmanager.events;
+import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
import org.anjocaido.groupmanager.data.User;
import org.bukkit.Server;
@@ -12,10 +13,15 @@ import org.bukkit.Server;
*/
public class GroupManagerEventHandler {
- protected Server server;
+ private final Server server;
+ private final GroupManager plugin;
- public GroupManagerEventHandler(Server server) {
- this.server = server;
+
+ public GroupManagerEventHandler(GroupManager plugin) {
+
+ this.plugin = plugin;
+ this.server = plugin.getServer();
+
}
protected void callEvent(GMGroupEvent event) {
@@ -59,19 +65,20 @@ public class GroupManagerEventHandler {
}
/**
- * @return the server
+ * @return the plugin
*/
- public Server getServer() {
+ public GroupManager getPlugin() {
- return server;
+ return plugin;
}
-
/**
- * @param server the server to set
+ * @return the server
*/
- public void setServer(Server server) {
+ public Server getServer() {
- this.server = server;
+ return server;
}
+
+
} \ No newline at end of file