mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-21 10:52:01 +00:00
Merge branch 'refs/heads/groupmanager'
Conflicts: EssentialsGroupManager/src/globalgroups.yml
This commit is contained in:
commit
3f9e19d279
|
@ -164,3 +164,14 @@ v 1.9:
|
|||
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.
|
|
@ -1,5 +1,101 @@
|
|||
# These groups only contain permission nodes.
|
||||
#
|
||||
# **** You can NOT add anything other than permission nodes ****
|
||||
#
|
||||
# These collections are to be inherited in your different worlds groups.yml's
|
||||
# They can also be added as one of a users subgroups, but NOT as a primary group.
|
||||
# These collections are available to ALL group and user yml's.
|
||||
#
|
||||
# Add to and customize these groups to fit yoru needs.
|
||||
|
||||
groups:
|
||||
|
||||
# Permission nodes for GroupManager
|
||||
# by ElgarL, snowleo, continued from gabrielcouto's original
|
||||
# http://dev.bukkit.org/server-mods/essentials/
|
||||
|
||||
g:groupmanager_default:
|
||||
permissions:
|
||||
- groupmanager.notify.self
|
||||
|
||||
g:groupmanager_moderator:
|
||||
permissions:
|
||||
- groupmanager.listgroups
|
||||
- groupmanager.mandemote
|
||||
- groupmanager.manpromote
|
||||
- groupmanager.manselect
|
||||
- groupmanager.manuadd
|
||||
- groupmanager.manudel
|
||||
- groupmanager.manwhois
|
||||
- groupmanager.notify.other
|
||||
|
||||
g:groupmanager_admin:
|
||||
permissions:
|
||||
- groupmanager.mantogglevalidate
|
||||
- groupmanager.mansave
|
||||
- groupmanager.mangcheckp
|
||||
- groupmanager.manglistp
|
||||
- groupmanager.manucheckp
|
||||
- groupmanager.manulistp
|
||||
|
||||
# Permission nodes for CraftBukkit
|
||||
# by many devs and contributors
|
||||
# http://dl.bukkit.org/
|
||||
|
||||
g:bukkit_default:
|
||||
permissions:
|
||||
- bukkit.broadcast.user
|
||||
- -bukkit.command.plugins
|
||||
|
||||
g:bukkit_moderator:
|
||||
permissions:
|
||||
- bukkit.command.ban
|
||||
- bukkit.command.ban.ip
|
||||
- bukkit.command.ban.player
|
||||
- bukkit.command.gamemode
|
||||
- bukkit.command.kick
|
||||
- bukkit.command.unban
|
||||
- bukkit.command.unban.ip
|
||||
- bukkit.command.unban.player
|
||||
|
||||
g:bukkit_admin:
|
||||
permissions:
|
||||
- bukkit.broadcast
|
||||
- bukkit.broadcast.admin
|
||||
- bukkit.command.give
|
||||
- bukkit.command.help
|
||||
- bukkit.command.kill
|
||||
- bukkit.command.list
|
||||
- bukkit.command.me
|
||||
- -bukkit.command.op
|
||||
- -bukkit.command.op.give
|
||||
- -bukkit.command.op.take
|
||||
- bukkit.command.plugins
|
||||
- bukkit.command.reload
|
||||
- bukkit.command.save
|
||||
- bukkit.command.save.disable
|
||||
- bukkit.command.save.enable
|
||||
- bukkit.command.save.perform
|
||||
- bukkit.command.say
|
||||
- bukkit.command.stop
|
||||
- bukkit.command.teleport
|
||||
- bukkit.command.tell
|
||||
- bukkit.command.time
|
||||
- bukkit.command.time.add
|
||||
- bukkit.command.time.set
|
||||
- bukkit.command.version
|
||||
- bukkit.command.whitelist
|
||||
- bukkit.command.whitelist.add
|
||||
- bukkit.command.whitelist.disable
|
||||
- bukkit.command.whitelist.enable
|
||||
- bukkit.command.whitelist.list
|
||||
- bukkit.command.whitelist.reload
|
||||
- bukkit.command.whitelist.remove
|
||||
|
||||
# Permission nodes for Essentials
|
||||
# by ementalo, snowleo, and KHobbits
|
||||
# http://dev.bukkit.org/server-mods/essentials/
|
||||
|
||||
g:essentials_default:
|
||||
permissions:
|
||||
- essentials.help
|
||||
|
@ -8,7 +104,6 @@ groups:
|
|||
- essentials.motd
|
||||
- essentials.rules
|
||||
- essentials.spawn
|
||||
- groupmanager.notify.self
|
||||
|
||||
g:essentials_builder:
|
||||
permissions:
|
||||
|
@ -121,14 +216,6 @@ groups:
|
|||
- essentials.whois
|
||||
- essentials.world
|
||||
- essentials.world.*
|
||||
- groupmanager.listgroups
|
||||
- groupmanager.mandemote
|
||||
- groupmanager.manpromote
|
||||
- groupmanager.manselect
|
||||
- groupmanager.manuadd
|
||||
- groupmanager.manudel
|
||||
- groupmanager.manwhois
|
||||
- groupmanager.notify.other
|
||||
|
||||
g:essentials_admin:
|
||||
permissions:
|
||||
|
@ -138,62 +225,13 @@ groups:
|
|||
- -essentials.reloadall
|
||||
- -essentials.plugin
|
||||
- essentials.*
|
||||
- groupmanager.mantogglevalidate
|
||||
- groupmanager.mansave
|
||||
- groupmanager.mangcheckp
|
||||
- groupmanager.manglistp
|
||||
- groupmanager.manucheckp
|
||||
- groupmanager.manulistp
|
||||
|
||||
g:bukkit_default:
|
||||
permissions:
|
||||
- bukkit.broadcast.user
|
||||
- -bukkit.command.plugins
|
||||
# Permission nodes for Towny by ElgarL
|
||||
# http://dev.bukkit.org/server-mods/towny-advanced/
|
||||
|
||||
g:bukkit_moderator:
|
||||
g:towny_default:
|
||||
permissions:
|
||||
- bukkit.command.ban
|
||||
- bukkit.command.ban.ip
|
||||
- bukkit.command.ban.player
|
||||
- bukkit.command.gamemode
|
||||
- bukkit.command.kick
|
||||
- bukkit.command.unban
|
||||
- bukkit.command.unban.ip
|
||||
- bukkit.command.unban.player
|
||||
|
||||
g:bukkit_admin:
|
||||
permissions:
|
||||
- bukkit.broadcast
|
||||
- bukkit.broadcast.admin
|
||||
- bukkit.command.give
|
||||
- bukkit.command.help
|
||||
- bukkit.command.kill
|
||||
- bukkit.command.list
|
||||
- bukkit.command.me
|
||||
- -bukkit.command.op
|
||||
- -bukkit.command.op.give
|
||||
- -bukkit.command.op.take
|
||||
- bukkit.command.plugins
|
||||
- bukkit.command.reload
|
||||
- bukkit.command.save
|
||||
- bukkit.command.save.disable
|
||||
- bukkit.command.save.enable
|
||||
- bukkit.command.save.perform
|
||||
- bukkit.command.say
|
||||
- bukkit.command.stop
|
||||
- bukkit.command.teleport
|
||||
- bukkit.command.tell
|
||||
- bukkit.command.time
|
||||
- bukkit.command.time.add
|
||||
- bukkit.command.time.set
|
||||
- bukkit.command.version
|
||||
- bukkit.command.whitelist
|
||||
- bukkit.command.whitelist.add
|
||||
- bukkit.command.whitelist.disable
|
||||
- bukkit.command.whitelist.enable
|
||||
- bukkit.command.whitelist.list
|
||||
- bukkit.command.whitelist.reload
|
||||
- bukkit.command.whitelist.remove
|
||||
- towny.chat.general
|
||||
|
||||
g:towny_builder:
|
||||
permissions:
|
||||
|
@ -245,3 +283,23 @@ groups:
|
|||
- -towny.wild.destroy.119
|
||||
- -towny.wild.destroy.120
|
||||
- towny.chat.admin
|
||||
|
||||
# Permission nodes for VanishNoPacket by mbaxter
|
||||
# http://dev.bukkit.org/server-mods/vanish/
|
||||
|
||||
g:vanish_moderator:
|
||||
permissions:
|
||||
- -vanish.*
|
||||
- vanish.vanish
|
||||
- vanish.smokin
|
||||
- vanish.nofollow
|
||||
- vanish.nopickup
|
||||
- vanish.preventincomingdamage
|
||||
- vanish.hooks.dynmap.alwayshidden
|
||||
- vanish.hooks.essentials.hide
|
||||
|
||||
g:vanish_admin:
|
||||
permissions:
|
||||
- vanish.silentjoin
|
||||
- vanish.silentquit
|
||||
- vanish.silentchests
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# Group inheritance
|
||||
# any inherited groups prefixed with a g: are global groups
|
||||
# These groups are defined in the globalgroups.yml
|
||||
# and can be inherited in any worlds groups/users.yml.
|
||||
#
|
||||
# Any inherited groups prefixed with a g: are global groups
|
||||
# and are inherited from the GlobalGroups.yml.
|
||||
#
|
||||
# Groups without the g: prefix are groups local to this world
|
||||
# and defined in the this groups.yml file.
|
||||
# and are defined in the this groups.yml file.
|
||||
#
|
||||
# Local group inheritances define your promotion tree when using 'manpromote/mandemote'
|
||||
|
||||
groups:
|
||||
Default:
|
||||
|
@ -12,8 +14,10 @@ groups:
|
|||
permissions:
|
||||
- -bukkit.command.kill
|
||||
inheritance:
|
||||
- g:essentials_default
|
||||
- g:groupmanager_default
|
||||
- g:bukkit_default
|
||||
- g:essentials_default
|
||||
- g:towny_default
|
||||
info:
|
||||
prefix: '&e'
|
||||
build: false
|
||||
|
@ -34,9 +38,11 @@ groups:
|
|||
permissions: []
|
||||
inheritance:
|
||||
- builder
|
||||
- g:essentials_moderator
|
||||
- g:groupmanager_moderator
|
||||
- g:bukkit_moderator
|
||||
- g:essentials_moderator
|
||||
- g:towny_moderator
|
||||
- g:vanish_moderator
|
||||
info:
|
||||
prefix: '&5'
|
||||
build: true
|
||||
|
@ -46,9 +52,11 @@ groups:
|
|||
permissions: []
|
||||
inheritance:
|
||||
- moderator
|
||||
- g:essentials_admin
|
||||
- g:groupmanager_admin
|
||||
- g:bukkit_admin
|
||||
- g:essentials_admin
|
||||
- g:towny_admin
|
||||
- g:vanish_admin
|
||||
info:
|
||||
prefix: '&c'
|
||||
build: true
|
||||
|
@ -57,6 +65,7 @@ groups:
|
|||
default: false
|
||||
permissions:
|
||||
- '*'
|
||||
- -vanish.*
|
||||
inheritance:
|
||||
- admin
|
||||
info:
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.anjocaido.groupmanager.data.Group;
|
|||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -60,6 +61,9 @@ public class GroupManager extends JavaPlugin {
|
|||
private Map<CommandSender, String> selectedWorlds = new HashMap<CommandSender, String>();
|
||||
private WorldsHolder worldsHolder;
|
||||
private boolean validateOnlinePlayer = true;
|
||||
|
||||
private String lastError = "";
|
||||
|
||||
/**
|
||||
* @return the validateOnlinePlayer
|
||||
*/
|
||||
|
@ -106,7 +110,12 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
|
||||
WorldEvents = null;
|
||||
|
||||
// Remove all attachments before clearing
|
||||
if (BukkitPermissions != null) {
|
||||
BukkitPermissions.removeAllAttachments();
|
||||
BukkitPermissions = null;
|
||||
}
|
||||
|
||||
// EXAMPLE: Custom code, here we just output some info so we can check that
|
||||
// all is well
|
||||
|
@ -115,8 +124,12 @@ public class GroupManager extends JavaPlugin {
|
|||
GroupManager.logger.removeHandler(ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Override
|
||||
public void onEnable() {
|
||||
|
||||
try {
|
||||
lastError = "";
|
||||
|
||||
GroupManager.logger.setUseParentHandlers(false);
|
||||
ch = new GMLoggerHandler();
|
||||
GroupManager.logger.addHandler(ch);
|
||||
|
@ -162,6 +175,57 @@ public class GroupManager extends JavaPlugin {
|
|||
|
||||
// Register as a service
|
||||
this.getServer().getServicesManager().register(WorldsHolder.class, this.worldsHolder, this, ServicePriority.Lowest);
|
||||
} catch (Exception ex) {
|
||||
|
||||
/*
|
||||
* Store the error and write to the log.
|
||||
*/
|
||||
saveErrorLog(ex);
|
||||
|
||||
/*
|
||||
* Throw an error so Bukkit knows about it.
|
||||
*/
|
||||
throw new IllegalArgumentException(ex.getMessage(),ex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an error.log
|
||||
*
|
||||
* @param ex
|
||||
*/
|
||||
private void saveErrorLog(Exception ex) {
|
||||
|
||||
if (!getDataFolder().exists()) {
|
||||
getDataFolder().mkdirs();
|
||||
}
|
||||
|
||||
lastError = ex.getMessage();
|
||||
|
||||
GroupManager.logger.severe("===================================================");
|
||||
GroupManager.logger.severe("= ERROR REPORT START =");
|
||||
GroupManager.logger.severe("===================================================");
|
||||
GroupManager.logger.severe("=== PLEASE COPY AND PASTE THE ERROR.LOG FROM THE ==");
|
||||
GroupManager.logger.severe("= GROUPMANAGER FOLDER TO AN ESSENTIALS DEVELOPER =");
|
||||
GroupManager.logger.severe("===================================================");
|
||||
GroupManager.logger.severe(lastError);
|
||||
GroupManager.logger.severe("===================================================");
|
||||
GroupManager.logger.severe("= ERROR REPORT ENDED =");
|
||||
GroupManager.logger.severe("===================================================");
|
||||
|
||||
// Append this error to the error log.
|
||||
try {
|
||||
String error = "=============================== GM ERROR LOG ===============================\n\n";
|
||||
error += Tasks.getStackTraceAsString(ex);
|
||||
error += "\n============================================================================\n";
|
||||
|
||||
Tasks.appendStringToFile(error, (getDataFolder() + System.getProperty("file.separator") + "ERROR.LOG"));
|
||||
} catch (IOException e) {
|
||||
// Failed to write file.
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
|
@ -298,9 +362,16 @@ public class GroupManager extends JavaPlugin {
|
|||
User senderUser = null;
|
||||
boolean isOpOverride = config.isOpOverride();
|
||||
|
||||
|
||||
// DETERMINING PLAYER INFORMATION
|
||||
if (sender instanceof Player) {
|
||||
senderPlayer = (Player) sender;
|
||||
|
||||
if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) {
|
||||
sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. Check the log and then try a '/manload'.)");
|
||||
return true;
|
||||
}
|
||||
|
||||
senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getName());
|
||||
senderGroup = senderUser.getGroup();
|
||||
isOpOverride = (isOpOverride && (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager.op")));
|
||||
|
@ -310,6 +381,12 @@ public class GroupManager extends JavaPlugin {
|
|||
playerCanDo = true;
|
||||
}
|
||||
} else if (sender instanceof ConsoleCommandSender) {
|
||||
|
||||
if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) {
|
||||
sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. Check the log and then try a '/manload'.)");
|
||||
return true;
|
||||
}
|
||||
|
||||
isConsole = true;
|
||||
}
|
||||
|
||||
|
@ -380,9 +457,18 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <group> | optional [world])");
|
||||
return false;
|
||||
}
|
||||
// Select the relevant world
|
||||
dataHolder = worldsHolder.getWorldData((args.length == 3)? args[2]:Bukkit.getWorlds().get(0).getName());
|
||||
|
||||
// Select the relevant world (if specified)
|
||||
if (args.length == 3) {
|
||||
dataHolder = worldsHolder.getWorldData(args[2]);
|
||||
permissionHandler = dataHolder.getPermissionsHandler();
|
||||
}
|
||||
|
||||
// Validating state of sender
|
||||
if (dataHolder == null || permissionHandler == null) {
|
||||
if (!setDefaultWorldHandler(sender))
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) {
|
||||
return false;
|
||||
|
@ -1395,6 +1481,16 @@ public class GroupManager extends JavaPlugin {
|
|||
// Seems OK
|
||||
sender.sendMessage(ChatColor.YELLOW + "Name: " + ChatColor.GREEN + auxUser.getName());
|
||||
sender.sendMessage(ChatColor.YELLOW + "Group: " + ChatColor.GREEN + auxUser.getGroup().getName());
|
||||
// Compile a list of subgroups
|
||||
auxString = "";
|
||||
for (String subGroup : auxUser.subGroupListStringCopy()) {
|
||||
auxString += subGroup + ", ";
|
||||
}
|
||||
if (auxString.lastIndexOf(",") > 0) {
|
||||
auxString = auxString.substring(0, auxString.lastIndexOf(","));
|
||||
sender.sendMessage(ChatColor.YELLOW + "subgroups: " + auxString);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW + "Overloaded: " + ChatColor.GREEN + dataHolder.isOverloaded(auxUser.getName()));
|
||||
auxGroup = dataHolder.surpassOverload(auxUser.getName()).getGroup();
|
||||
if (!auxGroup.equals(auxUser.getGroup())) {
|
||||
|
@ -1547,10 +1643,17 @@ public class GroupManager extends JavaPlugin {
|
|||
return true;
|
||||
|
||||
case manload:
|
||||
|
||||
/**
|
||||
* Attempt to reload a specific world
|
||||
*/
|
||||
if (args.length > 0) {
|
||||
|
||||
if (!lastError.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. Check the log and then try a '/manload'.)");
|
||||
return true;
|
||||
}
|
||||
|
||||
auxString = "";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
auxString += args[i];
|
||||
|
@ -1575,8 +1678,15 @@ public class GroupManager extends JavaPlugin {
|
|||
/**
|
||||
* Reload all settings and data as no world was specified.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Reset the last error as we are attempting a fresh load.
|
||||
*/
|
||||
lastError = "";
|
||||
onDisable();
|
||||
onEnable();
|
||||
|
||||
sender.sendMessage("All settings and worlds were reloaded!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
@ -459,18 +460,50 @@ public class WorldDataHolder {
|
|||
//PROCESS GROUPS FILE
|
||||
Map<String, List<String>> inheritance = new HashMap<String, List<String>>();
|
||||
try {
|
||||
/*
|
||||
* Fetch all child nodes under the 'groups' entry.
|
||||
*/
|
||||
Map<String, Object> allGroupsNode = (Map<String, Object>) groupsRootDataNode.get("groups");
|
||||
Iterator<String> groupItr = allGroupsNode.keySet().iterator();
|
||||
String groupKey;
|
||||
Integer groupCount = 0;
|
||||
|
||||
/*
|
||||
* loop each group entry
|
||||
* and read it's data.
|
||||
*/
|
||||
while (groupItr.hasNext()) {
|
||||
try {
|
||||
for (String groupKey : allGroupsNode.keySet()) {
|
||||
groupCount++;
|
||||
// Attempt to fetch the next group name.
|
||||
groupKey = groupItr.next();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid node type for group entry (" + groupCount + ") in file: " + groupsFile.getPath());
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch this groups child nodes
|
||||
*/
|
||||
Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
|
||||
/*
|
||||
* Create a new group with this name
|
||||
* in the assigned data source.
|
||||
*/
|
||||
Group thisGrp = ph.createGroup(groupKey);
|
||||
|
||||
if (thisGrp == null) {
|
||||
throw new IllegalArgumentException("I think this Group was declared more than once: " + groupKey + " in file: " + groupsFile.getPath());
|
||||
}
|
||||
/*
|
||||
* If no default node is found set it as false.
|
||||
*/
|
||||
if (thisGroupNode.get("default") == null) {
|
||||
thisGroupNode.put("default", false);
|
||||
}
|
||||
if ((Boolean.parseBoolean(thisGroupNode.get("default").toString()))) {
|
||||
} else if ((Boolean.parseBoolean(thisGroupNode.get("default").toString()))) {
|
||||
/*
|
||||
* Set this as the default group.
|
||||
* Warn if some other group has already claimed that position.
|
||||
*/
|
||||
if (ph.getDefaultGroup() != null) {
|
||||
GroupManager.logger.warning("The group " + thisGrp.getName() + " is claiming to be default where" + ph.getDefaultGroup().getName() + " already was.");
|
||||
GroupManager.logger.warning("Overriding first request for file: " + groupsFile.getPath());
|
||||
|
@ -480,10 +513,20 @@ public class WorldDataHolder {
|
|||
|
||||
//PERMISSIONS NODE
|
||||
try {
|
||||
/*
|
||||
* If no permissions node is found, or it's empty
|
||||
* set an empty permission list
|
||||
*/
|
||||
if (thisGroupNode.get("permissions") == null) {
|
||||
thisGroupNode.put("permissions", new ArrayList<String>());
|
||||
} else {
|
||||
/*
|
||||
* There is a permission list Which seems to hold some data
|
||||
*/
|
||||
if (thisGroupNode.get("permissions") instanceof List) {
|
||||
/*
|
||||
* Check each entry and add it as a new permission.
|
||||
*/
|
||||
for (Object o : ((List) thisGroupNode.get("permissions"))) {
|
||||
try {
|
||||
/*
|
||||
|
@ -492,8 +535,7 @@ public class WorldDataHolder {
|
|||
if (!thisGroupNode.get("permissions").toString().isEmpty())
|
||||
thisGrp.addPermission(o.toString());
|
||||
} catch (NullPointerException e) {
|
||||
// Ignore this entry as it's null.
|
||||
//throw new IllegalArgumentException("Invalid permission node in group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||
// Ignore this entry as it's null. It can be safely dropped
|
||||
}
|
||||
}
|
||||
} else if (thisGroupNode.get("permissions") instanceof String) {
|
||||
|
@ -505,6 +547,9 @@ public class WorldDataHolder {
|
|||
} else {
|
||||
throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>) for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||
}
|
||||
/*
|
||||
* Sort all permissions so they are in the correct order for checking.
|
||||
*/
|
||||
thisGrp.sortPermissions();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -548,9 +593,7 @@ public class WorldDataHolder {
|
|||
throw new IllegalArgumentException("Invalid formatting found in inheritance section for group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid node type, or bad indentation in file: " + groupsFile.getPath());
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new IllegalArgumentException("Your " + groupsFile.getPath() + " file is invalid. See console for details.");
|
||||
|
@ -614,9 +657,21 @@ public class WorldDataHolder {
|
|||
Map<String, Object> allUsersNode = (Map<String, Object>) usersRootDataNode.get("users");
|
||||
|
||||
// Load users if the file is NOT empty
|
||||
if (allUsersNode != null)
|
||||
if (allUsersNode != null) {
|
||||
|
||||
Iterator<String> usersItr = allUsersNode.keySet().iterator();
|
||||
String usersKey;
|
||||
Integer userCount = 0;
|
||||
|
||||
while (usersItr.hasNext()) {
|
||||
try {
|
||||
for (String usersKey : allUsersNode.keySet()) {
|
||||
userCount++;
|
||||
// Attempt to fetch the next user name.
|
||||
usersKey = usersItr.next();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid node type for user entry (" + userCount + ") in file: " + usersFile.getPath());
|
||||
}
|
||||
|
||||
Map<String, Object> thisUserNode = null;
|
||||
try {
|
||||
thisUserNode = (Map<String, Object>) allUsersNode.get(usersKey);
|
||||
|
@ -702,8 +757,6 @@ public class WorldDataHolder {
|
|||
thisUser.setGroup(ph.getDefaultGroup());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid node type, or bad indentation in file: " + usersFile.getPath());
|
||||
}
|
||||
|
||||
ph.removeUsersChangedFlag();
|
||||
|
@ -756,12 +809,14 @@ public class WorldDataHolder {
|
|||
String newLine = System.getProperty("line.separator");
|
||||
|
||||
out.write("# Group inheritance" + newLine);
|
||||
out.write("# any inherited groups prefixed with a g: are global groups" + newLine);
|
||||
out.write("# These groups are defined in the globalgroups.yml" + newLine);
|
||||
out.write("# and can be inherited in any worlds groups/users.yml." + newLine);
|
||||
out.write("#" + newLine);
|
||||
out.write("# Any inherited groups prefixed with a g: are global groups" + newLine);
|
||||
out.write("# and are inherited from the GlobalGroups.yml." + newLine);
|
||||
out.write("#" + newLine);
|
||||
out.write("# Groups without the g: prefix are groups local to this world" + newLine);
|
||||
out.write("# and defined in the this groups.yml file." + newLine);
|
||||
out.write("# and are defined in the this groups.yml file." + newLine);
|
||||
out.write("#" + newLine);
|
||||
out.write("# Local group inheritances define your promotion tree when using 'manpromote/mandemote'" + newLine);
|
||||
out.write(newLine);
|
||||
|
||||
yaml.dump(root, out);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.lang.reflect.Field;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -351,11 +352,39 @@ public class BukkitPermissions {
|
|||
*/
|
||||
private void removeAttachment(Player player) {
|
||||
if (attachments.containsKey(player)) {
|
||||
try {
|
||||
player.removeAttachment(attachments.get(player));
|
||||
} catch (IllegalArgumentException e) {
|
||||
/*
|
||||
* Failed to remove attachment
|
||||
* This usually means Bukkit no longer knows of it.
|
||||
*/
|
||||
}
|
||||
attachments.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all attachments in case of a restart or reload.
|
||||
*/
|
||||
public void removeAllAttachments() {
|
||||
|
||||
Iterator<Player> itr = attachments.keySet().iterator();
|
||||
|
||||
while (itr.hasNext()){
|
||||
Player player = itr.next();
|
||||
try {
|
||||
player.removeAttachment(attachments.get(player));
|
||||
} catch (IllegalArgumentException e) {
|
||||
/*
|
||||
* Failed to remove attachment
|
||||
* This usually means Bukkit no longer knows of it.
|
||||
*/
|
||||
}
|
||||
}
|
||||
attachments.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Player events tracked to cause Superperms updates
|
||||
*
|
||||
|
|
|
@ -4,12 +4,17 @@
|
|||
*/
|
||||
package org.anjocaido.groupmanager.utils;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
@ -17,12 +22,26 @@ import java.util.List;
|
|||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author gabrielcouto
|
||||
*/
|
||||
public abstract class Tasks {
|
||||
|
||||
/**
|
||||
* Gets the exception stack trace as a string.
|
||||
*
|
||||
* @param exception
|
||||
* @return stack trace as a string
|
||||
*/
|
||||
public static String getStackTraceAsString(Exception exception) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
exception.printStackTrace(pw);
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static void copy(InputStream src, File dst) throws IOException {
|
||||
InputStream in = src;
|
||||
OutputStream out = new FileOutputStream(dst);
|
||||
|
@ -45,6 +64,28 @@ public abstract class Tasks {
|
|||
copy(in, dst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a string to a file
|
||||
*
|
||||
* @param data
|
||||
* @param file
|
||||
*/
|
||||
public static void appendStringToFile(String data, String file) throws IOException {
|
||||
|
||||
FileWriter outStream = new FileWriter("." + System.getProperty("file.separator") + file, true);
|
||||
|
||||
BufferedWriter out = new BufferedWriter(outStream);
|
||||
|
||||
data.replaceAll("\n", System.getProperty("line.separator"));
|
||||
|
||||
out.append(new SimpleDateFormat("yyyy-MM-dd HH-mm").format(System.currentTimeMillis()));
|
||||
out.append(System.getProperty("line.separator"));
|
||||
out.append(data);
|
||||
out.append(System.getProperty("line.separator"));
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void removeOldFiles(GroupManager gm, File folder) {
|
||||
if (folder.isDirectory()) {
|
||||
long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000);
|
||||
|
|
Loading…
Reference in a new issue