refactor!: Reorganise the entire MV

This commit is contained in:
Ben Woo 2023-02-08 16:19:33 +08:00
parent a403380375
commit 24596419e5
80 changed files with 505 additions and 529 deletions

View File

@ -19,13 +19,13 @@ import java.util.Map;
import buscript.Buscript; import buscript.Buscript;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.anchor.AnchorManager;
import com.onarandombox.MultiverseCore.api.BlockSafety; import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.Core;
import com.onarandombox.MultiverseCore.api.LocationManipulation; import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.MVPlugin; import com.onarandombox.MultiverseCore.api.MVConfig;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.commands.CheckCommand; import com.onarandombox.MultiverseCore.commands.CheckCommand;
import com.onarandombox.MultiverseCore.commands.CreateCommand; import com.onarandombox.MultiverseCore.commands.CreateCommand;
@ -39,6 +39,7 @@ import com.onarandombox.MultiverseCore.destination.core.CannonDestination;
import com.onarandombox.MultiverseCore.destination.core.ExactDestination; import com.onarandombox.MultiverseCore.destination.core.ExactDestination;
import com.onarandombox.MultiverseCore.destination.core.PlayerDestination; import com.onarandombox.MultiverseCore.destination.core.PlayerDestination;
import com.onarandombox.MultiverseCore.destination.core.WorldDestination; import com.onarandombox.MultiverseCore.destination.core.WorldDestination;
import com.onarandombox.MultiverseCore.economy.MVEconomist;
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent; import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
import com.onarandombox.MultiverseCore.listeners.MVChatListener; import com.onarandombox.MultiverseCore.listeners.MVChatListener;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener; import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
@ -47,17 +48,16 @@ import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener; import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener;
import com.onarandombox.MultiverseCore.listeners.MVWorldListener; import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager; import com.onarandombox.MultiverseCore.teleportation.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.MVEconomist; import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.MVPermissions; import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession; import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.TestingMode; import com.onarandombox.MultiverseCore.utils.TestingMode;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper; import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator; import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
import com.onarandombox.MultiverseCore.world.SimpleWorldManager;
import com.onarandombox.MultiverseCore.world.WorldProperties;
import me.main__.util.SerializationConfig.SerializationConfig; import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.configuration.Configuration; import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -69,9 +69,9 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader; import org.bukkit.plugin.java.JavaPluginLoader;
/** /**
* The implementation of the Multiverse-{@link Core}. * The implementation of the Multiverse-{@link MVCore}.
*/ */
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { public class MultiverseCore extends JavaPlugin implements MVCore {
private static final int PROTOCOL = 24; private static final int PROTOCOL = 24;
// Setup various managers // Setup various managers
@ -85,7 +85,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private final MVPermissions mvPermissions = new MVPermissions(this); private final MVPermissions mvPermissions = new MVPermissions(this);
private SafeTTeleporter safeTTeleporter = new SimpleSafeTTeleporter(this); private SafeTTeleporter safeTTeleporter = new SimpleSafeTTeleporter(this);
private final UnsafeCallWrapper unsafeCallWrapper = new UnsafeCallWrapper(this); private final UnsafeCallWrapper unsafeCallWrapper = new UnsafeCallWrapper(this);
private final MVWorldManager worldManager = new WorldManager(this); private final WorldManager worldManager = new SimpleWorldManager(this);
// Configurations // Configurations
private FileConfiguration multiverseConfig; private FileConfiguration multiverseConfig;
@ -146,7 +146,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Now set the firstspawnworld (after the worlds are loaded): // Now set the firstspawnworld (after the worlds are loaded):
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld()); this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
MultiverseWorld firstSpawnWorld = this.worldManager.getFirstSpawnWorld(); MVWorld firstSpawnWorld = this.worldManager.getFirstSpawnWorld();
if (firstSpawnWorld != null) { if (firstSpawnWorld != null) {
getMVConfig().setFirstSpawnWorld(firstSpawnWorld.getName()); getMVConfig().setFirstSpawnWorld(firstSpawnWorld.getName());
} }
@ -361,7 +361,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MVWorldManager getMVWorldManager() { public WorldManager getMVWorldManager() {
return this.worldManager; return this.worldManager;
} }
@ -497,7 +497,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MultiverseCoreConfig getMVConfig() { public MVConfig getMVConfig() {
return config; return config;
} }

View File

@ -3,7 +3,7 @@ package com.onarandombox.MultiverseCore;
import java.util.Map; import java.util.Map;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig; import com.onarandombox.MultiverseCore.api.MVConfig;
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent; import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
import me.main__.util.SerializationConfig.NoSuchPropertyException; import me.main__.util.SerializationConfig.NoSuchPropertyException;
import me.main__.util.SerializationConfig.Property; import me.main__.util.SerializationConfig.Property;
@ -13,7 +13,7 @@ import org.bukkit.Bukkit;
/** /**
* Our configuration. * Our configuration.
*/ */
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig { public class MultiverseCoreConfiguration extends SerializationConfig implements MVConfig {
private static MultiverseCoreConfiguration instance; private static MultiverseCoreConfiguration instance;
/** /**
@ -35,6 +35,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
* Gets the statically saved instance. * Gets the statically saved instance.
* @return The statically saved instance. * @return The statically saved instance.
*/ */
@Deprecated
public static MultiverseCoreConfiguration getInstance() { public static MultiverseCoreConfiguration getInstance() {
if (instance == null) if (instance == null)
throw new IllegalStateException("The instance wasn't set!"); throw new IllegalStateException("The instance wasn't set!");

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.anchor;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;

View File

@ -0,0 +1,4 @@
/**
* this package contains the classes that are used for the anchor system.
*/
package com.onarandombox.MultiverseCore.anchor;

View File

@ -10,7 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin;
/** /**
* Make things easier for MV-Plugins! * Make things easier for MV-Plugins!
*/ */
public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin { public abstract class AbstractMVPlugin extends JavaPlugin implements MVPlugin {
private MultiverseCore core; private MultiverseCore core;
/** /**

View File

@ -1,20 +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 com.onarandombox.MultiverseCore.api;
/**
* A fancy text.
*/
public interface FancyText {
/**
* Gets the {@link String}-representation of this {@link FancyText}.
*
* @return The {@link String}-representation of this {@link FancyText}.
*/
String getFancyText();
}

View File

@ -5,7 +5,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
/** /**
* The configuration of MultiverseCore. * The configuration of MultiverseCore.
*/ */
public interface MultiverseCoreConfig extends ConfigurationSerializable { public interface MVConfig extends ConfigurationSerializable {
/** /**
* Sets a property using a {@link String}. * Sets a property using a {@link String}.
* @param property The name of the property. * @param property The name of the property.

View File

@ -10,13 +10,13 @@ package com.onarandombox.MultiverseCore.api;
import buscript.Buscript; import buscript.Buscript;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.destination.DestinationsProvider; import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
import com.onarandombox.MultiverseCore.utils.AnchorManager; import com.onarandombox.MultiverseCore.anchor.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist; import com.onarandombox.MultiverseCore.economy.MVEconomist;
import com.onarandombox.MultiverseCore.utils.MVPermissions; import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession; import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety; import com.onarandombox.MultiverseCore.teleportation.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation; import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter; import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper; import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
* <p> * <p>
* This API contains a bunch of useful things you can get out of Multiverse in general! * This API contains a bunch of useful things you can get out of Multiverse in general!
*/ */
public interface Core { public interface MVCore extends MVPlugin {
/** /**
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without * Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without
* worrying about any of the messy details. * worrying about any of the messy details.
@ -85,9 +85,9 @@ public interface Core {
/** /**
* Gets the primary class responsible for managing Multiverse Worlds. * Gets the primary class responsible for managing Multiverse Worlds.
* *
* @return {@link MVWorldManager}. * @return {@link WorldManager}.
*/ */
MVWorldManager getMVWorldManager(); WorldManager getMVWorldManager();
/** /**
* Saves the Multiverse-Config. * Saves the Multiverse-Config.
@ -135,15 +135,15 @@ public interface Core {
String getAuthors(); String getAuthors();
/** /**
* Gets the {@link BlockSafety} this {@link Core} is using. * Gets the {@link BlockSafety} this {@link MVCore} is using.
* @return The {@link BlockSafety} this {@link Core} is using. * @return The {@link BlockSafety} this {@link MVCore} is using.
* @see BlockSafety * @see BlockSafety
* @see SimpleBlockSafety * @see SimpleBlockSafety
*/ */
BlockSafety getBlockSafety(); BlockSafety getBlockSafety();
/** /**
* Sets the {@link BlockSafety} this {@link Core} is using. * Sets the {@link BlockSafety} this {@link MVCore} is using.
* @param blockSafety The new {@link BlockSafety}. * @param blockSafety The new {@link BlockSafety}.
* @see BlockSafety * @see BlockSafety
* @see SimpleBlockSafety * @see SimpleBlockSafety
@ -151,15 +151,15 @@ public interface Core {
void setBlockSafety(BlockSafety blockSafety); void setBlockSafety(BlockSafety blockSafety);
/** /**
* Gets the {@link LocationManipulation} this {@link Core} is using. * Gets the {@link LocationManipulation} this {@link MVCore} is using.
* @return The {@link LocationManipulation} this {@link Core} is using. * @return The {@link LocationManipulation} this {@link MVCore} is using.
* @see LocationManipulation * @see LocationManipulation
* @see SimpleLocationManipulation * @see SimpleLocationManipulation
*/ */
LocationManipulation getLocationManipulation(); LocationManipulation getLocationManipulation();
/** /**
* Sets the {@link LocationManipulation} this {@link Core} is using. * Sets the {@link LocationManipulation} this {@link MVCore} is using.
* @param locationManipulation The new {@link LocationManipulation}. * @param locationManipulation The new {@link LocationManipulation}.
* @see LocationManipulation * @see LocationManipulation
* @see SimpleLocationManipulation * @see SimpleLocationManipulation
@ -167,15 +167,15 @@ public interface Core {
void setLocationManipulation(LocationManipulation locationManipulation); void setLocationManipulation(LocationManipulation locationManipulation);
/** /**
* Gets the {@link SafeTTeleporter} this {@link Core} is using. * Gets the {@link SafeTTeleporter} this {@link MVCore} is using.
* @return The {@link SafeTTeleporter} this {@link Core} is using. * @return The {@link SafeTTeleporter} this {@link MVCore} is using.
* @see SafeTTeleporter * @see SafeTTeleporter
* @see SimpleSafeTTeleporter * @see SimpleSafeTTeleporter
*/ */
SafeTTeleporter getSafeTTeleporter(); SafeTTeleporter getSafeTTeleporter();
/** /**
* Sets the {@link SafeTTeleporter} this {@link Core} is using. * Sets the {@link SafeTTeleporter} this {@link MVCore} is using.
* @param safeTTeleporter The new {@link SafeTTeleporter}. * @param safeTTeleporter The new {@link SafeTTeleporter}.
* @see SafeTTeleporter * @see SafeTTeleporter
* @see SimpleSafeTTeleporter * @see SimpleSafeTTeleporter
@ -183,10 +183,10 @@ public interface Core {
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter); void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
/** /**
* Gets the {@link MultiverseCoreConfig}. * Gets the {@link MVConfig}.
* @return The configuration. * @return The configuration.
*/ */
MultiverseCoreConfig getMVConfig(); MVConfig getMVConfig();
/** /**
* Gets the buscript object for Multiverse. This is what handles Javascript processing. * Gets the buscript object for Multiverse. This is what handles Javascript processing.

View File

@ -7,8 +7,12 @@
package com.onarandombox.MultiverseCore.api; package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType; import java.util.List;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException; import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.world.configuration.AddProperties;
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatColor;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Difficulty; import org.bukkit.Difficulty;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -16,16 +20,13 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List;
/** /**
* The API for a Multiverse Handled World. * The API for a Multiverse Handled World.
*/ */
public interface MultiverseWorld { public interface MVWorld {
/** /**
* Returns the Bukkit world object that this world describes. * Returns the Bukkit world object that this world describes.
* *
@ -156,9 +157,9 @@ public interface MultiverseWorld {
boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException; boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
/** /**
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}. * Adds a value to the given property. The property must be a {@link AddProperties}.
* *
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to. * @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. * @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. * @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 We changed the entire world-config-system. This is not compatible any more.
@ -167,9 +168,9 @@ public interface MultiverseWorld {
boolean addToVariable(String property, String value); boolean addToVariable(String property, String value);
/** /**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}. * Removes a value from the given property. The property must be a {@link AddProperties}.
* *
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value * @param property The name of a {@link AddProperties} to remove a value
* from. * from.
* @param value A value in string representation, it will be parsed to the correct type. * @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. * @return True if the value was removed, false if not.
@ -179,9 +180,9 @@ public interface MultiverseWorld {
boolean removeFromVariable(String property, String value); boolean removeFromVariable(String property, String value);
/** /**
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}. * Removes all values from the given property. The property must be a {@link AddProperties}.
* *
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear. * @param property The name of a {@link AddProperties} to clear.
* @return True if it was cleared, false if not. * @return True if it was cleared, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more. * @deprecated We changed the entire world-config-system. This is not compatible any more.
*/ */
@ -279,7 +280,7 @@ public interface MultiverseWorld {
* @param color A string that may translate to a color. * @param color A string that may translate to a color.
* @return True if it is a color, false if not. * @return True if it is a color, false if not.
* *
* @deprecated This has been moved: {@link com.onarandombox.MultiverseCore.enums.EnglishChatColor#isValidAliasColor(String)} * @deprecated This has been moved: {@link EnglishChatColor#isValidAliasColor(String)}
*/ */
@Deprecated @Deprecated
boolean isValidAliasColor(String color); boolean isValidAliasColor(String color);

View File

@ -1,56 +0,0 @@
package com.onarandombox.MultiverseCore.api;
import java.util.Collection;
import org.bukkit.command.CommandSender;
/**
* Multiverse-messaging.
*/
public interface MultiverseMessaging {
/**
* Sets the message-cooldown.
* @param milliseconds The new message-cooldown in milliseconds.
*/
void setCooldown(int milliseconds);
/**
* Sends a message to the specified sender if the cooldown has passed.
*
* @param sender The person/console to send the message to.
* @param message The message to send.
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
* @return true if the message was sent, false if not.
*/
boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown);
/**
* Sends a group of messages to the specified sender if the cooldown has passed.
* This method is needed, since sending many messages in quick succession would violate
* the cooldown.
*
* @param sender The person/console to send the message to.
* @param messages The messages to send.
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
* @return true if the message was sent, false if not.
*/
boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown);
/**
* Sends a group of messages to the specified sender if the cooldown has passed.
* This method is needed, since sending many messages in quick succession would violate
* the cooldown.
*
* @param sender The person/console to send the message to.
* @param messages The messages to send.
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
* @return true if the message was sent, false if not.
*/
boolean sendMessages(CommandSender sender, Collection<String> messages, boolean ignoreCooldown);
/**
* Gets the message-cooldown.
* @return The message-cooldown.
*/
int getCooldown();
}

View File

@ -2,7 +2,7 @@ package com.onarandombox.MultiverseCore.api;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.destination.ParsedDestination; import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult; import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;

View File

@ -2,7 +2,7 @@ package com.onarandombox.MultiverseCore.api;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.destination.ParsedDestination; import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult; import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
public interface Teleporter { public interface Teleporter {

View File

@ -11,7 +11,7 @@ import java.io.File;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger; import com.onarandombox.MultiverseCore.world.SimpleWorldPurger;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldType; import org.bukkit.WorldType;
@ -24,7 +24,7 @@ import org.bukkit.generator.ChunkGenerator;
* This API contains all of the world managing * This API contains all of the world managing
* functions that your heart desires! * functions that your heart desires!
*/ */
public interface MVWorldManager { public interface WorldManager {
/** /**
* Add a new World to the Multiverse Setup. * Add a new World to the Multiverse Setup.
* *
@ -147,40 +147,40 @@ public interface MVWorldManager {
/** /**
* Returns a list of all the worlds Multiverse knows about. * Returns a list of all the worlds Multiverse knows about.
* *
* @return A list of {@link MultiverseWorld}. * @return A list of {@link MVWorld}.
*/ */
Collection<MultiverseWorld> getMVWorlds(); Collection<MVWorld> getMVWorlds();
/** /**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not. * Returns a {@link MVWorld} if it exists, and null if it does not.
* This will search name AND alias. * This will search name AND alias.
* *
* @param name The name or alias of the world to get. * @param name The name or alias of the world to get.
* @return A {@link MultiverseWorld} or null. * @return A {@link MVWorld} or null.
*/ */
MultiverseWorld getMVWorld(String name); MVWorld getMVWorld(String name);
/** /**
* Returns a {@link MultiverseWorld} if the world with name given exists, and null if it does not. * Returns a {@link MVWorld} if the world with name given exists, and null if it does not.
* This will search optionally for alias names. * This will search optionally for alias names.
* *
* @param name The name or optionally the alias of the world to get. * @param name The name or optionally the alias of the world to get.
* @param checkAliases Indicates whether to check for world alias name. * @param checkAliases Indicates whether to check for world alias name.
* @return A {@link MultiverseWorld} or null. * @return A {@link MVWorld} or null.
*/ */
MultiverseWorld getMVWorld(String name, boolean checkAliases); MVWorld getMVWorld(String name, boolean checkAliases);
/** /**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not. * Returns a {@link MVWorld} if it exists, and null if it does not.
* *
* @param world The Bukkit world to check. * @param world The Bukkit world to check.
* @return A {@link MultiverseWorld} or null. * @return A {@link MVWorld} or null.
*/ */
MultiverseWorld getMVWorld(World world); MVWorld getMVWorld(World world);
/** /**
* Checks to see if the given name is a valid {@link MultiverseWorld} * Checks to see if the given name is a valid {@link MVWorld}
* Searches based on world name AND alias. * Searches based on world name AND alias.
* *
* @param name The name or alias of the world to check. * @param name The name or alias of the world to check.
@ -189,7 +189,7 @@ public interface MVWorldManager {
boolean isMVWorld(String name); boolean isMVWorld(String name);
/** /**
* Checks to see if the given name is a valid {@link MultiverseWorld}. * Checks to see if the given name is a valid {@link MVWorld}.
* Optionally searches by alias is specified. * Optionally searches by alias is specified.
* *
* @param name The name or alias of the world to check. * @param name The name or alias of the world to check.
@ -199,7 +199,7 @@ public interface MVWorldManager {
boolean isMVWorld(String name, boolean checkAliases); boolean isMVWorld(String name, boolean checkAliases);
/** /**
* Checks to see if the given world is a valid {@link MultiverseWorld}. * Checks to see if the given world is a valid {@link MVWorld}.
* *
* @param world The Bukkit world to check. * @param world The Bukkit world to check.
* @return True if the world has been loaded into MV2, false if not. * @return True if the world has been loaded into MV2, false if not.
@ -224,7 +224,7 @@ public interface MVWorldManager {
/** /**
* Gets the {@link WorldPurger}. * Gets the {@link WorldPurger}.
* <p> * <p>
* @return The {@link WorldPurger} this {@link MVWorldManager} is using. * @return The {@link WorldPurger} this {@link WorldManager} is using.
* @see WorldPurger * @see WorldPurger
* @see SimpleWorldPurger * @see SimpleWorldPurger
*/ */
@ -236,7 +236,7 @@ public interface MVWorldManager {
* *
* @return A Multiverse world that players will spawn in or null if no MV world has been set. * @return A Multiverse world that players will spawn in or null if no MV world has been set.
*/ */
MultiverseWorld getSpawnWorld(); MVWorld getSpawnWorld();
/** /**
* Gets the list of worlds in the config, but unloaded. * Gets the list of worlds in the config, but unloaded.
@ -283,9 +283,9 @@ public interface MVWorldManager {
/** /**
* Gets the world players should spawn in first. * Gets the world players should spawn in first.
* *
* @return The {@link MultiverseWorld} new players should spawn in. * @return The {@link MVWorld} new players should spawn in.
*/ */
MultiverseWorld getFirstSpawnWorld(); MVWorld getFirstSpawnWorld();
/** /**
* Regenerates a world. * Regenerates a world.

View File

@ -12,38 +12,38 @@ public interface WorldPurger {
/** /**
* Synchronizes the given worlds with their settings. * Synchronizes the given worlds with their settings.
* *
* @param worlds A list of {@link MultiverseWorld} * @param worlds A list of {@link MVWorld}
*/ */
void purgeWorlds(List<MultiverseWorld> worlds); void purgeWorlds(List<MVWorld> worlds);
/** /**
* Convenience method for {@link #purgeWorld(MultiverseWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config. * Convenience method for {@link #purgeWorld(MVWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
* *
* @param world The {@link MultiverseWorld}. * @param world The {@link MVWorld}.
*/ */
void purgeWorld(MultiverseWorld world); void purgeWorld(MVWorld world);
/** /**
* Clear all animals/monsters that do not belong to a world according to the config. * Clear all animals/monsters that do not belong to a world according to the config.
* *
* @param mvworld The {@link MultiverseWorld}. * @param mvworld The {@link MVWorld}.
* @param thingsToKill A {@link List} of animals/monsters to be killed. * @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated. * @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated. * @param negateMonsters Whether the animals in the list should be negated.
*/ */
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals, void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters); boolean negateMonsters);
/** /**
* Clear all animals/monsters that do not belong to a world according to the config. * Clear all animals/monsters that do not belong to a world according to the config.
* *
* @param mvworld The {@link MultiverseWorld}. * @param mvworld The {@link MVWorld}.
* @param thingsToKill A {@link List} of animals/monsters to be killed. * @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated. * @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals 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. * @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
*/ */
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals, void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, CommandSender sender); boolean negateMonsters, CommandSender sender);
/** /**
@ -64,5 +64,5 @@ public interface WorldPurger {
* @param e The creature. * @param e The creature.
* @return {@code true} if the creature should be killed, otherwise {@code false}. * @return {@code true} if the creature should be killed, otherwise {@code false}.
*/ */
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e); boolean shouldWeKillThisCreature(MVWorld w, Entity e);
} }

View File

@ -2,7 +2,7 @@ package com.onarandombox.MultiverseCore.commands;
import co.aikar.commands.BaseCommand; import co.aikar.commands.BaseCommand;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags; import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
public class MultiverseCommand extends BaseCommand { public class MultiverseCommand extends BaseCommand {
protected final MultiverseCore plugin; protected final MultiverseCore plugin;
protected final MVWorldManager worldManager; protected final WorldManager worldManager;
protected final CommandFlagsManager flagsManager; protected final CommandFlagsManager flagsManager;
private String flagGroupName; private String flagGroupName;

View File

@ -0,0 +1,4 @@
/**
* This package contains all the commands for Multiverse-Core.
*/
package com.onarandombox.MultiverseCore.commands;

View File

@ -8,7 +8,7 @@ import co.aikar.commands.BukkitCommandCompletionContext;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.PaperCommandCompletions; import co.aikar.commands.PaperCommandCompletions;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class MVCommandCompletions extends PaperCommandCompletions { public class MVCommandCompletions extends PaperCommandCompletions {
@ -46,7 +46,7 @@ public class MVCommandCompletions extends PaperCommandCompletions {
return this.plugin.getMVWorldManager().getMVWorlds() return this.plugin.getMVWorldManager().getMVWorlds()
.stream() .stream()
.map(MultiverseWorld::getName) .map(MVWorld::getName)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View File

@ -0,0 +1,5 @@
/**
* This package contains all the flags parsing classes.
*
*/
package com.onarandombox.MultiverseCore.commandtools.flags;

View File

@ -0,0 +1,4 @@
/**
* This package contains the classes that manages command handling.
*/
package com.onarandombox.MultiverseCore.commandtools;

View File

@ -1,4 +0,0 @@
/**
* This package contains the Multiverse-configuration.
*/
package com.onarandombox.MultiverseCore.configuration;

View File

@ -6,7 +6,7 @@ import java.util.Collections;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.Destination;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.Teleporter; import com.onarandombox.MultiverseCore.api.Teleporter;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -53,7 +53,7 @@ public class CannonDestination implements Destination<CannonDestinationInstance>
return null; return null;
} }
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName);
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -6,7 +6,7 @@ import java.util.Collections;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.Destination;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.Teleporter; import com.onarandombox.MultiverseCore.api.Teleporter;
import org.bukkit.Location; import org.bukkit.Location;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -49,7 +49,7 @@ public class ExactDestination implements Destination<ExactDestinationInstance> {
return null; return null;
} }
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName);
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -6,7 +6,7 @@ import java.util.Collections;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Destination; import com.onarandombox.MultiverseCore.api.Destination;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.Teleporter; import com.onarandombox.MultiverseCore.api.Teleporter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -43,7 +43,7 @@ public class WorldDestination implements Destination<WorldDestinationInstance> {
} }
String worldName = items[0]; String worldName = items[0];
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName);
if (world == null) { if (world == null) {
return null; return null;
} }

View File

@ -1,7 +1,7 @@
package com.onarandombox.MultiverseCore.destination.core; package com.onarandombox.MultiverseCore.destination.core;
import com.onarandombox.MultiverseCore.api.DestinationInstance; import com.onarandombox.MultiverseCore.api.DestinationInstance;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class WorldDestinationInstance implements DestinationInstance { public class WorldDestinationInstance implements DestinationInstance {
private final MultiverseWorld world; private final MVWorld world;
private final String direction; private final String direction;
private final float yaw; private final float yaw;
@ -18,7 +18,7 @@ public class WorldDestinationInstance implements DestinationInstance {
* *
* @param world The world to teleport to. * @param world The world to teleport to.
*/ */
public WorldDestinationInstance(@NotNull MultiverseWorld world, @Nullable String direction, float yaw) { public WorldDestinationInstance(@NotNull MVWorld world, @Nullable String direction, float yaw) {
this.world = world; this.world = world;
this.direction = direction; this.direction = direction;
this.yaw = yaw; this.yaw = yaw;

View File

@ -0,0 +1,4 @@
/**
* This package contains the in-built implementations of the Destination interface.
*/
package com.onarandombox.MultiverseCore.destination.core;

View File

@ -0,0 +1,4 @@
/**
* This package contains all the filters that can be used to choose specific data to display.
*/
package com.onarandombox.MultiverseCore.display.filters;

View File

@ -0,0 +1,4 @@
/**
* This package contains all the handlers for the display system.
*/
package com.onarandombox.MultiverseCore.display.handlers;

View File

@ -0,0 +1,4 @@
/**
* This package contains all the classes that are used to display nicely formatted information to the user.
*/
package com.onarandombox.MultiverseCore.display;

View File

@ -0,0 +1,4 @@
/**
* This package contains all the parsers for the display system.
*/
package com.onarandombox.MultiverseCore.display.parsers;

View File

@ -0,0 +1,82 @@
package com.onarandombox.MultiverseCore.economy;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
class ItemEconomy {
private static final String ECONOMY_NAME = "Simple Item Economy";
static String getFormattedPrice(double amount, Material currency) {
if (MVEconomist.isItemCurrency(currency)) {
return amount + " " + currency.toString();
} else {
return "";
}
}
static String getName() {
return ECONOMY_NAME;
}
static boolean hasEnough(Player player, double amount, Material currency) {
if (currency != null) {
return player.getInventory().contains(currency, (int) amount);
} else {
return true;
}
}
static void deposit(Player player, double amount, Material currency) {
if (MVEconomist.isItemCurrency(currency)) {
giveItem(player, amount, currency);
}
}
static void withdraw(Player player, double amount, Material currency) {
if (MVEconomist.isItemCurrency(currency)) {
takeItem(player, amount, currency);
}
}
static void giveItem(Player player, double amount, Material type) {
ItemStack item = new ItemStack(type, (int) amount);
player.getInventory().addItem(item);
showReceipt(player, (amount * -1), type);
}
static void takeItem(Player player, double amount, Material type) {
int removed = 0;
HashMap<Integer, ItemStack> items = (HashMap<Integer, ItemStack>) player.getInventory().all(type);
for (int i : items.keySet()) {
if (removed >= amount) {
break;
}
int diff = (int) (amount - removed);
int amt = player.getInventory().getItem(i).getAmount();
if (amt - diff > 0) {
player.getInventory().getItem(i).setAmount(amt - diff);
break;
} else {
removed += amt;
player.getInventory().clear(i);
}
}
showReceipt(player, amount, type);
}
static void showReceipt(Player player, double price, Material item) {
if (price > 0D) {
player.sendMessage(String.format("%s%s%s %s",
ChatColor.WHITE, "You have been charged", ChatColor.GREEN, getFormattedPrice(price, item)));
} else if (price < 0D) {
player.sendMessage(String.format("%s%s%s %s",
ChatColor.DARK_GREEN, getFormattedPrice((price * -1), item),
ChatColor.WHITE, "has been added to your inventory."));
}
}
}

View File

@ -1,15 +1,11 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.economy;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
/** /**
* Multiverse's Friendly Economist. This is used to deal with external economies and also item costs for stuff in MV. * Multiverse's Friendly Economist. This is used to deal with external economies and also item costs for stuff in MV.
*/ */
@ -209,77 +205,4 @@ public class MVEconomist {
return currency != null; return currency != null;
} }
private static class ItemEconomy {
private static final String ECONOMY_NAME = "Simple Item Economy";
private static String getFormattedPrice(double amount, Material currency) {
if (isItemCurrency(currency)) {
return amount + " " + currency.toString();
} else {
return "";
}
}
private static String getName() {
return ECONOMY_NAME;
}
private static boolean hasEnough(Player player, double amount, Material currency) {
if (currency != null) {
return player.getInventory().contains(currency, (int) amount);
} else {
return true;
}
}
private static void deposit(Player player, double amount, Material currency) {
if (isItemCurrency(currency)) {
giveItem(player, amount, currency);
}
}
private static void withdraw(Player player, double amount, Material currency) {
if (isItemCurrency(currency)) {
takeItem(player, amount, currency);
}
}
private static void giveItem(Player player, double amount, Material type) {
ItemStack item = new ItemStack(type, (int) amount);
player.getInventory().addItem(item);
showReceipt(player, (amount * -1), type);
}
private static void takeItem(Player player, double amount, Material type) {
int removed = 0;
HashMap<Integer, ItemStack> items = (HashMap<Integer, ItemStack>) player.getInventory().all(type);
for (int i : items.keySet()) {
if (removed >= amount) {
break;
}
int diff = (int) (amount - removed);
int amt = player.getInventory().getItem(i).getAmount();
if (amt - diff > 0) {
player.getInventory().getItem(i).setAmount(amt - diff);
break;
} else {
removed += amt;
player.getInventory().clear(i);
}
}
showReceipt(player, amount, type);
}
private static void showReceipt(Player player, double price, Material item) {
if (price > 0D) {
player.sendMessage(String.format("%s%s%s %s",
ChatColor.WHITE, "You have been charged", ChatColor.GREEN, getFormattedPrice(price, item)));
} else if (price < 0D) {
player.sendMessage(String.format("%s%s%s %s",
ChatColor.DARK_GREEN, getFormattedPrice((price * -1), item),
ChatColor.WHITE, "has been added to your inventory."));
}
}
}
} }

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.economy;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
@ -41,6 +41,24 @@ public class VaultHandler implements Listener {
return (economy != null); return (economy != null);
} }
/**
* Checks whether Vault is in use and has an economy system enabled.
*
* @return true if vault is in use and has an economy system enabled.
*/
public boolean hasEconomy() {
return economy != null;
}
/**
* Returns the Vault economy system if Vault is present and has an economy system enabled.
*
* @return The vault economy system or null if not configured.
*/
public Economy getEconomy() {
return economy;
}
/** /**
* Listens for Vault plugin events. * Listens for Vault plugin events.
*/ */
@ -60,22 +78,4 @@ public class VaultHandler implements Listener {
} }
} }
} }
/**
* Checks whether Vault is in use and has an economy system enabled.
*
* @return true if vault is in use and has an economy system enabled.
*/
public boolean hasEconomy() {
return economy != null;
}
/**
* Returns the Vault economy system if Vault is present and has an economy system enabled.
*
* @return The vault economy system or null if not configured.
*/
public Economy getEconomy() {
return economy;
}
} }

View File

@ -0,0 +1,4 @@
/**
* This package contains the economy classes to handle external economy plugins.
*/
package com.onarandombox.MultiverseCore.economy;

View File

@ -1,7 +0,0 @@
package com.onarandombox.MultiverseCore.enums;
public enum RespawnType {
BED,
ANCHOR,
OTHER
}

View File

@ -1,4 +0,0 @@
/**
* This package contains all enums.
*/
package com.onarandombox.MultiverseCore.enums;

View File

@ -3,7 +3,7 @@ package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
/** /**
@ -12,10 +12,10 @@ import org.bukkit.event.HandlerList;
public class MVWorldDeleteEvent extends Event implements Cancellable { public class MVWorldDeleteEvent extends Event implements Cancellable {
private boolean cancelled = false; private boolean cancelled = false;
private final MultiverseWorld world; private final MVWorld world;
private final boolean removeFromConfig; private final boolean removeFromConfig;
public MVWorldDeleteEvent(MultiverseWorld world, boolean removeFromConfig) { public MVWorldDeleteEvent(MVWorld world, boolean removeFromConfig) {
if (world == null) if (world == null)
throw new IllegalArgumentException("world can't be null!"); throw new IllegalArgumentException("world can't be null!");
@ -60,9 +60,9 @@ public class MVWorldDeleteEvent extends Event implements Cancellable {
/** /**
* Gets the world that's about to be deleted. * Gets the world that's about to be deleted.
* *
* @return That {@link MultiverseWorld}. * @return That {@link MVWorld}.
*/ */
public MultiverseWorld getWorld() { public MVWorld getWorld() {
return world; return world;
} }

View File

@ -7,7 +7,7 @@
package com.onarandombox.MultiverseCore.event; package com.onarandombox.MultiverseCore.event;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -24,13 +24,13 @@ import org.bukkit.event.HandlerList;
* @param <T> The type of the property that was set. * @param <T> The type of the property that was set.
*/ */
public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable { public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable {
private MultiverseWorld world; private MVWorld world;
private CommandSender changer; private CommandSender changer;
private boolean isCancelled = false; private boolean isCancelled = false;
private String name; private String name;
private T value; private T value;
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) { public MVWorldPropertyChangeEvent(MVWorld world, CommandSender changer, String name, T value) {
this.world = world; this.world = world;
this.changer = changer; this.changer = changer;
this.name = name; this.name = name;
@ -106,7 +106,7 @@ public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable
* *
* @return A valid MultiverseWorld. * @return A valid MultiverseWorld.
*/ */
public MultiverseWorld getWorld() { public MVWorld getWorld() {
return this.world; return this.world;
} }

View File

@ -1,8 +1,8 @@
package com.onarandombox.MultiverseCore.listeners; package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -14,7 +14,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
*/ */
public class MVChatListener implements Listener { public class MVChatListener implements Listener {
private final MultiverseCore plugin; private final MultiverseCore plugin;
private final MVWorldManager worldManager; private final WorldManager worldManager;
private final MVPlayerListener playerListener; private final MVPlayerListener playerListener;
public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
@ -45,7 +45,7 @@ public class MVChatListener implements Listener {
if (!this.worldManager.isMVWorld(world)) { if (!this.worldManager.isMVWorld(world)) {
return; return;
} }
MultiverseWorld mvworld = this.worldManager.getMVWorld(world); MVWorld mvworld = this.worldManager.getMVWorld(world);
if (mvworld.isHidden()) { if (mvworld.isHidden()) {
return; return;
} }

View File

@ -9,8 +9,8 @@ package com.onarandombox.MultiverseCore.listeners;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,7 +28,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
*/ */
public class MVEntityListener implements Listener { public class MVEntityListener implements Listener {
private MultiverseCore plugin; private MultiverseCore plugin;
private MVWorldManager worldManager; private WorldManager worldManager;
public MVEntityListener(MultiverseCore plugin) { public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -46,7 +46,7 @@ public class MVEntityListener implements Listener {
} }
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity(); Player p = (Player) event.getEntity();
MultiverseWorld w = this.plugin.getMVWorldManager().getMVWorld(p.getWorld().getName()); MVWorld w = this.plugin.getMVWorldManager().getMVWorld(p.getWorld().getName());
if (w != null && !w.getHunger()) { if (w != null && !w.getHunger()) {
// If the world has hunger set to false, do not let the level go down // If the world has hunger set to false, do not let the level go down
if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) { if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
@ -66,7 +66,7 @@ public class MVEntityListener implements Listener {
return; return;
} }
RegainReason reason = event.getRegainReason(); RegainReason reason = event.getRegainReason();
MultiverseWorld world = this.worldManager.getMVWorld(event.getEntity().getLocation().getWorld()); MVWorld world = this.worldManager.getMVWorld(event.getEntity().getLocation().getWorld());
if (world != null && reason == RegainReason.REGEN && !world.getAutoHeal()) { if (world != null && reason == RegainReason.REGEN && !world.getAutoHeal()) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -102,7 +102,7 @@ public class MVEntityListener implements Listener {
return; return;
} }
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName()); MVWorld mvworld = this.worldManager.getMVWorld(world.getName());
event.setCancelled(this.plugin.getMVWorldManager().getTheWorldPurger().shouldWeKillThisCreature(mvworld, event.getEntity())); event.setCancelled(this.plugin.getMVWorldManager().getTheWorldPurger().shouldWeKillThisCreature(mvworld, event.getEntity()));
} }

View File

@ -12,8 +12,8 @@ import java.util.concurrent.ConcurrentHashMap;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent; import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.PermissionTools; import com.onarandombox.MultiverseCore.utils.PermissionTools;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -37,7 +37,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
*/ */
public class MVPlayerListener implements Listener { public class MVPlayerListener implements Listener {
private final MultiverseCore plugin; private final MultiverseCore plugin;
private final MVWorldManager worldManager; private final WorldManager worldManager;
private final PermissionTools pt; private final PermissionTools pt;
private final Map<String, String> playerWorld = new ConcurrentHashMap<String, String>(); private final Map<String, String> playerWorld = new ConcurrentHashMap<String, String>();
@ -62,7 +62,7 @@ public class MVPlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void playerRespawn(PlayerRespawnEvent event) { public void playerRespawn(PlayerRespawnEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName()); MVWorld mvWorld = this.worldManager.getMVWorld(world.getName());
// If it's not a World MV manages we stop. // If it's not a World MV manages we stop.
if (mvWorld == null) { if (mvWorld == null) {
return; return;
@ -74,7 +74,7 @@ public class MVPlayerListener implements Listener {
} }
// Get the instance of the World the player should respawn at. // Get the instance of the World the player should respawn at.
MultiverseWorld respawnWorld = null; MVWorld respawnWorld = null;
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) { if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld()); respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld());
} }
@ -93,7 +93,7 @@ public class MVPlayerListener implements Listener {
} }
private Location getMostAccurateRespawnLocation(World w) { private Location getMostAccurateRespawnLocation(World w) {
MultiverseWorld mvw = this.worldManager.getMVWorld(w.getName()); MVWorld mvw = this.worldManager.getMVWorld(w.getName());
if (mvw != null) { if (mvw != null) {
return mvw.getSpawnLocation(); return mvw.getSpawnLocation();
} }
@ -172,8 +172,8 @@ public class MVPlayerListener implements Listener {
} }
Logging.finer("Inferred sender '" + teleporter + "' from name '" Logging.finer("Inferred sender '" + teleporter + "' from name '"
+ teleporterName + "', fetched from name '" + teleportee.getName() + "'"); + teleporterName + "', fetched from name '" + teleportee.getName() + "'");
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName()); MVWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName()); MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (toWorld == null) { if (toWorld == null) {
Logging.fine("Player '" + teleportee.getName() + "' is teleporting to world '" Logging.fine("Player '" + teleportee.getName() + "' is teleporting to world '"
+ event.getTo().getWorld().getName() + "' which is not managed by Multiverse-Core. No further " + event.getTo().getWorld().getName() + "' which is not managed by Multiverse-Core. No further "
@ -276,8 +276,8 @@ public class MVPlayerListener implements Listener {
if (event.getTo() == null) { if (event.getTo() == null) {
return; return;
} }
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName()); MVWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName()); MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) { if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// The player is Portaling to the same world. // The player is Portaling to the same world.
Logging.finer("Player '" + event.getPlayer().getName() + "' is portaling to the same world."); Logging.finer("Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
@ -321,7 +321,7 @@ public class MVPlayerListener implements Listener {
// FOLLOWING 2 Methods and Private class handle Per Player GameModes. // FOLLOWING 2 Methods and Private class handle Per Player GameModes.
private void handleGameModeAndFlight(Player player, World world) { private void handleGameModeAndFlight(Player player, World world) {
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName()); MVWorld mvWorld = this.worldManager.getMVWorld(world.getName());
if (mvWorld != null) { if (mvWorld != null) {
this.handleGameModeAndFlight(player, mvWorld); this.handleGameModeAndFlight(player, mvWorld);
} else { } else {
@ -335,7 +335,7 @@ public class MVPlayerListener implements Listener {
* @param player The {@link Player}. * @param player The {@link Player}.
* @param world The world the player is in. * @param world The world the player is in.
*/ */
public void handleGameModeAndFlight(final Player player, final MultiverseWorld world) { public void handleGameModeAndFlight(final Player player, final MVWorld world) {
// We perform this task one tick later to MAKE SURE that the player actually reaches the // We perform this task one tick later to MAKE SURE that the player actually reaches the
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere. // destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,

View File

@ -9,7 +9,7 @@ package com.onarandombox.MultiverseCore.listeners;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.PortalType; import org.bukkit.PortalType;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -38,7 +38,7 @@ public class MVPortalListener implements Listener {
public void portalForm(PortalCreateEvent event) { public void portalForm(PortalCreateEvent event) {
Logging.fine("Attempting to create portal at '%s' with reason: %s", event.getWorld().getName(), event.getReason()); Logging.fine("Attempting to create portal at '%s' with reason: %s", event.getWorld().getName(), event.getReason());
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld()); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld());
if (world == null) { if (world == null) {
Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PortalCreateEvent.", event.getWorld().getName()); Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PortalCreateEvent.", event.getWorld().getName());
return; return;
@ -94,7 +94,7 @@ public class MVPortalListener implements Listener {
return; return;
} }
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld()); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld());
if (world == null) { if (world == null) {
Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PlayerInteractEvent.", Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PlayerInteractEvent.",
event.getPlayer().getWorld().getName()); event.getPlayer().getWorld().getName());

View File

@ -8,7 +8,7 @@
package com.onarandombox.MultiverseCore.listeners; package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.weather.ThunderChangeEvent; import org.bukkit.event.weather.ThunderChangeEvent;
@ -33,7 +33,7 @@ public class MVWeatherListener implements Listener {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName()); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
if (world != null) { if (world != null) {
// If it's going to start raining and we have weather disabled // If it's going to start raining and we have weather disabled
event.setCancelled((event.toWeatherState() && !world.isWeatherEnabled())); event.setCancelled((event.toWeatherState() && !world.isWeatherEnabled()));
@ -49,7 +49,7 @@ public class MVWeatherListener implements Listener {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName()); MVWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
if (world != null) { if (world != null) {
// If it's going to start raining and we have weather disabled // If it's going to start raining and we have weather disabled
event.setCancelled((event.toThunderState() && !world.isWeatherEnabled())); event.setCancelled((event.toThunderState() && !world.isWeatherEnabled()));

View File

@ -8,8 +8,8 @@
package com.onarandombox.MultiverseCore.listeners; package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -21,7 +21,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
*/ */
public class MVWorldListener implements Listener { public class MVWorldListener implements Listener {
private MultiverseCore plugin; private MultiverseCore plugin;
private MVWorldManager worldManager; private WorldManager worldManager;
public MVWorldListener(MultiverseCore plugin) { public MVWorldListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -56,7 +56,7 @@ public class MVWorldListener implements Listener {
if (this.plugin.getMVWorldManager().getUnloadedWorlds().contains(world.getName())) { if (this.plugin.getMVWorldManager().getUnloadedWorlds().contains(world.getName())) {
this.plugin.getMVWorldManager().loadWorld(world.getName()); this.plugin.getMVWorldManager().loadWorld(world.getName());
} }
MultiverseWorld mvWorld = plugin.getMVWorldManager().getMVWorld(world); MVWorld mvWorld = plugin.getMVWorldManager().getMVWorld(world);
if (mvWorld != null) { if (mvWorld != null) {
// This is where we can temporarily fix those pesky property issues! // This is where we can temporarily fix those pesky property issues!
world.setPVP(mvWorld.isPVPEnabled()); world.setPVP(mvWorld.isPVPEnabled());

View File

@ -0,0 +1,4 @@
/**
* This package contains all the locale reference for Multiverse-Core.
*/
package com.onarandombox.MultiverseCore.locale;

View File

@ -5,11 +5,11 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.teleportation;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.BlockSafety; import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.Core; import com.onarandombox.MultiverseCore.api.MVCore;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -27,7 +27,7 @@ import java.util.Set;
* The default-implementation of {@link BlockSafety}. * The default-implementation of {@link BlockSafety}.
*/ */
public class SimpleBlockSafety implements BlockSafety { public class SimpleBlockSafety implements BlockSafety {
private final Core plugin; private final MVCore plugin;
private static final Set<BlockFace> AROUND_BLOCK = EnumSet.noneOf(BlockFace.class); private static final Set<BlockFace> AROUND_BLOCK = EnumSet.noneOf(BlockFace.class);
static { static {
@ -41,7 +41,7 @@ public class SimpleBlockSafety implements BlockSafety {
AROUND_BLOCK.add(BlockFace.NORTH_WEST); AROUND_BLOCK.add(BlockFace.NORTH_WEST);
} }
public SimpleBlockSafety(Core plugin) { public SimpleBlockSafety(MVCore plugin) {
this.plugin = plugin; this.plugin = plugin;
} }

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.teleportation;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.teleportation;
import co.aikar.commands.BukkitCommandIssuer; import co.aikar.commands.BukkitCommandIssuer;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
@ -13,7 +13,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.DestinationInstance; import com.onarandombox.MultiverseCore.api.DestinationInstance;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.ParsedDestination; import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.enums; package com.onarandombox.MultiverseCore.teleportation;
/** /**
* An enum containing possible teleport-results. * An enum containing possible teleport-results.

View File

@ -0,0 +1,4 @@
/**
* This package contains all the teleportation and location safety related classes.
*/
package com.onarandombox.MultiverseCore.teleportation;

View File

@ -12,8 +12,8 @@ import java.util.List;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination; import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -27,7 +27,7 @@ import org.bukkit.permissions.PermissionDefault;
public class MVPermissions { public class MVPermissions {
private MultiverseCore plugin; private MultiverseCore plugin;
private MVWorldManager worldMgr; private WorldManager worldMgr;
public MVPermissions(MultiverseCore plugin) { public MVPermissions(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -39,10 +39,10 @@ public class MVPermissions {
* Check if a Player can ignore GameMode restrictions for world they travel to. * Check if a Player can ignore GameMode restrictions for world they travel to.
* *
* @param p The {@link Player} to check. * @param p The {@link Player} to check.
* @param w The {@link MultiverseWorld} the player wants to teleport to. * @param w The {@link MVWorld} the player wants to teleport to.
* @return True if they should bypass restrictions. * @return True if they should bypass restrictions.
*/ */
public boolean canIgnoreGameModeRestriction(Player p, MultiverseWorld w) { public boolean canIgnoreGameModeRestriction(Player p, MVWorld w) {
return p.hasPermission("mv.bypass.gamemode." + w.getName()); return p.hasPermission("mv.bypass.gamemode." + w.getName());
} }
@ -50,10 +50,10 @@ public class MVPermissions {
* Check if a Player can teleport to the Destination world from there current world. * Check if a Player can teleport to the Destination world from there current world.
* *
* @param p The {@link Player} to check. * @param p The {@link Player} to check.
* @param w The {@link MultiverseWorld} the player wants to teleport to. * @param w The {@link MVWorld} the player wants to teleport to.
* @return Whether the player can teleport to the given {@link MultiverseWorld}. * @return Whether the player can teleport to the given {@link MVWorld}.
*/ */
public boolean canTravelFromWorld(Player p, MultiverseWorld w) { public boolean canTravelFromWorld(Player p, MVWorld w) {
List<String> blackList = w.getWorldBlacklist(); List<String> blackList = w.getWorldBlacklist();
boolean returnValue = true; boolean returnValue = true;
@ -93,10 +93,10 @@ public class MVPermissions {
* Check if the Player has the permissions to enter this world. * Check if the Player has the permissions to enter this world.
* *
* @param p The {@link Player} player that wants to enter * @param p The {@link Player} player that wants to enter
* @param w The {@link MultiverseWorld} he wants to enter * @param w The {@link MVWorld} he wants to enter
* @return Whether he has the permission to enter the world * @return Whether he has the permission to enter the world
*/ */
public boolean canEnterWorld(Player p, MultiverseWorld w) { public boolean canEnterWorld(Player p, MVWorld w) {
// If we're not enforcing access, anyone can enter. // If we're not enforcing access, anyone can enter.
if (!plugin.getMVConfig().getEnforceAccess()) { if (!plugin.getMVConfig().getEnforceAccess()) {
Logging.finest("EnforceAccess is OFF. Player was allowed in " + w.getAlias()); Logging.finest("EnforceAccess is OFF. Player was allowed in " + w.getAlias());

View File

@ -7,11 +7,11 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import org.bukkit.entity.Player;
import java.util.Date; import java.util.Date;
import com.onarandombox.MultiverseCore.api.MVConfig;
import org.bukkit.entity.Player;
/** /**
* A player-session. * A player-session.
*/ */
@ -22,9 +22,9 @@ public class MVPlayerSession {
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation. private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
private long messageLast = 0L; // Timestamp for the Players last Alert Message. private long messageLast = 0L; // Timestamp for the Players last Alert Message.
private MultiverseCoreConfig config; // Configuration file to find out Cooldown Timers. private MVConfig config; // Configuration file to find out Cooldown Timers.
public MVPlayerSession(Player player, MultiverseCoreConfig config) { public MVPlayerSession(Player player, MVConfig config) {
this.player = player; this.player = player;
this.config = config; this.config = config;
// this.bedSpawn = null; // this.bedSpawn = null;

View File

@ -9,15 +9,14 @@ package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.economy.MVEconomist;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import java.util.logging.Level;
/** /**
* Utility-class for permissions. * Utility-class for permissions.
*/ */
@ -92,15 +91,15 @@ public class PermissionTools {
} }
/** /**
* Checks if the given {@link Player} has enough money to enter the specified {@link MultiverseWorld}. * Checks if the given {@link Player} has enough money to enter the specified {@link MVWorld}.
* @param fromWorld The {@link MultiverseWorld} the player is coming from. * @param fromWorld The {@link MVWorld} the player is coming from.
* @param toWorld The {@link MultiverseWorld} the player is going to. * @param toWorld The {@link MVWorld} the player is going to.
* @param teleporter The teleporter. * @param teleporter The teleporter.
* @param teleportee The teleportee. * @param teleportee The teleportee.
* @param pay If the player has to pay the money. * @param pay If the player has to pay the money.
* @return True if the player can enter the world. * @return True if the player can enter the world.
*/ */
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) { public boolean playerHasMoneyToEnter(MVWorld fromWorld, MVWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) {
Player teleporterPlayer; Player teleporterPlayer;
if (plugin.getMVConfig().getTeleportIntercept()) { if (plugin.getMVConfig().getTeleportIntercept()) {
if (teleporter instanceof ConsoleCommandSender) { if (teleporter instanceof ConsoleCommandSender) {
@ -195,7 +194,7 @@ public class PermissionTools {
* @param teleportee The player going somewhere. * @param teleportee The player going somewhere.
* @return True if they can't go to the world, False if they can. * @return True if they can't go to the world, False if they can.
*/ */
public boolean playerCanGoFromTo(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) { public boolean playerCanGoFromTo(MVWorld fromWorld, MVWorld toWorld, CommandSender teleporter, Player teleportee) {
Logging.finest("Checking '" + teleporter + "' can send '" + teleportee + "' somewhere"); Logging.finest("Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
Player teleporterPlayer; Player teleporterPlayer;
@ -266,7 +265,7 @@ public class PermissionTools {
* @param teleportee The player travelling. * @param teleportee The player travelling.
* @return True if they can bypass the player limit. * @return True if they can bypass the player limit.
*/ */
public boolean playerCanBypassPlayerLimit(MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) { public boolean playerCanBypassPlayerLimit(MVWorld toWorld, CommandSender teleporter, Player teleportee) {
if (teleporter == null) { if (teleporter == null) {
teleporter = teleportee; teleporter = teleportee;
} }
@ -291,7 +290,7 @@ public class PermissionTools {
* @param teleportee player travelling. * @param teleportee player travelling.
* @return True if they should bypass restrictions * @return True if they should bypass restrictions
*/ */
public boolean playerCanIgnoreGameModeRestriction(MultiverseWorld toWorld, Player teleportee) { public boolean playerCanIgnoreGameModeRestriction(MVWorld toWorld, Player teleportee) {
if (toWorld != null) { if (toWorld != null) {
return this.plugin.getMVPerms().canIgnoreGameModeRestriction(teleportee, toWorld); return this.plugin.getMVPerms().canIgnoreGameModeRestriction(teleportee, toWorld);
} else { } else {

View File

@ -1,7 +1,7 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.Core; import com.onarandombox.MultiverseCore.api.MVCore;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -9,9 +9,9 @@ import java.util.concurrent.Callable;
* Wraps calls that could result in exceptions that are not Multiverse's fault. * Wraps calls that could result in exceptions that are not Multiverse's fault.
*/ */
public class UnsafeCallWrapper { public class UnsafeCallWrapper {
private final Core core; private final MVCore core;
public UnsafeCallWrapper(Core core) { public UnsafeCallWrapper(MVCore core) {
this.core = core; this.core = core;
} }

View File

@ -6,8 +6,8 @@ import java.util.function.Consumer;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.World; import org.bukkit.World;
@ -30,11 +30,11 @@ public class MetricsConfigurator {
this.metrics = new Metrics(plugin, PLUGIN_ID); this.metrics = new Metrics(plugin, PLUGIN_ID);
} }
private MVWorldManager getWorldManager() { private WorldManager getWorldManager() {
return plugin.getMVWorldManager(); return plugin.getMVWorldManager();
} }
private Collection<MultiverseWorld> getMVWorlds() { private Collection<MVWorld> getMVWorlds() {
return getWorldManager().getMVWorlds(); return getWorldManager().getMVWorlds();
} }
@ -53,20 +53,20 @@ public class MetricsConfigurator {
private void addCustomGeneratorsMetric() { private void addCustomGeneratorsMetric() {
addAdvancedPieMetric("custom_generators", map -> { addAdvancedPieMetric("custom_generators", map -> {
for (MultiverseWorld w : getMVWorlds()) { for (MVWorld w : getMVWorlds()) {
MetricsHelper.incrementCount(map, getGeneratorName(w)); MetricsHelper.incrementCount(map, getGeneratorName(w));
} }
}); });
} }
private String getGeneratorName(MultiverseWorld world) { private String getGeneratorName(MVWorld world) {
String gen = world.getGenerator(); String gen = world.getGenerator();
return (gen != null && !gen.equalsIgnoreCase("null")) ? gen.split(":")[0] : NO_GENERATOR_NAME; return (gen != null && !gen.equalsIgnoreCase("null")) ? gen.split(":")[0] : NO_GENERATOR_NAME;
} }
private void addEnvironmentsMetric() { private void addEnvironmentsMetric() {
addAdvancedPieMetric("environments", map -> { addAdvancedPieMetric("environments", map -> {
for (MultiverseWorld w : getMVWorlds()) { for (MVWorld w : getMVWorlds()) {
MetricsHelper.incrementCount(map, titleCaseEnv(w.getEnvironment())); MetricsHelper.incrementCount(map, titleCaseEnv(w.getEnvironment()));
} }
}); });

View File

@ -0,0 +1,4 @@
/**
* This package contains the Metrics class, which is used to collect anonymous data for bstats
*/
package com.onarandombox.MultiverseCore.utils.metrics;

View File

@ -5,18 +5,25 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore.world;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
import com.onarandombox.MultiverseCore.api.BlockSafety; import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
import com.onarandombox.MultiverseCore.configuration.SpawnSettings;
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException; import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatColor;
import com.onarandombox.MultiverseCore.world.configuration.SpawnLocation;
import com.onarandombox.MultiverseCore.world.configuration.SpawnSettings;
import com.onarandombox.MultiverseCore.world.configuration.WorldPropertyValidator;
import me.main__.util.SerializationConfig.ChangeDeniedException; import me.main__.util.SerializationConfig.ChangeDeniedException;
import me.main__.util.SerializationConfig.NoSuchPropertyException; import me.main__.util.SerializationConfig.NoSuchPropertyException;
import me.main__.util.SerializationConfig.VirtualProperty; import me.main__.util.SerializationConfig.VirtualProperty;
@ -28,7 +35,6 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
@ -37,16 +43,10 @@ import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
/** /**
* The implementation of a Multiverse handled world. * The implementation of a Multiverse handled world.
*/ */
public class MVWorld implements MultiverseWorld { public class SimpleMVWorld implements MVWorld {
private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16; private static final int SPAWN_LOCATION_SEARCH_TOLERANCE = 16;
private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16; private static final int SPAWN_LOCATION_SEARCH_RADIUS = 16;
@ -55,14 +55,14 @@ public class MVWorld implements MultiverseWorld {
private final UUID worldUID; private final UUID worldUID;
private final WorldProperties props; private final WorldProperties props;
public MVWorld(MultiverseCore plugin, World world, WorldProperties properties) { public SimpleMVWorld(MultiverseCore plugin, World world, WorldProperties properties) {
this(plugin, world, properties, true); this(plugin, world, properties, true);
} }
/* /*
* We have to use setCBWorld(), setPlugin() and initPerms() to prepare this object for use. * We have to use setCBWorld(), setPlugin() and initPerms() to prepare this object for use.
*/ */
public MVWorld(MultiverseCore plugin, World world, WorldProperties properties, boolean fixSpawn) { public SimpleMVWorld(MultiverseCore plugin, World world, WorldProperties properties, boolean fixSpawn) {
this.plugin = plugin; this.plugin = plugin;
this.name = world.getName(); this.name = world.getName();
this.worldUID = world.getUID(); this.worldUID = world.getUID();
@ -212,7 +212,7 @@ public class MVWorld implements MultiverseWorld {
private final class ScalePropertyValidator extends WorldPropertyValidator<Double> { private final class ScalePropertyValidator extends WorldPropertyValidator<Double> {
@Override @Override
public Double validateChange(String property, Double newValue, Double oldValue, public Double validateChange(String property, Double newValue, Double oldValue,
MVWorld object) throws ChangeDeniedException { SimpleMVWorld object) throws ChangeDeniedException {
if (newValue <= 0) { if (newValue <= 0) {
Logging.fine("Someone tried to set a scale <= 0, aborting!"); Logging.fine("Someone tried to set a scale <= 0, aborting!");
throw new ChangeDeniedException(); throw new ChangeDeniedException();
@ -227,7 +227,7 @@ public class MVWorld implements MultiverseWorld {
private final class RespawnWorldPropertyValidator extends WorldPropertyValidator<String> { private final class RespawnWorldPropertyValidator extends WorldPropertyValidator<String> {
@Override @Override
public String validateChange(String property, String newValue, String oldValue, public String validateChange(String property, String newValue, String oldValue,
MVWorld object) throws ChangeDeniedException { SimpleMVWorld object) throws ChangeDeniedException {
if (!newValue.isEmpty() && !plugin.getMVWorldManager().isMVWorld(newValue)) if (!newValue.isEmpty() && !plugin.getMVWorldManager().isMVWorld(newValue))
throw new ChangeDeniedException(); throw new ChangeDeniedException();
return super.validateChange(property, newValue, oldValue, object); return super.validateChange(property, newValue, oldValue, object);
@ -242,7 +242,7 @@ public class MVWorld implements MultiverseWorld {
private final class AllowWeatherPropertyValidator extends WorldPropertyValidator<Boolean> { private final class AllowWeatherPropertyValidator extends WorldPropertyValidator<Boolean> {
@Override @Override
public Boolean validateChange(String property, Boolean newValue, Boolean oldValue, public Boolean validateChange(String property, Boolean newValue, Boolean oldValue,
MVWorld object) throws ChangeDeniedException { SimpleMVWorld object) throws ChangeDeniedException {
if (!newValue) { if (!newValue) {
final World world = getCBWorld(); final World world = getCBWorld();
if (world != null) { if (world != null) {
@ -260,7 +260,7 @@ public class MVWorld implements MultiverseWorld {
private final class SpawningPropertyValidator extends WorldPropertyValidator<SpawnSettings> { private final class SpawningPropertyValidator extends WorldPropertyValidator<SpawnSettings> {
@Override @Override
public SpawnSettings validateChange(String property, SpawnSettings newValue, SpawnSettings oldValue, public SpawnSettings validateChange(String property, SpawnSettings newValue, SpawnSettings oldValue,
MVWorld object) throws ChangeDeniedException { SimpleMVWorld object) throws ChangeDeniedException {
boolean allowMonsters, allowAnimals; boolean allowMonsters, allowAnimals;
if (getAnimalList().isEmpty()) { if (getAnimalList().isEmpty()) {
allowAnimals = canAnimalsSpawn(); allowAnimals = canAnimalsSpawn();
@ -274,16 +274,16 @@ public class MVWorld implements MultiverseWorld {
} }
final World world = getCBWorld(); final World world = getCBWorld();
if (world != null) { if (world != null) {
if (MVWorld.this.props.getAnimalSpawnRate() != -1) { if (SimpleMVWorld.this.props.getAnimalSpawnRate() != -1) {
world.setTicksPerAnimalSpawns(MVWorld.this.props.getAnimalSpawnRate()); world.setTicksPerAnimalSpawns(SimpleMVWorld.this.props.getAnimalSpawnRate());
} }
if (MVWorld.this.props.getMonsterSpawnRate() != -1) { if (SimpleMVWorld.this.props.getMonsterSpawnRate() != -1) {
world.setTicksPerMonsterSpawns(MVWorld.this.props.getMonsterSpawnRate()); world.setTicksPerMonsterSpawns(SimpleMVWorld.this.props.getMonsterSpawnRate());
} }
world.setSpawnFlags(allowMonsters, allowAnimals); world.setSpawnFlags(allowMonsters, allowAnimals);
} }
if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) { if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) {
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(MVWorld.this); plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(SimpleMVWorld.this);
} }
return super.validateChange(property, newValue, oldValue, object); return super.validateChange(property, newValue, oldValue, object);
} }
@ -295,11 +295,11 @@ public class MVWorld implements MultiverseWorld {
private final class GameModePropertyValidator extends WorldPropertyValidator<GameMode> { private final class GameModePropertyValidator extends WorldPropertyValidator<GameMode> {
@Override @Override
public GameMode validateChange(String property, GameMode newValue, GameMode oldValue, public GameMode validateChange(String property, GameMode newValue, GameMode oldValue,
MVWorld object) throws ChangeDeniedException { SimpleMVWorld object) throws ChangeDeniedException {
for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) { for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) {
Logging.finer(String.format("Setting %s's GameMode to %s", Logging.finer(String.format("Setting %s's GameMode to %s",
p.getName(), newValue.toString())); p.getName(), newValue.toString()));
plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this); plugin.getPlayerListener().handleGameModeAndFlight(p, SimpleMVWorld.this);
} }
return super.validateChange(property, newValue, oldValue, object); return super.validateChange(property, newValue, oldValue, object);
} }
@ -311,7 +311,7 @@ public class MVWorld implements MultiverseWorld {
private final class SpawnLocationPropertyValidator extends WorldPropertyValidator<Location> { private final class SpawnLocationPropertyValidator extends WorldPropertyValidator<Location> {
@Override @Override
public Location validateChange(String property, Location newValue, Location oldValue, public Location validateChange(String property, Location newValue, Location oldValue,
MVWorld object) throws ChangeDeniedException { SimpleMVWorld object) throws ChangeDeniedException {
if (newValue == null) if (newValue == null)
throw new ChangeDeniedException(); throw new ChangeDeniedException();
if (props.getAdjustSpawn()) { if (props.getAdjustSpawn()) {
@ -484,10 +484,10 @@ public class MVWorld implements MultiverseWorld {
} }
/** /**
* Copies all properties from another {@link MVWorld} object. * Copies all properties from another {@link SimpleMVWorld} object.
* @param other The other world object. * @param other The other world object.
*/ */
public void copyValues(MVWorld other) { public void copyValues(SimpleMVWorld other) {
props.copyValues(other.props); props.copyValues(other.props);
} }

View File

@ -5,33 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.world;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
import com.onarandombox.MultiverseCore.WorldProperties;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
@ -48,25 +22,49 @@ import java.util.Set;
import java.util.Stack; import java.util.Stack;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
import com.onarandombox.MultiverseCore.utils.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
/** /**
* Public facing API to add/remove Multiverse worlds. * Public facing API to add/remove Multiverse worlds.
*/ */
public class WorldManager implements MVWorldManager { public class SimpleWorldManager implements WorldManager {
private final MultiverseCore plugin; private final MultiverseCore plugin;
private final WorldPurger worldPurger; private final WorldPurger worldPurger;
private final Map<String, MultiverseWorld> worlds; private final Map<String, MVWorld> worlds;
private Map<String, WorldProperties> worldsFromTheConfig; private Map<String, WorldProperties> worldsFromTheConfig;
private FileConfiguration configWorlds = null; private FileConfiguration configWorlds = null;
private Map<String, String> defaultGens; private Map<String, String> defaultGens;
private String firstSpawn; private String firstSpawn;
public WorldManager(MultiverseCore core) { public SimpleWorldManager(MultiverseCore core) {
this.plugin = core; this.plugin = core;
this.worldsFromTheConfig = new HashMap<String, WorldProperties>(); this.worldsFromTheConfig = new HashMap<String, WorldProperties>();
this.worlds = new ConcurrentHashMap<String, MultiverseWorld>(); this.worlds = new ConcurrentHashMap<String, MVWorld>();
this.worldPurger = new SimpleWorldPurger(plugin); this.worldPurger = new SimpleWorldPurger(plugin);
} }
@ -152,7 +150,7 @@ public class WorldManager implements MVWorldManager {
} }
// Grab a bit of metadata from the old world. // Grab a bit of metadata from the old world.
MultiverseWorld oldWorld = getMVWorld(oldName); MVWorld oldWorld = getMVWorld(oldName);
// Don't need the loaded world anymore. // Don't need the loaded world anymore.
if (wasJustLoaded) { if (wasJustLoaded) {
@ -345,8 +343,8 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MultiverseWorld getFirstSpawnWorld() { public MVWorld getFirstSpawnWorld() {
MultiverseWorld world = this.getMVWorld(this.firstSpawn); MVWorld world = this.getMVWorld(this.firstSpawn);
if (world == null) { if (world == null) {
// If the spawn world was unloaded, get the default world // If the spawn world was unloaded, get the default world
Logging.warning("The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!"); Logging.warning("The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
@ -483,7 +481,7 @@ public class WorldManager implements MVWorldManager {
nullWorld(worldName); nullWorld(worldName);
return false; return false;
} }
MVWorld world = new MVWorld(plugin, cbworld, mvworld); SimpleMVWorld world = new SimpleMVWorld(plugin, cbworld, mvworld);
if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) { if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) {
this.worldPurger.purgeWorld(world); this.worldPurger.purgeWorld(world);
} }
@ -598,7 +596,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public Collection<MultiverseWorld> getMVWorlds() { public Collection<MVWorld> getMVWorlds() {
return this.worlds.values(); return this.worlds.values();
} }
@ -606,7 +604,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MultiverseWorld getMVWorld(String name) { public MVWorld getMVWorld(String name) {
return this.getMVWorld(name, true); return this.getMVWorld(name, true);
} }
@ -614,11 +612,11 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MultiverseWorld getMVWorld(String name, boolean checkAliases) { public MVWorld getMVWorld(String name, boolean checkAliases) {
if (name == null) { if (name == null) {
return null; return null;
} }
MultiverseWorld world = this.worlds.get(name); MVWorld world = this.worlds.get(name);
if (world != null) { if (world != null) {
return world; return world;
} }
@ -629,7 +627,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MultiverseWorld getMVWorld(World world) { public MVWorld getMVWorld(World world) {
if (world != null) { if (world != null) {
return this.getMVWorld(world.getName(), false); return this.getMVWorld(world.getName(), false);
} }
@ -637,13 +635,13 @@ public class WorldManager implements MVWorldManager {
} }
/** /**
* Returns a {@link MVWorld} if it exists, and null if it does not. This will search ONLY alias. * Returns a {@link SimpleMVWorld} if it exists, and null if it does not. This will search ONLY alias.
* *
* @param alias The alias of the world to get. * @param alias The alias of the world to get.
* @return A {@link MVWorld} or null. * @return A {@link SimpleMVWorld} or null.
*/ */
private MultiverseWorld getMVWorldByAlias(String alias) { private MVWorld getMVWorldByAlias(String alias) {
for (MultiverseWorld w : this.worlds.values()) { for (MVWorld w : this.worlds.values()) {
if (w.getAlias().equalsIgnoreCase(alias)) { if (w.getAlias().equalsIgnoreCase(alias)) {
return w; return w;
} }
@ -682,7 +680,7 @@ public class WorldManager implements MVWorldManager {
* @return True if the world exists, false if not. * @return True if the world exists, false if not.
*/ */
private boolean isMVWorldAlias(final String alias) { private boolean isMVWorldAlias(final String alias) {
for (MultiverseWorld w : this.worlds.values()) { for (MVWorld w : this.worlds.values()) {
if (w.getAlias().equalsIgnoreCase(alias)) { if (w.getAlias().equalsIgnoreCase(alias)) {
return true; return true;
} }
@ -731,7 +729,7 @@ public class WorldManager implements MVWorldManager {
// Remove all world permissions. // Remove all world permissions.
Permission allAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*"); Permission allAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
Permission allExempt = this.plugin.getServer().getPluginManager().getPermission("multiverse.exempt.*"); Permission allExempt = this.plugin.getServer().getPluginManager().getPermission("multiverse.exempt.*");
for (MultiverseWorld w : this.worlds.values()) { for (MVWorld w : this.worlds.values()) {
// Remove this world from the master list // Remove this world from the master list
if (allAccess != null) { if (allAccess != null) {
allAccess.getChildren().remove(w.getAccessPermission().getName()); allAccess.getChildren().remove(w.getAccessPermission().getName());
@ -816,7 +814,7 @@ public class WorldManager implements MVWorldManager {
if (this.worldsFromTheConfig.containsKey(worldName)) { if (this.worldsFromTheConfig.containsKey(worldName)) {
// Object-Recycling :D // Object-Recycling :D
// TODO Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM) // TODO Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM)
MVWorld mvWorld = (MVWorld) this.worlds.get(worldName); SimpleMVWorld mvWorld = (SimpleMVWorld) this.worlds.get(worldName);
if (mvWorld != null) { if (mvWorld != null) {
mvWorld.copyValues((WorldProperties) obj); mvWorld.copyValues((WorldProperties) obj);
} }
@ -858,7 +856,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public MultiverseWorld getSpawnWorld() { public MVWorld getSpawnWorld() {
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0)); return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
} }
@ -885,7 +883,7 @@ public class WorldManager implements MVWorldManager {
*/ */
@Override @Override
public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules) { public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed, boolean keepGameRules) {
MultiverseWorld world = this.getMVWorld(name); MVWorld world = this.getMVWorld(name);
if (world == null) { if (world == null) {
Logging.warning("Unable to regen a world that does not exist!"); Logging.warning("Unable to regen a world that does not exist!");
return false; return false;
@ -970,8 +968,8 @@ public class WorldManager implements MVWorldManager {
} }
/** /**
* Gets the {@link FileConfiguration} that this {@link WorldManager} is using. * Gets the {@link FileConfiguration} that this {@link SimpleWorldManager} is using.
* @return The {@link FileConfiguration} that this {@link WorldManager} is using. * @return The {@link FileConfiguration} that this {@link SimpleWorldManager} is using.
*/ */
public FileConfiguration getConfigWorlds() { public FileConfiguration getConfigWorlds() {
return this.configWorlds; return this.configWorlds;

View File

@ -5,11 +5,11 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.world;
import com.dumptruckman.minecraft.util.Logging; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.WorldPurger; import com.onarandombox.MultiverseCore.api.WorldPurger;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -52,11 +52,11 @@ public class SimpleWorldPurger implements WorldPurger {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void purgeWorlds(List<MultiverseWorld> worlds) { public void purgeWorlds(List<MVWorld> worlds) {
if (worlds == null || worlds.isEmpty()) { if (worlds == null || worlds.isEmpty()) {
return; return;
} }
for (MultiverseWorld world : worlds) { for (MVWorld world : worlds) {
this.purgeWorld(world); this.purgeWorld(world);
} }
} }
@ -65,7 +65,7 @@ public class SimpleWorldPurger implements WorldPurger {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void purgeWorld(MultiverseWorld world) { public void purgeWorld(MVWorld world) {
if (world == null) { if (world == null) {
return; return;
} }
@ -78,7 +78,7 @@ public class SimpleWorldPurger implements WorldPurger {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean shouldWeKillThisCreature(MultiverseWorld world, Entity e) { public boolean shouldWeKillThisCreature(MVWorld world, Entity e) {
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList()); ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
allMobs.addAll(world.getMonsterList()); allMobs.addAll(world.getMonsterList());
return this.shouldWeKillThisCreature(e, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn()); return this.shouldWeKillThisCreature(e, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
@ -88,7 +88,7 @@ public class SimpleWorldPurger implements WorldPurger {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, public void purgeWorld(MVWorld mvworld, List<String> thingsToKill,
boolean negateAnimals, boolean negateMonsters, CommandSender sender) { boolean negateAnimals, boolean negateMonsters, CommandSender sender) {
if (mvworld == null) { if (mvworld == null) {
return; return;
@ -193,7 +193,7 @@ public class SimpleWorldPurger implements WorldPurger {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) { public void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
purgeWorld(mvworld, thingsToKill, negateAnimals, negateMonsters, null); purgeWorld(mvworld, thingsToKill, negateAnimals, negateMonsters, null);
} }
} }

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.world;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,13 +1,21 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore.world;
import com.onarandombox.MultiverseCore.MVWorld.NullLocation; import java.util.ArrayList;
import com.onarandombox.MultiverseCore.configuration.EntryFee; import java.util.Collections;
import com.onarandombox.MultiverseCore.configuration.SpawnLocation; import java.util.HashMap;
import com.onarandombox.MultiverseCore.configuration.SpawnSettings; import java.util.List;
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator; import java.util.Map;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType; import java.util.regex.Matcher;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor; import java.util.regex.Pattern;
import com.onarandombox.MultiverseCore.enums.EnglishChatStyle;
import com.onarandombox.MultiverseCore.world.configuration.EntryFee;
import com.onarandombox.MultiverseCore.world.configuration.SpawnLocation;
import com.onarandombox.MultiverseCore.world.configuration.SpawnSettings;
import com.onarandombox.MultiverseCore.world.configuration.WorldPropertyValidator;
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatColor;
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatStyle;
import com.onarandombox.MultiverseCore.world.SimpleMVWorld.NullLocation;
import me.main__.util.SerializationConfig.IllegalPropertyValueException; import me.main__.util.SerializationConfig.IllegalPropertyValueException;
import me.main__.util.SerializationConfig.Property; import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig; import me.main__.util.SerializationConfig.SerializationConfig;
@ -23,14 +31,6 @@ import org.bukkit.World.Environment;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
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;
/* /*
* This is a property class, I think we don't need that much javadoc. * This is a property class, I think we don't need that much javadoc.
* BEGIN CHECKSTYLE-SUPPRESSION: Javadoc * BEGIN CHECKSTYLE-SUPPRESSION: Javadoc
@ -88,7 +88,7 @@ public class WorldProperties extends SerializationConfig {
keepSpawnFallback = true; keepSpawnFallback = true;
} }
void setMVWorld(MVWorld world) { void setMVWorld(SimpleMVWorld world) {
registerObjectUsing(world); registerObjectUsing(world);
registerGlobalValidator(new WorldPropertyValidator()); registerGlobalValidator(new WorldPropertyValidator());
} }

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.enums; package com.onarandombox.MultiverseCore.world.configuration;
/** /**
* A enum containing all actions that can be used to modify world-properties. * A enum containing all actions that can be used to modify world-properties.

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.enums; package com.onarandombox.MultiverseCore.world.configuration;
/** /**
* An enum containing all list-properties. * An enum containing all list-properties.

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.enums; package com.onarandombox.MultiverseCore.world.configuration;
import org.bukkit.PortalType; import org.bukkit.PortalType;

View File

@ -5,7 +5,7 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
package com.onarandombox.MultiverseCore.enums; package com.onarandombox.MultiverseCore.world.configuration;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.enums; package com.onarandombox.MultiverseCore.world.configuration;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.configuration; package com.onarandombox.MultiverseCore.world.configuration;
import java.util.Map; import java.util.Map;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.configuration; package com.onarandombox.MultiverseCore.world.configuration;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.configuration; package com.onarandombox.MultiverseCore.world.configuration;
import java.util.Map; import java.util.Map;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.configuration; package com.onarandombox.MultiverseCore.world.configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -1,8 +1,8 @@
package com.onarandombox.MultiverseCore.configuration; package com.onarandombox.MultiverseCore.world.configuration;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import com.onarandombox.MultiverseCore.MVWorld; import com.onarandombox.MultiverseCore.world.SimpleMVWorld;
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent; import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
import me.main__.util.SerializationConfig.ChangeDeniedException; import me.main__.util.SerializationConfig.ChangeDeniedException;
@ -12,12 +12,12 @@ import me.main__.util.SerializationConfig.ObjectUsingValidator;
* Validates world-property-changes. * Validates world-property-changes.
* @param <T> The type of the property that should be validated. * @param <T> The type of the property that should be validated.
*/ */
public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, MVWorld> { public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, SimpleMVWorld> {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException { public T validateChange(String property, T newValue, T oldValue, SimpleMVWorld object) throws ChangeDeniedException {
MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue); MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) if (event.isCancelled())

View File

@ -0,0 +1,4 @@
/**
* This package contains the configuration classes for the worlds.
*/
package com.onarandombox.MultiverseCore.world.configuration;

View File

@ -0,0 +1,4 @@
/**
* This package contains all the classes that are used to create and manage worlds.
*/
package com.onarandombox.MultiverseCore.world;

View File

@ -7,7 +7,7 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Core; import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import junit.framework.Assert; import junit.framework.Assert;
import org.bukkit.Server; import org.bukkit.Server;
@ -47,7 +47,7 @@ public class TestDebugMode {
public void testEnableDebugMode() { public void testEnableDebugMode() {
// Pull a core instance from the server. // Pull a core instance from the server.
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core"); Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
Core core = (Core) plugin; MVCore core = (MVCore) plugin;
// Make sure Core is not null // Make sure Core is not null
assertNotNull(plugin); assertNotNull(plugin);

View File

@ -1,7 +1,7 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener; import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.utils.MockWorldFactory; import com.onarandombox.MultiverseCore.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
@ -35,7 +35,7 @@ public class TestEntitySpawnRules {
MultiverseCore core; MultiverseCore core;
MVEntityListener listener; MVEntityListener listener;
MultiverseWorld mvWorld; MVWorld mvWorld;
World cbworld; World cbworld;
Sheep sheep; Sheep sheep;
@ -51,11 +51,11 @@ public class TestEntitySpawnRules {
core = creator.getCore(); core = creator.getCore();
listener = core.getEntityListener(); listener = core.getEntityListener();
mvWorld = mock(MultiverseWorld.class); mvWorld = mock(MVWorld.class);
cbworld = MockWorldFactory.makeNewMockWorld("world", World.Environment.NORMAL, WorldType.NORMAL); cbworld = MockWorldFactory.makeNewMockWorld("world", World.Environment.NORMAL, WorldType.NORMAL);
when(mvWorld.getCBWorld()).thenReturn(cbworld); when(mvWorld.getCBWorld()).thenReturn(cbworld);
MVWorldManager worldman = mock(MVWorldManager.class); WorldManager worldman = mock(WorldManager.class);
when(worldman.isMVWorld(anyString())).thenReturn(true); when(worldman.isMVWorld(anyString())).thenReturn(true);
when(worldman.getMVWorld(anyString())).thenReturn(mvWorld); when(worldman.getMVWorld(anyString())).thenReturn(mvWorld);
Field worldmanfield = MVEntityListener.class.getDeclaredField("worldManager"); Field worldmanfield = MVEntityListener.class.getDeclaredField("worldManager");

View File

@ -1,14 +1,15 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import java.util.HashMap;
import java.util.Map;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import com.onarandombox.MultiverseCore.world.WorldProperties;
import org.bukkit.Material; import org.bukkit.Material;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -41,22 +42,22 @@ public class TestEntryFeeConversion {
public void testConvertIntegerCurrencyToMaterialCurrency() { public void testConvertIntegerCurrencyToMaterialCurrency() {
entryFee.put("currency", -1); entryFee.put("currency", -1);
WorldProperties props = new WorldProperties(config); WorldProperties props = new WorldProperties(config);
assertNull(props.entryfee.getCurrency()); assertNull(props.getCurrency());
entryFee.put("currency", 0); entryFee.put("currency", 0);
props = new WorldProperties(config); props = new WorldProperties(config);
assertNull(props.entryfee.getCurrency()); assertNull(props.getCurrency());
entryFee.put("currency", 1); entryFee.put("currency", 1);
props = new WorldProperties(config); props = new WorldProperties(config);
assertEquals(Material.STONE, props.entryfee.getCurrency()); assertEquals(Material.STONE, props.getCurrency());
entryFee.put("currency", "1"); entryFee.put("currency", "1");
props = new WorldProperties(config); props = new WorldProperties(config);
assertEquals(Material.STONE, props.entryfee.getCurrency()); assertEquals(Material.STONE, props.getCurrency());
entryFee.put("currency", "stone"); entryFee.put("currency", "stone");
props = new WorldProperties(config); props = new WorldProperties(config);
assertEquals(Material.STONE, props.entryfee.getCurrency()); assertEquals(Material.STONE, props.getCurrency());
} }
} }

View File

@ -1,6 +1,6 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
@ -44,7 +44,7 @@ public class TestModifyCommand {
Command cmd = mock(Command.class); Command cmd = mock(Command.class);
when(cmd.getName()).thenReturn("mv"); when(cmd.getName()).thenReturn("mv");
MultiverseWorld world = core.getMVWorldManager().getMVWorld("world"); MVWorld world = core.getMVWorldManager().getMVWorld("world");
assertNotNull(world); assertNotNull(world);
assertFalse(world.isHidden()); // ensure it's not hidden now assertFalse(world.isHidden()); // ensure it's not hidden now

View File

@ -9,11 +9,12 @@ package com.onarandombox.MultiverseCore;
import java.io.File; import java.io.File;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.configuration.SpawnLocation; import com.onarandombox.MultiverseCore.world.configuration.SpawnLocation;
import com.onarandombox.MultiverseCore.utils.MockWorldFactory; import com.onarandombox.MultiverseCore.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import com.onarandombox.MultiverseCore.world.WorldProperties;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Difficulty; import org.bukkit.Difficulty;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -124,11 +125,11 @@ public class TestWorldProperties {
// //////////////////////////////////////////////// // ////////////////////////////////////////////////
// let's set some world-properties // let's set some world-properties
// we can test the API with this, too :D // we can test the API with this, too :D
MVWorldManager worldManager = core.getMVWorldManager(); WorldManager worldManager = core.getMVWorldManager();
assertNotNull(worldManager); assertNotNull(worldManager);
MultiverseWorld mvWorld = worldManager.getMVWorld("world"); MVWorld mvWorld = worldManager.getMVWorld("world");
MultiverseWorld netherWorld = worldManager.getMVWorld("world_nether"); MVWorld netherWorld = worldManager.getMVWorld("world_nether");
assertNotNull(mvWorld); assertNotNull(mvWorld);
assertNotNull(netherWorld); assertNotNull(netherWorld);
assertSame(mvWorld, worldManager.getFirstSpawnWorld()); assertSame(mvWorld, worldManager.getFirstSpawnWorld());
@ -340,7 +341,7 @@ public class TestWorldProperties {
assertEquals(new SpawnLocation(1, 1, 1), mvWorld.getSpawnLocation()); assertEquals(new SpawnLocation(1, 1, 1), mvWorld.getSpawnLocation());
} }
public void createEvents(MultiverseWorld mvWorld) { public void createEvents(MVWorld mvWorld) {
final World world = mvWorld.getCBWorld(); final World world = mvWorld.getCBWorld();
//// Weather events //// Weather events
// weather change // weather change

View File

@ -1,6 +1,6 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.WorldPurger; import com.onarandombox.MultiverseCore.api.WorldPurger;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import org.bukkit.World; import org.bukkit.World;
@ -24,7 +24,7 @@ public class TestWorldPurger {
MultiverseCore core; MultiverseCore core;
WorldPurger purger; WorldPurger purger;
MultiverseWorld mvWorld; MVWorld mvWorld;
World cbworld; World cbworld;
Sheep sheep; Sheep sheep;
@ -37,7 +37,7 @@ public class TestWorldPurger {
core = creator.getCore(); core = creator.getCore();
purger = core.getMVWorldManager().getTheWorldPurger(); purger = core.getMVWorldManager().getTheWorldPurger();
core.getMVConfig().setGlobalDebug(3); core.getMVConfig().setGlobalDebug(3);
mvWorld = mock(MultiverseWorld.class); mvWorld = mock(MVWorld.class);
cbworld = mock(World.class); cbworld = mock(World.class);
when(mvWorld.getCBWorld()).thenReturn(cbworld); when(mvWorld.getCBWorld()).thenReturn(cbworld);
} }

View File

@ -7,7 +7,7 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException; import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.utils.MockWorldFactory; import com.onarandombox.MultiverseCore.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator; import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
@ -249,7 +249,7 @@ public class TestWorldStuff {
// Ensure that the default worlds have been created. // Ensure that the default worlds have been created.
assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size()); assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
MultiverseWorld mainWorld = creator.getCore().getMVWorldManager().getMVWorld("world"); MVWorld mainWorld = creator.getCore().getMVWorldManager().getMVWorld("world");
// Ensure that the default mode was normal. // Ensure that the default mode was normal.
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode()); assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());

View File

@ -9,10 +9,11 @@ package com.onarandombox.MultiverseCore.utils;
import buscript.Buscript; import buscript.Buscript;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener; import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener; import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.world.SimpleWorldManager;
import junit.framework.Assert; import junit.framework.Assert;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -217,7 +218,7 @@ public class TestInstanceCreator {
buscriptfield.set(core, buscript); buscriptfield.set(core, buscript);
// Set worldManager // Set worldManager
WorldManager wm = spy(new WorldManager(core)); SimpleWorldManager wm = spy(new SimpleWorldManager(core));
Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager"); Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager");
worldmanagerfield.setAccessible(true); worldmanagerfield.setAccessible(true);
worldmanagerfield.set(core, wm); worldmanagerfield.set(core, wm);
@ -276,9 +277,9 @@ public class TestInstanceCreator {
} }
public boolean tearDown() { public boolean tearDown() {
List<MultiverseWorld> worlds = new ArrayList<MultiverseWorld>(core.getMVWorldManager() List<MVWorld> worlds = new ArrayList<MVWorld>(core.getMVWorldManager()
.getMVWorlds()); .getMVWorlds());
for (MultiverseWorld world : worlds) { for (MVWorld world : worlds) {
core.getMVWorldManager().deleteWorld(world.getName()); core.getMVWorldManager().deleteWorld(world.getName());
} }