Merge branch 'groupmanager' of github.com:essentials/Essentials

This commit is contained in:
KHobbits 2012-03-28 17:37:03 +01:00
commit 2aed3af3c4
3 changed files with 87 additions and 56 deletions

View File

@ -151,4 +151,7 @@ v 1.9:
- Better reporting when a users.yml is failing to load.
- Expanded '/manuadd'to accept an optional variable for the world (eg '/manuadd <player> <group> <world>').
- Removed some debug spam.
- Don't remove an attachment on a player leaving as Bukkit never forgets it. This fixes non mirrored permissions being messed up if a player relogs.
- Don't remove an attachment on a player leaving as Bukkit never forgets it. This fixes non mirrored permissions being messed up if a player relogs.
- 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).
- Auto rename all case sensitive world folders to lower case (if possible).
- Update GlobalGroups.yml for new/changed Towny permission nodes.

View File

@ -181,47 +181,47 @@ groups:
- towny.nation.*
- towny.chat.tc
- towny.chat.nc
- towny.wild.block.6.build
- towny.wild.block.6.destroy
- towny.wild.block.14.destroy
- towny.wild.block.15.destroy
- towny.wild.block.16.destroy
- towny.wild.block.17.build
- towny.wild.block.17.destroy
- towny.wild.block.18.destroy
- towny.wild.block.21.destroy
- towny.wild.block.31.destroy
- towny.wild.block.37.destroy
- towny.wild.block.38.destroy
- towny.wild.block.39.destroy
- towny.wild.block.40.destroy
- towny.wild.block.50.destroy
- towny.wild.block.56.destroy
- towny.wild.block.73.destroy
- towny.wild.block.74.destroy
- towny.wild.block.78.destroy
- towny.wild.block.81.destroy
- towny.wild.block.82.destroy
- towny.wild.block.83.destroy
- towny.wild.block.86.destroy
- towny.wild.block.103.destroy
- towny.wild.block.106.destroy
- towny.wild.block.111.destroy
- towny.wild.block.115.destroy
- towny.wild.build.6
- towny.wild.destroy.6
- towny.wild.destroy.14
- towny.wild.destroy.15
- towny.wild.destroy.16
- towny.wild.build.17
- towny.wild.destroy.17
- towny.wild.destroy.18
- towny.wild.destroy.21
- towny.wild.destroy.31
- towny.wild.destroy.37
- towny.wild.destroy.38
- towny.wild.destroy.39
- towny.wild.destroy.40
- towny.wild.destroy.50
- towny.wild.destroy.56
- towny.wild.destroy.73
- towny.wild.destroy.74
- towny.wild.destroy.78
- towny.wild.destroy.81
- towny.wild.destroy.82
- towny.wild.destroy.83
- towny.wild.destroy.86
- towny.wild.destroy.103
- towny.wild.destroy.106
- towny.wild.destroy.111
- towny.wild.destroy.115
g:towny_moderator:
permissions:
- towny.chat.mod
- towny.wild.block.64.switch
- towny.wild.block.83.build
- towny.wild.block.86.build
- towny.wild.block.103.build
- towny.wild.block.111.build
- towny.wild.block.115.build
- towny.wild.switch.64
- towny.wild.build.83
- towny.wild.build.86
- towny.wild.build.103
- towny.wild.build.111
- towny.wild.build.115
g:towny_admin:
permissions:
- towny.admin
- -towny.wild.block.119.destroy
- -towny.wild.block.120.destroy
- -towny.wild.destroy.119
- -towny.wild.destroy.120
- towny.chat.admin

View File

@ -106,7 +106,12 @@ public class WorldsHolder {
if (!worldsData.containsKey(folder.getName().toLowerCase())
&& ((!mirrorsGroup.containsKey(folder.getName().toLowerCase()))
|| (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
loadWorld(folder.getName());
/*
* Call setupWorldFolder to check case sensitivity
* and convert to lower case, before we attempt to load this world.
*/
setupWorldFolder(folder.getName());
loadWorld(folder.getName().toLowerCase());
}
}
@ -362,9 +367,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 +450,34 @@ 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()))) {
defaultWorldFolder.mkdirs();
File defaultWorldFolder = new File(worldsFolder, worldNameLowered);
if ((!defaultWorldFolder.exists()) && ((!mirrorsGroup.containsKey(worldNameLowered))) || (!mirrorsUser.containsKey(worldNameLowered))) {
/*
* check and convert all old case sensitive folders to lower case
*/
File casedWorldFolder = new File(worldsFolder, worldName);
if ((casedWorldFolder.exists()) && (casedWorldFolder.getName().toLowerCase().equals(worldNameLowered))) {
/*
* Rename the old folder to the new lower cased format
*/
casedWorldFolder.renameTo(new File(worldsFolder, worldNameLowered));
} else {
/*
* Else we just create the folder
*/
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 +490,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 +508,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 +555,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 +580,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 +601,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;
}