diff options
Diffstat (limited to 'EssentialsGroupManager')
11 files changed, 86 insertions, 36 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index fe33a9f15..6729907b5 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -39,4 +39,13 @@ v 1.3: - Fix for Bukkit passing a null To location on a player Portaling
- 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.
\ No newline at end of file + These allow players/admins to be notified when players are moved between groups.
+v 1.4:
+ - Updated for Bukkits new YamlConfiguration.
+ - Cleared remaining Cast errors cause by object cloning.
+ - Removed extra notification messages for the player issuing the group move command.
+ - Added a config setting - bukkit_perms_override: false
+ Enable to allow default Bukkit based permissions to remain enabled, unless directly negated within GroupManager.
+ - Fixed reading world mirrors from the config.
+ - Simplified config.yml while retaining backwards compatibility.
+ - Added data.save.hours setting to config. This allow control over how long backups are retained.
\ No newline at end of file diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml index 1c5e3e32d..25fb5dcd0 100644 --- a/EssentialsGroupManager/src/config.yml +++ b/EssentialsGroupManager/src/config.yml @@ -2,17 +2,24 @@ settings: config: # With this enabled anyone set as op has full permissions when managing GroupManager opOverrides: true + + # If enabled any bukkit permissiosn which default to true will be left enabled. + # If the player is op any permissions set to Op will follow suit. + bukkit_perms_override: false + data: save: # How often GroupManager will save it's data back to groups and users.yml minutes: 10 + # Number of hours to retain backups (plugins/GroupManager/backup) + hours: 24 + logging: # level of detail GroupManager will use when logging. # Acceptable entries are - ALL,CONFIG,FINE,FINER,FINEST,INFO,OFF,SEVERE,WARNING level: INFO - permission: - world: - mirror: + + mirrors: # Worlds listed here have their permissions mirrored in their children. world: - world_nether diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java index aa838d9e8..ad2945076 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java @@ -10,7 +10,7 @@ import java.util.Map; import java.util.logging.Level; import org.anjocaido.groupmanager.utils.Tasks; -import org.bukkit.util.config.Configuration; +import org.bukkit.configuration.file.YamlConfiguration; /** * @@ -20,7 +20,7 @@ public class GMConfiguration { private GroupManager plugin; private File configFile; - private Configuration GMconfig; + private YamlConfiguration GMconfig; public GMConfiguration(GroupManager plugin) { this.plugin = plugin; @@ -41,10 +41,10 @@ public class GMConfiguration { } } - GMconfig = new Configuration(configFile); + GMconfig = new YamlConfiguration(); try { - GMconfig.load(); + GMconfig.load(configFile); } catch (Exception ex) { throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex); } @@ -52,17 +52,28 @@ public class GMConfiguration { } public boolean isOpOverride() { + return GMconfig.getBoolean("settings.config.bukkit_perms_override", true); + } + public boolean isBukkitPermsOverride() { return GMconfig.getBoolean("settings.config.opOverrides", true); } - @SuppressWarnings("unchecked") - public Map<String, Object> getMirrorsMap() { - return (Map<String, Object>) GMconfig.getProperty("settings.permission.world.mirror"); + 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 + return (Map<String, Object>) GMconfig.getConfigurationSection("settings.mirrors").getValues(false); + } 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() { diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 43a57c419..5ef4fc537 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -57,7 +57,7 @@ public class GroupManager extends JavaPlugin { private boolean validateOnlinePlayer = true; private boolean isReady = false; private static boolean isLoaded = false; - private GMConfiguration config; + protected GMConfiguration config; private GMLoggerHandler ch; public static BukkitPermissions BukkitPermissions; private static WorldListener WorldEvents; @@ -163,6 +163,7 @@ public class GroupManager extends JavaPlugin { int minutes = getGMConfig().getSaveInterval(); scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES); GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!"); + GroupManager.logger.info("Backups will be retained for " + getGMConfig().getBackupDuration() + " hours!"); } } @@ -369,7 +370,8 @@ public class GroupManager extends JavaPlugin { //PARECE OK auxUser.setGroup(auxGroup); - sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'."); + if (!sender.hasPermission("groupmanager.notify.other")) + sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'."); targetPlayer = this.getServer().getPlayer(auxUser.getName()); if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer); @@ -1590,7 +1592,8 @@ public class GroupManager extends JavaPlugin { } //PARECE OK auxUser.setGroup(auxGroup); - sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + "."); + if (!sender.hasPermission("groupmanager.notify.other")) + sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + "."); targetPlayer = this.getServer().getPlayer(auxUser.getName()); if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer); @@ -1648,7 +1651,8 @@ public class GroupManager extends JavaPlugin { } //PARECE OK auxUser.setGroup(auxGroup); - sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + "."); + if (!sender.hasPermission("groupmanager.notify.other")) + sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + "."); targetPlayer = this.getServer().getPlayer(auxUser.getName()); if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer); @@ -1770,10 +1774,10 @@ public class GroupManager extends JavaPlugin { for(Player test: Bukkit.getServer().getOnlinePlayers()) { if (!test.equals(player)){ if (test.hasPermission("groupmanager.notify.other")) - test.sendMessage(ChatColor.YELLOW + name +" was " + msg); + test.sendMessage(ChatColor.YELLOW + name +" was" + msg); } else if ((player != null) && ((player.hasPermission("groupmanager.notify.self")) || (player.hasPermission("groupmanager.notify.other")))) - player.sendMessage(ChatColor.YELLOW + "You were " + msg); + player.sendMessage(ChatColor.YELLOW + "You were" + msg); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java index f17d8b21e..7b027a94d 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java @@ -102,7 +102,7 @@ public abstract class DataUnit { * @return a copy of the permission list */ public ArrayList<String> getPermissionList() { - return (ArrayList<String>) permissions.clone(); + return new ArrayList<String>(permissions); } public void sortPermissions() { diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java index c881fc95d..84d4fceed 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java @@ -41,7 +41,7 @@ public class Group extends DataUnit implements Cloneable { @Override public Group clone() { Group clone = new Group(getDataSource(), this.getName()); - clone.inherits = ((ArrayList<String>) this.getInherits().clone()); + clone.inherits = new ArrayList<String>(this.getInherits()); for (String perm : this.getPermissionList()) { clone.addPermission(perm); } @@ -60,7 +60,7 @@ public class Group extends DataUnit implements Cloneable { return null; } Group clone = getDataSource().createGroup(this.getName()); - clone.inherits = ((ArrayList<String>) this.getInherits().clone()); + clone.inherits = new ArrayList<String>(this.getInherits()); for (String perm : this.getPermissionList()) { clone.addPermission(perm); } @@ -76,7 +76,7 @@ public class Group extends DataUnit implements Cloneable { * @return the inherits */ public ArrayList<String> getInherits() { - return (ArrayList<String>) inherits.clone(); + return new ArrayList<String>(inherits); } /** diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index a95018fa9..8a0e6cdbb 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -183,7 +183,7 @@ public class User extends DataUnit implements Cloneable { } public ArrayList<String> subGroupListStringCopy() { - return (ArrayList<String>) subGroups.clone(); + return new ArrayList<String>(subGroups); } /** diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java index 0bcf9a827..7cbe4f65c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java @@ -99,11 +99,11 @@ public class WorldsHolder { * don't load any worlds which are already loaded * or mirrored worlds that don't need data. */ - if (worldsData.containsKey(folder.getName().toLowerCase()) - || mirrors.containsKey(folder.getName().toLowerCase())) { - continue; + if (!worldsData.containsKey(folder.getName().toLowerCase()) + || !mirrors.containsKey(folder.getName().toLowerCase())) { + loadWorld(folder.getName()); } - loadWorld(folder.getName()); + } } } @@ -168,7 +168,7 @@ public class WorldsHolder { if (alreadyDone.contains(w)) { continue; } - Tasks.removeOldFiles(plugin.getBackupFolder()); + Tasks.removeOldFiles(plugin, plugin.getBackupFolder()); if (w == null) { GroupManager.logger.severe("WHAT HAPPENED?"); continue; diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 19d90854b..6a5968c22 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -43,6 +43,7 @@ import org.bukkit.event.server.ServerListener; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
+import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -124,15 +125,31 @@ public class BukkitPermissions { User user = worldData.getUser(player.getName());
- // clear permissions
- for (String permission : attachment.getPermissions().keySet()) {
- attachment.unsetPermission(permission);
- }
+ // clear permissions
+ for (String permission : attachment.getPermissions().keySet())
+ attachment.unsetPermission(permission);
- // find matching permissions
+ /*
+ * find matching permissions
+ *
+ * and base bukkit perms if we are set to allow bukkit permissions to override.
+ */
Boolean value;
for (Permission permission : registeredPermissions) {
- value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
+
+ value = worldData.getPermissionsHandler().checkUserPermission(user, permission.getName());
+
+ // Only check bukkit override IF we don't have the permission directly.
+ if (value = false) {
+ PermissionDefault permDefault = permission.getDefault();
+
+ if ((plugin.getGMConfig().isBukkitPermsOverride())
+ && ((permDefault == PermissionDefault.TRUE)
+ || ((permDefault == PermissionDefault.NOT_OP) && !player.isOp())
+ || ((permDefault == PermissionDefault.OP) && player.isOp())))
+ value = true;
+ }
+
if (value == true)
attachment.setPermission(permission, value);
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java index 8e4d58dde..f3defd94a 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java @@ -13,6 +13,8 @@ import java.io.OutputStream; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; + +import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.data.Group; /** @@ -43,9 +45,9 @@ public abstract class Tasks { copy(in, dst); } - public static void removeOldFiles(File folder) { + public static void removeOldFiles(GroupManager gm, File folder) { if (folder.isDirectory()) { - long oldTime = System.currentTimeMillis() - 86400000L; + long oldTime = System.currentTimeMillis() - (((long)gm.getGMConfig().getBackupDuration()*60*60)*1000); for (File olds : folder.listFiles()) { if (olds.isFile()) { if (olds.lastModified() < oldTime) { diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index a247c7ad0..596b4a8d8 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,5 +1,5 @@ name: GroupManager -version: "1.3 (Phoenix)" +version: "1.4 (Phoenix)" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule. |