Eagerly load core services.

This commit is contained in:
Jeremy Wood 2023-03-25 00:27:30 -04:00
parent add73be4fc
commit 750460fff0
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
10 changed files with 20 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.config.MVCoreConfigProvider;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -32,7 +33,7 @@ import java.util.Set;
* Manages anchors.
*/
@Service
public class AnchorManager {
public class AnchorManager implements EagerlyLoaded {
private Map<String, Location> anchors;
private FileConfiguration anchorConfig;

View File

@ -13,6 +13,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager;
import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import org.jetbrains.annotations.NotNull;
@ -22,7 +23,7 @@ import org.jvnet.hk2.annotations.Service;
* Main class to manage permissions.
*/
@Service
public class MVCommandManager extends PaperCommandManager {
public class MVCommandManager extends PaperCommandManager implements EagerlyLoaded {
private final CommandFlagsManager flagsManager;
private final CommandQueueManager commandQueueManager;

View File

@ -6,6 +6,7 @@ import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
import com.onarandombox.MultiverseCore.api.MVConfig;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import io.vavr.control.Option;
import io.vavr.control.Try;
import jakarta.inject.Inject;
@ -23,7 +24,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
@Service
public final class MVCoreConfigProvider {
public final class MVCoreConfigProvider implements EagerlyLoaded {
private static final String CONFIG_FILE = "config.yml";
private static final String DEFAULTS_CONFIG_FILE = "/defaults/config.yml";

View File

@ -1,5 +1,6 @@
package com.onarandombox.MultiverseCore.economy;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import org.bukkit.Material;
import org.bukkit.World;
@ -12,7 +13,7 @@ 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 {
public class MVEconomist implements EagerlyLoaded {
private final VaultHandler vaultHandler;

View File

@ -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.LocationManipulation;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import org.bukkit.Location;
import org.bukkit.Material;
@ -29,7 +30,7 @@ import java.util.Set;
* The default-implementation of {@link BlockSafety}.
*/
@Service
public class SimpleBlockSafety implements BlockSafety {
public class SimpleBlockSafety implements BlockSafety, EagerlyLoaded {
private final LocationManipulation locationManipulation;
private static final Set<BlockFace> AROUND_BLOCK = EnumSet.noneOf(BlockFace.class);

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.teleportation;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -27,7 +28,7 @@ import java.util.Map;
* The default-implementation of {@link LocationManipulation}.
*/
@Service
public class SimpleLocationManipulation implements LocationManipulation {
public class SimpleLocationManipulation implements LocationManipulation, EagerlyLoaded {
private static final Map<String, Integer> ORIENTATION_INTS;
static {

View File

@ -15,6 +15,7 @@ import com.onarandombox.MultiverseCore.api.DestinationInstance;
import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -33,7 +34,7 @@ import org.jvnet.hk2.annotations.Service;
* The default-implementation of {@link SafeTTeleporter}.
*/
@Service
public class SimpleSafeTTeleporter implements SafeTTeleporter {
public class SimpleSafeTTeleporter implements SafeTTeleporter, EagerlyLoaded {
private final MultiverseCore plugin;
private final LocationManipulation locationManipulation;
private final BlockSafety blockSafety;

View File

@ -14,6 +14,7 @@ import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.config.MVCoreConfigProvider;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -28,7 +29,7 @@ import org.jvnet.hk2.annotations.Service;
* Multiverse's permission checker
*/
@Service
public class MVPermissions {
public class MVPermissions implements EagerlyLoaded {
private final PluginManager pluginManager;
private final MVCoreConfigProvider configProvider;

View File

@ -2,6 +2,7 @@ package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.config.MVCoreConfigProvider;
import com.onarandombox.MultiverseCore.inject.EagerlyLoaded;
import jakarta.inject.Inject;
import org.jvnet.hk2.annotations.Service;
@ -11,7 +12,7 @@ import java.util.concurrent.Callable;
* Wraps calls that could result in exceptions that are not Multiverse's fault.
*/
@Service
public class UnsafeCallWrapper {
public class UnsafeCallWrapper implements EagerlyLoaded {
private final MVCoreConfigProvider configProvider;
@Inject

View File

@ -34,6 +34,7 @@ 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.inject.EagerlyLoaded;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
import com.onarandombox.MultiverseCore.utils.file.FileUtils;
@ -60,7 +61,7 @@ import org.jvnet.hk2.annotations.Service;
* Public facing API to add/remove Multiverse worlds.
*/
@Service
public class SimpleMVWorldManager implements MVWorldManager {
public class SimpleMVWorldManager implements MVWorldManager, EagerlyLoaded {
private final MultiverseCore plugin;
private final MVPlayerListener playerListener;
private final BlockSafety blockSafety;