From e42c2d8ed52751d454d17727ccd6faa19f7f6864 Mon Sep 17 00:00:00 2001 From: Jackson_57 <49173011+jackson-57@users.noreply.github.com> Date: Wed, 22 Feb 2023 06:11:06 -0800 Subject: [PATCH 1/9] Fix artifact paths (#3570) --- .github/workflows/pullrequest.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 6781d7483..8d5f5c03c 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -48,34 +48,34 @@ jobs: if: success() with: name: Geyser Fabric - path: bootstrap/fabric/build/libs/Geyser-Fabric.jar + path: geyser/bootstrap/fabric/build/libs/Geyser-Fabric.jar - name: Archive artifacts (Geyser Standalone) uses: actions/upload-artifact@v2 if: success() with: name: Geyser Standalone - path: bootstrap/standalone/build/libs/Geyser-Standalone.jar + path: geyser/bootstrap/standalone/build/libs/Geyser-Standalone.jar - name: Archive artifacts (Geyser Spigot) uses: actions/upload-artifact@v2 if: success() with: name: Geyser Spigot - path: bootstrap/spigot/build/libs/Geyser-Spigot.jar + path: geyser/bootstrap/spigot/build/libs/Geyser-Spigot.jar - name: Archive artifacts (Geyser BungeeCord) uses: actions/upload-artifact@v2 if: success() with: name: Geyser BungeeCord - path: bootstrap/bungeecord/build/libs/Geyser-BungeeCord.jar + path: geyser/bootstrap/bungeecord/build/libs/Geyser-BungeeCord.jar - name: Archive artifacts (Geyser Sponge) uses: actions/upload-artifact@v2 if: success() with: name: Geyser Sponge - path: bootstrap/sponge/build/libs/Geyser-Sponge.jar + path: geyser/bootstrap/sponge/build/libs/Geyser-Sponge.jar - name: Archive artifacts (Geyser Velocity) uses: actions/upload-artifact@v2 if: success() with: name: Geyser Velocity - path: bootstrap/velocity/build/libs/Geyser-Velocity.jar + path: geyser/bootstrap/velocity/build/libs/Geyser-Velocity.jar From e50226132febee19831e95c06b1ab99538ecb625 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:11:18 -0500 Subject: [PATCH 2/9] Fix more issues of chunks not appearing --- .../java/org/geysermc/geyser/session/GeyserSession.java | 8 +++----- .../main/java/org/geysermc/geyser/util/ChunkUtils.java | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index bc49e8945..11467253e 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -180,7 +180,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { private final AdvancementsCache advancementsCache; private final BookEditCache bookEditCache; - private @org.checkerframework.checker.nullness.qual.NonNull final ChunkCache chunkCache; + private final ChunkCache chunkCache; private final EntityCache entityCache; private final EntityEffectCache effectCache; private final FormCache formCache; @@ -1410,10 +1410,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { } public void setServerRenderDistance(int renderDistance) { - // +1 is for Fabric and Spigot - // Without the client misses loading some chunks per https://github.com/GeyserMC/Geyser/issues/3490 - // Fog still appears essentially normally - renderDistance = renderDistance + 1; this.serverRenderDistance = renderDistance; ChunkRadiusUpdatedPacket chunkRadiusUpdatedPacket = new ChunkRadiusUpdatedPacket(); @@ -1425,11 +1421,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { return this.upstream.getAddress(); } + @Override public boolean sendForm(@NonNull Form form) { formCache.showForm(form); return true; } + @Override public boolean sendForm(@NonNull FormBuilder formBuilder) { formCache.showForm(formBuilder.build()); return true; diff --git a/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java b/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java index 501087f78..aacf4f4d9 100644 --- a/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.util; +import com.nukkitx.math.GenericMath; import com.nukkitx.math.vector.Vector2i; import com.nukkitx.math.vector.Vector3i; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; @@ -91,7 +92,9 @@ public class ChunkUtils { if (chunkPos == null || !chunkPos.equals(newChunkPos)) { NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket(); chunkPublisherUpdatePacket.setPosition(position); - chunkPublisherUpdatePacket.setRadius(session.getServerRenderDistance() << 4); + // Mitigates chunks not loading on 1.17.1 Paper and 1.19.3 Fabric. As of Bedrock 1.19.60. + // https://github.com/GeyserMC/Geyser/issues/3490 + chunkPublisherUpdatePacket.setRadius(GenericMath.ceil((session.getServerRenderDistance() + 1) * MathUtils.SQRT_OF_TWO) << 4); session.sendUpstreamPacket(chunkPublisherUpdatePacket); session.setLastChunkPosition(newChunkPos); From 65319c58597e73b8b8f0d8162f60fa48fc6aa8a9 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:40:29 -0500 Subject: [PATCH 3/9] Prepare for an actual 568 release --- .../main/java/org/geysermc/geyser/network/GameProtocol.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java b/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java index c76fd7b61..8a3d068f9 100644 --- a/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java +++ b/core/src/main/java/org/geysermc/geyser/network/GameProtocol.java @@ -34,6 +34,7 @@ import com.nukkitx.protocol.bedrock.v554.Bedrock_v554; import com.nukkitx.protocol.bedrock.v557.Bedrock_v557; import com.nukkitx.protocol.bedrock.v560.Bedrock_v560; import com.nukkitx.protocol.bedrock.v567.Bedrock_v567; +import com.nukkitx.protocol.bedrock.v567.Bedrock_v567patch; import org.geysermc.geyser.session.GeyserSession; import java.util.ArrayList; @@ -75,8 +76,7 @@ public final class GameProtocol { .minecraftVersion("1.19.50/1.19.51") .build()); SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC); - // So the version checker will work - SUPPORTED_BEDROCK_CODECS.add(Bedrock_v567.V567_CODEC.toBuilder() + SUPPORTED_BEDROCK_CODECS.add(Bedrock_v567patch.BEDROCK_V567PATCH.toBuilder() .protocolVersion(568) .minecraftVersion("1.19.62") .build()); From 50104c95ec52ddf1032ee6db11cf5acca9a5f15f Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Fri, 24 Feb 2023 13:32:46 -0500 Subject: [PATCH 4/9] Remove deploying Jenkinsfile step --- Jenkinsfile | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 072f99154..a61ba6b3a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,40 +24,6 @@ pipeline { } } } - - stage ('Deploy') { - when { - anyOf { - branch "master" - } - } - - steps { - rtGradleDeployer( - id: "GRADLE_DEPLOYER", - serverId: "opencollab-artifactory", - releaseRepo: "maven-releases", - snapshotRepo: "maven-snapshots" - ) - rtGradleResolver( - id: "GRADLE_RESOLVER", - serverId: "opencollab-artifactory" - ) - rtGradleRun( - usesPlugin: true, - tool: 'Gradle 7', - rootDir: "", - useWrapper: true, - buildFile: 'build.gradle.kts', - tasks: 'artifactoryPublish', - deployerId: "GRADLE_DEPLOYER", - resolverId: "GRADLE_RESOLVER" - ) - rtPublishBuildInfo( - serverId: "opencollab-artifactory" - ) - } - } } post { From a72e49527ddb48885b5bdaf57c766de8070d4c4b Mon Sep 17 00:00:00 2001 From: Redned Date: Fri, 24 Feb 2023 20:05:15 -0600 Subject: [PATCH 5/9] Simplify publish logic and move to GitHub Actions (#3579) Co-authored-by: Tim203 Co-authored-by: rtm516 --- .github/workflows/build.yml | 53 +++++++++++++++ Jenkinsfile | 37 ---------- build-logic/build.gradle.kts | 11 +-- build-logic/src/main/kotlin/extensions.kt | 3 - .../kotlin/geyser.base-conventions.gradle.kts | 25 ++++--- .../geyser.publish-conventions.gradle.kts | 32 ++------- .../chat/MessageTranslatorTest.java | 34 +++++----- .../inventory/item/CustomItemsTest.java | 14 ++-- .../collection/GeyserCollectionsTest.java | 68 ++++++++++--------- gradle/libs.versions.toml | 4 +- 10 files changed, 135 insertions(+), 146 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..160191d46 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + cache: gradle + + - name: Build + uses: gradle/gradle-build-action@v2 + with: + arguments: build + + - name: Publish to Maven Repository + if: ${{ job.status == 'success' && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }} + uses: gradle/gradle-build-action@v2 + env: + ORG_GRADLE_PROJECT_geysermcUsername: ${{ vars.DEPLOY_USER }} + ORG_GRADLE_PROJECT_geysermcPassword: ${{ secrets.DEPLOY_PASS }} + with: + arguments: publish + + - name: Publish to Downloads API + if: ${{ github.ref_name == 'master' && job.status == 'success' && github.repository == 'GeyserMC/Geyser' }} + shell: bash + run: | + # Save the private key to a file + echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa + chmod 600 id_ecdsa + # Get the version from gradle.properties + version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2) + # Copy over artifacts + scp -B -o StrictHostKeyChecking=no -i id_ecdsa bootstrap/**/build/libs/Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/files/ + # Run the build script + ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP ./handleBuild.sh geyser $version $GITHUB_RUN_ID $GITHUB_SHA + + - name: Notify Discord + if: ${{ github.repository == 'GeyserMC/Geyser' }} + uses: Tim203/actions-git-discord-webhook@main + with: + webhook_url: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ job.status }} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index a61ba6b3a..5c2eada3d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,43 +27,6 @@ pipeline { } post { - always { - script { - def changeLogSets = currentBuild.changeSets - def message = "**Changes:**" - - if (changeLogSets.size() == 0) { - message += "\n*No changes.*" - } else { - def repositoryUrl = scm.userRemoteConfigs[0].url.replace(".git", "") - def count = 0; - def extra = 0; - for (int i = 0; i < changeLogSets.size(); i++) { - def entries = changeLogSets[i].items - for (int j = 0; j < entries.length; j++) { - if (count <= 10) { - def entry = entries[j] - def commitId = entry.commitId.substring(0, 6) - message += "\n - [`${commitId}`](${repositoryUrl}/commit/${entry.commitId}) ${entry.msg}" - count++ - } else { - extra++; - } - } - } - - if (extra != 0) { - message += "\n - ${extra} more commits" - } - } - - env.changes = message - } - deleteDir() - withCredentials([string(credentialsId: 'geyser-discord-webhook', variable: 'DISCORD_WEBHOOK')]) { - discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n${changes}\n\n[**Artifacts on Jenkins**](https://ci.opencollab.dev/job/GeyserMC/job/Geyser)", footer: 'Open Collaboration Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK - } - } success { script { if (env.BRANCH_NAME == 'master') { diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index e21806660..3d1fb47f7 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { `kotlin-dsl` } @@ -10,17 +8,10 @@ repositories { } dependencies { - implementation("net.kyori", "indra-common", "2.0.6") - implementation("org.jfrog.buildinfo", "build-info-extractor-gradle", "4.26.1") + implementation("net.kyori", "indra-common", "3.0.1") implementation("com.github.johnrengelman", "shadow", "7.1.3-SNAPSHOT") // Within the gradle plugin classpath, there is a version conflict between loom and some other // plugin for databind. This fixes it: minimum 2.13.2 is required by loom. implementation("com.fasterxml.jackson.core:jackson-databind:2.14.0") } - -tasks.withType { - kotlinOptions { - jvmTarget = "16" - } -} diff --git a/build-logic/src/main/kotlin/extensions.kt b/build-logic/src/main/kotlin/extensions.kt index 0c01913d2..1e1732852 100644 --- a/build-logic/src/main/kotlin/extensions.kt +++ b/build-logic/src/main/kotlin/extensions.kt @@ -30,9 +30,6 @@ import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.provider.Provider import org.gradle.kotlin.dsl.named -fun Project.isSnapshot(): Boolean = - version.toString().endsWith("-SNAPSHOT") - fun Project.relocate(pattern: String) { tasks.named("shadowJar") { relocate(pattern, "org.geysermc.geyser.shaded.$pattern") diff --git a/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts b/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts index 44a74db3d..709867300 100644 --- a/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts @@ -1,12 +1,25 @@ plugins { `java-library` - `maven-publish` + id("net.kyori.indra") } dependencies { compileOnly("org.checkerframework", "checker-qual", "3.19.0") } +indra { + github("GeyserMC", "Geyser") { + ci(true) + issues(true) + scm(true) + } + mitLicense() + + javaVersions { + target(16) + } +} + tasks { processResources { // Spigot, BungeeCord, Velocity, Sponge, Fabric @@ -21,14 +34,4 @@ tasks { ) } } - compileJava { - options.encoding = Charsets.UTF_8.name() - } -} - -java { - sourceCompatibility = JavaVersion.VERSION_16 - targetCompatibility = JavaVersion.VERSION_16 - - withSourcesJar() } diff --git a/build-logic/src/main/kotlin/geyser.publish-conventions.gradle.kts b/build-logic/src/main/kotlin/geyser.publish-conventions.gradle.kts index 7525f97fa..036ee803c 100644 --- a/build-logic/src/main/kotlin/geyser.publish-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/geyser.publish-conventions.gradle.kts @@ -1,33 +1,9 @@ plugins { id("geyser.shadow-conventions") - id("com.jfrog.artifactory") - id("maven-publish") + id("net.kyori.indra.publishing") } -publishing { - publications { - create("mavenJava") { - groupId = project.group as String - artifactId = project.name - version = project.version as String - - from(components["java"]) - } - } -} - -artifactory { - setContextUrl("https://repo.opencollab.dev/artifactory") - publish { - repository { - setRepoKey(if (isSnapshot()) "maven-snapshots" else "maven-releases") - setMavenCompatible(true) - } - defaults { - publications("mavenJava") - setPublishArtifacts(true) - setPublishPom(true) - setPublishIvy(false) - } - } +indra { + publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/maven-snapshots") + publishReleasesTo("geysermc", "https://repo.opencollab.dev/maven-releases") } diff --git a/core/src/test/java/org/geysermc/geyser/network/translators/chat/MessageTranslatorTest.java b/core/src/test/java/org/geysermc/geyser/network/translators/chat/MessageTranslatorTest.java index e83c6f73d..a804916fa 100644 --- a/core/src/test/java/org/geysermc/geyser/network/translators/chat/MessageTranslatorTest.java +++ b/core/src/test/java/org/geysermc/geyser/network/translators/chat/MessageTranslatorTest.java @@ -27,18 +27,20 @@ package org.geysermc.geyser.network.translators.chat; import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; import org.geysermc.geyser.translator.text.MessageTranslator; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.util.HashMap; import java.util.Map; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class MessageTranslatorTest { private Map messages = new HashMap<>(); - @Before + @BeforeAll public void setUp() throws Exception { messages.put("{\"text\":\"\",\"extra\":[{\"text\":\"DoctorMad9952 joined the game\",\"color\":\"yellow\"}]}", "§r§eDoctorMad9952 joined the game"); @@ -70,27 +72,27 @@ public class MessageTranslatorTest { public void convertMessage() { for (Map.Entry entry : messages.entrySet()) { String bedrockMessage = MessageTranslator.convertMessage(entry.getKey(), "en_US"); - Assert.assertEquals("Translation of messages is incorrect", entry.getValue(), bedrockMessage); + Assertions.assertEquals(entry.getValue(), bedrockMessage, "Translation of messages is incorrect"); } } @Test public void convertMessageLenient() { - Assert.assertEquals("All newline message is not handled properly", "\n\n\n\n", MessageTranslator.convertMessageLenient("\n\n\n\n")); - Assert.assertEquals("Empty message is not handled properly", "", MessageTranslator.convertMessageLenient("")); - Assert.assertEquals("Reset before message is not handled properly", "§r§eGame Selector", MessageTranslator.convertMessageLenient("§r§eGame Selector")); - Assert.assertEquals("Unimplemented formatting chars not stripped", "Bold Underline", MessageTranslator.convertMessageLenient("§m§nBold Underline")); + Assertions.assertEquals("\n\n\n\n", MessageTranslator.convertMessageLenient("\n\n\n\n"), "All newline message is not handled properly"); + Assertions.assertEquals("", MessageTranslator.convertMessageLenient(""), "Empty message is not handled properly"); + Assertions.assertEquals("§r§eGame Selector", MessageTranslator.convertMessageLenient("§r§eGame Selector"), "Reset before message is not handled properly"); + Assertions.assertEquals("Bold Underline", MessageTranslator.convertMessageLenient("§m§nBold Underline"), "Unimplemented formatting chars not stripped"); } @Test public void convertToPlainText() { - Assert.assertEquals("JSON message is not handled properly", "Many colors here", MessageTranslator.convertToPlainText("{\"extra\":[{\"color\":\"red\",\"text\":\"M\"},{\"color\":\"gold\",\"text\":\"a\"},{\"color\":\"yellow\",\"text\":\"n\"},{\"color\":\"green\",\"text\":\"y \"},{\"color\":\"aqua\",\"text\":\"c\"},{\"color\":\"dark_purple\",\"text\":\"o\"},{\"color\":\"red\",\"text\":\"l\"},{\"color\":\"gold\",\"text\":\"o\"},{\"color\":\"yellow\",\"text\":\"r\"},{\"color\":\"green\",\"text\":\"s \"},{\"color\":\"aqua\",\"text\":\"h\"},{\"color\":\"dark_purple\",\"text\":\"e\"},{\"color\":\"red\",\"text\":\"r\"},{\"color\":\"gold\",\"text\":\"e\"}],\"text\":\"\"}", "en_US")); - Assert.assertEquals("Legacy formatted message is not handled properly (Colors)", "Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e")); - Assert.assertEquals("Legacy formatted message is not handled properly (Colors)", "Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e", "en_US")); - Assert.assertEquals("Legacy formatted message is not handled properly (Style)", "Obf Bold Strikethrough Underline Italic Reset", MessageTranslator.convertToPlainText("§kObf §lBold §mStrikethrough §nUnderline §oItalic §rReset", "en_US")); - Assert.assertEquals("Valid lenient JSON is not handled properly", "Strange", MessageTranslator.convertToPlainText("§rStrange", "en_US")); - Assert.assertEquals("Empty message is not handled properly", "", MessageTranslator.convertToPlainText("", "en_US")); - Assert.assertEquals("Whitespace is not preserved", " ", MessageTranslator.convertToPlainText(" ", "en_US")); + Assertions.assertEquals("Many colors here", MessageTranslator.convertToPlainText("{\"extra\":[{\"color\":\"red\",\"text\":\"M\"},{\"color\":\"gold\",\"text\":\"a\"},{\"color\":\"yellow\",\"text\":\"n\"},{\"color\":\"green\",\"text\":\"y \"},{\"color\":\"aqua\",\"text\":\"c\"},{\"color\":\"dark_purple\",\"text\":\"o\"},{\"color\":\"red\",\"text\":\"l\"},{\"color\":\"gold\",\"text\":\"o\"},{\"color\":\"yellow\",\"text\":\"r\"},{\"color\":\"green\",\"text\":\"s \"},{\"color\":\"aqua\",\"text\":\"h\"},{\"color\":\"dark_purple\",\"text\":\"e\"},{\"color\":\"red\",\"text\":\"r\"},{\"color\":\"gold\",\"text\":\"e\"}],\"text\":\"\"}", "en_US"), "JSON message is not handled properly"); + Assertions.assertEquals("Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e"), "Legacy formatted message is not handled properly (Colors)"); + Assertions.assertEquals("Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e", "en_US"), "Legacy formatted message is not handled properly (Colors)"); + Assertions.assertEquals("Obf Bold Strikethrough Underline Italic Reset", MessageTranslator.convertToPlainText("§kObf §lBold §mStrikethrough §nUnderline §oItalic §rReset", "en_US"), "Legacy formatted message is not handled properly (Style)"); + Assertions.assertEquals("Strange", MessageTranslator.convertToPlainText("§rStrange", "en_US"), "Valid lenient JSON is not handled properly"); + Assertions.assertEquals("", MessageTranslator.convertToPlainText("", "en_US"), "Empty message is not handled properly"); + Assertions.assertEquals(" ", MessageTranslator.convertToPlainText(" ", "en_US"), "Whitespace is not preserved"); } @Test diff --git a/core/src/test/java/org/geysermc/geyser/translator/inventory/item/CustomItemsTest.java b/core/src/test/java/org/geysermc/geyser/translator/inventory/item/CustomItemsTest.java index 145f46369..806ec4542 100644 --- a/core/src/test/java/org/geysermc/geyser/translator/inventory/item/CustomItemsTest.java +++ b/core/src/test/java/org/geysermc/geyser/translator/inventory/item/CustomItemsTest.java @@ -36,20 +36,22 @@ import org.geysermc.geyser.api.item.custom.CustomItemOptions; import org.geysermc.geyser.api.util.TriState; import org.geysermc.geyser.item.GeyserCustomItemOptions; import org.geysermc.geyser.registry.type.ItemMapping; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.util.List; import java.util.OptionalInt; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class CustomItemsTest { private ItemMapping testMappingWithDamage; private Object2IntMap tagToCustomItemWithDamage; private ItemMapping testMappingWithNoDamage; private Object2IntMap tagToCustomItemWithNoDamage; - @Before + @BeforeAll public void setup() { CustomItemOptions a = new GeyserCustomItemOptions(TriState.TRUE, OptionalInt.of(2), OptionalInt.empty()); CustomItemOptions b = new GeyserCustomItemOptions(TriState.FALSE, OptionalInt.of(5), OptionalInt.empty()); @@ -147,12 +149,12 @@ public class CustomItemsTest { public void testCustomItems() { for (Object2IntMap.Entry entry : this.tagToCustomItemWithDamage.object2IntEntrySet()) { int id = CustomItemTranslator.getCustomItem(entry.getKey(), this.testMappingWithDamage); - Assert.assertEquals(entry.getKey() + " did not produce the correct custom item", entry.getIntValue(), id); + Assertions.assertEquals(entry.getIntValue(), id, entry.getKey() + " did not produce the correct custom item"); } for (Object2IntMap.Entry entry : this.tagToCustomItemWithNoDamage.object2IntEntrySet()) { int id = CustomItemTranslator.getCustomItem(entry.getKey(), this.testMappingWithNoDamage); - Assert.assertEquals(entry.getKey() + " did not produce the correct custom item", entry.getIntValue(), id); + Assertions.assertEquals(entry.getIntValue(), id, entry.getKey() + " did not produce the correct custom item"); } } } diff --git a/core/src/test/java/org/geysermc/geyser/util/collection/GeyserCollectionsTest.java b/core/src/test/java/org/geysermc/geyser/util/collection/GeyserCollectionsTest.java index a2a9f98f6..639c79331 100644 --- a/core/src/test/java/org/geysermc/geyser/util/collection/GeyserCollectionsTest.java +++ b/core/src/test/java/org/geysermc/geyser/util/collection/GeyserCollectionsTest.java @@ -25,9 +25,11 @@ package org.geysermc.geyser.util.collection; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class GeyserCollectionsTest { private final byte[] bytes = new byte[] {(byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 2, (byte) 1}; private final boolean[] booleans = new boolean[] {true, false, false, true}; @@ -51,35 +53,35 @@ public class GeyserCollectionsTest { int lastKey = index; // Easy, understandable out-of-bounds checks - Assert.assertFalse("Map contains key bigger by one!", map.containsKey(lastKey)); - Assert.assertTrue("Map doesn't contain final key!", map.containsKey(lastKey - 1)); + Assertions.assertFalse(map.containsKey(lastKey), "Map contains key bigger by one!"); + Assertions.assertTrue(map.containsKey(lastKey - 1), "Map doesn't contain final key!"); // Ensure the first and last values do not throw an exception on get, and test getOrDefault map.get(start - 1); map.get(lastKey); - Assert.assertEquals(map.getOrDefault(start - 1, Byte.MAX_VALUE), Byte.MAX_VALUE); - Assert.assertEquals(map.getOrDefault(lastKey, Byte.MAX_VALUE), Byte.MAX_VALUE); - Assert.assertEquals(map.getOrDefault(lastKey, Byte.MIN_VALUE), Byte.MIN_VALUE); + Assertions.assertEquals(map.getOrDefault(start - 1, Byte.MAX_VALUE), Byte.MAX_VALUE); + Assertions.assertEquals(map.getOrDefault(lastKey, Byte.MAX_VALUE), Byte.MAX_VALUE); + Assertions.assertEquals(map.getOrDefault(lastKey, Byte.MIN_VALUE), Byte.MIN_VALUE); - Assert.assertEquals(map.size(), bytes.length); + Assertions.assertEquals(map.size(), bytes.length); for (int i = start; i < bytes.length; i++) { - Assert.assertTrue(map.containsKey(i)); - Assert.assertEquals(map.get(i), bytes[i - start]); + Assertions.assertTrue(map.containsKey(i)); + Assertions.assertEquals(map.get(i), bytes[i - start]); } for (int i = start - 1; i >= (start - 6); i--) { // Lower than expected check - Assert.assertFalse(i + " is in a map that starts with " + start, map.containsKey(i)); + Assertions.assertFalse(map.containsKey(i), i + " is in a map that starts with " + start); } for (int i = bytes.length + start; i < bytes.length + 5 + start; i++) { // Higher than expected check - Assert.assertFalse(i + " is in a map that ends with " + (start + bytes.length), map.containsKey(i)); + Assertions.assertFalse(map.containsKey(i), i + " is in a map that ends with " + (start + bytes.length)); } for (byte b : bytes) { - Assert.assertTrue(map.containsValue(b)); + Assertions.assertTrue(map.containsValue(b)); } } @@ -99,33 +101,33 @@ public class GeyserCollectionsTest { int lastKey = index; // Easy, understandable out-of-bounds checks - Assert.assertFalse("Map contains key bigger by one!", map.containsKey(lastKey)); - Assert.assertTrue("Map doesn't contain final key!", map.containsKey(lastKey - 1)); + Assertions.assertFalse(map.containsKey(lastKey), "Map contains key bigger by one!"); + Assertions.assertTrue(map.containsKey(lastKey - 1), "Map doesn't contain final key!"); // Ensure the first and last values do not throw an exception on get map.get(start - 1); map.get(lastKey); - Assert.assertTrue(map.getOrDefault(lastKey, true)); + Assertions.assertTrue(map.getOrDefault(lastKey, true)); - Assert.assertEquals(map.size(), booleans.length); + Assertions.assertEquals(map.size(), booleans.length); for (int i = start; i < booleans.length; i++) { - Assert.assertTrue(map.containsKey(i)); - Assert.assertEquals(map.get(i), booleans[i - start]); + Assertions.assertTrue(map.containsKey(i)); + Assertions.assertEquals(map.get(i), booleans[i - start]); } for (int i = start - 1; i >= (start - 6); i--) { // Lower than expected check - Assert.assertFalse(i + " is in a map that starts with " + start, map.containsKey(i)); + Assertions.assertFalse(map.containsKey(i), i + " is in a map that starts with " + start); } for (int i = booleans.length + start; i < booleans.length + start + 5; i++) { // Higher than expected check - Assert.assertFalse(i + " is in a map that ends with " + (start + booleans.length), map.containsKey(i)); + Assertions.assertFalse(map.containsKey(i), i + " is in a map that ends with " + (start + booleans.length)); } for (boolean b : booleans) { - Assert.assertTrue(map.containsValue(b)); + Assertions.assertTrue(map.containsValue(b)); } } @@ -145,35 +147,35 @@ public class GeyserCollectionsTest { int lastKey = index; // Easy, understandable out-of-bounds checks - Assert.assertFalse("Map contains key bigger by one!", map.containsKey(lastKey)); - Assert.assertTrue("Map doesn't contain final key!", map.containsKey(lastKey - 1)); + Assertions.assertFalse(map.containsKey(lastKey), "Map contains key bigger by one!"); + Assertions.assertTrue(map.containsKey(lastKey - 1), "Map doesn't contain final key!"); // Ensure the first and last values do not throw an exception on get, and test getOrDefault map.get(start - 1); map.get(lastKey); - Assert.assertEquals(map.getOrDefault(start - 1, Integer.MAX_VALUE), Integer.MAX_VALUE); - Assert.assertEquals(map.getOrDefault(lastKey, Integer.MAX_VALUE), Integer.MAX_VALUE); - Assert.assertEquals(map.getOrDefault(lastKey, Integer.MIN_VALUE), Integer.MIN_VALUE); + Assertions.assertEquals(map.getOrDefault(start - 1, Integer.MAX_VALUE), Integer.MAX_VALUE); + Assertions.assertEquals(map.getOrDefault(lastKey, Integer.MAX_VALUE), Integer.MAX_VALUE); + Assertions.assertEquals(map.getOrDefault(lastKey, Integer.MIN_VALUE), Integer.MIN_VALUE); - Assert.assertEquals(map.size(), ints.length); + Assertions.assertEquals(map.size(), ints.length); for (int i = start; i < ints.length; i++) { - Assert.assertTrue(map.containsKey(i)); - Assert.assertEquals(map.get(i), ints[i - start]); + Assertions.assertTrue(map.containsKey(i)); + Assertions.assertEquals(map.get(i), ints[i - start]); } for (int i = start - 1; i >= (start - 6); i--) { // Lower than expected check - Assert.assertFalse(i + " is in a map that starts with " + start, map.containsKey(i)); + Assertions.assertFalse(map.containsKey(i), i + " is in a map that starts with " + start); } for (int i = ints.length + start; i < ints.length + 5 + start; i++) { // Higher than expected check - Assert.assertFalse(i + " is in a map that ends with " + (start + ints.length), map.containsKey(i)); + Assertions.assertFalse(map.containsKey(i), i + " is in a map that ends with " + (start + ints.length)); } for (int i : ints) { - Assert.assertTrue(map.containsValue(i)); + Assertions.assertTrue(map.containsValue(i)); } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f62faa54f..8858edc68 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ mcprotocollib = "1.19.3-20230107.194116-10" packetlib = "3.0.1" adventure = "4.12.0-20220629.025215-9" adventure-platform = "4.1.2" -junit = "4.13.1" +junit = "5.9.2" checkerframework = "3.19.0" log4j = "2.17.1" jline = "3.21.0" @@ -81,7 +81,7 @@ checker-qual = { group = "org.checkerframework", name = "checker-qual", version. commodore = { group = "me.lucko", name = "commodore", version.ref = "commodore" } guava = { group = "com.google.guava", name = "guava", version.ref = "guava" } gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } -junit = { group = "junit", name = "junit", version.ref = "junit" } +junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" } mcauthlib = { group = "com.github.GeyserMC", name = "MCAuthLib", version.ref = "mcauthlib" } mcprotocollib = { group = "com.github.steveice10", name = "mcprotocollib", version.ref = "mcprotocollib" } packetlib = { group = "com.github.steveice10", name = "packetlib", version.ref = "packetlib" } From c9b58e154fe58a24fd8ef23ba522c81d67d54ba1 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 25 Feb 2023 02:36:51 +0000 Subject: [PATCH 6/9] Allow build notifcation on success or failure --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 160191d46..553e2c5b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,8 +46,8 @@ jobs: ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP ./handleBuild.sh geyser $version $GITHUB_RUN_ID $GITHUB_SHA - name: Notify Discord - if: ${{ github.repository == 'GeyserMC/Geyser' }} + if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Geyser' }} uses: Tim203/actions-git-discord-webhook@main with: webhook_url: ${{ secrets.DISCORD_WEBHOOK }} - status: ${{ job.status }} \ No newline at end of file + status: ${{ job.status }} From 806ce6c9303ae5a2673f4bf2013eb3a9e87afebb Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 25 Feb 2023 02:57:43 +0000 Subject: [PATCH 7/9] Import build secrets as env vars --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 553e2c5b2..a8e1ec152 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,9 @@ jobs: - name: Publish to Downloads API if: ${{ github.ref_name == 'master' && job.status == 'success' && github.repository == 'GeyserMC/Geyser' }} shell: bash + env: + DOWNLOADS_PRIVATE_KEY: ${{ secrets.DOWNLOADS_PRIVATE_KEY }} + DOWNLOADS_SERVER_IP: ${{ secrets.DOWNLOADS_SERVER_IP }} run: | # Save the private key to a file echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa From 9b77d43fa20ea501c4fcce0b69f533be43f070e7 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 25 Feb 2023 03:08:02 +0000 Subject: [PATCH 8/9] Testing in production --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8e1ec152..d493ffe94 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,7 @@ jobs: if: ${{ github.ref_name == 'master' && job.status == 'success' && github.repository == 'GeyserMC/Geyser' }} shell: bash env: + DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }} DOWNLOADS_PRIVATE_KEY: ${{ secrets.DOWNLOADS_PRIVATE_KEY }} DOWNLOADS_SERVER_IP: ${{ secrets.DOWNLOADS_SERVER_IP }} run: | From b0c42086ad70c0b010bbfd3084a9205bc85d05d4 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 25 Feb 2023 04:03:42 +0000 Subject: [PATCH 9/9] Fix build IDs for publishing --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d493ffe94..f83b9a901 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ jobs: # Copy over artifacts scp -B -o StrictHostKeyChecking=no -i id_ecdsa bootstrap/**/build/libs/Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/files/ # Run the build script - ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP ./handleBuild.sh geyser $version $GITHUB_RUN_ID $GITHUB_SHA + ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP ./handleBuild.sh geyser $version $GITHUB_RUN_NUMBER $GITHUB_SHA - name: Notify Discord if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Geyser' }}