mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-23 00:21:26 +01:00
Update event Action names to be unique
This commit is contained in:
parent
759892078a
commit
5b195299ba
@ -119,7 +119,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded()) {
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManagerEventHandler.callEvent(this, Action.INHERITANCE_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||
if (this.inherits.contains(inherit.toLowerCase())) {
|
||||
this.inherits.remove(inherit.toLowerCase());
|
||||
flagAsChanged();
|
||||
GroupManagerEventHandler.callEvent(this, Action.INHERITANCE_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -153,7 +153,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded()) {
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManagerEventHandler.callEvent(this, Action.INFO_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
if (notify)
|
||||
GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
|
||||
|
||||
GroupManagerEventHandler.callEvent(this, Action.GROUP_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_GROUP_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManagerEventHandler.callEvent(this, Action.SUBGROUP_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
if (GroupManager.isLoaded())
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManagerEventHandler.callEvent(this, Action.SUBGROUP_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -231,7 +231,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
GroupManagerEventHandler.callEvent(this, Action.INFO_CHANGED);
|
||||
GroupManagerEventHandler.callEvent(this, Action.USER_INFO_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GMGroupEvent extends GroupManagerEvent {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5294917600434510451L;
|
||||
|
||||
protected Group group;
|
||||
|
||||
protected String groupName;
|
||||
|
||||
protected Action action;
|
||||
|
||||
public GMGroupEvent(Group group, Action action) {
|
||||
super(action.toString());
|
||||
|
||||
this.group = group;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public GMGroupEvent(String groupName, Action action) {
|
||||
super(action.toString());
|
||||
|
||||
this.groupName = groupName;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Action getAction(){
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
GROUP_PERMISSIONS_CHANGED,
|
||||
GROUP_INHERITANCE_CHANGED,
|
||||
GROUP_INFO_CHANGED,
|
||||
GROUP_ADDED,
|
||||
GROUP_REMOVED,
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GMSystemEvent extends GroupManagerEvent {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8786811924448821548L;
|
||||
protected Action action;
|
||||
|
||||
public GMSystemEvent(Action action) {
|
||||
super(action.toString());
|
||||
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Action getAction(){
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
RELOADED,
|
||||
SAVED,
|
||||
DEFAULT_GROUP_CHANGED,
|
||||
VALIDATE_TOGGLE,
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GMUserEvent extends GroupManagerEvent {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5294917600434510451L;
|
||||
|
||||
protected User user;
|
||||
|
||||
protected String userName;
|
||||
|
||||
protected Action action;
|
||||
|
||||
public GMUserEvent(User user, Action action) {
|
||||
super(action.toString());
|
||||
|
||||
this.user = user;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public GMUserEvent(String userName, Action action) {
|
||||
super(action.toString());
|
||||
|
||||
this.userName = userName;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Action getAction(){
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
USER_PERMISSIONS_CHANGED,
|
||||
USER_INHERITANCE_CHANGED,
|
||||
USER_INFO_CHANGED,
|
||||
USER_GROUP_CHANGED,
|
||||
USER_SUBGROUP_CHANGED,
|
||||
USER_ADDED,
|
||||
USER_REMOVED,
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public abstract class GroupManagerEvent extends Event {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8790362185329926951L;
|
||||
|
||||
protected GroupManagerEvent(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package org.anjocaido.groupmanager.events;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author ElgarL
|
||||
*
|
||||
*/
|
||||
public class GroupManagerEventHandler {
|
||||
|
||||
protected static void callEvent(GMGroupEvent event) {
|
||||
GroupManager.callEvent(event);
|
||||
}
|
||||
protected static void callEvent(GMUserEvent event) {
|
||||
GroupManager.callEvent(event);
|
||||
}
|
||||
protected static void callEvent(GMSystemEvent event) {
|
||||
GroupManager.callEvent(event);
|
||||
}
|
||||
|
||||
public static void callEvent(Group group, GMGroupEvent.Action action) {
|
||||
callEvent(new GMGroupEvent(group, action));
|
||||
}
|
||||
public static void callEvent(String groupName, GMGroupEvent.Action action) {
|
||||
callEvent(new GMGroupEvent(groupName, action));
|
||||
}
|
||||
|
||||
public static void callEvent(User user, GMUserEvent.Action action) {
|
||||
callEvent(new GMUserEvent(user, action));
|
||||
}
|
||||
public static void callEvent(String userName, GMUserEvent.Action action) {
|
||||
callEvent(new GMUserEvent(userName, action));
|
||||
}
|
||||
|
||||
public static void callEvent(GMSystemEvent.Action action) {
|
||||
callEvent(new GMSystemEvent(action));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user