mirror of
https://github.com/essentials/Essentials.git
synced 2025-02-24 08:22:56 +01:00
Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9
This commit is contained in:
commit
8b687d18ee
@ -213,3 +213,10 @@ v 2.0:
|
||||
- Prevent '*' permissions granting the 'groupmanager.noofflineperms' permission.
|
||||
- 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.
|
||||
- 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).
|
@ -4,7 +4,7 @@ settings:
|
||||
# The user will be able to promote players to the same group or even above.
|
||||
opOverrides: true
|
||||
|
||||
# Default setting for 'mantoglevalidate'
|
||||
# Default setting for 'mantogglevalidate'
|
||||
# true will cause GroupManager to attempt name matching by default.
|
||||
validate_toggle: true
|
||||
# **********************************************************************************************************************************
|
||||
@ -26,10 +26,11 @@ settings:
|
||||
|
||||
mirrors:
|
||||
# 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
|
||||
# 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_nether:
|
||||
- users
|
||||
@ -37,6 +38,9 @@ settings:
|
||||
world_the_end:
|
||||
- users
|
||||
- groups
|
||||
all_unnamed_worlds:
|
||||
- users
|
||||
- groups
|
||||
# world2: (World2 would have it's own set of user and groups files)
|
||||
# world3:
|
||||
# - users (World3 would use the users.yml from world2, but it's own groups.yml)
|
||||
|
@ -195,7 +195,7 @@ groups:
|
||||
- essentials.fly.safelogin
|
||||
- essentials.getpos
|
||||
- essentials.getpos.others
|
||||
- essentials.helpop.recieve
|
||||
- essentials.helpop.receive
|
||||
- essentials.home.others
|
||||
- essentials.invsee
|
||||
- essentials.jails
|
||||
|
@ -85,9 +85,23 @@ public class GMConfiguration {
|
||||
try {
|
||||
Map<String, Object> config = getElement("config", getElement("settings", GMconfig));
|
||||
|
||||
allowCommandBlocks = (Boolean) config.get("allow_commandblocks");
|
||||
opOverride = (Boolean) config.get("opOverrides");
|
||||
toggleValidate = (Boolean) config.get("validate_toggle");
|
||||
try {
|
||||
allowCommandBlocks = (Boolean) config.get("allow_commandblocks");
|
||||
} 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.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -144,7 +144,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName)));
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -59,6 +59,28 @@ public class WorldsHolder {
|
||||
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() {
|
||||
|
||||
worldsData = new HashMap<String, OverloadedWorldHolder>();
|
||||
@ -92,33 +114,46 @@ public class WorldsHolder {
|
||||
private void loadAllSearchedWorlds() {
|
||||
|
||||
/*
|
||||
* Read all known worlds from Bukkit
|
||||
* Create the data files if they don't already exist,
|
||||
* and they are not mirrored.
|
||||
* Read all known worlds from Bukkit Create the data files if they don't
|
||||
* already exist, 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() + ".");
|
||||
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() + ".");
|
||||
setupWorldFolder(world.getName());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Loop over all folders within the worlds folder
|
||||
* and attempt to load the world data
|
||||
* Loop over all folders within the worlds folder and attempt to load
|
||||
* the world data
|
||||
*/
|
||||
for (File folder : worldsFolder.listFiles()) {
|
||||
if (folder.isDirectory() && !folder.getName().startsWith(".")) {
|
||||
GroupManager.logger.info("World Found: " + folder.getName());
|
||||
|
||||
/*
|
||||
* don't load any worlds which are already loaded
|
||||
* or fully mirrored worlds that don't need data.
|
||||
* don't load any worlds which are already loaded or fully
|
||||
* mirrored worlds that don't need data.
|
||||
*/
|
||||
if (!worldsData.containsKey(folder.getName().toLowerCase()) && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase())) || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
|
||||
/*
|
||||
* Call setupWorldFolder to check case sensitivity
|
||||
* and convert to lower case, before we attempt to load this
|
||||
* Call setupWorldFolder to check case sensitivity and
|
||||
* convert to lower case, before we attempt to load this
|
||||
* world.
|
||||
*/
|
||||
setupWorldFolder(folder.getName());
|
||||
@ -384,7 +419,13 @@ public class WorldsHolder {
|
||||
if (worldsData.containsKey(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...");
|
||||
return getDefaultWorld();
|
||||
}
|
||||
@ -699,41 +740,53 @@ public class WorldsHolder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all physically loaded worlds which have at least
|
||||
* one of their own data sets for users or groups which isn't an identical mirror.
|
||||
* Returns all physically loaded worlds which have at least one of their own
|
||||
* data sets for users or groups which isn't an identical mirror.
|
||||
*
|
||||
* @return ArrayList<OverloadedWorldHolder> of all loaded worlds
|
||||
*/
|
||||
public ArrayList<OverloadedWorldHolder> allWorldsDataList() {
|
||||
|
||||
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();
|
||||
String usersMirror = mirrorsUser.get(worldNameLowered);
|
||||
String groupsMirror = mirrorsGroup.get(worldNameLowered);
|
||||
for (String world : worldsData.keySet()) {
|
||||
|
||||
// is users mirrored?
|
||||
if (usersMirror != null) {
|
||||
if (!world.equalsIgnoreCase("all_unnamed_worlds")) {
|
||||
|
||||
// If both are mirrored
|
||||
if (groupsMirror != null) {
|
||||
// Fetch the relevant world object
|
||||
OverloadedWorldHolder data = getWorldData(world);
|
||||
|
||||
// if the data sources are the same, return the parent
|
||||
if (usersMirror == groupsMirror) {
|
||||
if (!list.contains(usersMirror.toLowerCase()))
|
||||
list.add(worldsData.get(usersMirror.toLowerCase()));
|
||||
continue;
|
||||
if (!list.contains(data)) {
|
||||
|
||||
String worldNameLowered = data.getName().toLowerCase();
|
||||
String usersMirror = mirrorsUser.get(worldNameLowered);
|
||||
String groupsMirror = mirrorsGroup.get(worldNameLowered);
|
||||
|
||||
// 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
|
||||
// so fall through to add the actual data object.
|
||||
// Groups isn't a mirror so fall through to add this this worlds data source
|
||||
}
|
||||
// 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
|
||||
list.add(data);
|
||||
// users isn't mirrored so we need to add this worlds data source
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
@ -35,8 +35,24 @@ public class GMWorldListener implements Listener {
|
||||
if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
|
||||
GroupManager.logger.info("New world detected...");
|
||||
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().loadWorld(worldName);
|
||||
|
||||
|
||||
if (plugin.getWorldsHolder().isInList(worldName)) {
|
||||
GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml.");
|
||||
} else
|
||||
|
@ -708,6 +708,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
for (String access : user.getPermissionList()) {
|
||||
result.resultType = comparePermissionString(access, permission);
|
||||
if (result.resultType != PermissionCheckResult.Type.NOTFOUND) {
|
||||
result.accessLevel = access;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -732,6 +733,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||
for (String access : group.getPermissionList()) {
|
||||
result.resultType = comparePermissionString(access, permission);
|
||||
if (result.resultType != PermissionCheckResult.Type.NOTFOUND) {
|
||||
result.accessLevel = access;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user