diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java index afcdd7e4..0073fbc3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/LoadedMultiverseWorld.java @@ -57,7 +57,8 @@ public class LoadedMultiverseWorld extends MultiverseWorld { } } - private Location readSpawnFromWorld(World world) { // TODO: Refactor... this is copy pasted and bad + private Location readSpawnFromWorld(World world) { + // TODO: Refactor... this is copy pasted and bad Location location = world.getSpawnLocation(); // Set the worldspawn to our configspawn // Verify that location was safe @@ -109,12 +110,18 @@ public class LoadedMultiverseWorld extends MultiverseWorld { return getBukkitWorld().map(World::canGenerateStructures); } + /** + * {@inheritDoc} + */ @Override void setWorldConfig(WorldConfig worldConfig) { super.setWorldConfig(worldConfig); setupWorldConfig(getBukkitWorld().get()); } + /** + * {@inheritDoc} + */ @Override public String toString() { return "LoadedMultiverseWorld{" diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java index 6bf79dfd..b5ddc7df 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/MultiverseWorld.java @@ -294,10 +294,18 @@ public class MultiverseWorld { return worldConfig; } + /** + * Sets the world config. Only for internal use. + * + * @param worldConfig The world config. + */ void setWorldConfig(WorldConfig worldConfig) { this.worldConfig = worldConfig; } + /** + * {@inheritDoc} + */ @Override public String toString() { return "MultiverseWorld{" diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java index f2f1b653..13c81a41 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/WorldPurger.java @@ -26,7 +26,7 @@ public class WorldPurger { private Class ambientClass = null; - public WorldPurger() { + WorldPurger() { try { Class entityClass = Class.forName("org.bukkit.entity.Ambient"); if (Entity.class.isAssignableFrom(entityClass)) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java index 80df59c9..8b20e0a0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/NullLocation.java @@ -4,6 +4,7 @@ import com.onarandombox.MultiverseCore.world.SimpleMVWorld; import org.bukkit.Location; import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.Map; @@ -18,17 +19,18 @@ public final class NullLocation extends SpawnLocation { } @Override - public Location clone() { + public @NotNull Location clone() { throw new UnsupportedOperationException(); } @Override - public Map serialize() { + public @NotNull Map serialize() { return Collections.emptyMap(); } /** * Let Bukkit be able to deserialize this. + * * @param args The map. * @return The deserialized object. */ @@ -37,7 +39,7 @@ public final class NullLocation extends SpawnLocation { } @Override - public Vector toVector() { + public @NotNull Vector toVector() { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/SpawnLocation.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/SpawnLocation.java index 824daad6..4e418f1c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/SpawnLocation.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/SpawnLocation.java @@ -11,6 +11,7 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.SerializableAs; +import org.jetbrains.annotations.NotNull; /** * Just like a regular {@link Location}, however {@code world} is usually {@code null} @@ -52,10 +53,11 @@ public class SpawnLocation extends Location implements ConfigurationSerializable * {@inheritDoc} */ @Override - public Chunk getChunk() { - if ((this.worldRef != null) && (this.worldRef.get() != null)) + public @NotNull Chunk getChunk() { + if (this.worldRef != null && this.worldRef.get() != null) { return this.worldRef.get().getChunkAt(this); - return null; + } + throw new IllegalStateException("World is null"); } /** @@ -63,27 +65,29 @@ public class SpawnLocation extends Location implements ConfigurationSerializable */ @Override public Block getBlock() { - if ((this.worldRef != null) && (this.worldRef.get() != null)) + if (this.worldRef != null && this.worldRef.get() != null) { return this.worldRef.get().getBlockAt(this); - return null; + } + throw new IllegalStateException("World is null"); } /** * {@inheritDoc} */ @Override - public Map serialize() { - Map serialized = new HashMap(5); // SUPPRESS CHECKSTYLE: MagicNumberCheck - serialized.put("x", this.getX()); - serialized.put("y", this.getY()); - serialized.put("z", this.getZ()); - serialized.put("pitch", this.getPitch()); - serialized.put("yaw", this.getYaw()); - return serialized; + public @NotNull Map serialize() { + return new HashMap<>() {{ + put("x", getX()); + put("y", getY()); + put("z", getZ()); + put("pitch", getPitch()); + put("yaw", getYaw()); + }}; } /** * Let Bukkit be able to deserialize this. + * * @param args The map. * @return The deserialized object. */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java index 68c80f19..8d6652a7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfig.java @@ -17,6 +17,9 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.List; +/** + * Represents a world configuration. + */ public final class WorldConfig { private final String worldName; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java index 53276948..2a309ca6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldConfigNodes.java @@ -14,6 +14,9 @@ import org.bukkit.World; import java.util.ArrayList; import java.util.List; +/** + * Represents nodes in a world configuration. + */ public class WorldConfigNodes { private final NodeGroup nodes = new NodeGroup(); LoadedMultiverseWorld world = null; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java index 23a972d9..f86ccfcb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/config/WorldsConfigManager.java @@ -48,6 +48,12 @@ public final class WorldsConfigManager { }); } + /** + * Loads the worlds.yml file. + * + * @throws IOException If an error occurs while loading the file. + * @throws InvalidConfigurationException If the file is not a valid YAML file. + */ private void loadWorldYmlFile() throws IOException, InvalidConfigurationException { if (!worldConfigFile.exists() && !worldConfigFile.createNewFile()) { throw new IllegalStateException("Could not create worlds.yml config file"); @@ -57,6 +63,11 @@ public final class WorldsConfigManager { worldsConfig.load(worldConfigFile); } + /** + * Parses the worlds.yml file and creates a WorldConfig for each world in the file if it doesn't already exist. + * + * @return A tuple containing a list of the new WorldConfigs added and a list of the worlds removed from the config. + */ private Tuple2, List> parseNewAndRemovedWorlds() { Set allWorldsInConfig = worldsConfig.getKeys(false); List newWorldsAdded = new ArrayList<>(); @@ -136,6 +147,13 @@ public final class WorldsConfigManager { worldsConfig.set(worldName, null); } + /** + * Gets the {@link ConfigurationSection} for the given world in the worlds.yml file. If the section doesn't exist, + * it is created. + * + * @param worldName The name of the world. + * @return The {@link ConfigurationSection} for the given world. + */ private ConfigurationSection getWorldConfigSection(String worldName) { return worldsConfig.isConfigurationSection(worldName) ? worldsConfig.getConfigurationSection(worldName) : worldsConfig.createSection(worldName); diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/GeneratorProvider.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/GeneratorProvider.java index 6f8997bd..93274aa9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/GeneratorProvider.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/GeneratorProvider.java @@ -28,6 +28,10 @@ import java.util.Set; import static com.onarandombox.MultiverseCore.utils.file.FileUtils.getBukkitConfig; +/** + * Parse the default world generators from the bukkit config and load any generator plugins. + * Helps in suggesting and validating generator strings. + */ @Service public class GeneratorProvider implements Listener { private final Map defaultGenerators; @@ -43,6 +47,9 @@ public class GeneratorProvider implements Listener { loadPluginGenerators(); } + /** + * Load the default world generators string from the bukkit config. + */ private void loadDefaultWorldGenerators() { File bukkitConfigFile = getBukkitConfig(); if (bukkitConfigFile == null) { @@ -57,6 +64,10 @@ public class GeneratorProvider implements Listener { keys.forEach(key -> defaultGenerators.put(key, bukkitConfig.getString("worlds." + key + ".generator", ""))); } } + + /** + * Find generator plugins from plugins loaded and register them. + */ private void loadPluginGenerators() { Arrays.stream(Bukkit.getPluginManager().getPlugins()).forEach(plugin -> { if (testIsGeneratorPlugin(plugin)) { @@ -65,6 +76,12 @@ public class GeneratorProvider implements Listener { }); } + /** + * Basic test if a plugin is a generator plugin. + * + * @param plugin The plugin to test. + * @return True if the plugin is a generator plugin, else false. + */ private boolean testIsGeneratorPlugin(Plugin plugin) { String worldName = Bukkit.getWorlds().stream().findFirst().map(World::getName).orElse("world"); try { @@ -74,14 +91,27 @@ public class GeneratorProvider implements Listener { return true; } catch (Throwable t) { Logging.warning("Plugin %s threw an exception when testing if it is a generator plugin!", plugin.getName()); + t.printStackTrace(); return false; } } + /** + * Gets the default generator for a world from the bukkit.yml config. + * + * @param worldName The name of the world. + * @return The default generator string for the world, or null if none. + */ public @Nullable String getDefaultGeneratorForWorld(String worldName) { return defaultGenerators.getOrDefault(worldName, null); } + /** + * Attempts to register a plugin as {@link SimpleGeneratorPlugin}. + * + * @param generatorPlugin The plugin to register. + * @return True if registered successfully, else false. + */ public boolean registerGeneratorPlugin(@NotNull GeneratorPlugin generatorPlugin) { var registeredGenerator = generatorPlugins.get(generatorPlugin.getPluginName()); if (registeredGenerator == null || registeredGenerator instanceof SimpleGeneratorPlugin) { @@ -92,7 +122,12 @@ public class GeneratorProvider implements Listener { return false; } - + /** + * Unregisters a plugin. + * + * @param pluginName The plugin to unregister. + * @return True if the plugin was present and now unregistered, else false. + */ public boolean unregisterGeneratorPlugin(@NotNull String pluginName) { if (generatorPlugins.containsKey(pluginName)) { generatorPlugins.remove(pluginName); @@ -102,14 +137,32 @@ public class GeneratorProvider implements Listener { return false; } + /** + * Whether a plugin is registered as a generator plugin. + * + * @param pluginName The name of the plugin. + * @return True if the plugin is registered, else false. + */ public boolean isGeneratorPluginRegistered(@NotNull String pluginName) { return generatorPlugins.containsKey(pluginName); } - public GeneratorPlugin getGeneratorPlugin(@NotNull String pluginName) { + /** + * Gets a generator plugin by name. + * + * @param pluginName The name of the plugin. + * @return The generator plugin, or null if not registered. + */ + public @Nullable GeneratorPlugin getGeneratorPlugin(@NotNull String pluginName) { return generatorPlugins.get(pluginName); } + /** + * Auto complete generator strings, used in command tab completion. + * + * @param currentInput The current input from the user. + * @return A collection of suggestions. + */ public Collection suggestGeneratorString(@Nullable String currentInput) { String[] genSpilt = currentInput == null ? new String[0] : currentInput.split(":", 2); List suggestions = new ArrayList<>(generatorPlugins.keySet()); @@ -124,17 +177,35 @@ public class GeneratorProvider implements Listener { return suggestions; } + /** + * Listen to plugins enabled to see if they are generator plugins. + * + * @param event The plugin enable event. + */ @EventHandler private void onPluginEnable(PluginEnableEvent event) { - if (testIsGeneratorPlugin(event.getPlugin())) { - registerGeneratorPlugin(new SimpleGeneratorPlugin(event.getPlugin().getName())); + if (!testIsGeneratorPlugin(event.getPlugin())) { + Logging.finest("Plugin %s is not a generator plugin.", event.getPlugin().getName()); + return; + } + if (!registerGeneratorPlugin(new SimpleGeneratorPlugin(event.getPlugin().getName()))) { + Logging.severe("Failed to register generator plugin %s!", event.getPlugin().getName()); } } + /** + * Listen to plugins disabled to see if they are generator plugins. If so, unregister them. + * + * @param event The plugin disable event. + */ @EventHandler private void onPluginDisable(PluginDisableEvent event) { - if (isGeneratorPluginRegistered(event.getPlugin().getName())) { - unregisterGeneratorPlugin(event.getPlugin().getName()); + if (!isGeneratorPluginRegistered(event.getPlugin().getName())) { + Logging.finest("Plugin %s is not a generator plugin.", event.getPlugin().getName()); + return; + } + if (!unregisterGeneratorPlugin(event.getPlugin().getName())) { + Logging.severe("Failed to unregister generator plugin %s!", event.getPlugin().getName()); } } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/SimpleGeneratorPlugin.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/SimpleGeneratorPlugin.java index 6cea4606..6a701c09 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/SimpleGeneratorPlugin.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/generators/SimpleGeneratorPlugin.java @@ -6,28 +6,44 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; import java.util.Collections; +/** + * A default implementation of {@link GeneratorPlugin} for those generator plugins that do not provide their own + * custom {@link GeneratorPlugin} implementation to Multiverse. + */ public final class SimpleGeneratorPlugin implements GeneratorPlugin { private final String pluginName; - public SimpleGeneratorPlugin(@NotNull String pluginName) { + SimpleGeneratorPlugin(@NotNull String pluginName) { this.pluginName = pluginName; } + /** + * {@inheritDoc} + */ @Override public @NotNull Collection suggestIds(@Nullable String currentIdInput) { return Collections.emptyList(); } + /** + * {@inheritDoc} + */ @Override public @Nullable Collection getExampleUsages() { return null; } + /** + * {@inheritDoc} + */ @Override public @Nullable String getInfoLink() { return null; } + /** + * {@inheritDoc} + */ @Override public @NotNull String getPluginName() { return pluginName; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java index b91a29ea..7eb334de 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataStore.java @@ -33,6 +33,9 @@ public interface DataStore { */ DataStore pasteTo(T object); + /** + * A {@link DataStore} for storing and restoring game rules for a multiverse world. + */ class GameRulesStore implements DataStore { private Map, Object> gameRuleMap; @@ -79,6 +82,9 @@ public interface DataStore { } } + /** + * A {@link DataStore} for storing and restoring world properties for a multiverse world. + */ class WorldConfigStore implements DataStore { private Map configMap; @@ -114,6 +120,9 @@ public interface DataStore { } } + /** + * A {@link DataStore} for storing and restoring world border properties for a multiverse world. + */ class WorldBorderStore implements DataStore { private double borderCenterX; private double borderCenterZ; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataTransfer.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataTransfer.java index 641f0bfd..00671003 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataTransfer.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/DataTransfer.java @@ -3,18 +3,38 @@ package com.onarandombox.MultiverseCore.worldnew.helpers; import java.util.ArrayList; import java.util.List; +/** + * A data transfer for storing and restoring data from multiple {@link DataStore} from one object to another. + * + * @param The type of the object to transfer data from and to. + */ public class DataTransfer { private final List> dataStores; + /** + * Creates a new {@link DataTransfer} instance. + */ public DataTransfer() { this.dataStores = new ArrayList<>(); } + /** + * Adds a {@link DataStore} to this {@link DataTransfer} instance. + * + * @param dataStore The {@link DataStore} to add. + * @return This {@link DataTransfer} instance. + */ public DataTransfer addDataStore(DataStore dataStore, T object) { this.dataStores.add(dataStore.copyFrom(object)); return this; } + /** + * Copies the data from all {@link DataStore} instances in this {@link DataTransfer} instance to the given object. + * + * @param object The object to paste data to. + * @return This {@link DataTransfer} instance. + */ public DataTransfer pasteAllTo(T object) { this.dataStores.forEach(dataStore -> dataStore.pasteTo(object)); return this; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/FilesManipulator.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/FilesManipulator.java index ace7243c..28dcf4fc 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/FilesManipulator.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/helpers/FilesManipulator.java @@ -60,7 +60,7 @@ public class FilesManipulator { } } - private static class CopyDirFileVisitor extends SimpleFileVisitor { + private static final class CopyDirFileVisitor extends SimpleFileVisitor { private final Path sourceDir; private final Path targetDir; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java index 8552f7f4..e6b66366 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/CloneWorldOptions.java @@ -3,7 +3,18 @@ package com.onarandombox.MultiverseCore.worldnew.options; import com.onarandombox.MultiverseCore.worldnew.LoadedMultiverseWorld; import org.jetbrains.annotations.NotNull; +/** + * Options for customizing the cloning of a world. + */ public class CloneWorldOptions { + + /** + * Creates a new {@link CloneWorldOptions} instance with the given world. + * + * @param world The world to clone. + * @param newWorldName The name of the new world. + * @return A new {@link CloneWorldOptions} instance. + */ public static CloneWorldOptions fromTo(LoadedMultiverseWorld world, String newWorldName) { return new CloneWorldOptions(world, newWorldName); } @@ -15,24 +26,45 @@ public class CloneWorldOptions { private boolean keepWorldBorder = true; - public CloneWorldOptions(LoadedMultiverseWorld world, String newWorldName) { + CloneWorldOptions(LoadedMultiverseWorld world, String newWorldName) { this.world = world; this.newWorldName = newWorldName; } + /** + * Gets the world to clone. + * + * @return The world to clone. + */ public LoadedMultiverseWorld world() { return world; } + /** + * Gets the name of the new world. + * + * @return The name of the new world. + */ public String newWorldName() { return newWorldName; } + /** + * Sets whether to keep the game rule of the world during cloning. + * + * @param keepGameRule Whether to keep the game rule of the world during cloning. + * @return This {@link CloneWorldOptions} instance. + */ public @NotNull CloneWorldOptions keepGameRule(boolean keepGameRule) { this.keepGameRule = keepGameRule; return this; } + /** + * Gets whether to keep the game rule of the world during cloning. + * + * @return Whether to keep the game rule of the world during cloning. + */ public boolean keepGameRule() { return keepGameRule; } @@ -42,6 +74,11 @@ public class CloneWorldOptions { return this; } + /** + * Gets whether to keep the world config of the world during cloning. + * + * @return Whether to keep the world config of the world during cloning. + */ public boolean keepWorldConfig() { return keepWorldConfig; } @@ -51,6 +88,11 @@ public class CloneWorldOptions { return this; } + /** + * Gets whether to keep the world border of the world during cloning. + * + * @return Whether to keep the world border of the world during cloning. + */ public boolean keepWorldBorder() { return keepWorldBorder; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/ImportWorldOptions.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/ImportWorldOptions.java index e5684684..4c092443 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/ImportWorldOptions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/ImportWorldOptions.java @@ -4,6 +4,9 @@ import org.bukkit.World; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +/** + * Options for customizing the import of a new world. + */ public class ImportWorldOptions { /** diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java index e24ad9c9..9cd9c8d7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/options/RegenWorldOptions.java @@ -6,7 +6,17 @@ import org.jetbrains.annotations.Nullable; import java.util.Random; +/** + * Options for customizing the regeneration of a world. + */ public class RegenWorldOptions { + + /** + * Creates a new {@link RegenWorldOptions} instance with the given world. + * + * @param world The world to regenerate. + * @return A new {@link RegenWorldOptions} instance. + */ public static @NotNull RegenWorldOptions world(@NotNull LoadedMultiverseWorld world) { return new RegenWorldOptions(world); } @@ -23,24 +33,51 @@ public class RegenWorldOptions { this.world = world; } + /** + * Gets the world to regenerate. + * + * @return The world to regenerate. + */ public @NotNull LoadedMultiverseWorld world() { return world; } + /** + * Sets whether to keep the game rule of the world during regeneration. + * + * @param keepGameRule Whether to keep the game rule of the world during regeneration. + * @return This {@link RegenWorldOptions} instance. + */ public @NotNull RegenWorldOptions keepGameRule(boolean keepGameRule) { this.keepGameRule = keepGameRule; return this; } + /** + * Gets whether to keep the game rule of the world during regeneration. + * + * @return Whether to keep the game rule of the world during regeneration. + */ public boolean keepGameRule() { return keepGameRule; } + /** + * Sets whether to keep the world config of the world during regeneration. + * + * @param keepWorldConfig Whether to keep the world config of the world during regeneration. + * @return This {@link RegenWorldOptions} instance. + */ public @NotNull RegenWorldOptions keepWorldConfig(boolean keepWorldConfig) { this.keepWorldConfig = keepWorldConfig; return this; } + /** + * Gets whether to keep the world config of the world during regeneration. + * + * @return Whether to keep the world config of the world during regeneration. + */ public boolean keepWorldConfig() { return keepWorldConfig; } @@ -50,10 +87,21 @@ public class RegenWorldOptions { return this; } + /** + * Gets whether to keep the world border of the world during regeneration. + * + * @return Whether to keep the world border of the world during regeneration. + */ public boolean keepWorldBorder() { return keepWorldBorder; } + /** + * Sets whether to use a random seed for the world to regenerate. Cannot be set to true when seed is set. + * + * @param randomSeed Whether to use a random seed for the world to regenerate. + * @return This {@link RegenWorldOptions} instance. + */ public @NotNull RegenWorldOptions randomSeed(boolean randomSeed) { if (randomSeed && seed != Long.MIN_VALUE) { throw new IllegalStateException("Cannot set randomSeed to true when seed is set"); @@ -62,10 +110,21 @@ public class RegenWorldOptions { return this; } + /** + * Gets whether to use a random seed for the world to regenerate. + * + * @return Whether to use a random seed for the world to regenerate. + */ public boolean randomSeed() { return randomSeed; } + /** + * Sets the seed for the world to regenerate. Random seed will be disabled. + * + * @param seed The seed for the world to regenerate. + * @return This {@link RegenWorldOptions} instance. + */ public @NotNull RegenWorldOptions seed(@Nullable String seed) { if (seed == null) { this.seed = Long.MIN_VALUE; @@ -82,11 +141,22 @@ public class RegenWorldOptions { return this; } + /** + * Sets the seed for the world to regenerate. Random seed will be disabled. + * + * @param seed The seed for the world to regenerate. + * @return This {@link RegenWorldOptions} instance. + */ public @NotNull RegenWorldOptions seed(long seed) { this.seed = seed; return this; } + /** + * Gets the seed for the world to regenerate. + * + * @return The seed for the world to regenerate. + */ public long seed() { if (randomSeed) { return new Random().nextLong(); diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CloneWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CloneWorldResult.java index 480fb0eb..c368ac9c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CloneWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CloneWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world clone operation. + */ public class CloneWorldResult { public enum Success implements SuccessReason { - CLONED(MVCorei18n.CLONEWORLD_CLONED) - ; + CLONED(MVCorei18n.CLONEWORLD_CLONED); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CreateWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CreateWorldResult.java index 356a86e8..21a1ef87 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CreateWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/CreateWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world creation operation. + */ public class CreateWorldResult { public enum Success implements SuccessReason { - CREATED(MVCorei18n.CREATEWORLD_CREATED) - ; + CREATED(MVCorei18n.CREATEWORLD_CREATED); private final MessageKeyProvider message; @@ -28,8 +30,7 @@ public class CreateWorldResult { WORLD_EXIST_FOLDER(MVCorei18n.CREATEWORLD_WORLDEXISTFOLDER), WORLD_EXIST_UNLOADED(MVCorei18n.CREATEWORLD_WORLDEXISTUNLOADED), WORLD_EXIST_LOADED(MVCorei18n.CREATEWORLD_WORLDEXISTLOADED), - BUKKIT_CREATION_FAILED(MVCorei18n.CREATEWORLD_BUKKITCREATIONFAILED), - ; + BUKKIT_CREATION_FAILED(MVCorei18n.CREATEWORLD_BUKKITCREATIONFAILED); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/DeleteWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/DeleteWorldResult.java index d196cd7e..604c0ad6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/DeleteWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/DeleteWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world deletion operation. + */ public class DeleteWorldResult { public enum Success implements SuccessReason { - DELETED(MVCorei18n.DELETEWORLD_DELETED) - ; + DELETED(MVCorei18n.DELETEWORLD_DELETED); private final MessageKeyProvider message; @@ -28,8 +30,7 @@ public class DeleteWorldResult { LOAD_FAILED(MVCorei18n.DELETEWORLD_LOADFAILED), WORLD_FOLDER_NOT_FOUND(MVCorei18n.DELETEWORLD_WORLDFOLDERNOTFOUND), REMOVE_FAILED(null), - FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER), - ; + FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/ImportWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/ImportWorldResult.java index a7606835..80da357f 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/ImportWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/ImportWorldResult.java @@ -6,6 +6,9 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world import operation. + */ public class ImportWorldResult { public enum Success implements SuccessReason { IMPORTED(MVCorei18n.IMPORTWORLD_IMPORTED); @@ -27,8 +30,7 @@ public class ImportWorldResult { WORLD_FOLDER_INVALID(MVCorei18n.IMPORTWORLD_WORLDFOLDERINVALID), WORLD_EXIST_UNLOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTUNLOADED), WORLD_EXIST_LOADED(MVCorei18n.IMPORTWORLD_WORLDEXISTLOADED), - BUKKIT_CREATION_FAILED(MVCorei18n.IMPORTWORLD_BUKKITCREATIONFAILED), - ; + BUKKIT_CREATION_FAILED(MVCorei18n.IMPORTWORLD_BUKKITCREATIONFAILED); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/LoadWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/LoadWorldResult.java index 875f5e50..32483c3e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/LoadWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/LoadWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world loading operation. + */ public class LoadWorldResult { public enum Success implements SuccessReason { - LOADED(MVCorei18n.LOADWORLD_LOADED) - ; + LOADED(MVCorei18n.LOADWORLD_LOADED); private final MessageKeyProvider message; @@ -28,8 +30,7 @@ public class LoadWorldResult { WORLD_NON_EXISTENT(MVCorei18n.LOADWORLD_WORLDNONEXISTENT), WORLD_EXIST_FOLDER(MVCorei18n.LOADWORLD_WORLDEXISTFOLDER), WORLD_EXIST_LOADED(MVCorei18n.LOADWORLD_WORLDEXISTLOADED), - BUKKIT_CREATION_FAILED(MVCorei18n.LOADWORLD_BUKKITCREATIONFAILED), - ; + BUKKIT_CREATION_FAILED(MVCorei18n.LOADWORLD_BUKKITCREATIONFAILED); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RegenWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RegenWorldResult.java index ed9ebb5b..4b8ef070 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RegenWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RegenWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world regeneration operation. + */ public class RegenWorldResult { public enum Success implements SuccessReason { - REGENERATED(MVCorei18n.REGENWORLD_REGENERATED) - ; + REGENERATED(MVCorei18n.REGENWORLD_REGENERATED); private final MessageKeyProvider message; @@ -25,8 +27,7 @@ public class RegenWorldResult { public enum Failure implements FailureReason { DELETE_FAILED(null), - CREATE_FAILED(null), - ; + CREATE_FAILED(null); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RemoveWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RemoveWorldResult.java index 7506b69e..e5b79386 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RemoveWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/RemoveWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world removal operation. + */ public class RemoveWorldResult { public enum Success implements SuccessReason { - REMOVED(MVCorei18n.REMOVEWORLD_REMOVED) - ; + REMOVED(MVCorei18n.REMOVEWORLD_REMOVED); private final MessageKeyProvider message; @@ -25,8 +27,7 @@ public class RemoveWorldResult { public enum Failure implements FailureReason { WORLD_NON_EXISTENT(MVCorei18n.REMOVEWORLD_WORLDNONEXISTENT), - UNLOAD_FAILED(null), - ; + UNLOAD_FAILED(null); private final MessageKeyProvider message; diff --git a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/UnloadWorldResult.java b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/UnloadWorldResult.java index b6ee919a..6038a050 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/UnloadWorldResult.java +++ b/src/main/java/com/onarandombox/MultiverseCore/worldnew/results/UnloadWorldResult.java @@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.utils.MVCorei18n; import com.onarandombox.MultiverseCore.utils.result.FailureReason; import com.onarandombox.MultiverseCore.utils.result.SuccessReason; +/** + * Result of a world unloading operation. + */ public class UnloadWorldResult { public enum Success implements SuccessReason { - UNLOADED(MVCorei18n.UNLOADWORLD_UNLOADED) - ; + UNLOADED(MVCorei18n.UNLOADWORLD_UNLOADED); private final MessageKeyProvider message; @@ -27,8 +29,7 @@ public class UnloadWorldResult { WORLD_ALREADY_UNLOADING(MVCorei18n.UNLOADWORLD_WORLDALREADYUNLOADING), WORLD_NON_EXISTENT(MVCorei18n.UNLOADWORLD_WORLDNONEXISTENT), WORLD_UNLOADED(MVCorei18n.UNLOADWORLD_WORLDUNLOADED), - BUKKIT_UNLOAD_FAILED(MVCorei18n.UNLOADWORLD_BUKKITUNLOADFAILED), - ; + BUKKIT_UNLOAD_FAILED(MVCorei18n.UNLOADWORLD_BUKKITUNLOADFAILED); private final MessageKeyProvider message;