diff --git a/src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java b/src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java
index 4bac4134..87385267 100644
--- a/src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java
+++ b/src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java
@@ -43,10 +43,9 @@ import org.mvplugins.multiverse.core.inject.PluginInjection;
import org.mvplugins.multiverse.core.placeholders.MultiverseCorePlaceholders;
import org.mvplugins.multiverse.core.utils.TestingMode;
import org.mvplugins.multiverse.core.utils.metrics.MetricsConfigurator;
-import org.mvplugins.multiverse.core.world.WorldProperties;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.config.NullLocation;
-import org.mvplugins.multiverse.core.worldnew.config.SpawnLocation;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.config.NullLocation;
+import org.mvplugins.multiverse.core.world.config.SpawnLocation;
/**
* The implementation of the Multiverse-{@link MVCore}.
@@ -96,8 +95,9 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
}
// Register our config classes
- SerializationConfig.registerAll(WorldProperties.class);
SerializationConfig.initLogging(Logging.getLogger());
+ ConfigurationSerialization.registerClass(NullLocation.class);
+ ConfigurationSerialization.registerClass(SpawnLocation.class);
}
/**
@@ -106,8 +106,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
@Override
public void onEnable() {
initializeDependencyInjection();
- ConfigurationSerialization.registerClass(NullLocation.class);
- ConfigurationSerialization.registerClass(SpawnLocation.class);
// Load our configs first as we need them for everything else.
var config = configProvider.get();
diff --git a/src/main/java/org/mvplugins/multiverse/core/api/MVWorld.java b/src/main/java/org/mvplugins/multiverse/core/api/MVWorld.java
deleted file mode 100644
index f577b56b..00000000
--- a/src/main/java/org/mvplugins/multiverse/core/api/MVWorld.java
+++ /dev/null
@@ -1,676 +0,0 @@
-/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
- * Multiverse 2 is licensed under the BSD License. *
- * For more information please check the README.md file included *
- * with this project. *
- ******************************************************************************/
-
-package org.mvplugins.multiverse.core.api;
-
-import java.util.List;
-
-import org.bukkit.ChatColor;
-import org.bukkit.Difficulty;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.World;
-import org.bukkit.WorldType;
-import org.bukkit.permissions.Permission;
-import org.jetbrains.annotations.Nullable;
-
-import org.mvplugins.multiverse.core.exceptions.PropertyDoesNotExistException;
-import org.mvplugins.multiverse.core.world.configuration.AddProperties;
-import org.mvplugins.multiverse.core.world.configuration.AllowedPortalType;
-import org.mvplugins.multiverse.core.world.configuration.EnglishChatColor;
-
-/**
- * The API for a Multiverse Handled World.
- */
-public interface MVWorld {
- /**
- * Returns the Bukkit world object that this world describes.
- *
- * @return A {@link World}
- */
- World getCBWorld();
-
- /**
- * Gets the name of this world. The name cannot be changed.
- *
- * Note for plugin developers: Usually {@link #getAlias()}
- * is what you want to use instead of this method.
- *
- * @return The name of the world as a String.
- */
- String getName();
-
- /**
- * Gets the type of this world. As of 1.2 this will be:
- * FLAT, NORMAL or VERSION_1_1
- *
- * This is not the generator.
- *
- * @return The Type of this world.
- */
- WorldType getWorldType();
-
- /**
- * Gets the environment of this world.
- *
- * @return A {@link org.bukkit.World.Environment}.
- */
- World.Environment getEnvironment();
-
- /**
- * Sets the environment of a world.
- *
- * Note: This will ONLY take effect once the world is unloaded/reloaded.
- *
- * @param environment A {@link org.bukkit.World.Environment}.
- */
- void setEnvironment(World.Environment environment);
-
- /**
- * Gets the difficulty of this world.
- *
- * @return The difficulty of this world.
- */
- Difficulty getDifficulty();
-
- /**
- * Sets the difficulty of this world and returns true if success.
- * Valid string values are either an integer of difficulty(0-3) or
- * the name that resides in the Bukkit enum, ex. {@code PEACEFUL}
- *
- * @param difficulty The difficulty to set the world to as a string.
- * @return True if success, false if the provided string
- * could not be translated to a difficulty.
- * @deprecated Use {@link #setDifficulty(Difficulty)} or, if you have to
- * pass a string, use {@link #setPropertyValue(String, String)} instead.
- */
- @Deprecated
- boolean setDifficulty(String difficulty);
-
- /**
- * Sets the difficulty of this world and returns {@code true} on success.
- * Valid string values are either an integer of difficulty(0-3) or
- * the name that resides in the Bukkit enum, ex. PEACEFUL
- *
- * @param difficulty The new difficulty.
- * @return True if success, false if the operation failed... for whatever reason.
- */
- boolean setDifficulty(Difficulty difficulty);
-
- /**
- * Gets the world seed of this world.
- *
- * @return The Long version of the seed.
- */
- long getSeed();
-
- /**
- * Sets the seed of this world.
- *
- * @param seed A Long that is the seed.
- */
- void setSeed(long seed);
-
- /**
- * Gets the generator of this world.
- *
- * @return The name of the generator.
- */
- String getGenerator();
-
- /**
- * Sets the generator of this world.
- *
- * @param generator The new generator's name.
- */
- void setGenerator(String generator);
-
- /**
- * Gets the help-message for a property.
- * @param property The name of the property.
- * @return The help-message.
- * @throws PropertyDoesNotExistException Thrown if the property was not found.
- */
- String getPropertyHelp(String property) throws PropertyDoesNotExistException;
-
- /**
- * Gets a property as {@link String}.
- *
- * @param property The name of a world property to get.
- * @return The string-representation of that property.
- * @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
- */
- String getPropertyValue(String property) throws PropertyDoesNotExistException;
-
- /**
- * Sets a property to a given value.
- *
- * @param property The name of a world property to set.
- * @param value A value in string representation, it will be parsed to the correct type.
- * @return True if the value was set, false if not.
- * @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
- */
- boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
-
- /**
- * Adds a value to the given property. The property must be a {@link AddProperties}.
- *
- * @param property The name of a {@link AddProperties} to add a value to.
- * @param value A value in string representation, it will be parsed to the correct type.
- * @return True if the value was added, false if not.
- * @deprecated We changed the entire world-config-system. This is not compatible any more.
- */
- @Deprecated
- boolean addToVariable(String property, String value);
-
- /**
- * Removes a value from the given property. The property must be a {@link AddProperties}.
- *
- * @param property The name of a {@link AddProperties} to remove a value
- * from.
- * @param value A value in string representation, it will be parsed to the correct type.
- * @return True if the value was removed, false if not.
- * @deprecated We changed the entire world-config-system. This is not compatible any more.
- */
- @Deprecated
- boolean removeFromVariable(String property, String value);
-
- /**
- * Removes all values from the given property. The property must be a {@link AddProperties}.
- *
- * @param property The name of a {@link AddProperties} to clear.
- * @return True if it was cleared, false if not.
- * @deprecated We changed the entire world-config-system. This is not compatible any more.
- */
- @Deprecated
- boolean clearVariable(String property);
-
- /**
- * Clears a list property (sets it to []).
- *
- * @param property The property to clear.
- * @return True if success, false if fail.
- * @deprecated We changed the entire world-config-system. This is not compatible any more.
- */
- @Deprecated
- boolean clearList(String property);
- // end of old config stuff
-
- // permission stuff
- /**
- * Gets the lowercased name of the world. This method is required, since the permissables
- * lowercase all permissions when recalculating.
- *
- * Note: This also means if a user has worlds named: world and WORLD, that they can both
- * exist, and both be teleported to independently, but their permissions **cannot** be
- * uniqueified at this time. See bug report #.
- *
- * @return The lowercased name of the world.
- */
- String getPermissibleName();
-
- /**
- * Gets the permission required to enter this world.
- *
- * @return The permission required to be exempt from charges to/from this world.
- */
- Permission getAccessPermission();
-
- /**
- * Gets the permission required to be exempt when entering.
- *
- * @return The permission required to be exempt when entering.
- */
- Permission getExemptPermission();
- // end of permission stuff
-
- /**
- * Gets the alias of this world.
- *
- * This alias allows users to have a world named "world" but show up in the list as "FernIsland"
- *
- * @return The alias of the world as a String.
- */
- String getAlias();
-
- /**
- * Sets the alias of the world.
- *
- * @param alias A string that is the new alias.
- */
- void setAlias(String alias);
-
- /**
- * Gets the color that this world's name/alias will display as.
- *
- * @return The color of this world.
- */
- ChatColor getColor();
-
- /**
- * Sets the color that this world's name/alias will display as.
- *
- * @param color A valid color name.
- * @return True if the color was set, false if not.
- */
- boolean setColor(String color);
-
- /**
- * Gets the style that this world's name/alias will display as.
- *
- * @return The style of this world. {@code null} for "normal" style.
- */
- ChatColor getStyle();
-
- /**
- * Sets the style that this world's name/alias will display as.
- *
- * @param style A valid style name.
- * @return True if the style was set, false if not.
- */
- boolean setStyle(String style);
-
- /**
- * Tells you if someone entered a valid color.
- *
- * @param color A string that may translate to a color.
- * @return True if it is a color, false if not.
- *
- * @deprecated This has been moved: {@link EnglishChatColor#isValidAliasColor(String)}
- */
- @Deprecated
- boolean isValidAliasColor(String color);
-
- /**
- * Returns a very nicely colored string (using Alias and Color if they are set).
- *
- * @return A nicely colored string.
- */
- String getColoredWorldString();
-
- // animals&monster stuff
- /**
- * Gets whether or not animals are allowed to spawn in this world.
- *
- * @return True if ANY animal can, false if no animals can spawn.
- */
- boolean canAnimalsSpawn();
-
- /**
- * Sets whether or not animals can spawn.
- * If there are values in {@link #getAnimalList()} and this is false,
- * those animals become the exceptions, and will spawn
- *
- * @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
- */
- void setAllowAnimalSpawn(boolean allowAnimalSpawn);
-
- /**
- * Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
- *
- * @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
- */
- List getAnimalList();
-
- /**
- * Gets whether or not monsters are allowed to spawn in this world.
- *
- * @return True if ANY monster can, false if no monsters can spawn.
- */
- boolean canMonstersSpawn();
-
- /**
- * Sets whether or not monsters can spawn.
- * If there are values in {@link #getMonsterList()} and this is false,
- * those monsters become the exceptions, and will spawn
- *
- * @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
- */
- void setAllowMonsterSpawn(boolean allowMonsterSpawn);
-
- /**
- * Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
- *
- * @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
- */
- List getMonsterList();
- // end of animal&monster stuff
-
- /**
- * Gets whether or not PVP is enabled in this world in some form (fake or not).
- *
- * @return True if players can take damage from other players.
- */
- boolean isPVPEnabled();
-
- /**
- * Turn pvp on or off. This setting is used to set the world's PVP mode.
- *
- * @param pvpMode True to enable PVP damage, false to disable it.
- */
- void setPVPMode(boolean pvpMode);
-
- /**
- * Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
- *
- * @return True if this world has fakepvp on
- * @deprecated This is deprecated.
- */
- @Deprecated
- boolean getFakePVP();
-
- /**
- * Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
- * access permissions to go to this world.
- *
- * @return True if the world will be hidden, false if not.
- */
- boolean isHidden();
-
- /**
- * Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
- * access permissions to go to this world.
- *
- * @param hidden Set
- */
- void setHidden(boolean hidden);
-
- /**
- * Gets whether weather is enabled in this world.
- *
- * @return True if weather events will occur, false if not.
- */
- boolean isWeatherEnabled();
-
- /**
- * Sets whether or not there will be weather events in a given world.
- * If set to false, Multiverse will disable the weather in the world immediately.
- *
- * @param enableWeather True if weather events should occur in a world, false if not.
- */
- void setEnableWeather(boolean enableWeather);
-
- /**
- * Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
- *
- * @return True if CraftBukkit is keeping spawn chunks in memory.
- */
- boolean isKeepingSpawnInMemory();
-
- /**
- * If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
- * If not, CraftBukkit will attempt to free memory when players have not used that world.
- * This will not happen immediately.
- *
- * @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
- */
- void setKeepSpawnInMemory(boolean keepSpawnInMemory);
-
- /**
- * Gets the spawn location of this world.
- *
- * @return The spawn location of this world.
- */
- Location getSpawnLocation();
-
- /**
- * Sets the spawn location for a world.
- *
- * @param spawnLocation The spawn location for a world.
- */
- void setSpawnLocation(Location spawnLocation);
-
- /**
- * Gets whether or not the hunger level of players will go down in a world.
- *
- * @return True if it will go down, false if it will remain steady.
- */
- boolean getHunger();
-
- /**
- * Sets whether or not the hunger level of players will go down in a world.
- *
- * @param hungerEnabled True if hunger will go down, false to keep it at
- * the level they entered a world with.
- */
- void setHunger(boolean hungerEnabled);
-
- /**
- * Gets the GameMode of this world.
- *
- * @return The GameMode of this world.
- */
- GameMode getGameMode();
-
- /**
- * Sets the game mode of this world.
- *
- * @param gameMode A valid game mode string (either
- * an int ex. 0 or a string ex. creative).
- * @return True if the game mode was successfully changed, false if not.
- * @deprecated Use {@link #setGameMode(GameMode)} instead. If you have to
- * pass a string, use {@link #setPropertyValue(String, String)}.
- */
- @Deprecated
- boolean setGameMode(String gameMode);
-
- /**
- * Sets the game mode of this world.
- *
- * @param gameMode The new {@link GameMode}.
- * @return True if the game mode was successfully changed, false if not.
- */
- boolean setGameMode(GameMode gameMode);
-
- /**
- * Gets the amount of currency it requires to enter this world.
- *
- * @return The amount it costs to enter this world.
- */
- double getPrice();
-
- /**
- * Sets the price for entry to this world.
- * You can think of this like an amount.
- * The type can be set with {@link #setCurrency(Material)}
- *
- * @param price The Amount of money/item to enter the world.
- */
- void setPrice(double price);
-
- /**
- * Gets the type of currency that will be used when users enter this world. A value of null indicates a non-item
- * based currency is used.
- *
- * @return The type of currency that will be used when users enter this world.
- */
- @Nullable
- Material getCurrency();
-
- /**
- * Sets the type of item that will be required given the price is not 0.
- * Use a value of null to specify a non-item based currency.
- *
- * @param item The Type of currency that will be used when users enter this world.
- */
- void setCurrency(@Nullable Material item);
-
- /**
- * Gets the world players will respawn in if they die in this one.
- *
- * @return A world that exists on the server.
- */
- World getRespawnToWorld();
-
- /**
- * Sets the world players will respawn in if they die in this one.
- * Returns true upon success, false upon failure.
- *
- * @param respawnWorld The name of a world that exists on the server.
- * @return True if respawnWorld existed, false if not.
- */
- boolean setRespawnToWorld(String respawnWorld);
-
- /**
- * Gets the scaling value of this world.Really only has an effect if you use
- * Multiverse-NetherPortals.
- *
- * @return This world's non-negative, non-zero scale.
- */
- double getScaling();
-
- /**
- * Sets the scale of this world. Really only has an effect if you use
- * Multiverse-NetherPortals.
- *
- * @param scaling A scaling value, cannot be negative or 0.
- * @return Whether the scale was set successfully.
- */
- boolean setScaling(double scaling);
-
- /**
- * Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
- *
- * @return True if the world should heal (default), false if not.
- */
- boolean getAutoHeal();
-
- /**
- * Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
- *
- * @param heal True if the world will heal.
- */
- void setAutoHeal(boolean heal);
-
- /**
- * Gets whether or not Multiverse should auto-adjust the spawn for this world.
- *
- * @return True if Multiverse should adjust the spawn, false if not.
- */
- boolean getAdjustSpawn();
-
- /**
- * Sets whether or not Multiverse should auto-adjust the spawn for this world.
- *
- * @param adjust True if multiverse should adjust the spawn, false if not.
- */
- void setAdjustSpawn(boolean adjust);
-
- /**
- * Gets whether or not Multiverse should auto-load this world.
- *
- * @return True if Multiverse should auto-load this world.
- */
- boolean getAutoLoad();
-
- /**
- * Sets whether or not Multiverse should auto-load this world.
- *
- * True is default.
- *
- * @param autoLoad True if multiverse should autoload this world the spawn, false if not.
- */
- void setAutoLoad(boolean autoLoad);
-
- /**
- * Gets whether or not a player who dies in this world will respawn in their
- * bed or follow the normal respawn pattern.
- *
- * @return True if players dying in this world should respawn at their bed.
- */
- boolean getBedRespawn();
-
- /**
- * Sets whether or not a player who dies in this world will respawn in their
- * bed or follow the normal respawn pattern.
- *
- * True is default.
- *
- * @param autoLoad True if players dying in this world respawn at their bed.
- */
- void setBedRespawn(boolean autoLoad);
-
- /**
- * Sets the player limit for this world after which players without an override
- * permission node will not be allowed in. A value of -1 or less signifies no limit
- *
- * @param limit The new limit
- */
- void setPlayerLimit(int limit);
-
- /**
- * Gets the player limit for this world after which players without an override
- * permission node will not be allowed in. A value of -1 or less signifies no limit
- *
- * @return The player limit
- */
- int getPlayerLimit();
-
- /**
- * Same as {@link #getTime()}, but returns a string.
- * @return The time as a short string: 12:34pm
- */
- String getTime();
-
- /**
- * Sets the current time in a world.
- *
- * This method will take the following formats:
- * 11:37am
- * 4:30p
- * day(morning), night, noon, midnight
- *
- * @param timeAsString The formatted time to set the world to.
- * @return True if the time was set, false if not.
- */
- boolean setTime(String timeAsString);
-
- /**
- * Sets The types of portals that are allowed in this world.
- *
- * @param type The type of portals allowed in this world.
- */
- void allowPortalMaking(AllowedPortalType type);
-
- /**
- * Gets which type(s) of portals are allowed to be constructed in this world.
- *
- * @return The type of portals that are allowed.
- */
- AllowedPortalType getAllowedPortals();
-
- // properties that are not "getter+setter" style
- /**
- * Gets a list of all the worlds that players CANNOT travel to from this world,
- * regardless of their access permissions.
- *
- * @return A List of world names.
- */
- List getWorldBlacklist();
-
- /**
- * Gets all the names of all properties that can be SET.
- *
- * @return All property names, with alternating colors.
- */
- String getAllPropertyNames();
-
- /**
- * Whether or not players are allowed to fly in this world.
- *
- * @return True if players allowed to fly in this world.
- */
- boolean getAllowFlight();
-
- /**
- * Sets whether or not players are allowed to fly in this world.
- *
- * @param allowFlight True to allow flight in this world.
- */
- void setAllowFlight(final boolean allowFlight);
-}
diff --git a/src/main/java/org/mvplugins/multiverse/core/api/MVWorldManager.java b/src/main/java/org/mvplugins/multiverse/core/api/MVWorldManager.java
deleted file mode 100644
index 54d35263..00000000
--- a/src/main/java/org/mvplugins/multiverse/core/api/MVWorldManager.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
- * Multiverse 2 is licensed under the BSD License. *
- * For more information please check the README.md file included *
- * with this project. *
- ******************************************************************************/
-
-package org.mvplugins.multiverse.core.api;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.bukkit.World;
-import org.bukkit.World.Environment;
-import org.bukkit.WorldType;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.generator.ChunkGenerator;
-import org.jvnet.hk2.annotations.Contract;
-
-/**
- * Multiverse 2 World Manager API
- *
- * This API contains all of the world managing
- * functions that your heart desires!
- */
-@Contract
-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 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, 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 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, Boolean generateStructures,
- String generator, boolean useSpawnAdjust);
-
- /**
- * Make a copy of a world.
- *
- * @param oldName
- * Name of world to be copied
- * @param newName
- * Name of world to be created
- * @return True if the world is copied successfully, false if not.
- */
- boolean cloneWorld(String oldName, String newName);
-
- /**
- * Remove the world from the Multiverse list, from the config and deletes
- * the folder.
- *
- * @param name
- * The name of the world to remove
- * @return True if success, false if failure.
- */
- boolean deleteWorld(String name);
-
- /**
- * Remove the world from the Multiverse list, from the
- * config if wanted, and deletes the folder.
- *
- * @param name The name of the world to remove
- * @param removeConfig If true(default), we'll remove the entries from the
- * config. If false, they'll stay and the world may come back.
- * @return True if success, false if failure.
- */
- boolean deleteWorld(String name, boolean removeConfig);
-
- /**
- *
- * @param name The name of the world to remove
- * @param removeFromConfig If true(default), we'll remove the entries from the
- * config. If false, they'll stay and the world may come back.
- * @param deleteWorldFolder If true the world folder will be completely deleted. If false
- * only the contents of the world folder will be deleted
- * @return True if success, false if failure.
- */
- boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
-
- /**
- * Unload a world from Multiverse.
- *
- * @param name Name of the world to unload
- * @return True if the world was unloaded, false if not.
- */
- boolean unloadWorld(String name);
-
- /**
- * Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
- *
- * @param name Name of the world to unload
- * @param unloadBukkit True if Bukkit world should be unloaded
- * @return True if the world was unloaded, false if not.
- */
- boolean unloadWorld(String name, boolean unloadBukkit);
-
- /**
- * Loads the world. Only use this if the world has been
- * unloaded with {@link #unloadWorld(String)}.
- *
- * @param name The name of the world to load
- * @return True if success, false if failure.
- */
- boolean loadWorld(String name);
-
- /**
- * Removes all players from the specified world.
- *
- * @param name World to remove players from.
- */
- void removePlayersFromWorld(String name);
-
- /**
- * Test if a given chunk generator is valid.
- *
- * @param generator The generator name.
- * @param generatorID The generator id.
- * @param worldName The worldName to use as the default.
- * @return A {@link ChunkGenerator} or null
- */
- ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
-
- /**
- * Returns a list of all the worlds Multiverse knows about.
- *
- * @return A list of {@link MVWorld}.
- */
- Collection getMVWorlds();
-
-
- /**
- * 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.
- */
- MVWorld getMVWorld(String name);
-
- /**
- * Returns a {@link MVWorld} if the world with name given exists, and null if it does not.
- * This will search optionally for alias names.
- *
- * @param name The name or optionally the alias of the world to get.
- * @param checkAliases Indicates whether to check for world alias name.
- * @return A {@link MVWorld} or null.
- */
- MVWorld getMVWorld(String name, boolean checkAliases);
-
- /**
- * Returns a {@link MVWorld} if it exists, and null if it does not.
- *
- * @param world The Bukkit world to check.
- * @return A {@link MVWorld} or null.
- */
- MVWorld getMVWorld(World world);
-
- /**
- * Checks to see if the given name is a valid {@link MVWorld}
- * Searches based on world name AND alias.
- *
- * @param name The name or alias of the world to check.
- * @return True if the world exists, false if not.
- */
- boolean isMVWorld(String name);
-
- /**
- * Checks to see if the given name is a valid {@link MVWorld}.
- * Optionally searches by alias is specified.
- *
- * @param name The name or alias of the world to check.
- * @param checkAliases Indicates whether to check for world alias name.
- * @return True if the world exists, false if not.
- */
- boolean isMVWorld(String name, boolean checkAliases);
-
- /**
- * Checks to see if the given world is a valid {@link MVWorld}.
- *
- * @param world The Bukkit world to check.
- * @return True if the world has been loaded into MV2, false if not.
- */
- boolean isMVWorld(World world);
-
- /**
- * 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.
- */
- void loadWorlds(boolean forceLoad);
-
- /**
- * Loads the Worlds & Settings for any worlds that bukkit loaded before us.
- *
- * This way people will _always_ have some worlds in the list.
- */
- void loadDefaultWorlds();
-
- /**
- * Gets the world players will spawn in on first join.
- * Currently this always returns worlds.get(0) from Bukkit.
- *
- * @return A Multiverse world that players will spawn in or null if no MV world has been set.
- */
- MVWorld getSpawnWorld();
-
- /**
- * Gets the list of worlds in the config, but unloaded.
- *
- * @return A List of worlds as strings.
- */
- List getUnloadedWorlds();
-
- /**
- * This method populates an internal list and needs to be called after multiverse initialization.
- */
- void getDefaultWorldGenerators();
-
- /**
- * Load the config from a file.
- *
- * @return A loaded configuration.
- */
- FileConfiguration loadWorldsConfig();
-
- /**
- * Saves the world config to disk.
- *
- * @return True if success, false if fail.
- */
- boolean saveWorldsConfig();
-
- /**
- * Remove the world from the Multiverse list and from the config.
- *
- * @param name The name of the world to remove
- * @return True if success, false if failure.
- */
- boolean removeWorldFromConfig(String name);
-
- /**
- * Sets the initial spawn world for new players.
- *
- * @param world The World new players should spawn in.
- */
- void setFirstSpawnWorld(String world);
-
- /**
- * Gets the world players should spawn in first.
- *
- * @return The {@link MVWorld} new players should spawn in.
- */
- MVWorld getFirstSpawnWorld();
-
- /**
- * Regenerates a world.
- *
- * @param name Name of the world to regenerate
- * @param useNewSeed If a new seed should be used
- * @param randomSeed If the new seed should be random
- * @param seed The seed of the world.
- *
- * @return True if success, false if fail.
- */
- boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
-
- /**
- * Regenerates a world.
- *
- * @param name Name of the world to regenerate
- * @param useNewSeed If a new seed should be used
- * @param randomSeed If the new seed should be random
- * @param seed The seed of the world.
- * @param keepGameRules If GameRules should be kept on world regen.
- *
- * @return True if success, false if fail.
- */
- boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules);
-
- boolean isKeepingSpawnInMemory(World world);
-
- /**
- * Checks whether Multiverse knows about a provided unloaded world. This
- * method will check the parameter against the alias mappings.
- *
- * @param name The name of the unloaded world
- * @param includeLoaded The value to return if the world is loaded
- *
- * @return True if the world exists and is unloaded. False if the world
- * does not exist. {@code includeLoaded} if the world exists and is loaded.
- */
- boolean hasUnloadedWorld(String name, boolean includeLoaded);
-
- /**
- * Get all the possible worlds that Multiverse has detected to be importable.
- *
- * @return A collection of world names that are deemed importable.
- */
- Collection getPotentialWorlds();
-}
diff --git a/src/main/java/org/mvplugins/multiverse/core/api/WorldPurger.java b/src/main/java/org/mvplugins/multiverse/core/api/WorldPurger.java
deleted file mode 100644
index d3c1d725..00000000
--- a/src/main/java/org/mvplugins/multiverse/core/api/WorldPurger.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.mvplugins.multiverse.core.api;
-
-import java.util.List;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Entity;
-import org.jvnet.hk2.annotations.Contract;
-
-/**
- * Used to remove animals from worlds that don't belong there.
- */
-@Contract
-public interface WorldPurger {
- /**
- * Synchronizes the given worlds with their settings.
- *
- * @param worlds A list of {@link MVWorld}
- */
- void purgeWorlds(List worlds);
-
- /**
- * Convenience method for {@link #purgeWorld(MVWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
- *
- * @param world The {@link MVWorld}.
- */
- void purgeWorld(MVWorld world);
-
- /**
- * Clear all animals/monsters that do not belong to a world according to the config.
- *
- * @param mvworld The {@link MVWorld}.
- * @param thingsToKill A {@link List} of animals/monsters to be killed.
- * @param negateAnimals Whether the monsters in the list should be negated.
- * @param negateMonsters Whether the animals in the list should be negated.
- */
- void purgeWorld(MVWorld mvworld, List thingsToKill, boolean negateAnimals,
- boolean negateMonsters);
-
- /**
- * Clear all animals/monsters that do not belong to a world according to the config.
- *
- * @param mvworld The {@link MVWorld}.
- * @param thingsToKill A {@link List} of animals/monsters to be killed.
- * @param negateAnimals Whether the monsters in the list should be negated.
- * @param negateMonsters Whether the animals in the list should be negated.
- * @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
- */
- void purgeWorld(MVWorld mvworld, List thingsToKill, boolean negateAnimals,
- boolean negateMonsters, CommandSender sender);
-
- /**
- * Determines whether the specified creature should be killed.
- *
- * @param e The creature.
- * @param thingsToKill A {@link List} of animals/monsters to be killed.
- * @param negateAnimals Whether the monsters in the list should be negated.
- * @param negateMonsters Whether the animals in the list should be negated.
- * @return {@code true} if the creature should be killed, otherwise {@code false}.
- */
- boolean shouldWeKillThisCreature(Entity e, List thingsToKill, boolean negateAnimals, boolean negateMonsters);
-
- /**
- * Determines whether the specified creature should be killed and automatically reads the params from a world object.
- *
- * @param w The world.
- * @param e The creature.
- * @return {@code true} if the creature should be killed, otherwise {@code false}.
- */
- boolean shouldWeKillThisCreature(MVWorld w, Entity e);
-}
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java
index fe7c2e2c..9493e7ad 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/CloneCommand.java
@@ -18,9 +18,9 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.options.CloneWorldOptions;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.options.CloneWorldOptions;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java
index f019cb25..dcf48f2d 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/CoordinatesCommand.java
@@ -15,7 +15,7 @@ import org.mvplugins.multiverse.core.api.LocationManipulation;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java
index 84f8b2c0..435aa9c6 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/CreateCommand.java
@@ -24,9 +24,9 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.generators.GeneratorProvider;
-import org.mvplugins.multiverse.core.worldnew.options.CreateWorldOptions;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.generators.GeneratorProvider;
+import org.mvplugins.multiverse.core.world.options.CreateWorldOptions;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java
index 8f576620..a59f624b 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java
@@ -19,7 +19,7 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.commandtools.queue.QueuedCommand;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java
index eaa0cd53..0c70b671 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java
@@ -27,7 +27,6 @@ import org.mvplugins.multiverse.core.MultiverseCore;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
-import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagGroup;
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.event.MVVersionEvent;
@@ -36,7 +35,7 @@ import org.mvplugins.multiverse.core.utils.webpaste.PasteFailedException;
import org.mvplugins.multiverse.core.utils.webpaste.PasteService;
import org.mvplugins.multiverse.core.utils.webpaste.PasteServiceFactory;
import org.mvplugins.multiverse.core.utils.webpaste.PasteServiceType;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
import static org.mvplugins.multiverse.core.utils.file.FileUtils.getBukkitConfig;
import static org.mvplugins.multiverse.core.utils.file.FileUtils.getServerProperties;
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java
index 0fad4434..86d5f1c2 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/GameruleCommand.java
@@ -18,7 +18,7 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.commandtools.context.GameRuleValue;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java
index 3de96f5c..d733a8b3 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/GamerulesCommand.java
@@ -33,7 +33,7 @@ import org.mvplugins.multiverse.core.display.filters.RegexContentFilter;
import org.mvplugins.multiverse.core.display.handlers.PagedSendHandler;
import org.mvplugins.multiverse.core.display.parsers.MapContentProvider;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
/**
* List all gamerules in your current or specified world.
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java
index 7e594b17..63c91751 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/ImportCommand.java
@@ -11,7 +11,6 @@ import co.aikar.commands.annotation.Syntax;
import com.dumptruckman.minecraft.util.Logging;
import jakarta.inject.Inject;
import org.bukkit.World;
-import org.bukkit.WorldType;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
@@ -19,13 +18,12 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
-import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagGroup;
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.generators.GeneratorProvider;
-import org.mvplugins.multiverse.core.worldnew.options.ImportWorldOptions;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.generators.GeneratorProvider;
+import org.mvplugins.multiverse.core.world.options.ImportWorldOptions;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java
index d6477883..7ac60aed 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/ListCommand.java
@@ -19,7 +19,6 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
-import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagGroup;
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.display.ContentDisplay;
@@ -28,10 +27,10 @@ import org.mvplugins.multiverse.core.display.filters.DefaultContentFilter;
import org.mvplugins.multiverse.core.display.filters.RegexContentFilter;
import org.mvplugins.multiverse.core.display.handlers.PagedSendHandler;
import org.mvplugins.multiverse.core.display.parsers.ListContentProvider;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.entrycheck.WorldEntryChecker;
-import org.mvplugins.multiverse.core.worldnew.entrycheck.WorldEntryCheckerProvider;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.entrycheck.WorldEntryChecker;
+import org.mvplugins.multiverse.core.world.entrycheck.WorldEntryCheckerProvider;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java
index c1a02bd9..e72ef798 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/LoadCommand.java
@@ -17,7 +17,7 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java
index 591188da..a66c98a1 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java
@@ -24,9 +24,9 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.commandtools.queue.QueuedCommand;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.options.RegenWorldOptions;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.options.RegenWorldOptions;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java
index 4ac7d85d..2630de1f 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/ReloadCommand.java
@@ -19,7 +19,7 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.config.MVCoreConfig;
import org.mvplugins.multiverse.core.event.MVConfigReloadEvent;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java
index dcfd9a44..677f55dc 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java
@@ -17,7 +17,7 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java
index 9507e19e..a74b6eb0 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java
@@ -18,9 +18,9 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.options.UnloadWorldOptions;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.options.UnloadWorldOptions;
@Service
@CommandAlias("mv")
diff --git a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java
index a12e62ca..2e605c3f 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java
@@ -25,9 +25,9 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.config.MVCoreConfig;
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
import org.mvplugins.multiverse.core.destination.ParsedDestination;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.MultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.MultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
public class MVCommandCompletions extends PaperCommandCompletions {
diff --git a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandConditions.java b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandConditions.java
index 44a2dea4..4b2f8fce 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandConditions.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandConditions.java
@@ -9,19 +9,24 @@ import co.aikar.commands.ConditionFailedException;
import org.jetbrains.annotations.NotNull;
import org.mvplugins.multiverse.core.world.WorldNameChecker;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
public class MVCommandConditions {
- static void load(MVCommandManager commandManager, WorldManager worldManager) {
- new MVCommandConditions(commandManager, worldManager);
+ static void load(MVCommandManager commandManager, WorldManager worldManager, WorldNameChecker worldNameChecker) {
+ new MVCommandConditions(commandManager, worldManager, worldNameChecker);
}
private final WorldManager worldManager;
private final MVCommandManager commandManager;
+ private final WorldNameChecker worldNameChecker;
- private MVCommandConditions(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) {
+ private MVCommandConditions(
+ @NotNull MVCommandManager commandManager,
+ @NotNull WorldManager worldManager,
+ @NotNull WorldNameChecker worldNameChecker) {
this.worldManager = worldManager;
this.commandManager = commandManager;
+ this.worldNameChecker = worldNameChecker;
registerConditions();
}
@@ -32,10 +37,10 @@ public class MVCommandConditions {
conditions.addCondition(String.class, "worldname", this::checkWorldname);
}
- private void checkWorldname(ConditionContext context,
- BukkitCommandExecutionContext executionContext,
- String worldName
- ) {
+ private void checkWorldname(
+ ConditionContext context,
+ BukkitCommandExecutionContext executionContext,
+ String worldName) {
String scope = context.getConfigValue("scope", "loaded");
switch (scope) {
@@ -65,7 +70,7 @@ public class MVCommandConditions {
if (this.worldManager.isWorld(worldName)) {
throw new ConditionFailedException("World with name '" + worldName + "' already exists!");
}
- switch (WorldNameChecker.checkName(worldName)) {
+ switch (worldNameChecker.checkName(worldName)) {
case INVALID_CHARS ->
throw new ConditionFailedException("World name '" + worldName + "' contains invalid characters!");
case BLACKLISTED ->
diff --git a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandContexts.java b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandContexts.java
index 25fc8b67..79a8de64 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandContexts.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandContexts.java
@@ -26,8 +26,8 @@ import org.mvplugins.multiverse.core.display.filters.ContentFilter;
import org.mvplugins.multiverse.core.display.filters.DefaultContentFilter;
import org.mvplugins.multiverse.core.display.filters.RegexContentFilter;
import org.mvplugins.multiverse.core.utils.PlayerFinder;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
public class MVCommandContexts extends PaperCommandContexts {
diff --git a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandManager.java b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandManager.java
index 296795e1..deaa0426 100644
--- a/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandManager.java
+++ b/src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandManager.java
@@ -19,7 +19,8 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.MultiverseCore;
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlagsManager;
import org.mvplugins.multiverse.core.commandtools.queue.CommandQueueManager;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldNameChecker;
/**
* Main class to manage permissions.
@@ -33,21 +34,21 @@ public class MVCommandManager extends PaperCommandManager {
private final Provider commandCompletionsProvider;
@Inject
- public MVCommandManager(
+ MVCommandManager(
@NotNull MultiverseCore plugin,
@NotNull CommandFlagsManager flagsManager,
@NotNull CommandQueueManager commandQueueManager,
@NotNull Provider commandContextsProvider,
@NotNull Provider commandCompletionsProvider,
- @NotNull WorldManager worldManager
- ) {
+ @NotNull WorldManager worldManager,
+ @NotNull WorldNameChecker worldNameChecker) {
super(plugin);
this.flagsManager = flagsManager;
this.commandQueueManager = commandQueueManager;
this.commandContextsProvider = commandContextsProvider;
this.commandCompletionsProvider = commandCompletionsProvider;
- MVCommandConditions.load(this, worldManager);
+ MVCommandConditions.load(this, worldManager, worldNameChecker);
this.enableUnstableAPI("help");
}
diff --git a/src/main/java/org/mvplugins/multiverse/core/destination/core/CannonDestination.java b/src/main/java/org/mvplugins/multiverse/core/destination/core/CannonDestination.java
index d19a784b..5e7f2ff8 100644
--- a/src/main/java/org/mvplugins/multiverse/core/destination/core/CannonDestination.java
+++ b/src/main/java/org/mvplugins/multiverse/core/destination/core/CannonDestination.java
@@ -13,8 +13,8 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.api.Destination;
import org.mvplugins.multiverse.core.api.Teleporter;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
/**
* {@link Destination} implementation for cannons.
diff --git a/src/main/java/org/mvplugins/multiverse/core/destination/core/ExactDestination.java b/src/main/java/org/mvplugins/multiverse/core/destination/core/ExactDestination.java
index a61cd6b8..f59e6a54 100644
--- a/src/main/java/org/mvplugins/multiverse/core/destination/core/ExactDestination.java
+++ b/src/main/java/org/mvplugins/multiverse/core/destination/core/ExactDestination.java
@@ -13,8 +13,8 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.api.Destination;
import org.mvplugins.multiverse.core.api.Teleporter;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
/**
* {@link Destination} implementation for exact locations.
diff --git a/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestination.java b/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestination.java
index 5610fa48..2d8fb597 100644
--- a/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestination.java
+++ b/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestination.java
@@ -12,8 +12,8 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.api.Destination;
import org.mvplugins.multiverse.core.api.LocationManipulation;
import org.mvplugins.multiverse.core.api.Teleporter;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
/**
* {@link Destination} implementation for exact locations.
diff --git a/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestinationInstance.java b/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestinationInstance.java
index 80571b8c..f0ce05fe 100644
--- a/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestinationInstance.java
+++ b/src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestinationInstance.java
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mvplugins.multiverse.core.api.DestinationInstance;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
/**
* Destination instance implementation for the {@link WorldDestination}.
diff --git a/src/main/java/org/mvplugins/multiverse/core/economy/MVEconomist.java b/src/main/java/org/mvplugins/multiverse/core/economy/MVEconomist.java
index ff779a68..5951c74f 100644
--- a/src/main/java/org/mvplugins/multiverse/core/economy/MVEconomist.java
+++ b/src/main/java/org/mvplugins/multiverse/core/economy/MVEconomist.java
@@ -8,13 +8,14 @@ import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import org.jvnet.hk2.annotations.Service;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
/**
* Multiverse's Friendly Economist. This is used to deal with external economies and also item costs for stuff in MV.
*/
@Service
public class MVEconomist {
+ public static final Material DISABLED_MATERIAL = Material.AIR;
private final VaultHandler vaultHandler;
diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java
index cc2292fb..0438d84a 100644
--- a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java
+++ b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java
@@ -4,7 +4,8 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import org.mvplugins.multiverse.core.api.MVWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.MultiverseWorld;
/**
* Called when a world is about to be deleted by Multiverse.
@@ -12,13 +13,13 @@ import org.mvplugins.multiverse.core.api.MVWorld;
public class MVWorldDeleteEvent extends Event implements Cancellable {
private boolean cancelled = false;
- private final MVWorld world;
+ private final LoadedMultiverseWorld world;
private final boolean removeFromConfig;
- public MVWorldDeleteEvent(MVWorld world, boolean removeFromConfig) {
- if (world == null)
+ public MVWorldDeleteEvent(LoadedMultiverseWorld world, boolean removeFromConfig) {
+ if (world == null) {
throw new IllegalArgumentException("world can't be null!");
-
+ }
this.world = world;
this.removeFromConfig = removeFromConfig;
}
@@ -60,9 +61,9 @@ public class MVWorldDeleteEvent extends Event implements Cancellable {
/**
* Gets the world that's about to be deleted.
*
- * @return That {@link MVWorld}.
+ * @return That {@link MultiverseWorld}.
*/
- public MVWorld getWorld() {
+ public LoadedMultiverseWorld getWorld() {
return world;
}
diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java
index b2cf5d5a..e67dbd9b 100644
--- a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java
+++ b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java
@@ -12,7 +12,8 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import org.mvplugins.multiverse.core.api.MVWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.MultiverseWorld;
/**
* This event is fired *before* the property is actually changed.
@@ -25,13 +26,13 @@ import org.mvplugins.multiverse.core.api.MVWorld;
* @param The type of the property that was set.
*/
public class MVWorldPropertyChangeEvent extends Event implements Cancellable {
- private MVWorld world;
+ private MultiverseWorld world;
private CommandSender changer;
private boolean isCancelled = false;
private String name;
private T value;
- public MVWorldPropertyChangeEvent(MVWorld world, CommandSender changer, String name, T value) {
+ public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) {
this.world = world;
this.changer = changer;
this.name = name;
@@ -107,7 +108,7 @@ public class MVWorldPropertyChangeEvent extends Event implements Cancellable
*
* @return A valid MultiverseWorld.
*/
- public MVWorld getWorld() {
+ public MultiverseWorld getWorld() {
return this.world;
}
diff --git a/src/main/java/org/mvplugins/multiverse/core/listeners/MVChatListener.java b/src/main/java/org/mvplugins/multiverse/core/listeners/MVChatListener.java
index f124b466..19bafbd9 100644
--- a/src/main/java/org/mvplugins/multiverse/core/listeners/MVChatListener.java
+++ b/src/main/java/org/mvplugins/multiverse/core/listeners/MVChatListener.java
@@ -8,7 +8,7 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.config.MVCoreConfig;
import org.mvplugins.multiverse.core.inject.InjectableListener;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
/**
* Multiverse's Listener for players.
diff --git a/src/main/java/org/mvplugins/multiverse/core/listeners/MVEntityListener.java b/src/main/java/org/mvplugins/multiverse/core/listeners/MVEntityListener.java
index b0fd3f6c..97e4ab73 100644
--- a/src/main/java/org/mvplugins/multiverse/core/listeners/MVEntityListener.java
+++ b/src/main/java/org/mvplugins/multiverse/core/listeners/MVEntityListener.java
@@ -21,8 +21,8 @@ import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.inject.InjectableListener;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.WorldPurger;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldPurger;
/**
* Multiverse's Entity {@link Listener}.
diff --git a/src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java b/src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java
index 6d0ac3e1..7027d7ad 100644
--- a/src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java
+++ b/src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java
@@ -40,15 +40,13 @@ import org.mvplugins.multiverse.core.destination.ParsedDestination;
import org.mvplugins.multiverse.core.economy.MVEconomist;
import org.mvplugins.multiverse.core.event.MVRespawnEvent;
import org.mvplugins.multiverse.core.inject.InjectableListener;
-import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
import org.mvplugins.multiverse.core.teleportation.TeleportQueue;
import org.mvplugins.multiverse.core.utils.result.ResultChain;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.entrycheck.EntryFeeResult;
-import org.mvplugins.multiverse.core.worldnew.entrycheck.WorldEntryCheckerProvider;
-import org.mvplugins.multiverse.core.worldnew.helpers.EnforcementHandler;
-import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.entrycheck.EntryFeeResult;
+import org.mvplugins.multiverse.core.world.entrycheck.WorldEntryCheckerProvider;
+import org.mvplugins.multiverse.core.world.helpers.EnforcementHandler;
/**
* Multiverse's Listener for players.
diff --git a/src/main/java/org/mvplugins/multiverse/core/listeners/MVPortalListener.java b/src/main/java/org/mvplugins/multiverse/core/listeners/MVPortalListener.java
index f51ab40f..f0ff939b 100644
--- a/src/main/java/org/mvplugins/multiverse/core/listeners/MVPortalListener.java
+++ b/src/main/java/org/mvplugins/multiverse/core/listeners/MVPortalListener.java
@@ -22,8 +22,8 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.config.MVCoreConfig;
import org.mvplugins.multiverse.core.inject.InjectableListener;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
/**
* A custom listener for portal related events.
diff --git a/src/main/java/org/mvplugins/multiverse/core/listeners/MVWeatherListener.java b/src/main/java/org/mvplugins/multiverse/core/listeners/MVWeatherListener.java
index 5f0a3c2e..8032d0f4 100644
--- a/src/main/java/org/mvplugins/multiverse/core/listeners/MVWeatherListener.java
+++ b/src/main/java/org/mvplugins/multiverse/core/listeners/MVWeatherListener.java
@@ -15,7 +15,7 @@ import org.bukkit.event.weather.WeatherChangeEvent;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.inject.InjectableListener;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.WorldManager;
/**
* Multiverse's Weather Listener.
diff --git a/src/main/java/org/mvplugins/multiverse/core/listeners/MVWorldListener.java b/src/main/java/org/mvplugins/multiverse/core/listeners/MVWorldListener.java
index 2dea585b..d321408a 100644
--- a/src/main/java/org/mvplugins/multiverse/core/listeners/MVWorldListener.java
+++ b/src/main/java/org/mvplugins/multiverse/core/listeners/MVWorldListener.java
@@ -16,10 +16,10 @@ import org.bukkit.event.world.WorldUnloadEvent;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.inject.InjectableListener;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
-import org.mvplugins.multiverse.core.worldnew.options.UnloadWorldOptions;
-import org.mvplugins.multiverse.core.worldnew.reasons.LoadFailureReason;
-import org.mvplugins.multiverse.core.worldnew.reasons.UnloadFailureReason;
+import org.mvplugins.multiverse.core.world.WorldManager;
+import org.mvplugins.multiverse.core.world.options.UnloadWorldOptions;
+import org.mvplugins.multiverse.core.world.reasons.LoadFailureReason;
+import org.mvplugins.multiverse.core.world.reasons.UnloadFailureReason;
/**
* Multiverse's World Listener.
diff --git a/src/main/java/org/mvplugins/multiverse/core/permissions/CorePermissionsChecker.java b/src/main/java/org/mvplugins/multiverse/core/permissions/CorePermissionsChecker.java
index be6b1a31..17337e8e 100644
--- a/src/main/java/org/mvplugins/multiverse/core/permissions/CorePermissionsChecker.java
+++ b/src/main/java/org/mvplugins/multiverse/core/permissions/CorePermissionsChecker.java
@@ -5,9 +5,8 @@ import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
-import org.mvplugins.multiverse.core.api.MVWorld;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.MultiverseWorld;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.MultiverseWorld;
@Service
public class CorePermissionsChecker {
@@ -15,11 +14,6 @@ public class CorePermissionsChecker {
return hasPermission(sender, concatPermission(CorePermissions.WORLD_ACCESS, world.getName()));
}
- @Deprecated // TODO: Remove old MVWorld
- public boolean hasWorldAccessPermission(@NotNull CommandSender sender, @NotNull MVWorld world) {
- return hasPermission(sender, concatPermission(CorePermissions.WORLD_ACCESS, world.getName()));
- }
-
public boolean hasWorldExemptPermission(@NotNull CommandSender sender, @NotNull LoadedMultiverseWorld world) {
return hasPermission(sender, concatPermission(CorePermissions.WORLD_EXEMPT, world.getName()));
}
@@ -32,11 +26,6 @@ public class CorePermissionsChecker {
return hasPermission(sender, concatPermission(CorePermissions.GAMEMODE_BYPASS, world.getName()));
}
- @Deprecated // TODO: Remove old MVWorld
- public boolean hasGameModeBypassPermission(@NotNull CommandSender sender, @NotNull MVWorld world) {
- return hasPermission(sender, concatPermission(CorePermissions.GAMEMODE_BYPASS, world.getName()));
- }
-
private String concatPermission(String permission, String...child) {
return permission + "." + String.join(".", child);
}
diff --git a/src/main/java/org/mvplugins/multiverse/core/placeholders/MultiverseCorePlaceholders.java b/src/main/java/org/mvplugins/multiverse/core/placeholders/MultiverseCorePlaceholders.java
index e2c9a82d..5531a1ad 100644
--- a/src/main/java/org/mvplugins/multiverse/core/placeholders/MultiverseCorePlaceholders.java
+++ b/src/main/java/org/mvplugins/multiverse/core/placeholders/MultiverseCorePlaceholders.java
@@ -13,8 +13,8 @@ import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.MultiverseCore;
import org.mvplugins.multiverse.core.economy.MVEconomist;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
public class MultiverseCorePlaceholders extends PlaceholderExpansion {
diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/metrics/MetricsConfigurator.java b/src/main/java/org/mvplugins/multiverse/core/utils/metrics/MetricsConfigurator.java
index 238436d0..52489488 100644
--- a/src/main/java/org/mvplugins/multiverse/core/utils/metrics/MetricsConfigurator.java
+++ b/src/main/java/org/mvplugins/multiverse/core/utils/metrics/MetricsConfigurator.java
@@ -12,8 +12,8 @@ import org.bukkit.World;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.MultiverseCore;
-import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld;
-import org.mvplugins.multiverse.core.worldnew.WorldManager;
+import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
+import org.mvplugins.multiverse.core.world.WorldManager;
@Service
public class MetricsConfigurator {
diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/LoadedMultiverseWorld.java b/src/main/java/org/mvplugins/multiverse/core/world/LoadedMultiverseWorld.java
similarity index 95%
rename from src/main/java/org/mvplugins/multiverse/core/worldnew/LoadedMultiverseWorld.java
rename to src/main/java/org/mvplugins/multiverse/core/world/LoadedMultiverseWorld.java
index d8a12a94..1e86205e 100644
--- a/src/main/java/org/mvplugins/multiverse/core/worldnew/LoadedMultiverseWorld.java
+++ b/src/main/java/org/mvplugins/multiverse/core/world/LoadedMultiverseWorld.java
@@ -1,4 +1,4 @@
-package org.mvplugins.multiverse.core.worldnew;
+package org.mvplugins.multiverse.core.world;
import java.util.List;
import java.util.UUID;
@@ -15,9 +15,9 @@ import org.jetbrains.annotations.NotNull;
import org.mvplugins.multiverse.core.api.BlockSafety;
import org.mvplugins.multiverse.core.api.LocationManipulation;
import org.mvplugins.multiverse.core.api.SafeTTeleporter;
-import org.mvplugins.multiverse.core.worldnew.config.NullLocation;
-import org.mvplugins.multiverse.core.worldnew.config.SpawnLocation;
-import org.mvplugins.multiverse.core.worldnew.config.WorldConfig;
+import org.mvplugins.multiverse.core.world.config.NullLocation;
+import org.mvplugins.multiverse.core.world.config.SpawnLocation;
+import org.mvplugins.multiverse.core.world.config.WorldConfig;
/**
* Extension of {@link MultiverseWorld} that represents a world that is currently loaded with bukkit world object.
diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/MultiverseWorld.java b/src/main/java/org/mvplugins/multiverse/core/world/MultiverseWorld.java
similarity index 99%
rename from src/main/java/org/mvplugins/multiverse/core/worldnew/MultiverseWorld.java
rename to src/main/java/org/mvplugins/multiverse/core/world/MultiverseWorld.java
index 9f0530c3..75b9cd58 100644
--- a/src/main/java/org/mvplugins/multiverse/core/worldnew/MultiverseWorld.java
+++ b/src/main/java/org/mvplugins/multiverse/core/world/MultiverseWorld.java
@@ -1,4 +1,4 @@
-package org.mvplugins.multiverse.core.worldnew;
+package org.mvplugins.multiverse.core.world;
import java.util.Collection;
import java.util.List;
@@ -13,8 +13,8 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.jetbrains.annotations.Nullable;
-import org.mvplugins.multiverse.core.world.configuration.AllowedPortalType;
-import org.mvplugins.multiverse.core.worldnew.config.WorldConfig;
+import org.mvplugins.multiverse.core.world.config.AllowedPortalType;
+import org.mvplugins.multiverse.core.world.config.WorldConfig;
/**
* Represents a world handled by Multiverse which has all the custom properties provided by Multiverse.
diff --git a/src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorld.java b/src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorld.java
deleted file mode 100644
index 018de867..00000000
--- a/src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorld.java
+++ /dev/null
@@ -1,1259 +0,0 @@
-/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
- * Multiverse 2 is licensed under the BSD License. *
- * For more information please check the README.md file included *
- * with this project. *
- ******************************************************************************/
-
-package org.mvplugins.multiverse.core.world;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import com.dumptruckman.minecraft.util.Logging;
-import me.main__.util.SerializationConfig.ChangeDeniedException;
-import me.main__.util.SerializationConfig.NoSuchPropertyException;
-import me.main__.util.SerializationConfig.VirtualProperty;
-import net.minidev.json.JSONObject;
-import org.bukkit.ChatColor;
-import org.bukkit.Difficulty;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.Server;
-import org.bukkit.World;
-import org.bukkit.World.Environment;
-import org.bukkit.WorldType;
-import org.bukkit.configuration.serialization.SerializableAs;
-import org.bukkit.entity.Player;
-import org.bukkit.permissions.Permission;
-import org.bukkit.permissions.PermissionDefault;
-import org.bukkit.util.Vector;
-import org.jetbrains.annotations.Nullable;
-
-import org.mvplugins.multiverse.core.api.BlockSafety;
-import org.mvplugins.multiverse.core.api.LocationManipulation;
-import org.mvplugins.multiverse.core.api.MVWorld;
-import org.mvplugins.multiverse.core.api.MVWorldManager;
-import org.mvplugins.multiverse.core.api.SafeTTeleporter;
-import org.mvplugins.multiverse.core.api.WorldPurger;
-import org.mvplugins.multiverse.core.config.MVCoreConfig;
-import org.mvplugins.multiverse.core.exceptions.PropertyDoesNotExistException;
-import org.mvplugins.multiverse.core.listeners.MVPlayerListener;
-import org.mvplugins.multiverse.core.world.configuration.AllowedPortalType;
-import org.mvplugins.multiverse.core.world.configuration.EnglishChatColor;
-import org.mvplugins.multiverse.core.world.configuration.SpawnSettings;
-import org.mvplugins.multiverse.core.world.configuration.WorldPropertyValidator;
-import org.mvplugins.multiverse.core.worldnew.config.SpawnLocation;
-
-/**
- * The implementation of a Multiverse handled world.
- */
-public class SimpleMVWorld implements MVWorld {
- private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16;
- private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16;
-
- private final MVWorldManager worldManager;
- private final MVCoreConfig config;
- private final WorldPurger worldPurger;
- private final MVPlayerListener playerListener;
- private final BlockSafety blockSafety;
- private final SafeTTeleporter safeTTeleporter;
- private final LocationManipulation locationManipulation;
- private final Server server;
- private final String name; // The Worlds Name, EG its folder name.
- private final UUID worldUID;
- private final WorldProperties props;
-
- public SimpleMVWorld(
- MVWorldManager worldManager,
- MVCoreConfig config,
- WorldPurger worldPurger,
- MVPlayerListener playerListener,
- BlockSafety blockSafety,
- SafeTTeleporter safeTTeleporter,
- LocationManipulation locationManipulation,
- Server server,
- World world,
- WorldProperties properties
- ) {
- this(worldManager, config, worldPurger, playerListener, blockSafety, safeTTeleporter,
- locationManipulation, server, world, properties, true);
- }
-
- /*
- * We have to use setCBWorld(), setPlugin() and initPerms() to prepare this object for use.
- */
- public SimpleMVWorld(
- MVWorldManager worldManager,
- MVCoreConfig config,
- WorldPurger worldPurger,
- MVPlayerListener playerListener,
- BlockSafety blockSafety,
- SafeTTeleporter safeTTeleporter,
- LocationManipulation locationManipulation,
- Server server,
- World world,
- WorldProperties properties,
- boolean fixSpawn
- ) {
- this.worldManager = worldManager;
- this.config = config;
- this.worldPurger = worldPurger;
- this.playerListener = playerListener;
- this.blockSafety = blockSafety;
- this.safeTTeleporter = safeTTeleporter;
- this.locationManipulation = locationManipulation;
- this.server = server;
-
- this.name = world.getName();
- this.worldUID = world.getUID();
- this.props = properties;
-
- setupProperties();
-
- if (!fixSpawn) {
- props.setAdjustSpawn(false);
- }
-
- // Setup spawn separately so we can use the validator with the world spawn value..
- final SpawnLocationPropertyValidator spawnValidator = new SpawnLocationPropertyValidator();
- this.props.setValidator("spawn", spawnValidator);
- this.props.spawnLocation.setWorld(world);
- if (this.props.spawnLocation instanceof NullLocation) {
- final SpawnLocation newLoc = new SpawnLocation(readSpawnFromWorld(world));
- this.props.spawnLocation = newLoc;
- world.setSpawnLocation(newLoc.getBlockX(), newLoc.getBlockY(), newLoc.getBlockZ());
- }
-
- this.props.environment = world.getEnvironment();
- this.props.seed = world.getSeed();
-
- this.initPerms();
-
- this.props.flushChanges();
-
- validateProperties();
- }
-
- private void setupProperties() {
- this.props.setMVWorld(this);
- this.props.pvp = new VirtualProperty() {
- @Override
- public void set(Boolean newValue) {
- final World world = getCBWorld();
- if (world != null) {
- world.setPVP(newValue);
- }
- }
-
- @Override
- public Boolean get() {
- final World world = getCBWorld();
- return world != null ? world.getPVP() : null;
- }
- };
-
- this.props.difficulty = new VirtualProperty() {
- @Override
- public void set(Difficulty newValue) {
- final World world = getCBWorld();
- if (world != null) {
- world.setDifficulty(newValue);
- }
- }
-
- @Override
- public Difficulty get() {
- final World world = getCBWorld();
- return world != null ? world.getDifficulty() : null;
- }
- };
-
- this.props.keepSpawnInMemory = new VirtualProperty() {
- @Override
- public void set(Boolean newValue) {
- final World world = getCBWorld();
- if (world != null) {
- world.setKeepSpawnInMemory(newValue);
- }
- }
-
- @Override
- public Boolean get() {
- final World world = getCBWorld();
- return world != null ? world.getKeepSpawnInMemory() : null;
- }
- };
-
- this.props.spawn = new VirtualProperty() {
- @Override
- public void set(Location newValue) {
- if (getCBWorld() != null)
- getCBWorld().setSpawnLocation(newValue.getBlockX(), newValue.getBlockY(), newValue.getBlockZ());
-
- props.spawnLocation = new SpawnLocation(newValue);
- }
-
- @Override
- public Location get() {
- props.spawnLocation.setWorld(getCBWorld());
- // basically, everybody should accept our "SpawnLocation", right?
- // so just returning it should be fine
- return props.spawnLocation;
- }
- };
-
- this.props.time = new VirtualProperty() {
- @Override
- public void set(Long newValue) {
- final World world = getCBWorld();
- if (world != null) {
- world.setTime(newValue);
- }
- }
-
- @Override
- public Long get() {
- final World world = getCBWorld();
- return world != null ? world.getTime() : null;
- }
- };
-
- this.props.setValidator("scale", new ScalePropertyValidator());
- this.props.setValidator("respawnWorld", new RespawnWorldPropertyValidator());
- this.props.setValidator("allowWeather", new AllowWeatherPropertyValidator());
- this.props.setValidator("spawning", new SpawningPropertyValidator());
- this.props.setValidator("gameMode", new GameModePropertyValidator());
-
- //this.props.validate();
- }
-
- /**
- * This method is here to provide a stopgap until the add/remove/clear methods are implemented with
- * SerializationConfig.
- */
- public void validateEntitySpawns() {
- setAllowAnimalSpawn(canAnimalsSpawn());
- setAllowMonsterSpawn(canMonstersSpawn());
- }
-
- private void validateProperties() {
- setPVPMode(isPVPEnabled());
- setDifficulty(getDifficulty());
- setKeepSpawnInMemory(isKeepingSpawnInMemory());
- setScaling(getScaling());
- setRespawnToWorld(this.props.getRespawnToWorld());
- validateEntitySpawns();
- setGameMode(getGameMode());
- }
-
- /**
- * Validates the scale-property.
- */
- private final class ScalePropertyValidator extends WorldPropertyValidator {
- @Override
- public Double validateChange(String property, Double newValue, Double oldValue,
- SimpleMVWorld object) throws ChangeDeniedException {
- if (newValue <= 0) {
- Logging.fine("Someone tried to set a scale <= 0, aborting!");
- throw new ChangeDeniedException();
- }
- return super.validateChange(property, newValue, oldValue, object);
- }
- }
-
- /**
- * Validates the respawnWorld-property.
- */
- private final class RespawnWorldPropertyValidator extends WorldPropertyValidator {
- @Override
- public String validateChange(String property, String newValue, String oldValue,
- SimpleMVWorld object) throws ChangeDeniedException {
- if (!newValue.isEmpty() && !worldManager.isMVWorld(newValue))
- throw new ChangeDeniedException();
- return super.validateChange(property, newValue, oldValue, object);
- }
- }
-
-
-
- /**
- * Used to apply the allowWeather-property.
- */
- private final class AllowWeatherPropertyValidator extends WorldPropertyValidator {
- @Override
- public Boolean validateChange(String property, Boolean newValue, Boolean oldValue,
- SimpleMVWorld object) throws ChangeDeniedException {
- if (!newValue) {
- final World world = getCBWorld();
- if (world != null) {
- world.setStorm(false);
- world.setThundering(false);
- }
- }
- return super.validateChange(property, newValue, oldValue, object);
- }
- }
-
- /**
- * Used to apply the spawning-property.
- */
- private final class SpawningPropertyValidator extends WorldPropertyValidator {
- @Override
- public SpawnSettings validateChange(String property, SpawnSettings newValue, SpawnSettings oldValue,
- SimpleMVWorld object) throws ChangeDeniedException {
- boolean allowMonsters, allowAnimals;
- if (getAnimalList().isEmpty()) {
- allowAnimals = canAnimalsSpawn();
- } else {
- allowAnimals = true;
- }
- if (getMonsterList().isEmpty()) {
- allowMonsters = canMonstersSpawn();
- } else {
- allowMonsters = true;
- }
- final World world = getCBWorld();
- if (world != null) {
- if (SimpleMVWorld.this.props.getAnimalSpawnRate() != -1) {
- world.setTicksPerAnimalSpawns(SimpleMVWorld.this.props.getAnimalSpawnRate());
- }
- if (SimpleMVWorld.this.props.getMonsterSpawnRate() != -1) {
- world.setTicksPerMonsterSpawns(SimpleMVWorld.this.props.getMonsterSpawnRate());
- }
- world.setSpawnFlags(allowMonsters, allowAnimals);
- }
- if (config.isAutoPurgeEntities()) {
- worldPurger.purgeWorld(SimpleMVWorld.this);
- }
- return super.validateChange(property, newValue, oldValue, object);
- }
- }
-
- /**
- * Used to apply the gameMode-property.
- */
- private final class GameModePropertyValidator extends WorldPropertyValidator {
- @Override
- public GameMode validateChange(String property, GameMode newValue, GameMode oldValue,
- SimpleMVWorld object) throws ChangeDeniedException {
- for (Player p : server.getWorld(getName()).getPlayers()) {
- Logging.finer(String.format("Setting %s's GameMode to %s",
- p.getName(), newValue.toString()));
- //playerListener.handleGameModeAndFlight(p, SimpleMVWorld.this);
- }
- return super.validateChange(property, newValue, oldValue, object);
- }
- }
-
- /**
- * Validator for the spawnLocation-property.
- */
- private final class SpawnLocationPropertyValidator extends WorldPropertyValidator {
- @Override
- public Location validateChange(String property, Location newValue, Location oldValue,
- SimpleMVWorld object) throws ChangeDeniedException {
- if (newValue == null)
- throw new ChangeDeniedException();
- if (props.getAdjustSpawn()) {
- // verify that the location is safe
- if (!blockSafety.playerCanSpawnHereSafely(newValue)) {
- // it's not ==> find a better one!
- Logging.warning(String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias()));
- Logging.warning("Old Location: " + locationManipulation.strCoordsRaw(oldValue));
- Logging.warning("New (unsafe) Location: " + locationManipulation.strCoordsRaw(newValue));
- newValue = safeTTeleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
- if (newValue == null) {
- Logging.warning("Couldn't fix the location. I have to abort the spawn location-change :/");
- throw new ChangeDeniedException();
- }
- Logging.warning("New (safe) Location: " + locationManipulation.strCoordsRaw(newValue));
- }
- }
- return super.validateChange(property, newValue, oldValue, object);
- }
- }
-
- private Permission permission;
- private Permission exempt;
- private Permission ignoreperm;
- private Permission limitbypassperm;
-
- /**
- * Null-location.
- */
- @SerializableAs("MVNullLocation (It's a bug if you see this in your config file)")
- public static final class NullLocation extends SpawnLocation {
- public NullLocation() {
- super(0, -1, 0);
- }
-
- @Override
- public Location clone() {
- throw new UnsupportedOperationException();
- };
-
- @Override
- public Map serialize() {
- return Collections.emptyMap();
- }
-
- /**
- * Let Bukkit be able to deserialize this.
- * @param args The map.
- * @return The deserialized object.
- */
- public static NullLocation deserialize(Map args) {
- return new NullLocation();
- }
-
- @Override
- public Vector toVector() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int hashCode() {
- return -1;
- };
-
- @Override
- public String toString() {
- return "Location{null}";
- };
- }
-
- /**
- * Initializes permissions.
- */
- private void initPerms() {
- this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.OP);
- // This guy is special. He shouldn't be added to any parent perms.
- this.ignoreperm = new Permission("mv.bypass.gamemode." + this.getName(),
- "Allows players with this permission to ignore gamemode changes.", PermissionDefault.FALSE);
-
- 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);
-
- this.limitbypassperm = new Permission("mv.bypass.playerlimit." + this.getName(),
- "A player who can enter this world regardless of wether its full", PermissionDefault.OP);
- try {
- this.server.getPluginManager().addPermission(this.permission);
- this.server.getPluginManager().addPermission(this.exempt);
- this.server.getPluginManager().addPermission(this.ignoreperm);
- this.server.getPluginManager().addPermission(this.limitbypassperm);
- // Add the permission and exempt to parents.
- this.addToUpperLists(this.permission);
-
- // Add ignore to it's parent:
- this.ignoreperm.addParent("mv.bypass.gamemode.*", true);
- // Add limit bypass to it's parent
- this.limitbypassperm.addParent("mv.bypass.playerlimit.*", true);
- } catch (IllegalArgumentException e) {
- Logging.finer("Permissions nodes were already added for " + this.name);
- }
- }
-
- private Location readSpawnFromWorld(World w) {
- Location location = w.getSpawnLocation();
- // Set the worldspawn to our configspawn
- // Verify that location was safe
- if (!blockSafety.playerCanSpawnHereSafely(location)) {
- if (!this.getAdjustSpawn()) {
- Logging.fine("Spawn location from world.dat file was unsafe!!");
- Logging.fine("NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to.");
- Logging.fine("To turn on spawn adjustment for this world simply type:");
- Logging.fine("/mvm set adjustspawn true " + this.getAlias());
- return location;
- }
- // If it's not, find a better one.
- Logging.warning("Spawn location from world.dat file was unsafe. Adjusting...");
- Logging.warning("Original Location: " + locationManipulation.strCoordsRaw(location));
- Location newSpawn = safeTTeleporter.getSafeLocation(location,
- SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
- // 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) {
- Logging.info("New Spawn for '%s' is located at: %s",
- this.getName(), locationManipulation.locationToString(newSpawn));
- return newSpawn;
- } else {
- // If it's a standard end world, let's check in a better place:
- Location newerSpawn;
- newerSpawn = blockSafety.getTopBlock(new Location(w, 0, 0, 0));
- if (newerSpawn != null) {
- Logging.info("New Spawn for '%s' is located at: %s",
- this.getName(), locationManipulation.locationToString(newerSpawn));
- return newerSpawn;
- } else {
- Logging.severe("Safe spawn NOT found!!!");
- }
- }
- }
- return location;
- }
-
- private void addToUpperLists(Permission perm) {
- Permission all = this.server.getPluginManager().getPermission("multiverse.*");
- Permission allWorlds = this.server.getPluginManager().getPermission("multiverse.access.*");
- Permission allExemption = this.server.getPluginManager().getPermission("multiverse.exempt.*");
-
- if (allWorlds == null) {
- allWorlds = new Permission("multiverse.access.*");
- this.server.getPluginManager().addPermission(allWorlds);
- }
- allWorlds.getChildren().put(perm.getName(), true);
- if (allExemption == null) {
- allExemption = new Permission("multiverse.exempt.*");
- this.server.getPluginManager().addPermission(allExemption);
- }
- allExemption.getChildren().put(this.exempt.getName(), true);
- if (all == null) {
- all = new Permission("multiverse.*");
- this.server.getPluginManager().addPermission(all);
- }
- all.getChildren().put("multiverse.access.*", true);
- all.getChildren().put("multiverse.exempt.*", true);
-
- this.server.getPluginManager().recalculatePermissionDefaults(all);
- this.server.getPluginManager().recalculatePermissionDefaults(allWorlds);
- }
-
- /**
- * Copies all properties from another {@link SimpleMVWorld} object.
- * @param other The other world object.
- */
- public void copyValues(SimpleMVWorld other) {
- props.copyValues(other.props);
- }
-
- /**
- * Copies all properties from a {@link WorldProperties} object.
- * @param other The world properties object.
- */
- public void copyValues(WorldProperties other) {
- props.copyValues(other);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public World getCBWorld() {
- final World world = server.getWorld(worldUID);
- if (world == null) {
- throw new IllegalStateException("Lost reference to bukkit world '" + name + "'");
- }
- return world;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getColoredWorldString() {
- if (props.getAlias().length() == 0) {
- props.setAlias(this.getName());
- }
-
- if ((props.getColor() == null) || (props.getColor().getColor() == null)) {
- this.props.setColor(EnglishChatColor.WHITE);
- }
-
- StringBuilder nameBuilder = new StringBuilder().append(props.getColor().getColor());
- if (props.getStyle().getColor() != null)
- nameBuilder.append(props.getStyle().getColor());
- nameBuilder.append(props.getAlias()).append(ChatColor.WHITE).toString();
-
- return nameBuilder.toString();
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean clearList(String property) {
- return clearVariable(property);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean clearVariable(String property) {
- List list = getOldAndEvilList(property);
- if (list == null)
- return false;
- list.clear();
- validateEntitySpawns();
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean addToVariable(String property, String value) {
- List list = getOldAndEvilList(property);
- if (list == null)
- return false;
- list.add(value);
- validateEntitySpawns();
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean removeFromVariable(String property, String value) {
- List list = getOldAndEvilList(property);
- if (list == null)
- return false;
- list.remove(value);
- validateEntitySpawns();
- return true;
- }
-
- /**
- * @deprecated This is deprecated.
- */
- @Deprecated
- private List getOldAndEvilList(String property) {
- if (property.equalsIgnoreCase("worldblacklist"))
- return this.props.getWorldBlacklist();
- else if (property.equalsIgnoreCase("animals"))
- return this.props.getAnimalList();
- else if (property.equalsIgnoreCase("monsters"))
- return this.props.getMonsterList();
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPropertyValue(String property) throws PropertyDoesNotExistException {
- try {
- return this.props.getProperty(property, true);
- } catch (NoSuchPropertyException e) {
- throw new PropertyDoesNotExistException(property, e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException {
- try {
- return this.props.setProperty(property, value, true);
- } catch (NoSuchPropertyException e) {
- throw new PropertyDoesNotExistException(property, e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPropertyHelp(String property) throws PropertyDoesNotExistException {
- try {
- return this.props.getPropertyDescription(property, true);
- } catch (NoSuchPropertyException e) {
- throw new PropertyDoesNotExistException(property, e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public WorldType getWorldType() {
- // This variable is not settable in-game, therefore does not get a property.
- final World world = getCBWorld();
- return world != null ? world.getWorldType() : null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Environment getEnvironment() {
- return this.props.getEnvironment();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEnvironment(Environment environment) {
- this.props.setEnvironment(environment);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getSeed() {
- return this.props.getSeed();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSeed(long seed) {
- this.props.setSeed(seed);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getGenerator() {
- return this.props.getGenerator();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setGenerator(String generator) {
- this.props.setGenerator(generator);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getPlayerLimit() {
- return this.props.getPlayerLimit();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setPlayerLimit(int limit) {
- this.props.setPlayerLimit(limit);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getName() {
- // This variable is not settable in-game, therefore does not get a property.
- return this.name;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getPermissibleName() {
- return this.name.toLowerCase();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getAlias() {
- if (this.props.getAlias() == null || this.props.getAlias().length() == 0) {
- return this.name;
- }
- return this.props.getAlias();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAlias(String alias) {
- this.props.setAlias(alias);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean canAnimalsSpawn() {
- return this.props.canAnimalsSpawn();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAllowAnimalSpawn(boolean animals) {
- this.props.setAllowAnimalSpawn(animals);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List getAnimalList() {
- // These don't fire events at the moment. Should they?
- return this.props.getAnimalList();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean canMonstersSpawn() {
- return this.props.canMonstersSpawn();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAllowMonsterSpawn(boolean monsters) {
- this.props.setAllowMonsterSpawn(monsters);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List getMonsterList() {
- // These don't fire events at the moment. Should they?
- return this.props.getMonsterList();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isPVPEnabled() {
- return this.props.isPVPEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setPVPMode(boolean pvp) {
- this.props.setPVPMode(pvp);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isHidden() {
- return this.props.isHidden();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setHidden(boolean hidden) {
- this.props.setHidden(hidden);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List getWorldBlacklist() {
- return this.props.getWorldBlacklist();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public double getScaling() {
- return this.props.getScaling();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setScaling(double scaling) {
- return this.props.setScaling(scaling);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setColor(String aliasColor) {
- return props.setColor(aliasColor);
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean isValidAliasColor(String aliasColor) {
- return (EnglishChatColor.fromString(aliasColor) != null);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ChatColor getColor() {
- return this.props.getColor().getColor();
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean getFakePVP() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public World getRespawnToWorld() {
- return this.server.getWorld(props.getRespawnToWorld());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setRespawnToWorld(String respawnToWorld) {
- if (!this.worldManager.isMVWorld(respawnToWorld)) return false;
- return this.props.setRespawnToWorld(respawnToWorld);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Permission getAccessPermission() {
- return this.permission;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Material getCurrency() {
- return this.props.getCurrency();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setCurrency(@Nullable Material currency) {
- this.props.setCurrency(currency);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public double getPrice() {
- return this.props.getPrice();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setPrice(double price) {
- this.props.setPrice(price);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Permission getExemptPermission() {
- return this.exempt;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setGameMode(String mode) {
- return this.props.setGameMode(mode);
- }
-
- @Override
- public boolean setGameMode(GameMode mode) {
- return this.props.setGameMode(mode);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public GameMode getGameMode() {
- return this.props.getGameMode();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEnableWeather(boolean weather) {
- this.props.setEnableWeather(weather);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isWeatherEnabled() {
- return this.props.isWeatherEnabled();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isKeepingSpawnInMemory() {
- return this.props.isKeepingSpawnInMemory();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setKeepSpawnInMemory(boolean value) {
- this.props.setKeepSpawnInMemory(value);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getHunger() {
- return this.props.getHunger();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setHunger(boolean hunger) {
- this.props.setHunger(hunger);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Location getSpawnLocation() {
- return this.props.getSpawnLocation();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSpawnLocation(Location l) {
- this.props.setSpawnLocation(l);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Difficulty getDifficulty() {
- return this.props.getDifficulty();
- }
-
- /**
- * {@inheritDoc}
- *
- * @deprecated This is deprecated.
- */
- @Override
- @Deprecated
- public boolean setDifficulty(String difficulty) {
- return this.props.setDifficulty(difficulty);
- }
-
- @Override
- public boolean setDifficulty(Difficulty difficulty) {
- return this.props.setDifficulty(difficulty);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getAutoHeal() {
- return this.props.getAutoHeal();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAutoHeal(boolean heal) {
- this.props.setAutoHeal(heal);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAdjustSpawn(boolean adjust) {
- this.props.setAdjustSpawn(adjust);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getAdjustSpawn() {
- return this.props.getAdjustSpawn();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAutoLoad(boolean load) {
- this.props.setAutoLoad(load);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getAutoLoad() {
- return this.props.getAutoLoad();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setBedRespawn(boolean respawn) {
- this.props.setBedRespawn(respawn);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getBedRespawn() {
- return this.props.getBedRespawn();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getAllPropertyNames() {
- return this.props.getAllPropertyNames();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getTime() {
- return this.props.getTime();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setTime(String timeAsString) {
- return this.props.setTime(timeAsString);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public AllowedPortalType getAllowedPortals() {
- return props.getAllowedPortals();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void allowPortalMaking(AllowedPortalType portalType) {
- this.props.allowPortalMaking(portalType);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ChatColor getStyle() {
- return this.props.getStyle().getColor();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean setStyle(String style) {
- return this.props.setStyle(style);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getAllowFlight() {
- return this.props.getAllowFlight();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setAllowFlight(final boolean allowFlight) {
- this.props.setAllowFlight(allowFlight);
- }
-
- @Override
- public String toString() {
- final JSONObject jsonData = new JSONObject();
- jsonData.put("Name", getName());
- jsonData.put("Env", getEnvironment().toString());
- jsonData.put("Type", getWorldType().toString());
- jsonData.put("Gen", getGenerator());
- final JSONObject topLevel = new JSONObject();
- topLevel.put(getClass().getSimpleName() + "@" + hashCode(), jsonData);
- return topLevel.toString();
- }
-}
diff --git a/src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorldManager.java b/src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorldManager.java
deleted file mode 100644
index c77a26ba..00000000
--- a/src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorldManager.java
+++ /dev/null
@@ -1,1040 +0,0 @@
-/******************************************************************************
- * Multiverse 2 Copyright (c) the Multiverse Team 2011. *
- * Multiverse 2 is licensed under the BSD License. *
- * For more information please check the README.md file included *
- * with this project. *
- ******************************************************************************/
-
-package org.mvplugins.multiverse.core.world;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.Stack;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-import com.dumptruckman.minecraft.util.Logging;
-import jakarta.inject.Inject;
-import org.bukkit.Bukkit;
-import org.bukkit.GameRule;
-import org.bukkit.Location;
-import org.bukkit.Server;
-import org.bukkit.World;
-import org.bukkit.World.Environment;
-import org.bukkit.WorldCreator;
-import org.bukkit.WorldType;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-import org.bukkit.generator.ChunkGenerator;
-import org.bukkit.permissions.Permission;
-import org.bukkit.permissions.PermissionDefault;
-import org.bukkit.plugin.Plugin;
-import org.jvnet.hk2.annotations.Service;
-
-import org.mvplugins.multiverse.core.MultiverseCore;
-import org.mvplugins.multiverse.core.api.BlockSafety;
-import org.mvplugins.multiverse.core.api.LocationManipulation;
-import org.mvplugins.multiverse.core.api.MVWorld;
-import org.mvplugins.multiverse.core.api.MVWorldManager;
-import org.mvplugins.multiverse.core.api.SafeTTeleporter;
-import org.mvplugins.multiverse.core.api.WorldPurger;
-import org.mvplugins.multiverse.core.config.MVCoreConfig;
-import org.mvplugins.multiverse.core.event.MVWorldDeleteEvent;
-import org.mvplugins.multiverse.core.listeners.MVPlayerListener;
-import org.mvplugins.multiverse.core.utils.UnsafeCallWrapper;
-import org.mvplugins.multiverse.core.utils.file.FileUtils;
-
-import static org.mvplugins.multiverse.core.utils.file.FileUtils.getBukkitConfig;
-
-/**
- * Public facing API to add/remove Multiverse worlds.
- */
-@Service
-public class SimpleMVWorldManager implements MVWorldManager {
- public static final String WORLD_CONFIG_FILE = "worlds.yml";
-
- private final MultiverseCore plugin;
- private final MVCoreConfig config;
- private final MVPlayerListener playerListener;
- private final BlockSafety blockSafety;
- private final SafeTTeleporter safeTTeleporter;
- private final LocationManipulation locationManipulation;
- private final UnsafeCallWrapper unsafeCallWrapper;
- private final Server server;
- private final WorldPurger worldPurger;
- private final Map worlds;
- private Map worldsFromTheConfig;
- private FileConfiguration configWorlds = null;
- private Map defaultGens;
- private String firstSpawn;
-
- @Inject
- public SimpleMVWorldManager(
- MultiverseCore plugin,
- MVCoreConfig config,
- MVPlayerListener playerListener,
- BlockSafety blockSafety,
- SafeTTeleporter safeTTeleporter,
- LocationManipulation locationManipulation,
- UnsafeCallWrapper unsafeCallWrapper,
- WorldPurger worldPurger,
- Server server
- ) {
- this.plugin = plugin;
- this.config = config;
- this.playerListener = playerListener;
- this.blockSafety = blockSafety;
- this.safeTTeleporter = safeTTeleporter;
- this.locationManipulation = locationManipulation;
- this.unsafeCallWrapper = unsafeCallWrapper;
- this.worldPurger = worldPurger;
- this.server = server;
-
- this.worldsFromTheConfig = new HashMap();
- this.worlds = new ConcurrentHashMap();
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void getDefaultWorldGenerators() {
- this.defaultGens = new HashMap<>();
-
- File bukkitConfigFile = getBukkitConfig();
- if (bukkitConfigFile == null) {
- Logging.warning("Any Default worldgenerators will not be loaded!");
- return;
- }
-
- FileConfiguration bukkitConfig = YamlConfiguration.loadConfiguration(bukkitConfigFile);
-
- if (bukkitConfig.isConfigurationSection("worlds")) {
- Set keys = bukkitConfig.getConfigurationSection("worlds").getKeys(false);
- for (String key : keys) {
- defaultGens.put(key, bukkitConfig.getString("worlds." + key + ".generator", ""));
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean cloneWorld(String oldName, String newName) {
- // Make sure we already know about the old world and that we don't
- // already know about the new world.
- if (!this.worldsFromTheConfig.containsKey(oldName)) {
- for (Map.Entry entry : this.worldsFromTheConfig.entrySet()) {
- if (oldName.equals(entry.getValue().getAlias())) {
- oldName = entry.getKey();
- break;
- }
- }
- if (!this.worldsFromTheConfig.containsKey(oldName)) {
- Logging.warning("Old world '%s' does not exist", oldName);
- return false;
- }
- }
- if (this.isMVWorld(newName)) {
- Logging.warning("New world '%s' already exists", newName);
- return false;
- }
-
- // Check for valid world name
- if (!(WorldNameChecker.isValidWorldName(oldName) && WorldNameChecker.isValidWorldName(newName))) {
- return false;
- }
-
- final File oldWorldFile = new File(this.server.getWorldContainer(), oldName);
- final File newWorldFile = new File(this.server.getWorldContainer(), newName);
- final List ignoreFiles = new ArrayList<>(Arrays.asList("session.lock", "uid.dat"));
-
- // Make sure the new world doesn't exist outside of multiverse.
- if (newWorldFile.exists()) {
- Logging.warning("Folder for new world '%s' already exists", newName);
- return false;
- }
-
- // Load the old world... but just the metadata.
- boolean wasJustLoaded = false;
- boolean wasLoadSpawn = false;
- if (this.server.getWorld(oldName) == null) {
- wasJustLoaded = true;
- WorldProperties props = this.worldsFromTheConfig.get(oldName);
- wasLoadSpawn = props.isKeepingSpawnInMemory();
- if (wasLoadSpawn) {
- // No chunks please.
- props.setKeepSpawnInMemory(false);
- }
- if (!this.loadWorld(oldName)) {
- return false;
- }
- this.server.getWorld(oldName).setAutoSave(false);
- }
-
- // Grab a bit of metadata from the old world.
- MVWorld oldWorld = getMVWorld(oldName);
-
- // Don't need the loaded world anymore.
- if (wasJustLoaded) {
- this.unloadWorld(oldName, true);
- oldWorld = null;
- if (wasLoadSpawn) {
- this.worldsFromTheConfig.get(oldName).setKeepSpawnInMemory(true);
- }
- }
-
- boolean wasAutoSave = false;
- if (oldWorld != null && oldWorld.getCBWorld().isAutoSave()) {
- wasAutoSave = true;
- Logging.config("Saving world '%s'", oldName);
- oldWorld.getCBWorld().setAutoSave(false);
- oldWorld.getCBWorld().save();
- }
- Logging.config("Copying files for world '%s'", oldName);
- if (!FileUtils.copyFolder(oldWorldFile, newWorldFile, ignoreFiles)) {
- Logging.warning("Failed to copy files for world '%s', see the log info", newName);
- return false;
- }
- if (oldWorld != null && wasAutoSave) {
- oldWorld.getCBWorld().setAutoSave(true);
- }
-
- if (newWorldFile.exists()) {
- Logging.fine("Succeeded at copying files");
-
- // initialize new properties with old ones
- WorldProperties newProps = new WorldProperties();
- newProps.copyValues(this.worldsFromTheConfig.get(oldName));
- // don't keep the alias the same -- that would be useless
- newProps.setAlias("");
- // store the new properties in worlds config map
- this.worldsFromTheConfig.put(newName, newProps);
-
- // save the worlds config to disk (worlds.yml)
- if (!saveWorldsConfig()) {
- Logging.severe("Failed to save worlds.yml");
- return false;
- }
-
- // actually load the world
- if (doLoad(newName)) {
- Logging.fine("Succeeded at loading cloned world '" + newName + "'");
- return true;
- }
- Logging.severe("Failed to load the cloned world '" + newName + "'");
- return false;
- }
-
- Logging.warning("Failed to copy files for world '%s', see the log info", newName);
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- 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, Boolean generateStructures,
- String generator, boolean useSpawnAdjust) {
- if (name.equalsIgnoreCase("plugins") || name.equalsIgnoreCase("logs")) {
- return false;
- }
-
- if (!WorldNameChecker.isValidWorldName(name)) {
- Logging.warning("Invalid world name '" + name + "'");
- Logging.warning("World name should not contain spaces or special characters!");
- return false;
- }
-
- Long seed = null;
- WorldCreator c = new WorldCreator(name);
- if (seedString != null && seedString.length() > 0) {
- try {
- seed = Long.parseLong(seedString);
- } catch (NumberFormatException numberformatexception) {
- seed = (long) seedString.hashCode();
- }
- c.seed(seed);
- }
-
- // TODO: Use the fancy kind with the commandSender
- if (generator != null && generator.length() != 0) {
- c.generator(generator);
- }
- c.environment(env);
- if (type != null) {
- c.type(type);
- }
- if (generateStructures != null) {
- c.generateStructures(generateStructures);
- }
-
- // Important: doLoad() needs the MVWorld-object in worldsFromTheConfig
- if (!worldsFromTheConfig.containsKey(name)) {
- WorldProperties props = new WorldProperties(useSpawnAdjust, env);
- worldsFromTheConfig.put(name, props);
- }
-
- 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) {
- builder.append(" & seed: ").append(seed);
- }
- if (generator != null) {
- builder.append(" & generator: ").append(generator);
- }
- Logging.info(builder.toString());
-
- if (!doLoad(c, true)) {
- Logging.severe("Failed to Create/Load the world '" + name + "'");
- return false;
- }
-
- // set generator (special case because we can't read it from org.bukkit.World)
- this.worlds.get(name).setGenerator(generator);
-
- this.saveWorldsConfig();
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ChunkGenerator getChunkGenerator(String generator, final String generatorID, final String worldName) {
- if (generator == null) {
- return null;
- }
-
- final Plugin myPlugin = this.server.getPluginManager().getPlugin(generator);
- if (myPlugin == null) {
- return null;
- } else {
- return unsafeCallWrapper.wrap(new Callable() {
- @Override
- public ChunkGenerator call() throws Exception {
- return myPlugin.getDefaultWorldGenerator(worldName, generatorID);
- }
- }, myPlugin.getName(), "Failed to get the default chunk generator: %s");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean removeWorldFromConfig(String name) {
- if (!unloadWorld(name)) {
- return false;
- }
- if (this.worldsFromTheConfig.containsKey(name)) {
- this.worldsFromTheConfig.remove(name);
- Logging.info("World '%s' was removed from config.yml", name);
-
- this.saveWorldsConfig();
- return true;
- } else {
- Logging.info("World '%s' was already removed from config.yml", name);
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setFirstSpawnWorld(String world) {
- if ((world == null) && (this.server.getWorlds().size() > 0)) {
- this.firstSpawn = this.server.getWorlds().get(0).getName();
- } else {
- this.firstSpawn = world;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public MVWorld getFirstSpawnWorld() {
- MVWorld world = this.getMVWorld(this.firstSpawn);
- if (world == null) {
- // If the spawn world was unloaded, get the default world
- Logging.warning("The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
- try {
- return this.getMVWorld(this.server.getWorlds().get(0));
- } catch (IndexOutOfBoundsException e) {
- // This should only happen in tests.
- return null;
- }
- }
- return world;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean unloadWorld(String name) {
- return this.unloadWorld(name, true);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean unloadWorld(String name, boolean unloadBukkit) {
- if (this.worlds.containsKey(name)) {
- this.worldsFromTheConfig.get(name).cacheVirtualProperties();
- if (unloadBukkit && this.unloadWorldFromBukkit(name, true)) {
- this.worlds.remove(name);
- Logging.info("World '%s' was unloaded from Bukkit.", name);
- return true;
- } else if (!unloadBukkit) {
- this.worlds.remove(name);
- Logging.info("World '%s' was unloaded from Multiverse.", name);
- return true;
- } else {
- Logging.warning("World '%s' could not be unloaded from Bukkit. Is it a default world?", name);
- }
- } else if (this.server.getWorld(name) != null) {
- Logging.warning("Hmm Multiverse does not know about this world but it's loaded in memory.");
- Logging.warning("To let Multiverse know about it, use:");
- Logging.warning("/mv import %s %s", name, this.server.getWorld(name).getEnvironment().toString());
- } else if (this.worldsFromTheConfig.containsKey(name)) {
- return true; // it's already unloaded
- } else {
- Logging.info("Multiverse does not know about '%s' and it's not loaded by Bukkit.", name);
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean loadWorld(String name) {
- // Check if the World is already loaded
- if (this.worlds.containsKey(name)) {
- return true;
- }
-
- // Check that the world is in the config
- if (worldsFromTheConfig.containsKey(name)) {
- return doLoad(name);
- } else {
- return false;
- }
- }
-
- private void brokenWorld(String name) {
- Logging.severe("The world '" + name + "' could NOT be loaded because it contains errors and is probably corrupt!");
- Logging.severe("Try using Minecraft Region Fixer to repair your world! '" + name + "'");
- Logging.severe("https://github.com/Fenixin/Minecraft-Region-Fixer");
- }
-
- private void nullWorld(String name) {
- Logging.severe("The world '" + name + "' could NOT be loaded because the server didn't like it!");
- Logging.severe("We don't really know why this is. Contact the developer of your server software!");
- Logging.severe("Server version info: " + Bukkit.getServer().getVersion());
- }
-
- private boolean doLoad(String name) {
- return doLoad(name, false, null);
- }
-
- private boolean doLoad(String name, boolean ignoreExists, WorldType type) {
- if (!worldsFromTheConfig.containsKey(name))
- throw new IllegalArgumentException("That world doesn't exist!");
-
- final WorldProperties world = worldsFromTheConfig.get(name);
- final WorldCreator creator = WorldCreator.name(name);
-
- creator.environment(world.getEnvironment()).seed(world.getSeed());
- if (type != null) {
- creator.type(type);
- }
-
- boolean generatorSuccess = true;
- if ((world.getGenerator() != null) && (!world.getGenerator().equals("null")))
- generatorSuccess = null != unsafeCallWrapper.wrap(new Callable