mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 12:05:14 +01:00
Revert "Add automatic destination registration through DestinationFeature."
This reverts commit c6a2cee050
.
This commit is contained in:
parent
2a504f4360
commit
5d2e68a362
@ -16,11 +16,13 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.anchor.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.api.Destination;
|
||||
import com.onarandombox.MultiverseCore.api.MVCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfigProvider;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.inject.PluginInjection;
|
||||
import com.onarandombox.MultiverseCore.utils.TestingMode;
|
||||
import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
@ -115,6 +117,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
// TODO consider moving this into the AnchorManager constructor
|
||||
serviceLocator.getService(AnchorManager.class).loadAnchors();
|
||||
this.setUpLocales();
|
||||
this.registerDestinations();
|
||||
this.setupMetrics();
|
||||
this.saveMVConfig();
|
||||
this.logEnableMessage();
|
||||
@ -164,6 +167,15 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
commandManager.getLocales().addMessageBundles("multiverse-core");
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all the destinations.
|
||||
*/
|
||||
private void registerDestinations() {
|
||||
// TODO add automatic destination registration through hk2
|
||||
var destinationsProvider = serviceLocator.getService(DestinationsProvider.class);
|
||||
serviceLocator.getAllServices(Destination.class).forEach(destinationsProvider::registerDestination);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup bstats Metrics.
|
||||
*/
|
||||
|
@ -3,13 +3,12 @@ package com.onarandombox.MultiverseCore.api;
|
||||
import java.util.Collection;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import com.onarandombox.MultiverseCore.inject.AutoLoadedService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public interface Destination<T extends DestinationInstance> extends AutoLoadedService {
|
||||
public interface Destination<T extends DestinationInstance> {
|
||||
/**
|
||||
* Returns the identifier or prefix that is required for this destination.
|
||||
*
|
||||
|
@ -1,47 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.inject.features;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.Destination;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||
import com.onarandombox.MultiverseCore.inject.InjectionFeature;
|
||||
import com.onarandombox.MultiverseCore.inject.registration.AbstractAutoRegistration;
|
||||
import com.onarandombox.MultiverseCore.inject.registration.AutoRegistrationBinder;
|
||||
import com.onarandombox.MultiverseCore.inject.registration.RegistrationFilter;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Provider;
|
||||
import org.glassfish.hk2.api.ServiceLocator;
|
||||
import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
class DestinationFeature implements InjectionFeature {
|
||||
|
||||
@Override
|
||||
public void postServicesCreation(ServiceLocator locator) {
|
||||
ServiceLocatorUtilities.bind(locator, AutoRegistrationBinder.with(DestinationAutoRegistration.class));
|
||||
}
|
||||
|
||||
@Service
|
||||
private static final class DestinationAutoRegistration extends AbstractAutoRegistration<Destination> {
|
||||
|
||||
private final @NotNull Provider<DestinationsProvider> destinationsProviderProvider;
|
||||
|
||||
@Inject
|
||||
private DestinationAutoRegistration(
|
||||
@NotNull Provider<DestinationsProvider> destinationsProviderProvider,
|
||||
@NotNull Provider<RegistrationFilter> filterProvider
|
||||
) {
|
||||
super(filterProvider, Destination.class);
|
||||
this.destinationsProviderProvider = destinationsProviderProvider;
|
||||
}
|
||||
|
||||
private DestinationsProvider getDestinationsProvider() {
|
||||
return destinationsProviderProvider.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void register(Destination instance) {
|
||||
getDestinationsProvider().registerDestination(instance);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user