Skip to content

Commit

Permalink
feat: add platform-api module (fix #287)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasing committed Sep 18, 2023
1 parent ee580c7 commit 1035b3c
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 41 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Additionally, commit message lines should not exceed 100 characters.
- `extensions`, when modifying a file that is related to extensions.
- `folia`, when modifying a file inside the `platform-folia` module.
- `nukkit`, when modifying a file inside the `platform-nukkit` module.
- `platform`, when modifying a file inside the `platform-api` module.
- `scheduling`, when modifying a file that is related to scheduling.
- `scripts`, when modifying a file inside the `scripts` directory.
- `sponge`, when modifying a file inside the `platform-sponge` module.
Expand Down
28 changes: 3 additions & 25 deletions api/src/test/java/dev/hypera/chameleon/TestChameleon.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import dev.hypera.chameleon.logger.ChameleonLogger;
import dev.hypera.chameleon.logger.DummyChameleonLogger;
import dev.hypera.chameleon.platform.Platform;
import dev.hypera.chameleon.platform.PlatformChameleon;
import dev.hypera.chameleon.platform.PluginManager;
import dev.hypera.chameleon.scheduler.Scheduler;
import dev.hypera.chameleon.user.UserManager;
Expand All @@ -41,7 +40,7 @@
/**
* Dummy Chameleon implementation.
*/
public final class TestChameleon extends PlatformChameleon<Object> {
public final class TestChameleon extends Chameleon {

public static final @NotNull String PLATFORM_ID = "Test";
private final @NotNull Platform platform = new TestChameleonPlatform();
Expand All @@ -53,51 +52,30 @@ public TestChameleon() {
this(new DummyChameleonLogger());
}

/**
* Dummy Chameleon implementation constructor.
*
* @param platformPlugin Platform plugin instance.
*/
public TestChameleon(@NotNull Object platformPlugin) {
this(new DummyChameleonLogger(), platformPlugin);
}

/**
* Dummy Chameleon implementation constructor.
*
* @param logger Logger.
* @param platformPlugin Platform plugin instance.
*/
public TestChameleon(@NotNull ChameleonLogger logger, @NotNull Object platformPlugin) {
this(TestChameleonPlugin::new, logger, platformPlugin, new EventBusImpl(logger), new ExtensionMap());
}

/**
* Dummy Chameleon implementation constructor.
*
* @param logger Logger.
*/
public TestChameleon(@NotNull ChameleonLogger logger) {
this(TestChameleonPlugin::new, logger, 0, new EventBusImpl(logger), new ExtensionMap());
this(TestChameleonPlugin::new, logger, new EventBusImpl(logger), new ExtensionMap());
}

/**
* Dummy Chameleon implementation constructor.
*
* @param pluginBootstrap Chameleon plugin bootstrap.
* @param logger Logger.
* @param platformPlugin Platform plugin.
* @param eventBus Event bus.
* @param extensions Extensions.
*/
public TestChameleon(
@NotNull ChameleonPluginBootstrap pluginBootstrap,
@NotNull ChameleonLogger logger,
@NotNull Object platformPlugin,
@NotNull EventBus eventBus,
@NotNull ExtensionMap extensions
) {
super(pluginBootstrap, platformPlugin, eventBus, logger, extensions);
super(pluginBootstrap, eventBus, logger, extensions);
}

public static @NotNull ChameleonBootstrap<TestChameleon> create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class TestChameleonBootstrap extends ChameleonBootstrap<TestChameleon> {

@Override
protected @NotNull TestChameleon loadPlatform() {
return new TestChameleon(this.pluginBootstrap, this.logger, 0, this.eventBus, this.extensions);
return new TestChameleon(this.pluginBootstrap, this.logger, this.eventBus, this.extensions);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.hypera.chameleon.platform;

import static org.junit.jupiter.api.Assertions.assertEquals;

import dev.hypera.chameleon.TestChameleon;
import org.junit.jupiter.api.Test;

final class PlatformChameleonTests {

@Test
void testPlatformPlugin() {
// Make sure PlatformChameleon stores and returns the platform plugin correctly.
TestChameleon chameleon = new TestChameleon(123);
assertEquals(123, chameleon.getPlatformPlugin());
}
plugins {
id("chameleon.common")
id("java-library")
}

dependencies {
compileOnlyApi(projects.chameleonApi)
}
1 change: 1 addition & 0 deletions platform-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repositories {

dependencies {
compileOnlyApi(projects.chameleonApi)
compileOnlyApi(projects.chameleonPlatformApi)
compileOnlyApi(libs.platform.bukkit)
implementation(libs.adventure.platform.bukkit)
}
1 change: 1 addition & 0 deletions platform-bungeecord/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repositories {

dependencies {
compileOnlyApi(projects.chameleonApi)
compileOnlyApi(projects.chameleonPlatformApi)
compileOnlyApi(libs.platform.bungeecord)
implementation(libs.adventure.platform.bungeecord)
}
1 change: 1 addition & 0 deletions platform-nukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ repositories {

dependencies {
compileOnlyApi(projects.chameleonApi)
compileOnlyApi(projects.chameleonPlatformApi)
compileOnlyApi(libs.platform.nukkit)
}
1 change: 1 addition & 0 deletions platform-sponge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repositories {

dependencies {
compileOnlyApi(projects.chameleonApi)
compileOnlyApi(projects.chameleonPlatformApi)
compileOnlyApi(libs.platform.sponge) {
exclude(module = "configurate-*")
}
Expand Down
1 change: 1 addition & 0 deletions platform-velocity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ repositories {

dependencies {
compileOnlyApi(projects.chameleonApi)
compileOnlyApi(projects.chameleonPlatformApi)
compileOnlyApi(libs.platform.velocity)
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sequenceOf(
"bom",
"annotations",
"example",
"platform-api",
"platform-bukkit",
"platform-bungeecord",
"platform-folia",
Expand Down

0 comments on commit 1035b3c

Please sign in to comment.