diff --git a/.github/workflows/build-remote.yml b/.github/workflows/build-remote.yml new file mode 100644 index 0000000..62484a5 --- /dev/null +++ b/.github/workflows/build-remote.yml @@ -0,0 +1,48 @@ +name: Build Remote + +on: + workflow_call: + inputs: + repository: + required: true + description: 'The repo of the remote' + type: string + ref: + required: true + description: 'The ref of the remote' + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository and Submodules + # See https://github.com/actions/checkout/releases + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + submodules: recursive + - name: Validate Gradle Wrapper + # See https://github.com/gradle/actions/releases + uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 + - name: Set up JDK 17 + # See https://github.com/actions/setup-java/releases + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + with: + java-version: 17 + distribution: temurin + - name: Build with Gradle + # See https://github.com/gradle/actions/releases + uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 + with: + arguments: build + gradle-home-cache-cleanup: true + - name: Archive Artifacts + # See https://github.com/actions/upload-artifact/releases + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + if: success() + with: + name: ParadisuPlugin + path: build/libs/ParadisuPlugin.jar + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f4ae110 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,73 @@ +name: Build + +on: + push: + branches: + - "*" + +jobs: + build: + runs-on: ubuntu-latest + outputs: + release_id: ${{ steps.release.outputs.releaseID }} + steps: + - name: Checkout Repository and Submodules + # See https://github.com/actions/checkout/releases + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: recursive + - name: Validate Gradle Wrapper + # See https://github.com/gradle/actions/releases + uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 + - name: Set up JDK 17 + # See https://github.com/actions/setup-java/releases + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + with: + java-version: 17 + distribution: temurin + - name: Build with Gradle + # See https://github.com/gradle/actions/releases + uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 + with: + arguments: build + gradle-home-cache-cleanup: true + - name: Archive Artifacts + # See https://github.com/actions/upload-artifact/releases + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + if: success() + with: + name: ParadisuPlugin + path: build/libs/ParadisuPlugin.jar + if-no-files-found: error + - name: Create Release + # See https://github.com/Kas-tle/base-release-action/releases + uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # main-11 + if: ${{ success() && github.repository == 'Paradisu/ParadisuPlugin' }} + id: release + with: + files: | + build/libs/ParadisuPlugin.jar + appID: ${{ secrets.RELEASE_APP_ID }} + appPrivateKey: ${{ secrets.RELEASE_APP_PK }} + preRelease: ${{ github.ref_name != 'master' }} + - name: Setup NodeJS + # See https://github.com/actions/setup-node/releases + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 + if: ${{ success() && github.repository == 'Paradisu/ParadisuPlugin' && github.ref_name == 'master' }} + - name: Publish Plugin to Servers + if: ${{ success() && github.repository == 'Paradisu/ParadisuPlugin' && github.ref_name == 'master' }} + env: + PTEROPUB_CONFIG: ${{ secrets.PTEROPUB_CONFIG }} + run: npx pteropub + upload-logs: + name: Upload Logs + runs-on: ubuntu-latest + needs: build + steps: + - name: Upload Logs + # See https://github.com/Kas-tle/release-build-log-action/releases + if: ${{ success() && github.repository == 'Paradisu/ParadisuPlugin' }} + uses: Kas-tle/release-build-log-action@1b57448eaf9476e6e05450e4ea240449eac2c0d2 # main-3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + releaseID: ${{ needs.build.outputs.release_id }} \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 0fad311..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Deploy Plungin - -on: - push: - branches: - - "master" - paths: - - "gradle.properties" - -jobs: - validate-version: - name: Validate Version - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Get previous tag - id: getPreviousTag - uses: WyriHaximus/github-action-get-previous-tag@v1 - - name: Validate Version - env: - PREVIOUS_VERSION: ${{ steps.getPreviousTag.outputs.tag }} - run: | - CURRENT_VERSION=$(cat gradle.properties | grep "version" | cut -d'=' -f2) - PREV_VER_GEQ_CUR_VER=$( - jq -r -n --arg previous_version "${PREVIOUS_VERSION}" --arg current_version "${CURRENT_VERSION}" ' - def ver2arr($inp): ($inp | split(".") | map(tonumber)); - ver2arr($previous_version) as $ver_prev - | ver2arr($current_version) as $ver_cur - | if ($ver_prev[0] > $ver_cur[0]) or ($ver_prev[1] > $ver_cur[1] and $ver_cur[1] != 0) or ($ver_prev[2] >= $ver_cur[2] and $ver_cur[2] != 0) then true else false end - ') - if [ "${PREV_VER_GEQ_CUR_VER}" = true ]; then - echo "Previous version is greater than or equal to current version." - echo "Please update gradle.properties with a valid SemVer version greater than ${PREVIOUS_VERSION} before pushing again!" - exit 1 - fi - build: - runs-on: ubuntu-latest - needs: [validate-version] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: temurin - - name: Build with Gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: build - gradle-home-cache-cleanup: true - - run: mkdir staging && cp build/libs/ParadisuPlugin.jar staging - - uses: actions/upload-artifact@v3 - with: - name: ParadisuPlugin-Latest - path: staging/ParadisuPlugin.jar - - name: Get previous version - id: getPreviousTag - uses: WyriHaximus/github-action-get-previous-tag@v1 - - name: Get current version - id: lookupParadisuVersion - run: echo result=$(cat gradle.properties | grep "version" | cut -d'=' -f2) >> $GITHUB_OUTPUT - - name: Bump version and push tag - id: tag_version - uses: mathieudutour/github-tag-action@v6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - tag_prefix: '' - custom_tag: ${{ steps.lookupParadisuVersion.outputs.result }} - - name: Generate release diff - env: - BEGIN_COMMIT: ${{ steps.getPreviousTag.outputs.tag }} - END_COMMIT: ${{ steps.lookupParadisuVersion.outputs.result }} - run: git fetch --tags --force && git log --pretty=format:"* %s (%h)" ${BEGIN_COMMIT}..${END_COMMIT} > release_notes.md - - name: Create release - uses: ncipollo/release-action@v1 - with: - artifacts: staging/ParadisuPlugin.jar - allowUpdates: true - bodyFile: "release_notes.md" - draft: false - prerelease: false - tag: ${{ steps.lookupParadisuVersion.outputs.result }} - token: ${{ secrets.GITHUB_TOKEN }} - - name: Upload jar to server - env: - PTERODACTYL_TOKEN: ${{ secrets.PTERODACTYL_TOKEN }} - run: | - cp staging/ParadisuPlugin.jar ParadisuPlugin.jar - upload_plugin () { - local upload_url=$(curl "https://panel.kastle.dev/api/client/servers/${1}/files/upload" -H "Authorization: Bearer ${PTERODACTYL_TOKEN}" -X GET -s | jq -r .attributes.url) - curl -F files=@ParadisuPlugin.jar "${upload_url}&directory=/plugins" - } - restart_server () { - task_id=$(curl "https://panel.kastle.dev/api/client/servers/${1}/schedules" -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer ${PTERODACTYL_TOKEN}" -X GET | jq '.data[]?.attributes? | select(.name == "Maintenance Restart") | .id') - curl "https://panel.kastle.dev/api/client/servers/${1}/schedules/${task_id}/execute" -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer ${PTERODACTYL_TOKEN}" -X POST - } - server_ids=( - "978fd706" - "1b063a16" - "a0638f52" - "517d0585" - ) - for id in ${server_ids[@]} - do - upload_plugin ${id} - restart_server ${id} - done diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..6646b79 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,14 @@ +name: Process Pull Request + +on: + pull_request_target: + +jobs: + build: + # Forbid access to secrets nor GH Token perms while building the PR + permissions: {} + secrets: {} + uses: ./.github/workflows/build-remote.yml + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.sha }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index f172457..7bf39e9 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,6 @@ build.bat # Gradle .gradle **/build -build/ \ No newline at end of file +build/ + +pteropub.json \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index be4ee8c..493cec8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group=net.paradisu id=paradisu pluginName=ParadisuPlugin -version=5.0.5 +version=6.0.0-SNAPSHOT description=The official plugin for the Paradisu server authors=cytocracy,JJakee-git,IncompleteIntegers,Raymond-exe,LordOfLlamaz,polargh,Kas-tle url=https://paradisu.net \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a5da733..d78d66e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,28 +1,28 @@ [versions] -dotenv-kotlin = "6.2.2" -mariadb-java-client = "2.3.0" -mysql-connector-java = "8.0.28" -cloud = "1.8.3" -inventorygui = "1.5.1-SNAPSHOT" -paper-api = "1.20.1-R0.1-SNAPSHOT" -protocollib = "5.0.0-SNAPSHOT" +dotenv-kotlin = "6.4.1" +mariadb-java-client = "3.3.3" +mysql-connector-j = "8.3.0" +cloud = "1.8.4" +inventorygui = "1.6.2-SNAPSHOT" +paper-api = "1.20.4-R0.1-SNAPSHOT" +protocollib = "5.2.0-SNAPSHOT" luckperms-api = "5.4" -configurate-yaml = "4.0.0" -adventure = "4.13.1-SNAPSHOT" -adventure-platform = "4.1.1-SNAPSHOT" -connectorplugin = "1.5-SNAPSHOT" +configurate-yaml = "4.1.2" +adventure = "4.17.0-SNAPSHOT" +adventure-platform = "4.3.3-SNAPSHOT" +connectorplugin = "1.5.1-SNAPSHOT" guava = "31.1-jre" -log4j-slf4j-impl = "2.20.0" -velocity-api = "3.2.0-SNAPSHOT" +log4j-slf4j-impl = "2.23.1" +velocity-api = "3.3.0-SNAPSHOT" shadow = "8.1.1" blossom = "1.2.0" -indra = "3.1.1" -lombok = "8.0.1" +indra = "3.1.3" +lombok = "8.6" [libraries] dotenv-kotlin = { group = "io.github.cdimascio", name = "dotenv-kotlin", version.ref = "dotenv-kotlin" } mariadb-java-client = { group = "org.mariadb.jdbc", name = "mariadb-java-client", version.ref = "mariadb-java-client" } -mysql-connector-java = { group = "mysql", name = "mysql-connector-java", version.ref = "mysql-connector-java" } +mysql-connector-j = { group = "com.mysql", name = "mysql-connector-j", version.ref = "mysql-connector-j" } cloud-core = { group = "cloud.commandframework", name = "cloud-core", version.ref = "cloud" } cloud-paper = { group = "cloud.commandframework", name = "cloud-paper", version.ref = "cloud" } cloud-velocity = { group = "cloud.commandframework", name = "cloud-velocity", version.ref = "cloud" } @@ -44,34 +44,19 @@ log4j-slf4j-impl = { group = "org.apache.logging.log4j", name = "log4j-slf4j-imp shadow = { group = "com.github.johnrengelman", name = "shadow", version.ref = "shadow" } [bundles] -cloud-velocity = [ - "cloud-velocity", - "cloud-minecraft-extras" -] -cloud-paper = [ - "cloud-paper", - "cloud-minecraft-extras" -] -cloud-core = [ - "cloud-core", - "cloud-minecraft-extras" -] -adventure-core = [ - "adventure-api", - "adventure-text-minimessage" -] -adventure-velocity = [ - "adventure-api", - "adventure-text-minimessage" -] +cloud-velocity = ["cloud-velocity", "cloud-minecraft-extras"] +cloud-paper = ["cloud-paper", "cloud-minecraft-extras"] +cloud-core = ["cloud-core", "cloud-minecraft-extras"] +adventure-core = ["adventure-api", "adventure-text-minimessage"] +adventure-velocity = ["adventure-api", "adventure-text-minimessage"] adventure-bukkit = [ - "adventure-api", - "adventure-text-minimessage", - "adventure-platform-bukkit" + "adventure-api", + "adventure-text-minimessage", + "adventure-platform-bukkit", ] [plugins] shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } blossom = { id = "net.kyori.blossom", version.ref = "blossom" } indra-git = { id = "net.kyori.indra.git", version.ref = "indra" } -lombok = { id = "io.freefair.lombok", version.ref = "lombok" } \ No newline at end of file +lombok = { id = "io.freefair.lombok", version.ref = "lombok" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..e644113 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 37aef8d..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cb..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,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 @@ -149,7 +153,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 @@ -198,11 +202,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..7101f8e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,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 +57,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/paper/build.gradle.kts b/paper/build.gradle.kts index 0ead24f..2feaa78 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -7,7 +7,7 @@ dependencies { api(project(":core")) implementation(libs.dotenv.kotlin) implementation(libs.mariadb.java.client) - implementation(libs.mysql.connector.java) + implementation(libs.mysql.connector.j) implementation(libs.bundles.cloud.paper) implementation(libs.bundles.adventure.bukkit) implementation(libs.configurate.yaml)