summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2012-01-24 14:08:53 +0000
committerElgarL <ElgarL@palmergames.com>2012-01-24 14:08:53 +0000
commit1dab4f95dd834af67dbc6f6c8e190d62f3e93752 (patch)
treed9ff17659aecd7b71fe4615f92c94b28b25c04a4 /EssentialsGroupManager
parent125ea7c701c365c0a903c436ef92577742eaad5f (diff)
downloadEssentials-1dab4f95dd834af67dbc6f6c8e190d62f3e93752.tar
Essentials-1dab4f95dd834af67dbc6f6c8e190d62f3e93752.tar.gz
Essentials-1dab4f95dd834af67dbc6f6c8e190d62f3e93752.tar.lz
Essentials-1dab4f95dd834af67dbc6f6c8e190d62f3e93752.tar.xz
Essentials-1dab4f95dd834af67dbc6f6c8e190d62f3e93752.zip
Added recursive loop detection for World mirroring (you may not set the
main world as a mirror of another). Fixed fetching world data so it no longer returns the mirrored world for groups. Each world data holder now points to the correct data set, so can be returned as an object.
Diffstat (limited to 'EssentialsGroupManager')
-rw-r--r--EssentialsGroupManager/src/Changelog.txt4
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java85
2 files changed, 45 insertions, 44 deletions
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index b58f520a8..22e812dd6 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -111,4 +111,6 @@ v 1.9:
- Update GroupManagerBridge for new event system.
- Fixed a random null error upon a player portaling.
- Fixed infinite loop error on player join.
- - Optimized code to only update the player logging in instead of all players online. \ No newline at end of file
+ - Optimized code to only update the player logging in instead of all players online.
+ - Added recursive loop detection for World mirroring (you may not set the main world as a mirror of another).
+ - Fixed fetching world data so it no longer returns the mirrored world for groups. Each world data holder now points to the correct data set, so can be returned as an object. \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 1a765c7b4..a24e534be 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -130,41 +130,48 @@ public class WorldsHolder {
// These worlds fully mirror their parent
for (Object o : mirrorList) {
- try {
- mirrorsGroup.remove(o.toString().toLowerCase());
- mirrorsUser.remove(o.toString().toLowerCase());
- } catch (Exception e) {
- }
- mirrorsGroup.put(o.toString().toLowerCase(), getWorldData(source).getName());
- mirrorsUser.put(o.toString().toLowerCase(), getWorldData(source).getName());
+ String world = o.toString().toLowerCase();
+ if (world != serverDefaultWorldName) {
+ try {
+ mirrorsGroup.remove(world);
+ mirrorsUser.remove(world);
+ } catch (Exception e) {
+ }
+ mirrorsGroup.put(world, getWorldData(source).getName());
+ mirrorsUser.put(world, getWorldData(source).getName());
+ } else
+ GroupManager.logger.log(Level.WARNING, "Mirroring error with " + o.toString() + ". Recursive loop detected!");
}
} else if (mirrorsMap.get(source) instanceof MemorySection) {
MemorySection subSection = (MemorySection) mirrorsMap.get(source);
for (String key : subSection.getKeys(true)) {
- //System.out.print("Key - " + key);
- if (subSection.get(key) instanceof ArrayList) {
- ArrayList mirrorList = (ArrayList) subSection.get(key);
-
- // These worlds have defined mirroring
- for (Object o : mirrorList) {
- String type = o.toString().toLowerCase();
- try {
- if (type.equals("groups"))
- mirrorsGroup.remove(key.toLowerCase());
-
- if (type.equals("users"))
- mirrorsUser.remove(key.toLowerCase());
-
- } catch (Exception e) {
- }
- if (type.equals("groups"))
- mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
-
- if (type.equals("users"))
- mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
- }
+ if (key.toLowerCase() != serverDefaultWorldName) {
+
+ if (subSection.get(key) instanceof ArrayList) {
+ ArrayList mirrorList = (ArrayList) subSection.get(key);
+
+ // These worlds have defined mirroring
+ for (Object o : mirrorList) {
+ String type = o.toString().toLowerCase();
+ try {
+ if (type.equals("groups"))
+ mirrorsGroup.remove(key.toLowerCase());
+
+ if (type.equals("users"))
+ mirrorsUser.remove(key.toLowerCase());
+
+ } catch (Exception e) {
+ }
+ if (type.equals("groups"))
+ mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
+
+ if (type.equals("users"))
+ mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
+ }
+ } else
+ GroupManager.logger.log(Level.WARNING, "Mirroring error with " + key + ". Recursive loop detected!");
@@ -312,27 +319,19 @@ public class WorldsHolder {
* If the world is not on the worlds list, returns the default world
* holder.
*
- * (WHEN A WORLD IS CONFIGURED TO MIRROR, IT WILL BE ON THE LIST, BUT
- * POINTING TO ANOTHER WORLD HOLDER)
- *
- * Mirrors prevails original data.
+ * Mirrors return original world data.
*
* @param worldName
* @return OverloadedWorldHolder
*/
public OverloadedWorldHolder getWorldData(String worldName) {
String worldNameLowered = worldName.toLowerCase();
- // If a mirror change to the real world to load.
- if (mirrorsGroup.containsKey(worldNameLowered)) {
- worldNameLowered = mirrorsGroup.get(worldNameLowered);
- }
- OverloadedWorldHolder data = worldsData.get(worldNameLowered);
+
+ if (worldsData.containsKey(worldNameLowered))
+ return worldsData.get(worldNameLowered);
- if (data == null) {
- GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
- data = getDefaultWorld();
- }
- return data;
+ GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
+ return getDefaultWorld();
}
/**