mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Allow generate-structures to be used per world
This commit is contained in:
parent
7aca740296
commit
87d4d4e1f4
@ -30,31 +30,35 @@ public interface MVWorldManager {
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @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 name World Name
|
||||
* @param env Environment Type
|
||||
* @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 generateStructures If true, this world will get NPC villages.
|
||||
* @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, WorldType type, String generator);
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, boolean generateStructures,
|
||||
String generator);
|
||||
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @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 name World Name
|
||||
* @param env Environment Type
|
||||
* @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 generateStructures If true, this world will get NPC villages.
|
||||
* @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, WorldType type, String generator, boolean useSpawnAdjust);
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
|
@ -29,8 +29,8 @@ 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]] -t [WORLDTYPE] [-n]");
|
||||
this.setArgRange(2, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n] -a [true|false]");
|
||||
this.setArgRange(2, 11); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvcreate");
|
||||
this.addKey("mvc");
|
||||
this.addKey("mv create");
|
||||
@ -51,6 +51,11 @@ public class CreateCommand extends MultiverseCommand {
|
||||
String env = args.get(1);
|
||||
String seed = CommandHandler.getFlag("-s", args);
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
boolean allowStructures = true;
|
||||
String structureString = CommandHandler.getFlag("-a", args);
|
||||
if (structureString != null) {
|
||||
allowStructures = Boolean.parseBoolean(structureString);
|
||||
}
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
@ -58,6 +63,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
useSpawnAdjust = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||
@ -84,7 +90,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, generator, useSpawnAdjust)) {
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, "FAILED.");
|
||||
|
@ -33,8 +33,8 @@ public class ImportCommand extends MultiverseCommand {
|
||||
public ImportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Import World");
|
||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE]");
|
||||
this.setArgRange(1, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE] -a [true|false]");
|
||||
this.setArgRange(1, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvimport");
|
||||
this.addKey("mvim");
|
||||
this.addKey("mv import");
|
||||
@ -129,6 +129,11 @@ public class ImportCommand extends MultiverseCommand {
|
||||
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean allowStructures = true;
|
||||
String structureString = CommandHandler.getFlag("-a", args);
|
||||
if (structureString != null) {
|
||||
allowStructures = Boolean.parseBoolean(structureString);
|
||||
}
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase("-n")) {
|
||||
@ -157,7 +162,7 @@ public class ImportCommand extends MultiverseCommand {
|
||||
|
||||
if (worldFile.exists() && env != null) {
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
|
||||
if (this.worldManager.addWorld(worldName, environment, null, type, generator, useSpawnAdjust))
|
||||
if (this.worldManager.addWorld(worldName, environment, null, type, allowStructures, generator, useSpawnAdjust))
|
||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
|
||||
else
|
||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
|
||||
|
@ -109,7 +109,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
|
||||
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
|
||||
Location spawn = world.getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
|
||||
@ -135,7 +136,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
// Page 2
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("More World Settings", colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
|
||||
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
|
||||
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
|
||||
|
@ -84,15 +84,17 @@ public class WorldManager implements MVWorldManager {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator) {
|
||||
return this.addWorld(name, env, seedString, type, generator, true);
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, boolean generateStructures,
|
||||
String generator) {
|
||||
return this.addWorld(name, env, seedString, type, generateStructures, generator, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust) {
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, boolean generateStructures,
|
||||
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);
|
||||
@ -111,6 +113,7 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
c.environment(env);
|
||||
c.type(type);
|
||||
c.generateStructures(generateStructures);
|
||||
|
||||
World world;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@ -281,9 +284,10 @@ public class WorldManager implements MVWorldManager {
|
||||
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");
|
||||
boolean generateStructures = this.configWorlds.getBoolean("worlds." + name + ".generatestructures", true);
|
||||
|
||||
addWorld(name, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generatorString);
|
||||
this.addWorld(name, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generateStructures, generatorString);
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
this.unloadedWorlds.remove(name);
|
||||
}
|
||||
@ -469,9 +473,11 @@ 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() + "", w.getWorldType(), this.defaultGens.get(name));
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(),
|
||||
w.canGenerateStructures(), this.defaultGens.get(name));
|
||||
} else {
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(), null);
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(),
|
||||
w.canGenerateStructures(), null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -545,6 +551,7 @@ public class WorldManager implements MVWorldManager {
|
||||
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);
|
||||
boolean generateStructures = this.configWorlds.getBoolean("worlds." + worldKey + ".generatestructures", true);
|
||||
if (seedString == null) {
|
||||
seedString = this.configWorlds.getLong("worlds." + worldKey + ".seed") + "";
|
||||
}
|
||||
@ -554,9 +561,8 @@ public class WorldManager implements MVWorldManager {
|
||||
this.plugin.log(Level.WARNING, "Found SKYLANDS world. Not importing automatically, as it won't work atm :(");
|
||||
continue;
|
||||
}
|
||||
// TODO: UNCOMMENT BEFORE RELEASE
|
||||
addWorld(worldKey, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generatorString);
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generateStructures, generatorString);
|
||||
|
||||
// Increment the world count
|
||||
count++;
|
||||
|
Loading…
Reference in New Issue
Block a user