diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b93076a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test +on: + push: + branches: + - '*' +jobs: + test: + runs-on: ubuntu-latest + name: "Test" + steps: + - uses: actions/checkout@v2 + - name: Setup git + run: 'git config --global user.email "actions@github.com" && git config --global user.name "GitHub Actions"' + - name: Setup Java JDK + uses: actions/setup-java@v2.3.1 + with: + java-version: 17 + distribution: temurin + cache: 'gradle' + - name: Run tests + run: ./gradlew clean test diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 529692c..67535c1 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -2,4 +2,5 @@ dependencies { api("org.yaml:snakeyaml:1.30") compileOnlyApi("org.jetbrains:annotations:23.0.0") compileOnlyApi("net.luckperms:api:5.4") + testRuntimeOnly("net.luckperms:api:5.4") } diff --git a/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/Protocol.java b/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/Protocol.java index 23c7fd2..7852bf2 100644 --- a/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/Protocol.java +++ b/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/Protocol.java @@ -55,8 +55,8 @@ public final class Protocol, M extends Message> { public static final Protocol P_TOGGLE_GAMING_SARA = new Protocol<>(PacketFlow.TO_PROXY, 0x04, new ProxyboundToggleGamingSaraPacket()); public static final Protocol P_TOGGLE_SARA_HIDE = new Protocol<>(PacketFlow.TO_PROXY, 0x05, new ProxyboundToggleSaraHidePacket()); // non-contextual public static final Protocol P_TOGGLE_SARA_SHOW = new Protocol<>(PacketFlow.TO_PROXY, 0x06, new ProxyboundToggleSaraShowPacket()); // contextual - public static final Protocol P_SET_PREFIX = new Protocol<>(PacketFlow.TO_PROXY, 0x06, new ProxyboundSetPrefixPacket()); - public static final Protocol P_CLEAR_PREFIX = new Protocol<>(PacketFlow.TO_PROXY, 0x06, new ProxyboundClearPrefixPacket()); + public static final Protocol P_SET_PREFIX = new Protocol<>(PacketFlow.TO_PROXY, 0x07, new ProxyboundSetPrefixPacket()); + public static final Protocol P_CLEAR_PREFIX = new Protocol<>(PacketFlow.TO_PROXY, 0x08, new ProxyboundClearPrefixPacket()); public static final Protocol S_ENCRYPTION = new Protocol<>(PacketFlow.TO_SERVER, 0x00, new ServerboundEncryptionPacket()); public static final Protocol S_ACTION_RESPONSE = new Protocol<>(PacketFlow.TO_SERVER, 0x01, new ServerboundActionResponsePacket()); diff --git a/api/src/test/java/net/azisaba/azipluginmessaging/test/ProtocolTest.java b/api/src/test/java/net/azisaba/azipluginmessaging/test/ProtocolTest.java new file mode 100644 index 0000000..7535d82 --- /dev/null +++ b/api/src/test/java/net/azisaba/azipluginmessaging/test/ProtocolTest.java @@ -0,0 +1,12 @@ +package net.azisaba.azipluginmessaging.test; + +import net.azisaba.azipluginmessaging.api.protocol.PacketFlow; +import net.azisaba.azipluginmessaging.api.protocol.Protocol; +import org.junit.jupiter.api.Test; + +public class ProtocolTest { + @Test + public void load() { + Protocol.getById(PacketFlow.TO_SERVER, (byte) 0); + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 1cde183..7004d6d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,6 +35,17 @@ subprojects { repositories { mavenCentral() } + + dependencies { + testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") + } + + tasks { + test { + useJUnitPlatform() + } + } } allprojects { diff --git a/gradlew b/gradlew old mode 100644 new mode 100755