mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-20 18:32:49 +00:00
Merge branch 'refs/heads/groupmanager'
This commit is contained in:
commit
79861b1f10
|
@ -82,4 +82,6 @@ v 1.6:
|
||||||
- Added file details in error messages for loading groups/users.
|
- Added file details in error messages for loading groups/users.
|
||||||
v 1.7:
|
v 1.7:
|
||||||
- GM now supports offline players without having to mantogglevalidate
|
- GM now supports offline players without having to mantogglevalidate
|
||||||
- Offline player checks now support partial name matches.
|
- Offline player checks now support partial name matches.
|
||||||
|
- Added custom events so plugins can now be notified of changes within GroupManager.
|
||||||
|
- GM now registers with Bukkits ServicesManager.
|
|
@ -14,6 +14,8 @@ import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.anjocaido.groupmanager.data.Group;
|
import org.anjocaido.groupmanager.data.Group;
|
||||||
|
import org.anjocaido.groupmanager.events.GMGroupEvent;
|
||||||
|
import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
|
||||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||||
import org.anjocaido.groupmanager.utils.Tasks;
|
import org.anjocaido.groupmanager.utils.Tasks;
|
||||||
import org.bukkit.configuration.MemorySection;
|
import org.bukkit.configuration.MemorySection;
|
||||||
|
@ -243,6 +245,8 @@ public class GlobalGroups {
|
||||||
|
|
||||||
newGroup(groupToAdd);
|
newGroup(groupToAdd);
|
||||||
haveGroupsChanged = true;
|
haveGroupsChanged = true;
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,6 +274,8 @@ public class GlobalGroups {
|
||||||
if (groups.containsKey(groupName.toLowerCase())) {
|
if (groups.containsKey(groupName.toLowerCase())) {
|
||||||
groups.remove(groupName.toLowerCase());
|
groups.remove(groupName.toLowerCase());
|
||||||
this.setGroupsChanged(true);
|
this.setGroupsChanged(true);
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
|
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
|
||||||
import org.anjocaido.groupmanager.events.GMWorldListener;
|
import org.anjocaido.groupmanager.events.GMWorldListener;
|
||||||
|
import org.anjocaido.groupmanager.events.GroupManagerEvent;
|
||||||
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
|
import org.anjocaido.groupmanager.utils.GMLoggerHandler;
|
||||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||||
import org.anjocaido.groupmanager.utils.Tasks;
|
import org.anjocaido.groupmanager.utils.Tasks;
|
||||||
|
@ -37,8 +38,10 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.world.WorldListener;
|
import org.bukkit.event.world.WorldListener;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,6 +92,9 @@ public class GroupManager extends JavaPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
setLoaded(false);
|
setLoaded(false);
|
||||||
|
|
||||||
|
// Un-register this service.
|
||||||
|
this.getServer().getServicesManager().unregister(this);
|
||||||
|
|
||||||
disableScheduler(); // Shutdown before we save, so it doesn't interfere.
|
disableScheduler(); // Shutdown before we save, so it doesn't interfere.
|
||||||
if (worldsHolder != null) {
|
if (worldsHolder != null) {
|
||||||
|
@ -153,6 +159,9 @@ public class GroupManager extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
||||||
|
|
||||||
|
// Register as a service
|
||||||
|
this.getServer().getServicesManager().register(AnjoPermissionsHandler.class, this.permissionHandler, this, ServicePriority.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLoaded() {
|
public static boolean isLoaded() {
|
||||||
|
@ -1828,6 +1837,15 @@ public class GroupManager extends JavaPlugin {
|
||||||
return match;
|
return match;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers all GroupManager events for other plugins to see.
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
public static void callEvent(GroupManagerEvent event) {
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the config
|
* @return the config
|
||||||
|
|
|
@ -6,6 +6,9 @@ package org.anjocaido.groupmanager.data;
|
||||||
|
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
||||||
|
import org.anjocaido.groupmanager.events.GMGroupEvent.Action;
|
||||||
|
import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,7 +16,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author gabrielcouto
|
* @author gabrielcouto/ElgarL
|
||||||
*/
|
*/
|
||||||
public class Group extends DataUnit implements Cloneable {
|
public class Group extends DataUnit implements Cloneable {
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
public Group(String name) {
|
public Group(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this group
|
* Clone this group
|
||||||
* @return a clone of this group
|
* @return a clone of this group
|
||||||
|
@ -114,14 +117,17 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
inherits.add(inherit.getName().toLowerCase());
|
inherits.add(inherit.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded()) {
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeInherits(String inherit) {
|
public boolean removeInherits(String inherit) {
|
||||||
if (this.inherits.contains(inherit.toLowerCase())) {
|
if (this.inherits.contains(inherit.toLowerCase())) {
|
||||||
this.inherits.remove(inherit.toLowerCase());
|
this.inherits.remove(inherit.toLowerCase());
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -145,7 +151,9 @@ public class Group extends DataUnit implements Cloneable {
|
||||||
variables.addVar(key, temp.getVarObject(key));
|
variables.addVar(key, temp.getVarObject(key));
|
||||||
}
|
}
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded()) {
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
||||||
|
import org.anjocaido.groupmanager.events.GMUserEvent.Action;
|
||||||
|
import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -16,7 +19,7 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author gabrielcouto
|
* @author gabrielcouto/ElgarL
|
||||||
*/
|
*/
|
||||||
public class User extends DataUnit implements Cloneable {
|
public class User extends DataUnit implements Cloneable {
|
||||||
|
|
||||||
|
@ -139,6 +142,8 @@ public class User extends DataUnit implements Cloneable {
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
|
GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
|
||||||
|
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.USER_GROUP_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,9 +158,11 @@ public class User extends DataUnit implements Cloneable {
|
||||||
removeSubGroup(subGroup);
|
removeSubGroup(subGroup);
|
||||||
subGroups.add(subGroup.getName());
|
subGroups.add(subGroup.getName());
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded()) {
|
||||||
if (GroupManager.BukkitPermissions.player_join = false)
|
if (GroupManager.BukkitPermissions.player_join = false)
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int subGroupsSize() {
|
public int subGroupsSize() {
|
||||||
|
@ -177,6 +184,7 @@ public class User extends DataUnit implements Cloneable {
|
||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded())
|
||||||
if (GroupManager.BukkitPermissions.player_join = false)
|
if (GroupManager.BukkitPermissions.player_join = false)
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.USER_SUBGROUP_CHANGED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -220,9 +228,11 @@ public class User extends DataUnit implements Cloneable {
|
||||||
variables.addVar(key, varList.get(key));
|
variables.addVar(key, varList.get(key));
|
||||||
}
|
}
|
||||||
flagAsChanged();
|
flagAsChanged();
|
||||||
if (GroupManager.isLoaded())
|
if (GroupManager.isLoaded()) {
|
||||||
if (GroupManager.BukkitPermissions.player_join = false)
|
if (GroupManager.BukkitPermissions.player_join = false)
|
||||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||||
|
GroupManagerEventHandler.callEvent(this, Action.USER_INFO_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public User updatePlayer(Player player) {
|
public User updatePlayer(Player player) {
|
||||||
|
@ -238,5 +248,4 @@ public class User extends DataUnit implements Cloneable {
|
||||||
}
|
}
|
||||||
return bukkitPlayer;
|
return bukkitPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ import java.util.logging.Logger;
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
import org.anjocaido.groupmanager.data.Group;
|
import org.anjocaido.groupmanager.data.Group;
|
||||||
import org.anjocaido.groupmanager.data.User;
|
import org.anjocaido.groupmanager.data.User;
|
||||||
|
import org.anjocaido.groupmanager.events.GMGroupEvent;
|
||||||
|
import org.anjocaido.groupmanager.events.GMSystemEvent;
|
||||||
|
import org.anjocaido.groupmanager.events.GMUserEvent;
|
||||||
|
import org.anjocaido.groupmanager.events.GMUserEvent.Action;
|
||||||
|
import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
|
||||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -144,6 +149,8 @@ public class WorldDataHolder {
|
||||||
removeUser(theUser.getName());
|
removeUser(theUser.getName());
|
||||||
users.put(theUser.getName().toLowerCase(), theUser);
|
users.put(theUser.getName().toLowerCase(), theUser);
|
||||||
haveUsersChanged = true;
|
haveUsersChanged = true;
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(theUser, Action.USER_ADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,6 +162,8 @@ public class WorldDataHolder {
|
||||||
if (users.containsKey(userName.toLowerCase())) {
|
if (users.containsKey(userName.toLowerCase())) {
|
||||||
users.remove(userName.toLowerCase());
|
users.remove(userName.toLowerCase());
|
||||||
haveUsersChanged = true;
|
haveUsersChanged = true;
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(userName, GMUserEvent.Action.USER_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -179,6 +188,8 @@ public class WorldDataHolder {
|
||||||
}
|
}
|
||||||
defaultGroup = this.getGroup(group.getName());
|
defaultGroup = this.getGroup(group.getName());
|
||||||
haveGroupsChanged = true;
|
haveGroupsChanged = true;
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.DEFAULT_GROUP_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,6 +232,7 @@ public class WorldDataHolder {
|
||||||
public void addGroup(Group groupToAdd) {
|
public void addGroup(Group groupToAdd) {
|
||||||
if (groupToAdd.getName().toLowerCase().startsWith("g:")) {
|
if (groupToAdd.getName().toLowerCase().startsWith("g:")) {
|
||||||
GroupManager.getGlobalGroups().addGroup(groupToAdd);
|
GroupManager.getGlobalGroups().addGroup(groupToAdd);
|
||||||
|
GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,10 +242,12 @@ public class WorldDataHolder {
|
||||||
removeGroup(groupToAdd.getName());
|
removeGroup(groupToAdd.getName());
|
||||||
groups.put(groupToAdd.getName().toLowerCase(), groupToAdd);
|
groups.put(groupToAdd.getName().toLowerCase(), groupToAdd);
|
||||||
haveGroupsChanged = true;
|
haveGroupsChanged = true;
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the group to the list
|
* Remove the group from the list
|
||||||
* @param groupName
|
* @param groupName
|
||||||
* @return true if had something to remove. false the group was default or non-existant
|
* @return true if had something to remove. false the group was default or non-existant
|
||||||
*/
|
*/
|
||||||
|
@ -248,6 +262,8 @@ public class WorldDataHolder {
|
||||||
if (groups.containsKey(groupName.toLowerCase())) {
|
if (groups.containsKey(groupName.toLowerCase())) {
|
||||||
groups.remove(groupName.toLowerCase());
|
groups.remove(groupName.toLowerCase());
|
||||||
haveGroupsChanged = true;
|
haveGroupsChanged = true;
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -345,6 +361,7 @@ public class WorldDataHolder {
|
||||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
||||||
}
|
}
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -375,6 +392,7 @@ public class WorldDataHolder {
|
||||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
||||||
}
|
}
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -936,6 +954,9 @@ public class WorldDataHolder {
|
||||||
ph.groupsFile = groupsFile;
|
ph.groupsFile = groupsFile;
|
||||||
ph.setTimeStampGroups(groupsFile.lastModified());
|
ph.setTimeStampGroups(groupsFile.lastModified());
|
||||||
ph.removeGroupsChangedFlag();
|
ph.removeGroupsChangedFlag();
|
||||||
|
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED);
|
||||||
|
|
||||||
/*FileWriter tx = null;
|
/*FileWriter tx = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1010,6 +1031,9 @@ public class WorldDataHolder {
|
||||||
ph.setTimeStampUsers(usersFile.lastModified());
|
ph.setTimeStampUsers(usersFile.lastModified());
|
||||||
ph.removeUsersChangedFlag();
|
ph.removeUsersChangedFlag();
|
||||||
|
|
||||||
|
if (GroupManager.isLoaded())
|
||||||
|
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.SAVED);
|
||||||
|
|
||||||
/*FileWriter tx = null;
|
/*FileWriter tx = null;
|
||||||
try {
|
try {
|
||||||
tx = new FileWriter(usersFile, false);
|
tx = new FileWriter(usersFile, false);
|
||||||
|
@ -1191,5 +1215,6 @@ public class WorldDataHolder {
|
||||||
setTimeStampGroups(groupsFile.lastModified());
|
setTimeStampGroups(groupsFile.lastModified());
|
||||||
if (usersFile != null)
|
if (usersFile != null)
|
||||||
setTimeStampUsers(usersFile.lastModified());
|
setTimeStampUsers(usersFile.lastModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
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;
|
||||||
|
this.groupName = group.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
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,59 @@
|
||||||
|
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;
|
||||||
|
this.userName = user.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
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 a new issue