Skip to content
Merged
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release/v7
schedule:
- cron: "0 0 * * 0"

Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- master
- release/v7
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -79,13 +80,6 @@ jobs:
mc_version: "1.21.3"
java_image: "java21"
spongeversion: "1.21.3-13.0.0"
# Sponge API 7 (Legacy - MC 1.12.2, Java 8)
- platform: Sponge7-1.12.2
task: testSponge7
build_task: ":BanManagerSponge7:shadowJar"
compose_dir: platforms/sponge7
mc_version: "1.12.2"
java_image: "java8"
# Velocity Proxy
- platform: Velocity
task: testVelocity
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/CommonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ fun Project.applyCommonConfiguration() {
}
}

// Only set Java 1.8 for non-Fabric modules
// Set Java 17 for non-Fabric modules (aligns with BanManager v8 baseline)
// Fabric uses toolchain configuration in its build.gradle.kts
plugins.withId("java") {
if (!plugins.hasPlugin("fabric-loom")) {
the<JavaPluginExtension>().setSourceCompatibility("1.8")
the<JavaPluginExtension>().setTargetCompatibility("1.8")
the<JavaPluginExtension>().setSourceCompatibility("17")
the<JavaPluginExtension>().setTargetCompatibility("17")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public CommonPlayerDeniedListener(WebEnhancerPlugin plugin) {
}

public void handlePin(PlayerData player, Message message) {
if (!message.toString().contains("[pin]")) return;
String template = message.getRawTemplate();
if (template == null || !template.contains("<pin>")) return;

PlayerPinData pin = plugin.getPlayerPinStorage().getValidPin(player);


if (pin != null) {
message.set("pin", String.valueOf(pin.getGeneratedPin()));
}
Expand Down
9 changes: 6 additions & 3 deletions common/src/main/resources/messages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Message templates use MiniMessage formatting: https://docs.advntr.dev/minimessage/format.html
# Placeholders use angle brackets, e.g. <pin>, <expires>, <seconds>

messages:
pin:
notify: '&6Your pin expires in [expires]'
pin: '[pin]'
rateLimited: '&cPlease wait [seconds] seconds before generating a new pin'
notify: '<gold>Your pin expires in <expires>'
pin: '<pin>'
rateLimited: '<red>Please wait <seconds> seconds before generating a new pin'
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ public void setUp() {

@Test
public void handlePin_replacesPlaceholderWithPin() {
// Setup
when(playerPinStorage.getValidPin(player)).thenReturn(pinData);
when(pinData.getGeneratedPin()).thenReturn(123456);

// Create a mocked message with [pin] placeholder
Message message = mock(Message.class);
when(message.toString()).thenReturn("Your login pin is: [pin]");
when(message.getRawTemplate()).thenReturn("Your login pin is: <pin>");

listener.handlePin(player, message);

Expand All @@ -54,9 +52,19 @@ public void handlePin_replacesPlaceholderWithPin() {

@Test
public void handlePin_ignoresMessagesWithoutPlaceholder() {
// Create a mocked message without [pin] placeholder
Message message = mock(Message.class);
when(message.toString()).thenReturn("You have been banned!");
when(message.getRawTemplate()).thenReturn("You have been banned!");

listener.handlePin(player, message);

verify(playerPinStorage, never()).getValidPin(any());
verify(message, never()).set(anyString(), anyString());
}

@Test
public void handlePin_ignoresMessagesWithNullTemplate() {
Message message = mock(Message.class);
when(message.getRawTemplate()).thenReturn(null);

listener.handlePin(player, message);

Expand All @@ -66,12 +74,10 @@ public void handlePin_ignoresMessagesWithoutPlaceholder() {

@Test
public void handlePin_handlesNullPinGracefully() {
// Setup - getValidPin returns null
when(playerPinStorage.getValidPin(player)).thenReturn(null);

// Create a mocked message with [pin] placeholder
Message message = mock(Message.class);
when(message.toString()).thenReturn("Your login pin is: [pin]");
when(message.getRawTemplate()).thenReturn("Your login pin is: <pin>");

listener.handlePin(player, message);

Expand Down
64 changes: 1 addition & 63 deletions e2e/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ tasks.register<Copy>("copyBanManagerSpongeJar") {
from(file("${banManagerDir.absolutePath}/sponge/build/libs/BanManagerSponge.jar"))
}

tasks.register<Copy>("copyBanManagerSponge7Jar") {
group = "verification"
description = "Copy BanManager Sponge7 shadow JAR to e2e/jars"

into(file("jars"))
from(file("${banManagerDir.absolutePath}/sponge-api7/build/libs/BanManagerSponge7.jar"))
}

tasks.register<Copy>("copyWebEnhancerBukkitJar") {
group = "verification"
description = "Copy WebEnhancer Bukkit JAR to e2e/jars"
Expand Down Expand Up @@ -98,18 +90,6 @@ tasks.register<Copy>("copyWebEnhancerSpongeJar") {
}
}

tasks.register<Copy>("copyWebEnhancerSponge7Jar") {
group = "verification"
description = "Copy WebEnhancer Sponge7 JAR to e2e/jars"

dependsOn(":BanManagerWebEnhancerSponge7:shadowJar")

into(file("jars"))
from(project(":BanManagerWebEnhancerSponge7").tasks.named("shadowJar")) {
rename { "BanManagerWebEnhancerSponge7.jar" }
}
}

// Velocity JAR copy tasks
tasks.register<Copy>("copyBanManagerVelocityJar") {
group = "verification"
Expand Down Expand Up @@ -314,20 +294,6 @@ tasks.register("testSpongeAll") {
}
}

// Sponge7 (Legacy API 7 / MC 1.12.2) E2E tests
tasks.register("prepareSponge7Jars") {
group = "verification"
description = "Prepare Sponge7 (legacy) plugin JARs for E2E tests"
dependsOn("copyBanManagerSponge7Jar", "copyWebEnhancerSponge7Jar")
}

createPlatformTestTask(
"testSponge7",
"sponge7",
"prepareSponge7Jars",
"Run Sponge7 (legacy API 7 / MC 1.12.2) E2E tests in Docker"
)

// Velocity E2E tests
tasks.register("prepareVelocityJars") {
group = "verification"
Expand Down Expand Up @@ -543,34 +509,6 @@ tasks.register<Exec>("logsSponge") {
commandLine("docker", "compose", "logs", "-f", "sponge")
}

// Sponge7 debug tasks
tasks.register<Exec>("startSponge7") {
group = "verification"
description = "Start the Sponge7 (legacy) test server without running tests (for debugging)"

dependsOn("prepareSponge7Jars")

workingDir = file("platforms/sponge7")
commandLine("docker", "compose", "up", "-d", "mariadb", "sponge7")
}

tasks.register<Exec>("stopSponge7") {
group = "verification"
description = "Stop the Sponge7 test server"

workingDir = file("platforms/sponge7")
commandLine("docker", "compose", "down", "-v")
isIgnoreExitValue = true
}

tasks.register<Exec>("logsSponge7") {
group = "verification"
description = "Show Sponge7 server logs"

workingDir = file("platforms/sponge7")
commandLine("docker", "compose", "logs", "-f", "sponge7")
}

// Velocity debug tasks
tasks.register<Exec>("startVelocity") {
group = "verification"
Expand Down Expand Up @@ -629,7 +567,7 @@ tasks.register<Exec>("logsBungee") {

tasks.named("clean") {
doLast {
listOf("bukkit", "fabric", "sponge", "sponge7", "velocity", "bungee").forEach { platform ->
listOf("bukkit", "fabric", "sponge", "velocity", "bungee").forEach { platform ->
ProcessBuilder("docker", "compose", "down", "-v", "--rmi", "local")
.directory(file("platforms/$platform"))
.inheritIO()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
messages:
pin:
notify: '&6Your pin expires in [expires]'
pin: '[pin]'

notify: '<gold>Your pin expires in <expires>'
pin: '<pin>'
rateLimited: '<red>Please wait <seconds> seconds before generating a new pin'
Loading
Loading