diff --git a/.github/workflows/PaperServerTest.yml b/.github/workflows/PaperServerTest.yml index 238707fc3..61db9bc2b 100644 --- a/.github/workflows/PaperServerTest.yml +++ b/.github/workflows/PaperServerTest.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: 11 + java-version: 17 distribution: adopt - name: Cache local Maven repository @@ -30,4 +30,4 @@ jobs: uses: jaoafa/CheckPluginEnabling@v2.2 with: plugin-name: MyMaid4 - minecraft-version: 1.16.5 + minecraft-version: 1.18.1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd1d6f7c5..4bfb8f599 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,12 +8,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: 11 + java-version: 17 distribution: adopt + - name: Cache local Maven repository uses: actions/cache@v2 with: @@ -21,5 +24,6 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 75fc22924..426a62311 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -21,6 +21,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: adopt + - name: Initialize CodeQL uses: github/codeql-action/init@v1 with: diff --git a/.github/workflows/dependencies-update.yml b/.github/workflows/dependencies-update.yml index b0562d5ac..8a4e755cd 100644 --- a/.github/workflows/dependencies-update.yml +++ b/.github/workflows/dependencies-update.yml @@ -17,10 +17,10 @@ jobs: - name: Create new branch run: hub checkout -b dependencies-update-${{ steps.date.outputs.date }} - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: 16 + java-version: 17 distribution: adopt - name: Cache local Maven repository diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 2f018c4df..000000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Deploy - -on: - pull_request_target: - branches: - - master - types: - - closed - -jobs: - deploy: - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - - steps: - - name: Deploy - id: deployRequest - uses: fjogeleit/http-request-action@master - with: - url: ${{ secrets.DEPLOY_URL }} - method: 'POST' - bearerToken: ${{ secrets.DEPLOY_KEY }} - ignoreStatusCodes: '500' - timeout: 600000 - - - name: Show Response - run: echo ${{ steps.deployRequest.outputs.response }} - - - name: Is Successful Deploy - if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'SUCCESSFUL' }} - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - # :white_check_mark: デプロイが完了しました - - プルリクエストがマージされたため、本番環境へのデプロイを行いました。 - バージョンは `${{ fromJson(steps.deployRequest.outputs.response).version }}` です。稼働中バージョンの確認は Minecraft サーバ内で `/ver MyMaid4` を実行することで確認できます。 - 反映は本番環境の再起動後ですので、アクティブログインユーザーの同意を得て再起動するか、3時の自動再起動を待ってください。 - - - name: Is Failed Deploy - if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'ERROR' }} - uses: peter-evans/create-or-update-comment@v1 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - # :x: デプロイに失敗しました - - プルリクエストがマージされたため、本番環境へのデプロイを行おうとしましたが失敗しました。 - エラー内容は以下の通りです。 - - ``` - ${{ fromJson(steps.deployRequest.outputs.response).type }} (${{ fromJson(steps.deployRequest.outputs.response).type_ja }}) - ${{ fromJson(steps.deployRequest.outputs.response).status }} (${{ fromJson(steps.deployRequest.outputs.response).status_ja }}) - ${{ fromJson(steps.deployRequest.outputs.response).message }} - ``` diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..6d90e71cb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,132 @@ +name: Release + +on: + workflow_dispatch: + pull_request_target: + branches: + - main + types: + - closed + +jobs: + release: + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true + + steps: + - name: Get current date + id: date + run: echo "::set-output name=datetime::$(date +'%Y%m%d-%H%M%S')" + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: adopt + + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Sed Version + run: | + sed -r -i '1,/version/s#(.+?)#test#' pom.xml + git diff + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Set SHORT_SHA + id: vars + run: | + echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)" + + - name: Create a Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.date.outputs.datetime }} + release_name: Release v${{ steps.date.outputs.datetime }} + draft: false + prerelease: true + body: | + ${{ github.event.pull_request.body }} + jaoweb sha: [${{ steps.jaoweb-vars.outputs.SHORT_SHA }}](https://github.com/jaoafa/jaoweb/commit/${{ steps.jaoweb-vars.outputs.SHORT_SHA }}) + jaoweb-docs sha: ${{ steps.docs-vars.outputs.SHORT_SHA }} + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/MyMaid4.jar + asset_name: MyMaid4.jar + asset_content_type: application/zip + + - name: Released comment + uses: actions/github-script@v4 + with: + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `# リリースが完了しました\n\n${{ steps.create_release.outputs.html_url }}` + }) + + deploy: + runs-on: ubuntu-latest + needs: release + if: github.event.pull_request.merged == true + + steps: + - name: Deploy + id: deployRequest + uses: fjogeleit/http-request-action@master + with: + url: ${{ secrets.DEPLOY_URL }} + method: 'POST' + bearerToken: ${{ secrets.DEPLOY_KEY }} + ignoreStatusCodes: '500' + timeout: 600000 + + - name: Show Response + run: echo ${{ steps.deployRequest.outputs.response }} + + - name: Is Successful Deploy + if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'SUCCESSFUL' }} + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + # :white_check_mark: デプロイが完了しました + + プルリクエストがマージされたため、本番環境へのデプロイを行いました。 + バージョンは `${{ fromJson(steps.deployRequest.outputs.response).version }}` です。稼働中バージョンの確認は Minecraft サーバ内で `/ver MyMaid4` を実行することで確認できます。 + 反映は本番環境の再起動後ですので、アクティブログインユーザーの同意を得て再起動するか、3時の自動再起動を待ってください。 + + - name: Is Failed Deploy + if: ${{ fromJson(steps.deployRequest.outputs.response).status == 'ERROR' }} + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + # :x: デプロイに失敗しました + + プルリクエストがマージされたため、本番環境へのデプロイを行おうとしましたが失敗しました。 + エラー内容は以下の通りです。 + + ``` + ${{ fromJson(steps.deployRequest.outputs.response).type }} (${{ fromJson(steps.deployRequest.outputs.response).type_ja }}) - ${{ fromJson(steps.deployRequest.outputs.response).status }} (${{ fromJson(steps.deployRequest.outputs.response).status_ja }}) + ${{ fromJson(steps.deployRequest.outputs.response).message }} + ``` diff --git a/.run/ReBuild And Reload (Mac).run.xml b/.run/ReBuild And Reload (Mac).run.xml deleted file mode 100644 index 576e37c32..000000000 --- a/.run/ReBuild And Reload (Mac).run.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - \ No newline at end of file diff --git a/.run/ReBuild And Reload (Win).run.xml b/.run/ReBuild And Reload (Win).run.xml index 743296d23..73528fe51 100644 --- a/.run/ReBuild And Reload (Win).run.xml +++ b/.run/ReBuild And Reload (Win).run.xml @@ -1,17 +1,20 @@ + \ No newline at end of file diff --git a/.run/buildAndTest.bat b/.run/buildAndTest.bat index ff1e00757..b32bee37d 100644 --- a/.run/buildAndTest.bat +++ b/.run/buildAndTest.bat @@ -16,7 +16,7 @@ if not exist server\plugins ( ) if not exist server\paper.jar ( - curl -o server\paper.jar -L "https://papermc.io/api/v1/paper/1.16.5/latest/download" + curl -o server\paper.jar -L "https://api.tomacheese.com/papermc/1.18.1/latest" ) if not exist server\mcrconapi-1.1.1.jar ( @@ -56,9 +56,9 @@ if %errorlevel% == 0 ( set SELECTED_JAVA=java ) -where java11 2>nul +where java17 2>nul if %errorlevel% == 0 ( - set SELECTED_JAVA=java11 + set SELECTED_JAVA=java17 ) if %SELECTED_JAVA% == "notfound" ( @@ -73,8 +73,8 @@ for /f tokens^=2-5^ delims^=-_^" %%j in ('%SELECTED_JAVA% -fullversion 2^>^&1') echo Java Version: %JAVA_VERSION% (%JAVA_VERSION:~0,3%) -if /i not "%JAVA_VERSION:~0,3%" == "11." ( - echo PaperT[őNɂJava 11KvłB +if /i not "%JAVA_VERSION:~0,3%" == "17." ( + echo PaperT[őNɂJava 17KvłB echo 5bɃN[Y܂B timeout 5 /NOBREAK diff --git a/.run/buildAndTest.sh b/.run/buildAndTest.sh deleted file mode 100644 index f2455797b..000000000 --- a/.run/buildAndTest.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -PLUGIN_NAME="MyMaid4" -JAR_FILE="MyMaid4.jar" - -if [ -f "server/" ]; then - mkdir server -fi - -if [ -f "server/eula.txt" ]; then - echo "eula=true" > server/eula.txt -fi - -if [ -f "server/plugins/" ]; then - mkdir server/plugins/ -fi - -if [ -f "server/paper.jar" ]; then - curl -o server/paper.jar -L "https://papermc.io/api/v1/paper/1.16.5/latest/download" -fi - -if [ -f "server/mcrconapi-1.1.1.jar" ]; then - curl -o server/mcrconapi-1.1.1.jar -L "https://github.com/fnetworks/mcrconapi/releases/download/v1.1.1/mcrconapi-1.1.1.jar" -fi - -if [ -f "server/server.properties" ]; then - echo "server.propertiesが存在しないため作成します。" - cat < server/server.properties -gamemode=creative -level-name=Jao_Afa -enforce-whitelist=true -difficulty=peaceful -level-type=flat -enable-command-block=true -server-port=25565 -enable-rcon=true -rcon.password=rconpassword -rcon.port=25575 -white-list=true -motd=$PLUGIN_NAME Test Server -EOF -fi - -echo "jarファイルをコピーします。" -cp target/$JAR_FILE server/plugins/ -if [ $? -ne 0 ]; then - echo $JAR_FILE NOT FOUND - - echo 5秒後にクローズします。 - sleep 5 - exit 1 -fi - -echo "Minecraftサーバに対してリロードコマンドを実行します。" -java -jar server/mcrconapi-1.1.1.jar -a localhost -l rconpassword -n -c "rl confirm" - -if [ $? -ne 0 ]; then - echo "Minecraftサーバが起動していないため、起動します。" - - cd server - java -jar paper.jar -nogui - if [ $? -eq 0 ]; then exit fi -fi - -echo 5秒後にクローズします。 -sleep 5 -exit diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73b3156ff..9802bb6a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ MyMaid4 にコントリビュートするには、以下の条件を満たす必 開発に関する環境情報です。 - IDE: IntelliJ IDEA (お勧め) -- Language: Java 11 +- Language: Java 17 - Package Manager: Maven Eclipse などでも開発できますが、開発のサポートやテストサーバの動作は IntelliJ IDEA のみ対応します。 diff --git a/pom.xml b/pom.xml index a45317c1f..091901ba9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ Our "Maid" is here. - 11 + 17 UTF-8 https://jaoafa.com @@ -57,7 +57,7 @@ *:* module-info.class - META-INF/* + META-INF* @@ -124,9 +124,9 @@ - com.destroystokyo.paper + io.papermc.paper paper-api - 1.16.5-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided @@ -224,5 +224,11 @@ 1.8.1 rollbar-java + + junit + junit + 4.13.2 + test + diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_AntiTNTCart.java b/src/main/java/com/jaoafa/mymaid4/event/Event_AntiTNTCart.java index 0c3f076ca..c3820464e 100644 --- a/src/main/java/com/jaoafa/mymaid4/event/Event_AntiTNTCart.java +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_AntiTNTCart.java @@ -1,7 +1,7 @@ /* * jaoLicense * - * Copyright (c) 2021 jao Minecraft Server + * Copyright (c) 2022 jao Minecraft Server * * The following license applies to this project: jaoLicense * @@ -14,6 +14,7 @@ import com.jaoafa.mymaid4.lib.EventPremise; import com.jaoafa.mymaid4.lib.MyMaidLibrary; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.entity.EntityType; import org.bukkit.entity.Vehicle; @@ -35,7 +36,7 @@ public void onVehicleCreateEvent(VehicleCreateEvent event) { } Location loc = vehicle.getLocation(); loc = loc.add(0, 0.5, 0); - loc.getWorld().spawnParticle(Particle.BARRIER, loc, 1, 0, 0, 0); + loc.getWorld().spawnParticle(Particle.BLOCK_MARKER, loc, 1, 0, 0, 0, Material.BARRIER.createBlockData()); vehicle.remove(); } }