2016-03-01 03:15:02 +00:00
|
|
|
package org.anjocaido.groupmanager.events;
|
|
|
|
|
|
|
|
import org.anjocaido.groupmanager.GroupManager;
|
|
|
|
import org.bukkit.event.Event;
|
|
|
|
import org.bukkit.event.HandlerList;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author ElgarL
|
2016-03-01 12:32:27 +00:00
|
|
|
*
|
2016-03-01 03:15:02 +00:00
|
|
|
*/
|
|
|
|
public class GMSystemEvent extends Event {
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
2016-03-01 12:32:27 +00:00
|
|
|
protected Action action;
|
2016-03-01 03:15:02 +00:00
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
public GMSystemEvent(final Action action) {
|
|
|
|
super();
|
|
|
|
this.action = action;
|
2016-03-01 03:15:02 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
//////////////////////////////
|
2016-03-01 03:15:02 +00:00
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action getAction() {
|
|
|
|
return this.action;
|
|
|
|
}
|
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
@Override
|
|
|
|
public HandlerList getHandlers() {
|
|
|
|
return handlers;
|
2016-03-01 03:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void schedule(final GMSystemEvent event) {
|
|
|
|
synchronized (GroupManager.getGMEventHandler().getServer()) {
|
|
|
|
if (GroupManager.getGMEventHandler().getServer().getScheduler().scheduleSyncDelayedTask(GroupManager.getGMEventHandler().getPlugin(), new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
GroupManager.getGMEventHandler().getServer().getPluginManager().callEvent(event);
|
|
|
|
}
|
|
|
|
}, 1) == -1)
|
|
|
|
GroupManager.logger.warning("Could not schedule GM Event.");
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 12:32:27 +00:00
|
|
|
|
|
|
|
public enum Action {
|
|
|
|
RELOADED,
|
|
|
|
SAVED,
|
|
|
|
DEFAULT_GROUP_CHANGED,
|
|
|
|
VALIDATE_TOGGLE,
|
|
|
|
}
|
2016-03-01 03:15:02 +00:00
|
|
|
}
|