Also bind MultiverseCore to MVCore and MVPlugin.

This commit is contained in:
Jeremy Wood 2023-03-07 02:24:00 -05:00
parent 40637e6a88
commit de6b25db35
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
5 changed files with 22 additions and 2 deletions

View File

@ -81,10 +81,12 @@ import org.glassfish.hk2.api.MultiException;
import org.glassfish.hk2.api.ServiceLocator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jvnet.hk2.annotations.Service;
/**
* The implementation of the Multiverse-{@link MVCore}.
*/
@Service
public class MultiverseCore extends JavaPlugin implements MVCore {
private static final int PROTOCOL = 50;

View File

@ -1,5 +1,6 @@
package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.inject.binder.JavaPluginBinder;
import org.glassfish.hk2.utilities.binding.ScopedBindingBuilder;
import org.jetbrains.annotations.NotNull;
@ -12,6 +13,6 @@ class MultiverseCorePluginBinder extends JavaPluginBinder<MultiverseCore> {
@Override
protected ScopedBindingBuilder<MultiverseCore> bindPluginClass(ScopedBindingBuilder<MultiverseCore> bindingBuilder) {
return super.bindPluginClass(bindingBuilder).to(MultiverseCore.class);
return super.bindPluginClass(bindingBuilder).to(MVCore.class).to(MultiverseCore.class);
}
}

View File

@ -16,12 +16,14 @@ 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 org.jvnet.hk2.annotations.Contract;
/**
* Multiverse 2 Core API
* <p>
* This API contains a bunch of useful things you can get out of Multiverse in general!
*/
@Contract
public interface MVCore extends MVPlugin {
/**
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without

View File

@ -7,9 +7,12 @@
package com.onarandombox.MultiverseCore.api;
import org.jvnet.hk2.annotations.Contract;
/**
* This interface is implemented by every official Multiverse-plugin.
*/
@Contract
public interface MVPlugin {
/**
* Gets the reference to MultiverseCore.

View File

@ -1,6 +1,8 @@
package org.mvplugins.multiverse.core.inject
import com.onarandombox.MultiverseCore.MultiverseCore
import com.onarandombox.MultiverseCore.api.MVCore
import com.onarandombox.MultiverseCore.api.MVPlugin
import org.junit.jupiter.api.Test
import org.mvplugins.multiverse.core.TestWithMockBukkit
import kotlin.test.assertNotNull
@ -9,10 +11,20 @@ import kotlin.test.assertSame
class InjectionTest : TestWithMockBukkit() {
@Test
fun `MultiverseCore is available in its ServiceLocator`() {
fun `MultiverseCore is available in its ServiceLocator as Multiverse`() {
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`() {
assertSame(multiverseCore, multiverseCore.getService(MultiverseCore::class.java));