From 76eb00575bcd855f74c1cf284a09a9c58f928f7d Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 14 Aug 2011 21:55:22 +0200 Subject: Update Permissions3.jar in lib folder to 3.1.6 --- lib/Permissions3.jar | Bin 72897 -> 78579 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 lib/Permissions3.jar diff --git a/lib/Permissions3.jar b/lib/Permissions3.jar old mode 100755 new mode 100644 index 7e2741283..31c3e5d99 Binary files a/lib/Permissions3.jar and b/lib/Permissions3.jar differ -- cgit v1.2.3 From a2fa666fd5b1cd3f6fac82da1063268589fd967a Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 14 Aug 2011 21:56:40 +0200 Subject: GroupManager update to Permissions 3.1.6 API done by ElgarL --- EssentialsGroupBridge/nbproject/project.properties | 21 +- .../src/com/nijiko/Messaging.class | Bin 2604 -> 0 bytes .../src/com/nijiko/Misc$string.class | Bin 982 -> 0 bytes EssentialsGroupBridge/src/com/nijiko/Misc.class | Bin 3980 -> 0 bytes .../configuration/ConfigurationHandler.class | Bin 788 -> 0 bytes .../configuration/DefaultConfiguration.class | Bin 435 -> 0 bytes .../src/com/nijiko/database/Wrapper$Type.class | Bin 1107 -> 0 bytes .../src/com/nijiko/database/Wrapper.class | Bin 5428 -> 0 bytes .../src/com/nijiko/permissions/Control.class | Bin 27337 -> 0 bytes .../com/nijiko/permissions/PermissionHandler.class | Bin 3198 -> 0 bytes .../nijikokun/bukkit/Permissions/Permissions.java | 120 ++---- .../permissions/NijikoPermissionsProxy.java | 457 ++++++++++++++------- EssentialsGroupBridge/src/plugin.yml | 2 +- .../nbproject/project.properties | 13 + .../anjocaido/groupmanager/GMConfiguration.java | 2 +- .../org/anjocaido/groupmanager/GroupManager.java | 28 +- .../org/anjocaido/groupmanager/data/DataUnit.java | 19 +- .../src/org/anjocaido/groupmanager/data/Group.java | 12 +- .../groupmanager/data/GroupVariables.java | 2 +- .../src/org/anjocaido/groupmanager/data/User.java | 46 ++- .../anjocaido/groupmanager/data/UserVariables.java | 13 +- .../org/anjocaido/groupmanager/data/Variables.java | 14 +- .../dataholder/OverloadedWorldHolder.java | 7 +- .../groupmanager/dataholder/WorldDataHolder.java | 92 +++-- .../dataholder/worlds/WorldsHolder.java | 17 +- .../permissions/AnjoPermissionsHandler.java | 204 ++++++++- .../permissions/PermissionsReaderInterface.java | 77 +++- .../groupmanager/utils/GMLoggerHandler.java | 0 .../utils/GroupManagerPermissions.java | 1 + .../groupmanager/utils/PermissionCheckResult.java | 1 + .../utils/StringPermissionComparator.java | 19 +- .../org/anjocaido/groupmanager/utils/Tasks.java | 53 +-- 32 files changed, 810 insertions(+), 410 deletions(-) delete mode 100644 EssentialsGroupBridge/src/com/nijiko/Messaging.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/Misc$string.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/Misc.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/configuration/ConfigurationHandler.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/configuration/DefaultConfiguration.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/database/Wrapper$Type.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/database/Wrapper.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/permissions/Control.class delete mode 100644 EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class mode change 100644 => 100755 EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java mode change 100644 => 100755 EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java mode change 100644 => 100755 EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java diff --git a/EssentialsGroupBridge/nbproject/project.properties b/EssentialsGroupBridge/nbproject/project.properties index 30137e428..28cec30c9 100644 --- a/EssentialsGroupBridge/nbproject/project.properties +++ b/EssentialsGroupBridge/nbproject/project.properties @@ -4,6 +4,19 @@ annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output application.title=EssentialsGroupBridge application.vendor=gabrielcouto +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-limit-width=120 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap=none build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: @@ -26,16 +39,16 @@ dist.jar=${dist.dir}/EssentialsGroupBridge.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= -file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar -file.reference.Permissions.jar=..\\lib\\Permissions.jar +file.reference.bukkit-0.0.1-SNAPSHOT.jar=../lib/bukkit-0.0.1-SNAPSHOT.jar +file.reference.Permissions3.jar=../lib/Permissions3.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=true jar.index=${jnlp.enabled} javac.classpath=\ ${reference.EssentialsGroupManager.jar}:\ - ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\ - ${file.reference.Permissions.jar} + ${file.reference.Permissions3.jar}:\ + ${file.reference.bukkit-0.0.1-SNAPSHOT.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/EssentialsGroupBridge/src/com/nijiko/Messaging.class b/EssentialsGroupBridge/src/com/nijiko/Messaging.class deleted file mode 100644 index f563d0085..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/Messaging.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/Misc$string.class b/EssentialsGroupBridge/src/com/nijiko/Misc$string.class deleted file mode 100644 index 124b535c3..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/Misc$string.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/Misc.class b/EssentialsGroupBridge/src/com/nijiko/Misc.class deleted file mode 100644 index 4330a303f..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/Misc.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/configuration/ConfigurationHandler.class b/EssentialsGroupBridge/src/com/nijiko/configuration/ConfigurationHandler.class deleted file mode 100644 index 97c1fb35b..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/configuration/ConfigurationHandler.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/configuration/DefaultConfiguration.class b/EssentialsGroupBridge/src/com/nijiko/configuration/DefaultConfiguration.class deleted file mode 100644 index 06d9ee23b..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/configuration/DefaultConfiguration.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/database/Wrapper$Type.class b/EssentialsGroupBridge/src/com/nijiko/database/Wrapper$Type.class deleted file mode 100644 index 173279ddf..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/database/Wrapper$Type.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/database/Wrapper.class b/EssentialsGroupBridge/src/com/nijiko/database/Wrapper.class deleted file mode 100644 index e1b59f9e1..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/database/Wrapper.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/permissions/Control.class b/EssentialsGroupBridge/src/com/nijiko/permissions/Control.class deleted file mode 100644 index d0d8845ac..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/permissions/Control.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class b/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class deleted file mode 100644 index a23287a5b..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class and /dev/null differ diff --git a/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java b/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java old mode 100644 new mode 100755 index cf0d09a35..c7a85fc71 --- a/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java +++ b/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java @@ -1,16 +1,11 @@ package com.nijikokun.bukkit.Permissions; -import com.nijiko.Misc; -import com.nijiko.configuration.DefaultConfiguration; import com.nijiko.permissions.PermissionHandler; import java.util.logging.Logger; import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.permissions.NijikoPermissionsProxy; -import org.bukkit.Server; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Type; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerListener; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; import org.bukkit.plugin.Plugin; @@ -19,110 +14,69 @@ import org.bukkit.plugin.java.JavaPlugin; public class Permissions extends JavaPlugin { - private class Listener extends PlayerListener { - - private Permissions plugin; - - public Listener(Permissions plugin) { - //compiled code - throw new RuntimeException("Compiled Code"); - } - - public void onPlayerCommand(PlayerChatEvent event) { - //compiled code - throw new RuntimeException("Compiled Code"); - } - } public static final Logger log = Logger.getLogger("Fake Permissions"); public static String name = "Permissions"; public static String codename = "Hacked Permissions by AnjoCaido"; public static String version = "2.0"; public static PermissionHandler Security = null; - public static Misc Misc = new Misc(); - public static Server Server; - private Listener Listener = null; - private DefaultConfiguration config = null; - private GroupManager groupManager; @Override public void onDisable() { - //compiled code - //throw new RuntimeException("Compiled Code"); - // EXAMPLE: Custom code, here we just output some info so we can check all is well PluginDescriptionFile pdfFile = this.getDescription(); System.out.println("Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!"); } @Override public void onEnable() { - Server = this.getServer(); PluginDescriptionFile pdfFile = this.getDescription(); - if (Security == null) {//make sure we have only one instance - Security = new NijikoPermissionsProxy(null); - } - - Plugin p = (this.getServer() == null) ? null : this.getServer().getPluginManager().getPlugin("GroupManager"); - if (p != null) { - if (p.isEnabled()) { - setGM(p); - } else { - if (this.getServer() != null) { - this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, new ServerListener() { + if (Security == null) { + //make sure we have only one instance + Security = new NijikoPermissionsProxy(null); + } + + Plugin p = (this.getServer() == null) ? null : this.getServer().getPluginManager().getPlugin("GroupManager"); + if (p != null) { + if (p.isEnabled()) { + setGM(p); + } else { + if (this.getServer() != null) { + this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, new ServerListener() { + + @Override + public void onPluginEnable(PluginEnableEvent event) { + if (event.getPlugin().getDescription().getName().equals("GroupManager")) { + Permissions.this.setGM(event.getPlugin()); + } + } + }, Priority.Normal, this); + } + } + } else { + System.err.println("OOOPS! Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " couldn't find GroupManager!"); + this.getPluginLoader().disablePlugin(this); + } - @Override - public void onPluginEnable(PluginEnableEvent event) - { - if (event.getPlugin().getDescription().getName().equals("GroupManager")) { - Permissions.this.setGM(event.getPlugin()); - } - } - - }, Priority.Normal, this); - } - } - } else { - System.err.println("OOOPS! Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " couldn't find GroupManager!"); - this.getPluginLoader().disablePlugin(this); - } - // EXAMPLE: Custom code, here we just output some info so we can check all is well - if (pdfFile != null) - System.out.println("Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!"); + if (pdfFile != null) { + System.out.println("Fake " + pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!"); + } } - private void registerEvents() { - //compiled code - //throw new RuntimeException("Compiled Code"); + private void setGM(final Plugin p) { + GroupManager groupManager = (GroupManager) p; + ((NijikoPermissionsProxy) Security).setGM(p); } - - private void setGM(Plugin p) { - groupManager = (GroupManager)p; - ((NijikoPermissionsProxy)Security).setGM(p); - } public PermissionHandler getHandler() { - //compiled code - //throw new RuntimeException("Compiled Code"); - //System.out.println("Alguem chamou o handler"); - if (Security == null) - { - Security = new NijikoPermissionsProxy(null); - } - //checkEnable(); + if (Security == null) { + Security = new NijikoPermissionsProxy(null); + } return Security; } public void setupPermissions() { - if (Security == null) - { - Security = new NijikoPermissionsProxy(null); - } - //checkEnable(); - } - - private void checkEnable() { - if (!this.isEnabled() && Security == null && this.getServer() != null) { - this.getServer().getPluginManager().enablePlugin(this); + if (Security == null) { + Security = new NijikoPermissionsProxy(null); } } } diff --git a/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java b/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java old mode 100644 new mode 100755 index e26c10711..bc9cde437 --- a/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java +++ b/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java @@ -4,26 +4,34 @@ */ package org.anjocaido.groupmanager.permissions; -import com.nijiko.permissions.Control; +import com.nijiko.permissions.Group; +import com.nijiko.permissions.PermissionHandler; +import com.nijiko.permissions.User; + import java.io.File; +import java.util.Collection; +import java.util.Comparator; import java.util.Map; +import java.util.Set; + import org.anjocaido.groupmanager.GroupManager; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import org.bukkit.util.config.Configuration; /** - * Everything here maintains the model created by Nijikokun - * + * Everything here maintains the model created by Nijikokun + * * But implemented to use GroupManager system. Which provides instant changes, * without file access. * * @author gabrielcouto */ -public class NijikoPermissionsProxy extends Control { +public class NijikoPermissionsProxy extends PermissionHandler { + GroupManager plugin; - public NijikoPermissionsProxy(GroupManager plugin){ - super(null); + + public NijikoPermissionsProxy(GroupManager plugin) { + super(); this.plugin = plugin; } @@ -39,12 +47,12 @@ public class NijikoPermissionsProxy extends Control { @Override public void addGroupInfo(String world, String group, String node, Object data) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().addGroupInfo(group, node, data); } @Override public void removeGroupInfo(String world, String group, String node) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().removeGroupInfo(group, node); } @Override @@ -59,62 +67,62 @@ public class NijikoPermissionsProxy extends Control { @Override public void addUserInfo(String world, String user, String node, Object data) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().addUserInfo(user, node, data); } @Override public void removeUserInfo(String world, String user, String node) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().removeUserInfo(user, node); } - @Override + @Deprecated public void removeUserInfo(String user, String node) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().removeUserInfo(user, node); } - @Override + @Deprecated public void addGroupPermission(String group, String node) { throw new UnsupportedOperationException("Not supported yet."); } - @Override + @Deprecated public void removeGroupPermission(String group, String node) { throw new UnsupportedOperationException("Not supported yet."); } - @Override + @Deprecated public void addGroupInfo(String group, String node, Object data) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().addGroupInfo(group, node, data); } - @Override + @Deprecated public void removeGroupInfo(String group, String node) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().removeGroupInfo(group, node); } - @Override + @Deprecated public void addUserPermission(String user, String node) { throw new UnsupportedOperationException("Not supported yet."); } - @Override + @Deprecated public void removeUserPermission(String user, String node) { throw new UnsupportedOperationException("Not supported yet."); } - @Override + @Deprecated public void addUserInfo(String user, String node, Object data) { - throw new UnsupportedOperationException("Not supported yet."); + plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().addUserInfo(user, node, data); } @Override public void setDefaultWorld(String world) { - //throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } - @Override + @Deprecated public void setDirectory(File directory) { - //throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } @Override @@ -124,7 +132,7 @@ public class NijikoPermissionsProxy extends Control { @Override public void forceLoadWorld(String world) { - //throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } @Override @@ -134,12 +142,7 @@ public class NijikoPermissionsProxy extends Control { @Override public void load() { - //throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void load(String world, Configuration config) { - //throw new UnsupportedOperationException("Not supported yet."); + throw new UnsupportedOperationException("Not supported yet."); } @Override @@ -155,100 +158,64 @@ public class NijikoPermissionsProxy extends Control { } @Override - public void setCache(Map Cache) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setCache(String world, Map Cache) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setCacheItem(String player, String permission, boolean data) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void setCacheItem(String world, String player, String permission, boolean data) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Map getCache() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Map getCache(String world) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean getCacheItem(String player, String permission) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean getCacheItem(String world, String player, String permission) { - throw new UnsupportedOperationException("Not supported yet."); + public boolean has(Player player, String permission) { + //throw new UnsupportedOperationException("Not supported yet."); + return permission(player, permission); } @Override - public void removeCachedItem(String player, String permission) { - throw new UnsupportedOperationException("Not supported yet."); + public boolean permission(Player player, String permission) { + //throw new UnsupportedOperationException("Not supported yet."); + if (permission == null || permission.equals("")) { + return false; + } + if (player == null) { + GroupManager.logger.severe("A plugin is asking permission '" + permission + "' for a null player... Which plugin does that? Bastards!"); + return false; + } + if (player.getWorld() == null) { + GroupManager.logger.warning("The player " + player.getName() + " has a null world? Treating as default world!"); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().has(player, permission); + } + return plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getPermissionsHandler().has(player, permission); } @Override - public void removeCachedItem(String world, String player, String permission) { - throw new UnsupportedOperationException("Not supported yet."); + public String getGroupRawPrefix(String world, String group) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPrefix(group); } @Override - public void clearCache() { - throw new UnsupportedOperationException("Not supported yet."); + public String getGroupRawSuffix(String world, String group) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupSuffix(group); } @Override - public void clearCache(String world) { - throw new UnsupportedOperationException("Not supported yet."); + public String getUserPrefix(String world, String user) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPrefix(user); } @Override - public void clearAllCache() { - throw new UnsupportedOperationException("Not supported yet."); + public String getUserSuffix(String world, String user) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserSuffix(user); } @Override - public boolean has(Player player, String permission) { - //throw new UnsupportedOperationException("Not supported yet."); - return permission(player, permission); + public String getGroup(String world, String user) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(user); } @Override - public boolean permission(Player player, String permission) { - //throw new UnsupportedOperationException("Not supported yet."); - if(permission==null || permission.equals("")){ - return false; - } - if(player==null){ - GroupManager.logger.severe("A plugin is asking permission '"+permission+"' for a null player... Which plugin does that? Bastards!"); - return false; - } - if(player.getWorld()==null){ - GroupManager.logger.warning("The player "+player.getName()+" has a null world? Treating as default world!"); - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().has(player, permission); - } - return plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getPermissionsHandler().has(player, permission); + public String getPrimaryGroup(String world, String user) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(user); } @Override - public String getGroup(String world, String name) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(name); + public boolean canUserBuild(String world, String user) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().canUserBuild(user); } @Deprecated - @Override public String getGroup(String name) { return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroup(name); } @@ -258,21 +225,14 @@ public class NijikoPermissionsProxy extends Control { return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroups(name); } - @Deprecated - @Override - public String[] getGroups(String name) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroups(name); - } - @Override public boolean inGroup(String world, String name, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(name,group); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(name, group); } @Deprecated - @Override public boolean inGroup(String name, String group) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().inGroup(name,group); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().inGroup(name, group); } @Override @@ -280,7 +240,7 @@ public class NijikoPermissionsProxy extends Control { return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPrefix(group); } - @Override + @Deprecated public String getGroupPrefix(String group) { return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPrefix(group); } @@ -290,7 +250,7 @@ public class NijikoPermissionsProxy extends Control { return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupSuffix(group); } - @Override + @Deprecated public String getGroupSuffix(String group) { return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupSuffix(group); } @@ -301,134 +261,327 @@ public class NijikoPermissionsProxy extends Control { } @Deprecated - @Override public boolean canGroupBuild(String group) { return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().canGroupBuild(group); } @Override public String getGroupPermissionString(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionString(group,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionString(group, permission); } - @Override + @Deprecated public String getGroupPermissionString(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionString(group,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionString(group, permission); } @Override public int getGroupPermissionInteger(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionInteger(group,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionInteger(group, permission); } - @Override + @Deprecated public int getGroupPermissionInteger(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionInteger(group,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionInteger(group, permission); } @Override public boolean getGroupPermissionBoolean(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionBoolean(group,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionBoolean(group, permission); } - @Override + @Deprecated public boolean getGroupPermissionBoolean(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionBoolean(group,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionBoolean(group, permission); } @Override public double getGroupPermissionDouble(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionDouble(group,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionDouble(group, permission); } - @Override + @Deprecated public double getGroupPermissionDouble(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionDouble(group,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionDouble(group, permission); } @Override public String getUserPermissionString(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionString(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionString(name, permission); } - @Override + @Deprecated public String getUserPermissionString(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionString(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionString(name, permission); } @Override public int getUserPermissionInteger(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionInteger(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionInteger(name, permission); } - @Override + @Deprecated public int getUserPermissionInteger(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionInteger(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionInteger(name, permission); } @Override public boolean getUserPermissionBoolean(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionBoolean(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionBoolean(name, permission); } - @Override + @Deprecated public boolean getUserPermissionBoolean(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionBoolean(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionBoolean(name, permission); } @Override public double getUserPermissionDouble(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionDouble(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionDouble(name, permission); } - @Override + @Deprecated public double getUserPermissionDouble(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionDouble(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionDouble(name, permission); } @Override public String getPermissionString(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionString(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionString(name, permission); } - @Override + @Deprecated public String getPermissionString(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionString(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionString(name, permission); } @Override public int getPermissionInteger(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionInteger(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionInteger(name, permission); } - @Override + @Deprecated public int getPermissionInteger(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionInteger(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionInteger(name, permission); } @Override public boolean getPermissionBoolean(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionBoolean(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionBoolean(name, permission); } - @Override + @Deprecated public boolean getPermissionBoolean(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionBoolean(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionBoolean(name, permission); } @Override public double getPermissionDouble(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionDouble(name,permission); + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionDouble(name, permission); } - @Override + @Deprecated public double getPermissionDouble(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionDouble(name,permission); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionDouble(name, permission); } - public void setGM(Plugin p) - { - this.plugin = (GroupManager)p; - } + public void setGM(Plugin p) { + this.plugin = (GroupManager) p; + } + + @Override + public boolean canGroupRawBuild(String world, String group) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().canGroupBuild(group); + } + + @Override + public void closeAll() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int compareWeights(String firstWorld, String first, String secondWorld, String second) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int compareWeights(String world, String first, String second) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Map> getAllGroups(String world, String name) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Group getDefaultGroup(String world) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Group getGroupObject(String world, String group) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getGroupProperName(String world, String group) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Boolean getInfoBoolean(String world, String entryName, String path, + boolean isGroup) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoBoolean(entryName, path, isGroup); + } + + @Override + public Boolean getInfoBoolean(String world, String entryName, String path, + boolean isGroup, Comparator comparator) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Double getInfoDouble(String world, String entryName, String path, boolean isGroup) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoDouble(entryName, path, isGroup); + } + + @Override + public Double getInfoDouble(String world, String entryName, String path, + boolean isGroup, Comparator comparator) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Integer getInfoInteger(String world, String entryName, String path, + boolean isGroup) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoInteger(entryName, path, isGroup); + } + + @Override + public Integer getInfoInteger(String world, String entryName, String path, + boolean isGroup, Comparator comparator) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getInfoString(String world, String entryName, String path, boolean isGroup) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoString(entryName, path, isGroup); + } + + @Override + public String getInfoString(String world, String entryName, String path, + boolean isGroup, Comparator comparator) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Boolean getRawInfoBoolean(String world, String entryName, String path, + boolean isGroup) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Double getRawInfoDouble(String world, String entryName, String path, + boolean isGroup) { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override + public Integer getRawInfoInteger(String world, String entryName, String path, + boolean isGroup) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getRawInfoString(String world, String entryName, String path, + boolean isGroup) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Set getTracks(String world) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public User getUserObject(String world, String name) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection getUsers(String world) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Set getWorlds() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean has(String world, String playerName, String permission) { + if (permission == null || permission.equals("")) { + return false; + } + if (playerName == null || playerName == "") { + GroupManager.logger.severe("A plugin is asking permission '" + permission + "' for a null player... Which plugin does that? Bastards!"); + return false; + } + if (world == null) { + GroupManager.logger.warning("The player " + playerName + " has a null world? Treating as default world!"); + return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().permission(playerName, permission); + } + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().permission(playerName, permission); + } + + @Override + public boolean inGroup(String world, String user, String groupWorld, String group) { + return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(user, group); + } + + @Override + public boolean inSingleGroup(String world, String user, String group) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean inSingleGroup(String world, String user, String groupWorld, String group) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean permission(String world, String name, String node) { + return has(world, name, node); + } + + @Override + public Group safeGetGroup(String world, String name) throws Exception { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public User safeGetUser(String world, String name) throws Exception { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void save(String world) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void saveAll() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection getGroups(String world) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Group getPrimaryGroupObject(String string, String string1) { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/EssentialsGroupBridge/src/plugin.yml b/EssentialsGroupBridge/src/plugin.yml index 513beb372..ca6e2b1dc 100644 --- a/EssentialsGroupBridge/src/plugin.yml +++ b/EssentialsGroupBridge/src/plugin.yml @@ -1,4 +1,4 @@ name: Permissions -version: 2.7.2 +version: 3.1.6 main: com.nijikokun.bukkit.Permissions.Permissions depend: [GroupManager] \ No newline at end of file diff --git a/EssentialsGroupManager/nbproject/project.properties b/EssentialsGroupManager/nbproject/project.properties index 0470fe406..245766661 100644 --- a/EssentialsGroupManager/nbproject/project.properties +++ b/EssentialsGroupManager/nbproject/project.properties @@ -4,6 +4,19 @@ annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output application.title=EssentialsGroupManager application.vendor=gabrielcouto +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120 +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none +auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=true +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-limit-width=120 +auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap=none build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java old mode 100644 new mode 100755 index 68253eccc..153221ed9 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GMConfiguration.java @@ -117,4 +117,4 @@ public class GMConfiguration { } 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 old mode 100644 new mode 100755 index 890af718b..7f6e0fb85 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -32,6 +32,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; +@SuppressWarnings("unused") /** * * @author gabrielcouto @@ -48,7 +49,7 @@ public class GroupManager extends JavaPlugin { private boolean validateOnlinePlayer = true; private boolean isReady = false; private GMConfiguration config; - private GMLoggerHandler ch; + private GMLoggerHandler ch; public static final Logger logger = Logger.getLogger(GroupManager.class.getName()); @Override @@ -60,7 +61,7 @@ public class GroupManager extends JavaPlugin { // EXAMPLE: Custom code, here we just output some info so we can check all is well PluginDescriptionFile pdfFile = this.getDescription(); System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!"); - GroupManager.logger.removeHandler(ch); + GroupManager.logger.removeHandler(ch); } @Override @@ -166,7 +167,7 @@ public class GroupManager extends JavaPlugin { } /** - * A simple interface, for ones that don't want to mess with overloading. + * A simple interface, for ones that don't want to mess with overloading. * Yet it is affected by overloading. But seamless. * @return the dataholder with all information */ @@ -176,8 +177,8 @@ public class GroupManager extends JavaPlugin { } /** - * Use this if you want to play with overloading. - * @return a dataholder with overloading interface + * Use this if you want to play with overloading. + * @return a dataholder with overloading interface */ @Deprecated public OverloadedWorldHolder getOverloadedClassData() { @@ -186,10 +187,11 @@ public class GroupManager extends JavaPlugin { /** * Called when a command registered by this plugin is received. - * @param sender - * @param cmd + * @param sender + * @param cmd * @param args */ + @SuppressWarnings({"null", "deprecation"}) @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { boolean playerCanDo = false; @@ -246,9 +248,9 @@ public class GroupManager extends JavaPlugin { } catch (Exception e) { //this error happened once with someone. now im prepared... i think GroupManager.logger.severe("==================================================="); - GroupManager.logger.severe("= ERROR REPORT START ="); + GroupManager.logger.severe("= ERROR REPORT START ="); GroupManager.logger.severe("==================================================="); - GroupManager.logger.severe("= COPY AND PASTE THIS TO GROUPMANAGER DEVELOPER ="); + GroupManager.logger.severe("= COPY AND PASTE THIS TO GROUPMANAGER DEVELOPER ="); GroupManager.logger.severe("==================================================="); GroupManager.logger.severe(this.getDescription().getName()); GroupManager.logger.severe(this.getDescription().getVersion()); @@ -265,7 +267,7 @@ public class GroupManager extends JavaPlugin { GroupManager.logger.severe(val.name()); } GroupManager.logger.severe("==================================================="); - GroupManager.logger.severe("= ERROR REPORT ENDED ="); + GroupManager.logger.severe("= ERROR REPORT ENDED ="); GroupManager.logger.severe("==================================================="); sender.sendMessage("An error occurred. Ask the admin to take a look at the console."); } @@ -889,7 +891,7 @@ public class GroupManager extends JavaPlugin { } //PARECE OK auxGroup.addInherits(auxGroup2); - sender.sendMessage(ChatColor.RED + "Group " + auxGroup2.getName() + " is now in " + auxGroup.getName() + " inheritance list."); + sender.sendMessage(ChatColor.RED + "Group " + auxGroup2.getName() + " is now in " + auxGroup.getName() + " inheritance list."); return true; case mangdeli: @@ -925,7 +927,7 @@ public class GroupManager extends JavaPlugin { } //PARECE OK auxGroup.removeInherits(auxGroup2.getName()); - sender.sendMessage(ChatColor.RED + "Group " + auxGroup2.getName() + " was removed from " + auxGroup.getName() + " inheritance list."); + sender.sendMessage(ChatColor.RED + "Group " + auxGroup2.getName() + " was removed from " + auxGroup.getName() + " inheritance list."); return true; case manuaddv: @@ -1633,4 +1635,4 @@ public class GroupManager extends JavaPlugin { public File getBackupFolder() { return backupFolder; } -} +} \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java old mode 100644 new mode 100755 index 3eb7491dd..f17d8b21e --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java @@ -27,7 +27,7 @@ public abstract class DataUnit { } /** - * Every group is matched only by their names and DataSources names. + * Every group is matched only by their names and DataSources names. * @param o * @return true if they are equal. false if not. */ @@ -49,9 +49,6 @@ public abstract class DataUnit { return hash; } - - - /** * @return the dataSource */ @@ -67,10 +64,10 @@ public abstract class DataUnit { } public void flagAsChanged() { - GroupManager.logger.finest("DataSource: "+getDataSource().getName()+" - DataUnit: "+getName()+" flagged as changed!"); -// for(StackTraceElement st: Thread.currentThread().getStackTrace()){ -// GroupManager.logger.finest(st.toString()); -// } + GroupManager.logger.finest("DataSource: " + getDataSource().getName() + " - DataUnit: " + getName() + " flagged as changed!"); +// for(StackTraceElement st: Thread.currentThread().getStackTrace()){ +// GroupManager.logger.finest(st.toString()); +// } changed = true; } @@ -79,7 +76,7 @@ public abstract class DataUnit { } public void flagAsSaved() { - GroupManager.logger.finest("DataSource: "+getDataSource().getName()+" - DataUnit: "+getName()+" flagged as saved!"); + GroupManager.logger.finest("DataSource: " + getDataSource().getName() + " - DataUnit: " + getName() + " flagged as saved!"); changed = false; } @@ -108,7 +105,7 @@ public abstract class DataUnit { return (ArrayList) permissions.clone(); } - public void sortPermissions(){ + public void sortPermissions() { Collections.sort(permissions, StringPermissionComparator.getInstance()); } -} +} \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java old mode 100644 new mode 100755 index c734b208e..4af5449fc --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java @@ -30,18 +30,18 @@ public class Group extends DataUnit implements Cloneable { * @param name */ public Group(WorldDataHolder source, String name) { - super(source,name); + super(source, name); } /** - * Clone this group + * Clone this group * @return a clone of this group */ @Override public Group clone() { Group clone = new Group(getDataSource(), this.getName()); clone.inherits = ((ArrayList) this.getInherits().clone()); - for(String perm: this.getPermissionList()){ + for (String perm : this.getPermissionList()) { clone.addPermission(perm); } clone.variables = ((GroupVariables) variables).clone(clone); @@ -60,7 +60,7 @@ public class Group extends DataUnit implements Cloneable { } Group clone = getDataSource().createGroup(this.getName()); clone.inherits = ((ArrayList) this.getInherits().clone()); - for(String perm: this.getPermissionList()){ + for (String perm : this.getPermissionList()) { clone.addPermission(perm); } clone.variables = variables.clone(clone); @@ -108,13 +108,13 @@ public class Group extends DataUnit implements Cloneable { } /** - * + * * @param varList */ public void setVariables(Map varList) { GroupVariables temp = new GroupVariables(this, varList); variables.clearVars(); - for(String key: temp.getVarKeyList()){ + for (String key : temp.getVarKeyList()) { variables.addVar(key, temp.getVarObject(key)); } flagAsChanged(); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java old mode 100644 new mode 100755 index 87c34de2b..4775eac1f --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/GroupVariables.java @@ -45,7 +45,7 @@ public class GroupVariables extends Variables implements Cloneable { } /** - * A clone of all vars here. + * A clone of all vars here. * @return */ protected GroupVariables clone(Group newOwner) { diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java old mode 100644 new mode 100755 index ceecbfa21..b90cf4ff1 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -4,7 +4,7 @@ */ package org.anjocaido.groupmanager.data; -import com.sun.org.apache.bcel.internal.generic.AALOAD; +//import com.sun.org.apache.bcel.internal.generic.AALOAD; import java.util.ArrayList; import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import java.util.Map; @@ -27,13 +27,12 @@ public class User extends DataUnit implements Cloneable { */ private UserVariables variables = new UserVariables(this); - /** * * @param name */ public User(WorldDataHolder source, String name) { - super(source,name); + super(source, name); this.group = source.getDefaultGroup().getName(); } @@ -45,7 +44,7 @@ public class User extends DataUnit implements Cloneable { public User clone() { User clone = new User(getDataSource(), this.getName()); clone.group = this.group; - for(String perm: this.getPermissionList()){ + for (String perm : this.getPermissionList()) { clone.addPermission(perm); } //clone.variables = this.variables.clone(); @@ -68,7 +67,7 @@ public class User extends DataUnit implements Cloneable { } else { clone.setGroup(this.getGroupName()); } - for(String perm: this.getPermissionList()){ + for (String perm : this.getPermissionList()) { clone.addPermission(perm); } //clone.variables = this.variables.clone(); @@ -117,43 +116,47 @@ public class User extends DataUnit implements Cloneable { flagAsChanged(); } - public void addSubGroup(Group subGroup){ - if(this.group.equalsIgnoreCase(subGroup.getName())){ + public void addSubGroup(Group subGroup) { + if (this.group.equalsIgnoreCase(subGroup.getName())) { return; } if (!this.getDataSource().groupExists(subGroup.getName())) { getDataSource().addGroup(subGroup); - } + } subGroup = getDataSource().getGroup(subGroup.getName()); removeSubGroup(subGroup); subGroups.add(subGroup.getName()); flagAsChanged(); } - public int subGroupsSize(){ + + public int subGroupsSize() { return subGroups.size(); } - public boolean isSubGroupsEmpty(){ + + public boolean isSubGroupsEmpty() { return subGroups.isEmpty(); } - public boolean containsSubGroup(Group subGroup){ + + public boolean containsSubGroup(Group subGroup) { return subGroups.contains(subGroup.getName()); } - public boolean removeSubGroup(Group subGroup){ - try{ - if(subGroups.remove(subGroup.getName())){ + + public boolean removeSubGroup(Group subGroup) { + try { + if (subGroups.remove(subGroup.getName())) { flagAsChanged(); return true; } - } catch (Exception e){ - + } catch (Exception e) { } return false; } - public ArrayList subGroupListCopy(){ + + public ArrayList subGroupListCopy() { ArrayList val = new ArrayList(); - for(String gstr: subGroups){ + for (String gstr : subGroups) { Group g = getDataSource().getGroup(gstr); - if(g==null){ + if (g == null) { removeSubGroup(g); continue; } @@ -161,7 +164,8 @@ public class User extends DataUnit implements Cloneable { } return val; } - public ArrayList subGroupListStringCopy(){ + + public ArrayList subGroupListStringCopy() { return (ArrayList) subGroups.clone(); } @@ -179,7 +183,7 @@ public class User extends DataUnit implements Cloneable { public void setVariables(Map varList) { UserVariables temp = new UserVariables(this, varList); variables.clearVars(); - for(String key: temp.getVarKeyList()){ + for (String key : temp.getVarKeyList()) { variables.addVar(key, temp.getVarObject(key)); } flagAsChanged(); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java old mode 100644 new mode 100755 index 45dfc31e7..3f3a6c374 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/UserVariables.java @@ -2,7 +2,6 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ - package org.anjocaido.groupmanager.data; import java.util.Map; @@ -11,19 +10,23 @@ import java.util.Map; * * @author gabrielcouto */ -public class UserVariables extends Variables{ +public class UserVariables extends Variables { + private User owner; - public UserVariables(User owner){ + + public UserVariables(User owner) { super(owner); this.owner = owner; } + public UserVariables(User owner, Map varList) { super(owner); this.variables = varList; this.owner = owner; } + /** - * A clone of all vars here. + * A clone of all vars here. * @return */ protected UserVariables clone(User newOwner) { @@ -34,6 +37,7 @@ public class UserVariables extends Variables{ newOwner.flagAsChanged(); return clone; } + /** * @return the owner */ @@ -41,5 +45,4 @@ public class UserVariables extends Variables{ public User getOwner() { return owner; } - } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java old mode 100644 new mode 100755 index 31ed0d795..547e6266d --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Variables.java @@ -19,12 +19,14 @@ import java.util.Set; * @author gabrielcouto */ public abstract class Variables implements Cloneable { + private DataUnit owner; protected Map variables = new HashMap(); - public Variables(DataUnit owner){ + public Variables(DataUnit owner) { this.owner = owner; } + /** * Add var to the the INFO node. * examples: @@ -45,7 +47,7 @@ public abstract class Variables implements Cloneable { } /** - * Returns the object inside the var + * Returns the object inside the var * @param name * @return a Object if exists. null if doesn't exists */ @@ -112,7 +114,7 @@ public abstract class Variables implements Cloneable { } /** - * All variable keys this is holding + * All variable keys this is holding * @return */ public Set getVarKeyList() { @@ -122,7 +124,7 @@ public abstract class Variables implements Cloneable { } /** - * verify is a var exists + * verify is a var exists * @param name the key name of the var * @return true if that var exists */ @@ -174,7 +176,7 @@ public abstract class Variables implements Cloneable { } - public void clearVars(){ + public void clearVars() { variables.clear(); owner.flagAsChanged(); } @@ -186,7 +188,7 @@ public abstract class Variables implements Cloneable { return owner; } - public boolean isEmpty(){ + public boolean isEmpty() { return variables.isEmpty(); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java old mode 100644 new mode 100755 index f735ff5e6..42c78cccf --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java @@ -25,6 +25,7 @@ public class OverloadedWorldHolder extends WorldDataHolder { * * @param ph */ + @SuppressWarnings("deprecation") public OverloadedWorldHolder(WorldDataHolder ph) { super(ph.getName()); this.f = ph.f; @@ -135,7 +136,7 @@ public class OverloadedWorldHolder extends WorldDataHolder { } /** - * + * * @return */ @Override @@ -185,7 +186,7 @@ public class OverloadedWorldHolder extends WorldDataHolder { } /** - * Gets the user in normal state. Surpassing the overload state. + * Gets the user in normal state. Surpassing the overload state. * It doesn't affect permissions. But it enables plugins change the * actual user permissions even in overload mode. * @param userName @@ -201,4 +202,4 @@ public class OverloadedWorldHolder extends WorldDataHolder { User newUser = createUser(userName); return newUser; } -} +} \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java old mode 100644 new mode 100755 index ac26138c4..1331a92ad --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -42,7 +42,7 @@ public class WorldDataHolder { */ protected String name; /** - * The actual groups holder + * The actual groups holder */ protected Map groups = new HashMap(); /** @@ -50,7 +50,7 @@ public class WorldDataHolder { */ protected Map users = new HashMap(); /** - * Points to the default group + * Points to the default group */ protected Group defaultGroup = null; /** @@ -81,7 +81,7 @@ public class WorldDataHolder { protected boolean haveGroupsChanged = false; /** - * Prevent direct instantiation + * Prevent direct instantiation * @param worldName */ protected WorldDataHolder(String worldName) { @@ -90,7 +90,7 @@ public class WorldDataHolder { /** * The main constructor for a new WorldDataHolder - * Please don't set the default group as null + * Please don't set the default group as null * @param worldName * @param defaultGroup the default group. its good to start with one */ @@ -116,7 +116,7 @@ public class WorldDataHolder { } /** - * Add a user to the list. If it already exists, overwrite the old. + * Add a user to the list. If it already exists, overwrite the old. * @param theUser the user you want to add to the permission list */ public void addUser(User theUser) { @@ -158,7 +158,7 @@ public class WorldDataHolder { } /** - * Change the default group of the file. + * Change the default group of the file. * @param group the group you want make default. */ public void setDefaultGroup(Group group) { @@ -170,7 +170,7 @@ public class WorldDataHolder { } /** - * Returns the default group of the file + * Returns the default group of the file * @return the default group */ public Group getDefaultGroup() { @@ -178,7 +178,7 @@ public class WorldDataHolder { } /** - * Returns a group of the given name + * Returns a group of the given name * @param groupName the name of the group * @return a group if it is found. null if not found. */ @@ -187,7 +187,7 @@ public class WorldDataHolder { } /** - * Check if a group exists. + * Check if a group exists. * Its the same of getGroup, but check if it is null. * @param groupName the name of the group * @return true if exists. false if not. @@ -210,7 +210,7 @@ public class WorldDataHolder { } /** - * Remove the group to the list + * Remove the group to the list * @param groupName * @return true if had something to remove. false the group was default or non-existant */ @@ -277,7 +277,7 @@ public class WorldDataHolder { } /** - * reads the file again + * reads the file again */ public void reload() { try { @@ -301,13 +301,14 @@ public class WorldDataHolder { } /** - * Returns a data holder for the given file + * Returns a data holder for the given file * @param worldName * @param file * @return * @throws Exception * @deprecated */ + @SuppressWarnings({"rawtypes", "unchecked"}) @Deprecated public static WorldDataHolder load(String worldName, File file) throws Exception { WorldDataHolder ph = new WorldDataHolder(worldName); @@ -387,7 +388,7 @@ public class WorldDataHolder { } } catch (Exception ex) { ex.printStackTrace(); - throw new Exception("Your Permissions config file is invalid. See console for details."); + throw new Exception("Your Permissions config file is invalid. See console for details."); } if (ph.defaultGroup == null) { throw new IllegalArgumentException("There was no Default Group declared."); @@ -409,7 +410,7 @@ public class WorldDataHolder { User thisUser = ph.createUser(usersKey); if (thisUser == null) { GroupManager.logger.warning("I think this user was declared more than once: " + usersKey); - continue; + continue; } if (thisUserNode.get("permissions") == null) { thisUserNode.put("permissions", new ArrayList()); @@ -436,8 +437,8 @@ public class WorldDataHolder { Group hisGroup = ph.getGroup(thisUserNode.get("group").toString()); if (hisGroup == null) { GroupManager.logger.warning("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName()); - thisUser.setGroup(ph.defaultGroup); - } + thisUser.setGroup(ph.defaultGroup); + } thisUser.setGroup(hisGroup); } else { thisUser.setGroup(ph.defaultGroup); @@ -447,7 +448,7 @@ public class WorldDataHolder { } /** - * Returns a data holder for the given file + * Returns a data holder for the given file * @param worldName * @param groupsFile * @param usersFile @@ -455,6 +456,7 @@ public class WorldDataHolder { * @throws FileNotFoundException * @throws IOException */ + @SuppressWarnings({"rawtypes", "unchecked"}) public static WorldDataHolder load(String worldName, File groupsFile, File usersFile) throws FileNotFoundException, IOException { WorldDataHolder ph = new WorldDataHolder(worldName); ph.groupsFile = groupsFile; @@ -539,7 +541,7 @@ public class WorldDataHolder { } } catch (Exception ex) { ex.printStackTrace(); - throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details."); + throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details."); } if (ph.defaultGroup == null) { throw new IllegalArgumentException("There was no Default Group declared."); @@ -639,7 +641,7 @@ public class WorldDataHolder { } /** - * Write a dataHolder in a specified file + * Write a dataHolder in a specified file * @param ph * @param file * @deprecated @@ -726,7 +728,7 @@ public class WorldDataHolder { } /** - * Write a dataHolder in a specified file + * Write a dataHolder in a specified file * @param ph * @param groupsFile */ @@ -761,28 +763,28 @@ public class WorldDataHolder { DumperOptions opt = new DumperOptions(); opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); final Yaml yaml = new Yaml(opt); - try { - yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8")); - } catch (UnsupportedEncodingException ex) { - } catch (FileNotFoundException ex) { - } + try { + yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8")); + } catch (UnsupportedEncodingException ex) { + } catch (FileNotFoundException ex) { + } /*FileWriter tx = null; try { - tx = new FileWriter(groupsFile, false); - tx.write(yaml.dump(root)); - tx.flush(); + tx = new FileWriter(groupsFile, false); + tx.write(yaml.dump(root)); + tx.flush(); } catch (Exception e) { } finally { - try { - tx.close(); - } catch (IOException ex) { - } + try { + tx.close(); + } catch (IOException ex) { + } }*/ } /** - * Write a dataHolder in a specified file + * Write a dataHolder in a specified file * @param ph * @param usersFile */ @@ -823,22 +825,22 @@ public class WorldDataHolder { DumperOptions opt = new DumperOptions(); opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); final Yaml yaml = new Yaml(opt); - try { - yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8")); - } catch (UnsupportedEncodingException ex) { - } catch (FileNotFoundException ex) { - } + try { + yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8")); + } catch (UnsupportedEncodingException ex) { + } catch (FileNotFoundException ex) { + } /*FileWriter tx = null; try { - tx = new FileWriter(usersFile, false); - tx.write(yaml.dump(root)); - tx.flush(); + tx = new FileWriter(usersFile, false); + tx.write(yaml.dump(root)); + tx.flush(); } catch (Exception e) { } finally { - try { - tx.close(); - } catch (IOException ex) { - } + try { + tx.close(); + } catch (IOException ex) { + } }*/ } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java old mode 100644 new mode 100755 index 83073c10b..b4d50b431 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java @@ -37,7 +37,7 @@ public class WorldsHolder { * Map of mirrors: * The key is the mirror. * The object is the mirrored. - * + * * Mirror shows the same data of mirrored. */ private Map mirrors = new HashMap(); @@ -63,7 +63,8 @@ public class WorldsHolder { initialWorldLoading(); mirrorSetUp(); } - private void initialWorldLoading(){ + + private void initialWorldLoading() { //LOAD EVERY WORLD POSSIBLE loadWorld(serverDefaultWorldName); defaultWorld = worldsData.get(serverDefaultWorldName); @@ -77,7 +78,9 @@ public class WorldsHolder { } } } - public void mirrorSetUp(){ + + @SuppressWarnings("rawtypes") + public void mirrorSetUp() { mirrors.clear(); Map mirrorsMap = plugin.getConfig().getMirrorsMap(); if (mirrorsMap != null) { @@ -122,7 +125,7 @@ public class WorldsHolder { } /** - * + * */ public void saveChanges() { ArrayList alreadyDone = new ArrayList(); @@ -136,7 +139,7 @@ public class WorldsHolder { continue; } if (w.haveGroupsChanged()) { - String groupsFolderName = w.getGroupsFile().getParentFile().getName(); + //String groupsFolderName = w.getGroupsFile().getParentFile().getName(); File backupGroups = new File(plugin.getBackupFolder(), "bkp_" + w.getName() + "_g_" + Tasks.getDateString() + ".yml"); try { Tasks.copy(w.getGroupsFile(), backupGroups); @@ -368,7 +371,7 @@ public class WorldsHolder { GroupManager.logger.log(Level.SEVERE, null, ex); return; } - GroupManager.logger.severe("Failed to load world " + worldName + "..."); + //GroupManager.logger.severe("Failed to load world " + worldName + "..."); } } @@ -376,7 +379,7 @@ public class WorldsHolder { * Tells if the such world has been mapped. * * It will return true if world is a mirror. - * + * * @param worldName * @return true if world is loaded or mirrored. false if not listed */ diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java old mode 100644 new mode 100755 index ca223da81..b892e653e --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -13,10 +13,11 @@ import org.anjocaido.groupmanager.data.Group; import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import org.anjocaido.groupmanager.data.User; import org.anjocaido.groupmanager.utils.PermissionCheckResult; +import org.anjocaido.groupmanager.utils.PermissionCheckResult.Type; import org.bukkit.entity.Player; /** - * Everything here maintains the model created by Nijikokun + * Everything here maintains the model created by Nijikokun * * But implemented to use GroupManager system. Which provides instant changes, * without file access. @@ -49,7 +50,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { } /** - * Checks if a player can use that permission node. + * Checks if a player can use that permission node. * @param player * @param permission * @return @@ -59,6 +60,16 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { return checkUserPermission(ph.getUser(player.getName()), permission); } + /** + * Checks if a player can use that permission node. + * @param playerName + * @param permission + * @return + */ + public boolean permission(String playerName, String permission) { + return checkUserPermission(ph.getUser(playerName), permission); + } + /** * Returns the name of the group of that player name. * @param userName @@ -70,7 +81,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { } /** - * Verify if player is in suck group. + * Verify if player is in suck group. * It will check it's groups inheritance. * * So if you have a group Admin > Moderator @@ -98,6 +109,75 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { return false; } + /** + * Gets the appropriate prefix for the user. + * This method is a utility method for chat plugins to get the user's prefix + * without having to look at every one of the user's ancestors. + * Returns an empty string if user has no parent groups. + * @param user Player's name + * @return Player's prefix + */ + @Override + public String getUserPrefix(String user) { + + String prefix = ph.getUser(user).getVariables().getVarString("prefix"); + if (prefix.length() != 0) { + return prefix; + } + + return getGroupPrefix(getGroup(user)); + } + + /** + * Gets the appropriate prefix for the user. + * This method is a utility method for chat plugins to get the user's prefix + * without having to look at every one of the user's ancestors. + * Returns an empty string if user has no parent groups. + * @param user Player's name + * @return Player's prefix + */ + @Override + public String getUserSuffix(String user) { + + String suffix = ph.getUser(user).getVariables().getVarString("suffix"); + if (suffix.length() != 0) { + return suffix; + } + + return getGroupSuffix(getGroup(user)); + + } + + /** + * Gets name of the primary group of the user. + * Returns the name of the default group if user has no parent groups, + * or "Default" if there is no default group for that world. + * @param user Player's name + * @return Name of player's primary group + */ + public String getPrimaryGroup(String user) { + + return getGroup(user); + + } + + /** + * Check if user can build. + * @param world Player's world + * @param user Player's name + * @return Whether the user can build + */ + public boolean canUserBuild(String user) { + boolean test = ph.getUser(user).getVariables().getVarBoolean("build"); + + if (test) { + return test; + } + + return canGroupBuild(getGroup(user)); + + } + /** * Returns the String prefix for the given group * @param groupName @@ -107,7 +187,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { public String getGroupPrefix(String groupName) { Group g = ph.getGroup(groupName); if (g == null) { - return null; + return ""; } return g.getVariables().getVarString("prefix"); } @@ -121,7 +201,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { public String getGroupSuffix(String groupName) { Group g = ph.getGroup(groupName); if (g == null) { - return null; + return ""; } return g.getVariables().getVarString("suffix"); } @@ -161,7 +241,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { } /** - * It returns a Integer variable value + * It returns a Integer variable value * It will harvest inheritance for value. * @param groupName * @param variable @@ -619,8 +699,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { @Deprecated public boolean checkGroupPermissionWithInheritance(Group start, String permission, List alreadyChecked) { PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission); - if (result.resultType.equals(result.resultType.EXCEPTION) - || result.resultType.equals(result.resultType.FOUND)) { + if (result.resultType.equals(Type.EXCEPTION) + || result.resultType.equals(Type.FOUND)) { return true; } return false; @@ -682,8 +762,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { @Deprecated public Group nextGroupWithPermission(Group start, String permission, List alreadyChecked) { PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission); - if (result.resultType.equals(result.resultType.EXCEPTION) - || result.resultType.equals(result.resultType.FOUND)) { + if (result.resultType.equals(Type.EXCEPTION) + || result.resultType.equals(Type.FOUND)) { return (Group) checkGroupPermissionWithInheritance(start, permission).owner; } return null; @@ -699,7 +779,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { * @param start * @param alreadyChecked * @return the group that passed on test. null if no group passed. - * @deprecated use the other method with same name, instead + * @deprecated use the other method with same name, instead */ @Deprecated public ArrayList listAllGroupsInherited(Group start, ArrayList alreadyChecked) { @@ -807,9 +887,10 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { * @param userName * @return */ + @Override public String[] getGroups(String userName) { ArrayList allGroups = listAllGroupsInherited(ph.getUser(userName).getGroup()); - for(Group subg: ph.getUser(userName).subGroupListCopy()){ + for (Group subg : ph.getUser(userName).subGroupListCopy()) { allGroups.addAll(listAllGroupsInherited(subg)); } String[] arr = new String[allGroups.size()]; @@ -825,6 +906,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { * @param targerPermission * @return */ + @SuppressWarnings("unused") private Group breadthFirstSearch(Group start, String targerPermission) { if (start == null || targerPermission == null) { return null; @@ -853,4 +935,102 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { } return null; } + + @Override + public Group getDefaultGroup() { + return ph.getDefaultGroup(); + } + + @Override + public String getInfoString(String entryName, String path, + boolean isGroup) { + if (isGroup) { + Group data = ph.getGroup(entryName); + if (data == null) { + return null; + } + return data.getVariables().getVarString(path); + } else { + User data = ph.getUser(entryName); + if (data == null) { + return null; + } + return data.getVariables().getVarString(path); + } + } + + @Override + public int getInfoInteger(String entryName, String path, + boolean isGroup) { + if (isGroup) { + Group data = ph.getGroup(entryName); + if (data == null) { + return -1; + } + return data.getVariables().getVarInteger(path); + } else { + User data = ph.getUser(entryName); + if (data == null) { + return -1; + } + return data.getVariables().getVarInteger(path); + } + } + + @Override + public double getInfoDouble(String entryName, String path, + boolean isGroup) { + if (isGroup) { + Group data = ph.getGroup(entryName); + if (data == null) { + return -1; + } + return data.getVariables().getVarDouble(path); + } else { + User data = ph.getUser(entryName); + if (data == null) { + return -1; + } + return data.getVariables().getVarDouble(path); + } + + } + + @Override + public boolean getInfoBoolean(String entryName, String path, + boolean isGroup) { + if (isGroup) { + Group data = ph.getGroup(entryName); + if (data == null) { + return false; + } + return data.getVariables().getVarBoolean(path); + } else { + User data = ph.getUser(entryName); + if (data == null) { + return false; + } + return data.getVariables().getVarBoolean(path); + } + } + + @Override + public void addUserInfo(String name, String path, Object data) { + ph.getUser(name).getVariables().addVar(path, data); + } + + @Override + public void removeUserInfo(String name, String path) { + ph.getUser(name).getVariables().removeVar(path); + } + + @Override + public void addGroupInfo(String name, String path, Object data) { + ph.getGroup(name).getVariables().addVar(path, data); + } + + @Override + public void removeGroupInfo(String name, String path) { + ph.getGroup(name).getVariables().removeVar(path); + } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java old mode 100644 new mode 100755 index 90194cddd..ede097ea4 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java @@ -1,10 +1,15 @@ package org.anjocaido.groupmanager.permissions; +//import java.util.Collection; +//import java.util.Map; +//import java.util.Set; +import org.anjocaido.groupmanager.data.Group; +//import org.anjocaido.groupmanager.data.User; import org.bukkit.entity.Player; /** - * Made by Nijikokun. Changed by Gabriel Couto - * + * Made by Nijikokun. Changed by Gabriel Couto + * * This class is intended to *read* permissions from a single world. * * @author Nijikokun @@ -12,7 +17,6 @@ import org.bukkit.entity.Player; */ public abstract class PermissionsReaderInterface { - /** * * @param player @@ -90,7 +94,7 @@ public abstract class PermissionsReaderInterface { public abstract boolean getGroupPermissionBoolean(String string, String string1); /** - * + * * @param string * @param string1 * @return @@ -160,4 +164,69 @@ public abstract class PermissionsReaderInterface { * @return */ public abstract double getPermissionDouble(String string, String string1); + +///////////////////////////// + /** + * Gets the appropriate prefix for the user. + * This method is a utility method for chat plugins to get the user's prefix + * without having to look at every one of the user's ancestors. + * Returns an empty string if user has no parent groups. + * @param world Player's world + * @param user Player's name + * @return Player's prefix + */ + public abstract String getUserPrefix(String user); + + /** + * Gets the appropriate suffix for the user. + * This method is a utility method for chat plugins to get the user's suffix + * without having to look at every one of the user's ancestors. + * Returns an empty string if user has no parent groups. + * @param world Player's world + * @param user Player's name + * @return Player's suffix + */ + public abstract String getUserSuffix(String user); + + /** + * Returns the group object representing the default group of the given world. + * This method will return null if the object does not exist or the world has no default group. + * @return Group object representing default world, or null if it doesn't exist or is not defined. + */ + public abstract Group getDefaultGroup(); + + /** + * Gets a array of the names of all parent groups in the same world. + * @param name Target user's name + * @return An array containing the names of all parent groups (including ancestors) that are in the same world + */ + public abstract String[] getGroups(String name); + + public abstract String getInfoString(String entryName, String path, boolean isGroup); + //public abstract String getInfoString(String entryName, String path, boolean isGroup, Comparator comparator); + + public abstract int getInfoInteger(String entryName, String path, boolean isGroup); + //public abstract int getInfoInteger(String entryName, String path, boolean isGroup, Comparator comparator); + + /** + * Gets a double from the Info node without inheritance. + * @param entryName + * @param path + * @param isGroup + * @return + */ + public abstract double getInfoDouble(String entryName, String path, boolean isGroup); + //public abstract double getInfoDouble(String entryName, String path, boolean isGroup, Comparator comparator); + + public abstract boolean getInfoBoolean(String entryName, String path, boolean isGroup); + //public abstract boolean getInfoBoolean(String entryName, String path, boolean isGroup, Comparator comparator); + + public abstract void addUserInfo(String name, String path, Object data); + + public abstract void removeUserInfo(String name, String path); + + public abstract void addGroupInfo(String name, String path, Object data); + + public abstract void removeGroupInfo(String name, String path); +////////////////////////////// } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GMLoggerHandler.java old mode 100644 new mode 100755 diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java old mode 100644 new mode 100755 index 781f2753c..0262bb33e --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/GroupManagerPermissions.java @@ -9,6 +9,7 @@ package org.anjocaido.groupmanager.utils; * @author gabrielcouto */ public enum GroupManagerPermissions { + manuadd, manudel, manuaddsub, diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java old mode 100644 new mode 100755 index 3ee6fdf30..88ac48427 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/PermissionCheckResult.java @@ -11,6 +11,7 @@ import org.anjocaido.groupmanager.data.DataUnit; * @author gabrielcouto */ public class PermissionCheckResult { + /** * It should be the owner of the access level found. * diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java old mode 100644 new mode 100755 index 2e192118d..ab2fd605b --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/StringPermissionComparator.java @@ -2,7 +2,6 @@ * To change this template, choose Tools | Templates * and open the template in the editor. */ - package org.anjocaido.groupmanager.utils; import java.util.Comparator; @@ -19,32 +18,32 @@ public class StringPermissionComparator implements Comparator { boolean bp = permB.startsWith("+"); boolean am = permA.startsWith("-"); boolean bm = permB.startsWith("-"); - if(ap&&bp){ + if (ap && bp) { return 0; } - if(ap&&!bp){ + if (ap && !bp) { return -1; } - if(!ap&&bp){ + if (!ap && bp) { return 1; } - if(am&&bm){ + if (am && bm) { return 0; } - if(am&&!bm){ + if (am && !bm) { return -1; } - if(!am&&bm){ + if (!am && bm) { return 1; } return permA.compareToIgnoreCase(permB); } private static StringPermissionComparator instance; - public static StringPermissionComparator getInstance(){ - if(instance==null){ + + public static StringPermissionComparator getInstance() { + if (instance == null) { instance = new StringPermissionComparator(); } return instance; } - } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java old mode 100644 new mode 100755 index 64bdb6209..579ee72a6 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/utils/Tasks.java @@ -10,7 +10,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; +import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; import org.anjocaido.groupmanager.data.Group; @@ -62,48 +62,51 @@ public abstract class Tasks { public static String getDateString() { GregorianCalendar now = new GregorianCalendar(); String date = ""; - date += now.get(GregorianCalendar.DAY_OF_MONTH); + date += now.get(Calendar.DAY_OF_MONTH); date += "-"; - date += now.get(GregorianCalendar.HOUR); + date += now.get(Calendar.HOUR); date += "-"; - date += now.get(GregorianCalendar.MINUTE); + date += now.get(Calendar.MINUTE); return date; } - public static String getStringListInString(List list){ - if(list==null){ + + public static String getStringListInString(List list) { + if (list == null) { return ""; } - String result=""; - for(int i=0;i list){ - if(list==null){ + + public static String getGroupListInString(List list) { + if (list == null) { return ""; } - String result=""; - for(int i=0;i Date: Mon, 29 Aug 2011 21:15:33 +0100 Subject: Test commit to see if push works Updated plugin.yml to alpha-6 for GM --- EssentialsGroupManager/src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index 86fb874af..0318f43f6 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,5 +1,5 @@ name: GroupManager -version: "1.0(alpha-5) [Zombie-Version, please switch to Permissions 3]" +version: "1.0(alpha-6)" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. -- cgit v1.2.3 From b140f606b41cbb30fd0acff3f9c6f416967d82c2 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 31 Aug 2011 01:56:31 +0100 Subject: added PermissionHandler.class and .project/.classpath so this will build in eclipse --- .classpath | 8 ++++++++ .project | 17 +++++++++++++++++ .../src/com/nijiko/permissions/PermissionHandler.class | Bin 0 -> 5289 bytes 3 files changed, 25 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..0683da590 --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..2c69e0560 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Essentials + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class b/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class new file mode 100644 index 000000000..d3022a484 Binary files /dev/null and b/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class differ -- cgit v1.2.3 From 1153a0eee4a3685fcfad490646e4610d38d61c01 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Fri, 2 Sep 2011 23:07:23 +0100 Subject: Bukkit Superperms support --- EssentialsGroupBridge/.classpath | 10 ++ EssentialsGroupBridge/.project | 17 ++ .../nijikokun/bukkit/Permissions/Permissions.java | 4 +- .../permissions/NijikoPermissionsProxy.java | 131 +++++++------- EssentialsGroupManager/.classpath | 7 + EssentialsGroupManager/.project | 17 ++ .../org/anjocaido/groupmanager/GroupManager.java | 14 +- .../src/org/anjocaido/groupmanager/data/Group.java | 9 +- .../src/org/anjocaido/groupmanager/data/User.java | 12 ++ .../permissions/BukkitPermissions.java | 195 +++++++++++++++++++++ 10 files changed, 344 insertions(+), 72 deletions(-) create mode 100644 EssentialsGroupBridge/.classpath create mode 100644 EssentialsGroupBridge/.project mode change 100755 => 100644 EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java mode change 100755 => 100644 EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java create mode 100644 EssentialsGroupManager/.classpath create mode 100644 EssentialsGroupManager/.project mode change 100755 => 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java mode change 100755 => 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java mode change 100755 => 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java create mode 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java diff --git a/EssentialsGroupBridge/.classpath b/EssentialsGroupBridge/.classpath new file mode 100644 index 000000000..a1bc47710 --- /dev/null +++ b/EssentialsGroupBridge/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/EssentialsGroupBridge/.project b/EssentialsGroupBridge/.project new file mode 100644 index 000000000..0780b7dbb --- /dev/null +++ b/EssentialsGroupBridge/.project @@ -0,0 +1,17 @@ + + + EssentialsGroupBridge + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java b/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java old mode 100755 new mode 100644 index c7a85fc71..5d027cccc --- a/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java +++ b/EssentialsGroupBridge/src/com/nijikokun/bukkit/Permissions/Permissions.java @@ -2,7 +2,7 @@ package com.nijikokun.bukkit.Permissions; import com.nijiko.permissions.PermissionHandler; import java.util.logging.Logger; -import org.anjocaido.groupmanager.GroupManager; +//import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.permissions.NijikoPermissionsProxy; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Type; @@ -63,7 +63,7 @@ public class Permissions extends JavaPlugin { } private void setGM(final Plugin p) { - GroupManager groupManager = (GroupManager) p; + //GroupManager groupManager = (GroupManager) p; ((NijikoPermissionsProxy) Security).setGM(p); } diff --git a/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java b/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java old mode 100755 new mode 100644 index bc9cde437..a41a51bc9 --- a/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java +++ b/EssentialsGroupBridge/src/org/anjocaido/groupmanager/permissions/NijikoPermissionsProxy.java @@ -47,12 +47,12 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public void addGroupInfo(String world, String group, String node, Object data) { - plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().addGroupInfo(group, node, data); + GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().addGroupInfo(group, node, data); } @Override public void removeGroupInfo(String world, String group, String node) { - plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().removeGroupInfo(group, node); + GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().removeGroupInfo(group, node); } @Override @@ -67,17 +67,17 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public void addUserInfo(String world, String user, String node, Object data) { - plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().addUserInfo(user, node, data); + GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().addUserInfo(user, node, data); } @Override public void removeUserInfo(String world, String user, String node) { - plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().removeUserInfo(user, node); + GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().removeUserInfo(user, node); } @Deprecated public void removeUserInfo(String user, String node) { - plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().removeUserInfo(user, node); + GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().removeUserInfo(user, node); } @Deprecated @@ -92,12 +92,12 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Deprecated public void addGroupInfo(String group, String node, Object data) { - plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().addGroupInfo(group, node, data); + GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().addGroupInfo(group, node, data); } @Deprecated public void removeGroupInfo(String group, String node) { - plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().removeGroupInfo(group, node); + GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().removeGroupInfo(group, node); } @Deprecated @@ -112,7 +112,7 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Deprecated public void addUserInfo(String user, String node, Object data) { - plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().addUserInfo(user, node, data); + GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().addUserInfo(user, node, data); } @Override @@ -147,13 +147,13 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public void reload() { - plugin.getWorldsHolder().reloadAll(); + GroupManager.getWorldsHolder().reloadAll(); //throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean reload(String world) { - plugin.getWorldsHolder().reloadWorld(world); + GroupManager.getWorldsHolder().reloadWorld(world); return true; } @@ -175,214 +175,214 @@ public class NijikoPermissionsProxy extends PermissionHandler { } if (player.getWorld() == null) { GroupManager.logger.warning("The player " + player.getName() + " has a null world? Treating as default world!"); - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().has(player, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().has(player, permission); } - return plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getPermissionsHandler().has(player, permission); + return GroupManager.getWorldsHolder().getWorldData(player.getWorld().getName()).getPermissionsHandler().has(player, permission); } @Override public String getGroupRawPrefix(String world, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPrefix(group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPrefix(group); } @Override public String getGroupRawSuffix(String world, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupSuffix(group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupSuffix(group); } @Override public String getUserPrefix(String world, String user) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPrefix(user); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPrefix(user); } @Override public String getUserSuffix(String world, String user) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserSuffix(user); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserSuffix(user); } @Override public String getGroup(String world, String user) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(user); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(user); } @Override public String getPrimaryGroup(String world, String user) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(user); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroup(user); } @Override public boolean canUserBuild(String world, String user) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().canUserBuild(user); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().canUserBuild(user); } @Deprecated public String getGroup(String name) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroup(name); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroup(name); } @Override public String[] getGroups(String world, String name) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroups(name); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroups(name); } @Override public boolean inGroup(String world, String name, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(name, group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(name, group); } @Deprecated public boolean inGroup(String name, String group) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().inGroup(name, group); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().inGroup(name, group); } @Override public String getGroupPrefix(String world, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPrefix(group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPrefix(group); } @Deprecated public String getGroupPrefix(String group) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPrefix(group); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPrefix(group); } @Override public String getGroupSuffix(String world, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupSuffix(group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupSuffix(group); } @Deprecated public String getGroupSuffix(String group) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupSuffix(group); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupSuffix(group); } @Override public boolean canGroupBuild(String world, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().canGroupBuild(group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().canGroupBuild(group); } @Deprecated public boolean canGroupBuild(String group) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().canGroupBuild(group); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().canGroupBuild(group); } @Override public String getGroupPermissionString(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionString(group, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionString(group, permission); } @Deprecated public String getGroupPermissionString(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionString(group, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionString(group, permission); } @Override public int getGroupPermissionInteger(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionInteger(group, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionInteger(group, permission); } @Deprecated public int getGroupPermissionInteger(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionInteger(group, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionInteger(group, permission); } @Override public boolean getGroupPermissionBoolean(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionBoolean(group, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionBoolean(group, permission); } @Deprecated public boolean getGroupPermissionBoolean(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionBoolean(group, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionBoolean(group, permission); } @Override public double getGroupPermissionDouble(String world, String group, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionDouble(group, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getGroupPermissionDouble(group, permission); } @Deprecated public double getGroupPermissionDouble(String group, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionDouble(group, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getGroupPermissionDouble(group, permission); } @Override public String getUserPermissionString(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionString(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionString(name, permission); } @Deprecated public String getUserPermissionString(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionString(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionString(name, permission); } @Override public int getUserPermissionInteger(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionInteger(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionInteger(name, permission); } @Deprecated public int getUserPermissionInteger(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionInteger(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionInteger(name, permission); } @Override public boolean getUserPermissionBoolean(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionBoolean(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionBoolean(name, permission); } @Deprecated public boolean getUserPermissionBoolean(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionBoolean(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionBoolean(name, permission); } @Override public double getUserPermissionDouble(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionDouble(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getUserPermissionDouble(name, permission); } @Deprecated public double getUserPermissionDouble(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionDouble(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getUserPermissionDouble(name, permission); } @Override public String getPermissionString(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionString(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionString(name, permission); } @Deprecated public String getPermissionString(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionString(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionString(name, permission); } @Override public int getPermissionInteger(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionInteger(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionInteger(name, permission); } @Deprecated public int getPermissionInteger(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionInteger(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionInteger(name, permission); } @Override public boolean getPermissionBoolean(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionBoolean(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionBoolean(name, permission); } @Deprecated public boolean getPermissionBoolean(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionBoolean(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionBoolean(name, permission); } @Override public double getPermissionDouble(String world, String name, String permission) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionDouble(name, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getPermissionDouble(name, permission); } @Deprecated public double getPermissionDouble(String name, String permission) { - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionDouble(name, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().getPermissionDouble(name, permission); } public void setGM(Plugin p) { @@ -391,7 +391,7 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public boolean canGroupRawBuild(String world, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().canGroupBuild(group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().canGroupBuild(group); } @Override @@ -432,7 +432,7 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public Boolean getInfoBoolean(String world, String entryName, String path, boolean isGroup) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoBoolean(entryName, path, isGroup); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoBoolean(entryName, path, isGroup); } @Override @@ -443,7 +443,7 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public Double getInfoDouble(String world, String entryName, String path, boolean isGroup) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoDouble(entryName, path, isGroup); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoDouble(entryName, path, isGroup); } @Override @@ -455,7 +455,7 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public Integer getInfoInteger(String world, String entryName, String path, boolean isGroup) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoInteger(entryName, path, isGroup); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoInteger(entryName, path, isGroup); } @Override @@ -466,7 +466,7 @@ public class NijikoPermissionsProxy extends PermissionHandler { @Override public String getInfoString(String world, String entryName, String path, boolean isGroup) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoString(entryName, path, isGroup); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().getInfoString(entryName, path, isGroup); } @Override @@ -530,14 +530,14 @@ public class NijikoPermissionsProxy extends PermissionHandler { } if (world == null) { GroupManager.logger.warning("The player " + playerName + " has a null world? Treating as default world!"); - return plugin.getWorldsHolder().getDefaultWorld().getPermissionsHandler().permission(playerName, permission); + return GroupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler().permission(playerName, permission); } - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().permission(playerName, permission); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().permission(playerName, permission); } @Override public boolean inGroup(String world, String user, String groupWorld, String group) { - return plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(user, group); + return GroupManager.getWorldsHolder().getWorldData(world).getPermissionsHandler().inGroup(user, group); } @Override @@ -580,8 +580,9 @@ public class NijikoPermissionsProxy extends PermissionHandler { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public Group getPrimaryGroupObject(String string, String string1) { - throw new UnsupportedOperationException("Not supported yet."); - } + //@Override + public Group getPrimaryGroupObject(String arg0, String arg1) { + throw new UnsupportedOperationException("Not supported yet."); + } + } diff --git a/EssentialsGroupManager/.classpath b/EssentialsGroupManager/.classpath new file mode 100644 index 000000000..eafae0c2b --- /dev/null +++ b/EssentialsGroupManager/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/EssentialsGroupManager/.project b/EssentialsGroupManager/.project new file mode 100644 index 000000000..6ad74b347 --- /dev/null +++ b/EssentialsGroupManager/.project @@ -0,0 +1,17 @@ + + + EssentialsGroupManager + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java old mode 100755 new mode 100644 index 7f6e0fb85..2e094558c --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -5,6 +5,7 @@ package org.anjocaido.groupmanager; import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler; +import org.anjocaido.groupmanager.permissions.BukkitPermissions; import org.anjocaido.groupmanager.utils.GroupManagerPermissions; import org.anjocaido.groupmanager.data.Variables; import org.anjocaido.groupmanager.data.User; @@ -45,15 +46,19 @@ public class GroupManager extends JavaPlugin { private ScheduledThreadPoolExecutor scheduler; private Map> overloadedUsers = new HashMap>(); private Map selectedWorlds = new HashMap(); - private WorldsHolder worldsHolder; + private static WorldsHolder worldsHolder; private boolean validateOnlinePlayer = true; private boolean isReady = false; + public static boolean isLoaded = false; private GMConfiguration config; private GMLoggerHandler ch; + public static BukkitPermissions BukkitPermissions; public static final Logger logger = Logger.getLogger(GroupManager.class.getName()); @Override public void onDisable() { + isLoaded = false; + if (worldsHolder != null) { worldsHolder.saveChanges(); } @@ -82,8 +87,11 @@ public class GroupManager extends JavaPlugin { this.getServer().getPluginManager().disablePlugin(this); throw new IllegalStateException("An error ocurred while loading GroupManager"); } + + BukkitPermissions = new BukkitPermissions(this); enableScheduler(); + isLoaded = true; System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!"); } @@ -110,7 +118,7 @@ public class GroupManager extends JavaPlugin { @Override public void run() { - GroupManager.this.worldsHolder.saveChanges(); + GroupManager.worldsHolder.saveChanges(); } }; scheduler = new ScheduledThreadPoolExecutor(1); @@ -153,7 +161,7 @@ public class GroupManager extends JavaPlugin { worldsHolder.reloadAll(); } - public WorldsHolder getWorldsHolder() { + public static WorldsHolder getWorldsHolder() { return worldsHolder; } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java old mode 100755 new mode 100644 index 4af5449fc..7523831e7 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/Group.java @@ -4,6 +4,7 @@ */ package org.anjocaido.groupmanager.data; +import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import java.util.ArrayList; import java.util.Map; @@ -52,7 +53,7 @@ public class Group extends DataUnit implements Cloneable { /** * Use this to deliver a group from a different dataSource to another * @param dataSource - * @return + * @return Null or Clone */ public Group clone(WorldDataHolder dataSource) { if (dataSource.groupExists(this.getName())) { @@ -79,7 +80,7 @@ public class Group extends DataUnit implements Cloneable { } /** - * @param inherits the inherits to set + * @param inherit the inherits to set */ public void addInherits(Group inherit) { if (!this.getDataSource().groupExists(inherit.getName())) { @@ -89,6 +90,8 @@ public class Group extends DataUnit implements Cloneable { inherits.add(inherit.getName().toLowerCase()); } flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); } public boolean removeInherits(String inherit) { @@ -118,5 +121,7 @@ public class Group extends DataUnit implements Cloneable { variables.addVar(key, temp.getVarObject(key)); } flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java old mode 100755 new mode 100644 index b90cf4ff1..f3ea1d0f5 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -6,6 +6,8 @@ package org.anjocaido.groupmanager.data; //import com.sun.org.apache.bcel.internal.generic.AALOAD; import java.util.ArrayList; + +import org.anjocaido.groupmanager.GroupManager; import org.anjocaido.groupmanager.dataholder.WorldDataHolder; import java.util.Map; @@ -102,6 +104,8 @@ public class User extends DataUnit implements Cloneable { public void setGroup(String group) { this.group = group; flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); } /** @@ -114,6 +118,8 @@ public class User extends DataUnit implements Cloneable { group = getDataSource().getGroup(group.getName()); this.group = group.getName(); flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); } public void addSubGroup(Group subGroup) { @@ -127,6 +133,8 @@ public class User extends DataUnit implements Cloneable { removeSubGroup(subGroup); subGroups.add(subGroup.getName()); flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); } public int subGroupsSize() { @@ -145,6 +153,8 @@ public class User extends DataUnit implements Cloneable { try { if (subGroups.remove(subGroup.getName())) { flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); return true; } } catch (Exception e) { @@ -187,5 +197,7 @@ public class User extends DataUnit implements Cloneable { variables.addVar(key, temp.getVarObject(key)); } flagAsChanged(); + if (GroupManager.isLoaded) + GroupManager.BukkitPermissions.updateAllPlayers(); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java new file mode 100644 index 000000000..e396118b4 --- /dev/null +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -0,0 +1,195 @@ +/* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +package org.anjocaido.groupmanager.permissions; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.anjocaido.groupmanager.GroupManager; +import org.anjocaido.groupmanager.data.User; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.server.PluginDisableEvent; +import org.bukkit.event.server.PluginEnableEvent; +import org.bukkit.event.server.ServerListener; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; + + +/** + * + * BukkitPermissions overrides to force GM reponses to Superperms + * + * @author ElgarL, based upon PermissionsEX implementation + */ +public class BukkitPermissions { + + protected Map attachments = new HashMap(); + protected Set registeredPermissions = new HashSet(); + protected Plugin plugin; + protected boolean dumpAllPermissions = true; + protected boolean dumpMatchedPermissions = true; + + public BukkitPermissions(Plugin plugin) { + this.plugin = plugin; + + this.collectPermissions(); + this.registerEvents(); + + this.updateAllPlayers(); + + GroupManager.logger.info("Superperms support enabled."); + } + + private void registerEvents() { + PluginManager manager = plugin.getServer().getPluginManager(); + + PlayerEvents playerEventListener = new PlayerEvents(); + + manager.registerEvent(Event.Type.PLAYER_JOIN, playerEventListener, Event.Priority.Normal, plugin); + manager.registerEvent(Event.Type.PLAYER_KICK, playerEventListener, Event.Priority.Normal, plugin); + manager.registerEvent(Event.Type.PLAYER_QUIT, playerEventListener, Event.Priority.Normal, plugin); + + manager.registerEvent(Event.Type.PLAYER_RESPAWN, playerEventListener, Event.Priority.Normal, plugin); + manager.registerEvent(Event.Type.PLAYER_TELEPORT, playerEventListener, Event.Priority.Normal, plugin); + manager.registerEvent(Event.Type.PLAYER_PORTAL, playerEventListener, Event.Priority.Normal, plugin); + + ServerListener serverListener = new BukkitEvents(); + + manager.registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Event.Priority.Normal, plugin); + manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin); + } + + private void collectPermissions() { + registeredPermissions.clear(); + for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) { + registeredPermissions.addAll(bukkitPlugin.getDescription().getPermissions()); + } + } + + public void updatePermissions(Player player){ + this.updatePermissions(player, null); + } + + public void updatePermissions(Player player, String world) { + if (player == null || !this.plugin.isEnabled()) { + return; + } + + if (!this.attachments.containsKey(player)) { + this.attachments.put(player, player.addAttachment(plugin)); + } + + if(world == null){ + world = player.getWorld().getName(); + } + + PermissionAttachment attachment = this.attachments.get(player); + + User user = GroupManager.getWorldsHolder().getWorldData(world).getUser(player.getName()); + + // clear permissions + for (String permission : attachment.getPermissions().keySet()) { + attachment.unsetPermission(permission); + } + + for (Permission permission : registeredPermissions) { + boolean permissionValue = user.getGroup().hasSamePermissionNode(permission.getName()); + + //GroupManager.logger.info(permission.getName() + " : " + Boolean.toString(permissionValue)); + + attachment.setPermission(permission, permissionValue); + } + + player.recalculatePermissions(); + + } + + public void updateAllPlayers() { + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + updatePermissions(player); + } + } + + protected class PlayerEvents extends PlayerListener { + + @Override + public void onPlayerJoin(PlayerJoinEvent event) { + updatePermissions(event.getPlayer()); + } + + @Override + public void onPlayerPortal(PlayerPortalEvent event) { // will portal into another world + if(event.getPlayer().getWorld().equals(event.getTo().getWorld())){ // only if world actually changed + return; + } + + updatePermissions(event.getPlayer(), event.getTo().getWorld().getName()); + } + + @Override + public void onPlayerRespawn(PlayerRespawnEvent event) { // can be respawned in another world + updatePermissions(event.getPlayer(), event.getRespawnLocation().getWorld().getName()); + } + + @Override + public void onPlayerTeleport(PlayerTeleportEvent event) { // can be teleported into another world + if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) { // only if world actually changed + updatePermissions(event.getPlayer(), event.getTo().getWorld().getName()); + } + } + + @Override + public void onPlayerQuit(PlayerQuitEvent event) { + attachments.remove(event.getPlayer()); + } + + @Override + public void onPlayerKick(PlayerKickEvent event) { + attachments.remove(event.getPlayer()); + } + } + + protected class BukkitEvents extends ServerListener { + + @Override + public void onPluginEnable(PluginEnableEvent event) { + collectPermissions(); + updateAllPlayers(); + } + + @Override + public void onPluginDisable(PluginDisableEvent event) { + collectPermissions(); + updateAllPlayers(); + } + } + +} \ No newline at end of file -- cgit v1.2.3 From a220b267d4a443788ed40d2f5619213399e35a6f Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 11:33:14 +0100 Subject: - Fixed users being able to use 'manuadd' to add users to higher groups than their own. - Added SuperPerms support so GM will update adn provide the permissions to plugins which only support Bukkit Perms. - Added more helpful output to errors on argument lengths. --- EssentialsGroupManager/src/Changelog.txt | 6 ++ .../org/anjocaido/groupmanager/GroupManager.java | 79 ++++++++++++++-------- EssentialsGroupManager/src/plugin.yml | 2 +- 3 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 EssentialsGroupManager/src/Changelog.txt diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt new file mode 100644 index 000000000..716242e3b --- /dev/null +++ b/EssentialsGroupManager/src/Changelog.txt @@ -0,0 +1,6 @@ +Changelog + +v 1.1: + - Fixed users being able to use 'manuadd' to add users to higher groups than their own. + - Added SuperPerms support so GM will update adn provide the permissions to plugins which only support Bukkit Perms. + - Added more helpful output to errors on argument lengths. \ 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 2e094558c..71a379976 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -291,7 +291,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -311,11 +311,29 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "Group not found!"); return false; } + //VALIDANDO PERMISSAO if (!isConsole && !senderPlayer.isOp() && (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()))) { + 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()))) { + 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()))) { + 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()))) { + sender.sendMessage(ChatColor.RED + "The new group must be a higher rank."); + return false; + } + //PARECE OK auxUser.setGroup(auxGroup); sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'."); @@ -331,7 +349,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -365,7 +383,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -403,8 +421,8 @@ public class GroupManager extends JavaPlugin { return true; } //VALIDANDO ARGUMENTOS - if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + if (args.length != 2) { + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manudelsub )"); return false; } if (validateOnlinePlayer) { @@ -438,7 +456,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -460,7 +478,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -482,7 +500,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -547,7 +565,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -599,7 +617,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -654,7 +672,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -702,7 +720,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -756,6 +774,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -795,7 +814,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -844,7 +863,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -879,7 +898,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -911,7 +930,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -947,7 +966,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length < 3) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -983,7 +1002,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1015,7 +1034,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1053,7 +1072,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1096,7 +1115,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length < 3) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -1126,7 +1145,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -1152,7 +1171,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -1190,7 +1209,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } auxGroup = dataHolder.getGroup(args[0]); @@ -1218,7 +1237,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1253,7 +1272,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1292,7 +1311,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1449,7 +1468,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1505,7 +1524,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ARGUMENTOS if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); return false; } if (validateOnlinePlayer) { @@ -1585,7 +1604,7 @@ public class GroupManager extends JavaPlugin { return true; case manselect: if (args.length < 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count!"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/ )"); sender.sendMessage(ChatColor.YELLOW + "Worlds available: "); ArrayList worlds = worldsHolder.allWorldsDataList(); auxString = ""; diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index 0318f43f6..ace9701cd 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,5 +1,5 @@ name: GroupManager -version: "1.0(alpha-6)" +version: "1.1" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. -- cgit v1.2.3 From 16e19a77759585118e97f3f1d4ca7bc7041e800f Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 3 Sep 2011 14:24:32 +0100 Subject: - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect '. --- EssentialsGroupManager/src/Changelog.txt | 5 +- .../org/anjocaido/groupmanager/GroupManager.java | 192 ++++++++++----------- 2 files changed, 96 insertions(+), 101 deletions(-) diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 716242e3b..86f6e521f 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -2,5 +2,6 @@ Changelog v 1.1: - Fixed users being able to use 'manuadd' to add users to higher groups than their own. - - Added SuperPerms support so GM will update adn provide the permissions to plugins which only support Bukkit Perms. - - Added more helpful output to errors on argument lengths. \ No newline at end of file + - Added SuperPerms support so GM will update and provide the permissions to plugins which only support Bukkit Perms. + - Added more helpful output to errors on argument lengths. + - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect '. \ 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 71a379976..7663e0930 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -285,9 +285,8 @@ public class GroupManager extends JavaPlugin { case manuadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -343,9 +342,8 @@ public class GroupManager extends JavaPlugin { case manudel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -377,9 +375,11 @@ public class GroupManager extends JavaPlugin { case manuaddsub: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) { + sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); + sender.sendMessage(ChatColor.RED + "Use /manselect "); + return true; + } } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -416,9 +416,8 @@ public class GroupManager extends JavaPlugin { case manudelsub: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -450,9 +449,8 @@ public class GroupManager extends JavaPlugin { case mangadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -472,9 +470,8 @@ public class GroupManager extends JavaPlugin { case mangdel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -494,9 +491,8 @@ public class GroupManager extends JavaPlugin { case manuaddp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -559,9 +555,8 @@ public class GroupManager extends JavaPlugin { case manudelp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -611,9 +606,8 @@ public class GroupManager extends JavaPlugin { case manulistp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -666,9 +660,8 @@ public class GroupManager extends JavaPlugin { case manucheckp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -714,9 +707,8 @@ public class GroupManager extends JavaPlugin { case mangaddp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -768,9 +760,8 @@ public class GroupManager extends JavaPlugin { case mangdelp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -808,9 +799,8 @@ public class GroupManager extends JavaPlugin { case manglistp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -857,9 +847,8 @@ public class GroupManager extends JavaPlugin { case mangcheckp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -892,9 +881,8 @@ public class GroupManager extends JavaPlugin { case mangaddi: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -924,9 +912,8 @@ public class GroupManager extends JavaPlugin { case mangdeli: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -960,9 +947,8 @@ public class GroupManager extends JavaPlugin { case manuaddv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length < 3) { @@ -996,9 +982,8 @@ public class GroupManager extends JavaPlugin { case manudelv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -1028,9 +1013,8 @@ public class GroupManager extends JavaPlugin { case manulistv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -1066,9 +1050,8 @@ public class GroupManager extends JavaPlugin { case manucheckv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -1109,9 +1092,8 @@ public class GroupManager extends JavaPlugin { case mangaddv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length < 3) { @@ -1139,9 +1121,8 @@ public class GroupManager extends JavaPlugin { case mangdelv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -1165,9 +1146,8 @@ public class GroupManager extends JavaPlugin { case manglistv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -1203,9 +1183,8 @@ public class GroupManager extends JavaPlugin { case mangcheckv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -1231,9 +1210,8 @@ public class GroupManager extends JavaPlugin { case manwhois: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -1266,9 +1244,8 @@ public class GroupManager extends JavaPlugin { case tempadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -1305,9 +1282,8 @@ public class GroupManager extends JavaPlugin { case tempdel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 1) { @@ -1346,9 +1322,8 @@ public class GroupManager extends JavaPlugin { case templist: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //WORKING auxString = ""; @@ -1376,9 +1351,8 @@ public class GroupManager extends JavaPlugin { case tempdelall: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //WORKING removeList = new ArrayList(); @@ -1420,9 +1394,8 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //WORKING config.load(); @@ -1445,9 +1418,8 @@ public class GroupManager extends JavaPlugin { case listgroups: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //WORKING auxString = ""; @@ -1462,9 +1434,8 @@ public class GroupManager extends JavaPlugin { case manpromote: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -1518,9 +1489,8 @@ public class GroupManager extends JavaPlugin { case mandemote: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); - sender.sendMessage(ChatColor.RED + "Use /manselect "); - return true; + if (!seDefaulttWorldHandler(sender)) + return true; } //VALIDANDO ARGUMENTOS if (args.length != 2) { @@ -1648,6 +1618,30 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "You are not allowed to use that command."); return false; } + + /** + * Sets up the default world for use. + */ + private boolean seDefaulttWorldHandler(CommandSender sender) { + + //PERMISSIONS FOR COMMAND BEING LOADED + OverloadedWorldHolder dataHolder = null; + AnjoPermissionsHandler permissionHandler = null; + + dataHolder = worldsHolder.getWorldData(worldsHolder.getDefaultWorld().getName()); + permissionHandler = dataHolder.getPermissionsHandler(); + selectedWorlds.put(sender, dataHolder.getName()); + + if ((dataHolder != null) && (permissionHandler != null)) { + sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. Default world '" + worldsHolder.getDefaultWorld().getName() + "' selected."); + return true; + } + + sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); + sender.sendMessage(ChatColor.RED + "Use /manselect "); + return false; + + } /** * @return the config -- cgit v1.2.3 From f67e13122dad5710f0ea381c1dbbb2b4b89f2aca Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 14:33:47 +0100 Subject: correct typo on setDefaulttWorldHandler --- .../org/anjocaido/groupmanager/GroupManager.java | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 7663e0930..0412e4181 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -285,7 +285,7 @@ public class GroupManager extends JavaPlugin { case manuadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -342,7 +342,7 @@ public class GroupManager extends JavaPlugin { case manudel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -375,7 +375,7 @@ public class GroupManager extends JavaPlugin { case manuaddsub: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) { + if (!setDefaulttWorldHandler(sender)) { sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); sender.sendMessage(ChatColor.RED + "Use /manselect "); return true; @@ -416,7 +416,7 @@ public class GroupManager extends JavaPlugin { case manudelsub: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -449,7 +449,7 @@ public class GroupManager extends JavaPlugin { case mangadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -470,7 +470,7 @@ public class GroupManager extends JavaPlugin { case mangdel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -491,7 +491,7 @@ public class GroupManager extends JavaPlugin { case manuaddp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -555,7 +555,7 @@ public class GroupManager extends JavaPlugin { case manudelp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -606,7 +606,7 @@ public class GroupManager extends JavaPlugin { case manulistp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -660,7 +660,7 @@ public class GroupManager extends JavaPlugin { case manucheckp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -707,7 +707,7 @@ public class GroupManager extends JavaPlugin { case mangaddp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -760,7 +760,7 @@ public class GroupManager extends JavaPlugin { case mangdelp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -799,7 +799,7 @@ public class GroupManager extends JavaPlugin { case manglistp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -847,7 +847,7 @@ public class GroupManager extends JavaPlugin { case mangcheckp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -881,7 +881,7 @@ public class GroupManager extends JavaPlugin { case mangaddi: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -912,7 +912,7 @@ public class GroupManager extends JavaPlugin { case mangdeli: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -947,7 +947,7 @@ public class GroupManager extends JavaPlugin { case manuaddv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -982,7 +982,7 @@ public class GroupManager extends JavaPlugin { case manudelv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1013,7 +1013,7 @@ public class GroupManager extends JavaPlugin { case manulistv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1050,7 +1050,7 @@ public class GroupManager extends JavaPlugin { case manucheckv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1092,7 +1092,7 @@ public class GroupManager extends JavaPlugin { case mangaddv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1121,7 +1121,7 @@ public class GroupManager extends JavaPlugin { case mangdelv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1146,7 +1146,7 @@ public class GroupManager extends JavaPlugin { case manglistv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1183,7 +1183,7 @@ public class GroupManager extends JavaPlugin { case mangcheckv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1210,7 +1210,7 @@ public class GroupManager extends JavaPlugin { case manwhois: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1244,7 +1244,7 @@ public class GroupManager extends JavaPlugin { case tempadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1282,7 +1282,7 @@ public class GroupManager extends JavaPlugin { case tempdel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1322,7 +1322,7 @@ public class GroupManager extends JavaPlugin { case templist: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //WORKING @@ -1351,7 +1351,7 @@ public class GroupManager extends JavaPlugin { case tempdelall: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //WORKING @@ -1394,7 +1394,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //WORKING @@ -1418,7 +1418,7 @@ public class GroupManager extends JavaPlugin { case listgroups: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //WORKING @@ -1434,7 +1434,7 @@ public class GroupManager extends JavaPlugin { case manpromote: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1489,7 +1489,7 @@ public class GroupManager extends JavaPlugin { case mandemote: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!seDefaulttWorldHandler(sender)) + if (!setDefaulttWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1622,7 +1622,7 @@ public class GroupManager extends JavaPlugin { /** * Sets up the default world for use. */ - private boolean seDefaulttWorldHandler(CommandSender sender) { + private boolean setDefaulttWorldHandler(CommandSender sender) { //PERMISSIONS FOR COMMAND BEING LOADED OverloadedWorldHolder dataHolder = null; -- cgit v1.2.3 From 80491513a2ba82889d95dd246bfd0482a519e276 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 14:39:10 +0100 Subject: Damn typos --- .../org/anjocaido/groupmanager/GroupManager.java | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 0412e4181..f7e797f36 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -285,7 +285,7 @@ public class GroupManager extends JavaPlugin { case manuadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -342,7 +342,7 @@ public class GroupManager extends JavaPlugin { case manudel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -375,7 +375,7 @@ public class GroupManager extends JavaPlugin { case manuaddsub: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) { + if (!setDefaultWorldHandler(sender)) { sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. World selection is needed."); sender.sendMessage(ChatColor.RED + "Use /manselect "); return true; @@ -416,7 +416,7 @@ public class GroupManager extends JavaPlugin { case manudelsub: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -449,7 +449,7 @@ public class GroupManager extends JavaPlugin { case mangadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -470,7 +470,7 @@ public class GroupManager extends JavaPlugin { case mangdel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -491,7 +491,7 @@ public class GroupManager extends JavaPlugin { case manuaddp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -555,7 +555,7 @@ public class GroupManager extends JavaPlugin { case manudelp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -606,7 +606,7 @@ public class GroupManager extends JavaPlugin { case manulistp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -660,7 +660,7 @@ public class GroupManager extends JavaPlugin { case manucheckp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -707,7 +707,7 @@ public class GroupManager extends JavaPlugin { case mangaddp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -760,7 +760,7 @@ public class GroupManager extends JavaPlugin { case mangdelp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -799,7 +799,7 @@ public class GroupManager extends JavaPlugin { case manglistp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -847,7 +847,7 @@ public class GroupManager extends JavaPlugin { case mangcheckp: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -881,7 +881,7 @@ public class GroupManager extends JavaPlugin { case mangaddi: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -912,7 +912,7 @@ public class GroupManager extends JavaPlugin { case mangdeli: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -947,7 +947,7 @@ public class GroupManager extends JavaPlugin { case manuaddv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -982,7 +982,7 @@ public class GroupManager extends JavaPlugin { case manudelv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1013,7 +1013,7 @@ public class GroupManager extends JavaPlugin { case manulistv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1050,7 +1050,7 @@ public class GroupManager extends JavaPlugin { case manucheckv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1092,7 +1092,7 @@ public class GroupManager extends JavaPlugin { case mangaddv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1121,7 +1121,7 @@ public class GroupManager extends JavaPlugin { case mangdelv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1146,7 +1146,7 @@ public class GroupManager extends JavaPlugin { case manglistv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1183,7 +1183,7 @@ public class GroupManager extends JavaPlugin { case mangcheckv: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1210,7 +1210,7 @@ public class GroupManager extends JavaPlugin { case manwhois: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1244,7 +1244,7 @@ public class GroupManager extends JavaPlugin { case tempadd: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1282,7 +1282,7 @@ public class GroupManager extends JavaPlugin { case tempdel: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1322,7 +1322,7 @@ public class GroupManager extends JavaPlugin { case templist: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //WORKING @@ -1351,7 +1351,7 @@ public class GroupManager extends JavaPlugin { case tempdelall: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //WORKING @@ -1394,7 +1394,7 @@ public class GroupManager extends JavaPlugin { } //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //WORKING @@ -1418,7 +1418,7 @@ public class GroupManager extends JavaPlugin { case listgroups: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //WORKING @@ -1434,7 +1434,7 @@ public class GroupManager extends JavaPlugin { case manpromote: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1489,7 +1489,7 @@ public class GroupManager extends JavaPlugin { case mandemote: //VALIDANDO ESTADO DO SENDER if (dataHolder == null || permissionHandler == null) { - if (!setDefaulttWorldHandler(sender)) + if (!setDefaultWorldHandler(sender)) return true; } //VALIDANDO ARGUMENTOS @@ -1622,7 +1622,7 @@ public class GroupManager extends JavaPlugin { /** * Sets up the default world for use. */ - private boolean setDefaulttWorldHandler(CommandSender sender) { + private boolean setDefaultWorldHandler(CommandSender sender) { //PERMISSIONS FOR COMMAND BEING LOADED OverloadedWorldHolder dataHolder = null; -- cgit v1.2.3 From e2024ca2b63112cbb343812e4d4354c98245e03b Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 15:29:44 +0100 Subject: - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. --- EssentialsGroupManager/src/Changelog.txt | 3 ++- .../src/org/anjocaido/groupmanager/GroupManager.java | 12 ++++++------ .../anjocaido/groupmanager/dataholder/WorldDataHolder.java | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) mode change 100755 => 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 86f6e521f..401d762f1 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -4,4 +4,5 @@ v 1.1: - Fixed users being able to use 'manuadd' to add users to higher groups than their own. - Added SuperPerms support so GM will update and provide the permissions to plugins which only support Bukkit Perms. - Added more helpful output to errors on argument lengths. - - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect '. \ No newline at end of file + - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect '. + - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. \ 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 f7e797f36..e0a29f509 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -54,6 +54,10 @@ public class GroupManager extends JavaPlugin { private GMLoggerHandler ch; public static BukkitPermissions BukkitPermissions; public static final Logger logger = Logger.getLogger(GroupManager.class.getName()); + + //PERMISSIONS FOR COMMAND BEING LOADED + OverloadedWorldHolder dataHolder = null; + AnjoPermissionsHandler permissionHandler = null; @Override public void onDisable() { @@ -222,8 +226,8 @@ public class GroupManager extends JavaPlugin { } //PERMISSIONS FOR COMMAND BEING LOADED - OverloadedWorldHolder dataHolder = null; - AnjoPermissionsHandler permissionHandler = null; + dataHolder = null; + permissionHandler = null; if (senderPlayer != null) { dataHolder = worldsHolder.getWorldData(senderPlayer); @@ -1623,10 +1627,6 @@ public class GroupManager extends JavaPlugin { * Sets up the default world for use. */ private boolean setDefaultWorldHandler(CommandSender sender) { - - //PERMISSIONS FOR COMMAND BEING LOADED - OverloadedWorldHolder dataHolder = null; - AnjoPermissionsHandler permissionHandler = null; dataHolder = worldsHolder.getWorldData(worldsHolder.getDefaultWorld().getName()); permissionHandler = dataHolder.getPermissionsHandler(); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java old mode 100755 new mode 100644 index 1331a92ad..ae68e03cc --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -630,7 +630,9 @@ public class WorldDataHolder { if (thisUserNode.get("group") != null) { Group hisGroup = ph.getGroup(thisUserNode.get("group").toString()); if (hisGroup == null) { - throw new IllegalArgumentException("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName()); + GroupManager.logger.warning("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName() + ": Set to '" + ph.getDefaultGroup().getName() + "'."); + hisGroup = ph.defaultGroup; + //throw new IllegalArgumentException("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName()); } thisUser.setGroup(hisGroup); } else { -- cgit v1.2.3 From 8f28073b29a99c46ed3782784cc928c54addcb26 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 15:41:23 +0100 Subject: Minor change to GM's config.yml to make it slightly easier to understand mirroring --- EssentialsGroupManager/src/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml index 68308cca2..688d3f3ea 100644 --- a/EssentialsGroupManager/src/config.yml +++ b/EssentialsGroupManager/src/config.yml @@ -7,7 +7,8 @@ settings: permission: world: mirror: - world1: + world: + - world_nether - world2 - world3 world4: -- cgit v1.2.3 From e3756623a1531241b40084c0aa9a8e4b4e8cda31 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 16:13:43 +0100 Subject: - Fix for Users.yml containing only 'users:' causing a crash. - GroupManager will now generate a fresh Users and Groups yml if either file is empty. --- EssentialsGroupManager/src/Changelog.txt | 4 +++- .../src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java | 5 +++++ .../org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java | 4 ++-- EssentialsGroupManager/src/plugin.yml | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) mode change 100755 => 100644 EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 401d762f1..2879a9d33 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -5,4 +5,6 @@ v 1.1: - Added SuperPerms support so GM will update and provide the permissions to plugins which only support Bukkit Perms. - Added more helpful output to errors on argument lengths. - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect '. - - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. \ No newline at end of file + - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. + - Fix for Users.yml containing only 'users:' causing a crash. + - GroupManager will now generate a fresh Users and Groups yml if either file is empty. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index ae68e03cc..77d933fa0 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -578,6 +578,11 @@ public class WorldDataHolder { // PROCESS USERS FILE Map allUsersNode = (Map) usersRootDataNode.get("users"); + + // Stop loading if the file is empty + if (allUsersNode == null) + return ph; + for (String usersKey : allUsersNode.keySet()) { Map thisUserNode = (Map) allUsersNode.get(usersKey); User thisUser = ph.createUser(usersKey); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java old mode 100755 new mode 100644 index b4d50b431..a2c34be16 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java @@ -265,7 +265,7 @@ public class WorldsHolder { File groupsFile = new File(defaultWorldFolder, "groups.yml"); File usersFile = new File(defaultWorldFolder, "users.yml"); File oldDataFile = new File(plugin.getDataFolder(), "data.yml"); - if (!groupsFile.exists()) { + if (!groupsFile.exists() || groupsFile.length() == 0) { if (oldDataFile.exists()) { try { Tasks.copy(oldDataFile, groupsFile); @@ -281,7 +281,7 @@ public class WorldsHolder { } } } - if (!usersFile.exists()) { + if (!usersFile.exists() || usersFile.length() == 0) { if (oldDataFile.exists()) { try { Tasks.copy(oldDataFile, usersFile); diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index ace9701cd..6863df1de 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,5 +1,5 @@ name: GroupManager -version: "1.1" +version: "1.1 (Phoenix)" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. -- cgit v1.2.3 From 2e1c88050222c0be59a290a0b796677483daf066 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sat, 3 Sep 2011 17:53:34 +0100 Subject: - Fix for an infinite loop bug with the new Bukkit Perms during a new user creation. --- EssentialsGroupManager/src/Changelog.txt | 3 ++- .../src/org/anjocaido/groupmanager/data/User.java | 10 +++++----- .../anjocaido/groupmanager/permissions/BukkitPermissions.java | 10 +++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 2879a9d33..7005c8cc1 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -7,4 +7,5 @@ v 1.1: - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect '. - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. - Fix for Users.yml containing only 'users:' causing a crash. - - GroupManager will now generate a fresh Users and Groups yml if either file is empty. \ No newline at end of file + - GroupManager will now generate a fresh Users and Groups yml if either file is empty. + - Fix for an infinite loop bug with the new Bukkit Perms during a new user creation. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index f3ea1d0f5..e9bf79aa9 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -104,7 +104,7 @@ public class User extends DataUnit implements Cloneable { public void setGroup(String group) { this.group = group; flagAsChanged(); - if (GroupManager.isLoaded) + if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false)) GroupManager.BukkitPermissions.updateAllPlayers(); } @@ -118,7 +118,7 @@ public class User extends DataUnit implements Cloneable { group = getDataSource().getGroup(group.getName()); this.group = group.getName(); flagAsChanged(); - if (GroupManager.isLoaded) + if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false)) GroupManager.BukkitPermissions.updateAllPlayers(); } @@ -133,7 +133,7 @@ public class User extends DataUnit implements Cloneable { removeSubGroup(subGroup); subGroups.add(subGroup.getName()); flagAsChanged(); - if (GroupManager.isLoaded) + if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false)) GroupManager.BukkitPermissions.updateAllPlayers(); } @@ -153,7 +153,7 @@ public class User extends DataUnit implements Cloneable { try { if (subGroups.remove(subGroup.getName())) { flagAsChanged(); - if (GroupManager.isLoaded) + if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false)) GroupManager.BukkitPermissions.updateAllPlayers(); return true; } @@ -197,7 +197,7 @@ public class User extends DataUnit implements Cloneable { variables.addVar(key, temp.getVarObject(key)); } flagAsChanged(); - if (GroupManager.isLoaded) + if ((GroupManager.isLoaded) && (GroupManager.BukkitPermissions.player_join = false)) GroupManager.BukkitPermissions.updateAllPlayers(); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index e396118b4..5df263eb4 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -56,6 +56,7 @@ public class BukkitPermissions { protected Plugin plugin; protected boolean dumpAllPermissions = true; protected boolean dumpMatchedPermissions = true; + public boolean player_join = false; public BukkitPermissions(Plugin plugin) { this.plugin = plugin; @@ -142,7 +143,14 @@ public class BukkitPermissions { @Override public void onPlayerJoin(PlayerJoinEvent event) { - updatePermissions(event.getPlayer()); + player_join = true; + Player player = event.getPlayer(); + //force GM to create the player if they are not already listed. + if (GroupManager.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(player.getName()) != null) { + player_join = false; + updatePermissions(event.getPlayer()); + } else + player_join = false; } @Override -- cgit v1.2.3 From aa085de3e78fe09452f815aa92f6c06783fa06bd Mon Sep 17 00:00:00 2001 From: ElgarL Date: Sun, 4 Sep 2011 02:09:11 +0100 Subject: Push to Build dev version --- EssentialsGroupManager/src/users.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml index c3324f0c0..43d030e9a 100644 --- a/EssentialsGroupManager/src/users.yml +++ b/EssentialsGroupManager/src/users.yml @@ -1,6 +1,6 @@ # "For a more advanced configuration example utilizing the advanced features of GroupManager, see http://pastebin.com/a8ZA0j5G" users: - kimkandor: + snowleo: subgroups: [] permissions: [] group: Admin @@ -8,7 +8,7 @@ users: subgroups: [] permissions: [] group: Builder - zenexer: + ElgarL: subgroups: [] permissions: [] group: Admin -- cgit v1.2.3 From 0654a76ccc64b62549ef8f9389b145a2e9a602a4 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 6 Sep 2011 10:11:21 +0100 Subject: - Fixed BukkitPerms population. Wasn't correctly setting superperms. --- EssentialsGroupManager/src/Changelog.txt | 4 ++- .../permissions/BukkitPermissions.java | 40 ++++++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 7005c8cc1..56f52a998 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -8,4 +8,6 @@ v 1.1: - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. - Fix for Users.yml containing only 'users:' causing a crash. - GroupManager will now generate a fresh Users and Groups yml if either file is empty. - - Fix for an infinite loop bug with the new Bukkit Perms during a new user creation. \ No newline at end of file + - Fix for an infinite loop bug with the new Bukkit Perms during a new user creation. +v 1.2: + - Fixed BukkitPerms population. Wasn't correctly setting superperms. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 5df263eb4..383020a7c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -16,8 +16,10 @@ package org.anjocaido.groupmanager.permissions; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -39,6 +41,7 @@ import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; @@ -115,22 +118,45 @@ public class BukkitPermissions { PermissionAttachment attachment = this.attachments.get(player); User user = GroupManager.getWorldsHolder().getWorldData(world).getUser(player.getName()); - + List permissions = user.getPermissionList(); + // clear permissions for (String permission : attachment.getPermissions().keySet()) { attachment.unsetPermission(permission); - } - + } + + // find matching permissions for (Permission permission : registeredPermissions) { boolean permissionValue = user.getGroup().hasSamePermissionNode(permission.getName()); - - //GroupManager.logger.info(permission.getName() + " : " + Boolean.toString(permissionValue)); - attachment.setPermission(permission, permissionValue); - } + } + + // all permissions + for (String permission : permissions) { + Boolean value = true; + if (permission.startsWith("-")) { + permission = permission.substring(1); // cut off - + value = false; + } + if (!attachment.getPermissions().containsKey(permission)) { + attachment.setPermission(permission, value); + } + } + player.recalculatePermissions(); + /* + // List perms for this player + GroupManager.logger.info("Attachment Permissions:"); + for(Map.Entry entry : attachment.getPermissions().entrySet()){ + GroupManager.logger.info(" " + entry.getKey() + " = " + entry.getValue()); + } + GroupManager.logger.info("Effective Permissions:"); + for(PermissionAttachmentInfo info : player.getEffectivePermissions()){ + GroupManager.logger.info(" " + info.getPermission() + " = " + info.getValue()); + } + */ } public void updateAllPlayers() { -- cgit v1.2.3 From ab530f35d0ece2f9ceb5bd532e658d29210229c4 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 6 Sep 2011 10:12:15 +0100 Subject: removed unneeded include --- .../src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java | 1 - EssentialsGroupManager/src/plugin.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 383020a7c..9dac878ef 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -41,7 +41,6 @@ import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index 6863df1de..3beae0125 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,5 +1,5 @@ name: GroupManager -version: "1.1 (Phoenix)" +version: "1.2 (Phoenix)" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. -- cgit v1.2.3 From b110ce79cc33cddb5e30423a6ae960a9f13062c1 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 6 Sep 2011 10:13:32 +0100 Subject: Final tidy up of superperms for GM 1.2 --- .../src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java | 1 - 1 file changed, 1 deletion(-) diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 9dac878ef..9e500b123 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -16,7 +16,6 @@ package org.anjocaido.groupmanager.permissions; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -- cgit v1.2.3 From bbab993ef1b06394bf835da0b01402bcb70cecfc Mon Sep 17 00:00:00 2001 From: ElgarL Date: Tue, 6 Sep 2011 10:19:11 +0100 Subject: Doh, jumped a version --- EssentialsGroupManager/src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index 3beae0125..6863df1de 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -1,5 +1,5 @@ name: GroupManager -version: "1.2 (Phoenix)" +version: "1.1 (Phoenix)" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. -- cgit v1.2.3 From 63986265591eeddc72c4df3139afffc19eadbb9b Mon Sep 17 00:00:00 2001 From: KHobbits Date: Thu, 15 Sep 2011 07:08:05 +0200 Subject: Quickfix: Slightly changing syntax to stop conflict - This needs to be properly addressed --- EssentialsGroupManager/src/plugin.yml | 116 +++++++++++++++++----------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml index 6863df1de..91f8df05c 100644 --- a/EssentialsGroupManager/src/plugin.yml +++ b/EssentialsGroupManager/src/plugin.yml @@ -2,7 +2,7 @@ name: GroupManager version: "1.1 (Phoenix)" main: org.anjocaido.groupmanager.GroupManager website: http://www.anjocaido.info/ -description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. +description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule. authors: - AnjoCaido - Gabriel Couto @@ -10,156 +10,156 @@ commands: manuadd: description: Move a player to desired group.(Adds to the file if not exists) usage: / - permission: groupmanager.manuadd + permissions: groupmanager.manuadd manudel: description: Remove any user specific configuration. Make him default group. usage: / - permission: groupmanager.manudel + permissions: groupmanager.manudel manuaddsub: description: Add a group to a player's subgroup list. usage: / - permission: groupmanager.manuaddsub + permissions: groupmanager.manuaddsub manudelsub: description: Remove a group to a player's subgroup list. usage: / - permission: groupmanager.manudelsub + permissions: groupmanager.manudelsub mangadd: description: Add group to the system. usage: / - permission: groupmanager.mangadd + permissions: groupmanager.mangadd mangdel: description: Removes group from the system(all it's users become default) usage: / - permission: groupmanager.mangdel + permissions: groupmanager.mangdel manuaddp: - description: Add permission diretly to the player. - usage: / - permission: groupmanager.manuaddp + description: Add permissions diretly to the player. + usage: / + permissions: groupmanager.manuaddp manudelp: - description: Removes permission diretly from the player. - usage: / - permission: groupmanager.manudelp + description: Removes permissions diretly from the player. + usage: / + permissions: groupmanager.manudelp manulistp: - description: List all permissions from a player. + description: List all permissionss from a player. usage: / - permission: groupmanager.manulistp + permissions: groupmanager.manulistp manucheckp: - description: Verify if user has a permission, and where it comes from. - usage: / - permission: groupmanager.manucheckp + description: Verify if user has a permissions, and where it comes from. + usage: / + permissions: groupmanager.manucheckp mangaddp: - description: Add permission to a group. - usage: / - permission: groupmanager.mangaddp + description: Add permissions to a group. + usage: / + permissions: groupmanager.mangaddp mangdelp: - description: Removes permission from a group. - usage: / - permission: groupmanager.mangdelp + description: Removes permissions from a group. + usage: / + permissions: groupmanager.mangdelp manglistp: - description: Lists all permissions from a group. + description: Lists all permissionss from a group. usage: / - permission: groupmanager.manglistp + permissions: groupmanager.manglistp mangcheckp: - description: Check if group has a permission, and where it comes from. - usage: / - permission: groupmanager.mangcheckp + description: Check if group has a permissions, and where it comes from. + usage: / + permissions: groupmanager.mangcheckp mangaddi: description: Add a group to another group inheritance list. usage: / - permission: groupmanager.mangaddi + permissions: groupmanager.mangaddi mangdeli: description: Remove a group from another group inheritance list. usage: / - permission: groupmanager.mangdeli + permissions: groupmanager.mangdeli manuaddv: description: Add, or replaces, a variable to a user (like prefix or suffix). usage: / - permission: groupmanager.manuaddv + permissions: groupmanager.manuaddv manudelv: description: Remove a variable from a user. usage: / - permission: groupmanager.manudelv + permissions: groupmanager.manudelv manulistv: description: List variables a user has (like prefix or suffix). usage: / - permission: groupmanager.manulistv + permissions: groupmanager.manulistv manucheckv: description: Verify a value of a variable of user, and where it comes from. usage: / - permission: groupmanager.manucheckv + permissions: groupmanager.manucheckv mangaddv: description: Add, or replaces, a variable to a group (like prefix or suffix). usage: / - permission: groupmanager.mangaddv + permissions: groupmanager.mangaddv mangdelv: description: Remove a variable from a group. usage: / - permission: groupmanager.mangdelv + permissions: groupmanager.mangdelv manglistv: description: List variables a group has (like prefix or suffix). usage: / - permission: groupmanager.manglistv + permissions: groupmanager.manglistv mangcheckv: description: Verify a value of a variable of group, and where it comes from. usage: / - permission: groupmanager.mangckeckv + permissions: groupmanager.mangckeckv manwhois: description: Tell the group that user belongs. usage: / - permission: groupmanager.manwhois + permissions: groupmanager.manwhois tempadd: - description: Creates a temporary permission copy for that user. + description: Creates a temporary permissions copy for that user. usage: / - permission: groupmanager.tempadd + permissions: groupmanager.tempadd tempdel: - description: Remove the temporary permission copy for player. + description: Remove the temporary permissions copy for player. usage: / - permission: groupmanager.tempdel + permissions: groupmanager.tempdel templist: - description: List players in overload-permissions mode made by /tempadd. + description: List players in overload-permissionss mode made by /tempadd. usage: / - permission: groupmanager.templist + permissions: groupmanager.templist tempdelall: description: Remove all overrides made by command /tempadd. usage: / - permission: groupmanager.tempdelall + permissions: groupmanager.tempdelall mansave: - description: Save all permissions on file. + description: Save all permissionss on file. usage: / - permission: groupmanager.mansave + permissions: groupmanager.mansave manload: description: Reload current world and config.yml. Or load given world. usage: / [world] - permission: groupmanager.manload + permissions: groupmanager.manload listgroups: description: List the groups available. usage: / - permission: groupmanager.listgroups + permissions: groupmanager.listgroups manpromote: description: Promote a player in the same heritage line to a higher rank. usage: / - permission: groupmanager.manpromote + permissions: groupmanager.manpromote mandemote: description: Demote a player in the same heritage line to a lower rank. usage: / - permission: groupmanager.mandemote + permissions: groupmanager.mandemote mantogglevalidate: description: Toggle on/off the validating if player is online. usage: / - permission: groupmanager.mantogglevalidate + permissions: groupmanager.mantogglevalidate mantogglesave: description: Toggle on/ff the autosave. usage: / - permission: groupmanager.mantogglesave + permissions: groupmanager.mantogglesave manworld: description: Prints the selected world name usage: / - permission: groupmanager.manworld + permissions: groupmanager.manworld manselect: description: Select a world to work with next commands. usage: / - permission: groupmanager.manselect + permissions: groupmanager.manselect manclear: description: Clear world selection. Next commands will work on your world. usage: / - permission: groupmanager.manclear \ No newline at end of file + permissions: groupmanager.manclear \ No newline at end of file -- cgit v1.2.3 From 73b5fe971f1dc77c008373652c49efa53b86990e Mon Sep 17 00:00:00 2001 From: ElgarL Date: Fri, 16 Sep 2011 20:15:25 +0100 Subject: Read from group not user for setting superperms --- .../src/com/nijiko/permissions/PermissionHandler.class | Bin 5289 -> 0 bytes .../groupmanager/permissions/BukkitPermissions.java | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class diff --git a/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class b/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class deleted file mode 100644 index d3022a484..000000000 Binary files a/EssentialsGroupBridge/src/com/nijiko/permissions/PermissionHandler.class and /dev/null differ diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index 9e500b123..fe381c127 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -116,7 +116,7 @@ public class BukkitPermissions { PermissionAttachment attachment = this.attachments.get(player); User user = GroupManager.getWorldsHolder().getWorldData(world).getUser(player.getName()); - List permissions = user.getPermissionList(); + List permissions = user.getGroup().getPermissionList(); // clear permissions for (String permission : attachment.getPermissions().keySet()) { @@ -136,7 +136,7 @@ public class BukkitPermissions { permission = permission.substring(1); // cut off - value = false; } - + if (!attachment.getPermissions().containsKey(permission)) { attachment.setPermission(permission, value); } -- cgit v1.2.3