Add firstworldspawn, safe spawn disabling, fix a few neat bugs.
This commit is contained in:
parent
8164f484dd
commit
fc24062f66
2
pom.xml
2
pom.xml
|
@ -170,7 +170,7 @@
|
|||
<!-- Start of Spout -->
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutapi</artifactId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- End of Spout -->
|
||||
|
|
|
@ -61,7 +61,7 @@ public class MVWorld implements MultiverseWorld {
|
|||
private boolean canSave = false; // Prevents all the setters from constantly saving to the config when being called from the constructor.
|
||||
private Map<String, String> propertyAliases;
|
||||
|
||||
public MVWorld(World world, FileConfiguration config, MultiverseCore instance, Long seed, String generatorString) {
|
||||
public MVWorld(World world, FileConfiguration config, MultiverseCore instance, Long seed, String generatorString, boolean fixSpawn) {
|
||||
this.config = config;
|
||||
this.plugin = instance;
|
||||
|
||||
|
@ -111,6 +111,9 @@ public class MVWorld implements MultiverseWorld {
|
|||
this.propertyList.put("hunger", fac.getNewProperty("hunger", true, "Sorry, 'hunger' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("autoheal", fac.getNewProperty("autoheal", true, "Sorry, 'autoheal' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true, "Sorry, 'adjustspawn' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
if(!fixSpawn) {
|
||||
this.setAdjustSpawn(false);
|
||||
}
|
||||
this.propertyList.put("gamemode", fac.getNewProperty("gamemode", GameMode.SURVIVAL, "GameMode must be set as one of the following: " + ChatColor.RED + "survival " + ChatColor.GREEN + "creative "));
|
||||
this.propertyList.put("memory", fac.getNewProperty("keepspawninmemory", true, "keepspawninmemory", "Sorry, 'memory' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("spawn", fac.getNewProperty("spawn", this.world.getSpawnLocation(), "There is no help available for this variable. Go bug Rigby90 about it."));
|
||||
|
|
|
@ -50,7 +50,7 @@ import java.util.logging.Logger;
|
|||
* The implementation of the Multiverse-{@link Core}.
|
||||
*/
|
||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private final static int Protocol = 9;
|
||||
private final static int Protocol = 10;
|
||||
// Global Multiverse config variable, states whether or not
|
||||
// Multiverse should stop other plugins from teleporting players
|
||||
// to worlds.
|
||||
|
@ -282,11 +282,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
*/
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
|
||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, this.playerListener, Priority.Highest, this); // Cancel Teleports if needed.
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Priority.Normal, this); // To create the Player Session
|
||||
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_LOGIN, 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.Lowest, this); // To switch gamemode
|
||||
pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, this.playerListener, Priority.Monitor, this); // To switch gamemode
|
||||
|
@ -324,11 +324,27 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
EnforceGameModes = this.multiverseConfig.getBoolean("enforcegamemodes", true);
|
||||
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
|
||||
DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
|
||||
// Default as the server.props world.
|
||||
this.worldManager.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld", getDefaultWorldName()));
|
||||
DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
|
||||
this.messaging = new MVMessaging(this);
|
||||
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000));
|
||||
this.saveMVConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely return a world name
|
||||
* (The tests call this with no worlds loaded)
|
||||
*
|
||||
* @return The default world name.
|
||||
*/
|
||||
private String getDefaultWorldName() {
|
||||
if (this.getServer().getWorlds().size() > 0) {
|
||||
return this.getServer().getWorlds().get(0).getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -15,8 +15,6 @@ import org.bukkit.util.Vector;
|
|||
/**
|
||||
* A destination API for Multiverse
|
||||
* Any plugin can add these to MV and when they are, any action that uses them (portals, MVTP, etc.) can use them!
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public interface MVDestination {
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,20 @@ public interface MVWorldManager {
|
|||
*/
|
||||
public boolean addWorld(String name, Environment env, String seedString, 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 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.
|
||||
*/
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config and deletes the folder.
|
||||
|
@ -196,4 +210,18 @@ public interface MVWorldManager {
|
|||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean removeWorldFromConfig(String name);
|
||||
|
||||
/**
|
||||
* Sets the initial spawn world for new players.
|
||||
*
|
||||
* @param world The World new players should spawn in.
|
||||
*/
|
||||
public void setFirstSpawnWorld(String world);
|
||||
|
||||
/**
|
||||
* Gets the world players should spawn in first.
|
||||
*
|
||||
* @return The {@link MultiverseWorld} new players should spawn in.
|
||||
*/
|
||||
public MultiverseWorld getFirstSpawnWorld();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,11 @@ public class ConfigCommand extends MultiverseCommand {
|
|||
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")) {
|
||||
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
|
||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
|
||||
// Don't forget to set the world!
|
||||
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
|
||||
} else 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)));
|
||||
} catch (NumberFormatException e) {
|
||||
|
|
|
@ -25,8 +25,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]]");
|
||||
this.setArgRange(2, 6);
|
||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] [-n]");
|
||||
this.setArgRange(2, 7);
|
||||
this.addKey("mvcreate");
|
||||
this.addKey("mvc");
|
||||
this.addKey("mv create");
|
||||
|
@ -41,16 +41,17 @@ public class CreateCommand extends MultiverseCommand {
|
|||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() % 2 != 0) {
|
||||
sender.sendMessage("You must preface your SEED with -s OR your GENERATOR with -g. Type /mv for help");
|
||||
return;
|
||||
}
|
||||
String worldName = args.get(0);
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
String env = args.get(1);
|
||||
String seed = CommandHandler.getFlag("-s", args);
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
|
||||
boolean useSpawnAdjust = true;
|
||||
for(String s : args) {
|
||||
if(s.equalsIgnoreCase("-n")) {
|
||||
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");
|
||||
|
@ -66,7 +67,7 @@ public class CreateCommand extends MultiverseCommand {
|
|||
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, generator)) {
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, generator, useSpawnAdjust)) {
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, "FAILED.");
|
||||
|
|
|
@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.commands;
|
|||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -28,7 +29,7 @@ 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 + "[GENERATOR[:ID]]");
|
||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n]");
|
||||
this.setArgRange(1, 3);
|
||||
this.addKey("mvimport");
|
||||
this.addKey("mvim");
|
||||
|
@ -97,24 +98,35 @@ public class ImportCommand extends MultiverseCommand {
|
|||
|
||||
if (worldName.toLowerCase().equals("--list") || worldName.toLowerCase().equals("-l")) {
|
||||
String worldList = this.getPotentialWorlds();
|
||||
sender.sendMessage(ChatColor.AQUA + "====[ These look like worlds ]====");
|
||||
sender.sendMessage(worldList);
|
||||
if (worldList.length() > 2) {
|
||||
sender.sendMessage(ChatColor.AQUA + "====[ These look like worlds ]====");
|
||||
sender.sendMessage(worldList);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No potential worlds found. Sorry!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Since we made an exception for the list, we have to make sure they have at least 2 params:
|
||||
// Note the exception is --list, which is covered above.
|
||||
if (args.size() == 1) {
|
||||
this.showHelp(sender);
|
||||
return;
|
||||
}
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
if (this.worldManager.isMVWorld(worldName) && worldFile.exists()) {
|
||||
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
|
||||
|
||||
// Make sure we don't already know about this world.
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Multiverse" + ChatColor.WHITE + " already knows about '" + ChatColor.AQUA + worldName + ChatColor.WHITE + "'!");
|
||||
return;
|
||||
}
|
||||
|
||||
String generator = null;
|
||||
if (args.size() == 3) {
|
||||
generator = args.get(2);
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for(String s : args) {
|
||||
if(s.equalsIgnoreCase("-n")) {
|
||||
useSpawnAdjust = false;
|
||||
}
|
||||
}
|
||||
|
||||
String env = args.get(1);
|
||||
|
@ -127,7 +139,7 @@ public class ImportCommand extends MultiverseCommand {
|
|||
|
||||
if (worldFile.exists() && env != null) {
|
||||
Command.broadcastCommandMessage(sender, "Starting import of world '" + worldName + "'...");
|
||||
this.worldManager.addWorld(worldName, environment, null, generator);
|
||||
this.worldManager.addWorld(worldName, environment, null, generator, useSpawnAdjust);
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
} else if (env == null) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
public enum ConfigProperty {
|
||||
messagecooldown, teleportcooldown, worldnameprefix, enforcegamemodes, enforceaccess, displaypermerrors, debug;
|
||||
|
||||
messagecooldown, teleportcooldown, worldnameprefix, enforcegamemodes, enforceaccess, displaypermerrors, debug, firstworldspawn;
|
||||
|
||||
public static String getAllValues() {
|
||||
String buffer = "";
|
||||
|
|
|
@ -16,8 +16,6 @@ import org.bukkit.event.Event;
|
|||
|
||||
/**
|
||||
* Event that gets called when a player use the /mvtp command.
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public class MVTeleportEvent extends Event implements Cancellable {
|
||||
private Player teleportee;
|
||||
|
|
|
@ -13,21 +13,12 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
|||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -70,6 +61,8 @@ public class MVPlayerListener extends PlayerListener {
|
|||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
|
||||
|
||||
World world = event.getPlayer().getWorld();
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
// If it's not a World MV manages we stop.
|
||||
|
@ -77,6 +70,7 @@ public class MVPlayerListener extends PlayerListener {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (mvWorld.getBedRespawn() && event.isBedSpawn()) {
|
||||
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
|
||||
return;
|
||||
|
@ -111,11 +105,15 @@ public class MVPlayerListener extends PlayerListener {
|
|||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (this.worldManager.getMVWorlds().size() == 0 && this.plugin.getMVPerms().hasPermission(event.getPlayer(), "multiverse.core.import", true)) {
|
||||
event.getPlayer().sendMessage("You don't have any worlds imported into Multiverse!");
|
||||
event.getPlayer().sendMessage("You can import your current worlds with " + ChatColor.AQUA + "/mvimport");
|
||||
event.getPlayer().sendMessage("or you can create new ones with " + ChatColor.GOLD + "/mvcreate");
|
||||
event.getPlayer().sendMessage("If you just wanna see all of the Multiverse Help, type: " + ChatColor.GREEN + "/mv");
|
||||
Player p = event.getPlayer();
|
||||
if (!p.hasPlayedBefore()) {
|
||||
this.plugin.log(Level.WARNING, "Player joined first!");
|
||||
this.plugin.log(Level.WARNING, "Loc: " + worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||
// This will override other spawn plugins atm :(
|
||||
this.spawnNewPlayer(p);
|
||||
return;
|
||||
} else {
|
||||
this.plugin.log(Level.WARNING, "Player joined AGAIN!");
|
||||
}
|
||||
// Handle the Players GameMode setting for the new world.
|
||||
if (MultiverseCore.EnforceGameModes) {
|
||||
|
@ -127,6 +125,8 @@ public class MVPlayerListener extends PlayerListener {
|
|||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
||||
// Handle the Players GameMode setting for the new world.
|
||||
if (MultiverseCore.EnforceGameModes) {
|
||||
// Not yet implemented, but eventually we'll switch to this!
|
||||
//if (this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld()).getEnforceGameMode())
|
||||
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,10 @@ public class MVPlayerListener extends PlayerListener {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void spawnNewPlayer(Player player) {
|
||||
// Spawn the player 1 tick after the login. I'm sure there's GOT to be a better way to do this...
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new SpawnNewbie(player, this.plugin.getMVWorldManager().getFirstSpawnWorld().getSpawnLocation()), 1L);
|
||||
}
|
||||
// FOLLOWING 2 Methods and Private class handle Per Player GameModes.
|
||||
private void handleGameMode(Player player, World world) {
|
||||
this.plugin.log(Level.FINE, "Handeling gamemode for player: " + player.getName());
|
||||
|
@ -229,7 +232,21 @@ public class MVPlayerListener extends PlayerListener {
|
|||
public void handleGameMode(Player player, MultiverseWorld world) {
|
||||
// We perform this task one tick later to MAKE SURE that the player actually reaches the
|
||||
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new HandleGameMode(player, world), 1L);
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new HandleGameMode(player, world), 1L);
|
||||
}
|
||||
|
||||
private class SpawnNewbie implements Runnable {
|
||||
private Player player;
|
||||
private Location spawn;
|
||||
|
||||
private SpawnNewbie(Player player, Location spawn) {
|
||||
this.player = player;
|
||||
this.spawn = spawn;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
this.player.teleport(this.spawn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,16 +9,9 @@ package com.onarandombox.MultiverseCore.utils;
|
|||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +25,12 @@ public class PurgeWorlds {
|
|||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/** Synchronizes the given world with it's settings. */
|
||||
/**
|
||||
* Synchronizes the given world with it's settings.
|
||||
*
|
||||
* @param sender The {@link CommandSender} who is requesting the world be purged.
|
||||
* @param worlds A list of {@link MultiverseWorld}
|
||||
*/
|
||||
public void purgeWorlds(CommandSender sender, List<MultiverseWorld> worlds) {
|
||||
if (worlds == null || worlds.isEmpty()) {
|
||||
return;
|
||||
|
@ -110,7 +108,6 @@ public class PurgeWorlds {
|
|||
* @param e
|
||||
* @param creaturesToKill
|
||||
* @param negate
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean killMonster(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
|
||||
|
|
|
@ -26,19 +26,11 @@ import org.bukkit.plugin.Plugin;
|
|||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Public facing API to add/remove Multiverse worlds.
|
||||
*
|
||||
* @author fernferret, Rigby90
|
||||
*/
|
||||
public class WorldManager implements MVWorldManager {
|
||||
private MultiverseCore plugin;
|
||||
|
@ -47,6 +39,7 @@ public class WorldManager implements MVWorldManager {
|
|||
private List<String> unloadedWorlds;
|
||||
private FileConfiguration configWorlds = null;
|
||||
private Map<String, String> defaultGens;
|
||||
private String firstSpawn;
|
||||
|
||||
public WorldManager(MultiverseCore core) {
|
||||
this.plugin = core;
|
||||
|
@ -83,6 +76,14 @@ public class WorldManager implements MVWorldManager {
|
|||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator) {
|
||||
return this.addWorld(name, env, seedString, 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);
|
||||
Long seed = null;
|
||||
WorldCreator c = new WorldCreator(name);
|
||||
|
@ -130,7 +131,7 @@ public class WorldManager implements MVWorldManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, this.plugin.getServer().getWorld(name).getSeed(), generator);
|
||||
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, this.plugin.getServer().getWorld(name).getSeed(), generator, useSpawnAdjust);
|
||||
this.worldPurger.purgeWorld(null, mvworld);
|
||||
this.worlds.put(name, mvworld);
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
|
@ -192,6 +193,32 @@ public class WorldManager implements MVWorldManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setFirstSpawnWorld(String world) {
|
||||
if (world == null) {
|
||||
this.firstSpawn = this.plugin.getServer().getWorlds().get(0).getName();
|
||||
} else {
|
||||
this.firstSpawn = world;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MultiverseWorld getFirstSpawnWorld() {
|
||||
MultiverseWorld world = this.getMVWorld(this.firstSpawn);
|
||||
if (world == null) {
|
||||
// If the spawn world was unloaded, get the default world
|
||||
this.plugin.log(Level.WARNING, "The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
|
||||
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -498,7 +525,7 @@ public class WorldManager implements MVWorldManager {
|
|||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", null);
|
||||
if(seedString == null) {
|
||||
if (seedString == null) {
|
||||
seedString = this.configWorlds.getLong("worlds." + worldKey + ".seed") + "";
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,6 @@ public class TestWorldStuff {
|
|||
|
||||
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "blah", "fish", "world" });
|
||||
verify(mockCommandSender).sendMessage(ChatColor.RED + "Sorry, You can't set: '"+ChatColor.GRAY+ "blah" + ChatColor.RED + "'");
|
||||
|
||||
}
|
||||
|
||||
private void createInitialWorlds(Plugin plugin, Command command) {
|
||||
|
|
|
@ -16,8 +16,7 @@ import java.util.logging.LogRecord;
|
|||
|
||||
/**
|
||||
* Formatter to format log-messages in tests
|
||||
*
|
||||
* @author main()
|
||||
*
|
||||
*/
|
||||
public class MVTestLogFormatter extends Formatter {
|
||||
private static final DateFormat df = new SimpleDateFormat("HH:mm:ss");
|
||||
|
@ -40,4 +39,4 @@ public class MVTestLogFormatter extends Formatter {
|
|||
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ import org.bukkit.block.*;
|
|||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public class MockBlock implements Block{
|
||||
private Material type;
|
||||
|
|
Loading…
Reference in New Issue