mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Merge branch 'MV5' into ben/mv5/teleporter
# Conflicts: # src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java # src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java # src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java # src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java # src/main/java/org/mvplugins/multiverse/core/destination/core/CannonDestination.java # src/main/java/org/mvplugins/multiverse/core/destination/core/ExactDestination.java # src/main/java/org/mvplugins/multiverse/core/destination/core/WorldDestination.java # src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java # src/main/java/org/mvplugins/multiverse/core/permissions/CorePermissionsChecker.java # src/main/java/org/mvplugins/multiverse/core/world/LoadedMultiverseWorld.java # src/main/java/org/mvplugins/multiverse/core/world/helpers/PlayerWorldTeleporter.java
This commit is contained in:
commit
bc1a2ff8a1
@ -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();
|
||||
|
@ -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.
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* This is <b>not</b> 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String> 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<String> 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<String> 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);
|
||||
}
|
@ -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
|
||||
* <p>
|
||||
* 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<MVWorld> 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.
|
||||
* <p>
|
||||
* 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<String> 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<String> getPotentialWorlds();
|
||||
}
|
@ -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<MVWorld> 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<String> 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<String> 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<String> 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);
|
||||
}
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -24,9 +24,7 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
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.helpers.PlayerWorldTeleporter;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
|
@ -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;
|
||||
|
@ -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")
|
||||
|
@ -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.
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -27,10 +27,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.helpers.PlayerWorldTeleporter;
|
||||
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")
|
||||
|
@ -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")
|
||||
|
@ -22,8 +22,7 @@ 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.WorldManager;
|
||||
import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
|
@ -20,10 +20,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.helpers.PlayerWorldTeleporter;
|
||||
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")
|
||||
|
@ -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 {
|
||||
|
@ -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<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext executionContext,
|
||||
String worldName
|
||||
) {
|
||||
private void checkWorldname(
|
||||
ConditionContext<BukkitCommandIssuer> 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 ->
|
||||
|
@ -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 {
|
||||
|
@ -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<MVCommandCompletions> commandCompletionsProvider;
|
||||
|
||||
@Inject
|
||||
public MVCommandManager(
|
||||
MVCommandManager(
|
||||
@NotNull MultiverseCore plugin,
|
||||
@NotNull CommandFlagsManager flagsManager,
|
||||
@NotNull CommandQueueManager commandQueueManager,
|
||||
@NotNull Provider<MVCommandContexts> commandContextsProvider,
|
||||
@NotNull Provider<MVCommandCompletions> 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");
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.api.Destination;
|
||||
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.
|
||||
|
@ -12,8 +12,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.api.Destination;
|
||||
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.
|
||||
|
@ -11,8 +11,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.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.
|
||||
|
@ -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}.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 <T> The type of the property that was set.
|
||||
*/
|
||||
public class MVWorldPropertyChangeEvent<T> 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<T> extends Event implements Cancellable
|
||||
*
|
||||
* @return A valid MultiverseWorld.
|
||||
*/
|
||||
public MVWorld getWorld() {
|
||||
public MultiverseWorld getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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}.
|
||||
|
@ -44,11 +44,11 @@ import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
|
||||
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.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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -8,11 +8,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.api.Destination;
|
||||
import org.mvplugins.multiverse.core.api.MVWorld;
|
||||
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.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
||||
|
||||
@Service
|
||||
public class CorePermissionsChecker {
|
||||
@ -28,11 +27,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()));
|
||||
}
|
||||
@ -45,11 +39,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()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the teleporter has permission to teleport the teleportee to the destination.
|
||||
*
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew;
|
||||
package org.mvplugins.multiverse.core.world;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -14,9 +14,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.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.
|
@ -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.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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<Entity> 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<MVWorld> 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<String> allMobs = new ArrayList<String>(world.getAnimalList());
|
||||
allMobs.addAll(world.getMonsterList());
|
||||
purgeWorld(world, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldWeKillThisCreature(MVWorld world, Entity e) {
|
||||
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
|
||||
allMobs.addAll(world.getMonsterList());
|
||||
return this.shouldWeKillThisCreature(e, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void purgeWorld(MVWorld mvworld, List<String> 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<Entity> worldEntities = world.getEntities();
|
||||
List<LivingEntity> livingEntities = new ArrayList<LivingEntity>(worldEntities.size());
|
||||
List<Projectile> projectiles = new ArrayList<Projectile>(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<Projectile> 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<String> 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<String> 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<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
|
||||
purgeWorld(mvworld, thingsToKill, negateAnimals, negateMonsters, null);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew;
|
||||
package org.mvplugins.multiverse.core.world;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -30,31 +30,31 @@ import org.mvplugins.multiverse.core.api.LocationManipulation;
|
||||
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.
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>Utility class in helping to check the status of a world name and it's associated world folder.</p>
|
||||
@ -16,15 +15,17 @@ import org.jetbrains.annotations.Nullable;
|
||||
* <p>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.</p>
|
||||
*/
|
||||
@Service
|
||||
public class WorldNameChecker {
|
||||
|
||||
private static final Pattern WORLD_NAME_PATTERN = Pattern.compile("[a-zA-Z0-9/._-]+");
|
||||
private static final Set<String> BLACKLIST_NAMES = Collections.unmodifiableSet(new HashSet<String>() {{
|
||||
add("plugins");
|
||||
add("logs");
|
||||
add("cache");
|
||||
add("crash-reports");
|
||||
}});
|
||||
private static final Set<String> 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;
|
||||
}
|
||||
|
@ -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<String, String> PROPERTY_ALIASES;
|
||||
|
||||
static {
|
||||
PROPERTY_ALIASES = new HashMap<String, String>();
|
||||
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<String, Object> 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<T extends Enum<T>> implements Serializor<T, String> {
|
||||
@Override
|
||||
public String serialize(T from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(String serialized, Class<T> 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<Difficulty, String> {
|
||||
@Override
|
||||
public String serialize(Difficulty from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Difficulty deserialize(String serialized, Class<Difficulty> 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<GameMode, String> {
|
||||
@Override
|
||||
public String serialize(GameMode from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode deserialize(String serialized, Class<GameMode> 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<Long, String> {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
private static final String TIME_REGEX = "(\\d\\d?):?(\\d\\d)(a|p)?m?";
|
||||
private static final Map<String, String> TIME_ALIASES;
|
||||
static {
|
||||
Map<String, String> staticTimes = new HashMap<String, String>();
|
||||
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<Long> 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<Boolean> 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> 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<Boolean> 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<Location> 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<String> worldBlacklist;
|
||||
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
|
||||
description = "Set the time to whatever you want! (Will NOT freeze time)")
|
||||
volatile VirtualProperty<Long> 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<String>();
|
||||
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<String, String> 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<String> 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<String> 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<String> 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<String, Object> 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);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew;
|
||||
package org.mvplugins.multiverse.core.world;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
@ -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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew.config;
|
||||
package org.mvplugins.multiverse.core.world.config;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -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<String, Object> args) {
|
||||
return new SimpleMVWorld.NullLocation();
|
||||
public static NullLocation deserialize(Map<String, Object> args) {
|
||||
return new NullLocation();
|
||||
}
|
||||
|
||||
@Override
|
@ -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;
|
@ -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.
|
@ -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.
|
@ -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(() -> {
|
@ -0,0 +1 @@
|
||||
package org.mvplugins.multiverse.core.world.config;
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<String, Object> 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<Material, Object> {
|
||||
@Override
|
||||
public String serialize(Material material) {
|
||||
return material.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material deserialize(Object o, Class<Material> aClass) {
|
||||
return MaterialConverter.convertTypeString(o.toString());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<String, Object> 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;
|
||||
}
|
||||
}
|
@ -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<String> exceptions;
|
||||
|
||||
public SubSpawnSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SubSpawnSettings(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
spawn = true;
|
||||
exceptions = new ArrayList<String>();
|
||||
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<String> 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;
|
||||
}
|
||||
}
|
@ -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 <T> The type of the property that should be validated.
|
||||
*/
|
||||
public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, SimpleMVWorld> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T validateChange(String property, T newValue, T oldValue, SimpleMVWorld object) throws ChangeDeniedException {
|
||||
MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
throw new ChangeDeniedException();
|
||||
return event.getTheNewValue();
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* This package contains the configuration classes for the worlds.
|
||||
*/
|
||||
package org.mvplugins.multiverse.core.world.configuration;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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<EntryFeeResult.Success, EntryFeeResult.Failure> 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) {
|
@ -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;
|
@ -0,0 +1 @@
|
||||
package org.mvplugins.multiverse.core.world.entrycheck;
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew.generators;
|
||||
package org.mvplugins.multiverse.core.world.generators;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -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;
|
@ -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;
|
@ -0,0 +1 @@
|
||||
package org.mvplugins.multiverse.core.world.generators;
|
@ -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.
|
@ -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;
|
@ -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 {
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew.helpers;
|
||||
package org.mvplugins.multiverse.core.world.helpers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -15,7 +15,7 @@ import org.jvnet.hk2.annotations.Service;
|
||||
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
|
||||
import org.mvplugins.multiverse.core.teleportation.TeleportResult;
|
||||
import org.mvplugins.multiverse.core.utils.result.Result;
|
||||
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.
|
@ -0,0 +1 @@
|
||||
package org.mvplugins.multiverse.core.world.helpers;
|
@ -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.
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew.options;
|
||||
package org.mvplugins.multiverse.core.world.options;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -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;
|
@ -1,4 +1,4 @@
|
||||
package org.mvplugins.multiverse.core.worldnew.options;
|
||||
package org.mvplugins.multiverse.core.world.options;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -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.
|
@ -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.
|
@ -0,0 +1 @@
|
||||
package org.mvplugins.multiverse.core.world.options;
|
@ -1,4 +1 @@
|
||||
/**
|
||||
* This package contains all the classes that are used to create and manage worlds.
|
||||
*/
|
||||
package org.mvplugins.multiverse.core.world;
|
||||
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -0,0 +1 @@
|
||||
package org.mvplugins.multiverse.core.world.reasons;
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>Utility class in helping to check the status of a world name and it's associated world folder.</p>
|
||||
*
|
||||
* <p>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.</p>
|
||||
*/
|
||||
@Service
|
||||
public class WorldNameChecker {
|
||||
|
||||
private static final Pattern WORLD_NAME_PATTERN = Pattern.compile("[a-zA-Z0-9/._-]+");
|
||||
private static final Set<String> 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
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
package org.mvplugins.multiverse.core.worldnew.config;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user