From fbab3bc2690ac92a8d71589f2ff565cc4ecc68d5 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Tue, 12 Sep 2023 23:05:51 +0800 Subject: [PATCH] Nuke the old world manager --- .../multiverse/core/MultiverseCore.java | 12 +- .../multiverse/core/api/MVWorld.java | 676 --------- .../multiverse/core/api/MVWorldManager.java | 325 ----- .../multiverse/core/api/WorldPurger.java | 70 - .../core/commands/CloneCommand.java | 6 +- .../core/commands/CoordinatesCommand.java | 2 +- .../core/commands/CreateCommand.java | 6 +- .../core/commands/DeleteCommand.java | 2 +- .../core/commands/DumpsCommand.java | 3 +- .../core/commands/GameruleCommand.java | 2 +- .../core/commands/GamerulesCommand.java | 2 +- .../core/commands/ImportCommand.java | 8 +- .../multiverse/core/commands/ListCommand.java | 9 +- .../multiverse/core/commands/LoadCommand.java | 2 +- .../core/commands/RegenCommand.java | 6 +- .../core/commands/ReloadCommand.java | 2 +- .../core/commands/RemoveCommand.java | 2 +- .../core/commands/UnloadCommand.java | 6 +- .../commandtools/MVCommandCompletions.java | 6 +- .../commandtools/MVCommandConditions.java | 23 +- .../core/commandtools/MVCommandContexts.java | 4 +- .../core/commandtools/MVCommandManager.java | 11 +- .../destination/core/CannonDestination.java | 4 +- .../destination/core/ExactDestination.java | 4 +- .../destination/core/WorldDestination.java | 4 +- .../core/WorldDestinationInstance.java | 2 +- .../multiverse/core/economy/MVEconomist.java | 3 +- .../core/event/MVWorldDeleteEvent.java | 15 +- .../event/MVWorldPropertyChangeEvent.java | 9 +- .../core/listeners/MVChatListener.java | 2 +- .../core/listeners/MVEntityListener.java | 4 +- .../core/listeners/MVPlayerListener.java | 12 +- .../core/listeners/MVPortalListener.java | 4 +- .../core/listeners/MVWeatherListener.java | 2 +- .../core/listeners/MVWorldListener.java | 8 +- .../permissions/CorePermissionsChecker.java | 15 +- .../MultiverseCorePlaceholders.java | 4 +- .../utils/metrics/MetricsConfigurator.java | 4 +- .../LoadedMultiverseWorld.java | 8 +- .../{worldnew => world}/MultiverseWorld.java | 6 +- .../multiverse/core/world/SimpleMVWorld.java | 1259 ----------------- .../core/world/SimpleMVWorldManager.java | 1040 -------------- .../core/world/SimpleWorldPurger.java | 198 --- .../{worldnew => world}/WorldManager.java | 48 +- .../core/world/WorldNameChecker.java | 31 +- .../core/world/WorldProperties.java | 655 --------- .../core/{worldnew => world}/WorldPurger.java | 2 +- .../AllowedPortalType.java | 2 +- .../config/LegacyAliasMigrator.java | 2 +- .../config/NullLocation.java | 8 +- .../config/SpawnLocation.java | 2 +- .../config/WorldConfig.java | 7 +- .../config/WorldConfigNodes.java | 8 +- .../config/WorldsConfigManager.java | 6 +- .../core/world/config/package-info.java | 1 + .../core/world/configuration/Action.java | 30 - .../world/configuration/AddProperties.java | 26 - .../world/configuration/EnglishChatColor.java | 95 -- .../world/configuration/EnglishChatStyle.java | 49 - .../core/world/configuration/EntryFee.java | 89 -- .../world/configuration/SpawnSettings.java | 49 - .../world/configuration/SubSpawnSettings.java | 75 - .../configuration/WorldPropertyValidator.java | 26 - .../world/configuration/package-info.java | 4 - .../entrycheck/BlacklistResult.java | 2 +- .../entrycheck/EntryFeeResult.java | 2 +- .../entrycheck/PlayerLimitResult.java | 2 +- .../entrycheck/WorldAccessResult.java | 2 +- .../entrycheck/WorldEntryChecker.java | 9 +- .../entrycheck/WorldEntryCheckerProvider.java | 2 +- .../core/world/entrycheck/package-info.java | 1 + .../generators/GeneratorPlugin.java | 2 +- .../generators/GeneratorProvider.java | 2 +- .../generators/SimpleGeneratorPlugin.java | 2 +- .../core/world/generators/package-info.java | 1 + .../helpers/DataStore.java | 4 +- .../helpers/DataTransfer.java | 2 +- .../helpers/EnforcementHandler.java | 6 +- .../helpers/FilesManipulator.java | 2 +- .../helpers/PlayerWorldTeleporter.java | 4 +- .../core/world/helpers/package-info.java | 1 + .../options/CloneWorldOptions.java | 4 +- .../options/CreateWorldOptions.java | 2 +- .../options/ImportWorldOptions.java | 2 +- .../options/KeepWorldSettingsOptions.java | 2 +- .../options/RegenWorldOptions.java | 4 +- .../options/UnloadWorldOptions.java | 4 +- .../core/world/options/package-info.java | 1 + .../multiverse/core/world/package-info.java | 3 - .../reasons/CloneFailureReason.java | 2 +- .../reasons/CreateFailureReason.java | 2 +- .../reasons/DeleteFailureReason.java | 2 +- .../reasons/ImportFailureReason.java | 2 +- .../reasons/LoadFailureReason.java | 2 +- .../reasons/RegenFailureReason.java | 2 +- .../reasons/RemoveFailureReason.java | 2 +- .../reasons/UnloadFailureReason.java | 2 +- .../core/world/reasons/package-info.java | 1 + .../core/worldnew/WorldNameChecker.java | 160 --- .../core/worldnew/config/package-info.java | 1 - .../worldnew/entrycheck/package-info.java | 1 - .../worldnew/generators/package-info.java | 1 - .../core/worldnew/helpers/package-info.java | 1 - .../core/worldnew/options/package-info.java | 1 - .../core/worldnew/package-info.java | 1 - .../core/worldnew/reasons/package-info.java | 1 - .../multiverse/core/TestEntitySpawnRules.java | 2 - .../multiverse/core/TestWorldProperties.java | 1 - .../multiverse/core/TestWorldPurger.java | 2 - .../multiverse/core/inject/InjectionTest.kt | 2 +- .../core/world/WorldConfigMangerTest.kt | 4 +- .../multiverse/core/world/WorldConfigTest.kt | 4 +- .../multiverse/core/world/WorldManagerTest.kt | 4 +- 113 files changed, 214 insertions(+), 5064 deletions(-) delete mode 100644 src/main/java/org/mvplugins/multiverse/core/api/MVWorld.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/api/MVWorldManager.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/api/WorldPurger.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/LoadedMultiverseWorld.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/MultiverseWorld.java (99%) delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorld.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/SimpleMVWorldManager.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/SimpleWorldPurger.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/WorldManager.java (95%) delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/WorldProperties.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/WorldPurger.java (99%) rename src/main/java/org/mvplugins/multiverse/core/world/{configuration => config}/AllowedPortalType.java (96%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/config/LegacyAliasMigrator.java (98%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/config/NullLocation.java (84%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/config/SpawnLocation.java (98%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/config/WorldConfig.java (98%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/config/WorldConfigNodes.java (97%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/config/WorldsConfigManager.java (97%) create mode 100644 src/main/java/org/mvplugins/multiverse/core/world/config/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/Action.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/AddProperties.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatColor.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatStyle.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/EntryFee.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/SpawnSettings.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/SubSpawnSettings.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/WorldPropertyValidator.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/world/configuration/package-info.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/entrycheck/BlacklistResult.java (94%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/entrycheck/EntryFeeResult.java (94%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/entrycheck/PlayerLimitResult.java (94%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/entrycheck/WorldAccessResult.java (94%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/entrycheck/WorldEntryChecker.java (94%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/entrycheck/WorldEntryCheckerProvider.java (94%) create mode 100644 src/main/java/org/mvplugins/multiverse/core/world/entrycheck/package-info.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/generators/GeneratorPlugin.java (97%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/generators/GeneratorProvider.java (99%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/generators/SimpleGeneratorPlugin.java (94%) create mode 100644 src/main/java/org/mvplugins/multiverse/core/world/generators/package-info.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/helpers/DataStore.java (97%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/helpers/DataTransfer.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/helpers/EnforcementHandler.java (94%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/helpers/FilesManipulator.java (99%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/helpers/PlayerWorldTeleporter.java (96%) create mode 100644 src/main/java/org/mvplugins/multiverse/core/world/helpers/package-info.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/options/CloneWorldOptions.java (96%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/options/CreateWorldOptions.java (98%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/options/ImportWorldOptions.java (98%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/options/KeepWorldSettingsOptions.java (96%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/options/RegenWorldOptions.java (97%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/options/UnloadWorldOptions.java (94%) create mode 100644 src/main/java/org/mvplugins/multiverse/core/world/options/package-info.java rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/CloneFailureReason.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/CreateFailureReason.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/DeleteFailureReason.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/ImportFailureReason.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/LoadFailureReason.java (95%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/RegenFailureReason.java (93%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/RemoveFailureReason.java (93%) rename src/main/java/org/mvplugins/multiverse/core/{worldnew => world}/reasons/UnloadFailureReason.java (94%) create mode 100644 src/main/java/org/mvplugins/multiverse/core/world/reasons/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/WorldNameChecker.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/config/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/generators/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/options/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/package-info.java delete mode 100644 src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/package-info.java 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() { - @Override - public Object call() throws Exception { - creator.generator(world.getGenerator()); - return new Object(); - } - }, "the generator plugin", "Failed to set the generator for world '%s' to '%s': %s", name, world.getGenerator()); - - return generatorSuccess && doLoad(creator, ignoreExists); - } - - private boolean doLoad(WorldCreator creator, boolean ignoreExists) { - String worldName = creator.name(); - if (!worldsFromTheConfig.containsKey(worldName)) - throw new IllegalArgumentException("That world doesn't exist!"); - if (worlds.containsKey(worldName)) - throw new IllegalArgumentException("That world is already loaded!"); - - if (!ignoreExists && !new File(this.server.getWorldContainer(), worldName).exists() && !new File(this.server.getWorldContainer().getParent(), worldName).exists()) { - Logging.warning("WorldManager: Can't load this world because the folder was deleted/moved: " + worldName); - Logging.warning("Use '/mv remove' to remove it from the config!"); - return false; - } - - WorldProperties mvworld = worldsFromTheConfig.get(worldName); - World cbworld; - try { - cbworld = creator.createWorld(); - } catch (Exception e) { - e.printStackTrace(); - brokenWorld(worldName); - return false; - } - if (cbworld == null) { - nullWorld(worldName); - return false; - } - SimpleMVWorld world = new SimpleMVWorld(this, config, worldPurger, playerListener, blockSafety, - safeTTeleporter, locationManipulation, server, cbworld, mvworld); - if (config.isAutoPurgeEntities()) { - this.worldPurger.purgeWorld(world); - } - this.worlds.put(worldName, world); - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder) { - if (this.hasUnloadedWorld(name, false)) { - // Attempt to load if unloaded so we can actually delete the world - if (!this.doLoad(name)) { - return false; - } - } - - World world = this.server.getWorld(name); - if (world == null) { - // We can only delete loaded worlds - return false; - } - - // call the event! - MVWorldDeleteEvent mvwde = new MVWorldDeleteEvent(getMVWorld(name), removeFromConfig); - this.server.getPluginManager().callEvent(mvwde); - if (mvwde.isCancelled()) { - Logging.fine("Tried to delete a world, but the event was cancelled!"); - return false; - } - - if (removeFromConfig) { - if (!removeWorldFromConfig(name)) { - return false; - } - } else { - if (!this.unloadWorld(name)) { - return false; - } - } - - try { - File worldFile = world.getWorldFolder(); - Logging.finer("deleteWorld(): worldFile: " + worldFile.getAbsolutePath()); - if (deleteWorldFolder ? FileUtils.deleteFolder(worldFile) : FileUtils.deleteFolderContents(worldFile)) { - Logging.info("World '%s' was DELETED.", name); - return true; - } else { - Logging.severe("World '%s' was NOT deleted.", name); - Logging.severe("Are you sure the folder %s exists?", name); - Logging.severe("Please check your file permissions on '%s'", name); - return false; - } - } catch (Throwable e) { - Logging.severe("Hrm, something didn't go as planned. Here's an exception for ya."); - Logging.severe("You can go politely explain your situation in #multiverse on esper.net"); - Logging.severe("But from here, it looks like your folder is oddly named."); - Logging.severe("This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry."); - Logging.severe(e.getMessage()); - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean deleteWorld(String name, boolean removeFromConfig) { - return this.deleteWorld(name, removeFromConfig, true); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean deleteWorld(String name) { - return this.deleteWorld(name, true); - } - - /** - * Unload a world from Bukkit. - * - * @param name Name of the world to unload - * @param safely Perform this safely. Set to True to save world files before unloading. - * @return True if the world was unloaded, false if not. - */ - private boolean unloadWorldFromBukkit(String name, boolean safely) { - this.removePlayersFromWorld(name); - return this.server.unloadWorld(name, safely); - } - - /** - * {@inheritDoc} - */ - @Override - public void removePlayersFromWorld(String name) { - World w = this.server.getWorld(name); - if (w != null) { - World safeWorld = this.server.getWorlds().get(0); - List ps = w.getPlayers(); - for (Player p : ps) { - // We're removing players forcefully from a world, they'd BETTER spawn safely. - this.safeTTeleporter.safelyTeleport(null, p, safeWorld.getSpawnLocation(), true); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public Collection getMVWorlds() { - return this.worlds.values(); - } - - /** - * {@inheritDoc} - */ - @Override - public MVWorld getMVWorld(String name) { - return this.getMVWorld(name, true); - } - - /** - * {@inheritDoc} - */ - @Override - public MVWorld getMVWorld(String name, boolean checkAliases) { - if (name == null) { - return null; - } - MVWorld world = this.worlds.get(name); - if (world != null) { - return world; - } - return (checkAliases) ? this.getMVWorldByAlias(name) : null; - } - - /** - * {@inheritDoc} - */ - @Override - public MVWorld getMVWorld(World world) { - if (world != null) { - return this.getMVWorld(world.getName(), false); - } - return null; - } - - /** - * Returns a {@link SimpleMVWorld} if it exists, and null if it does not. This will search ONLY alias. - * - * @param alias The alias of the world to get. - * @return A {@link SimpleMVWorld} or null. - */ - private MVWorld getMVWorldByAlias(String alias) { - for (MVWorld w : this.worlds.values()) { - if (w.getAlias().equalsIgnoreCase(alias)) { - return w; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isMVWorld(final String name) { - return this.isMVWorld(name, true); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isMVWorld(final String name, boolean checkAliases) { - return this.worlds.containsKey(name) || (checkAliases && this.isMVWorldAlias(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isMVWorld(World world) { - return world != null && this.isMVWorld(world.getName()); - } - - /** - * This method ONLY checks the alias of each world. - * - * @param alias The alias of the world to check. - * @return True if the world exists, false if not. - */ - private boolean isMVWorldAlias(final String alias) { - for (MVWorld w : this.worlds.values()) { - if (w.getAlias().equalsIgnoreCase(alias)) { - return true; - } - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public void loadDefaultWorlds() { - this.ensureConfigIsPrepared(); - List myWorlds = this.server.getWorlds(); - for (World w : myWorlds) { - String name = w.getName(); - if (!worldsFromTheConfig.containsKey(name)) { - String generator = null; - if (this.defaultGens.containsKey(name)) { - generator = this.defaultGens.get(name); - } - this.addWorld(name, w.getEnvironment(), String.valueOf(w.getSeed()), w.getWorldType(), w.canGenerateStructures(), generator); - } - } - } - - private void ensureConfigIsPrepared() { - this.configWorlds.options().pathSeparator(SEPARATOR); - if (this.configWorlds.getConfigurationSection("worlds") == null) { - this.configWorlds.createSection("worlds"); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void loadWorlds(boolean forceLoad) { - // Basic Counter to count how many Worlds we are loading. - int count = 0; - this.ensureConfigIsPrepared(); - this.ensureSecondNamespaceIsPrepared(); - - // Force the worlds to be loaded, ie don't just load new worlds. - if (forceLoad) { - // Remove all world permissions. - Permission allAccess = this.server.getPluginManager().getPermission("multiverse.access.*"); - Permission allExempt = this.server.getPluginManager().getPermission("multiverse.exempt.*"); - for (MVWorld w : this.worlds.values()) { - // Remove this world from the master list - if (allAccess != null) { - allAccess.getChildren().remove(w.getAccessPermission().getName()); - } - if (allExempt != null) { - allExempt.getChildren().remove(w.getAccessPermission().getName()); - } - this.server.getPluginManager().removePermission(w.getAccessPermission().getName()); - this.server.getPluginManager().removePermission(w.getExemptPermission().getName()); - // Special namespace for gamemodes - this.server.getPluginManager().removePermission("mv.bypass.gamemode." + w.getName()); - } - // Recalc the all permission - this.server.getPluginManager().recalculatePermissionDefaults(allAccess); - this.server.getPluginManager().recalculatePermissionDefaults(allExempt); - this.worlds.clear(); - } - - for (Map.Entry entry : worldsFromTheConfig.entrySet()) { - if (worlds.containsKey(entry.getKey())) { - continue; - } - if (!entry.getValue().getAutoLoad()) - continue; - - if (doLoad(entry.getKey())) - count++; - } - - // Simple Output to the Console to show how many Worlds were loaded. - Logging.config("%s - World(s) loaded.", count); - this.saveWorldsConfig(); - } - - private void ensureSecondNamespaceIsPrepared() { - Permission special = this.server.getPluginManager().getPermission("mv.bypass.gamemode.*"); - if (special == null) { - special = new Permission("mv.bypass.gamemode.*", PermissionDefault.FALSE); - this.server.getPluginManager().addPermission(special); - } - } - - private static final char SEPARATOR = '\uF8FF'; - - public boolean isKeepingSpawnInMemory(World world) { - WorldProperties properties = worldsFromTheConfig.get(world.getName()); - return properties == null || properties.isKeepingSpawnInMemory(); - } - - /** - * {@inheritDoc} - */ - @Override - public FileConfiguration loadWorldsConfig() { - File file = new File(this.plugin.getDataFolder(), WORLD_CONFIG_FILE); - this.configWorlds = YamlConfiguration.loadConfiguration(file); - this.ensureConfigIsPrepared(); - try { - this.configWorlds.save(file); - } catch (IOException e) { - // TODO: Auto-generated catch block - e.printStackTrace(); - } - // load world-objects - Stack worldKeys = new Stack(); - worldKeys.addAll(this.configWorlds.getConfigurationSection("worlds").getKeys(false)); - Map newWorldsFromTheConfig = new HashMap(); - while (!worldKeys.isEmpty()) { - String key = worldKeys.pop(); - String path = "worlds" + SEPARATOR + key; - Object obj = this.configWorlds.get(path); - if ((obj != null) && (obj instanceof WorldProperties)) { - String worldName = key.replaceAll(String.valueOf(SEPARATOR), "."); - WorldProperties props = (WorldProperties) obj; - if (this.worldsFromTheConfig.containsKey(worldName)) { - // Object-Recycling :D - // TODO: Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM) - SimpleMVWorld mvWorld = (SimpleMVWorld) this.worlds.get(worldName); - if (mvWorld != null) { - mvWorld.copyValues((WorldProperties) obj); - } - } - newWorldsFromTheConfig.put(worldName, props); - } else if (this.configWorlds.isConfigurationSection(path)) { - ConfigurationSection section = this.configWorlds.getConfigurationSection(path); - Set subkeys = section.getKeys(false); - for (String subkey : subkeys) { - worldKeys.push(key + SEPARATOR + subkey); - } - } - } - this.worldsFromTheConfig = newWorldsFromTheConfig; - this.worlds.keySet().retainAll(this.worldsFromTheConfig.keySet()); - return this.configWorlds; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean saveWorldsConfig() { - try { - this.configWorlds.options().pathSeparator(SEPARATOR); - this.configWorlds.set("worlds", null); - for (Map.Entry entry : worldsFromTheConfig.entrySet()) { - this.configWorlds.set("worlds" + SEPARATOR + entry.getKey(), entry.getValue()); - } - this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml")); - return true; - } catch (IOException e) { - Logging.severe("Could not save worlds.yml. Please check your settings."); - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public MVWorld getSpawnWorld() { - return this.getMVWorld(this.server.getWorlds().get(0)); - } - - /** - * {@inheritDoc} - */ - @Override - public List getUnloadedWorlds() { - List allNames = new ArrayList(this.worldsFromTheConfig.keySet()); - allNames.removeAll(worlds.keySet()); - return allNames; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed) { - return regenWorld(name, useNewSeed, randomSeed, seed, false); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules) { - MVWorld world = this.getMVWorld(name); - if (world == null) { - Logging.warning("Unable to regen a world that does not exist!"); - return false; - } - - List ps = world.getCBWorld().getPlayers(); - - // Apply new seed if needed. - if (useNewSeed) { - long theSeed; - - if (randomSeed) { - theSeed = new Random().nextLong(); - } else { - try { - theSeed = Long.parseLong(seed); - } catch (NumberFormatException e) { - theSeed = seed.hashCode(); - } - } - - world.setSeed(theSeed); - } - - WorldType type = world.getWorldType(); - - // Save current GameRules if needed. - Map, Object> gameRuleMap = null; - if (keepGameRules) { - gameRuleMap = new HashMap<>(GameRule.values().length); - World CBWorld = world.getCBWorld(); - for (GameRule gameRule : GameRule.values()) { - // Only save if not default value. - Object value = CBWorld.getGameRuleValue(gameRule); - if (value != CBWorld.getGameRuleDefault(gameRule)) { - gameRuleMap.put(gameRule, value); - } - } - } - - // Do the regen. - if (!this.deleteWorld(name, false, false)) { - Logging.severe("Unable to regen world as world cannot be deleted."); - return false; - } - if (!this.doLoad(name, true, type)) { - Logging.severe("Unable to regen world as world cannot be loaded."); - return false; - } - - // Get new MultiverseWorld reference. - world = this.getMVWorld(name); - - // Load back GameRules if needed. - if (keepGameRules) { - Logging.fine("Restoring previous world's GameRules..."); - World CBWorld = world.getCBWorld(); - for (Map.Entry, Object> gameRuleEntry : gameRuleMap.entrySet()) { - if (!setGameRuleValue(CBWorld, gameRuleEntry.getKey(), gameRuleEntry.getValue())) { - Logging.warning("Unable to set GameRule '%s' to '%s' on regen world.", - gameRuleEntry.getKey().getName(), gameRuleEntry.getValue()); - } - } - } - - // Send all players that were in the old world, BACK to it! - Location newSpawn = world.getSpawnLocation(); - for (Player p : ps) { - this.safeTTeleporter.safelyTeleport(null, p, newSpawn, true); - } - - return true; - } - - private boolean setGameRuleValue(World world, GameRule gameRule, Object value) { - try { - return world.setGameRule(gameRule, (T) value); - } catch (Exception e) { - return false; - } - } - - /** - * Gets the {@link FileConfiguration} that this {@link SimpleMVWorldManager} is using. - * - * @return The {@link FileConfiguration} that this {@link SimpleMVWorldManager} is using. - */ - public FileConfiguration getConfigWorlds() { - return this.configWorlds; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasUnloadedWorld(String name, boolean includeLoaded) { - if (getMVWorld(name) != null) { - return includeLoaded; - } - for (Map.Entry entry : this.worldsFromTheConfig.entrySet()) { - if (name.equals(entry.getKey()) || name.equals(entry.getValue().getAlias())) { - return true; - } - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public Collection getPotentialWorlds() { - File worldContainer = this.server.getWorldContainer(); - if (worldContainer == null) { - return Collections.emptyList(); - } - return Arrays.stream(worldContainer.listFiles()) - .filter(File::isDirectory) - .filter(folder -> !this.isMVWorld(folder.getName(), false)) - .filter(WorldNameChecker::isValidWorldFolder) - .map(File::getName) - .collect(Collectors.toList()); - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/SimpleWorldPurger.java b/src/main/java/org/mvplugins/multiverse/core/world/SimpleWorldPurger.java deleted file mode 100644 index 3c97dc18..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/SimpleWorldPurger.java +++ /dev/null @@ -1,198 +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.ArrayList; -import java.util.Iterator; -import java.util.List; - -import com.dumptruckman.minecraft.util.Logging; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Animals; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Golem; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Phantom; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Squid; -import org.jvnet.hk2.annotations.Service; - -import org.mvplugins.multiverse.core.api.MVWorld; -import org.mvplugins.multiverse.core.api.WorldPurger; - -/** - * Utility class that removes animals from worlds that don't belong there. - */ -@Service -public class SimpleWorldPurger implements WorldPurger { - - private Class ambientClass = null; - - public SimpleWorldPurger() { - try { - Class entityClass = Class.forName("org.bukkit.entity.Ambient"); - if (Entity.class.isAssignableFrom(entityClass)) { - ambientClass = entityClass; - } - } catch (ClassNotFoundException ignore) { } - } - - /** - * {@inheritDoc} - */ - @Override - public void purgeWorlds(List worlds) { - if (worlds == null || worlds.isEmpty()) { - return; - } - for (MVWorld world : worlds) { - this.purgeWorld(world); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void purgeWorld(MVWorld world) { - if (world == null) { - return; - } - ArrayList allMobs = new ArrayList(world.getAnimalList()); - allMobs.addAll(world.getMonsterList()); - purgeWorld(world, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn()); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean shouldWeKillThisCreature(MVWorld world, Entity e) { - ArrayList allMobs = new ArrayList(world.getAnimalList()); - allMobs.addAll(world.getMonsterList()); - return this.shouldWeKillThisCreature(e, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn()); - } - - /** - * {@inheritDoc} - */ - @Override - public void purgeWorld(MVWorld mvworld, List thingsToKill, - boolean negateAnimals, boolean negateMonsters, CommandSender sender) { - if (mvworld == null) { - return; - } - World world = mvworld.getCBWorld(); - if (world == null) { - return; - } - int projectilesKilled = 0; - int entitiesKilled = 0; - boolean specifiedAll = thingsToKill.contains("ALL"); - boolean specifiedAnimals = thingsToKill.contains("ANIMALS") || specifiedAll; - boolean specifiedMonsters = thingsToKill.contains("MONSTERS") || specifiedAll; - List worldEntities = world.getEntities(); - List livingEntities = new ArrayList(worldEntities.size()); - List projectiles = new ArrayList(worldEntities.size()); - for (final Entity e : worldEntities) { - if (e instanceof Projectile) { - final Projectile p = (Projectile) e; - if (p.getShooter() != null) { - projectiles.add((Projectile) e); - } - } else if (e instanceof LivingEntity) { - livingEntities.add((LivingEntity) e); - } - } - for (final LivingEntity e : livingEntities) { - if (killDecision(e, thingsToKill, negateAnimals, negateMonsters, specifiedAnimals, specifiedMonsters)) { - final Iterator it = projectiles.iterator(); - while (it.hasNext()) { - final Projectile p = it.next(); - if (p.getShooter().equals(e)) { - p.remove(); - it.remove(); - projectilesKilled++; - } - } - e.remove(); - entitiesKilled++; - } - } - if (sender != null) { - sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "' along with " + projectilesKilled + " projectiles that belonged to them."); - } - } - - private boolean killDecision(Entity e, List thingsToKill, boolean negateAnimals, - boolean negateMonsters, boolean specifiedAnimals, boolean specifiedMonsters) { - boolean negate = false; - boolean specified = false; - if (e instanceof Golem || e instanceof Squid || e instanceof Animals - || (ambientClass != null && ambientClass.isInstance(e))) { - // it's an animal - if (specifiedAnimals && !negateAnimals) { - Logging.finest("Removing an entity because I was told to remove all animals in world %s: %s", e.getWorld().getName(), e); - return true; - } - if (specifiedAnimals) - specified = true; - negate = negateAnimals; - } else if (e instanceof Monster || e instanceof Ghast || e instanceof Slime || e instanceof Phantom) { - // it's a monster - if (specifiedMonsters && !negateMonsters) { - Logging.finest("Removing an entity because I was told to remove all monsters in world %s: %s", e.getWorld().getName(), e); - return true; - } - if (specifiedMonsters) - specified = true; - negate = negateMonsters; - } - for (String s : thingsToKill) { - EntityType type = EntityType.fromName(s); - if (type != null && type.equals(e.getType())) { - specified = true; - if (!negate) { - Logging.finest("Removing an entity because it WAS specified and we are NOT negating in world %s: %s", e.getWorld().getName(), e); - return true; - } - break; - } - } - if (!specified && negate) { - Logging.finest("Removing an entity because it was NOT specified and we ARE negating in world %s: %s", e.getWorld().getName(), e); - return true; - } - - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean shouldWeKillThisCreature(Entity e, List thingsToKill, boolean negateAnimals, boolean negateMonsters) { - boolean specifiedAll = thingsToKill.contains("ALL"); - boolean specifiedAnimals = thingsToKill.contains("ANIMALS") || specifiedAll; - boolean specifiedMonsters = thingsToKill.contains("MONSTERS") || specifiedAll; - return this.killDecision(e, thingsToKill, negateAnimals, negateMonsters, specifiedAnimals, specifiedMonsters); - } - - /** - * {@inheritDoc} - */ - @Override - public void purgeWorld(MVWorld mvworld, List thingsToKill, boolean negateAnimals, boolean negateMonsters) { - purgeWorld(mvworld, thingsToKill, negateAnimals, negateMonsters, null); - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java rename to src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java index 3855f0b7..c4064263 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew; +package org.mvplugins.multiverse.core.world; import java.io.File; import java.util.ArrayList; @@ -31,31 +31,31 @@ import org.mvplugins.multiverse.core.api.SafeTTeleporter; import org.mvplugins.multiverse.core.utils.message.MessageReplacement; import org.mvplugins.multiverse.core.utils.result.Attempt; import org.mvplugins.multiverse.core.utils.result.FailureReason; -import org.mvplugins.multiverse.core.worldnew.config.WorldConfig; -import org.mvplugins.multiverse.core.worldnew.config.WorldsConfigManager; -import org.mvplugins.multiverse.core.worldnew.generators.GeneratorProvider; -import org.mvplugins.multiverse.core.worldnew.helpers.DataStore.GameRulesStore; -import org.mvplugins.multiverse.core.worldnew.helpers.DataTransfer; -import org.mvplugins.multiverse.core.worldnew.helpers.FilesManipulator; -import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter; -import org.mvplugins.multiverse.core.worldnew.options.CloneWorldOptions; -import org.mvplugins.multiverse.core.worldnew.options.CreateWorldOptions; -import org.mvplugins.multiverse.core.worldnew.options.ImportWorldOptions; -import org.mvplugins.multiverse.core.worldnew.options.KeepWorldSettingsOptions; -import org.mvplugins.multiverse.core.worldnew.options.RegenWorldOptions; -import org.mvplugins.multiverse.core.worldnew.options.UnloadWorldOptions; -import org.mvplugins.multiverse.core.worldnew.reasons.CloneFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.CreateFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.DeleteFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.ImportFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.LoadFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.RegenFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.RemoveFailureReason; -import org.mvplugins.multiverse.core.worldnew.reasons.UnloadFailureReason; +import org.mvplugins.multiverse.core.world.config.WorldConfig; +import org.mvplugins.multiverse.core.world.config.WorldsConfigManager; +import org.mvplugins.multiverse.core.world.generators.GeneratorProvider; +import org.mvplugins.multiverse.core.world.helpers.DataStore.GameRulesStore; +import org.mvplugins.multiverse.core.world.helpers.DataTransfer; +import org.mvplugins.multiverse.core.world.helpers.FilesManipulator; +import org.mvplugins.multiverse.core.world.helpers.PlayerWorldTeleporter; +import org.mvplugins.multiverse.core.world.options.CloneWorldOptions; +import org.mvplugins.multiverse.core.world.options.CreateWorldOptions; +import org.mvplugins.multiverse.core.world.options.ImportWorldOptions; +import org.mvplugins.multiverse.core.world.options.KeepWorldSettingsOptions; +import org.mvplugins.multiverse.core.world.options.RegenWorldOptions; +import org.mvplugins.multiverse.core.world.options.UnloadWorldOptions; +import org.mvplugins.multiverse.core.world.reasons.CloneFailureReason; +import org.mvplugins.multiverse.core.world.reasons.CreateFailureReason; +import org.mvplugins.multiverse.core.world.reasons.DeleteFailureReason; +import org.mvplugins.multiverse.core.world.reasons.ImportFailureReason; +import org.mvplugins.multiverse.core.world.reasons.LoadFailureReason; +import org.mvplugins.multiverse.core.world.reasons.RegenFailureReason; +import org.mvplugins.multiverse.core.world.reasons.RemoveFailureReason; +import org.mvplugins.multiverse.core.world.reasons.UnloadFailureReason; import static org.mvplugins.multiverse.core.utils.message.MessageReplacement.replace; -import static org.mvplugins.multiverse.core.worldnew.helpers.DataStore.WorldBorderStore; -import static org.mvplugins.multiverse.core.worldnew.helpers.DataStore.WorldConfigStore; +import static org.mvplugins.multiverse.core.world.helpers.DataStore.WorldBorderStore; +import static org.mvplugins.multiverse.core.world.helpers.DataStore.WorldConfigStore; /** * This manager contains all the world managing functions that your heart desires. diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java index 5e5af646..65d86fd4 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldNameChecker.java @@ -1,14 +1,13 @@ package org.mvplugins.multiverse.core.world; import java.io.File; -import java.util.Collections; -import java.util.HashSet; import java.util.Set; import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jvnet.hk2.annotations.Service; /** *

Utility class in helping to check the status of a world name and it's associated world folder.

@@ -16,15 +15,17 @@ import org.jetbrains.annotations.Nullable; *

Note this is for preliminary checks and better command output. A valid result will suggest but not * 100% determine that a world name can be created, loaded or imported.

*/ +@Service public class WorldNameChecker { private static final Pattern WORLD_NAME_PATTERN = Pattern.compile("[a-zA-Z0-9/._-]+"); - private static final Set BLACKLIST_NAMES = Collections.unmodifiableSet(new HashSet() {{ - add("plugins"); - add("logs"); - add("cache"); - add("crash-reports"); - }}); + private static final Set BLACKLIST_NAMES = Set.of( + "cache", + "config", + "crash-reports", + "logs", + "plugins", + "versions"); /** * Checks if a world name is valid. @@ -32,7 +33,7 @@ public class WorldNameChecker { * @param worldName The world name to check on. * @return True if check result is valid, else false. */ - public static boolean isValidWorldName(@Nullable String worldName) { + public boolean isValidWorldName(@Nullable String worldName) { return checkName(worldName) == NameStatus.VALID; } @@ -43,7 +44,7 @@ public class WorldNameChecker { * @return The resulting name status. */ @NotNull - public static NameStatus checkName(@Nullable String worldName) { + public NameStatus checkName(@Nullable String worldName) { if (BLACKLIST_NAMES.contains(worldName)) { return NameStatus.BLACKLISTED; } @@ -59,7 +60,7 @@ public class WorldNameChecker { * @param worldName The world name to check on. * @return True if check result is valid, else false. */ - public static boolean isValidWorldFolder(@Nullable String worldName) { + public boolean isValidWorldFolder(@Nullable String worldName) { return checkFolder(worldName) == FolderStatus.VALID; } @@ -69,7 +70,7 @@ public class WorldNameChecker { * @param worldFolder The world folder to check on. * @return True if check result is valid, else false. */ - public static boolean isValidWorldFolder(@Nullable File worldFolder) { + public boolean isValidWorldFolder(@Nullable File worldFolder) { return checkFolder(worldFolder) == FolderStatus.VALID; } @@ -80,7 +81,7 @@ public class WorldNameChecker { * @return The resulting folder status. */ @NotNull - public static FolderStatus checkFolder(@Nullable String worldName) { + public FolderStatus checkFolder(@Nullable String worldName) { if (worldName == null) { return FolderStatus.DOES_NOT_EXIST; } @@ -95,7 +96,7 @@ public class WorldNameChecker { * @return The resulting folder status. */ @NotNull - public static FolderStatus checkFolder(@Nullable File worldFolder) { + public FolderStatus checkFolder(@Nullable File worldFolder) { if (worldFolder == null || !worldFolder.exists() || !worldFolder.isDirectory()) { return FolderStatus.DOES_NOT_EXIST; } @@ -112,7 +113,7 @@ public class WorldNameChecker { * @param worldFolder The File that may be a world. * @return True if it looks like a world, else false. */ - private static boolean folderHasDat(@NotNull File worldFolder) { + private boolean folderHasDat(@NotNull File worldFolder) { File[] files = worldFolder.listFiles((file, name) -> name.toLowerCase().endsWith(".dat")); return files != null && files.length > 0; } diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldProperties.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldProperties.java deleted file mode 100644 index 2ceb38ba..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldProperties.java +++ /dev/null @@ -1,655 +0,0 @@ -package org.mvplugins.multiverse.core.world; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import me.main__.util.SerializationConfig.IllegalPropertyValueException; -import me.main__.util.SerializationConfig.Property; -import me.main__.util.SerializationConfig.SerializationConfig; -import me.main__.util.SerializationConfig.Serializor; -import me.main__.util.SerializationConfig.Validator; -import me.main__.util.SerializationConfig.VirtualProperty; -import org.bukkit.ChatColor; -import org.bukkit.Difficulty; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World.Environment; -import org.bukkit.configuration.serialization.SerializableAs; -import org.jetbrains.annotations.Nullable; - -import org.mvplugins.multiverse.core.world.configuration.AllowedPortalType; -import org.mvplugins.multiverse.core.world.configuration.EnglishChatColor; -import org.mvplugins.multiverse.core.world.configuration.EnglishChatStyle; -import org.mvplugins.multiverse.core.world.configuration.EntryFee; -import org.mvplugins.multiverse.core.world.configuration.SpawnSettings; -import org.mvplugins.multiverse.core.world.configuration.WorldPropertyValidator; -import org.mvplugins.multiverse.core.worldnew.config.SpawnLocation; - -/* - * This is a property class, I think we don't need that much javadoc. - * BEGIN CHECKSTYLE-SUPPRESSION: Javadoc - */ - -@SerializableAs("MVWorld") -public class WorldProperties extends SerializationConfig { - - private static final Map PROPERTY_ALIASES; - - static { - PROPERTY_ALIASES = new HashMap(); - PROPERTY_ALIASES.put("curr", "entryfee.currency"); - PROPERTY_ALIASES.put("currency", "entryfee.currency"); - PROPERTY_ALIASES.put("price", "entryfee.amount"); - PROPERTY_ALIASES.put("scaling", "scale"); - PROPERTY_ALIASES.put("aliascolor", "color"); - PROPERTY_ALIASES.put("heal", "autoHeal"); - PROPERTY_ALIASES.put("storm", "allowWeather"); - PROPERTY_ALIASES.put("weather", "allowWeather"); - PROPERTY_ALIASES.put("spawnmemory", "keepSpawnInMemory"); - PROPERTY_ALIASES.put("memory", "keepSpawnInMemory"); - PROPERTY_ALIASES.put("mode", "gameMode"); - PROPERTY_ALIASES.put("diff", "difficulty"); - PROPERTY_ALIASES.put("spawnlocation", "spawn"); - PROPERTY_ALIASES.put("limit", "playerLimit"); - PROPERTY_ALIASES.put("animals", "spawning.animals.spawn"); - PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn"); - PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate"); - PROPERTY_ALIASES.put("monstersrate", "spawning.monsters.spawnrate"); - PROPERTY_ALIASES.put("flight", "allowFlight"); - PROPERTY_ALIASES.put("fly", "allowFlight"); - PROPERTY_ALIASES.put("allowfly", "allowFlight"); - } - - private final boolean keepSpawnFallback; - - public WorldProperties(Map values) { - super(values); - Object keepSpawnObject = values.get("keepSpawnInMemory"); - keepSpawnFallback = keepSpawnObject == null || Boolean.parseBoolean(keepSpawnObject.toString()); - } - - public WorldProperties() { - super(); - keepSpawnFallback = true; - } - - public WorldProperties(final boolean fixSpawn, final Environment environment) { - super(); - if (!fixSpawn) { - this.adjustSpawn = false; - } - setScaling(getDefaultScale(environment)); - keepSpawnFallback = true; - } - - void setMVWorld(SimpleMVWorld world) { - registerObjectUsing(world); - registerGlobalValidator(new WorldPropertyValidator()); - } - - /** - * Serializor for the color-property. - */ - private static final class EnumPropertySerializor> implements Serializor { - @Override - public String serialize(T from) { - return from.toString(); - } - - @Override - public T deserialize(String serialized, Class wanted) throws IllegalPropertyValueException { - try { - return Enum.valueOf(wanted, serialized.toUpperCase()); - } catch (IllegalArgumentException e) { - throw new IllegalPropertyValueException(e); - } - } - } - - /** - * Serializor for the difficulty-property. - */ - private static final class DifficultyPropertySerializor implements Serializor { - @Override - public String serialize(Difficulty from) { - return from.toString(); - } - - @Override - public Difficulty deserialize(String serialized, Class wanted) throws IllegalPropertyValueException { - try { - return Difficulty.getByValue(Integer.parseInt(serialized)); - } catch (Exception e) { - } - try { - return Difficulty.valueOf(serialized.toUpperCase()); - } catch (Exception e) { - } - throw new IllegalPropertyValueException(); - } - } - - /** - * Serializor for the gameMode-property. - */ - private static final class GameModePropertySerializor implements Serializor { - @Override - public String serialize(GameMode from) { - return from.toString(); - } - - @Override - public GameMode deserialize(String serialized, Class wanted) throws IllegalPropertyValueException { - try { - return GameMode.getByValue(Integer.parseInt(serialized)); - } catch (NumberFormatException nfe) { - } - try { - return GameMode.valueOf(serialized.toUpperCase()); - } catch (Exception e) { - } - throw new IllegalPropertyValueException(); - } - } - - /** - * Serializor for the time-property. - */ - private static final class TimePropertySerializor implements Serializor { - // BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck - private static final String TIME_REGEX = "(\\d\\d?):?(\\d\\d)(a|p)?m?"; - private static final Map TIME_ALIASES; - static { - Map staticTimes = new HashMap(); - staticTimes.put("morning", "8:00"); - staticTimes.put("day", "12:00"); - staticTimes.put("noon", "12:00"); - staticTimes.put("midnight", "0:00"); - staticTimes.put("night", "20:00"); - - // now set TIME_ALIASES to a "frozen" map - TIME_ALIASES = Collections.unmodifiableMap(staticTimes); - } - - @Override - public String serialize(Long from) { - // I'm tired, so they get time in 24 hour for now. - // Someone else can add 12 hr format if they want :P - - int hours = (int) ((from / 1000 + 8) % 24); - int minutes = (int) (60 * (from % 1000) / 1000); - - return String.format("%d:%02d", hours, minutes); - } - - @Override - public Long deserialize(String serialized, Class wanted) throws IllegalPropertyValueException { - if (TIME_ALIASES.containsKey(serialized.toLowerCase())) { - serialized = TIME_ALIASES.get(serialized.toLowerCase()); - } - // Regex that extracts a time in the following formats: - // 11:11pm, 11:11, 23:11, 1111, 1111p, and the aliases at the top of this file. - Pattern pattern = Pattern.compile(TIME_REGEX, Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(serialized); - matcher.find(); - int hour = 0; - double minute = 0; - int count = matcher.groupCount(); - if (count >= 2) { - hour = Integer.parseInt(matcher.group(1)); - minute = Integer.parseInt(matcher.group(2)); - } - // If there were 4 matches (all, hour, min, am/pm) - if (count == 4) { - // We want 24 hour time for calcs, but if they - // added a p[m], turn it into a 24 hr one. - if (matcher.group(3).equals("p")) { - hour += 12; - } - } - // Translate 24th hour to 0th hour. - if (hour == 24) { - hour = 0; - } - // Clamp the hour - if (hour > 23 || hour < 0) { - throw new IllegalPropertyValueException("Illegal hour!"); - } - // Clamp the minute - if (minute > 59 || minute < 0) { - throw new IllegalPropertyValueException("Illegal minute!"); - } - // 60 seconds in a minute, time needs to be in hrs * 1000, per - // the bukkit docs. - double totaltime = (hour + (minute / 60.0)) * 1000; - // Somehow there's an 8 hour offset... - totaltime -= 8000; - if (totaltime < 0) { - totaltime = 24000 + totaltime; - } - - return (long) totaltime; - } - // END CHECKSTYLE-SUPPRESSION: MagicNumberCheck - } - - // -------------------------------------------------------------- - // Begin properties - @Property(description = "Sorry, 'hidden' must either be: true or false.") - private volatile boolean hidden; - @Property(description = "Alias must be a valid string.") - private volatile String alias; - @Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'color' must be a valid color-name.") - private volatile EnglishChatColor color; - @Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'style' must be a valid style-name.") - private volatile EnglishChatStyle style; - @Property(description = "Sorry, 'pvp' must either be: true or false.", virtualType = Boolean.class, persistVirtual = true) - volatile VirtualProperty pvp; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property(description = "Scale must be a positive double value. ex: 2.3") - private volatile double scale; - @Property(description = "You must set this to the NAME not alias of a world.") - private volatile String respawnWorld; - @Property(description = "Sorry, this must either be: true or false.") - private volatile boolean allowWeather; - @Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class, persistVirtual = true, - description = "Difficulty must be set as one of the following: peaceful easy normal hard") - volatile VirtualProperty difficulty; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property(description = "Sorry, 'animals' must either be: true or false.") - private volatile SpawnSettings spawning; - @Property - volatile EntryFee entryfee; - @Property(description = "Sorry, 'hunger' must either be: true or false.") - private volatile boolean hunger; - @Property(description = "Sorry, 'autoheal' must either be: true or false.") - private volatile boolean autoHeal; - @Property(description = "Sorry, 'adjustspawn' must either be: true or false.") - private volatile boolean adjustSpawn; - @Property(serializor = EnumPropertySerializor.class, description = "Allow portal forming must be NONE, ALL, NETHER or END.") - private volatile AllowedPortalType portalForm; - @Property(serializor = GameModePropertySerializor.class, description = "GameMode must be set as one of the following: survival creative") - private volatile GameMode gameMode; - @Property(description = "Sorry, this must either be: true or false.", virtualType = Boolean.class, persistVirtual = true) - volatile VirtualProperty keepSpawnInMemory; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property - volatile SpawnLocation spawnLocation; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property(virtualType = Location.class, - description = "There is no help available for this variable. Go bug Rigby90 about it.") - volatile VirtualProperty spawn; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property(description = "Set this to false ONLY if you don't want this world to load itself on server restart.") - private volatile boolean autoLoad; - @Property(description = "If a player dies in this world, shoudld they go to their bed?") - private volatile boolean bedRespawn; - @Property - private volatile List worldBlacklist; - @Property(serializor = TimePropertySerializor.class, virtualType = Long.class, - description = "Set the time to whatever you want! (Will NOT freeze time)") - volatile VirtualProperty time; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property - volatile Environment environment; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property - volatile long seed; // SUPPRESS CHECKSTYLE: VisibilityModifier - @Property - private volatile String generator; - @Property - private volatile int playerLimit; - @Property - private volatile boolean allowFlight; - // End of properties - // -------------------------------------------------------------- - - void setValidator(String fieldName, Validator validator) { - registerValidator(fieldName, validator); //To change body of overridden methods use File | Settings | File Templates. - } - - /** - * {@inheritDoc} - */ - @Override - public void copyValues(SerializationConfig other) { - super.copyValues(other); - } - - /** - * This prepares the MVWorld for unloading. - */ - public void cacheVirtualProperties() { - try { - this.buildVPropChanges(); - } catch (IllegalStateException e) { - // do nothing - } - } - - /** - * {@inheritDoc} - */ - @Override - protected void setDefaults() { - this.hidden = false; - this.alias = new String(); - this.color = EnglishChatColor.WHITE; - this.style = EnglishChatStyle.NORMAL; - this.scale = 1D; - this.respawnWorld = new String(); - this.allowWeather = true; - this.spawning = new SpawnSettings(); - this.entryfee = new EntryFee(); - this.hunger = true; - this.autoHeal = true; - this.adjustSpawn = true; - this.portalForm = AllowedPortalType.ALL; - this.gameMode = GameMode.SURVIVAL; - this.spawnLocation = new SimpleMVWorld.NullLocation(); - this.autoLoad = true; - this.bedRespawn = true; - this.worldBlacklist = new ArrayList(); - this.generator = null; - this.playerLimit = -1; - this.allowFlight = true; - } - - private static double getDefaultScale(Environment environment) { - if (environment == Environment.NETHER) { - return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck - } else if (environment == Environment.THE_END) { - return 16.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck - } - return 1.0; - } - - /** - * getAliases(). - * @return The alias-map. - * @see SerializationConfig - */ - protected static Map getAliases() { - return PROPERTY_ALIASES; - } - - void flushChanges() { - this.flushPendingVPropChanges(); - } - - public String getAlias() { - return this.alias; - } - - public void setAlias(String alias) { - this.setPropertyValueUnchecked("alias", alias); - } - - public Environment getEnvironment() { - return this.environment; - } - - public void setEnvironment(Environment environment) { - this.setPropertyValueUnchecked("environment", environment); - } - - public long getSeed() { - return this.seed; - } - - public void setSeed(long seed) { - this.setPropertyValueUnchecked("seed", seed); - } - - public String getGenerator() { - return this.generator; - } - - public void setGenerator(String generator) { - this.setPropertyValueUnchecked("generator", generator); - } - - public int getPlayerLimit() { - return this.playerLimit; - } - - public void setPlayerLimit(int limit) { - this.setPropertyValueUnchecked("playerLimit", limit); - } - - public boolean canAnimalsSpawn() { - return this.spawning.getAnimalSettings().doSpawn(); - } - - public void setAllowAnimalSpawn(boolean animals) { - this.setPropertyValueUnchecked("spawning.animals.spawn", animals); - } - - public List getAnimalList() { - // These don't fire events at the moment. Should they? - return this.spawning.getAnimalSettings().getExceptions(); - } - - public boolean canMonstersSpawn() { - return this.spawning.getMonsterSettings().doSpawn(); - } - - public void setAllowMonsterSpawn(boolean monsters) { - this.setPropertyValueUnchecked("spawning.monsters.spawn", monsters); - } - - public int getAnimalSpawnRate() { - return this.spawning.getAnimalSettings().getSpawnRate(); - } - - public int getMonsterSpawnRate() { - return this.spawning.getMonsterSettings().getSpawnRate(); - } - - public List getMonsterList() { - // These don't fire events at the moment. Should they? - return this.spawning.getMonsterSettings().getExceptions(); - } - - public boolean isPVPEnabled() { - return this.pvp.get(); - } - - public void setPVPMode(boolean pvp) { - this.setPropertyValueUnchecked("pvp", pvp); - } - - public boolean isHidden() { - return this.hidden; - } - - public void setHidden(boolean hidden) { - this.setPropertyValueUnchecked("hidden", hidden); - } - - public List getWorldBlacklist() { - return this.worldBlacklist; - } - - public double getScaling() { - return this.scale; - } - - public boolean setScaling(double scaling) { - return this.setPropertyValueUnchecked("scale", scaling); - } - - public boolean setColor(String aliasColor) { - return this.setPropertyUnchecked("color", aliasColor); - } - - public boolean setColor(EnglishChatColor color) { - return this.setPropertyValueUnchecked("color", color); - } - - public EnglishChatColor getColor() { - return this.color; - } - - public String getRespawnToWorld() { - return this.respawnWorld; - } - - public boolean setRespawnToWorld(String respawnToWorld) { - return this.setPropertyValueUnchecked("respawnWorld", respawnToWorld); - } - - public Material getCurrency() { - return this.entryfee.getCurrency(); - } - - public void setCurrency(@Nullable Material currency) { - this.setPropertyValueUnchecked("entryfee.currency", currency); - } - - public double getPrice() { - return this.entryfee.getAmount(); - } - - public void setPrice(double price) { - this.setPropertyValueUnchecked("entryfee.amount", price); - } - - public boolean setGameMode(String mode) { - return this.setPropertyUnchecked("gameMode", mode); - } - - public boolean setGameMode(GameMode mode) { - return this.setPropertyValueUnchecked("gameMode", mode); - } - - public GameMode getGameMode() { - return this.gameMode; - } - - public void setEnableWeather(boolean weather) { - this.setPropertyValueUnchecked("allowWeather", weather); - } - - public boolean isWeatherEnabled() { - return this.allowWeather; - } - - public boolean isKeepingSpawnInMemory() { - if (keepSpawnInMemory == null) { - return keepSpawnFallback; - } - try { - return this.keepSpawnInMemory.get(); - } catch (IllegalStateException e) { - return keepSpawnFallback; - } - } - - public void setKeepSpawnInMemory(boolean value) { - this.setPropertyValueUnchecked("keepSpawnInMemory", value); - } - - public boolean getHunger() { - return this.hunger; - } - - public void setHunger(boolean hunger) { - this.setPropertyValueUnchecked("hunger", hunger); - } - - public Location getSpawnLocation() { - return this.spawn.get(); - } - - public void setSpawnLocation(Location l) { - this.setPropertyValueUnchecked("spawn", l); - } - - public Difficulty getDifficulty() { - return this.difficulty.get(); - } - - @Deprecated // SUPPRESS CHECKSTYLE: Deprecated - public boolean setDifficulty(String difficulty) { - return this.setPropertyUnchecked("difficulty", difficulty); - } - - public boolean setDifficulty(Difficulty difficulty) { - return this.setPropertyValueUnchecked("difficulty", difficulty); - } - - public boolean getAutoHeal() { - return this.autoHeal; - } - - public void setAutoHeal(boolean heal) { - this.setPropertyValueUnchecked("autoHeal", heal); - } - - public void setAdjustSpawn(boolean adjust) { - this.setPropertyValueUnchecked("adjustSpawn", adjust); - } - - public boolean getAdjustSpawn() { - return this.adjustSpawn; - } - - public void setAutoLoad(boolean load) { - this.setPropertyValueUnchecked("autoLoad", load); - } - - public boolean getAutoLoad() { - return this.autoLoad; - } - - public void setBedRespawn(boolean respawn) { - this.setPropertyValueUnchecked("bedRespawn", respawn); - } - - public boolean getBedRespawn() { - return this.bedRespawn; - } - - public String getAllPropertyNames() { - ChatColor myColor = ChatColor.AQUA; - StringBuilder result = new StringBuilder(); - Map serialized = this.serialize(); - for (String key : serialized.keySet()) { - result.append(myColor).append(key).append(' '); - myColor = (myColor == ChatColor.AQUA) ? ChatColor.GOLD : ChatColor.AQUA; - } - return result.toString(); - } - - public String getTime() { - return this.getPropertyUnchecked("time"); - } - - public boolean setTime(String timeAsString) { - return this.setPropertyUnchecked("time", timeAsString); - } - - public AllowedPortalType getAllowedPortals() { - return portalForm; - } - - public void allowPortalMaking(AllowedPortalType portalType) { - this.setPropertyValueUnchecked("portalForm", portalType); - } - - public EnglishChatStyle getStyle() { - return style; - } - - public boolean setStyle(String style) { - return this.setPropertyUnchecked("style", style); - } - - public boolean getAllowFlight() { - return this.allowFlight; - } - - public void setAllowFlight(final boolean allowFlight) { - this.setPropertyValueUnchecked("allowFlight", allowFlight); - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldPurger.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldPurger.java similarity index 99% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/WorldPurger.java rename to src/main/java/org/mvplugins/multiverse/core/world/WorldPurger.java index 581a65e9..a80b13cb 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldPurger.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldPurger.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew; +package org.mvplugins.multiverse.core.world; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/AllowedPortalType.java b/src/main/java/org/mvplugins/multiverse/core/world/config/AllowedPortalType.java similarity index 96% rename from src/main/java/org/mvplugins/multiverse/core/world/configuration/AllowedPortalType.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/AllowedPortalType.java index 7f8e1af3..3690aa08 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/AllowedPortalType.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/AllowedPortalType.java @@ -5,7 +5,7 @@ * with this project. * ******************************************************************************/ -package org.mvplugins.multiverse.core.world.configuration; +package org.mvplugins.multiverse.core.world.config; import org.bukkit.PortalType; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/LegacyAliasMigrator.java b/src/main/java/org/mvplugins/multiverse/core/world/config/LegacyAliasMigrator.java similarity index 98% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/config/LegacyAliasMigrator.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/LegacyAliasMigrator.java index e6b66aaf..8e588120 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/LegacyAliasMigrator.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/LegacyAliasMigrator.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.config; +package org.mvplugins.multiverse.core.world.config; import java.util.concurrent.atomic.AtomicReference; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/NullLocation.java b/src/main/java/org/mvplugins/multiverse/core/world/config/NullLocation.java similarity index 84% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/config/NullLocation.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/NullLocation.java index b240e07b..d48fb052 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/NullLocation.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/NullLocation.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.config; +package org.mvplugins.multiverse.core.world.config; import java.util.Collections; import java.util.Map; @@ -8,8 +8,6 @@ import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; -import org.mvplugins.multiverse.core.world.SimpleMVWorld; - /** * Null-location. */ @@ -46,8 +44,8 @@ public final class NullLocation extends SpawnLocation { * @param args The map. * @return The deserialized object. */ - public static SimpleMVWorld.NullLocation deserialize(Map args) { - return new SimpleMVWorld.NullLocation(); + public static NullLocation deserialize(Map args) { + return new NullLocation(); } @Override diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/SpawnLocation.java b/src/main/java/org/mvplugins/multiverse/core/world/config/SpawnLocation.java similarity index 98% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/config/SpawnLocation.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/SpawnLocation.java index cd4f96e4..4e450f98 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/SpawnLocation.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/SpawnLocation.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.config; +package org.mvplugins.multiverse.core.world.config; import java.lang.ref.Reference; import java.lang.ref.WeakReference; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldConfig.java b/src/main/java/org/mvplugins/multiverse/core/world/config/WorldConfig.java similarity index 98% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldConfig.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/WorldConfig.java index f5a2f417..c49b5319 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldConfig.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/WorldConfig.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.config; +package org.mvplugins.multiverse.core.world.config; import java.util.Collection; import java.util.List; @@ -22,9 +22,8 @@ import org.mvplugins.multiverse.core.configuration.migration.LongMigratorAction; import org.mvplugins.multiverse.core.configuration.migration.MoveMigratorAction; import org.mvplugins.multiverse.core.configuration.migration.NullStringMigratorAction; import org.mvplugins.multiverse.core.configuration.migration.VersionMigrator; -import org.mvplugins.multiverse.core.world.configuration.AllowedPortalType; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; -import org.mvplugins.multiverse.core.worldnew.helpers.EnforcementHandler; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.helpers.EnforcementHandler; /** * Represents a world configuration. diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldConfigNodes.java b/src/main/java/org/mvplugins/multiverse/core/world/config/WorldConfigNodes.java similarity index 97% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldConfigNodes.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/WorldConfigNodes.java index cdb0bd2f..8c6d6f3b 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldConfigNodes.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/WorldConfigNodes.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.config; +package org.mvplugins.multiverse.core.world.config; import java.util.ArrayList; import java.util.List; @@ -13,9 +13,9 @@ import org.jetbrains.annotations.NotNull; import org.mvplugins.multiverse.core.configuration.node.ConfigNode; import org.mvplugins.multiverse.core.configuration.node.Node; import org.mvplugins.multiverse.core.configuration.node.NodeGroup; -import org.mvplugins.multiverse.core.world.configuration.AllowedPortalType; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; -import org.mvplugins.multiverse.core.worldnew.helpers.EnforcementHandler; +import org.mvplugins.multiverse.core.world.config.AllowedPortalType; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.helpers.EnforcementHandler; /** * Represents nodes in a world configuration. diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldsConfigManager.java b/src/main/java/org/mvplugins/multiverse/core/world/config/WorldsConfigManager.java similarity index 97% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldsConfigManager.java rename to src/main/java/org/mvplugins/multiverse/core/world/config/WorldsConfigManager.java index b51d38a2..c5868c66 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/WorldsConfigManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/WorldsConfigManager.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.config; +package org.mvplugins.multiverse.core.world.config; import java.io.File; import java.io.IOException; @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.MultiverseCore; -import org.mvplugins.multiverse.core.worldnew.helpers.EnforcementHandler; +import org.mvplugins.multiverse.core.world.helpers.EnforcementHandler; /** * Manages the worlds.yml file. @@ -84,7 +84,7 @@ public final class WorldsConfigManager { return configData.replace(" ==: MVWorld\n", "") .replace(" ==: MVSpawnSettings\n", "") .replace(" ==: MVSpawnSubSettings\n", "") - .replace(" ==: MVEntryFee\n", ""); + .replace(" ==: MVEntryFee\n", ""); }) .andThenTry(configData -> Files.writeString(worldConfigFile.toPath(), configData)) .andThenTry(() -> { diff --git a/src/main/java/org/mvplugins/multiverse/core/world/config/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/config/package-info.java new file mode 100644 index 00000000..e5369dc9 --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/world/config/package-info.java @@ -0,0 +1 @@ +package org.mvplugins.multiverse.core.world.config; diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/Action.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/Action.java deleted file mode 100644 index 998d2022..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/Action.java +++ /dev/null @@ -1,30 +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.configuration; - -/** - * A enum containing all actions that can be used to modify world-properties. - */ -public enum Action { - /** - * Setting a property. - */ - Set, - /** - * Adding something to a list-property. - */ - Add, - /** - * Removing something from a list-property. - */ - Remove, - /** - * Clearing a list-property. - */ - Clear -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/AddProperties.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/AddProperties.java deleted file mode 100644 index 5f758238..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/AddProperties.java +++ /dev/null @@ -1,26 +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.configuration; - -/** - * An enum containing all list-properties. - */ -public enum AddProperties { - /** - * Worlds that people cannot go to from a world. - */ - worldblacklist, - /** - * Animal-exceptions. - */ - animals, - /** - * Monster-exceptions. - */ - monsters -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatColor.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatColor.java deleted file mode 100644 index af94054d..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatColor.java +++ /dev/null @@ -1,95 +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.configuration; - -import org.bukkit.ChatColor; - -/** - * A regular {@link ChatColor} represented by an english string. - * @see ChatColor - */ -public enum EnglishChatColor { - // BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable - AQUA(ChatColor.AQUA), - BLACK(ChatColor.BLACK), - BLUE(ChatColor.BLUE), - DARKAQUA(ChatColor.DARK_AQUA), - DARKBLUE(ChatColor.DARK_BLUE), - DARKGRAY(ChatColor.DARK_GRAY), - DARKGREEN(ChatColor.DARK_GREEN), - DARKPURPLE(ChatColor.DARK_PURPLE), - DARKRED(ChatColor.DARK_RED), - GOLD(ChatColor.GOLD), - GRAY(ChatColor.GRAY), - GREEN(ChatColor.GREEN), - LIGHTPURPLE(ChatColor.LIGHT_PURPLE), - RED(ChatColor.RED), - YELLOW(ChatColor.YELLOW), - WHITE(ChatColor.WHITE); - // END CHECKSTYLE-SUPPRESSION: JavadocVariable - - private final ChatColor color; - //private final String text; - - EnglishChatColor(ChatColor color) { - this.color = color; - } - - /** - * Gets the text. - * @return The text. - */ - public String getText() { - return this.name(); - } - - /** - * Gets the color. - * @return The color as {@link ChatColor}. - */ - public ChatColor getColor() { - return this.color; - } - - /** - * Constructs a string containing all available colors. - * @return That {@link String}. - */ - public static String getAllColors() { - String buffer = ""; - for (EnglishChatColor c : EnglishChatColor.values()) { - buffer += c.getColor() + c.getText() + " "; - } - return buffer; - } - - /** - * Constructs an {@link EnglishChatColor} from a {@link String}. - * @param text The {@link String}. - * @return The {@link EnglishChatColor}. - */ - public static EnglishChatColor fromString(String text) { - if (text != null) { - for (EnglishChatColor c : EnglishChatColor.values()) { - if (text.equalsIgnoreCase(c.name())) { - return c; - } - } - } - return null; - } - - /** - * Looks if the given-color name is a valid color. - * @param aliasColor A color-name. - * @return True if the name is a valid color, false if it isn't. - */ - public static boolean isValidAliasColor(String aliasColor) { - return (EnglishChatColor.fromString(aliasColor) != null); - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatStyle.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatStyle.java deleted file mode 100644 index 1211af0d..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/EnglishChatStyle.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.mvplugins.multiverse.core.world.configuration; - -import org.bukkit.ChatColor; - -/** - * A regular {@link ChatColor} represented by an english string. - * @see ChatColor - */ -public enum EnglishChatStyle { - // BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable - /** No style. */ - NORMAL(null), - MAGIC(ChatColor.MAGIC), - BOLD(ChatColor.BOLD), - STRIKETHROUGH(ChatColor.STRIKETHROUGH), - UNDERLINE(ChatColor.UNDERLINE), - ITALIC(ChatColor.ITALIC); - // END CHECKSTYLE-SUPPRESSION: JavadocVariable - - private final ChatColor color; - - EnglishChatStyle(ChatColor color) { - this.color = color; - } - - /** - * Gets the color. - * @return The color as {@link ChatColor}. - */ - public ChatColor getColor() { - return color; - } - - /** - * Constructs an {@link EnglishChatStyle} from a {@link String}. - * @param text The {@link String}. - * @return The {@link EnglishChatStyle}. - */ - public static EnglishChatStyle fromString(String text) { - if (text != null) { - for (EnglishChatStyle c : EnglishChatStyle.values()) { - if (text.equalsIgnoreCase(c.name())) { - return c; - } - } - } - return null; - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/EntryFee.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/EntryFee.java deleted file mode 100644 index 381bbac3..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/EntryFee.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.mvplugins.multiverse.core.world.configuration; - -import java.util.Map; - -import me.main__.util.SerializationConfig.Property; -import me.main__.util.SerializationConfig.SerializationConfig; -import me.main__.util.SerializationConfig.Serializor; -import org.bukkit.Material; -import org.bukkit.configuration.serialization.SerializableAs; -import org.jetbrains.annotations.Nullable; - -import org.mvplugins.multiverse.core.utils.MaterialConverter; - -/** - * Entryfee-settings. - */ -@SerializableAs("MVEntryFee") -public class EntryFee extends SerializationConfig { - @Property - private double amount; - @Property(serializor = EntryFeeCurrencySerializor.class) - @Nullable - private Material currency; - - public static final Material DISABLED_MATERIAL = Material.AIR; - - public EntryFee() { - super(); - } - - public EntryFee(Map values) { - super(values); - } - - /** - * {@inheritDoc} - */ - @Override - protected void setDefaults() { - amount = 0D; - currency = null; - } - - /** - * @return the amount - */ - public double getAmount() { - return amount; - } - - /** - * @return the currency - */ - @Nullable - public Material getCurrency() { - if (currency == null || currency.equals(DISABLED_MATERIAL)) { - return null; - } - return currency; - } - - /** - * Sets the amount. - * @param amount The new value. - */ - public void setAmount(double amount) { - this.amount = amount; - } - - /** - * Sets the currency. - * @param currency The new value. - */ - public void setCurrency(@Nullable Material currency) { - this.currency = currency; - } - - public static final class EntryFeeCurrencySerializor implements Serializor { - @Override - public String serialize(Material material) { - return material.toString(); - } - - @Override - public Material deserialize(Object o, Class aClass) { - return MaterialConverter.convertTypeString(o.toString()); - } - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/SpawnSettings.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/SpawnSettings.java deleted file mode 100644 index f1383dc7..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/SpawnSettings.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.mvplugins.multiverse.core.world.configuration; - -import java.util.Map; - -import me.main__.util.SerializationConfig.Property; -import me.main__.util.SerializationConfig.SerializationConfig; -import org.bukkit.configuration.serialization.SerializableAs; - -/** - * Spawning-Settings. - */ -@SerializableAs("MVSpawnSettings") -public class SpawnSettings extends SerializationConfig { - @Property - private SubSpawnSettings animals; - @Property - private SubSpawnSettings monsters; - - public SpawnSettings() { - super(); - } - - public SpawnSettings(Map values) { - super(values); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDefaults() { - animals = new SubSpawnSettings(); - monsters = new SubSpawnSettings(); - } - - /** - * @return the animal-settings - */ - public SubSpawnSettings getAnimalSettings() { - return animals; - } - - /** - * @return the monster-settings - */ - public SubSpawnSettings getMonsterSettings() { - return monsters; - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/SubSpawnSettings.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/SubSpawnSettings.java deleted file mode 100644 index 60de09f1..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/SubSpawnSettings.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.mvplugins.multiverse.core.world.configuration; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import me.main__.util.SerializationConfig.Property; -import me.main__.util.SerializationConfig.SerializationConfig; -import org.bukkit.configuration.serialization.SerializableAs; - -/** - * SpawnSubSettings. - */ -@SerializableAs("MVSpawnSubSettings") -public class SubSpawnSettings extends SerializationConfig { - @Property - private boolean spawn; - @Property - private int spawnrate; - @Property - private List exceptions; - - public SubSpawnSettings() { - super(); - } - - public SubSpawnSettings(Map values) { - super(values); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDefaults() { - spawn = true; - exceptions = new ArrayList(); - spawnrate = -1; - } - - /** - * @return spawn - */ - public boolean doSpawn() { - return spawn; - } - - /** - * @param spawn The new value. - */ - public void setSpawn(boolean spawn) { - this.spawn = spawn; - } - - /** - * @return The exceptions - */ - public List getExceptions() { - return exceptions; - } - - /** - * @param rate The new spawn rate - */ - public void setSpawnRate(int rate) { - this.spawnrate = rate; - } - - /** - * @return The spawn rate - */ - public int getSpawnRate() { - return this.spawnrate; - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/WorldPropertyValidator.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/WorldPropertyValidator.java deleted file mode 100644 index e8eb0ced..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/WorldPropertyValidator.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.mvplugins.multiverse.core.world.configuration; - -import me.main__.util.SerializationConfig.ChangeDeniedException; -import me.main__.util.SerializationConfig.ObjectUsingValidator; -import org.bukkit.Bukkit; - -import org.mvplugins.multiverse.core.event.MVWorldPropertyChangeEvent; -import org.mvplugins.multiverse.core.world.SimpleMVWorld; - -/** - * Validates world-property-changes. - * @param The type of the property that should be validated. - */ -public class WorldPropertyValidator extends ObjectUsingValidator { - /** - * {@inheritDoc} - */ - @Override - public T validateChange(String property, T newValue, T oldValue, SimpleMVWorld object) throws ChangeDeniedException { - MVWorldPropertyChangeEvent event = new MVWorldPropertyChangeEvent(object, null, property, newValue); - Bukkit.getPluginManager().callEvent(event); - if (event.isCancelled()) - throw new ChangeDeniedException(); - return event.getTheNewValue(); - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/world/configuration/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/configuration/package-info.java deleted file mode 100644 index 9afa1595..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/world/configuration/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains the configuration classes for the worlds. - */ -package org.mvplugins.multiverse.core.world.configuration; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/BlacklistResult.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/BlacklistResult.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/BlacklistResult.java rename to src/main/java/org/mvplugins/multiverse/core/world/entrycheck/BlacklistResult.java index 71c697a6..7de9b859 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/BlacklistResult.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/BlacklistResult.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; +package org.mvplugins.multiverse.core.world.entrycheck; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/EntryFeeResult.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/EntryFeeResult.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/EntryFeeResult.java rename to src/main/java/org/mvplugins/multiverse/core/world/entrycheck/EntryFeeResult.java index 0b562a54..2179762e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/EntryFeeResult.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/EntryFeeResult.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; +package org.mvplugins.multiverse.core.world.entrycheck; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/PlayerLimitResult.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/PlayerLimitResult.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/PlayerLimitResult.java rename to src/main/java/org/mvplugins/multiverse/core/world/entrycheck/PlayerLimitResult.java index 3a2e2b31..61482a12 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/PlayerLimitResult.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/PlayerLimitResult.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; +package org.mvplugins.multiverse.core.world.entrycheck; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldAccessResult.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldAccessResult.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldAccessResult.java rename to src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldAccessResult.java index ea7b2982..5cee48f4 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldAccessResult.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldAccessResult.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; +package org.mvplugins.multiverse.core.world.entrycheck; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldEntryChecker.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryChecker.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldEntryChecker.java rename to src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryChecker.java index 7798eb17..b4e4f9a1 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldEntryChecker.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryChecker.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; +package org.mvplugins.multiverse.core.world.entrycheck; import java.util.Collection; @@ -16,9 +16,8 @@ import org.mvplugins.multiverse.core.economy.MVEconomist; import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker; import org.mvplugins.multiverse.core.utils.result.Result; import org.mvplugins.multiverse.core.utils.result.ResultChain; -import org.mvplugins.multiverse.core.world.configuration.EntryFee; -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; import static org.mvplugins.multiverse.core.utils.message.MessageReplacement.replace; @@ -137,7 +136,7 @@ public class WorldEntryChecker { public Result canPayEntryFee(LoadedMultiverseWorld world) { double price = world.getPrice(); Material currency = world.getCurrency(); - if (price == 0D && (currency == null || currency == EntryFee.DISABLED_MATERIAL)) { + if (price == 0D && (currency == null || currency == MVEconomist.DISABLED_MATERIAL)) { return Result.success(EntryFeeResult.Success.FREE_ENTRY); } if (sender instanceof ConsoleCommandSender || sender instanceof BlockCommandSender) { diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldEntryCheckerProvider.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryCheckerProvider.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldEntryCheckerProvider.java rename to src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryCheckerProvider.java index 91910dad..64be944d 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/WorldEntryCheckerProvider.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/WorldEntryCheckerProvider.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; +package org.mvplugins.multiverse.core.world.entrycheck; import jakarta.inject.Inject; import org.bukkit.command.CommandSender; diff --git a/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/package-info.java new file mode 100644 index 00000000..399c47b1 --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/world/entrycheck/package-info.java @@ -0,0 +1 @@ +package org.mvplugins.multiverse.core.world.entrycheck; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/GeneratorPlugin.java b/src/main/java/org/mvplugins/multiverse/core/world/generators/GeneratorPlugin.java similarity index 97% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/generators/GeneratorPlugin.java rename to src/main/java/org/mvplugins/multiverse/core/world/generators/GeneratorPlugin.java index d8bbcacb..8273e9e0 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/GeneratorPlugin.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/generators/GeneratorPlugin.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.generators; +package org.mvplugins.multiverse.core.world.generators; import java.util.Collection; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/GeneratorProvider.java b/src/main/java/org/mvplugins/multiverse/core/world/generators/GeneratorProvider.java similarity index 99% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/generators/GeneratorProvider.java rename to src/main/java/org/mvplugins/multiverse/core/world/generators/GeneratorProvider.java index e57682a3..dfdb8774 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/GeneratorProvider.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/generators/GeneratorProvider.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.generators; +package org.mvplugins.multiverse.core.world.generators; import java.io.File; import java.util.ArrayList; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/SimpleGeneratorPlugin.java b/src/main/java/org/mvplugins/multiverse/core/world/generators/SimpleGeneratorPlugin.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/generators/SimpleGeneratorPlugin.java rename to src/main/java/org/mvplugins/multiverse/core/world/generators/SimpleGeneratorPlugin.java index 66cbb984..5a1c435c 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/SimpleGeneratorPlugin.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/generators/SimpleGeneratorPlugin.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.generators; +package org.mvplugins.multiverse.core.world.generators; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/org/mvplugins/multiverse/core/world/generators/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/generators/package-info.java new file mode 100644 index 00000000..1765e7fb --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/world/generators/package-info.java @@ -0,0 +1 @@ +package org.mvplugins.multiverse.core.world.generators; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/DataStore.java b/src/main/java/org/mvplugins/multiverse/core/world/helpers/DataStore.java similarity index 97% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/DataStore.java rename to src/main/java/org/mvplugins/multiverse/core/world/helpers/DataStore.java index a86251ea..08f6f994 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/DataStore.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/helpers/DataStore.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.helpers; +package org.mvplugins.multiverse.core.world.helpers; import java.util.Arrays; import java.util.HashMap; @@ -10,7 +10,7 @@ import org.bukkit.GameRule; import org.bukkit.World; import org.jvnet.hk2.annotations.Service; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; /** * A data store for storing and restoring data from an object. diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/DataTransfer.java b/src/main/java/org/mvplugins/multiverse/core/world/helpers/DataTransfer.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/DataTransfer.java rename to src/main/java/org/mvplugins/multiverse/core/world/helpers/DataTransfer.java index 9a2a0d8d..89769b73 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/DataTransfer.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/helpers/DataTransfer.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.helpers; +package org.mvplugins.multiverse.core.world.helpers; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/EnforcementHandler.java b/src/main/java/org/mvplugins/multiverse/core/world/helpers/EnforcementHandler.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/EnforcementHandler.java rename to src/main/java/org/mvplugins/multiverse/core/world/helpers/EnforcementHandler.java index 246b7a23..49561ac9 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/EnforcementHandler.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/helpers/EnforcementHandler.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.helpers; +package org.mvplugins.multiverse.core.world.helpers; import com.dumptruckman.minecraft.util.Logging; import jakarta.inject.Inject; @@ -9,8 +9,8 @@ import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker; -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 EnforcementHandler { diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/FilesManipulator.java b/src/main/java/org/mvplugins/multiverse/core/world/helpers/FilesManipulator.java similarity index 99% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/FilesManipulator.java rename to src/main/java/org/mvplugins/multiverse/core/world/helpers/FilesManipulator.java index 5cc3464c..6a6057e0 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/FilesManipulator.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/helpers/FilesManipulator.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.helpers; +package org.mvplugins.multiverse.core.world.helpers; import java.io.File; import java.io.IOException; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java b/src/main/java/org/mvplugins/multiverse/core/world/helpers/PlayerWorldTeleporter.java similarity index 96% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java rename to src/main/java/org/mvplugins/multiverse/core/world/helpers/PlayerWorldTeleporter.java index facecadd..15160668 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/helpers/PlayerWorldTeleporter.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.helpers; +package org.mvplugins.multiverse.core.world.helpers; import java.util.List; @@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.api.SafeTTeleporter; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; /** * Handles all player actions that need to be done when a change in world related activity occurs. diff --git a/src/main/java/org/mvplugins/multiverse/core/world/helpers/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/helpers/package-info.java new file mode 100644 index 00000000..777d759b --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/world/helpers/package-info.java @@ -0,0 +1 @@ +package org.mvplugins.multiverse.core.world.helpers; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/CloneWorldOptions.java b/src/main/java/org/mvplugins/multiverse/core/world/options/CloneWorldOptions.java similarity index 96% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/options/CloneWorldOptions.java rename to src/main/java/org/mvplugins/multiverse/core/world/options/CloneWorldOptions.java index 8a18da36..f487ffce 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/CloneWorldOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/CloneWorldOptions.java @@ -1,8 +1,8 @@ -package org.mvplugins.multiverse.core.worldnew.options; +package org.mvplugins.multiverse.core.world.options; import org.jetbrains.annotations.NotNull; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; /** * Options for customizing the cloning of a world. diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/CreateWorldOptions.java b/src/main/java/org/mvplugins/multiverse/core/world/options/CreateWorldOptions.java similarity index 98% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/options/CreateWorldOptions.java rename to src/main/java/org/mvplugins/multiverse/core/world/options/CreateWorldOptions.java index d9bcde80..bbbc9d44 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/CreateWorldOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/CreateWorldOptions.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.options; +package org.mvplugins.multiverse.core.world.options; import java.util.Random; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/ImportWorldOptions.java b/src/main/java/org/mvplugins/multiverse/core/world/options/ImportWorldOptions.java similarity index 98% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/options/ImportWorldOptions.java rename to src/main/java/org/mvplugins/multiverse/core/world/options/ImportWorldOptions.java index 95fdd404..a082ca4e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/ImportWorldOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/ImportWorldOptions.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.options; +package org.mvplugins.multiverse.core.world.options; import org.bukkit.World; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/KeepWorldSettingsOptions.java b/src/main/java/org/mvplugins/multiverse/core/world/options/KeepWorldSettingsOptions.java similarity index 96% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/options/KeepWorldSettingsOptions.java rename to src/main/java/org/mvplugins/multiverse/core/world/options/KeepWorldSettingsOptions.java index 81729a17..8e501c7e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/KeepWorldSettingsOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/KeepWorldSettingsOptions.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.options; +package org.mvplugins.multiverse.core.world.options; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/RegenWorldOptions.java b/src/main/java/org/mvplugins/multiverse/core/world/options/RegenWorldOptions.java similarity index 97% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/options/RegenWorldOptions.java rename to src/main/java/org/mvplugins/multiverse/core/world/options/RegenWorldOptions.java index ac49460a..c7475039 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/RegenWorldOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/RegenWorldOptions.java @@ -1,11 +1,11 @@ -package org.mvplugins.multiverse.core.worldnew.options; +package org.mvplugins.multiverse.core.world.options; import java.util.Random; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; /** * Options for customizing the regeneration of a world. diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java b/src/main/java/org/mvplugins/multiverse/core/world/options/UnloadWorldOptions.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java rename to src/main/java/org/mvplugins/multiverse/core/world/options/UnloadWorldOptions.java index 27824c3b..f35abc4f 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/UnloadWorldOptions.java @@ -1,6 +1,6 @@ -package org.mvplugins.multiverse.core.worldnew.options; +package org.mvplugins.multiverse.core.world.options; -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; +import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; /** * Options for customizing the unloading of a world. diff --git a/src/main/java/org/mvplugins/multiverse/core/world/options/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/options/package-info.java new file mode 100644 index 00000000..c6221aa1 --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/world/options/package-info.java @@ -0,0 +1 @@ +package org.mvplugins.multiverse.core.world.options; diff --git a/src/main/java/org/mvplugins/multiverse/core/world/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/package-info.java index 65e57c1c..be040f95 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/package-info.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/package-info.java @@ -1,4 +1 @@ -/** - * This package contains all the classes that are used to create and manage worlds. - */ package org.mvplugins.multiverse.core.world; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/CloneFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/CloneFailureReason.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/CloneFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/CloneFailureReason.java index 3dff3919..aab9f8e2 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/CloneFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/CloneFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/CreateFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/CreateFailureReason.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/CreateFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/CreateFailureReason.java index 876b20ce..4830f4fd 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/CreateFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/CreateFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/DeleteFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/DeleteFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java index 83149944..454f57de 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/DeleteFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/ImportFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/ImportFailureReason.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/ImportFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/ImportFailureReason.java index 45927aa4..1f7d76bc 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/ImportFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/ImportFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/LoadFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/LoadFailureReason.java similarity index 95% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/LoadFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/LoadFailureReason.java index 30657fd5..100b3208 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/LoadFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/LoadFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/RegenFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/RegenFailureReason.java similarity index 93% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/RegenFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/RegenFailureReason.java index d904c00e..d855cdd0 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/RegenFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/RegenFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/RemoveFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/RemoveFailureReason.java similarity index 93% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/RemoveFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/RemoveFailureReason.java index 810d93fe..3d7b794e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/RemoveFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/RemoveFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/UnloadFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/UnloadFailureReason.java similarity index 94% rename from src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/UnloadFailureReason.java rename to src/main/java/org/mvplugins/multiverse/core/world/reasons/UnloadFailureReason.java index 759ecd5c..4bbf0e43 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/UnloadFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/UnloadFailureReason.java @@ -1,4 +1,4 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; +package org.mvplugins.multiverse.core.world.reasons; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/org/mvplugins/multiverse/core/world/reasons/package-info.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/package-info.java new file mode 100644 index 00000000..16452d66 --- /dev/null +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/package-info.java @@ -0,0 +1 @@ +package org.mvplugins.multiverse.core.world.reasons; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldNameChecker.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldNameChecker.java deleted file mode 100644 index 0026c7ac..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldNameChecker.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew; - -import java.io.File; -import java.util.Set; -import java.util.regex.Pattern; - -import org.bukkit.Bukkit; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jvnet.hk2.annotations.Service; - -/** - *

Utility class in helping to check the status of a world name and it's associated world folder.

- * - *

Note this is for preliminary checks and better command output. A valid result will suggest but not - * 100% determine that a world name can be created, loaded or imported.

- */ -@Service -public class WorldNameChecker { - - private static final Pattern WORLD_NAME_PATTERN = Pattern.compile("[a-zA-Z0-9/._-]+"); - private static final Set BLACKLIST_NAMES = Set.of( - "cache", - "config", - "crash-reports", - "logs", - "plugins", - "versions"); - - /** - * Checks if a world name is valid. - * - * @param worldName The world name to check on. - * @return True if check result is valid, else false. - */ - public boolean isValidWorldName(@Nullable String worldName) { - return checkName(worldName) == NameStatus.VALID; - } - - /** - * Checks the current validity status of a world name. - * - * @param worldName The world name to check on. - * @return The resulting name status. - */ - @NotNull - public NameStatus checkName(@Nullable String worldName) { - if (BLACKLIST_NAMES.contains(worldName)) { - return NameStatus.BLACKLISTED; - } - if (worldName == null || !WORLD_NAME_PATTERN.matcher(worldName).matches()) { - return NameStatus.INVALID_CHARS; - } - return NameStatus.VALID; - } - - /** - * Checks if a world name has a valid world folder. - * - * @param worldName The world name to check on. - * @return True if check result is valid, else false. - */ - public boolean isValidWorldFolder(@Nullable String worldName) { - return checkFolder(worldName) == FolderStatus.VALID; - } - - /** - * Checks if a world folder is valid. - * - * @param worldFolder The world folder to check on. - * @return True if check result is valid, else false. - */ - public boolean isValidWorldFolder(@Nullable File worldFolder) { - return checkFolder(worldFolder) == FolderStatus.VALID; - } - - /** - * Checks the current folder status for a world name. - * - * @param worldName The world name to check on. - * @return The resulting folder status. - */ - @NotNull - public FolderStatus checkFolder(@Nullable String worldName) { - if (worldName == null) { - return FolderStatus.DOES_NOT_EXIST; - } - File worldFolder = new File(Bukkit.getWorldContainer(), worldName); - return checkFolder(worldFolder); - } - - /** - * Checks the current folder status. - * - * @param worldFolder The world folder to check on. - * @return The resulting folder status. - */ - @NotNull - public FolderStatus checkFolder(@Nullable File worldFolder) { - if (worldFolder == null || !worldFolder.exists() || !worldFolder.isDirectory()) { - return FolderStatus.DOES_NOT_EXIST; - } - if (!folderHasDat(worldFolder)) { - return FolderStatus.NOT_A_WORLD; - } - return FolderStatus.VALID; - } - - /** - * A very basic check to see if a folder has a level.dat file. If it does, we can safely assume - * it's a world folder. - * - * @param worldFolder The File that may be a world. - * @return True if it looks like a world, else false. - */ - private boolean folderHasDat(@NotNull File worldFolder) { - File[] files = worldFolder.listFiles((file, name) -> name.toLowerCase().endsWith(".dat")); - return files != null && files.length > 0; - } - - /** - * Result after checking validity of world name. - */ - public enum NameStatus { - /** - * Name is valid. - */ - VALID, - - /** - * Name not valid as it contains invalid characters. - */ - INVALID_CHARS, - - /** - * Name not valid as it is deemed blacklisted. - */ - BLACKLISTED - } - - /** - * Result after checking validity of world folder. - */ - public enum FolderStatus { - /** - * Folder is valid. - */ - VALID, - - /** - * Folder exist, but contents in it doesnt look like a world. - */ - NOT_A_WORLD, - - /** - * Folder does not exist. - */ - DOES_NOT_EXIST - } -} diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/config/package-info.java deleted file mode 100644 index 8788e6c6..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/config/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew.config; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/package-info.java deleted file mode 100644 index 5cf06e95..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/entrycheck/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew.entrycheck; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/package-info.java deleted file mode 100644 index fb2f0204..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/generators/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew.generators; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/package-info.java deleted file mode 100644 index 0d262369..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew.helpers; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/options/package-info.java deleted file mode 100644 index af757ae0..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew.options; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/package-info.java deleted file mode 100644 index 91c9ebd6..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew; diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/package-info.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/package-info.java deleted file mode 100644 index 99eb225a..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/reasons/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.mvplugins.multiverse.core.worldnew.reasons; diff --git a/src/old-test/java/org/mvplugins/multiverse/core/TestEntitySpawnRules.java b/src/old-test/java/org/mvplugins/multiverse/core/TestEntitySpawnRules.java index b09faafb..403f4ad2 100644 --- a/src/old-test/java/org/mvplugins/multiverse/core/TestEntitySpawnRules.java +++ b/src/old-test/java/org/mvplugins/multiverse/core/TestEntitySpawnRules.java @@ -17,8 +17,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mvplugins.multiverse.core.api.MVWorld; -import org.mvplugins.multiverse.core.api.MVWorldManager; import org.mvplugins.multiverse.core.listeners.MVEntityListener; import org.mvplugins.multiverse.core.utils.MockWorldFactory; import org.mvplugins.multiverse.core.utils.TestInstanceCreator; diff --git a/src/old-test/java/org/mvplugins/multiverse/core/TestWorldProperties.java b/src/old-test/java/org/mvplugins/multiverse/core/TestWorldProperties.java index 62ecb265..1a8f44d8 100644 --- a/src/old-test/java/org/mvplugins/multiverse/core/TestWorldProperties.java +++ b/src/old-test/java/org/mvplugins/multiverse/core/TestWorldProperties.java @@ -27,7 +27,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mvplugins.multiverse.core.api.MVWorld; import org.mvplugins.multiverse.core.utils.MockWorldFactory; import org.mvplugins.multiverse.core.utils.TestInstanceCreator; diff --git a/src/old-test/java/org/mvplugins/multiverse/core/TestWorldPurger.java b/src/old-test/java/org/mvplugins/multiverse/core/TestWorldPurger.java index 9c031b7e..6c389a28 100644 --- a/src/old-test/java/org/mvplugins/multiverse/core/TestWorldPurger.java +++ b/src/old-test/java/org/mvplugins/multiverse/core/TestWorldPurger.java @@ -10,8 +10,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mvplugins.multiverse.core.api.MVWorld; -import org.mvplugins.multiverse.core.api.WorldPurger; import org.mvplugins.multiverse.core.utils.TestInstanceCreator; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt b/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt index ca818c3a..47a50458 100644 --- a/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt @@ -18,7 +18,7 @@ import org.mvplugins.multiverse.core.teleportation.SimpleSafeTTeleporter import org.mvplugins.multiverse.core.teleportation.TeleportQueue import org.mvplugins.multiverse.core.utils.UnsafeCallWrapper import org.mvplugins.multiverse.core.utils.metrics.MetricsConfigurator -import org.mvplugins.multiverse.core.worldnew.WorldManager +import org.mvplugins.multiverse.core.world.WorldManager import kotlin.test.* class InjectionTest : TestWithMockBukkit() { diff --git a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigMangerTest.kt b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigMangerTest.kt index 718effe3..9a23bd79 100644 --- a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigMangerTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigMangerTest.kt @@ -4,8 +4,8 @@ import org.bukkit.World.Environment import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.mvplugins.multiverse.core.TestWithMockBukkit -import org.mvplugins.multiverse.core.worldnew.config.SpawnLocation -import org.mvplugins.multiverse.core.worldnew.config.WorldsConfigManager +import org.mvplugins.multiverse.core.world.config.SpawnLocation +import org.mvplugins.multiverse.core.world.config.WorldsConfigManager import java.io.File import java.nio.file.Path import kotlin.io.path.absolutePathString diff --git a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt index 02dbc248..d4b76a62 100644 --- a/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/world/WorldConfigTest.kt @@ -1,8 +1,8 @@ package org.mvplugins.multiverse.core.world import org.mvplugins.multiverse.core.TestWithMockBukkit -import org.mvplugins.multiverse.core.worldnew.config.WorldConfig -import org.mvplugins.multiverse.core.worldnew.config.WorldsConfigManager +import org.mvplugins.multiverse.core.world.config.WorldConfig +import org.mvplugins.multiverse.core.world.config.WorldsConfigManager import java.io.File import java.nio.file.Path import kotlin.io.path.absolutePathString diff --git a/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt b/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt index 65cb97cf..bfe857e2 100644 --- a/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/world/WorldManagerTest.kt @@ -3,9 +3,7 @@ package org.mvplugins.multiverse.core.world import org.bukkit.World import org.bukkit.WorldType import org.mvplugins.multiverse.core.TestWithMockBukkit -import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld -import org.mvplugins.multiverse.core.worldnew.WorldManager -import org.mvplugins.multiverse.core.worldnew.options.CreateWorldOptions +import org.mvplugins.multiverse.core.world.options.CreateWorldOptions import kotlin.test.* class WorldManagerTest : TestWithMockBukkit() {