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 com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.anchor.AnchorManager;
import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.Core;
import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.MVPlugin;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.MVConfig;
import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.commands.CheckCommand;
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.PlayerDestination;
import com.onarandombox.MultiverseCore.destination.core.WorldDestination;
import com.onarandombox.MultiverseCore.economy.MVEconomist;
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
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.MVWorldInitListener;
import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
import com.onarandombox.MultiverseCore.teleportation.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
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.UnsafeCallWrapper;
import com.onarandombox.MultiverseCore.utils.WorldManager;
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 org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
@ -69,9 +69,9 @@ import org.bukkit.plugin.java.JavaPlugin;
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;
// Setup various managers
@ -85,7 +85,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private final MVPermissions mvPermissions = new MVPermissions(this);
private SafeTTeleporter safeTTeleporter = new SimpleSafeTTeleporter(this);
private final UnsafeCallWrapper unsafeCallWrapper = new UnsafeCallWrapper(this);
private final MVWorldManager worldManager = new WorldManager(this);
private final WorldManager worldManager = new SimpleWorldManager(this);
// Configurations
private FileConfiguration multiverseConfig;
@ -146,7 +146,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Now set the firstspawnworld (after the worlds are loaded):
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
MultiverseWorld firstSpawnWorld = this.worldManager.getFirstSpawnWorld();
MVWorld firstSpawnWorld = this.worldManager.getFirstSpawnWorld();
if (firstSpawnWorld != null) {
getMVConfig().setFirstSpawnWorld(firstSpawnWorld.getName());
}
@ -361,7 +361,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* {@inheritDoc}
*/
@Override
public MVWorldManager getMVWorldManager() {
public WorldManager getMVWorldManager() {
return this.worldManager;
}
@ -497,7 +497,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* {@inheritDoc}
*/
@Override
public MultiverseCoreConfig getMVConfig() {
public MVConfig getMVConfig() {
return config;
}

View File

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

View File

@ -5,7 +5,7 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
package com.onarandombox.MultiverseCore.anchor;
import com.dumptruckman.minecraft.util.Logging;
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!
*/
public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
public abstract class AbstractMVPlugin extends JavaPlugin implements MVPlugin {
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.
*/
public interface MultiverseCoreConfig extends ConfigurationSerializable {
public interface MVConfig extends ConfigurationSerializable {
/**
* Sets a property using a {@link String}.
* @param property The name of the property.

View File

@ -10,13 +10,13 @@ package com.onarandombox.MultiverseCore.api;
import buscript.Buscript;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVEconomist;
import com.onarandombox.MultiverseCore.anchor.AnchorManager;
import com.onarandombox.MultiverseCore.economy.MVEconomist;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
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.teleportation.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import org.bukkit.entity.Player;
@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
* <p>
* 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
* worrying about any of the messy details.
@ -85,9 +85,9 @@ public interface Core {
/**
* Gets the primary class responsible for managing Multiverse Worlds.
*
* @return {@link MVWorldManager}.
* @return {@link WorldManager}.
*/
MVWorldManager getMVWorldManager();
WorldManager getMVWorldManager();
/**
* Saves the Multiverse-Config.
@ -135,15 +135,15 @@ public interface Core {
String getAuthors();
/**
* Gets the {@link BlockSafety} this {@link Core} is using.
* @return The {@link BlockSafety} this {@link Core} is using.
* Gets the {@link BlockSafety} this {@link MVCore} is using.
* @return The {@link BlockSafety} this {@link MVCore} is using.
* @see BlockSafety
* @see SimpleBlockSafety
*/
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}.
* @see BlockSafety
* @see SimpleBlockSafety
@ -151,15 +151,15 @@ public interface Core {
void setBlockSafety(BlockSafety blockSafety);
/**
* Gets the {@link LocationManipulation} this {@link Core} is using.
* @return The {@link LocationManipulation} this {@link Core} is using.
* Gets the {@link LocationManipulation} this {@link MVCore} is using.
* @return The {@link LocationManipulation} this {@link MVCore} is using.
* @see LocationManipulation
* @see SimpleLocationManipulation
*/
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}.
* @see LocationManipulation
* @see SimpleLocationManipulation
@ -167,15 +167,15 @@ public interface Core {
void setLocationManipulation(LocationManipulation locationManipulation);
/**
* Gets the {@link SafeTTeleporter} this {@link Core} is using.
* @return The {@link SafeTTeleporter} this {@link Core} is using.
* Gets the {@link SafeTTeleporter} this {@link MVCore} is using.
* @return The {@link SafeTTeleporter} this {@link MVCore} is using.
* @see SafeTTeleporter
* @see SimpleSafeTTeleporter
*/
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}.
* @see SafeTTeleporter
* @see SimpleSafeTTeleporter
@ -183,10 +183,10 @@ public interface Core {
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
/**
* Gets the {@link MultiverseCoreConfig}.
* Gets the {@link MVConfig}.
* @return The configuration.
*/
MultiverseCoreConfig getMVConfig();
MVConfig getMVConfig();
/**
* Gets the buscript object for Multiverse. This is what handles Javascript processing.

View File

@ -7,8 +7,12 @@
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.world.configuration.AddProperties;
import com.onarandombox.MultiverseCore.world.configuration.AllowedPortalType;
import com.onarandombox.MultiverseCore.world.configuration.EnglishChatColor;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@ -16,16 +20,13 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* The API for a Multiverse Handled World.
*/
public interface MultiverseWorld {
public interface MVWorld {
/**
* Returns the Bukkit world object that this world describes.
*
@ -156,9 +157,9 @@ public interface MultiverseWorld {
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.
* @return True if the value was added, false if not.
* @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);
/**
* 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.
* @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.
@ -179,9 +180,9 @@ public interface MultiverseWorld {
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.
* @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.
* @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
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 com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;

View File

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

View File

@ -11,7 +11,7 @@ import java.io.File;
import java.util.Collection;
import java.util.List;
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
import com.onarandombox.MultiverseCore.world.SimpleWorldPurger;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
@ -24,7 +24,7 @@ import org.bukkit.generator.ChunkGenerator;
* This API contains all of the world managing
* functions that your heart desires!
*/
public interface MVWorldManager {
public interface WorldManager {
/**
* 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.
*
* @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.
*
* @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.
*
* @param name The name or optionally the alias of the world to get.
* @param checkAliases Indicates whether to check for world alias name.
* @return A {@link 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.
* @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.
*
* @param name The name or alias of the world to check.
@ -189,7 +189,7 @@ public interface MVWorldManager {
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.
*
* @param name The name or alias of the world to check.
@ -199,7 +199,7 @@ public interface MVWorldManager {
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.
* @return True if the world has been loaded into MV2, false if not.
@ -224,7 +224,7 @@ public interface MVWorldManager {
/**
* Gets the {@link WorldPurger}.
* <p>
* @return The {@link WorldPurger} this {@link MVWorldManager} is using.
* @return The {@link WorldPurger} this {@link WorldManager} is using.
* @see WorldPurger
* @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.
*/
MultiverseWorld getSpawnWorld();
MVWorld getSpawnWorld();
/**
* 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.
*
* @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.

View File

@ -12,39 +12,39 @@ public interface WorldPurger {
/**
* 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.
*
* @param mvworld The {@link MultiverseWorld}.
* @param mvworld The {@link MVWorld}.
* @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
*/
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters);
void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters);
/**
* Clear all animals/monsters that do not belong to a world according to the config.
*
* @param mvworld The {@link MultiverseWorld}.
* @param mvworld The {@link MVWorld}.
* @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
* @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
*/
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, CommandSender sender);
void purgeWorld(MVWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, CommandSender sender);
/**
* Determines whether the specified creature should be killed.
@ -64,5 +64,5 @@ public interface WorldPurger {
* @param e The creature.
* @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 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.CommandFlagsManager;
import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags;
@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
public class MultiverseCommand extends BaseCommand {
protected final MultiverseCore plugin;
protected final MVWorldManager worldManager;
protected final WorldManager worldManager;
protected final CommandFlagsManager flagsManager;
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.PaperCommandCompletions;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.jetbrains.annotations.NotNull;
public class MVCommandCompletions extends PaperCommandCompletions {
@ -46,7 +46,7 @@ public class MVCommandCompletions extends PaperCommandCompletions {
return this.plugin.getMVWorldManager().getMVWorlds()
.stream()
.map(MultiverseWorld::getName)
.map(MVWorld::getName)
.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 com.onarandombox.MultiverseCore.MultiverseCore;
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 org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
@ -53,7 +53,7 @@ public class CannonDestination implements Destination<CannonDestinationInstance>
return null;
}
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName);
MVWorld world = this.plugin.getMVWorldManager().getMVWorld(worldName);
if (world == null) {
return null;
}

View File

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

View File

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

View File

@ -1,7 +1,7 @@
package com.onarandombox.MultiverseCore.destination.core;
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.entity.Entity;
import org.bukkit.util.Vector;
@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class WorldDestinationInstance implements DestinationInstance {
private final MultiverseWorld world;
private final MVWorld world;
private final String direction;
private final float yaw;
@ -18,7 +18,7 @@ public class WorldDestinationInstance implements DestinationInstance {
*
* @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.direction = direction;
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.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
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.
*/
@ -209,77 +205,4 @@ public class MVEconomist {
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 net.milkbowl.vault.economy.Economy;
@ -41,6 +41,24 @@ public class VaultHandler implements Listener {
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.
*/
@ -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.Event;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.event.HandlerList;
/**
@ -12,10 +12,10 @@ import org.bukkit.event.HandlerList;
public class MVWorldDeleteEvent extends Event implements Cancellable {
private boolean cancelled = false;
private final MultiverseWorld world;
private final MVWorld world;
private final boolean removeFromConfig;
public MVWorldDeleteEvent(MultiverseWorld world, boolean removeFromConfig) {
public MVWorldDeleteEvent(MVWorld world, boolean removeFromConfig) {
if (world == 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.
*
* @return That {@link MultiverseWorld}.
* @return That {@link MVWorld}.
*/
public MultiverseWorld getWorld() {
public MVWorld getWorld() {
return world;
}

View File

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

View File

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

View File

@ -9,8 +9,8 @@ package com.onarandombox.MultiverseCore.listeners;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -28,7 +28,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
*/
public class MVEntityListener implements Listener {
private MultiverseCore plugin;
private MVWorldManager worldManager;
private WorldManager worldManager;
public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin;
@ -46,7 +46,7 @@ public class MVEntityListener implements Listener {
}
if (event.getEntity() instanceof Player) {
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 the world has hunger set to false, do not let the level go down
if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
@ -66,7 +66,7 @@ public class MVEntityListener implements Listener {
return;
}
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()) {
event.setCancelled(true);
}
@ -102,7 +102,7 @@ public class MVEntityListener implements Listener {
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()));
}

View File

@ -12,8 +12,8 @@ import java.util.concurrent.ConcurrentHashMap;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.PermissionTools;
import org.bukkit.GameMode;
@ -37,7 +37,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
*/
public class MVPlayerListener implements Listener {
private final MultiverseCore plugin;
private final MVWorldManager worldManager;
private final WorldManager worldManager;
private final PermissionTools pt;
private final Map<String, String> playerWorld = new ConcurrentHashMap<String, String>();
@ -62,7 +62,7 @@ public class MVPlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void playerRespawn(PlayerRespawnEvent event) {
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 (mvWorld == null) {
return;
@ -74,7 +74,7 @@ public class MVPlayerListener implements Listener {
}
// Get the instance of the World the player should respawn at.
MultiverseWorld respawnWorld = null;
MVWorld respawnWorld = null;
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld());
}
@ -93,7 +93,7 @@ public class MVPlayerListener implements Listener {
}
private Location getMostAccurateRespawnLocation(World w) {
MultiverseWorld mvw = this.worldManager.getMVWorld(w.getName());
MVWorld mvw = this.worldManager.getMVWorld(w.getName());
if (mvw != null) {
return mvw.getSpawnLocation();
}
@ -172,8 +172,8 @@ public class MVPlayerListener implements Listener {
}
Logging.finer("Inferred sender '" + teleporter + "' from name '"
+ teleporterName + "', fetched from name '" + teleportee.getName() + "'");
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
MVWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (toWorld == null) {
Logging.fine("Player '" + teleportee.getName() + "' is teleporting to world '"
+ 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) {
return;
}
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
MVWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MVWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// The player 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.
private void handleGameModeAndFlight(Player player, World world) {
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
MVWorld mvWorld = this.worldManager.getMVWorld(world.getName());
if (mvWorld != null) {
this.handleGameModeAndFlight(player, mvWorld);
} else {
@ -335,7 +335,7 @@ public class MVPlayerListener implements Listener {
* @param player The {@link Player}.
* @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
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
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.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.Material;
import org.bukkit.PortalType;
import org.bukkit.block.BlockState;
@ -38,7 +38,7 @@ public class MVPortalListener implements Listener {
public void portalForm(PortalCreateEvent event) {
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) {
Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PortalCreateEvent.", event.getWorld().getName());
return;
@ -94,7 +94,7 @@ public class MVPortalListener implements Listener {
return;
}
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld());
MVWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld());
if (world == null) {
Logging.fine("World '%s' is not managed by Multiverse! Ignoring at PlayerInteractEvent.",
event.getPlayer().getWorld().getName());

View File

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

View File

@ -8,8 +8,8 @@
package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -21,7 +21,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
*/
public class MVWorldListener implements Listener {
private MultiverseCore plugin;
private MVWorldManager worldManager;
private WorldManager worldManager;
public MVWorldListener(MultiverseCore plugin) {
this.plugin = plugin;
@ -56,7 +56,7 @@ public class MVWorldListener implements Listener {
if (this.plugin.getMVWorldManager().getUnloadedWorlds().contains(world.getName())) {
this.plugin.getMVWorldManager().loadWorld(world.getName());
}
MultiverseWorld mvWorld = plugin.getMVWorldManager().getMVWorld(world);
MVWorld mvWorld = plugin.getMVWorldManager().getMVWorld(world);
if (mvWorld != null) {
// This is where we can temporarily fix those pesky property issues!
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. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
package com.onarandombox.MultiverseCore.teleportation;
import com.dumptruckman.minecraft.util.Logging;
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.Material;
import org.bukkit.World;
@ -27,7 +27,7 @@ import java.util.Set;
* The default-implementation of {@link 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);
static {
@ -41,7 +41,7 @@ public class SimpleBlockSafety implements BlockSafety {
AROUND_BLOCK.add(BlockFace.NORTH_WEST);
}
public SimpleBlockSafety(Core plugin) {
public SimpleBlockSafety(MVCore plugin) {
this.plugin = plugin;
}

View File

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

View File

@ -5,7 +5,7 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
package com.onarandombox.MultiverseCore.teleportation;
import co.aikar.commands.BukkitCommandIssuer;
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.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.enums.TeleportResult;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;

View File

@ -5,7 +5,7 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
package com.onarandombox.MultiverseCore.teleportation;
/**
* 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.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
@ -27,7 +27,7 @@ import org.bukkit.permissions.PermissionDefault;
public class MVPermissions {
private MultiverseCore plugin;
private MVWorldManager worldMgr;
private WorldManager worldMgr;
public MVPermissions(MultiverseCore plugin) {
this.plugin = plugin;
@ -39,10 +39,10 @@ public class MVPermissions {
* Check if a Player can ignore GameMode restrictions for world they travel to.
*
* @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.
*/
public boolean canIgnoreGameModeRestriction(Player p, MultiverseWorld w) {
public boolean canIgnoreGameModeRestriction(Player p, MVWorld w) {
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.
*
* @param p The {@link Player} to check.
* @param w The {@link MultiverseWorld} the player wants to teleport to.
* @return Whether the player can teleport to the given {@link MultiverseWorld}.
* @param w The {@link MVWorld} the player wants to teleport to.
* @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();
boolean returnValue = true;
@ -93,10 +93,10 @@ public class MVPermissions {
* Check if the Player has the permissions to enter this world.
*
* @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
*/
public boolean canEnterWorld(Player p, MultiverseWorld w) {
public boolean canEnterWorld(Player p, MVWorld w) {
// If we're not enforcing access, anyone can enter.
if (!plugin.getMVConfig().getEnforceAccess()) {
Logging.finest("EnforceAccess is OFF. Player was allowed in " + w.getAlias());

View File

@ -7,11 +7,11 @@
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import org.bukkit.entity.Player;
import java.util.Date;
import com.onarandombox.MultiverseCore.api.MVConfig;
import org.bukkit.entity.Player;
/**
* A player-session.
*/
@ -22,9 +22,9 @@ public class MVPlayerSession {
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
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.config = config;
// this.bedSpawn = null;

View File

@ -9,15 +9,14 @@ package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
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.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import java.util.logging.Level;
/**
* 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}.
* @param fromWorld The {@link MultiverseWorld} the player is coming from.
* @param toWorld The {@link MultiverseWorld} the player is going to.
* Checks if the given {@link Player} has enough money to enter the specified {@link MVWorld}.
* @param fromWorld The {@link MVWorld} the player is coming from.
* @param toWorld The {@link MVWorld} the player is going to.
* @param teleporter The teleporter.
* @param teleportee The teleportee.
* @param pay If the player has to pay the money.
* @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;
if (plugin.getMVConfig().getTeleportIntercept()) {
if (teleporter instanceof ConsoleCommandSender) {
@ -195,7 +194,7 @@ public class PermissionTools {
* @param teleportee The player going somewhere.
* @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");
Player teleporterPlayer;
@ -266,7 +265,7 @@ public class PermissionTools {
* @param teleportee The player travelling.
* @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) {
teleporter = teleportee;
}
@ -291,7 +290,7 @@ public class PermissionTools {
* @param teleportee player travelling.
* @return True if they should bypass restrictions
*/
public boolean playerCanIgnoreGameModeRestriction(MultiverseWorld toWorld, Player teleportee) {
public boolean playerCanIgnoreGameModeRestriction(MVWorld toWorld, Player teleportee) {
if (toWorld != null) {
return this.plugin.getMVPerms().canIgnoreGameModeRestriction(teleportee, toWorld);
} else {

View File

@ -1,7 +1,7 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.Core;
import com.onarandombox.MultiverseCore.api.MVCore;
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.
*/
public class UnsafeCallWrapper {
private final Core core;
private final MVCore core;
public UnsafeCallWrapper(Core core) {
public UnsafeCallWrapper(MVCore core) {
this.core = core;
}

View File

@ -6,8 +6,8 @@ import java.util.function.Consumer;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import org.apache.commons.lang.WordUtils;
import org.bstats.bukkit.Metrics;
import org.bukkit.World;
@ -30,11 +30,11 @@ public class MetricsConfigurator {
this.metrics = new Metrics(plugin, PLUGIN_ID);
}
private MVWorldManager getWorldManager() {
private WorldManager getWorldManager() {
return plugin.getMVWorldManager();
}
private Collection<MultiverseWorld> getMVWorlds() {
private Collection<MVWorld> getMVWorlds() {
return getWorldManager().getMVWorlds();
}
@ -53,20 +53,20 @@ public class MetricsConfigurator {
private void addCustomGeneratorsMetric() {
addAdvancedPieMetric("custom_generators", map -> {
for (MultiverseWorld w : getMVWorlds()) {
for (MVWorld w : getMVWorlds()) {
MetricsHelper.incrementCount(map, getGeneratorName(w));
}
});
}
private String getGeneratorName(MultiverseWorld world) {
private String getGeneratorName(MVWorld world) {
String gen = world.getGenerator();
return (gen != null && !gen.equalsIgnoreCase("null")) ? gen.split(":")[0] : NO_GENERATOR_NAME;
}
private void addEnvironmentsMetric() {
addAdvancedPieMetric("environments", map -> {
for (MultiverseWorld w : getMVWorlds()) {
for (MVWorld w : getMVWorlds()) {
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. *
******************************************************************************/
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.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
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.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.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.NoSuchPropertyException;
import me.main__.util.SerializationConfig.VirtualProperty;
@ -28,7 +35,6 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
@ -37,16 +43,10 @@ import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
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.
*/
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_RADIUS = 16;
@ -55,14 +55,14 @@ public class MVWorld implements MultiverseWorld {
private final UUID worldUID;
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);
}
/*
* 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.name = world.getName();
this.worldUID = world.getUID();
@ -212,7 +212,7 @@ public class MVWorld implements MultiverseWorld {
private final class ScalePropertyValidator extends WorldPropertyValidator<Double> {
@Override
public Double validateChange(String property, Double newValue, Double oldValue,
MVWorld object) throws ChangeDeniedException {
SimpleMVWorld object) throws ChangeDeniedException {
if (newValue <= 0) {
Logging.fine("Someone tried to set a scale <= 0, aborting!");
throw new ChangeDeniedException();
@ -227,7 +227,7 @@ public class MVWorld implements MultiverseWorld {
private final class RespawnWorldPropertyValidator extends WorldPropertyValidator<String> {
@Override
public String validateChange(String property, String newValue, String oldValue,
MVWorld object) throws ChangeDeniedException {
SimpleMVWorld object) throws ChangeDeniedException {
if (!newValue.isEmpty() && !plugin.getMVWorldManager().isMVWorld(newValue))
throw new ChangeDeniedException();
return super.validateChange(property, newValue, oldValue, object);
@ -242,7 +242,7 @@ public class MVWorld implements MultiverseWorld {
private final class AllowWeatherPropertyValidator extends WorldPropertyValidator<Boolean> {
@Override
public Boolean validateChange(String property, Boolean newValue, Boolean oldValue,
MVWorld object) throws ChangeDeniedException {
SimpleMVWorld object) throws ChangeDeniedException {
if (!newValue) {
final World world = getCBWorld();
if (world != null) {
@ -260,7 +260,7 @@ public class MVWorld implements MultiverseWorld {
private final class SpawningPropertyValidator extends WorldPropertyValidator<SpawnSettings> {
@Override
public SpawnSettings validateChange(String property, SpawnSettings newValue, SpawnSettings oldValue,
MVWorld object) throws ChangeDeniedException {
SimpleMVWorld object) throws ChangeDeniedException {
boolean allowMonsters, allowAnimals;
if (getAnimalList().isEmpty()) {
allowAnimals = canAnimalsSpawn();
@ -274,16 +274,16 @@ public class MVWorld implements MultiverseWorld {
}
final World world = getCBWorld();
if (world != null) {
if (MVWorld.this.props.getAnimalSpawnRate() != -1) {
world.setTicksPerAnimalSpawns(MVWorld.this.props.getAnimalSpawnRate());
if (SimpleMVWorld.this.props.getAnimalSpawnRate() != -1) {
world.setTicksPerAnimalSpawns(SimpleMVWorld.this.props.getAnimalSpawnRate());
}
if (MVWorld.this.props.getMonsterSpawnRate() != -1) {
world.setTicksPerMonsterSpawns(MVWorld.this.props.getMonsterSpawnRate());
if (SimpleMVWorld.this.props.getMonsterSpawnRate() != -1) {
world.setTicksPerMonsterSpawns(SimpleMVWorld.this.props.getMonsterSpawnRate());
}
world.setSpawnFlags(allowMonsters, allowAnimals);
}
if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) {
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(MVWorld.this);
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(SimpleMVWorld.this);
}
return super.validateChange(property, newValue, oldValue, object);
}
@ -295,11 +295,11 @@ public class MVWorld implements MultiverseWorld {
private final class GameModePropertyValidator extends WorldPropertyValidator<GameMode> {
@Override
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()) {
Logging.finer(String.format("Setting %s's GameMode to %s",
p.getName(), newValue.toString()));
plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this);
plugin.getPlayerListener().handleGameModeAndFlight(p, SimpleMVWorld.this);
}
return super.validateChange(property, newValue, oldValue, object);
}
@ -311,7 +311,7 @@ public class MVWorld implements MultiverseWorld {
private final class SpawnLocationPropertyValidator extends WorldPropertyValidator<Location> {
@Override
public Location validateChange(String property, Location newValue, Location oldValue,
MVWorld object) throws ChangeDeniedException {
SimpleMVWorld object) throws ChangeDeniedException {
if (newValue == null)
throw new ChangeDeniedException();
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.
*/
public void copyValues(MVWorld other) {
public void copyValues(SimpleMVWorld other) {
props.copyValues(other.props);
}

View File

@ -5,33 +5,7 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
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;
package com.onarandombox.MultiverseCore.world;
import java.io.File;
import java.io.FilenameFilter;
@ -48,25 +22,49 @@ import java.util.Set;
import java.util.Stack;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
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 class WorldManager implements MVWorldManager {
public class SimpleWorldManager implements WorldManager {
private final MultiverseCore plugin;
private final WorldPurger worldPurger;
private final Map<String, MultiverseWorld> worlds;
private final Map<String, MVWorld> worlds;
private Map<String, WorldProperties> worldsFromTheConfig;
private FileConfiguration configWorlds = null;
private Map<String, String> defaultGens;
private String firstSpawn;
public WorldManager(MultiverseCore core) {
public SimpleWorldManager(MultiverseCore core) {
this.plugin = core;
this.worldsFromTheConfig = new HashMap<String, WorldProperties>();
this.worlds = new ConcurrentHashMap<String, MultiverseWorld>();
this.worlds = new ConcurrentHashMap<String, MVWorld>();
this.worldPurger = new SimpleWorldPurger(plugin);
}
@ -152,7 +150,7 @@ public class WorldManager implements MVWorldManager {
}
// Grab a bit of metadata from the old world.
MultiverseWorld oldWorld = getMVWorld(oldName);
MVWorld oldWorld = getMVWorld(oldName);
// Don't need the loaded world anymore.
if (wasJustLoaded) {
@ -345,8 +343,8 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc}
*/
@Override
public MultiverseWorld getFirstSpawnWorld() {
MultiverseWorld world = this.getMVWorld(this.firstSpawn);
public MVWorld getFirstSpawnWorld() {
MVWorld world = this.getMVWorld(this.firstSpawn);
if (world == null) {
// If the spawn world was unloaded, get the default world
Logging.warning("The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
@ -483,7 +481,7 @@ public class WorldManager implements MVWorldManager {
nullWorld(worldName);
return false;
}
MVWorld world = new MVWorld(plugin, cbworld, mvworld);
SimpleMVWorld world = new SimpleMVWorld(plugin, cbworld, mvworld);
if (MultiverseCoreConfiguration.getInstance().isAutoPurgeEnabled()) {
this.worldPurger.purgeWorld(world);
}
@ -598,7 +596,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc}
*/
@Override
public Collection<MultiverseWorld> getMVWorlds() {
public Collection<MVWorld> getMVWorlds() {
return this.worlds.values();
}
@ -606,7 +604,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc}
*/
@Override
public MultiverseWorld getMVWorld(String name) {
public MVWorld getMVWorld(String name) {
return this.getMVWorld(name, true);
}
@ -614,11 +612,11 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc}
*/
@Override
public MultiverseWorld getMVWorld(String name, boolean checkAliases) {
public MVWorld getMVWorld(String name, boolean checkAliases) {
if (name == null) {
return null;
}
MultiverseWorld world = this.worlds.get(name);
MVWorld world = this.worlds.get(name);
if (world != null) {
return world;
}
@ -629,7 +627,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc}
*/
@Override
public MultiverseWorld getMVWorld(World world) {
public MVWorld getMVWorld(World world) {
if (world != null) {
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.
* @return A {@link MVWorld} or null.
* @return A {@link SimpleMVWorld} or null.
*/
private MultiverseWorld getMVWorldByAlias(String alias) {
for (MultiverseWorld w : this.worlds.values()) {
private MVWorld getMVWorldByAlias(String alias) {
for (MVWorld w : this.worlds.values()) {
if (w.getAlias().equalsIgnoreCase(alias)) {
return w;
}
@ -682,7 +680,7 @@ public class WorldManager implements MVWorldManager {
* @return True if the world exists, false if not.
*/
private boolean isMVWorldAlias(final String alias) {
for (MultiverseWorld w : this.worlds.values()) {
for (MVWorld w : this.worlds.values()) {
if (w.getAlias().equalsIgnoreCase(alias)) {
return true;
}
@ -731,7 +729,7 @@ public class WorldManager implements MVWorldManager {
// Remove all world permissions.
Permission allAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
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
if (allAccess != null) {
allAccess.getChildren().remove(w.getAccessPermission().getName());
@ -816,7 +814,7 @@ public class WorldManager implements MVWorldManager {
if (this.worldsFromTheConfig.containsKey(worldName)) {
// Object-Recycling :D
// 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) {
mvWorld.copyValues((WorldProperties) obj);
}
@ -858,7 +856,7 @@ public class WorldManager implements MVWorldManager {
* {@inheritDoc}
*/
@Override
public MultiverseWorld getSpawnWorld() {
public MVWorld getSpawnWorld() {
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
}
@ -885,7 +883,7 @@ public class WorldManager implements MVWorldManager {
*/
@Override
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) {
Logging.warning("Unable to regen a world that does not exist!");
return false;
@ -970,8 +968,8 @@ public class WorldManager implements MVWorldManager {
}
/**
* Gets the {@link FileConfiguration} that this {@link WorldManager} is using.
* @return 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 SimpleWorldManager} is using.
*/
public FileConfiguration getConfigWorlds() {
return this.configWorlds;

View File

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

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.utils;
package com.onarandombox.MultiverseCore.world;
import org.bukkit.Bukkit;
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 com.onarandombox.MultiverseCore.configuration.EntryFee;
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.enums.EnglishChatStyle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import 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.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
@ -23,14 +31,6 @@ import org.bukkit.World.Environment;
import org.bukkit.configuration.serialization.SerializableAs;
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.
* BEGIN CHECKSTYLE-SUPPRESSION: Javadoc
@ -88,7 +88,7 @@ public class WorldProperties extends SerializationConfig {
keepSpawnFallback = true;
}
void setMVWorld(MVWorld world) {
void setMVWorld(SimpleMVWorld world) {
registerObjectUsing(world);
registerGlobalValidator(new WorldPropertyValidator());
}

View File

@ -5,7 +5,7 @@
* 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.

View File

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

View File

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

View File

@ -5,7 +5,7 @@
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
package com.onarandombox.MultiverseCore.world.configuration;
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;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.configuration;
package com.onarandombox.MultiverseCore.world.configuration;
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.WeakReference;

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.configuration;
package com.onarandombox.MultiverseCore.world.configuration;
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.List;

View File

@ -1,8 +1,8 @@
package com.onarandombox.MultiverseCore.configuration;
package com.onarandombox.MultiverseCore.world.configuration;
import org.bukkit.Bukkit;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.world.SimpleMVWorld;
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
import me.main__.util.SerializationConfig.ChangeDeniedException;
@ -12,12 +12,12 @@ import me.main__.util.SerializationConfig.ObjectUsingValidator;
* Validates world-property-changes.
* @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}
*/
@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);
Bukkit.getPluginManager().callEvent(event);
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;
import com.onarandombox.MultiverseCore.api.Core;
import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import junit.framework.Assert;
import org.bukkit.Server;
@ -47,7 +47,7 @@ public class TestDebugMode {
public void testEnableDebugMode() {
// Pull a core instance from the server.
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
Core core = (Core) plugin;
MVCore core = (MVCore) plugin;
// Make sure Core is not null
assertNotNull(plugin);

View File

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

View File

@ -1,14 +1,15 @@
package com.onarandombox.MultiverseCore;
import java.util.HashMap;
import java.util.Map;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import com.onarandombox.MultiverseCore.world.WorldProperties;
import org.bukkit.Material;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@ -41,22 +42,22 @@ public class TestEntryFeeConversion {
public void testConvertIntegerCurrencyToMaterialCurrency() {
entryFee.put("currency", -1);
WorldProperties props = new WorldProperties(config);
assertNull(props.entryfee.getCurrency());
assertNull(props.getCurrency());
entryFee.put("currency", 0);
props = new WorldProperties(config);
assertNull(props.entryfee.getCurrency());
assertNull(props.getCurrency());
entryFee.put("currency", 1);
props = new WorldProperties(config);
assertEquals(Material.STONE, props.entryfee.getCurrency());
assertEquals(Material.STONE, props.getCurrency());
entryFee.put("currency", "1");
props = new WorldProperties(config);
assertEquals(Material.STONE, props.entryfee.getCurrency());
assertEquals(Material.STONE, props.getCurrency());
entryFee.put("currency", "stone");
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;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
import org.bukkit.Server;
import org.bukkit.World.Environment;
@ -44,7 +44,7 @@ public class TestModifyCommand {
Command cmd = mock(Command.class);
when(cmd.getName()).thenReturn("mv");
MultiverseWorld world = core.getMVWorldManager().getMVWorld("world");
MVWorld world = core.getMVWorldManager().getMVWorld("world");
assertNotNull(world);
assertFalse(world.isHidden()); // ensure it's not hidden now

View File

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

View File

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

View File

@ -7,7 +7,7 @@
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.utils.MockWorldFactory;
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
@ -249,7 +249,7 @@ public class TestWorldStuff {
// Ensure that the default worlds have been created.
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.
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());

View File

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