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
64 changes: 2 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,6 @@ on:
branches: [ main, master ]

jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- paper-version: "1.21.11-R0.1-SNAPSHOT"
mockbukkit-artifactId: "mockbukkit-v1.21"
mockbukkit-version: "4.101.0"

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'

- name: Cache Maven local repository
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ matrix.paper-version }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-${{ matrix.paper-version }}-

- name: Run unit tests
run: mvn -B -Dpaper.version=${{ matrix.paper-version }} -Dmockbukkit.artifactId=${{ matrix.mockbukkit-artifactId }} -Dmockbukkit.version=${{ matrix.mockbukkit-version }} test

feature-tests:
runs-on: ubuntu-latest
needs: unit-tests
strategy:
matrix:
include:
- paper-version: "1.21.11-R0.1-SNAPSHOT"
mockbukkit-artifactId: "mockbukkit-v1.21"
mockbukkit-version: "4.101.0"

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'

- name: Cache Maven local repository
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-feature-${{ matrix.paper-version }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-feature-${{ matrix.paper-version }}-

- name: Run feature tests
run: mvn -B -Dpaper.version=${{ matrix.paper-version }} -Dmockbukkit.artifactId=${{ matrix.mockbukkit-artifactId }} -Dmockbukkit.version=${{ matrix.mockbukkit-version }} -Pfeature-tests -Dtest=*FeatureTest test

# ─────────────────────────────────────────────────────────────────────────
# Smoke tests — Paper & Folia (downloaded from api.papermc.io)
Expand All @@ -73,7 +13,7 @@ jobs:
smoke-papermc:
name: "Smoke · ${{ matrix.platform }} / MC ${{ matrix.mc-prefix }} / Java ${{ matrix.java }}"
runs-on: ubuntu-latest
needs: [unit-tests, feature-tests]
needs: []
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -205,7 +145,7 @@ jobs:
smoke-spigot:
name: "Smoke · spigot / MC ${{ matrix.mc-prefix }} / Java ${{ matrix.java }}"
runs-on: ubuntu-latest
needs: [unit-tests, feature-tests]
needs: []
strategy:
fail-fast: false
matrix:
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Tests

on:
pull_request:
branches: [ main, master ]
push:
branches: [ main, master ]

permissions:
contents: read

jobs:
unit-tests-coverage:
name: Unit Tests + Coverage
runs-on: ubuntu-latest
strategy:
matrix:
include:
- paper-version: "1.21.11-R0.1-SNAPSHOT"
mockbukkit-artifactId: "mockbukkit-v1.21"
mockbukkit-version: "4.101.0"

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
cache: maven

- name: Run unit tests with JaCoCo
run: >
mvn -B -ntp
-Dpaper.version=${{ matrix.paper-version }}
-Dmockbukkit.artifactId=${{ matrix.mockbukkit-artifactId }}
-Dmockbukkit.version=${{ matrix.mockbukkit-version }}
jacoco:prepare-agent test jacoco:report

- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: unit-coverage-report
path: target/site/jacoco/jacoco.xml
if-no-files-found: error
retention-days: 7

- name: Upload unit coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: target/site/jacoco/jacoco.xml
flags: unit-tests
name: unit-tests
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

feature-tests-coverage:
name: Feature Tests + Coverage
runs-on: ubuntu-latest
strategy:
matrix:
include:
- paper-version: "1.21.11-R0.1-SNAPSHOT"
mockbukkit-artifactId: "mockbukkit-v1.21"
mockbukkit-version: "4.101.0"

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
cache: maven

- name: Run feature tests with JaCoCo
run: >
mvn -B -ntp
-Dpaper.version=${{ matrix.paper-version }}
-Dmockbukkit.artifactId=${{ matrix.mockbukkit-artifactId }}
-Dmockbukkit.version=${{ matrix.mockbukkit-version }}
-Pfeature-tests -Dtest=*FeatureTest
jacoco:prepare-agent test jacoco:report

- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: feature-coverage-report
path: target/site/jacoco/jacoco.xml
if-no-files-found: error
retention-days: 7

- name: Upload feature coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: target/site/jacoco/jacoco.xml
flags: feature-tests
name: feature-tests
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ pom.xml.next
*.iml
*.ipr
*.iws
/.vscode/
/.vscode/*
!/.vscode/settings.json
!/.vscode/tasks.json
!/.vscode/extensions.json
/out/

# Eclipse
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ryanluker.vscode-coverage-gutters"
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"java.debug.settings.onBuildFailureProceed": true,
"java.configuration.updateBuildConfiguration": "automatic",
"coverage-gutters.coverageBaseDir": "${workspaceFolder}",
"coverage-gutters.coverageFileNames": [
"jacoco.xml"
],
"coverage-gutters.showLineCoverage": true,
"coverage-gutters.showRulerCoverage": true,
"coverage-gutters.showGutterCoverage": true
}
35 changes: 35 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Tests: Unit Coverage (JaCoCo)",
"type": "shell",
"command": "mvn",
"args": [
"-B",
"-ntp",
"jacoco:prepare-agent",
"test",
"jacoco:report"
],
"group": "test",
"problemMatcher": []
},
{
"label": "Tests: Feature Coverage (JaCoCo)",
"type": "shell",
"command": "mvn",
"args": [
"-B",
"-ntp",
"-Pfeature-tests",
"-Dtest=*FeatureTest",
"jacoco:prepare-agent",
"test",
"jacoco:report"
],
"group": "test",
"problemMatcher": []
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EzCountdown
[![CI](https://github.com/ez-plugins/EzCountdown/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-plugins/EzCountdown/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/ez-plugins/EzCountdown)](https://github.com/ez-plugins/EzCountdown/releases) [![License](https://img.shields.io/github/license/ez-plugins/EzCountdown)](https://github.com/ez-plugins/EzCountdown/blob/main/LICENSE) [![Issues](https://img.shields.io/github/issues/ez-plugins/EzCountdown)](https://github.com/ez-plugins/EzCountdown/issues)
[![CI](https://github.com/ez-plugins/EzCountdown/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-plugins/EzCountdown/actions/workflows/ci.yml) [![Coverage](https://codecov.io/gh/ez-plugins/EzCountdown/branch/main/graph/badge.svg)](https://codecov.io/gh/ez-plugins/EzCountdown) [![Release](https://img.shields.io/github/v/release/ez-plugins/EzCountdown)](https://github.com/ez-plugins/EzCountdown/releases) [![License](https://img.shields.io/github/license/ez-plugins/EzCountdown)](https://github.com/ez-plugins/EzCountdown/blob/main/LICENSE) [![Issues](https://img.shields.io/github/issues/ez-plugins/EzCountdown)](https://github.com/ez-plugins/EzCountdown/issues)

EzCountdown provides configurable countdown timers for events, launches, and maintenance windows across your server.

Expand Down
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,23 @@
<version>3.0.0-M7</version>
<configuration>
<useModulePath>false</useModulePath>
<argLine>-Dnet.bytebuddy.experimental=true</argLine>
<argLine>${argLine} -Dnet.bytebuddy.experimental=true</argLine>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
<include>**/*TestCase.java</include>
<include>**/*UnitTest.java</include>
</includes>
<excludes>
<exclude>**/*FeatureTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down Expand Up @@ -312,6 +323,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<argLine>${argLine} -Dnet.bytebuddy.experimental=true</argLine>
<includes>
<include>**/*FeatureTest.java</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public ActionResult handle(InventoryClickEvent event, Player player, String cdNa
registry.scheduler().runTask(() -> registry.gui().editorMenu().openEditor(player, cd));
return;
}
try {
Sound.valueOf(value.toUpperCase(Locale.ROOT));
String normalized = value.toUpperCase(Locale.ROOT);
boolean exists = java.util.Arrays.stream(Sound.values()).anyMatch(s -> s.name().equals(normalized));
if (exists) {
cd.setEndSound(value.toUpperCase(Locale.ROOT));
manager.save();
player.sendMessage(messageManager.message("gui.edit.saved", java.util.Map.of("name", cdName)));
registry.scheduler().runTask(() -> registry.gui().editorMenu().openEditor(player, cd));
} catch (IllegalArgumentException ex) {
} else {
player.sendMessage(org.bukkit.ChatColor.RED + "Invalid sound name: " + value);
SoundEditorHelper.sendAvailableSounds(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public ActionResult handle(InventoryClickEvent event, Player player, String cdNa
registry.scheduler().runTask(() -> registry.gui().editorMenu().openEditor(player, cd));
return;
}
try {
Sound.valueOf(value.toUpperCase(Locale.ROOT));
String normalized = value.toUpperCase(Locale.ROOT);
boolean exists = java.util.Arrays.stream(Sound.values()).anyMatch(s -> s.name().equals(normalized));
if (exists) {
cd.setStartSound(value.toUpperCase(Locale.ROOT));
manager.save();
player.sendMessage(messageManager.message("gui.edit.saved", java.util.Map.of("name", cdName)));
registry.scheduler().runTask(() -> registry.gui().editorMenu().openEditor(player, cd));
} catch (IllegalArgumentException ex) {
} else {
player.sendMessage(org.bukkit.ChatColor.RED + "Invalid sound name: " + value);
SoundEditorHelper.sendAvailableSounds(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ static void sendAvailableSounds(Player player) {
}

private static String soundName(Sound sound) {
if (sound == null) {
return "";
}
try {
java.lang.reflect.Method nameMethod = sound.getClass().getMethod("name");
Object value = nameMethod.invoke(sound);
if (value instanceof String s) {
return s;
}
} catch (Exception ignored) {
// Fallback for API variants where Sound is not a Java enum type.
}
return String.valueOf(sound);
return sound == null ? "" : sound.name();
}
}
Loading
Loading