99
1010import com.dumptruckman.minecraft.util.Logging;
1111import org.mvplugins.multiverse.core.MultiverseCoreApi;
12- import org.mvplugins.multiverse.core.MultiversePlugin;
1312import org.mvplugins.multiverse.core.config.CoreConfig;
1413import org.mvplugins.multiverse.core.inject.PluginServiceLocatorFactory;
14+ import org.mvplugins.multiverse.core.module.MultiverseModule;
1515import org.mvplugins.multiverse.core.utils.StringFormatter;
1616import org.mvplugins.multiverse.netherportals.commands.NetherPortalsCommand;
1717import org.mvplugins.multiverse.netherportals.listeners.MVNPListener;
2929import org.mvplugins.multiverse.portals.MultiversePortals;
3030import org.mvplugins.multiverse.portals.utils.PortalManager;
3131
32- public class MultiverseNetherPortals extends MultiversePlugin {
32+ public class MultiverseNetherPortals extends MultiverseModule {
3333
3434 private static final double TARGET_CORE_API_VERSION = 5.0;
3535
@@ -45,15 +45,14 @@ public class MultiverseNetherPortals extends MultiversePlugin {
4545 private Map<String, String> linkMap;
4646 private Map<String, String> endLinkMap;
4747
48- private PluginServiceLocator serviceLocator;
4948 @Inject
5049 private Provider<CoreConfig> coreConfig;
5150 @Inject
5251 private Provider<MVCommandManager> commandManager;
5352
5453 @Override
5554 public void onLoad() {
56- super.onEnable ();
55+ super.onLoad ();
5756 getDataFolder().mkdirs();
5857 }
5958
@@ -71,27 +70,16 @@ public void onEnable() {
7170 return;
7271 }
7372
74- initializeDependencyInjection();
73+ initializeDependencyInjection(new MultiverseNetherPortalsPluginBinder(this) );
7574 Logging.setDebugLevel(coreConfig.get().getGlobalDebug());
7675
7776 loadConfig();
78- this.registerCommands();
77+ this.registerCommands(NetherPortalsCommand.class );
7978 this.registerEvents();
8079
8180 Logging.log(true, Level.INFO, " Enabled - By %s", StringFormatter.joinAnd(this.getDescription().getAuthors()));
8281 }
8382
84- private void initializeDependencyInjection() {
85- serviceLocator = PluginServiceLocatorFactory.get()
86- .registerPlugin(new MultiverseNetherPortalsPluginBinder(this), core.getServiceLocator())
87- .flatMap(PluginServiceLocator::enable)
88- .getOrElseThrow(exception -> {
89- Logging.severe("Failed to initialize dependency injection!");
90- getServer().getPluginManager().disablePlugin(this);
91- return new RuntimeException(exception);
92- });
93- }
94-
9583 public void loadConfig() {
9684 initMVNPConfig();
9785
@@ -159,19 +147,6 @@ private void initMVNPConfig() {
159147 }
160148 }
161149
162- /**
163- * Register commands to Multiverse's CommandHandler so we get a super sexy single menu
164- */
165- private void registerCommands() {
166- Try.of(() -> commandManager.get())
167- .andThenTry(commandManager -> serviceLocator.getAllServices(NetherPortalsCommand.class)
168- .forEach(commandManager::registerCommand))
169- .onFailure(e -> {
170- Logging.severe("Failed to register commands");
171- e.printStackTrace();
172- });
173- }
174-
175150 private void registerEvents() {
176151 var pluginManager = getServer().getPluginManager();
177152
@@ -192,11 +167,6 @@ public double getTargetCoreVersion() {
192167 return TARGET_CORE_API_VERSION;
193168 }
194169
195- @Override
196- public PluginServiceLocator getServiceLocator() {
197- return serviceLocator;
198- }
199-
200170 public void setNetherPrefix(String netherPrefix) {
201171 this.MVNPConfiguration.set("portal-auto-link-when.nether.prefix", netherPrefix);
202172 }
0 commit comments