1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-07 23:27:08 +02:00

Missing gm changes

This commit is contained in:
ementalo
2012-06-06 10:01:27 +01:00
parent 9f3b3d5873
commit 72b4ac257d
4 changed files with 781 additions and 573 deletions

View File

@@ -34,10 +34,10 @@ v 1.3:
(for all worlds named in config.yml)
- Attempt to stop GM wiping groups/users yml's on a bad shut down.
- Added event handling to manage new world creation at runtime.
- Added the ability to handle unknown worlds at server start.
(GM will create the data files for any worlds it finds which are not in the config.yml)
- Added the ability to handle unknown worlds at server start.
(GM will create the data files for any worlds it finds which are not in the config.yml)
- Fix for Bukkit passing a null To location on a player Portaling
- Fixed manudelsub not correctly selecting the group to remove.
- Fixed manudelsub not correctly selecting the group to remove.
- Added two new permission nodes - groupmanager.notify.self & groupmanager.notify.other
These allow players/admins to be notified when players are moved between groups.
v 1.4:
@@ -146,4 +146,41 @@ v 1.9:
- Removed BukkitPermsOverride as this is now the default with bukkit handling child nodes.
- Prevent adding inheritances and info nodes to globalgroups. These are permissions collections, not player groups.
- Prevent promoting players to, and demoting to GlobalGroups.
- Make 'manload' reload the config correctly.
- Make 'manload' reload the config correctly.
- Minor optimization when checking bukkit permissions.
- Better reporting when a users.yml is failing to load.
- Expanded '/manuadd'to accept an optional variable for the world (eg '/manuadd <player> <group> <world>').
- Removed some debug spam.
- Don't remove an attachment on a player leaving as Bukkit never forgets it. This fixes non mirrored permissions being messed up if a player relogs.
- Treat all world names as lower case for file handling (please check in your worlds folder. You should have no folders with upper case letters from now).
- Auto rename all case sensitive world folders to lower case (if possible).
- Update GlobalGroups.yml for new/changed Towny permission nodes.
- Stop attempting to push empty permissions when players edit the yml's incorrectly.
- Catch errors caused by bad indentation in yml's.
- Force remove player attachments on disconnect, and tidyup during player join in case of any errors. Fixes a bug of losing permissions.
- Added a new permission node 'groupmanager.op'. This will cause players with this node to be treated as op's when
using GroupManager commands (they will still require each commands permission node to use them).
- Prevent Null entries in group inheritance from throwing errors.
v 2.0:
- Fix GM reporting of permission inheritance to retain the correct order. Lower inheritance groups can no longer negate a higher groups permissions.
- Fix an error I caused trying to modify an unmodifiable list when parsing '*' permissions.
- Don't throw errors when attempting to remove permission attachments (bukkit will have already removed it).
- Remove all permission attachments when performing a manload or restart.
- Expand 'manwhois' to also list a users subgroups.
- Fix a concurrent modification error when removing all attachments.
- Better handling of errors in user and group yml's.
- Added missing confirmation message on '/manload'.
- Stop the error on shutdown if GM failed to load at startup.
- GroupManager will now generate it's own log (in the GM folder) to keep things tidy, but also to account of those players unable to find/access their server.log.
- Startup errors will now lock out ALL commands other than '/manload'
- Fix 'manuadd' to use the default or selected world (via 'manselect'), if the world is not specified in the command.
- Expand GlobalGroups.yml and groups.yml to cover the VanishNoPacket plugin. Demonstrating how to negate and add nodes when using the '*' permission with inheritance.
- Fix silly nested throw/catch statements. Errors are now correctly generated when reading yml's.
- Unregister the worldsHolder as a service on a reload/shutdown instead of the whole plugin.
- Update all code formatting to use tabs for indentation.
- Stop using our own deprecated methods as we tell others to do.
- Finally remove all deprecated methods.
- Re-initialize the WorldsHolder on a reload, as un-registering and re-registering a new holder means all plugins have to check for the new service on every quiery.
- Prevent null perms getting past the GlobalGroups loader.
- Fix forgetting sub groups on a manload.
- Allow 'manucheckp' to notify when superperms reports false but it is really negated.

View File

@@ -13,81 +13,89 @@ import org.anjocaido.groupmanager.utils.Tasks;
import org.bukkit.configuration.file.YamlConfiguration;
/**
*
*
* @author gabrielcouto
*/
public class GMConfiguration {
private GroupManager plugin;
private File configFile;
private YamlConfiguration GMconfig;
public GMConfiguration(GroupManager plugin) {
this.plugin = plugin;
load();
}
private GroupManager plugin;
private File configFile;
private YamlConfiguration GMconfig;
public void load() {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
configFile = new File(plugin.getDataFolder(), "config.yml");
public GMConfiguration(GroupManager plugin) {
if (!configFile.exists()) {
try {
Tasks.copy(plugin.getResourceAsStream("config.yml"), configFile);
} catch (IOException ex) {
GroupManager.logger.log(Level.SEVERE, null, ex);
}
}
this.plugin = plugin;
load();
}
GMconfig = new YamlConfiguration();
try {
GMconfig.load(configFile);
} catch (Exception ex) {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex);
}
// Setup defaults
adjustLoggerLevel();
plugin.setValidateOnlinePlayer(isToggleValidate());
}
public boolean isOpOverride() {
return GMconfig.getBoolean("settings.config.opOverrides", true);
}
public boolean isToggleValidate() {
return GMconfig.getBoolean("settings.config.validate_toggle", true);
}
public void load() {
public Map<String, Object> getMirrorsMap() {
// Try to fetch the old mirror path first
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
configFile = new File(plugin.getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
Tasks.copy(plugin.getResourceAsStream("config.yml"), configFile);
} catch (IOException ex) {
GroupManager.logger.log(Level.SEVERE, null, ex);
}
}
GMconfig = new YamlConfiguration();
try {
GMconfig.load(configFile);
} catch (Exception ex) {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex);
}
// Setup defaults
adjustLoggerLevel();
plugin.setValidateOnlinePlayer(isToggleValidate());
}
public boolean isOpOverride() {
return GMconfig.getBoolean("settings.config.opOverrides", true);
}
public boolean isToggleValidate() {
return GMconfig.getBoolean("settings.config.validate_toggle", true);
}
public Map<String, Object> getMirrorsMap() {
// Try to fetch the old mirror path first
if (GMconfig.isConfigurationSection("settings.permission.world.mirror")) {
return (Map<String, Object>) GMconfig.getConfigurationSection("settings.permission.world.mirror").getValues(false);
} else if (GMconfig.isConfigurationSection("settings.mirrors")){
} else if (GMconfig.isConfigurationSection("settings.mirrors")) {
return (Map<String, Object>) GMconfig.getConfigurationSection("settings.mirrors").getValues(false);
}
return null;
}
public Integer getSaveInterval() {
return GMconfig.getInt("settings.data.save.minutes", 10);
}
public Integer getBackupDuration() {
return GMconfig.getInt("settings.data.save.hours", 24);
}
}
public void adjustLoggerLevel() {
try {
GroupManager.logger.setLevel(Level.parse(GMconfig.getString("settings.logging.level", "INFO")));
return;
} catch (Exception e) {
}
GroupManager.logger.setLevel(Level.INFO);
}
public Integer getSaveInterval() {
return GMconfig.getInt("settings.data.save.minutes", 10);
}
public Integer getBackupDuration() {
return GMconfig.getInt("settings.data.save.hours", 24);
}
public void adjustLoggerLevel() {
try {
GroupManager.logger.setLevel(Level.parse(GMconfig.getString("settings.logging.level", "INFO")));
return;
} catch (Exception e) {
}
GroupManager.logger.setLevel(Level.INFO);
}
}

View File

@@ -15,160 +15,173 @@ import java.util.List;
import java.util.Map;
/**
*
*
* @author gabrielcouto/ElgarL
*/
public class Group extends DataUnit implements Cloneable {
/**
* The group it inherits DIRECTLY!
*/
private ArrayList<String> inherits = new ArrayList<String>();
/**
*This one holds the fields in INFO node.
* like prefix = 'c'
* or build = false
*/
private GroupVariables variables = new GroupVariables(this);
/**
* The group it inherits DIRECTLY!
*/
private ArrayList<String> inherits = new ArrayList<String>();
/**
* This one holds the fields in INFO node.
* like prefix = 'c'
* or build = false
*/
private GroupVariables variables = new GroupVariables(this);
/**
* Constructor for individual World Groups.
*
* @param name
*/
public Group(WorldDataHolder source, String name) {
super(source, name);
}
/**
* Constructor for Global Groups.
*
* @param name
*/
public Group(String name) {
super(name);
}
/**
* Is this a GlobalGroup
*
* @return
*/
public boolean isGlobal() {
return (getDataSource() == null);
}
/**
* Clone this group
* @return a clone of this group
*/
@Override
public Group clone() {
Group clone;
if (isGlobal()) {
clone = new Group(this.getName());
} else {
clone = new Group(getDataSource(), this.getName());
clone.inherits = new ArrayList<String>(this.getInherits());
}
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
clone.variables = ((GroupVariables) variables).clone(clone);
//clone.flagAsChanged();
return clone;
}
/**
* Constructor for individual World Groups.
*
* @param name
*/
public Group(WorldDataHolder source, String name) {
/**
* Use this to deliver a group from a different dataSource to another
* @param dataSource
* @return Null or Clone
*/
public Group clone(WorldDataHolder dataSource) {
if (dataSource.groupExists(this.getName())) {
return null;
}
Group clone = dataSource.createGroup(this.getName());
// Don't add inheritance for GlobalGroups
if (!isGlobal()) {
clone.inherits = new ArrayList<String>(this.getInherits());
}
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
clone.variables = variables.clone(clone);
clone.flagAsChanged(); //use this to make the new dataSource save the new group
return clone;
}
super(source, name);
}
/**
* an unmodifiable list of inherits list
* You can't manage the list by here
* Lol... version 0.6 had a problem because this.
* @return the inherits
*/
public List<String> getInherits() {
return Collections.unmodifiableList(inherits);
}
/**
* Constructor for Global Groups.
*
* @param name
*/
public Group(String name) {
/**
* @param inherit the inherits to set
*/
public void addInherits(Group inherit) {
if (!isGlobal()) {
if (!this.getDataSource().groupExists(inherit.getName())) {
getDataSource().addGroup(inherit);
}
if (!inherits.contains(inherit.getName().toLowerCase())) {
inherits.add(inherit.getName().toLowerCase());
}
flagAsChanged();
if (GroupManager.isLoaded()) {
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
}
}
}
super(name);
}
public boolean removeInherits(String inherit) {
if (!isGlobal()) {
if (this.inherits.contains(inherit.toLowerCase())) {
this.inherits.remove(inherit.toLowerCase());
flagAsChanged();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
return true;
}
}
return false;
}
/**
* Is this a GlobalGroup
*
* @return true if this is a global group
*/
public boolean isGlobal() {
/**
* @return the variables
*/
public GroupVariables getVariables() {
return variables;
}
return (getDataSource() == null);
}
/**
*
* @param varList
*/
public void setVariables(Map<String, Object> varList) {
if (!isGlobal()) {
GroupVariables temp = new GroupVariables(this, varList);
variables.clearVars();
for (String key : temp.getVarKeyList()) {
variables.addVar(key, temp.getVarObject(key));
}
flagAsChanged();
if (GroupManager.isLoaded()) {
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
}
}
}
/**
* Clone this group
*
* @return a clone of this group
*/
@Override
public Group clone() {
Group clone;
if (isGlobal()) {
clone = new Group(this.getName());
} else {
clone = new Group(getDataSource(), this.getName());
clone.inherits = new ArrayList<String>(this.getInherits());
}
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
clone.variables = ((GroupVariables) variables).clone(clone);
//clone.flagAsChanged();
return clone;
}
/**
* Use this to deliver a group from a different dataSource to another
*
* @param dataSource
* @return Null or Clone
*/
public Group clone(WorldDataHolder dataSource) {
if (dataSource.groupExists(this.getName())) {
return null;
}
Group clone = dataSource.createGroup(this.getName());
// Don't add inheritance for GlobalGroups
if (!isGlobal()) {
clone.inherits = new ArrayList<String>(this.getInherits());
}
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
}
clone.variables = variables.clone(clone);
clone.flagAsChanged(); //use this to make the new dataSource save the new group
return clone;
}
/**
* an unmodifiable list of inherits list
* You can't manage the list by here
* Lol... version 0.6 had a problem because this.
*
* @return the inherits
*/
public List<String> getInherits() {
return Collections.unmodifiableList(inherits);
}
/**
* @param inherit the inherits to set
*/
public void addInherits(Group inherit) {
if (!isGlobal()) {
if (!this.getDataSource().groupExists(inherit.getName())) {
getDataSource().addGroup(inherit);
}
if (!inherits.contains(inherit.getName().toLowerCase())) {
inherits.add(inherit.getName().toLowerCase());
}
flagAsChanged();
if (GroupManager.isLoaded()) {
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
}
}
}
public boolean removeInherits(String inherit) {
if (!isGlobal()) {
if (this.inherits.contains(inherit.toLowerCase())) {
this.inherits.remove(inherit.toLowerCase());
flagAsChanged();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INHERITANCE_CHANGED);
return true;
}
}
return false;
}
/**
* @return the variables
*/
public GroupVariables getVariables() {
return variables;
}
/**
*
* @param varList
*/
public void setVariables(Map<String, Object> varList) {
if (!isGlobal()) {
GroupVariables temp = new GroupVariables(this, varList);
variables.clearVars();
for (String key : temp.getVarKeyList()) {
variables.addVar(key, temp.getVarObject(key));
}
flagAsChanged();
if (GroupManager.isLoaded()) {
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManagerEventHandler.callEvent(this, Action.GROUP_INFO_CHANGED);
}
}
}
}