1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-19 13:01:20 +02:00

Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9

This commit is contained in:
KHobbits
2013-03-14 18:01:50 +00:00
9 changed files with 394 additions and 224 deletions

View File

@@ -213,3 +213,10 @@ v 2.0:
- Prevent '*' permissions granting the 'groupmanager.noofflineperms' permission. - Prevent '*' permissions granting the 'groupmanager.noofflineperms' permission.
- Added '/mancheckw <world>' to inspect which permission files a world is referencing. - Added '/mancheckw <world>' to inspect which permission files a world is referencing.
- Add config potion to set if GM commands should be allowed on CommnandBlocks. - Add config potion to set if GM commands should be allowed on CommnandBlocks.
- Catch the error when using an out of date config for 'allow_commandblocks' So it doesn't kill the whole config.
- '/manselect' will no longer list duplicate worlds.
- Added a new mirroring option in the config of 'all_unnamed_worlds'. This will cause all new or unnamed worlds to use this mirroring.
- Don't allow adding a node with '/manuaddp' and '/mangaddp' which is already negated.
- Warn when adding a node where an exception already exist.
- Only prevent adding nodes with '/manuaddp' and '/mangaddp' if they are exact matches (not wildcards).
- Store worldSelection indexed on the senders name rather than the object (fixes commandblocks using manselect).

View File

@@ -4,7 +4,7 @@ settings:
# The user will be able to promote players to the same group or even above. # The user will be able to promote players to the same group or even above.
opOverrides: true opOverrides: true
# Default setting for 'mantoglevalidate' # Default setting for 'mantogglevalidate'
# true will cause GroupManager to attempt name matching by default. # true will cause GroupManager to attempt name matching by default.
validate_toggle: true validate_toggle: true
# ********************************************************************************************************************************** # **********************************************************************************************************************************
@@ -26,10 +26,11 @@ settings:
mirrors: mirrors:
# Worlds listed here have their settings mirrored in their children. # Worlds listed here have their settings mirrored in their children.
# The first element 'world' is the main worlds name # The first element 'world' is the main worlds name, and is the parent world.
# subsequent elements 'world_nether' and 'world_the_end' are worlds which will use # subsequent elements 'world_nether' and 'world_the_end' are worlds which will use
# the same user/groups files as the parent. # the same user/groups files as the parent.
# Each child world can be configured to mirror the 'groups', 'users' or both files from it's parent. # the element 'all_unnamed_worlds' specifies all worlds that aren't listed, and automatically mirrors them to it's parent.
# Each child world can be configured to mirror the 'groups', 'users' or both files from its parent.
world: world:
world_nether: world_nether:
- users - users
@@ -37,6 +38,9 @@ settings:
world_the_end: world_the_end:
- users - users
- groups - groups
all_unnamed_worlds:
- users
- groups
# world2: (World2 would have it's own set of user and groups files) # world2: (World2 would have it's own set of user and groups files)
# world3: # world3:
# - users (World3 would use the users.yml from world2, but it's own groups.yml) # - users (World3 would use the users.yml from world2, but it's own groups.yml)

View File

@@ -195,7 +195,7 @@ groups:
- essentials.fly.safelogin - essentials.fly.safelogin
- essentials.getpos - essentials.getpos
- essentials.getpos.others - essentials.getpos.others
- essentials.helpop.recieve - essentials.helpop.receive
- essentials.home.others - essentials.home.others
- essentials.invsee - essentials.invsee
- essentials.jails - essentials.jails

View File

@@ -85,9 +85,23 @@ public class GMConfiguration {
try { try {
Map<String, Object> config = getElement("config", getElement("settings", GMconfig)); Map<String, Object> config = getElement("config", getElement("settings", GMconfig));
allowCommandBlocks = (Boolean) config.get("allow_commandblocks"); try {
opOverride = (Boolean) config.get("opOverrides"); allowCommandBlocks = (Boolean) config.get("allow_commandblocks");
toggleValidate = (Boolean) config.get("validate_toggle"); } catch (Exception ex) {
GroupManager.logger.log(Level.SEVERE, "Missing or corrupt 'allow_commandblocks' node. Using default settings", ex);
}
try {
opOverride = (Boolean) config.get("opOverrides");
} catch (Exception ex) {
GroupManager.logger.log(Level.SEVERE, "Missing or corrupt 'opOverrides' node. Using default settings", ex);
}
try {
toggleValidate = (Boolean) config.get("validate_toggle");
} catch (Exception ex) {
GroupManager.logger.log(Level.SEVERE, "Missing or corrupt 'validate_toggle' node. Using default settings", ex);
}
/* /*
* data node for save/backup timers. * data node for save/backup timers.

View File

@@ -144,7 +144,7 @@ public class User extends DataUnit implements Cloneable {
boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName))); boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName)));
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 in %s.", group.getName(), this.getDataSource().getName()));
GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED); GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED);
} }

View File

@@ -59,6 +59,28 @@ public class WorldsHolder {
resetWorldsHolder(); resetWorldsHolder();
} }
/**
* @return the mirrorsGroup
*/
public Map<String, String> getMirrorsGroup() {
return mirrorsGroup;
}
/**
* @return the mirrorsUser
*/
public Map<String, String> getMirrorsUser() {
return mirrorsUser;
}
public boolean isWorldKnown(String name) {
return worldsData.containsKey(name.toLowerCase());
}
public void resetWorldsHolder() { public void resetWorldsHolder() {
worldsData = new HashMap<String, OverloadedWorldHolder>(); worldsData = new HashMap<String, OverloadedWorldHolder>();
@@ -92,33 +114,46 @@ public class WorldsHolder {
private void loadAllSearchedWorlds() { private void loadAllSearchedWorlds() {
/* /*
* Read all known worlds from Bukkit * Read all known worlds from Bukkit Create the data files if they don't
* Create the data files if they don't already exist, * already exist, and they are not mirrored.
* and they are not mirrored.
*/ */
for (World world : plugin.getServer().getWorlds()){ for (World world : plugin.getServer().getWorlds()) {
GroupManager.logger.log(Level.FINE, "Checking data for " + world.getName() + "."); GroupManager.logger.log(Level.FINE, "Checking data for " + world.getName() + ".");
if ((!worldsData.containsKey(world.getName().toLowerCase())) && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase())))) { if ((!worldsData.containsKey(world.getName().toLowerCase())) && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase())))) {
if (worldsData.containsKey("all_unnamed_worlds")) {
String usersMirror = mirrorsUser.get("all_unnamed_worlds");
String groupsMirror = mirrorsGroup.get("all_unnamed_worlds");
if (usersMirror != null)
mirrorsUser.put(world.getName().toLowerCase(), usersMirror);
if (groupsMirror != null)
mirrorsGroup.put(world.getName().toLowerCase(), groupsMirror);
}
GroupManager.logger.log(Level.FINE, "Creating folders for " + world.getName() + "."); GroupManager.logger.log(Level.FINE, "Creating folders for " + world.getName() + ".");
setupWorldFolder(world.getName()); setupWorldFolder(world.getName());
} }
} }
/* /*
* Loop over all folders within the worlds folder * Loop over all folders within the worlds folder and attempt to load
* and attempt to load the world data * the world data
*/ */
for (File folder : worldsFolder.listFiles()) { for (File folder : worldsFolder.listFiles()) {
if (folder.isDirectory() && !folder.getName().startsWith(".")) { if (folder.isDirectory() && !folder.getName().startsWith(".")) {
GroupManager.logger.info("World Found: " + folder.getName()); GroupManager.logger.info("World Found: " + folder.getName());
/* /*
* don't load any worlds which are already loaded * don't load any worlds which are already loaded or fully
* or fully mirrored worlds that don't need data. * mirrored worlds that don't need data.
*/ */
if (!worldsData.containsKey(folder.getName().toLowerCase()) && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase())) || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) { if (!worldsData.containsKey(folder.getName().toLowerCase()) && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase())) || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
/* /*
* Call setupWorldFolder to check case sensitivity * Call setupWorldFolder to check case sensitivity and
* and convert to lower case, before we attempt to load this * convert to lower case, before we attempt to load this
* world. * world.
*/ */
setupWorldFolder(folder.getName()); setupWorldFolder(folder.getName());
@@ -383,8 +418,14 @@ public class WorldsHolder {
// Find this worlds data // Find this worlds data
if (worldsData.containsKey(worldNameLowered)) if (worldsData.containsKey(worldNameLowered))
return getUpdatedWorldData(worldNameLowered); return getUpdatedWorldData(worldNameLowered);
// Oddly no data source was found for this world so return the default. // Oddly no data source was found for this world so attempt to return the global mirror.
if (worldsData.containsKey("all_unnamed_worlds")) {
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning all_unnamed_worlds world...");
return getUpdatedWorldData("all_unnamed_worlds");
}
// Oddly no data source or global mirror was found for this world so return the default.
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world..."); GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
return getDefaultWorld(); return getDefaultWorld();
} }
@@ -699,41 +740,53 @@ public class WorldsHolder {
} }
/** /**
* Returns all physically loaded worlds which have at least * Returns all physically loaded worlds which have at least one of their own
* one of their own data sets for users or groups which isn't an identical mirror. * data sets for users or groups which isn't an identical mirror.
* *
* @return ArrayList<OverloadedWorldHolder> of all loaded worlds * @return ArrayList<OverloadedWorldHolder> of all loaded worlds
*/ */
public ArrayList<OverloadedWorldHolder> allWorldsDataList() { public ArrayList<OverloadedWorldHolder> allWorldsDataList() {
ArrayList<OverloadedWorldHolder> list = new ArrayList<OverloadedWorldHolder>(); ArrayList<OverloadedWorldHolder> list = new ArrayList<OverloadedWorldHolder>();
for (OverloadedWorldHolder data : worldsData.values()) {
if ((!list.contains(data))) { // && (!mirrorsGroup.containsKey(data.getName().toLowerCase()) || !mirrorsUser.containsKey(data.getName().toLowerCase()))) {
String worldNameLowered = data.getName().toLowerCase(); for (String world : worldsData.keySet()) {
String usersMirror = mirrorsUser.get(worldNameLowered);
String groupsMirror = mirrorsGroup.get(worldNameLowered);
// is users mirrored? if (!world.equalsIgnoreCase("all_unnamed_worlds")) {
if (usersMirror != null) {
// Fetch the relevant world object
OverloadedWorldHolder data = getWorldData(world);
// If both are mirrored if (!list.contains(data)) {
if (groupsMirror != null) {
// if the data sources are the same, return the parent String worldNameLowered = data.getName().toLowerCase();
if (usersMirror == groupsMirror) { String usersMirror = mirrorsUser.get(worldNameLowered);
if (!list.contains(usersMirror.toLowerCase())) String groupsMirror = mirrorsGroup.get(worldNameLowered);
list.add(worldsData.get(usersMirror.toLowerCase()));
continue; // is users mirrored?
if (usersMirror != null) {
// If both are mirrored
if (groupsMirror != null) {
// if the data sources are the same, return the parent
if (usersMirror == groupsMirror) {
data = getWorldData(usersMirror.toLowerCase());
// Only add the parent if it's not already listed.
if (!list.contains(data))
list.add(data);
continue;
}
// Both data sources are mirrors, but they are from different parents
// so fall through to add the actual data object.
} }
// Both data sources are mirrors, but they are from different parents // Groups isn't a mirror so fall through to add this this worlds data source
// so fall through to add the actual data object.
} }
// Groups isn't a mirror so fall through to add this this worlds data source
}
// users isn't mirrored so we need to add this worlds data source // users isn't mirrored so we need to add this worlds data source
list.add(data); list.add(data);
}
} }
} }
return list; return list;

View File

@@ -35,8 +35,24 @@ public class GMWorldListener implements Listener {
if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) { if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
GroupManager.logger.info("New world detected..."); GroupManager.logger.info("New world detected...");
GroupManager.logger.info("Creating data for: " + worldName); GroupManager.logger.info("Creating data for: " + worldName);
if (plugin.getWorldsHolder().isWorldKnown("all_unnamed_worlds")) {
String usersMirror = plugin.getWorldsHolder().getMirrorsUser().get("all_unnamed_worlds");
String groupsMirror = plugin.getWorldsHolder().getMirrorsGroup().get("all_unnamed_worlds");
if (usersMirror != null)
plugin.getWorldsHolder().getMirrorsUser().put(worldName.toLowerCase(), usersMirror);
if (groupsMirror != null)
plugin.getWorldsHolder().getMirrorsGroup().put(worldName.toLowerCase(), groupsMirror);
}
plugin.getWorldsHolder().setupWorldFolder(worldName); plugin.getWorldsHolder().setupWorldFolder(worldName);
plugin.getWorldsHolder().loadWorld(worldName); plugin.getWorldsHolder().loadWorld(worldName);
if (plugin.getWorldsHolder().isInList(worldName)) { if (plugin.getWorldsHolder().isInList(worldName)) {
GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml."); GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml.");
} else } else

View File

@@ -708,6 +708,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
for (String access : user.getPermissionList()) { for (String access : user.getPermissionList()) {
result.resultType = comparePermissionString(access, permission); result.resultType = comparePermissionString(access, permission);
if (result.resultType != PermissionCheckResult.Type.NOTFOUND) { if (result.resultType != PermissionCheckResult.Type.NOTFOUND) {
result.accessLevel = access;
return result; return result;
} }
} }
@@ -732,6 +733,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
for (String access : group.getPermissionList()) { for (String access : group.getPermissionList()) {
result.resultType = comparePermissionString(access, permission); result.resultType = comparePermissionString(access, permission);
if (result.resultType != PermissionCheckResult.Type.NOTFOUND) { if (result.resultType != PermissionCheckResult.Type.NOTFOUND) {
result.accessLevel = access;
return result; return result;
} }
} }