Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ out/
.gradle/
.kotlin/
run/
runTestPaper/
build/

.DS_Store
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ plugins {

repositories {
gradlePluginPortal()
mavenLocal()
}

dependencies {
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.2.2")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.21")
implementation("net.minecrell:plugin-yml:0.6.0")
implementation("xyz.jpenilla.run-paper:xyz.jpenilla.run-paper.gradle.plugin:3.0.2") // We need to declare it in buildSrc BUG: https://github.com/gradle/gradle/issues/17559
}

sourceSets {
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ object Versions {
// tests
const val JUNIT_BOM = "6.0.0"
const val MOCKITO_CORE = "5.20.0"
const val LITEGRATION = "0.2.0"

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ repositories {
maven("https://repo.stellardrift.ca/repository/snapshots/")
maven("https://storehouse.okaeri.eu/repository/maven-public/")
maven("https://repo.mikeprimm.com/")
maven("https://repo.opencollab.dev/maven-releases")
}
2 changes: 1 addition & 1 deletion eternalcore-api-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {

id("com.gradleup.shadow")
id("net.minecrell.plugin-yml.bukkit")
id("xyz.jpenilla.run-paper") version "3.0.2"
id("xyz.jpenilla.run-paper")
}

group = "com.eternalcode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
import net.kyori.adventure.translation.GlobalTranslator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import panda.std.Blank;

public class MockAudienceProvider extends FacetAudienceProvider<Viewer, MockAudienceProvider.MockAudience> {

private static final Collection<FacetComponentFlattener.Translator<Blank>> TRANSLATORS = Facet.of();
private static final ComponentFlattener FLATTENER = FacetComponentFlattener.get(Blank.BLANK, TRANSLATORS);
private static final Collection<FacetComponentFlattener.Translator<Void>> TRANSLATORS = Facet.of();
private static final ComponentFlattener FLATTENER = FacetComponentFlattener.get(null, TRANSLATORS);

public MockAudienceProvider() {
super(GlobalTranslator.renderer().mapContext(ptr -> ptr.getOrDefault(Identity.LOCALE, Locale.US)));
Expand Down
22 changes: 21 additions & 1 deletion eternalcore-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ plugins {
`eternalcode-java`
`eternalcore-repositories`
`eternalcore-shadow-compiler`
id("xyz.jpenilla.run-paper") version "3.0.2"
id("dev.rollczi.litegration.paper") version Versions.LITEGRATION
id("xyz.jpenilla.run-paper")
}

repositories {
maven("https://repo.eternalcode.pl/releases/")
}
Comment on lines +9 to 11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This repositories block is redundant. The eternalcore-repositories convention plugin is applied on line 3, and it already includes the https://repo.eternalcode.pl/releases/ repository. You can safely remove this block to avoid duplication.


eternalShadowCompiler {
Expand Down Expand Up @@ -30,8 +35,23 @@ eternalShadowCompiler {
}
}

tasks.testPaper {
eula = true
serverVersion = "1.21.7"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The server version 1.21.7 is hardcoded. To maintain consistency and ease of updates, it's better to define this version in your buildSrc/src/main/kotlin/Versions.kt file and reference it here.

For example, you could add const val PAPER_TEST_SERVER = "1.21.7" to Versions.kt and then use Versions.PAPER_TEST_SERVER here.

}

dependencies {
implementation("com.spotify:completable-futures:${Versions.SPOTIFY_COMPLETABLE_FUTURES}")

testPaperImplementation(project(":eternalcore-core"))
testPaperImplementation(project(":eternalcore-api"))

testPaperImplementation("dev.rollczi:litegration-client-mcprotocollib:${Versions.LITEGRATION}")

testPaperImplementation(platform("org.junit:junit-bom:6.0.0"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JUnit BOM version is hardcoded. You have a JUNIT_BOM constant defined in Versions.kt. Please use it here to ensure version consistency across the project.

    testPaperImplementation(platform("org.junit:junit-bom:${Versions.JUNIT_BOM}"))

testPaperImplementation("org.spigotmc:spigot-api:${Versions.SPIGOT_API}")

testPaperImplementation("org.assertj:assertj-core:3.27.6")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The AssertJ version 3.27.6 is hardcoded. It's a good practice to manage all dependency versions in the Versions.kt file. Please add a constant for this version there and use it here.

For example, you could add const val ASSERTJ_CORE = "3.27.6" to Versions.kt and then use Versions.ASSERTJ_CORE here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the AssertJ framework, we should migrate other tests to it in near future.

}

tasks {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.eternalcode.core;

import dev.rollczi.litegration.Litegration;
import dev.rollczi.litegration.client.Client;
import dev.rollczi.litegration.client.McProtocolLibClient;
import java.util.Objects;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;

public class IntegrationBaseTest {

private final static Plugin plugin = JavaPlugin.getProvidingPlugin(EternalCoreApi.class);
private final static BukkitScheduler scheduler = Bukkit.getScheduler();


protected static void joinPlayer(String name, Consumer<Player> action) {
Litegration litegration = Litegration.getCurrent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getCurrent could be changed imo on Litegration's end, "current" in english without any context means just electricity

scheduler.runTaskAsynchronously(plugin, () -> joinPlayer(name, litegration, action));

}

private static void joinPlayer(String name, Litegration litegration, Consumer<Player> action) {
Client client = McProtocolLibClient.connected(name, litegration.getAddress(), litegration.getPort());
Player rollczi = Objects.requireNonNull(Bukkit.getPlayer(client.getName()));
scheduler.runTask(plugin, () -> {
action.accept(rollczi);
client.quit();
});
Comment on lines +28 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable rollczi is used to store the player object, but the player's name is passed as a parameter name. Using a generic name like player would make the code more readable and less confusing, as this method is intended to be a generic utility for joining any player. This change should also be reflected in the test that calls this method.

Suggested change
Player rollczi = Objects.requireNonNull(Bukkit.getPlayer(client.getName()));
scheduler.runTask(plugin, () -> {
action.accept(rollczi);
client.quit();
});
Player player = Objects.requireNonNull(Bukkit.getPlayer(client.getName()));
scheduler.runTask(plugin, () -> {
action.accept(player);
client.quit();
});

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.eternalcode.core.catboy;

import com.eternalcode.core.EternalCoreApi;
import com.eternalcode.core.EternalCoreApiProvider;
import com.eternalcode.core.IntegrationBaseTest;
import com.eternalcode.core.feature.catboy.CatboyService;
import dev.rollczi.litegration.junit.LitegrationTest;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import org.bukkit.entity.Cat;
import org.junit.jupiter.api.Test;

class CatboyServiceIntegrationTest extends IntegrationBaseTest {

@LitegrationTest
void shouldMarkAndUnmarkPlayerAsCatboy() {
EternalCoreApi api = EternalCoreApiProvider.provide();
CatboyService catboyService = api.getCatboyService();

joinPlayer("Rollczi", rollczi -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
joinPlayer("Rollczi", rollczi -> {
joinPlayer("Rollczi", player -> {

No need to use player's name as parameter, as Rollczi is the only player anyway.

catboyService.markAsCatboy(rollczi, Cat.Type.WHITE);
assertThat(catboyService.isCatboy(rollczi.getUniqueId())).isTrue();
assertThat(rollczi.getWalkSpeed()).isEqualTo(0.4F);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The walk speed value 0.4F is a magic number. It would be better to use a constant if one is defined in the production code (e.g., CatboyService.CATBOY_WALK_SPEED). This improves readability and maintainability. The same applies to the default walk speed 0.2F on line 31. If constants don't exist, consider adding them.

assertThat(rollczi.getPassengers()).hasSize(1)
.allMatch(entity -> entity instanceof Cat cat && cat.getCatType() == Cat.Type.WHITE);

catboyService.changeCatboyType(rollczi, Cat.Type.BLACK);
assertThat(rollczi.getPassengers()).hasSize(1)
.allMatch(entity -> entity instanceof Cat cat && cat.getCatType() == Cat.Type.BLACK);

catboyService.unmarkAsCatboy(rollczi);
assertThat(rollczi.getWalkSpeed()).isEqualTo(0.2F);
assertThat(rollczi.getPassengers()).isEmpty();

assertThat(catboyService.isCatboy(rollczi.getUniqueId())).isFalse();
});
}

}
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.parallel=true
org.gradle.parallel=false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Disabling parallel execution can significantly increase build times. While this might be a necessary workaround for the integration tests to function correctly, the reason for this change should be documented with a comment. This will help other developers understand the limitation and potentially re-enable it in the future if the underlying issue is resolved. The same applies to org.gradle.configuration-cache.parallel on line 6.

Copy link
Member

@Jakubk15 Jakubk15 Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rollczi Can't we toggle this off per-task?

org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache.parallel=true
org.gradle.configuration-cache.parallel=false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

#org.gradle.jvmargs=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
9 changes: 8 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ include(":eternalcore-paper")
include(":eternalcore-plugin")
include(":eternalcore-docs-api")
include(":eternalcore-docs-generate")
include(":eternalcore-api-example")
include(":eternalcore-api-example")

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://repo.eternalcode.pl/releases/")
}
}