summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsGroupManager/src')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt8
-rw-r--r--EssentialsGroupManager/src/config.yml7
-rw-r--r--[-rwxr-xr-x]EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java88
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java47
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java20
5 files changed, 76 insertions, 94 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 74752bca8..8a2d92c1d 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -24,4 +24,10 @@ v 1.1:
- Optimized getAllPlayersPermissions and fixed pushing unknown perms to superperms.
v 1.2:
- Changed priority of Registered events to lowest.
- - Fixed an issue with superperms where plugins define perms with inheritance after the root perms \ No newline at end of file
+ - Fixed an issue with superperms where plugins define perms with inheritance after the root perms
+ - Rewrote Config loading to use Bukkits Configuration features
+ - Added an opOverride setting in config.
+ If present and set to false, op's will not get overriding permissions in GroupManager.
+ (one op will not be able to alter another op's settings)
+ - GM will now create all relevant world data files for non mirrored worlds.
+ (for all worlds named in config.yml) \ No newline at end of file
diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml
index 688d3f3ea..a5bca810e 100644
--- a/EssentialsGroupManager/src/config.yml
+++ b/EssentialsGroupManager/src/config.yml
@@ -1,12 +1,19 @@
settings:
+ config:
+ # With this enabled anyone set as op has full permissions when managing GroupManager
+ opOverrides: true
data:
save:
+ # How often GroupManager will save it's data back to groups and users.yml
minutes: 10
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:
+ # Worlds listed here have their permissions mirrored in their children.
world:
- world_nether
- world2
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
index 153221ed9..3a83491db 100755..100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java
@@ -5,15 +5,11 @@
package org.anjocaido.groupmanager;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import org.anjocaido.groupmanager.utils.Tasks;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-import org.yaml.snakeyaml.reader.UnicodeReader;
+import org.bukkit.util.config.Configuration;
/**
*
@@ -22,9 +18,9 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
public class GMConfiguration {
private GroupManager plugin;
- private Map<String, Object> rootDataNode;
private File configFile;
-
+ private Configuration GMconfig;
+
public GMConfiguration(GroupManager plugin) {
this.plugin = plugin;
load();
@@ -44,77 +40,37 @@ public class GMConfiguration {
}
}
- Yaml yaml = new Yaml(new SafeConstructor());
- FileInputStream rx = null;
- try {
- rx = new FileInputStream(configFile);
- } catch (FileNotFoundException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- }
+ GMconfig = new Configuration(configFile);
+
try {
- rootDataNode = (Map<String, Object>) yaml.load(new UnicodeReader(rx));
- if (rootDataNode == null) {
- throw new NullPointerException();
- }
+ GMconfig.load();
} catch (Exception ex) {
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + configFile.getPath(), ex);
- } finally {
- try {
- rx.close();
- } catch (IOException ex) {
- }
}
adjustLoggerLevel();
}
+
+ public boolean isOpOverride() {
+ return GMconfig.getBoolean("settings.config.opOverrides", true);
+ }
- public Map<String, Object> getMirrorsMap() {
- if (rootDataNode.get("settings") instanceof Map) {
- Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
- if (settingsNode.get("permission") instanceof Map) {
- Map<String, Object> permissionNode = (Map<String, Object>) settingsNode.get("permission");
- if (permissionNode.get("world") instanceof Map) {
- Map<String, Object> worldsNode = (Map<String, Object>) permissionNode.get("world");
- if (worldsNode.get("mirror") instanceof Map) {
- Map<String, Object> mirrorsNode = (Map<String, Object>) worldsNode.get("mirror");
- return mirrorsNode;
- }
- }
- }
- }
- return null;
+ @SuppressWarnings("unchecked")
+ public Map<String, Object> getMirrorsMap() {
+ return (Map<String, Object>) GMconfig.getProperty("settings.permission.world.mirror");
}
- public Integer getSaveInterval() {
- if (rootDataNode.get("settings") instanceof Map) {
- Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
- if (settingsNode.get("data") instanceof Map) {
- Map<String, Object> dataNode = (Map<String, Object>) settingsNode.get("data");
- if (dataNode.get("save") instanceof Map) {
- Map<String, Object> saveNode = (Map<String, Object>) dataNode.get("save");
- if (saveNode.get("minutes") instanceof Integer) {
- return (Integer) saveNode.get("minutes");
- }
- }
- }
- }
- return 10;
+ public Integer getSaveInterval() {
+ return GMconfig.getInt("settings.data.save.minutes", 10);
}
public void adjustLoggerLevel() {
- if (rootDataNode.get("settings") instanceof Map) {
- Map<String, Object> settingsNode = (Map<String, Object>) rootDataNode.get("settings");
- if (settingsNode.get("logging") instanceof Map) {
- Map<String, Object> loggingNode = (Map<String, Object>) settingsNode.get("logging");
- if (loggingNode.get("level") instanceof String) {
- String level = (String) loggingNode.get("level");
- try {
- GroupManager.logger.setLevel(Level.parse(level));
- return;
- } catch (Exception e) {
- }
- }
- }
+
+ try {
+ GroupManager.logger.setLevel(Level.parse(GMconfig.getString("settings.logging.level", "INFO")));
+ return;
+ } catch (Exception e) {
}
- GroupManager.logger.setLevel(Level.INFO);
+
+ GroupManager.logger.setLevel(Level.INFO);
}
} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index dcec36639..29c688da5 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -232,6 +232,7 @@ public class GroupManager extends JavaPlugin {
Player senderPlayer = null, targetPlayer = null;
Group senderGroup = null;
User senderUser = null;
+ boolean isOpOverride = config.isOpOverride();
//DETERMINING PLAYER INFORMATION
@@ -239,8 +240,10 @@ public class GroupManager extends JavaPlugin {
senderPlayer = (Player) sender;
senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getName());
senderGroup = senderUser.getGroup();
+ isOpOverride = (isOpOverride && senderPlayer.isOp());
+
System.out.println("[PLAYER_COMMAND] " + senderPlayer.getName() + ": /" + commandLabel + " " + Tasks.join(args, " "));
- if (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
+ if (isOpOverride || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) {
playerCanDo = true;
}
} else if (sender instanceof ConsoleCommandSender) {
@@ -338,23 +341,23 @@ public class GroupManager extends JavaPlugin {
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
return false;
}
@@ -392,7 +395,7 @@ public class GroupManager extends JavaPlugin {
auxUser = dataHolder.getUser(args[0]);
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
@@ -436,7 +439,7 @@ public class GroupManager extends JavaPlugin {
return false;
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
@@ -472,7 +475,7 @@ public class GroupManager extends JavaPlugin {
auxUser = dataHolder.getUser(args[0]);
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
@@ -557,7 +560,7 @@ public class GroupManager extends JavaPlugin {
return false;
}
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
- if (!isConsole && !senderPlayer.isOp() && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
+ if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
sender.sendMessage(ChatColor.RED + "Can't add a permission you don't have.");
return false;
@@ -620,12 +623,12 @@ public class GroupManager extends JavaPlugin {
auxUser = dataHolder.getUser(args[0]);
}
//VALIDANDO SUA PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same group than you, or higher.");
return false;
}
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
- if (!isConsole && !senderPlayer.isOp() && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
+ if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have.");
return false;
@@ -1554,23 +1557,23 @@ public class GroupManager extends JavaPlugin {
return false;
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don't inherit.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
return false;
}
@@ -1612,23 +1615,23 @@ public class GroupManager extends JavaPlugin {
return false;
}
//VALIDANDO PERMISSAO
- if (!isConsole && !senderPlayer.isOp() && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
+ if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) {
sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player involving a group that you don' inherit.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "Can't modify player using groups with different heritage line.");
return false;
}
- if (!isConsole && !senderPlayer.isOp() && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
+ if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) {
sender.sendMessage(ChatColor.RED + "The new group must be a lower rank.");
return false;
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index a2c34be16..32c06249a 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -22,6 +22,7 @@ import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.anjocaido.groupmanager.utils.Tasks;
import org.bukkit.entity.Player;
+import org.bukkit.util.config.ConfigurationNode;
/**
*
@@ -85,6 +86,8 @@ public class WorldsHolder {
Map<String, Object> mirrorsMap = plugin.getConfig().getMirrorsMap();
if (mirrorsMap != null) {
for (String source : mirrorsMap.keySet()) {
+ // Make sure all non mirrored worlds have a set of data files.
+ setupWorldFolder(source);
if (mirrorsMap.get(source) instanceof ArrayList) {
ArrayList mirrorList = (ArrayList) mirrorsMap.get(source);
for (Object o : mirrorList) {
@@ -246,17 +249,24 @@ public class WorldsHolder {
}
private void verifyFirstRun() {
- worldsFolder = new File(plugin.getDataFolder(), "worlds");
- if (!worldsFolder.exists()) {
- worldsFolder.mkdirs();
- }
+
Properties server = new Properties();
try {
server.load(new FileInputStream(new File("server.properties")));
+ serverDefaultWorldName = server.getProperty("level-name").toLowerCase();
+ setupWorldFolder(serverDefaultWorldName);
} catch (IOException ex) {
GroupManager.logger.log(Level.SEVERE, null, ex);
}
- serverDefaultWorldName = server.getProperty("level-name").toLowerCase();
+
+ }
+
+ private void setupWorldFolder(String worldName) {
+ worldsFolder = new File(plugin.getDataFolder(), "worlds");
+ if (!worldsFolder.exists()) {
+ worldsFolder.mkdirs();
+ }
+
File defaultWorldFolder = new File(worldsFolder, serverDefaultWorldName);
if (!defaultWorldFolder.exists()) {
defaultWorldFolder.mkdirs();