Remove EagerlyLoaded from AnchorManager.

This commit is contained in:
Jeremy Wood 2023-03-26 12:45:14 -04:00
parent 472742dde8
commit 8b244e7d3b
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
3 changed files with 11 additions and 7 deletions

View File

@ -52,12 +52,13 @@ import org.jvnet.hk2.annotations.Service;
public class MultiverseCore extends JavaPlugin implements MVCore {
private static final int PROTOCOL = 50;
// Setup various managers
private ServiceLocator serviceLocator;
@Inject
private MVCoreConfigProvider configProvider;
@Inject
private Provider<MVWorldManager> worldManagerProvider;
@Inject
private MVCoreConfigProvider configProvider;
private Provider<AnchorManager> anchorManagerProvider;
// Counter for the number of plugins that have registered with us
private int pluginCount;
@ -119,8 +120,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
// this.economist = new MVEconomist(this);
// Init all the other stuff
// TODO consider moving this into the AnchorManager constructor
serviceLocator.getService(AnchorManager.class).loadAnchors();
this.loadAnchors();
this.registerEvents();
this.registerCommands();
this.setUpLocales();
@ -164,6 +164,12 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
return !getConfigProvider().getConfig().getSilentStart();
}
private void loadAnchors() {
Try.of(() -> anchorManagerProvider.get())
.onSuccess(AnchorManager::loadAnchors)
.onFailure(throwable -> Logging.severe("Failed to load anchors", throwable));
}
/**
* Function to Register all the Events needed.
*/

View File

@ -11,7 +11,6 @@ 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;
@ -33,7 +32,7 @@ import java.util.Set;
* Manages anchors.
*/
@Service
public class AnchorManager implements EagerlyLoaded {
public class AnchorManager {
private Map<String, Location> anchors;
private FileConfiguration anchorConfig;

View File

@ -18,7 +18,6 @@ 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.placeholders.MultiverseCorePlaceholders
import com.onarandombox.MultiverseCore.teleportation.SimpleBlockSafety
import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation
import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter