From 73fb2d3735e6c4db4ca2e7bd61b163ad359ce25f Mon Sep 17 00:00:00 2001
From: ElgarL <ElgarL@palmergames.com>
Date: Fri, 3 Aug 2012 11:15:14 +0100
Subject: Fix mirroring now we are not using any Bukkit methods.

---
 .../dataholder/worlds/WorldsHolder.java            | 40 +++++++++++++---------
 1 file changed, 24 insertions(+), 16 deletions(-)

(limited to 'EssentialsGroupManager/src/org/anjocaido')

diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index afdb0e15b..f84262eeb 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -22,7 +22,6 @@ import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
 import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
 import org.anjocaido.groupmanager.utils.Tasks;
 import org.bukkit.World;
-import org.bukkit.configuration.MemorySection;
 import org.bukkit.entity.Player;
 
 /**
@@ -97,9 +96,13 @@ public class WorldsHolder {
 		 * Create the data files if they don't already exist,
 		 * and they are not mirrored.
 		 */
-		for (World world : plugin.getServer().getWorlds())
-			if ((!worldsData.containsKey(world.getName().toLowerCase())) && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase()))))
+		for (World world : plugin.getServer().getWorlds()){
+			GroupManager.logger.log(Level.FINE, "Checking data for " + world.getName() + ".");
+			if ((!worldsData.containsKey(world.getName().toLowerCase())) && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase())))) {
+				GroupManager.logger.log(Level.FINE, "Creating folders for " + world.getName() + ".");
 				setupWorldFolder(world.getName());
+			}
+		}
 		/*
 		 * Loop over all folders within the worlds folder
 		 * and attempt to load the world data
@@ -164,12 +167,12 @@ public class WorldsHolder {
 						} 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);
+				} else if (mirrorsMap.get(source) instanceof Map) {
+					Map subSection = (Map) mirrorsMap.get(source);
 
-					for (String key : subSection.getKeys(true)) {
+					for (Object key : subSection.keySet()) {
 
-						if (key.toLowerCase() != serverDefaultWorldName) {
+						if (((String)key).toLowerCase() != serverDefaultWorldName) {
 
 							if (subSection.get(key) instanceof ArrayList) {
 								ArrayList mirrorList = (ArrayList) subSection.get(key);
@@ -179,28 +182,32 @@ public class WorldsHolder {
 									String type = o.toString().toLowerCase();
 									try {
 										if (type.equals("groups"))
-											mirrorsGroup.remove(key.toLowerCase());
+											mirrorsGroup.remove(((String)key).toLowerCase());
 
 										if (type.equals("users"))
-											mirrorsUser.remove(key.toLowerCase());
+											mirrorsUser.remove(((String)key).toLowerCase());
 
 									} catch (Exception e) {
 									}
-									if (type.equals("groups"))
-										mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
+									if (type.equals("groups")) {
+										mirrorsGroup.put(((String)key).toLowerCase(), getWorldData(source).getName());
+										GroupManager.logger.log(Level.FINE, "Adding groups mirror for " + key + ".");
+									}
 
-									if (type.equals("users"))
-										mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
+									if (type.equals("users")) {
+										mirrorsUser.put(((String)key).toLowerCase(), getWorldData(source).getName());
+										GroupManager.logger.log(Level.FINE, "Adding users mirror for " + key + ".");
+									}
 								}
 
 								// Track this world so we can create a datasource for it later
-								mirroredWorlds.add(key);
+								mirroredWorlds.add((String)key);
 
 							} else
-								GroupManager.logger.log(Level.WARNING, "Mirroring error with " + key + ". Recursive loop detected!");
+								GroupManager.logger.log(Level.WARNING, "Mirroring error with " + (String)key + ". Recursive loop detected!");
 
 						} else {
-							throw new IllegalStateException("Unknown mirroring format for " + key);
+							throw new IllegalStateException("Unknown mirroring format for " + (String)key);
 						}
 
 					}
@@ -210,6 +217,7 @@ public class WorldsHolder {
 			// Create a datasource for any worlds not already loaded
 			for (String world : mirroredWorlds) {
 				if (!worldsData.containsKey(world.toLowerCase())) {
+					GroupManager.logger.log(Level.FINE, "No data for " + world + ".");
 					setupWorldFolder(world);
 					loadWorld(world, true);
 				}
-- 
cgit v1.2.3