Added a new mirroring option in the config of 'all_unnamed_worlds'. This

will cause all new or unnamed worlds to use this mirroring.
This commit is contained in:
ElgarL 2013-02-22 12:39:41 +00:00
parent 13e07f64ec
commit 90730f63d5
4 changed files with 61 additions and 11 deletions

View file

@ -215,3 +215,4 @@ v 2.0:
- Add config potion to set if GM commands should be allowed on CommnandBlocks. - Add config potion to set if GM commands should be allowed on CommnandBlocks.
- Catch the error when using an out of date config for 'allow_commandblocks' So it doesn't kill the whole config. - Catch the error when using an out of date config for 'allow_commandblocks' So it doesn't kill the whole config.
- '/manselect' will no longer list duplicate worlds. - '/manselect' will no longer list duplicate worlds.
- Added a new mirroring option in the config of 'all_unnamed_worlds'. This will cause all new or unnamed worlds to use this mirroring.

View file

@ -37,6 +37,9 @@ settings:
world_the_end: world_the_end:
- users - users
- groups - groups
all_unnamed_worlds:
- users
- groups
# world2: (World2 would have it's own set of user and groups files) # world2: (World2 would have it's own set of user and groups files)
# world3: # world3:
# - users (World3 would use the users.yml from world2, but it's own groups.yml) # - users (World3 would use the users.yml from world2, but it's own groups.yml)

View file

@ -59,6 +59,23 @@ public class WorldsHolder {
resetWorldsHolder(); resetWorldsHolder();
} }
/**
* @return the mirrorsGroup
*/
public Map<String, String> getMirrorsGroup() {
return mirrorsGroup;
}
/**
* @return the mirrorsUser
*/
public Map<String, String> getMirrorsUser() {
return mirrorsUser;
}
public void resetWorldsHolder() { public void resetWorldsHolder() {
worldsData = new HashMap<String, OverloadedWorldHolder>(); worldsData = new HashMap<String, OverloadedWorldHolder>();
@ -92,33 +109,46 @@ public class WorldsHolder {
private void loadAllSearchedWorlds() { private void loadAllSearchedWorlds() {
/* /*
* Read all known worlds from Bukkit * Read all known worlds from Bukkit Create the data files if they don't
* Create the data files if they don't already exist, * already exist, and they are not mirrored.
* and they are not mirrored.
*/ */
for (World world : plugin.getServer().getWorlds()){ for (World world : plugin.getServer().getWorlds()) {
GroupManager.logger.log(Level.FINE, "Checking data for " + world.getName() + "."); 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())))) { if ((!worldsData.containsKey(world.getName().toLowerCase())) && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase())))) {
if (plugin.getWorldsHolder().getWorldData("all_unnamed_worlds") != null) {
String usersMirror = plugin.getWorldsHolder().getMirrorsUser().get("all_unnamed_worlds");
String groupsMirror = plugin.getWorldsHolder().getMirrorsGroup().get("all_unnamed_worlds");
if (usersMirror != null)
plugin.getWorldsHolder().getMirrorsUser().put(world.getName().toLowerCase(), usersMirror);
if (groupsMirror != null)
plugin.getWorldsHolder().getMirrorsGroup().put(world.getName().toLowerCase(), groupsMirror);
}
GroupManager.logger.log(Level.FINE, "Creating folders for " + world.getName() + "."); GroupManager.logger.log(Level.FINE, "Creating folders for " + world.getName() + ".");
setupWorldFolder(world.getName()); setupWorldFolder(world.getName());
} }
} }
/* /*
* Loop over all folders within the worlds folder * Loop over all folders within the worlds folder and attempt to load
* and attempt to load the world data * the world data
*/ */
for (File folder : worldsFolder.listFiles()) { for (File folder : worldsFolder.listFiles()) {
if (folder.isDirectory() && !folder.getName().startsWith(".")) { if (folder.isDirectory() && !folder.getName().startsWith(".")) {
GroupManager.logger.info("World Found: " + folder.getName()); GroupManager.logger.info("World Found: " + folder.getName());
/* /*
* don't load any worlds which are already loaded * don't load any worlds which are already loaded or fully
* or fully mirrored worlds that don't need data. * mirrored worlds that don't need data.
*/ */
if (!worldsData.containsKey(folder.getName().toLowerCase()) && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase())) || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) { if (!worldsData.containsKey(folder.getName().toLowerCase()) && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase())) || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
/* /*
* Call setupWorldFolder to check case sensitivity * Call setupWorldFolder to check case sensitivity and
* and convert to lower case, before we attempt to load this * convert to lower case, before we attempt to load this
* world. * world.
*/ */
setupWorldFolder(folder.getName()); setupWorldFolder(folder.getName());

View file

@ -35,8 +35,24 @@ public class GMWorldListener implements Listener {
if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) { if (GroupManager.isLoaded() && !plugin.getWorldsHolder().isInList(worldName)) {
GroupManager.logger.info("New world detected..."); GroupManager.logger.info("New world detected...");
GroupManager.logger.info("Creating data for: " + worldName); GroupManager.logger.info("Creating data for: " + worldName);
if (plugin.getWorldsHolder().getWorldData("all_unnamed_worlds") != null) {
String usersMirror = plugin.getWorldsHolder().getMirrorsUser().get("all_unnamed_worlds");
String groupsMirror = plugin.getWorldsHolder().getMirrorsGroup().get("all_unnamed_worlds");
if (usersMirror != null)
plugin.getWorldsHolder().getMirrorsUser().put(worldName.toLowerCase(), usersMirror);
if (groupsMirror != null)
plugin.getWorldsHolder().getMirrorsGroup().put(worldName.toLowerCase(), groupsMirror);
}
plugin.getWorldsHolder().setupWorldFolder(worldName); plugin.getWorldsHolder().setupWorldFolder(worldName);
plugin.getWorldsHolder().loadWorld(worldName); plugin.getWorldsHolder().loadWorld(worldName);
if (plugin.getWorldsHolder().isInList(worldName)) { if (plugin.getWorldsHolder().isInList(worldName)) {
GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml."); GroupManager.logger.info("Don't forget to configure/mirror this world in config.yml.");
} else } else