diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index 1054e22..1967602 100644 --- a/.github/workflows/build_and_push.yml +++ b/.github/workflows/build_and_push.yml @@ -9,9 +9,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -21,16 +21,16 @@ jobs: caches- - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 17 + java-version: 21 - name: Build with Gradle run: ./gradlew build - name: Upload-Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: artifact path: build/libs/ @@ -51,9 +51,9 @@ jobs: echo IMAGE_NAME=${GITHUB_REPOSITORY,,} >>${GITHUB_ENV} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: artifact path: build/libs/ @@ -62,7 +62,7 @@ jobs: run: cp build/libs/galaxy-proxy-1.0-SNAPSHOT.jar docker/plugins - name: Log in to the Container registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} diff --git a/Dockerfile b/Dockerfile index 49823ad..cdd97dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /app COPY --chown=1000 --link docker /app # Download Velocity -ADD --chown=1000 --link https://api.papermc.io/v2/projects/velocity/versions/3.3.0-SNAPSHOT/builds/312/downloads/velocity-3.3.0-SNAPSHOT-312.jar /app/velocity.jar +ADD --chown=1000 --link https://api.papermc.io/v2/projects/velocity/versions/3.3.0-SNAPSHOT/builds/414/downloads/velocity-3.3.0-SNAPSHOT-414.jar /app/velocity.jar # Run Server EXPOSE 25565 diff --git a/build.gradle b/build.gradle index d91fcb0..b9bdb7e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,9 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { - id 'org.jetbrains.kotlin.jvm' version '1.9.22' - id "org.jetbrains.kotlin.kapt" version "1.9.22" - id 'com.github.johnrengelman.shadow' version '8.1.1' + id 'org.jetbrains.kotlin.jvm' version '2.0.10' + id "org.jetbrains.kotlin.kapt" version "2.0.10" + id 'com.gradleup.shadow' version '8.3.0' } group 'one.oktw' @@ -23,16 +25,16 @@ repositories { dependencies { kapt 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT' compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT' - implementation 'io.fabric8:kubernetes-client:6.9.2' - implementation 'io.fabric8:kubernetes-httpclient-okhttp:6.9.2' + implementation 'io.fabric8:kubernetes-client:6.13.3' + implementation 'io.fabric8:kubernetes-httpclient-okhttp:6.13.3' implementation 'com.github.fkorotkov:k8s-kotlin-dsl:3.3.0' - implementation 'io.lettuce:lettuce-core:6.3.0.RELEASE' + implementation 'io.lettuce:lettuce-core:6.4.0.RELEASE' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive' // lettuce need this - implementation 'one.oktw:galaxy-lib:9a964eaf' + implementation 'one.oktw:galaxy-lib:7376fcdf' } compileKotlin { - kotlinOptions.jvmTarget = "17" + compilerOptions.jvmTarget = JvmTarget.JVM_21 } tasks.withType(AbstractArchiveTask).configureEach { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135..2c35211 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34..09523c0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 0adc8e1..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -145,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +205,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 6689b85..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/settings.gradle b/settings.gradle index 8a55ab6..41c2fb3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,3 @@ rootProject.name = 'galaxy-proxy' include 'api' +project(":api").projectDir.mkdirs() diff --git a/src/main/kotlin/one/oktw/galaxy/proxy/extension/Player.kt b/src/main/kotlin/one/oktw/galaxy/proxy/extension/Player.kt deleted file mode 100644 index 35c4ebf..0000000 --- a/src/main/kotlin/one/oktw/galaxy/proxy/extension/Player.kt +++ /dev/null @@ -1,13 +0,0 @@ -package one.oktw.galaxy.proxy.extension - -import com.velocitypowered.api.proxy.Player -import one.oktw.galaxy.proxy.Main.Companion.main - -fun Player.sendPacket(o: Any) { - try { - val connection = this.javaClass.getMethod("getConnection").invoke(this) - connection.javaClass.getMethod("write", Any::class.java).invoke(connection, o) - } catch (e: Exception) { - main.logger.error("Call velocity method error.", e) - } -} diff --git a/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt b/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt index 333a1e5..02c6744 100644 --- a/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt +++ b/src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt @@ -2,20 +2,13 @@ package one.oktw.galaxy.proxy.resourcepack import com.velocitypowered.api.proxy.Player import one.oktw.galaxy.proxy.Main.Companion.main -import one.oktw.galaxy.proxy.extension.sendPacket class ResourcePackHelper { companion object{ fun trySendResourcePack(player: Player, galaxy: String){ val resourcePack = main.config.galaxiesResourcePack[galaxy] ?: return - // workaround Minecraft 1.20.3 not auto unload old resource pack - try { - val packet = Class.forName("com.velocitypowered.proxy.protocol.packet.RemoveResourcePack").getConstructor().newInstance() - player.sendPacket(packet) - } catch (e: Exception) { - main.logger.error("Send remove resource pack packet error.", e) - } + player.clearResourcePacks() player.sendResourcePackOffer( main.proxy.createResourcePackBuilder(resourcePack.uri.toString()) .setHash(resourcePack.hash) diff --git a/src/main/resources/config/proxy.json b/src/main/resources/config/proxy.json index c9039b8..acae75f 100644 --- a/src/main/resources/config/proxy.json +++ b/src/main/resources/config/proxy.json @@ -1,3 +1,3 @@ { - "ProtocolVersion": 765 + "ProtocolVersion": 767 }