mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-04 14:41:25 +01:00
Set up DI for primary dependencies of MultiverseCore.
This commit is contained in:
parent
6a434746c9
commit
0db90dc0b9
@ -42,7 +42,6 @@ import com.onarandombox.MultiverseCore.commands.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.destination.core.AnchorDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.core.BedDestination;
|
||||
@ -60,15 +59,13 @@ 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.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.TestingMode;
|
||||
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
import com.onarandombox.MultiverseCore.world.SimpleMVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.world.WorldProperties;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Provider;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -92,30 +89,31 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
|
||||
// Setup various managers
|
||||
private ServiceLocator serviceLocator;
|
||||
private final AnchorManager anchorManager = new AnchorManager(this);
|
||||
private BlockSafety blockSafety = new SimpleBlockSafety(this);
|
||||
private MVCommandManager commandManager;
|
||||
private DestinationsProvider destinationsProvider;
|
||||
private MVEconomist economist;
|
||||
private LocationManipulation locationManipulation = new SimpleLocationManipulation();
|
||||
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 SimpleMVWorldManager(this);
|
||||
@Inject
|
||||
private Provider<AnchorManager> anchorManager;
|
||||
@Inject
|
||||
private Provider<BlockSafety> blockSafety;
|
||||
@Inject
|
||||
private Provider<MVCommandManager> commandManager;
|
||||
@Inject
|
||||
private Provider<DestinationsProvider> destinationsProvider;
|
||||
@Inject
|
||||
private Provider<MVEconomist> economist;
|
||||
@Inject
|
||||
private Provider<LocationManipulation> locationManipulation;
|
||||
@Inject
|
||||
private Provider<MVPermissions> mvPermissions;
|
||||
@Inject
|
||||
private Provider<SafeTTeleporter> safeTTeleporter;
|
||||
@Inject
|
||||
private Provider<UnsafeCallWrapper> unsafeCallWrapper;
|
||||
@Inject
|
||||
private Provider<MVWorldManager> worldManager;
|
||||
|
||||
// Configurations
|
||||
private FileConfiguration multiverseConfig;
|
||||
private volatile MultiverseCoreConfiguration config;
|
||||
|
||||
// Listeners
|
||||
private MVChatListener chatListener;
|
||||
private final MVEntityListener entityListener = new MVEntityListener(this);
|
||||
private final MVPlayerListener playerListener = new MVPlayerListener(this);
|
||||
private final MVPortalListener portalListener = new MVPortalListener(this);
|
||||
private final MVWeatherListener weatherListener = new MVWeatherListener(this);
|
||||
private final MVWorldListener worldListener = new MVWorldListener(this);
|
||||
private final MVWorldInitListener worldInitListener = new MVWorldInitListener(this);
|
||||
|
||||
// Counter for the number of plugins that have registered with us
|
||||
private int pluginCount;
|
||||
|
||||
@ -158,22 +156,25 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
|
||||
Logging.setShowingConfig(!getMVConfig().getSilentStart());
|
||||
|
||||
this.worldManager.getDefaultWorldGenerators();
|
||||
this.worldManager.loadDefaultWorlds();
|
||||
this.worldManager.loadWorlds(true);
|
||||
var worldManager = getMVWorldManager();
|
||||
|
||||
worldManager.getDefaultWorldGenerators();
|
||||
worldManager.loadDefaultWorlds();
|
||||
worldManager.loadWorlds(true);
|
||||
|
||||
// Now set the firstspawnworld (after the worlds are loaded):
|
||||
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
|
||||
MVWorld firstSpawnWorld = this.worldManager.getFirstSpawnWorld();
|
||||
worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
|
||||
MVWorld firstSpawnWorld = worldManager.getFirstSpawnWorld();
|
||||
if (firstSpawnWorld != null) {
|
||||
getMVConfig().setFirstSpawnWorld(firstSpawnWorld.getName());
|
||||
}
|
||||
|
||||
//Setup economy here so vault is loaded
|
||||
this.economist = new MVEconomist(this);
|
||||
// TODO we may need to change MVEconomist to have an enable method or something
|
||||
// this.economist = new MVEconomist(this);
|
||||
|
||||
// Init all the other stuff
|
||||
this.anchorManager.loadAnchors();
|
||||
getAnchorManager().loadAnchors();
|
||||
this.registerEvents();
|
||||
this.registerCommands();
|
||||
this.setUpLocales();
|
||||
@ -198,7 +199,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
.andThenTry(locator -> {
|
||||
PluginInjection.enable(this, locator);
|
||||
})
|
||||
.andThen(this::saveLegacyVars)
|
||||
.getOrElseThrow(exception -> {
|
||||
Logging.severe("Failed to initialize dependency injection");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
@ -206,10 +206,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
});
|
||||
}
|
||||
|
||||
private void saveLegacyVars(ServiceLocator locator) {
|
||||
// TODO set up existing things e.g. worldManager = locator.getService(MVWorldManager.class);
|
||||
}
|
||||
|
||||
private void shutdownDependencyInjection() {
|
||||
if (serviceLocator != null) {
|
||||
PluginInjection.disable(this, serviceLocator);
|
||||
@ -221,58 +217,63 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
* Function to Register all the Events needed.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
// TODO add automatic listener registration through hk2
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
this.chatListener = new MVChatListener(this, this.playerListener);
|
||||
pluginManager.registerEvents(this.chatListener, this);
|
||||
pluginManager.registerEvents(this.entityListener, this);
|
||||
pluginManager.registerEvents(this.playerListener, this);
|
||||
pluginManager.registerEvents(this.portalListener, this);
|
||||
pluginManager.registerEvents(this.weatherListener, this);
|
||||
pluginManager.registerEvents(this.worldListener, this);
|
||||
pluginManager.registerEvents(this.worldInitListener, this);
|
||||
pluginManager.registerEvents(getService(MVEntityListener.class), this);
|
||||
pluginManager.registerEvents(getService(MVPlayerListener.class), this);
|
||||
pluginManager.registerEvents(getService(MVChatListener.class), this);
|
||||
pluginManager.registerEvents(getService(MVPortalListener.class), this);
|
||||
pluginManager.registerEvents(getService(MVWeatherListener.class), this);
|
||||
pluginManager.registerEvents(getService(MVWorldListener.class), this);
|
||||
pluginManager.registerEvents(getService(MVWorldInitListener.class), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Multiverse-Core commands to Command Manager.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
this.commandManager = new MVCommandManager(this);
|
||||
this.commandManager.registerCommand(new CheckCommand(this));
|
||||
this.commandManager.registerCommand(new CloneCommand(this));
|
||||
this.commandManager.registerCommand(new ConfirmCommand(this));
|
||||
this.commandManager.registerCommand(new CreateCommand(this));
|
||||
this.commandManager.registerCommand(new DebugCommand(this));
|
||||
this.commandManager.registerCommand(new DeleteCommand(this));
|
||||
this.commandManager.registerCommand(new ImportCommand(this));
|
||||
this.commandManager.registerCommand(new GameruleCommand(this));
|
||||
this.commandManager.registerCommand(new LoadCommand(this));
|
||||
this.commandManager.registerCommand(new RegenCommand(this));
|
||||
this.commandManager.registerCommand(new ReloadCommand(this));
|
||||
this.commandManager.registerCommand(new RemoveCommand(this));
|
||||
this.commandManager.registerCommand(new TeleportCommand(this));
|
||||
this.commandManager.registerCommand(new UnloadCommand(this));
|
||||
var commandManager = getMVCommandManager();
|
||||
|
||||
commandManager = new MVCommandManager(this);
|
||||
commandManager.registerCommand(new CheckCommand(this));
|
||||
commandManager.registerCommand(new CloneCommand(this));
|
||||
commandManager.registerCommand(new ConfirmCommand(this));
|
||||
commandManager.registerCommand(new CreateCommand(this));
|
||||
commandManager.registerCommand(new DebugCommand(this));
|
||||
commandManager.registerCommand(new DeleteCommand(this));
|
||||
commandManager.registerCommand(new ImportCommand(this));
|
||||
commandManager.registerCommand(new GameruleCommand(this));
|
||||
commandManager.registerCommand(new LoadCommand(this));
|
||||
commandManager.registerCommand(new RegenCommand(this));
|
||||
commandManager.registerCommand(new ReloadCommand(this));
|
||||
commandManager.registerCommand(new RemoveCommand(this));
|
||||
commandManager.registerCommand(new TeleportCommand(this));
|
||||
commandManager.registerCommand(new UnloadCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register locales
|
||||
*/
|
||||
private void setUpLocales() {
|
||||
this.commandManager.usePerIssuerLocale(true, true);
|
||||
this.commandManager.getLocales().addFileResClassLoader(this);
|
||||
this.commandManager.getLocales().addMessageBundles("multiverse-core");
|
||||
var commandManager = getMVCommandManager();
|
||||
|
||||
commandManager.usePerIssuerLocale(true, true);
|
||||
commandManager.getLocales().addFileResClassLoader(this);
|
||||
commandManager.getLocales().addMessageBundles("multiverse-core");
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all the destinations.
|
||||
*/
|
||||
private void registerDestinations() {
|
||||
this.destinationsProvider = new DestinationsProvider(this);
|
||||
this.destinationsProvider.registerDestination(new AnchorDestination(this));
|
||||
this.destinationsProvider.registerDestination(new BedDestination());
|
||||
this.destinationsProvider.registerDestination(new CannonDestination(this));
|
||||
this.destinationsProvider.registerDestination(new ExactDestination(this));
|
||||
this.destinationsProvider.registerDestination(new PlayerDestination());
|
||||
this.destinationsProvider.registerDestination(new WorldDestination(this));
|
||||
var destinationsProvider = getDestinationsProvider();
|
||||
|
||||
destinationsProvider.registerDestination(new AnchorDestination(this));
|
||||
destinationsProvider.registerDestination(new BedDestination());
|
||||
destinationsProvider.registerDestination(new CannonDestination(this));
|
||||
destinationsProvider.registerDestination(new ExactDestination(this));
|
||||
destinationsProvider.registerDestination(new PlayerDestination());
|
||||
destinationsProvider.registerDestination(new WorldDestination(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +317,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public MVEconomist getEconomist() {
|
||||
return economist;
|
||||
return economist.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -324,7 +325,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public MVPermissions getMVPerms() {
|
||||
return this.mvPermissions;
|
||||
return this.mvPermissions.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -356,7 +357,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public MVCommandManager getMVCommandManager() {
|
||||
return this.commandManager;
|
||||
return this.commandManager.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,7 +389,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public DestinationsProvider getDestinationsProvider() {
|
||||
return this.destinationsProvider;
|
||||
return this.destinationsProvider.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,7 +397,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public MVWorldManager getMVWorldManager() {
|
||||
return this.worldManager;
|
||||
return this.worldManager.get();
|
||||
}
|
||||
|
||||
|
||||
@ -430,7 +431,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
} finally {
|
||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||
}
|
||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||
getMVWorldManager().loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
int level = Logging.getDebugLevel();
|
||||
Logging.setDebugLevel(getMVConfig().getGlobalDebug());
|
||||
@ -459,7 +460,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAllConfigs() {
|
||||
return this.saveMVConfig() && this.worldManager.saveWorldsConfig();
|
||||
return this.saveMVConfig() && getMVWorldManager().saveWorldsConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -467,7 +468,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public AnchorManager getAnchorManager() {
|
||||
return this.anchorManager;
|
||||
return this.anchorManager.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -475,57 +476,51 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public BlockSafety getBlockSafety() {
|
||||
return blockSafety;
|
||||
return blockSafety.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated Use dependency injection instead.
|
||||
*/
|
||||
@Override
|
||||
public void setBlockSafety(BlockSafety blockSafety) {
|
||||
if (blockSafety == null) {
|
||||
throw new NullPointerException("block safety may not be null.");
|
||||
}
|
||||
this.blockSafety = blockSafety;
|
||||
}
|
||||
@Deprecated
|
||||
public void setBlockSafety(BlockSafety blockSafety) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public LocationManipulation getLocationManipulation() {
|
||||
return locationManipulation;
|
||||
return locationManipulation.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated Use dependency injection instead.
|
||||
*/
|
||||
@Override
|
||||
public void setLocationManipulation(LocationManipulation locationManipulation) {
|
||||
if (locationManipulation == null) {
|
||||
throw new NullPointerException("location manipulation may not be null.");
|
||||
}
|
||||
this.locationManipulation = locationManipulation;
|
||||
}
|
||||
@Deprecated
|
||||
public void setLocationManipulation(LocationManipulation locationManipulation) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SafeTTeleporter getSafeTTeleporter() {
|
||||
return safeTTeleporter;
|
||||
return safeTTeleporter.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated Use dependency injection instead.
|
||||
*/
|
||||
@Override
|
||||
public void setSafeTTeleporter(SafeTTeleporter safeTTeleporter) {
|
||||
if (safeTTeleporter == null) {
|
||||
throw new NullPointerException("safeTTeleporter may not be null.");
|
||||
}
|
||||
this.safeTTeleporter = safeTTeleporter;
|
||||
}
|
||||
@Deprecated
|
||||
public void setSafeTTeleporter(SafeTTeleporter safeTTeleporter) {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -540,7 +535,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
@Override
|
||||
public UnsafeCallWrapper getUnsafeCallWrapper() {
|
||||
return this.unsafeCallWrapper;
|
||||
return this.unsafeCallWrapper.get();
|
||||
}
|
||||
|
||||
|
||||
@ -596,7 +591,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
* @return The {@link MVPlayerListener}.
|
||||
*/
|
||||
public MVPlayerListener getPlayerListener() {
|
||||
return this.playerListener;
|
||||
return getService(MVPlayerListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -605,7 +600,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
* @return The {@link MVChatListener}.
|
||||
*/
|
||||
public MVChatListener getChatListener() {
|
||||
return this.chatListener;
|
||||
return getService(MVChatListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -614,7 +609,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
* @return The {@link MVEntityListener}.
|
||||
*/
|
||||
public MVEntityListener getEntityListener() {
|
||||
return this.entityListener;
|
||||
return getService(MVEntityListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -623,7 +618,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
* @return The {@link MVWeatherListener}.
|
||||
*/
|
||||
public MVWeatherListener getWeatherListener() {
|
||||
return this.weatherListener;
|
||||
return getService(MVWeatherListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,10 +9,12 @@ import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
*/
|
||||
@Service
|
||||
public class MultiverseCoreConfiguration extends SerializationConfig implements MVConfig {
|
||||
private static MultiverseCoreConfiguration instance;
|
||||
|
||||
|
@ -9,11 +9,13 @@ package com.onarandombox.MultiverseCore.anchor;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -22,16 +24,17 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Manages anchors.
|
||||
*/
|
||||
@Service
|
||||
public class AnchorManager {
|
||||
private MultiverseCore plugin;
|
||||
private Map<String, Location> anchors;
|
||||
private FileConfiguration anchorConfig;
|
||||
|
||||
@Inject
|
||||
public AnchorManager(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.anchors = new HashMap<String, Location>();
|
||||
|
@ -4,10 +4,12 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to get block/location-related information.
|
||||
*/
|
||||
@Contract
|
||||
public interface BlockSafety {
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
|
@ -3,10 +3,12 @@ package com.onarandombox.MultiverseCore.api;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to manipulate locations.
|
||||
*/
|
||||
@Contract
|
||||
public interface LocationManipulation {
|
||||
/**
|
||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* The configuration of MultiverseCore.
|
||||
*/
|
||||
@Contract
|
||||
public interface MVConfig extends ConfigurationSerializable {
|
||||
/**
|
||||
* Sets a property using a {@link String}.
|
||||
|
@ -128,7 +128,10 @@ public interface MVCore extends MVPlugin {
|
||||
* @param blockSafety The new {@link BlockSafety}.
|
||||
* @see BlockSafety
|
||||
* @see SimpleBlockSafety
|
||||
*
|
||||
* @deprecated Use dependency injection instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setBlockSafety(BlockSafety blockSafety);
|
||||
|
||||
/**
|
||||
@ -144,7 +147,10 @@ public interface MVCore extends MVPlugin {
|
||||
* @param locationManipulation The new {@link LocationManipulation}.
|
||||
* @see LocationManipulation
|
||||
* @see SimpleLocationManipulation
|
||||
*
|
||||
* @deprecated Use dependency injection instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setLocationManipulation(LocationManipulation locationManipulation);
|
||||
|
||||
/**
|
||||
@ -160,7 +166,10 @@ public interface MVCore extends MVPlugin {
|
||||
* @param safeTTeleporter The new {@link SafeTTeleporter}.
|
||||
* @see SafeTTeleporter
|
||||
* @see SimpleSafeTTeleporter
|
||||
*
|
||||
* @deprecated Use dependency injection instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Multiverse 2 World Manager API
|
||||
@ -24,6 +25,7 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
* This API contains all of the world managing
|
||||
* functions that your heart desires!
|
||||
*/
|
||||
@Contract
|
||||
public interface MVWorldManager {
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
|
@ -6,10 +6,12 @@ import com.onarandombox.MultiverseCore.teleportation.TeleportResult;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
/**
|
||||
* Used to safely teleport people.
|
||||
*/
|
||||
@Contract
|
||||
public interface SafeTTeleporter extends Teleporter {
|
||||
|
||||
/**
|
||||
|
@ -12,11 +12,14 @@ import co.aikar.commands.PaperCommandManager;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Main class to manage permissions.
|
||||
*/
|
||||
@Service
|
||||
public class MVCommandManager extends PaperCommandManager {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
@ -24,6 +27,7 @@ public class MVCommandManager extends PaperCommandManager {
|
||||
private CommandQueueManager commandQueueManager;
|
||||
private PluginLocales pluginLocales;
|
||||
|
||||
@Inject
|
||||
public MVCommandManager(@NotNull MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
|
@ -11,16 +11,19 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.Destination;
|
||||
import com.onarandombox.MultiverseCore.api.DestinationInstance;
|
||||
import com.onarandombox.MultiverseCore.api.Teleporter;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Provides destinations for teleportation.
|
||||
*/
|
||||
@Service
|
||||
public class DestinationsProvider {
|
||||
private static final String SEPARATOR = ":";
|
||||
private static final String PERMISSION_PREFIX = "multiverse.teleport.";
|
||||
@ -33,6 +36,7 @@ public class DestinationsProvider {
|
||||
*
|
||||
* @param plugin The plugin.
|
||||
*/
|
||||
@Inject
|
||||
public DestinationsProvider(@NotNull MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.destinationMap = new HashMap<>();
|
||||
|
@ -1,18 +1,22 @@
|
||||
package com.onarandombox.MultiverseCore.economy;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's Friendly Economist. This is used to deal with external economies and also item costs for stuff in MV.
|
||||
*/
|
||||
@Service
|
||||
public class MVEconomist {
|
||||
|
||||
private final VaultHandler vaultHandler;
|
||||
|
||||
@Inject
|
||||
public MVEconomist(Plugin plugin) {
|
||||
vaultHandler = new VaultHandler(plugin);
|
||||
}
|
||||
|
@ -4,19 +4,23 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's {@link org.bukkit.event.Listener} for players.
|
||||
*/
|
||||
@Service
|
||||
public class MVChatListener implements Listener {
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
private final MVPlayerListener playerListener;
|
||||
|
||||
@Inject
|
||||
public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
|
@ -11,6 +11,7 @@ import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,14 +23,17 @@ import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's Entity {@link Listener}.
|
||||
*/
|
||||
@Service
|
||||
public class MVEntityListener implements Listener {
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public MVEntityListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
|
@ -16,6 +16,7 @@ import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -30,10 +31,12 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's {@link Listener} for players.
|
||||
*/
|
||||
@Service
|
||||
public class MVPlayerListener implements Listener {
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
@ -41,6 +44,7 @@ public class MVPlayerListener implements Listener {
|
||||
|
||||
private final Map<String, String> playerWorld = new ConcurrentHashMap<String, String>();
|
||||
|
||||
@Inject
|
||||
public MVPlayerListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
worldManager = plugin.getMVWorldManager();
|
||||
|
@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.listeners;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.PortalType;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -18,14 +19,17 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.world.PortalCreateEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* A custom listener for portal related events.
|
||||
*/
|
||||
@Service
|
||||
public class MVPortalListener implements Listener {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
|
||||
@Inject
|
||||
public MVPortalListener(MultiverseCore core) {
|
||||
this.plugin = core;
|
||||
}
|
||||
|
@ -9,17 +9,21 @@ package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's Weather {@link Listener}.
|
||||
*/
|
||||
@Service
|
||||
public class MVWeatherListener implements Listener {
|
||||
private MultiverseCore plugin;
|
||||
|
||||
@Inject
|
||||
public MVWeatherListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -8,14 +8,18 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
public class MVWorldInitListener implements Listener {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
@Inject
|
||||
public MVWorldInitListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -8,24 +8,25 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's World {@link Listener}.
|
||||
*/
|
||||
@Service
|
||||
public class MVWorldListener implements Listener {
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
@Inject
|
||||
public MVWorldListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.teleportation;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.MVCore;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -18,6 +19,7 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
@ -26,6 +28,7 @@ import java.util.Set;
|
||||
/**
|
||||
* The default-implementation of {@link BlockSafety}.
|
||||
*/
|
||||
@Service
|
||||
public class SimpleBlockSafety implements BlockSafety {
|
||||
private final MVCore plugin;
|
||||
private static final Set<BlockFace> AROUND_BLOCK = EnumSet.noneOf(BlockFace.class);
|
||||
@ -41,6 +44,7 @@ public class SimpleBlockSafety implements BlockSafety {
|
||||
AROUND_BLOCK.add(BlockFace.NORTH_WEST);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public SimpleBlockSafety(MVCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collections;
|
||||
@ -25,6 +26,7 @@ import java.util.Map;
|
||||
/**
|
||||
* The default-implementation of {@link LocationManipulation}.
|
||||
*/
|
||||
@Service
|
||||
public class SimpleLocationManipulation implements LocationManipulation {
|
||||
private static final Map<String, Integer> ORIENTATION_INTS;
|
||||
|
||||
|
@ -13,6 +13,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.DestinationInstance;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -24,13 +25,16 @@ import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* The default-implementation of {@link SafeTTeleporter}.
|
||||
*/
|
||||
@Service
|
||||
public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
private MultiverseCore plugin;
|
||||
|
||||
@Inject
|
||||
public SimpleSafeTTeleporter(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -14,25 +14,28 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Multiverse's permission checker
|
||||
*/
|
||||
@Service
|
||||
public class MVPermissions {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldMgr;
|
||||
|
||||
@Inject
|
||||
public MVPermissions(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldMgr = plugin.getMVWorldManager();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,15 +2,19 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MVCore;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Wraps calls that could result in exceptions that are not Multiverse's fault.
|
||||
*/
|
||||
@Service
|
||||
public class UnsafeCallWrapper {
|
||||
private final MVCore core;
|
||||
|
||||
@Inject
|
||||
public UnsafeCallWrapper(MVCore core) {
|
||||
this.core = core;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.file.FileUtils;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.Location;
|
||||
@ -48,10 +49,12 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
/**
|
||||
* Public facing API to add/remove Multiverse worlds.
|
||||
*/
|
||||
@Service
|
||||
public class SimpleMVWorldManager implements MVWorldManager {
|
||||
private final MultiverseCore plugin;
|
||||
private final WorldPurger worldPurger;
|
||||
@ -61,6 +64,7 @@ public class SimpleMVWorldManager implements MVWorldManager {
|
||||
private Map<String, String> defaultGens;
|
||||
private String firstSpawn;
|
||||
|
||||
@Inject
|
||||
public SimpleMVWorldManager(MultiverseCore core) {
|
||||
this.plugin = core;
|
||||
this.worldsFromTheConfig = new HashMap<String, WorldProperties>();
|
||||
|
@ -1,32 +1,146 @@
|
||||
package org.mvplugins.multiverse.core.inject
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore
|
||||
import com.onarandombox.MultiverseCore.anchor.AnchorManager
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation
|
||||
import com.onarandombox.MultiverseCore.api.MVCore
|
||||
import com.onarandombox.MultiverseCore.api.MVPlugin
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager
|
||||
import com.onarandombox.MultiverseCore.economy.MVEconomist
|
||||
import com.onarandombox.MultiverseCore.listeners.MVChatListener
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener
|
||||
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.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.UnsafeCallWrapper
|
||||
import com.onarandombox.MultiverseCore.world.SimpleMVWorldManager
|
||||
import org.bukkit.Server
|
||||
import org.bukkit.plugin.PluginManager
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mvplugins.multiverse.core.TestWithMockBukkit
|
||||
import java.util.logging.Logger
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertSame
|
||||
|
||||
class InjectionTest : TestWithMockBukkit() {
|
||||
|
||||
@Test
|
||||
fun `MultiverseCore is available in its ServiceLocator as Multiverse`() {
|
||||
fun `Server is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(Server::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `PluginManager is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(PluginManager::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MultiverseCore is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MultiverseCore::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MultiverseCore is available in its ServiceLocator as MVCore`() {
|
||||
assertNotNull(multiverseCore.getService(MVCore::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MultiverseCore is available in its ServiceLocator as MVPlugin`() {
|
||||
assertNotNull(multiverseCore.getService(MVPlugin::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ServiceLocator provides same instance of MultiverseCore that the MockBukkit server creates`() {
|
||||
fun `MultiverseCore service is the same instance of MultiverseCore that the MockBukkit server creates`() {
|
||||
assertSame(multiverseCore, multiverseCore.getService(MultiverseCore::class.java));
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Logger is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(Logger::class.java));
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `AnchorManager is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(AnchorManager::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `BlockSafety is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(BlockSafety::class.java))
|
||||
assertNotNull(multiverseCore.getService(SimpleBlockSafety::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVCommandManager is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVCommandManager::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVEconomist is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVEconomist::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `LocationManipulation is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(LocationManipulation::class.java))
|
||||
assertNotNull(multiverseCore.getService(SimpleLocationManipulation::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVPermissions is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVPermissions::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `SafeTTeleporter is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(SafeTTeleporter::class.java))
|
||||
assertNotNull(multiverseCore.getService(SimpleSafeTTeleporter::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `UnsafeCallWrapper is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(UnsafeCallWrapper::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVWorldManager is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVWorldManager::class.java))
|
||||
assertNotNull(multiverseCore.getService(SimpleMVWorldManager::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVEntityListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVEntityListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVPlayerListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVPlayerListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVChatListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVChatListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVPortalListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVPortalListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVWeatherListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVWeatherListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVWorldListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVWorldListener::class.java))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MVWorldInitListener is available as a service`() {
|
||||
assertNotNull(multiverseCore.getService(MVWorldInitListener::class.java))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user