summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org/anjocaido
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2012-03-26 19:18:19 +0100
committerElgarL <ElgarL@palmergames.com>2012-03-26 19:18:19 +0100
commit50ea442bf0be605420befc97c715825b3eff9bfc (patch)
tree66e35d01df694aed7f7f431fc06a055dab5bb8ce /EssentialsGroupManager/src/org/anjocaido
parent9570e5cfd9731e19420f33048c55d3fb7d58bc7d (diff)
downloadEssentials-50ea442bf0be605420befc97c715825b3eff9bfc.tar
Essentials-50ea442bf0be605420befc97c715825b3eff9bfc.tar.gz
Essentials-50ea442bf0be605420befc97c715825b3eff9bfc.tar.lz
Essentials-50ea442bf0be605420befc97c715825b3eff9bfc.tar.xz
Essentials-50ea442bf0be605420befc97c715825b3eff9bfc.zip
Treat all world names as lower case for file handling (please check in
your worlds folder. You should have no folders with upper case letters from now).
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java44
1 files changed, 26 insertions, 18 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 290a58388..35e8794b5 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -362,9 +362,10 @@ public class WorldsHolder {
* @return updated world holder
*/
private OverloadedWorldHolder getUpdatedWorldData(String worldName) {
+ String worldNameLowered = worldName.toLowerCase();
- if (worldsData.containsKey(worldName.toLowerCase())) {
- OverloadedWorldHolder data = worldsData.get(worldName.toLowerCase());
+ if (worldsData.containsKey(worldNameLowered)) {
+ OverloadedWorldHolder data = worldsData.get(worldNameLowered);
data.updateDataSource();
return data;
}
@@ -444,17 +445,19 @@ public class WorldsHolder {
}
public void setupWorldFolder(String worldName) {
+ String worldNameLowered = worldName.toLowerCase();
+
worldsFolder = new File(plugin.getDataFolder(), "worlds");
if (!worldsFolder.exists()) {
worldsFolder.mkdirs();
}
- File defaultWorldFolder = new File(worldsFolder, worldName);
- if ((!defaultWorldFolder.exists()) && ((!mirrorsGroup.containsKey(worldName.toLowerCase()))) || (!mirrorsUser.containsKey(worldName.toLowerCase()))) {
+ File defaultWorldFolder = new File(worldsFolder, worldNameLowered);
+ if ((!defaultWorldFolder.exists()) && ((!mirrorsGroup.containsKey(worldNameLowered))) || (!mirrorsUser.containsKey(worldNameLowered))) {
defaultWorldFolder.mkdirs();
}
if (defaultWorldFolder.exists()) {
- if (!mirrorsGroup.containsKey(worldName.toLowerCase())) {
+ if (!mirrorsGroup.containsKey(worldNameLowered)) {
File groupsFile = new File(defaultWorldFolder, "groups.yml");
if (!groupsFile.exists() || groupsFile.length() == 0) {
@@ -467,7 +470,7 @@ public class WorldsHolder {
}
}
- if (!mirrorsUser.containsKey(worldName.toLowerCase())) {
+ if (!mirrorsUser.containsKey(worldNameLowered)) {
File usersFile = new File(defaultWorldFolder, "users.yml");
if (!usersFile.exists() || usersFile.length() == 0) {
@@ -485,13 +488,15 @@ public class WorldsHolder {
/**
* Copies the specified world data to another world
+ *
* @param fromWorld
* @param toWorld
* @return true if successfully copied.
*/
public boolean cloneWorld(String fromWorld, String toWorld) {
- File fromWorldFolder = new File(worldsFolder, fromWorld);
- File toWorldFolder = new File(worldsFolder, toWorld);
+
+ File fromWorldFolder = new File(worldsFolder, fromWorld.toLowerCase());
+ File toWorldFolder = new File(worldsFolder, toWorld.toLowerCase());
if (toWorldFolder.exists() || !fromWorldFolder.exists()) {
return false;
}
@@ -530,17 +535,20 @@ public class WorldsHolder {
* @param worldName
*/
public void loadWorld(String worldName, Boolean isMirror) {
- if (worldsData.containsKey(worldName.toLowerCase())) {
- worldsData.get(worldName.toLowerCase()).reload();
+
+ String worldNameLowered = worldName.toLowerCase();
+
+ if (worldsData.containsKey(worldNameLowered)) {
+ worldsData.get(worldNameLowered).reload();
return;
}
GroupManager.logger.finest("Trying to load world " + worldName + "...");
- File thisWorldFolder = new File(worldsFolder, worldName);
+ File thisWorldFolder = new File(worldsFolder, worldNameLowered);
if ((isMirror) || (thisWorldFolder.exists() && thisWorldFolder.isDirectory())) {
// Setup file handles, if not mirrored
- File groupsFile = (mirrorsGroup.containsKey(worldName.toLowerCase()))? null : new File(thisWorldFolder, "groups.yml");
- File usersFile = (mirrorsUser.containsKey(worldName.toLowerCase()))? null : new File(thisWorldFolder, "users.yml");
+ File groupsFile = (mirrorsGroup.containsKey(worldNameLowered))? null : new File(thisWorldFolder, "groups.yml");
+ File usersFile = (mirrorsUser.containsKey(worldNameLowered))? null : new File(thisWorldFolder, "users.yml");
if ((groupsFile != null) && (!groupsFile.exists())) {
throw new IllegalArgumentException("Groups file for world '" + worldName + "' doesnt exist: " + groupsFile.getPath());
@@ -552,14 +560,14 @@ public class WorldsHolder {
WorldDataHolder tempHolder = new WorldDataHolder(worldName);
// Map the group object for any mirror
- if (mirrorsGroup.containsKey(worldName.toLowerCase()))
- tempHolder.setGroupsObject(this.getWorldData(mirrorsGroup.get(worldName.toLowerCase())).getGroupsObject());
+ if (mirrorsGroup.containsKey(worldNameLowered))
+ tempHolder.setGroupsObject(this.getWorldData(mirrorsGroup.get(worldNameLowered)).getGroupsObject());
else
tempHolder.loadGroups(groupsFile);
// Map the user object for any mirror
- if (mirrorsUser.containsKey(worldName.toLowerCase()))
- tempHolder.setUsersObject(this.getWorldData(mirrorsUser.get(worldName.toLowerCase())).getUsersObject());
+ if (mirrorsUser.containsKey(worldNameLowered))
+ tempHolder.setUsersObject(this.getWorldData(mirrorsUser.get(worldNameLowered)).getUsersObject());
else
tempHolder.loadUsers(usersFile);
@@ -573,7 +581,7 @@ public class WorldsHolder {
if (thisWorldData != null) {
GroupManager.logger.finest("Successful load of world " + worldName + "...");
- worldsData.put(worldName.toLowerCase(), thisWorldData);
+ worldsData.put(worldNameLowered, thisWorldData);
return;
}