mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
parent
7f93eedbac
commit
0f3fd89228
2
pom.xml
2
pom.xml
@ -162,7 +162,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.0.0-R1-SNAPSHOT</version>
|
||||
<version>1.1-R1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -23,6 +23,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -68,6 +69,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
private Permission ignoreperm;
|
||||
|
||||
private static final Map<String, String> TIME_ALIASES;
|
||||
private WorldType type;
|
||||
|
||||
static {
|
||||
Map<String, String> staticTimes = new HashMap<String, String>();
|
||||
@ -90,6 +92,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.name = world.getName();
|
||||
this.seed = seed;
|
||||
this.environment = world.getEnvironment();
|
||||
this.type = world.getWorldType();
|
||||
|
||||
// Initialize our lists
|
||||
this.initLists();
|
||||
@ -107,6 +110,8 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
worldSection.set("environment", this.environment.toString());
|
||||
|
||||
worldSection.set("type", this.type.toString());
|
||||
|
||||
// Start NEW config awesomeness.
|
||||
ConfigPropertyFactory fac = new ConfigPropertyFactory(this.worldSection);
|
||||
this.propertyList = new HashMap<String, MVConfigProperty<?>>();
|
||||
@ -1145,6 +1150,14 @@ public class MVWorld implements MultiverseWorld {
|
||||
return String.format("%d:%02d", hours, minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active time-property to set the "actual" property.
|
||||
* @return True if the property was successfully set.
|
||||
|
@ -38,7 +38,6 @@ import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
@ -582,33 +581,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return MultiverseCore.LOG_TAG;
|
||||
}
|
||||
|
||||
// TODO This code should get moved somewhere more appropriate, but for now, it's here.
|
||||
// TODO oh, and it should be static.
|
||||
/**
|
||||
* Converts a {@link String} into an {@link Environment}.
|
||||
*
|
||||
* @param env The environment as {@link String}
|
||||
* @return The environment as {@link Environment}
|
||||
*/
|
||||
public Environment getEnvFromString(String env) {
|
||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
||||
env = "NETHER";
|
||||
|
||||
if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS"))
|
||||
env = "THE_END";
|
||||
|
||||
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
|
||||
env = "NORMAL";
|
||||
|
||||
try {
|
||||
// If the value wasn't found, maybe it's new, try checking the enum directly.
|
||||
return Environment.valueOf(env);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a message that the given world is not a MultiverseWorld.
|
||||
*
|
||||
|
@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.api;
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
@ -32,10 +33,11 @@ public interface MVWorldManager {
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, String generator);
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator);
|
||||
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
@ -45,11 +47,12 @@ public interface MVWorldManager {
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, String generator, boolean useSpawnAdjust);
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
@ -22,8 +23,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* The API for a Multiverse Handled World.
|
||||
* <p>
|
||||
* Currently INCOMPLETE
|
||||
*/
|
||||
public interface MultiverseWorld {
|
||||
|
||||
@ -536,7 +535,7 @@ public interface MultiverseWorld {
|
||||
|
||||
/**
|
||||
* Sets the current time in a world.
|
||||
*
|
||||
* <p>
|
||||
* This method will take the following formats:
|
||||
* 11:37am
|
||||
* 4:30p
|
||||
@ -552,4 +551,14 @@ public interface MultiverseWorld {
|
||||
* @return The time as a short string: 12:34pm
|
||||
*/
|
||||
String getTime();
|
||||
|
||||
/**
|
||||
* Gets the type of this world. As of 1.1-R1 this will be:
|
||||
* FLAT or NORMAL
|
||||
* <p>
|
||||
* This is *not* the generator.
|
||||
*
|
||||
* @return The Type of this world.
|
||||
*/
|
||||
WorldType getWorldType();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@ -28,7 +29,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Create World");
|
||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] [-n]");
|
||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n]");
|
||||
this.setArgRange(2, 7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvcreate");
|
||||
this.addKey("mvc");
|
||||
@ -49,6 +50,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
String env = args.get(1);
|
||||
String seed = CommandHandler.getFlag("-s", args);
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase("-n")) {
|
||||
@ -61,16 +63,27 @@ public class CreateCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Environment environment = this.plugin.getEnvFromString(env);
|
||||
Environment environment = EnvironmentCommand.getEnvFromString(env);
|
||||
if (environment == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// If they didn't specify a type, default to NORMAL
|
||||
if (typeString == null) {
|
||||
typeString = "NORMAL";
|
||||
}
|
||||
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, generator, useSpawnAdjust)) {
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, generator, useSpawnAdjust)) {
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, "FAILED.");
|
||||
|
@ -9,6 +9,8 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
@ -26,10 +28,11 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvenv");
|
||||
this.addKey("mv env");
|
||||
this.addKey("mv type");
|
||||
this.addKey("mv environment");
|
||||
this.addKey("mv environments");
|
||||
this.addCommandExample("/mv env");
|
||||
this.setPermission("multiverse.core.list.environments", "Lists valid known environments.", PermissionDefault.OP);
|
||||
this.setPermission("multiverse.core.list.environments", "Lists valid known environments/world types.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,9 +46,67 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
sender.sendMessage(ChatColor.RED + "NETHER");
|
||||
sender.sendMessage(ChatColor.AQUA + "END");
|
||||
}
|
||||
/**
|
||||
* Shows all valid known world types to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
public static void showWorldTypes(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
|
||||
sender.sendMessage(String.format("%sNORMAL %sor %sFLAT",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link String} into a {@link WorldType}.
|
||||
*
|
||||
* @param type The WorldType as a {@link String}
|
||||
* @return The WorldType as a {@link WorldType}
|
||||
*/
|
||||
public static WorldType getWorldTypeFromString(String type) {
|
||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||
if (type.equalsIgnoreCase("normal"))
|
||||
type = "NORMAL";
|
||||
if (type.equalsIgnoreCase("flat"))
|
||||
type = "FLAT";
|
||||
try {
|
||||
// Now that we've converted a potentially unfriendly value
|
||||
// to a friendly one, get it from the ENUM!
|
||||
return WorldType.valueOf(type);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link String} into an {@link org.bukkit.World.Environment}.
|
||||
*
|
||||
* @param env The environment as {@link String}
|
||||
* @return The environment as {@link org.bukkit.World.Environment}
|
||||
*/
|
||||
public static World.Environment getEnvFromString(String env) {
|
||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
||||
env = "NETHER";
|
||||
|
||||
if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS"))
|
||||
env = "THE_END";
|
||||
|
||||
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
|
||||
env = "NORMAL";
|
||||
|
||||
try {
|
||||
// Now that we've converted a potentially unfriendly value
|
||||
// to a friendly one, get it from the ENUM!
|
||||
return World.Environment.valueOf(env);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@ -126,6 +127,7 @@ public class ImportCommand extends MultiverseCommand {
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase("-n")) {
|
||||
@ -134,16 +136,27 @@ public class ImportCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
String env = args.get(1);
|
||||
Environment environment = this.plugin.getEnvFromString(env);
|
||||
Environment environment = EnvironmentCommand.getEnvFromString(env);
|
||||
if (environment == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
|
||||
EnvironmentCommand.showEnvironments(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// If they didn't specify a type, default to NORMAL
|
||||
if (typeString == null) {
|
||||
typeString = "NORMAL";
|
||||
}
|
||||
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldFile.exists() && env != null) {
|
||||
Command.broadcastCommandMessage(sender, "Starting import of world '" + worldName + "'...");
|
||||
if (this.worldManager.addWorld(worldName, environment, null, generator, useSpawnAdjust))
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
|
||||
if (this.worldManager.addWorld(worldName, environment, null, type, generator, useSpawnAdjust))
|
||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
|
||||
else
|
||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
|
||||
|
@ -11,10 +11,12 @@ import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -80,16 +82,16 @@ public class WorldManager implements MVWorldManager {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator) {
|
||||
return this.addWorld(name, env, seedString, generator, true);
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator) {
|
||||
return this.addWorld(name, env, seedString, type, generator, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator, boolean useSpawnAdjust) {
|
||||
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust) {
|
||||
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + type.toString() + ", " + generator);
|
||||
Long seed = null;
|
||||
WorldCreator c = new WorldCreator(name);
|
||||
if (seedString != null && seedString.length() > 0) {
|
||||
@ -101,27 +103,26 @@ public class WorldManager implements MVWorldManager {
|
||||
c.seed(seed);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Use the fancy kind with the commandSender
|
||||
if (generator != null && generator.length() != 0) {
|
||||
c.generator(generator);
|
||||
}
|
||||
c.environment(env);
|
||||
c.type(type);
|
||||
|
||||
World world = null;
|
||||
World world;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Loading World & Settings - '").append(name).append("'");
|
||||
builder.append(" - Env: ").append(env);
|
||||
builder.append(" - Type: ").append(type);
|
||||
if (seed != null) {
|
||||
if (generator != null) {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed + " & Custom Generator: " + generator);
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed);
|
||||
}
|
||||
} else {
|
||||
if (generator != null) {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " & Custom Generator: " + generator);
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env);
|
||||
}
|
||||
builder.append(" & seed: ").append(seed);
|
||||
}
|
||||
if (generator != null) {
|
||||
builder.append(" & generator: ").append(generator);
|
||||
}
|
||||
this.plugin.log(Level.INFO, builder.toString());
|
||||
|
||||
try {
|
||||
world = c.createWorld();
|
||||
} catch (Exception e) {
|
||||
@ -275,10 +276,12 @@ public class WorldManager implements MVWorldManager {
|
||||
if ((worldKeys != null) && (worldKeys.contains(name))) {
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + name + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String type = this.configWorlds.getString("worlds." + name + ".type", "NORMAL");
|
||||
String seedString = this.configWorlds.getString("worlds." + name + ".seed", "");
|
||||
String generatorString = this.configWorlds.getString("worlds." + name + ".generator");
|
||||
|
||||
addWorld(name, this.plugin.getEnvFromString(environment), seedString, generatorString);
|
||||
addWorld(name, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generatorString);
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
this.unloadedWorlds.remove(name);
|
||||
}
|
||||
@ -464,9 +467,9 @@ public class WorldManager implements MVWorldManager {
|
||||
String name = w.getName();
|
||||
if (!worldStrings.contains(name)) {
|
||||
if (this.defaultGens.containsKey(name)) {
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", this.defaultGens.get(name));
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(), this.defaultGens.get(name));
|
||||
} else {
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", null);
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(), null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -537,7 +540,8 @@ public class WorldManager implements MVWorldManager {
|
||||
continue;
|
||||
}
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL");
|
||||
String type = this.configWorlds.getString("worlds." + worldKey + ".type", "NORMAL");
|
||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", null);
|
||||
if (seedString == null) {
|
||||
seedString = this.configWorlds.getLong("worlds." + worldKey + ".seed") + "";
|
||||
@ -548,7 +552,9 @@ public class WorldManager implements MVWorldManager {
|
||||
this.plugin.log(Level.WARNING, "Found SKYLANDS world. Not importing automatically, as it won't work atm :(");
|
||||
continue;
|
||||
}
|
||||
addWorld(worldKey, this.plugin.getEnvFromString(environment), seedString, generatorString);
|
||||
// TODO: UNCOMMENT BEFORE RELEASE
|
||||
addWorld(worldKey, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generatorString);
|
||||
|
||||
// Increment the world count
|
||||
count++;
|
||||
|
@ -19,6 +19,7 @@ import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Matchers;
|
||||
@ -81,10 +82,11 @@ public class MockWorldFactory {
|
||||
createdWorlds.put(world.getName(), world);
|
||||
}
|
||||
|
||||
private static World basics(String world, World.Environment env) {
|
||||
private static World basics(String world, World.Environment env, WorldType type) {
|
||||
World mockWorld = mock(World.class);
|
||||
when(mockWorld.getName()).thenReturn(world);
|
||||
when(mockWorld.getEnvironment()).thenReturn(env);
|
||||
when(mockWorld.getWorldType()).thenReturn(type);
|
||||
when(mockWorld.getSpawnLocation()).thenReturn(new Location(mockWorld, 0, 0, 0));
|
||||
when(mockWorld.getWorldFolder()).thenAnswer(new Answer<File>() {
|
||||
public File answer(InvocationOnMock invocation) throws Throwable {
|
||||
@ -101,15 +103,15 @@ public class MockWorldFactory {
|
||||
return mockWorld;
|
||||
}
|
||||
|
||||
public static World makeNewMockWorld(String world, World.Environment env) {
|
||||
World w = basics(world, env);
|
||||
public static World makeNewMockWorld(String world, World.Environment env, WorldType type) {
|
||||
World w = basics(world, env, type);
|
||||
registerWorld(w);
|
||||
return w;
|
||||
}
|
||||
|
||||
public static World makeNewMockWorld(String world, World.Environment env, long seed,
|
||||
public static World makeNewMockWorld(String world, World.Environment env, WorldType type, long seed,
|
||||
ChunkGenerator generator) {
|
||||
World mockWorld = basics(world, env);
|
||||
World mockWorld = basics(world, env, type);
|
||||
when(mockWorld.getGenerator()).thenReturn(generator);
|
||||
when(mockWorld.getSeed()).thenReturn(seed);
|
||||
registerWorld(mockWorld);
|
||||
|
@ -122,7 +122,7 @@ public class TestInstanceCreator {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return MockWorldFactory.makeNewMockWorld(arg.name(), arg.environment());
|
||||
return MockWorldFactory.makeNewMockWorld(arg.name(), arg.environment(), arg.type());
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user