Merge remote-tracking branch 'origin/groupmanager' into 2.9

This commit is contained in:
Chris Ward 2013-01-11 21:59:39 +11:00
commit 29d28456aa
5 changed files with 24 additions and 21 deletions

View File

@ -88,7 +88,7 @@ public class GroupManager extends JavaPlugin {
/*
* Initialize the event handler
*/
setGMEventHandler(new GroupManagerEventHandler(this.getServer()));
setGMEventHandler(new GroupManagerEventHandler(this));
onEnable(false);
}

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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) {
@ -58,6 +64,14 @@ public class GroupManagerEventHandler {
callEvent(new GMSystemEvent(action));
}
/**
* @return the plugin
*/
public GroupManager getPlugin() {
return plugin;
}
/**
* @return the server
*/
@ -67,11 +81,4 @@ public class GroupManagerEventHandler {
}
/**
* @param server the server to set
*/
public void setServer(Server server) {
this.server = server;
}
}