From 9ff6f21c7b1aad872b58b5d454d5dd3f1e90a654 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 --- .../dataholder/OverloadedWorldHolder.java | 7 +- .../groupmanager/dataholder/WorldDataHolder.java | 92 +++++++++++----------- .../dataholder/worlds/WorldsHolder.java | 17 ++-- 3 files changed, 61 insertions(+), 55 deletions(-) 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 (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder') 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 */ -- cgit v1.2.3