Merge branch 'master' into test

This commit is contained in:
Eric Stokes 2011-10-20 16:44:02 -06:00
commit b028811d36
10 changed files with 256 additions and 111 deletions

16
pom.xml
View File

@ -9,7 +9,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>UNKNOWN</project.build.number>
<doxygen.configuration>doxygen</doxygen.configuration>
</properties>
<repositories>
@ -104,18 +103,11 @@
</archive>
</configuration>
</plugin>
<!-- Doxygen JavaDoc Plugin -->
<!-- Maven Source Plugin -->
<plugin>
<groupId>net.sf.doodleproject</groupId>
<artifactId>doxygen-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<executable>/usr/local/bin/doxygen</executable>
<configurationFile>${doxygen.configuration}</configurationFile>
<projectName>${project.name}</projectName>
<destDir>target/doxygen</destDir>
<inputDirectory>src/main/java</inputDirectory>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
</plugins>
</build>

View File

@ -96,16 +96,15 @@ public class MVWorld implements MultiverseWorld {
}
worldSection.set("environment", this.environment.toString());
// Set local values that CAN be changed by the user
this.setAlias(worldSection.getString("alias.name", ""));
this.setColor(worldSection.getString("alias.color", ChatColor.WHITE.toString()));
this.setFakePVPMode(worldSection.getBoolean("fakepvp", false));
this.setPVPMode(worldSection.getBoolean("pvp", true));
this.setFakePVPMode(worldSection.getBoolean("fakepvp", false));
this.setScaling(worldSection.getDouble("scale", this.getDefaultScale(this.environment)));
this.setRespawnToWorld(worldSection.getString("respawnworld", ""));
this.setEnableWeather(worldSection.getBoolean("allowweather", true));
this.setDifficulty(worldSection.getString("difficulty", "1"));
this.setDifficulty(worldSection.get("difficulty", "EASY"));
this.setAllowAnimalSpawn(worldSection.getBoolean("animals.spawn", true));
this.setAllowMonsterSpawn(worldSection.getBoolean("monsters.spawn", true));
@ -115,7 +114,7 @@ public class MVWorld implements MultiverseWorld {
this.setHidden(worldSection.getBoolean("hidden", false));
this.getMobExceptions();
this.setGameMode(worldSection.getString("gamemode", GameMode.SURVIVAL.toString()));
this.setGameMode(worldSection.get("gamemode", GameMode.SURVIVAL.toString()));
this.setKeepSpawnInMemory(worldSection.getBoolean("keepspawninmemory", true));
@ -123,7 +122,7 @@ public class MVWorld implements MultiverseWorld {
this.translateTempSpawn(worldSection);
this.readSpawnFromConfig(this.getCBWorld());
this.canSave = true;
saveConfig();
this.saveConfig();
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.OP);
this.exempt = new Permission("multiverse.exempt." + this.getName(), "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
@ -671,12 +670,30 @@ public class MVWorld implements MultiverseWorld {
return false;
}
this.setGameMode(mode);
this.worldSection.set("gamemode", mode.getValue());
this.worldSection.set("gamemode", mode.toString());
saveConfig();
return true;
}
/**
* FernFerret messed up and now config values could be in either string or Int
*
* @param mode The gamemode as an object.
*
* @return True if the mode was set, false if not.
*/
private boolean setGameMode(Object mode) {
if (mode instanceof Integer) {
return this.setGameMode(GameMode.getByValue((Integer) mode));
}
try {
return this.setGameMode((String) mode);
} catch (ClassCastException e) {
return false;
}
}
private boolean setGameMode(GameMode mode) {
this.gameMode = mode;
@ -732,19 +749,20 @@ public class MVWorld implements MultiverseWorld {
}
private void readSpawnFromConfig(World w) {
double x = config.getDouble("spawn.x", w.getSpawnLocation().getX());
double y = config.getDouble("spawn.y", w.getSpawnLocation().getY());
double z = config.getDouble("spawn.z", w.getSpawnLocation().getZ());
double x = worldSection.getDouble("spawn.x", w.getSpawnLocation().getX());
double y = worldSection.getDouble("spawn.y", w.getSpawnLocation().getY());
double z = worldSection.getDouble("spawn.z", w.getSpawnLocation().getZ());
this.plugin.log(Level.FINE, "Read spawn from config as: " + x + ", " + y + ", " + z);
float pitch = (float) config.getDouble("spawn.pitch", w.getSpawnLocation().getPitch());
float yaw = (float) config.getDouble("spawn.yaw", w.getSpawnLocation().getYaw());
this.spawnLocation = new Location(w, x, y, z, yaw, pitch);
float pitch = (float) worldSection.getDouble("spawn.pitch", w.getSpawnLocation().getPitch());
float yaw = (float) worldSection.getDouble("spawn.yaw", w.getSpawnLocation().getYaw());
this.setSpawnLocation(new Location(w, x, y, z, yaw, pitch));
SafeTTeleporter teleporter = this.plugin.getTeleporter();
BlockSafety bs = new BlockSafety();
if (!bs.playerCanSpawnHereSafely(this.spawnLocation)) {
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
Location newSpawn = teleporter.getSafeLocation(this.spawnLocation, 128, 128);
// I think we could also do this, as I think this is what notch does.
// I think we could also do this, as I think this is what Notch does.
// Not sure how it will work in the nether...
//Location newSpawn = this.spawnLocation.getWorld().getHighestBlockAt(this.spawnLocation).getLocation();
if (newSpawn != null) {
@ -754,6 +772,7 @@ public class MVWorld implements MultiverseWorld {
this.plugin.log(Level.SEVERE, "New safe spawn NOT found!!!");
}
}
this.plugin.log(Level.FINEST, "Spawn for '" + this.getName() + "' Located at: " + LocationManipulation.locationToString(this.getSpawnLocation()));
}
@Override
@ -766,6 +785,24 @@ public class MVWorld implements MultiverseWorld {
return this.getCBWorld().getDifficulty();
}
/**
* FernFerret messed up and now config values could be in either string or Int
*
* @param mode The gamemode as an object.
*
* @return True if the mode was set, false if not.
*/
private boolean setDifficulty(Object mode) {
if (mode instanceof Integer) {
return this.setDifficulty(Difficulty.getByValue((Integer) mode));
}
try {
return this.setDifficulty((String) mode);
} catch (ClassCastException e) {
return false;
}
}
@Override
public boolean setDifficulty(String difficulty) {
Difficulty worlddiff;
@ -783,8 +820,14 @@ public class MVWorld implements MultiverseWorld {
if (worlddiff == null) {
return false;
}
this.getCBWorld().setDifficulty(worlddiff);
this.worldSection.set("difficulty", worlddiff.getValue());
this.setDifficulty(worlddiff);
saveConfig();
return true;
}
private boolean setDifficulty(Difficulty diff) {
this.getCBWorld().setDifficulty(diff);
this.worldSection.set("difficulty", diff.toString());
saveConfig();
return true;
}

View File

@ -45,7 +45,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private final static int Protocol = 6;
private final static int Protocol = 7;
// Global Multiverse config variable, states whether or not
// Multiverse should stop other plugins from teleporting players
// to worlds.
@ -269,7 +269,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this); // To remove Player Sessions
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this); // To prepend the world name
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.Monitor, this); // To switch gamemode
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.Lowest, this); // To switch gamemode
pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, this.playerListener, Priority.Monitor, this); // To switch gamemode
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
@ -291,6 +291,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
this.multiverseConfig.setDefaults(coreDefaults);
this.multiverseConfig.options().copyDefaults(true);
this.saveMVConfig();
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
// Setup the Debug option, we'll default to false because this option will not be in the default config.
@ -647,16 +649,21 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return false;
}
public boolean saveMVConfigs() {
boolean retVal = true;
public boolean saveMVConfig() {
try {
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
return true;
} catch (IOException e) {
retVal = false;
this.log(Level.SEVERE, "Could not save Multiverse config.yml config. Please check your file permissions.");
return false;
}
}
this.worldManager.saveWorldsConfig();
return retVal;
public boolean saveWorldConfig() {
return this.worldManager.saveWorldsConfig();
}
public boolean saveMVConfigs() {
return this.saveMVConfig() && this.saveWorldConfig();
}
}

View File

@ -23,12 +23,13 @@ public class ConfigCommand extends MultiverseCommand {
super(plugin);
this.setName("Configuration");
this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
this.setArgRange(2, 2);
this.setArgRange(1, 2);
this.addKey("mv config");
this.addKey("mvconfig");
this.addKey("mv conf");
this.addKey("mvconf");
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
this.addCommandExample("/mv config show");
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
this.addCommandExample("/mv config " + ChatColor.GREEN + "bedrespawn" + ChatColor.AQUA + " true");
@ -38,6 +39,22 @@ public class ConfigCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() <= 1) {
String[] allProps = ConfigProperty.getAllValues().split(" ");
String currentvals = "";
for (String prop : allProps) {
currentvals += ChatColor.GREEN;
currentvals += prop;
currentvals += ChatColor.WHITE;
currentvals += " = ";
currentvals += ChatColor.GOLD;
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
currentvals += ChatColor.WHITE;
currentvals += ", ";
}
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
return;
}
if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown") || args.get(0).equalsIgnoreCase("debug")) {
try {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));

View File

@ -102,7 +102,7 @@ public class TeleportCommand extends MultiverseCommand {
return;
}
if (teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (MultiverseCore.EnforceAccess && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {

View File

@ -177,6 +177,6 @@ public class CannonDestination implements MVDestination {
@Override
public boolean useSafeTeleporter() {
return true;
return false;
}
}

View File

@ -11,12 +11,10 @@ import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.player.*;
@ -151,10 +149,14 @@ public class MVPlayerListener extends PlayerListener {
@Override
public void onPlayerPortal(PlayerPortalEvent event) {
// If the player was actually outside of the portal, adjust the from location
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
event.setFrom(SafeTTeleporter.findPortalBlockNextTo(event.getFrom()));
}
if (event.isCancelled() || event.getTo() == null || event.getFrom() == null) {
return;
}
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
@ -178,9 +180,9 @@ public class MVPlayerListener extends PlayerListener {
* <p/>
* The return is a little backwards, and will return a value safe for event.setCancelled.
*
* @param fromWorld
* @param toWorld
* @param player
* @param fromWorld The MultiverseWorld they are in.
* @param toWorld The MultiverseWorld they want to go to.
* @param player The player that wants to travel.
*
* @return True if they can't go to the world, False if they can.
*/

View File

@ -78,6 +78,10 @@ public class MVPermissions implements PermissionsInterface {
* @return
*/
public boolean canEnterWorld(Player p, MultiverseWorld w) {
// If we're not enforcing access, anyone can enter.
if (!MultiverseCore.EnforceAccess) {
return true;
}
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
}
@ -120,6 +124,15 @@ public class MVPermissions implements PermissionsInterface {
return this.hasPermission(p, d.getRequiredPermission(), false);
}
/**
* Check to see if a player has a permission.
*
* @param sender Who is requesting the permission.
* @param node The permission node in string format; multiverse.core.list.worlds for example.
* @param isOpRequired @Deprecated. This is not used for anything anymore.
*
* @return True if they have that permission or any parent.
*/
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
if (!(sender instanceof Player)) {
return true;
@ -133,11 +146,73 @@ public class MVPermissions implements PermissionsInterface {
if (node.equals("")) {
return true;
}
boolean hasPermission = checkActualPermission(sender, node);
// I consider this a workaround. At the moment, when we add a node AND recalc the permissions, until the perms
// plugin reloads, when MV asks the API if a player has a perm, it reports that they do NOT.
// For the moment, we're going to check all of this node's parents to see if the user has those. It stops
// when if finds a true or there are no more parents. --FF
if (!hasPermission) {
hasPermission = this.hasAnyParentPermission(sender, node);
}
return hasPermission;
}
// TODO: Better player checks, most likely not needed, but safer.
private boolean checkActualPermission(CommandSender sender, String node) {
Player player = (Player) sender;
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
return sender.hasPermission(node);
boolean hasPermission = sender.hasPermission(node);
if (hasPermission) {
this.plugin.log(Level.FINER, "Player [" + player.getName() + "] HAS PERMISSION [" + node + "]!");
}
return hasPermission;
}
/**
* Checks to see if the sender has any parent perms.
* Stops when it finds one or when there are no more parents.
* This method is recursive.
*
* @param sender Who is asking for the permission.
* @param node The permission node to check (possibly already a parent).
*
* @return True if they have any parent perm, false if none.
*/
private boolean hasAnyParentPermission(CommandSender sender, String node) {
String parentPerm = this.pullOneLevelOff(node);
// Base case
if (parentPerm == null) {
return false;
}
// If they have a parent, they're good
if (this.checkActualPermission(sender, parentPerm + ".*")) {
return true;
}
return hasAnyParentPermission(sender, parentPerm);
}
/**
* Pulls one level off of a yaml style node.
* Given multiverse.core.list.worlds will return multiverse.core.list
*
* @param node The root node to check.
*
* @return The parent of the node
*/
private String pullOneLevelOff(String node) {
if (node == null) {
return null;
}
int index = node.lastIndexOf(".");
if (index > 0) {
return node.substring(0, index);
}
return null;
}
public String getType() {
return "Bukkit Permissions (SuperPerms)";
}

View File

@ -11,6 +11,9 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
@ -31,22 +34,6 @@ public class SafeTTeleporter {
this.bs = new BlockSafety();
}
/**
* This method will be specific to beds, and check on top of the bed then around it.
*
* @return
*/
public Location getSafeBedDestination(Location bedLocation) {
Location idealLocation = bedLocation;
idealLocation.setY(idealLocation.getY() + 1);
idealLocation.setX(idealLocation.getX() + .5);
idealLocation.setZ(idealLocation.getZ() + .5);
if (this.bs.playerCanSpawnHereSafely(idealLocation)) {
return bedLocation;
}
return null;
}
public Location getSafeLocation(Location l) {
return this.getSafeLocation(l, 6, 9);
}
@ -112,7 +99,7 @@ public class SafeTTeleporter {
* For my crappy algorithm, radius MUST be odd
*
* @param l
* @param radius
* @param diameter
*
* @return
*/
@ -196,7 +183,7 @@ public class SafeTTeleporter {
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param temeporter Person who performed the teleport command.
* @param teleporter Person who performed the teleport command.
* @param teleportee Entity to teleport
* @param d Destination to teleport them to
*
@ -229,7 +216,7 @@ public class SafeTTeleporter {
* see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param temeporter Person who issued the teleport command.
* @param teleporter Person who issued the teleport command.
* @param teleportee Entity to teleport.
* @param location Location to teleport them to.
* @param safely Should the destination be checked for safety before teleport?
@ -297,4 +284,44 @@ public class SafeTTeleporter {
return null;
}
public static Location findPortalBlockNextTo(Location l) {
Block b = l.getWorld().getBlockAt(l);
Location foundLocation = null;
if (b.getRelative(BlockFace.NORTH).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.NORTH).getLocation(), foundLocation);
}
if (b.getRelative(BlockFace.SOUTH).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.SOUTH).getLocation(), foundLocation);
}
if (b.getRelative(BlockFace.EAST).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.EAST).getLocation(), foundLocation);
}
if (b.getRelative(BlockFace.WEST).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.WEST).getLocation(), foundLocation);
}
return foundLocation;
}
private static Location getCloserBlock(Location source, Location blockA, Location blockB) {
// If B wasn't given, return a.
if (blockB == null) {
return blockA;
}
// Center our calculations
blockA.add(.5,0,.5);
blockB.add(.5,0,.5);
// Retrieve the distance to the normalized blocks
double testA = source.distance(blockA);
double testB = source.distance(blockB);
// Compare and return
if(testA <= testB) {
return blockA;
}
return blockB;
}
}

View File

@ -47,7 +47,7 @@ public class WorldManager implements MVWorldManager {
this.worldPurger = new PurgeWorlds(this.plugin);
}
/** {@inheritDoc} */
public boolean addWorld(String name, Environment env, String seedString, String generator) {
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
Long seed = null;
@ -80,8 +80,14 @@ public class WorldManager implements MVWorldManager {
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env);
}
}
world = c.createWorld();
try {
world = c.createWorld();
} catch (Exception e) {
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors!");
this.plugin.log(Level.SEVERE, "Try using Chukster to repair your world! '" + name + "'");
this.plugin.log(Level.SEVERE, "http://forums.bukkit.org/threads/admin-chunkster.8186/");
return false;
}
if (world == null) {
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
@ -106,7 +112,7 @@ public class WorldManager implements MVWorldManager {
return plugin != null && plugin.isEnabled();
}
/** {@inheritDoc} */
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
if (generator == null) {
return null;
@ -142,6 +148,7 @@ public class WorldManager implements MVWorldManager {
return false;
}
/** {@inheritDoc} */
public boolean unloadWorld(String name) {
if (this.worlds.containsKey(name)) {
@ -158,6 +165,7 @@ public class WorldManager implements MVWorldManager {
return false;
}
/** {@inheritDoc} */
public boolean loadWorld(String name) {
// Check if the World is already loaded
if (this.worlds.containsKey(name)) {
@ -182,13 +190,12 @@ public class WorldManager implements MVWorldManager {
}
}
/** {@inheritDoc} */
public Boolean deleteWorld(String name) {
if (this.plugin.getServer().getWorld(name) != null) {
if (!unloadWorldFromBukkit(name, false)) {
// If the world was loaded, and we couldn't unload it, return false. DON"T DELTEE
return false;
}
if (this.plugin.getServer().getWorld(name) == null) {
// We can only delete loaded worlds
return false;
}
removeWorldFromConfig(name);
try {
@ -212,6 +219,7 @@ public class WorldManager implements MVWorldManager {
this.plugin.log(Level.SEVERE, "rm " + worldFile.getAbsolutePath());
return false;
}
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
boolean deletedWorld = FileUtils.deleteFolder(worldFile);
if (deletedWorld) {
this.plugin.log(Level.INFO, "World " + name + " was DELETED.");
@ -244,6 +252,7 @@ public class WorldManager implements MVWorldManager {
return this.plugin.getServer().unloadWorld(name, safely);
}
/** {@inheritDoc} */
public void removePlayersFromWorld(String name) {
World w = this.plugin.getServer().getWorld(name);
if (w != null) {
@ -257,22 +266,12 @@ public class WorldManager implements MVWorldManager {
}
}
/**
* Returns a list of all the worlds Multiverse knows about.
*
* @return A list of {@link MVWorld}.
*/
/** {@inheritDoc} */
public Collection<MultiverseWorld> getMVWorlds() {
return this.worlds.values();
}
/**
* Returns a {@link MVWorld} if it exists, and null if it does not. This will search name AND alias.
*
* @param name The name or alias of the world to get.
*
* @return A {@link MVWorld} or null.
*/
/** {@inheritDoc} */
@Override
public MultiverseWorld getMVWorld(String name) {
if (this.worlds.containsKey(name)) {
@ -281,6 +280,7 @@ public class WorldManager implements MVWorldManager {
return this.getMVWorldByAlias(name);
}
/** {@inheritDoc} */
@Override
public MultiverseWorld getMVWorld(World world) {
if (world != null) {
@ -305,25 +305,13 @@ public class WorldManager implements MVWorldManager {
return null;
}
/**
* Checks to see if the given name is a valid {@link MVWorld}
*
* @param name The name or alias of the world to check.
*
* @return True if the world exists, false if not.
*/
/** {@inheritDoc} */
@Override
public boolean isMVWorld(String name) {
return (this.worlds.containsKey(name) || isMVWorldAlias(name));
}
/**
* Checks to see if the given world is a valid {@link MultiverseWorld}
*
* @param world The Bukkit world to check.
*
* @return True if the world has been loaded into MV2, false if not.
*/
/** {@inheritDoc} */
@Override
public boolean isMVWorld(World world) {
return world != null && this.isMVWorld(world.getName());
@ -345,11 +333,7 @@ public class WorldManager implements MVWorldManager {
return false;
}
/**
* Load the Worlds & Settings from the configuration file.
*
* @param forceLoad If set to true, this will perform a total reset and not just load new worlds.
*/
/** {@inheritDoc} */
public void loadWorlds(boolean forceLoad) {
// Basic Counter to count how many Worlds we are loading.
int count = 0;
@ -415,11 +399,7 @@ public class WorldManager implements MVWorldManager {
this.plugin.log(Level.INFO, count + " - World(s) loaded.");
}
/**
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
*/
/** {@inheritDoc} */
public PurgeWorlds getWorldPurger() {
return this.worldPurger;
}
@ -436,11 +416,13 @@ public class WorldManager implements MVWorldManager {
return this.configWorlds;
}
public void saveWorldsConfig() {
public boolean saveWorldsConfig() {
try {
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
return true;
} catch (IOException e) {
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings.");
return false;
}
}