2016-03-01 03:15:02 +00:00
|
|
|
package org.anjocaido.groupmanager.events;
|
|
|
|
|
|
|
|
import org.anjocaido.groupmanager.GroupManager;
|
|
|
|
import org.anjocaido.groupmanager.data.User;
|
|
|
|
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 GMUserEvent extends Event {
|
|
|
|
|
|
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
protected User user;
|
|
|
|
protected String userName;
|
2016-03-01 12:32:27 +00:00
|
|
|
//////////////////////////////
|
2016-03-01 03:15:02 +00:00
|
|
|
protected Action action;
|
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
public GMUserEvent(final String userName, final Action action) {
|
2016-03-01 03:15:02 +00:00
|
|
|
super();
|
2016-03-01 12:32:27 +00:00
|
|
|
this.userName = userName;
|
|
|
|
this.action = action;
|
|
|
|
}
|
2016-03-01 03:15:02 +00:00
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
public GMUserEvent(final User user, final Action action) {
|
|
|
|
super();
|
2016-03-01 03:15:02 +00:00
|
|
|
this.user = user;
|
|
|
|
this.action = action;
|
|
|
|
this.userName = user.getLastName();
|
|
|
|
}
|
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
public static HandlerList getHandlerList() {
|
|
|
|
return handlers;
|
2016-03-01 03:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-03-01 12:32:27 +00:00
|
|
|
public User getUser() {
|
2016-03-01 03:15:02 +00:00
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUserName() {
|
|
|
|
return userName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void schedule(final GMUserEvent 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 {
|
|
|
|
USER_PERMISSIONS_CHANGED,
|
|
|
|
USER_INHERITANCE_CHANGED,
|
|
|
|
USER_INFO_CHANGED,
|
|
|
|
USER_GROUP_CHANGED,
|
|
|
|
USER_SUBGROUP_CHANGED,
|
|
|
|
USER_ADDED,
|
|
|
|
USER_REMOVED,
|
|
|
|
}
|
2016-03-01 03:15:02 +00:00
|
|
|
}
|