Skip to content

Commit 6d3fa3a

Browse files
authored
chore: drop Sponge7 support, bump to Java 17, extend CI to release/v7 (#40)
Realigns this repo with **BanManager v8.0.0-SNAPSHOT** on `master` after BanManager dropped its legacy Sponge API 7 (MC 1.12.2 / Java 8) module, then carries the WebEnhancer pin feature forward onto v8's MiniMessage-based message pipeline so the full E2E matrix passes against v8. ### Drop Sponge7 (mirrors BanManager v8) - Remove `sponge-api7/` source module (build script, `SpongePlugin`, `SpongeCommand`, `SpongeMetrics`, `LogServerAppender`, `ReportListener`, bundled assets symlink). - Remove `e2e/platforms/sponge7/` Docker compose + bundled configs. - Drop `:BanManagerWebEnhancerSponge7` from `settings.gradle.kts`. - Strip Sponge7 jar copy / test / debug tasks from `e2e/build.gradle.kts` and remove `"sponge7"` from the e2e `clean` platform list. - Remove the `Sponge7-1.12.2` entry from the e2e workflow matrix. ### Bump baseline to Java 17 - `buildSrc/src/main/kotlin/CommonConfig.kt`: source/target compatibility 1.8 → 17 for non-Fabric modules. - Sponge module already overrides to Java 21; Fabric uses its own toolchain; CI already provisions JDK 21 as default. ### Extend CI to `release/v7` - `.github/workflows/build.yml` and `.github/workflows/e2e.yml` now trigger on push to `release/v7` (in addition to `master` / PRs / scheduled / dispatch). ### Migrate pin feature to BanManager v8 placeholder syntax BanManager v8 rejects legacy `&`-code messages outright and uses MiniMessage `<token>` placeholders instead of `[token]`. Updates required so the WebEnhancer pin survives v8: - `CommonPlayerDeniedListener.handlePin` now inspects `Message.getRawTemplate()` and looks for `<pin>` (not `[pin]` via `toString()`); skips early when the template is missing or doesn't contain the placeholder. Mirror the change in `CommonPlayerDeniedListenerTest` (mocks `getRawTemplate()`, adds null-template case). - Rewrite the bundled `common/src/main/resources/messages.yml` (the WebEnhancer defaults) to MiniMessage with `<pin>`, `<expires>`, `<seconds>`. - Rewrite every `e2e/platforms/*/configs/banmanager-webenhancer/messages.yml` fixture to match. - Replace each `e2e/platforms/*/configs/banmanager/messages.yml` fixture with a minimal MiniMessage override – only the `ban` / `tempban` / `banip` / `tempbanip` `disallowed` + `kick` templates carry `<pin>`; everything else falls through to BanManager v8's bundled defaults so the override stays small. ### Fix nested kick-reason extraction in E2E helpers MiniMessage renders nested-color templates (`<gold>A<dark_red>B<gold>C`) as nested chat components, and Paper 1.20.3+ / newer Fabric versions deliver disconnects as NBT compounds. The previous `extractNbtText` only walked top-level `extra[*].text`, which truncated the kick reason at the first nested segment and hid the `. Your appeal pin is <pin>` tail. Result: every Online Kick Pin Placeholder test failed except Fabric-1.20.1 (still on JSON disconnects). - `extractNbtText` now recurses into each `extra[*]` list item. - New `extractJsonText` helper applies the same recursion to JSON chat components, replacing the shallow `extra.map(e => e.text)` that had the same bug for nested JSON payloads (Velocity / Sponge login-denial kicks). ### CI All 12 required checks green: Java 21 - mariadb, Java 21 - h2, plus E2E for Bukkit, Fabric-1.20.1 / 1.21.1 / 1.21.4 / 1.21.11, Sponge-1.20.6 / 1.21.1 / 1.21.3, Velocity, BungeeCord. ### Notes - Replaces the closed PR #39 (CI-only); both fixes consolidated here so master goes green in one merge. - WebEnhancer `release/v7` already shipped `v7.11.0` with Sponge7 support; this PR only changes `master`.
1 parent aa4d458 commit 6d3fa3a

37 files changed

Lines changed: 157 additions & 3562 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- release/v7
89
schedule:
910
- cron: "0 0 * * 0"
1011

.github/workflows/e2e.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
push:
99
branches:
1010
- master
11+
- release/v7
1112
workflow_dispatch:
1213

1314
jobs:
@@ -79,13 +80,6 @@ jobs:
7980
mc_version: "1.21.3"
8081
java_image: "java21"
8182
spongeversion: "1.21.3-13.0.0"
82-
# Sponge API 7 (Legacy - MC 1.12.2, Java 8)
83-
- platform: Sponge7-1.12.2
84-
task: testSponge7
85-
build_task: ":BanManagerSponge7:shadowJar"
86-
compose_dir: platforms/sponge7
87-
mc_version: "1.12.2"
88-
java_image: "java8"
8983
# Velocity Proxy
9084
- platform: Velocity
9185
task: testVelocity

buildSrc/src/main/kotlin/CommonConfig.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ fun Project.applyCommonConfiguration() {
3030
}
3131
}
3232

33-
// Only set Java 1.8 for non-Fabric modules
33+
// Set Java 17 for non-Fabric modules (aligns with BanManager v8 baseline)
3434
// Fabric uses toolchain configuration in its build.gradle.kts
3535
plugins.withId("java") {
3636
if (!plugins.hasPlugin("fabric-loom")) {
37-
the<JavaPluginExtension>().setSourceCompatibility("1.8")
38-
the<JavaPluginExtension>().setTargetCompatibility("1.8")
37+
the<JavaPluginExtension>().setSourceCompatibility("17")
38+
the<JavaPluginExtension>().setTargetCompatibility("17")
3939
}
4040
}
4141
}

common/src/main/java/me/confuser/banmanager/webenhancer/common/listeners/CommonPlayerDeniedListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public CommonPlayerDeniedListener(WebEnhancerPlugin plugin) {
1313
}
1414

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

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

20-
2121
if (pin != null) {
2222
message.set("pin", String.valueOf(pin.getGeneratedPin()));
2323
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Message templates use MiniMessage formatting: https://docs.advntr.dev/minimessage/format.html
2+
# Placeholders use angle brackets, e.g. <pin>, <expires>, <seconds>
3+
14
messages:
25
pin:
3-
notify: '&6Your pin expires in [expires]'
4-
pin: '[pin]'
5-
rateLimited: '&cPlease wait [seconds] seconds before generating a new pin'
6+
notify: '<gold>Your pin expires in <expires>'
7+
pin: '<pin>'
8+
rateLimited: '<red>Please wait <seconds> seconds before generating a new pin'

common/src/test/java/me/confuser/banmanager/webenhancer/common/listeners/CommonPlayerDeniedListenerTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ public void setUp() {
3939

4040
@Test
4141
public void handlePin_replacesPlaceholderWithPin() {
42-
// Setup
4342
when(playerPinStorage.getValidPin(player)).thenReturn(pinData);
4443
when(pinData.getGeneratedPin()).thenReturn(123456);
4544

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

5048
listener.handlePin(player, message);
5149

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

5553
@Test
5654
public void handlePin_ignoresMessagesWithoutPlaceholder() {
57-
// Create a mocked message without [pin] placeholder
5855
Message message = mock(Message.class);
59-
when(message.toString()).thenReturn("You have been banned!");
56+
when(message.getRawTemplate()).thenReturn("You have been banned!");
57+
58+
listener.handlePin(player, message);
59+
60+
verify(playerPinStorage, never()).getValidPin(any());
61+
verify(message, never()).set(anyString(), anyString());
62+
}
63+
64+
@Test
65+
public void handlePin_ignoresMessagesWithNullTemplate() {
66+
Message message = mock(Message.class);
67+
when(message.getRawTemplate()).thenReturn(null);
6068

6169
listener.handlePin(player, message);
6270

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

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

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

7682
listener.handlePin(player, message);
7783

e2e/build.gradle.kts

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ tasks.register<Copy>("copyBanManagerSpongeJar") {
4747
from(file("${banManagerDir.absolutePath}/sponge/build/libs/BanManagerSponge.jar"))
4848
}
4949

50-
tasks.register<Copy>("copyBanManagerSponge7Jar") {
51-
group = "verification"
52-
description = "Copy BanManager Sponge7 shadow JAR to e2e/jars"
53-
54-
into(file("jars"))
55-
from(file("${banManagerDir.absolutePath}/sponge-api7/build/libs/BanManagerSponge7.jar"))
56-
}
57-
5850
tasks.register<Copy>("copyWebEnhancerBukkitJar") {
5951
group = "verification"
6052
description = "Copy WebEnhancer Bukkit JAR to e2e/jars"
@@ -98,18 +90,6 @@ tasks.register<Copy>("copyWebEnhancerSpongeJar") {
9890
}
9991
}
10092

101-
tasks.register<Copy>("copyWebEnhancerSponge7Jar") {
102-
group = "verification"
103-
description = "Copy WebEnhancer Sponge7 JAR to e2e/jars"
104-
105-
dependsOn(":BanManagerWebEnhancerSponge7:shadowJar")
106-
107-
into(file("jars"))
108-
from(project(":BanManagerWebEnhancerSponge7").tasks.named("shadowJar")) {
109-
rename { "BanManagerWebEnhancerSponge7.jar" }
110-
}
111-
}
112-
11393
// Velocity JAR copy tasks
11494
tasks.register<Copy>("copyBanManagerVelocityJar") {
11595
group = "verification"
@@ -314,20 +294,6 @@ tasks.register("testSpongeAll") {
314294
}
315295
}
316296

317-
// Sponge7 (Legacy API 7 / MC 1.12.2) E2E tests
318-
tasks.register("prepareSponge7Jars") {
319-
group = "verification"
320-
description = "Prepare Sponge7 (legacy) plugin JARs for E2E tests"
321-
dependsOn("copyBanManagerSponge7Jar", "copyWebEnhancerSponge7Jar")
322-
}
323-
324-
createPlatformTestTask(
325-
"testSponge7",
326-
"sponge7",
327-
"prepareSponge7Jars",
328-
"Run Sponge7 (legacy API 7 / MC 1.12.2) E2E tests in Docker"
329-
)
330-
331297
// Velocity E2E tests
332298
tasks.register("prepareVelocityJars") {
333299
group = "verification"
@@ -543,34 +509,6 @@ tasks.register<Exec>("logsSponge") {
543509
commandLine("docker", "compose", "logs", "-f", "sponge")
544510
}
545511

546-
// Sponge7 debug tasks
547-
tasks.register<Exec>("startSponge7") {
548-
group = "verification"
549-
description = "Start the Sponge7 (legacy) test server without running tests (for debugging)"
550-
551-
dependsOn("prepareSponge7Jars")
552-
553-
workingDir = file("platforms/sponge7")
554-
commandLine("docker", "compose", "up", "-d", "mariadb", "sponge7")
555-
}
556-
557-
tasks.register<Exec>("stopSponge7") {
558-
group = "verification"
559-
description = "Stop the Sponge7 test server"
560-
561-
workingDir = file("platforms/sponge7")
562-
commandLine("docker", "compose", "down", "-v")
563-
isIgnoreExitValue = true
564-
}
565-
566-
tasks.register<Exec>("logsSponge7") {
567-
group = "verification"
568-
description = "Show Sponge7 server logs"
569-
570-
workingDir = file("platforms/sponge7")
571-
commandLine("docker", "compose", "logs", "-f", "sponge7")
572-
}
573-
574512
// Velocity debug tasks
575513
tasks.register<Exec>("startVelocity") {
576514
group = "verification"
@@ -629,7 +567,7 @@ tasks.register<Exec>("logsBungee") {
629567

630568
tasks.named("clean") {
631569
doLast {
632-
listOf("bukkit", "fabric", "sponge", "sponge7", "velocity", "bungee").forEach { platform ->
570+
listOf("bukkit", "fabric", "sponge", "velocity", "bungee").forEach { platform ->
633571
ProcessBuilder("docker", "compose", "down", "-v", "--rmi", "local")
634572
.directory(file("platforms/$platform"))
635573
.inheritIO()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
messages:
22
pin:
3-
notify: '&6Your pin expires in [expires]'
4-
pin: '[pin]'
5-
3+
notify: '<gold>Your pin expires in <expires>'
4+
pin: '<pin>'
5+
rateLimited: '<red>Please wait <seconds> seconds before generating a new pin'

0 commit comments

Comments
 (0)