pain: Add docs to the new world related classes

This commit is contained in:
Ben Woo 2023-09-09 13:46:32 +08:00
parent 8e95c22c4d
commit 0f105b1777
No known key found for this signature in database
GPG Key ID: FB2A3645536E12C8
24 changed files with 341 additions and 55 deletions

View File

@ -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{"

View File

@ -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{"

View File

@ -26,7 +26,7 @@ public class WorldPurger {
private Class<Entity> ambientClass = null;
public WorldPurger() {
WorldPurger() {
try {
Class entityClass = Class.forName("org.bukkit.entity.Ambient");
if (Entity.class.isAssignableFrom(entityClass)) {

View File

@ -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<String, Object> serialize() {
public @NotNull Map<String, Object> 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();
}

View File

@ -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<String, Object> serialize() {
Map<String, Object> serialized = new HashMap<String, Object>(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<String, Object> 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.
*/

View File

@ -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;

View File

@ -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;

View File

@ -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<WorldConfig>, List<String>> parseNewAndRemovedWorlds() {
Set<String> allWorldsInConfig = worldsConfig.getKeys(false);
List<WorldConfig> 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);

View File

@ -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<String, String> 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<String> suggestGeneratorString(@Nullable String currentInput) {
String[] genSpilt = currentInput == null ? new String[0] : currentInput.split(":", 2);
List<String> 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());
}
}
}

View File

@ -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<String> suggestIds(@Nullable String currentIdInput) {
return Collections.emptyList();
}
/**
* {@inheritDoc}
*/
@Override
public @Nullable Collection<String> getExampleUsages() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public @Nullable String getInfoLink() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public @NotNull String getPluginName() {
return pluginName;

View File

@ -33,6 +33,9 @@ public interface DataStore<T> {
*/
DataStore<T> pasteTo(T object);
/**
* A {@link DataStore} for storing and restoring game rules for a multiverse world.
*/
class GameRulesStore implements DataStore<LoadedMultiverseWorld> {
private Map<GameRule<?>, Object> gameRuleMap;
@ -79,6 +82,9 @@ public interface DataStore<T> {
}
}
/**
* A {@link DataStore} for storing and restoring world properties for a multiverse world.
*/
class WorldConfigStore implements DataStore<LoadedMultiverseWorld> {
private Map<String, Object> configMap;
@ -114,6 +120,9 @@ public interface DataStore<T> {
}
}
/**
* A {@link DataStore} for storing and restoring world border properties for a multiverse world.
*/
class WorldBorderStore implements DataStore<LoadedMultiverseWorld> {
private double borderCenterX;
private double borderCenterZ;

View File

@ -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 <T> The type of the object to transfer data from and to.
*/
public class DataTransfer<T> {
private final List<DataStore<T>> 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<T> addDataStore(DataStore<T> 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<T> pasteAllTo(T object) {
this.dataStores.forEach(dataStore -> dataStore.pasteTo(object));
return this;

View File

@ -60,7 +60,7 @@ public class FilesManipulator {
}
}
private static class CopyDirFileVisitor extends SimpleFileVisitor<Path> {
private static final class CopyDirFileVisitor extends SimpleFileVisitor<Path> {
private final Path sourceDir;
private final Path targetDir;

View File

@ -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;
}

View File

@ -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 {
/**

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;