From 52eb3d820fc43678457087e38c478b28bab64d9b Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 09:58:10 -0500 Subject: [PATCH 01/69] Test out the prerelease action. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 738878dc..f0b1ebc6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: - name: Create release id: release - uses: rymndhng/release-on-push-action@v0.27.0 + uses: Multiverse/release-on-push-action@support_prerelease env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From 2af835f0c3ceba0a8d9be1ed5f54b0f8da64f437 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 11:15:36 -0500 Subject: [PATCH 02/69] Publish prerelease versions as snapshots. --- .github/workflows/release.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0b1ebc6..ec433708 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,18 +37,32 @@ jobs: release_name: "Release " use_github_release_notes: true + - name: Get PR labels + id: pr-labels + uses: joerick/pr-labels-action@v1.0.7 + + - name: Modify version scheme + run: | + if [[ "${{ steps.pr-labels.outputs.labels }}" == *"prerelease"* ]]; then + echo "Replacing prerelease version scheme with SNAPSHOT" + echo "VERSION=$(echo ${{ steps.release.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV + else + echo "Using release version scheme" + echo "VERSION=${{ steps.release.outputs.tag_name }}" >> $GITHUB_ENV + fi + - name: Publish package uses: gradle/gradle-build-action@v2 with: arguments: publish env: - GITHUB_VERSION: ${{ steps.release.outputs.tag_name }} + GITHUB_VERSION: ${{ env.VERSION }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload release artifact uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/libs/multiverse-core-${{ steps.release.outputs.tag_name }}.jar + file: build/libs/multiverse-core-${{ env.VERSION }}.jar asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar tag: ${{ steps.release.outputs.tag_name }} From b64e48769de7d7b66133a3adf5e7ca0a5fcc46c1 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 11:29:28 -0500 Subject: [PATCH 03/69] Check if the tag name contains pre instead of checking PR labels. --- .github/workflows/release.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec433708..498d42ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,13 +37,9 @@ jobs: release_name: "Release " use_github_release_notes: true - - name: Get PR labels - id: pr-labels - uses: joerick/pr-labels-action@v1.0.7 - - name: Modify version scheme run: | - if [[ "${{ steps.pr-labels.outputs.labels }}" == *"prerelease"* ]]; then + if [[ "${{ steps.release.outputs.tag_name }}" == *"pre"* ]]; then echo "Replacing prerelease version scheme with SNAPSHOT" echo "VERSION=$(echo ${{ steps.release.outputs.tag_name }} | sed -E 's/-pre.*/-SNAPSHOT/')" >> $GITHUB_ENV else From 7e5a3238b81ddfda99463574b935e5e257de503a Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 11:44:06 -0500 Subject: [PATCH 04/69] Drop "Release" prefix on release names. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 498d42ec..5cecab08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: with: bump_version_scheme: norelease tag_prefix: '' - release_name: "Release " + release_name: "" use_github_release_notes: true - name: Modify version scheme From 9a9bfc03b9fbc31f3e4144f5c6ca080afe9d1971 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 11:57:02 -0500 Subject: [PATCH 05/69] Add space to trigger release. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a884097a..50cd0343 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,4 @@ Additionally, we would like to give a big thanks to everyone that has supported License ======= -Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info. +Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info. From d88bf6e1377d75a3d1e70dc3ae4623bf7bb0cd17 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 12:40:36 -0500 Subject: [PATCH 06/69] Remove space to test pre-releases --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50cd0343..a884097a 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,4 @@ Additionally, we would like to give a big thanks to everyone that has supported License ======= -Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info. +Multiverse-Core is licensed under BSD-3-Clause License. Please see [LICENSE.md](LICENSE.md) for more info. From f36a56e85445c06bbed7a5306d353b18fced1e77 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 24 Feb 2023 13:17:39 -0500 Subject: [PATCH 07/69] Use "no version bump" label instead of "no release". --- .github/workflows/require_label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/require_label.yml b/.github/workflows/require_label.yml index e4f9c293..13922340 100644 --- a/.github/workflows/require_label.yml +++ b/.github/workflows/require_label.yml @@ -15,4 +15,4 @@ jobs: with: mode: exactly count: 1 - labels: "release:major, release:minor, release:patch, no release" + labels: "release:major, release:minor, release:patch, no version bump" From 4e53d13290feafaf3463ba942402c72111fbff04 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:10:53 -0500 Subject: [PATCH 08/69] Add workflow for manually promoting a release. --- .github/workflows/promote_release.yml | 81 +++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/promote_release.yml diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml new file mode 100644 index 00000000..8b23aff4 --- /dev/null +++ b/.github/workflows/promote_release.yml @@ -0,0 +1,81 @@ +name: Manually promote last prerelease to release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to promote' + required: true + +jobs: + release_on_push: + runs-on: ubuntu-latest + steps: + - name: Verify input version is prerelease + run: | + if [[ "${{ github.event.inputs.version }}" != *"pre"* ]]; then + echo "Version must be a prerelease" + exit 1 + fi + + - name: Get release info + id: get-release + uses: cardinalby/git-get-release-action@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tag: ${{ github.event.inputs.version }} + + - uses: actions/checkout@v3 + with: + ref: ${{ steps.get-release.outputs.tag_name }} + + - uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Remove prerelease tag + run: | + echo "Removing prerelease tag from version" + echo "VERSION=$(echo ${{ steps.get-release.outputs.tag_name }} | sed -E 's/-pre.*//')" >> $GITHUB_ENV + + - name: Build + uses: gradle/gradle-build-action@v2 + with: + arguments: clean build -x test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_VERSION: ${{ env.VERSION }} + + - name: Create release + id: release + uses: Multiverse/release-on-push-action@support_prerelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_SHA: ${{ steps.get-release.outputs.tag_name }} + with: + bump_version_scheme: norelease + tag_prefix: '' + release_name: "" + use_github_release_notes: true + dry_run: true + +# - name: Publish package +# uses: gradle/gradle-build-action@v2 +# with: +# arguments: publish +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +# - name: Upload release artifact +# uses: svenstaro/upload-release-action@v2 +# with: +# repo_token: ${{ secrets.GITHUB_TOKEN }} +# file: build/libs/multiverse-core-${{ env.VERSION }}.jar +# asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar +# tag: ${{ steps.release.outputs.tag_name }} From 1bc4e68ff9e8b069e6bcb8e3475b47b7ec595817 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:20:40 -0500 Subject: [PATCH 09/69] Use promote scheme for manual workflow. --- .github/workflows/promote_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 8b23aff4..3c83adb9 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -54,12 +54,12 @@ jobs: - name: Create release id: release - uses: Multiverse/release-on-push-action@support_prerelease + uses: Multiverse/release-on-push-action@support_promote env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_SHA: ${{ steps.get-release.outputs.tag_name }} with: - bump_version_scheme: norelease + bump_version_scheme: promote tag_prefix: '' release_name: "" use_github_release_notes: true From 7065ffaea23b0786db7e02a4f207269505c94ab0 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:24:24 -0500 Subject: [PATCH 10/69] Remove checkstyle from promote workflow. --- .github/workflows/promote_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 3c83adb9..d5734544 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -47,7 +47,7 @@ jobs: - name: Build uses: gradle/gradle-build-action@v2 with: - arguments: clean build -x test + arguments: clean build -x test -x checkstyleMain -x checkstyleTest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_VERSION: ${{ env.VERSION }} From 06e9e33da4a8f5e1c5d99bc0bdc7ae4ec80ae9da Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:28:36 -0500 Subject: [PATCH 11/69] Workflow requires version bump type. --- .github/workflows/promote_release.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index d5734544..a162d0d5 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -6,6 +6,14 @@ on: version: description: 'Version to promote' required: true + version-bump: + description: 'Version bump to apply - should usually match the version bump used for the prerelease since last release' + required: true + type: choice + options: + - 'minor' + - 'major' + - 'patch' jobs: release_on_push: @@ -54,12 +62,12 @@ jobs: - name: Create release id: release - uses: Multiverse/release-on-push-action@support_promote + uses: Multiverse/release-on-push-action@support_prerelease env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_SHA: ${{ steps.get-release.outputs.tag_name }} with: - bump_version_scheme: promote + bump_version_scheme: ${{ github.event.inputs.version-bump }}} tag_prefix: '' release_name: "" use_github_release_notes: true From ee2a304148cb53b7f637f6a4fd8f9d8d4bb84f9d Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:31:49 -0500 Subject: [PATCH 12/69] Reorder version bump types. --- .github/workflows/promote_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index a162d0d5..787ea274 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -11,9 +11,9 @@ on: required: true type: choice options: + - 'patch' - 'minor' - 'major' - - 'patch' jobs: release_on_push: From cd895d03dc940ff4fbebf6f5a829df8cc5fb89bb Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:32:08 -0500 Subject: [PATCH 13/69] Remove extra } in bump_version_scheme. --- .github/workflows/promote_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 787ea274..7672888b 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -67,7 +67,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_SHA: ${{ steps.get-release.outputs.tag_name }} with: - bump_version_scheme: ${{ github.event.inputs.version-bump }}} + bump_version_scheme: ${{ github.event.inputs.version-bump }} tag_prefix: '' release_name: "" use_github_release_notes: true From 7bbeb9032018a8b1a4110e868501a94f2c191cb9 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:34:10 -0500 Subject: [PATCH 14/69] Remove dry_run. --- .github/workflows/promote_release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 7672888b..045ccd8b 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -71,7 +71,6 @@ jobs: tag_prefix: '' release_name: "" use_github_release_notes: true - dry_run: true # - name: Publish package # uses: gradle/gradle-build-action@v2 From 87b14d3944c5516d0175f5545772d409b4dcc694 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:34:24 -0500 Subject: [PATCH 15/69] Add publish and upload. --- .github/workflows/promote_release.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 045ccd8b..20a2f7e3 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -72,17 +72,17 @@ jobs: release_name: "" use_github_release_notes: true -# - name: Publish package -# uses: gradle/gradle-build-action@v2 -# with: -# arguments: publish -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish package + uses: gradle/gradle-build-action@v2 + with: + arguments: publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# - name: Upload release artifact -# uses: svenstaro/upload-release-action@v2 -# with: -# repo_token: ${{ secrets.GITHUB_TOKEN }} -# file: build/libs/multiverse-core-${{ env.VERSION }}.jar -# asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar -# tag: ${{ steps.release.outputs.tag_name }} + - name: Upload release artifact + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/libs/multiverse-core-${{ env.VERSION }}.jar + asset_name: multiverse-core-${{ steps.release.outputs.tag_name }}.jar + tag: ${{ steps.release.outputs.tag_name }} From 66e21da6b2cfcfc77d5f142a6466bfdca2d14bdd Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:39:59 -0500 Subject: [PATCH 16/69] Add version to publish action as well. --- .github/workflows/promote_release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 20a2f7e3..3b963d41 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -78,6 +78,7 @@ jobs: arguments: publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_VERSION: ${{ env.VERSION }} - name: Upload release artifact uses: svenstaro/upload-release-action@v2 From cdf9767959870f600ec4ba2f6ff4fa2c177b472d Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 13:41:26 -0500 Subject: [PATCH 17/69] Use target_commitish for GITHUA_SHA. --- .github/workflows/promote_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 3b963d41..9d8ebe53 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -65,7 +65,7 @@ jobs: uses: Multiverse/release-on-push-action@support_prerelease env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_SHA: ${{ steps.get-release.outputs.tag_name }} + GITHUB_SHA: ${{ steps.get-release.outputs.target_commitish }} with: bump_version_scheme: ${{ github.event.inputs.version-bump }} tag_prefix: '' From 9725bdfeebe279b9e21a18a2396366a03c3846e1 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 14:02:01 -0500 Subject: [PATCH 18/69] Use ref input. --- .github/workflows/promote_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 9d8ebe53..ee348890 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -62,15 +62,15 @@ jobs: - name: Create release id: release - uses: Multiverse/release-on-push-action@support_prerelease + uses: Multiverse/release-on-push-action@support_ref_input env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_SHA: ${{ steps.get-release.outputs.target_commitish }} with: bump_version_scheme: ${{ github.event.inputs.version-bump }} tag_prefix: '' release_name: "" use_github_release_notes: true + ref: ${{ steps.get-release.outputs.target_commitish }} - name: Publish package uses: gradle/gradle-build-action@v2 From 01f745b0272d36d3acf28d872240c7f01e652148 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 19:39:14 -0500 Subject: [PATCH 19/69] Skip checking PR labels. --- .github/workflows/promote_release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index ee348890..1449dc31 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -62,7 +62,7 @@ jobs: - name: Create release id: release - uses: Multiverse/release-on-push-action@support_ref_input + uses: Multiverse/release-on-push-action@skip_prs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -71,6 +71,7 @@ jobs: release_name: "" use_github_release_notes: true ref: ${{ steps.get-release.outputs.target_commitish }} + skip_prs: true - name: Publish package uses: gradle/gradle-build-action@v2 From 79b9c1231996b2a0116e3e0346bdb49d0e6070be Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 20:29:04 -0500 Subject: [PATCH 20/69] Change job name for manually promoting releases. --- .github/workflows/promote_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index 1449dc31..5ee77d1d 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -16,7 +16,7 @@ on: - 'major' jobs: - release_on_push: + manually_promote_release: runs-on: ubuntu-latest steps: - name: Verify input version is prerelease From 073091525bbd3b5f34a28d90e1787330b30b0826 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 20:34:19 -0500 Subject: [PATCH 21/69] Label PRs automatically as prerelease. --- .github/labeler.yml | 2 ++ .github/workflows/pr_labeler.yml | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/pr_labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..0de407b5 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,2 @@ +prerelease: + - '*' diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml new file mode 100644 index 00000000..f993fcf5 --- /dev/null +++ b/.github/workflows/pr_labeler.yml @@ -0,0 +1,17 @@ +name: "Pull Request Labeler" + +on: + pull_request: + types: [opened] + branches: [main] + +jobs: + prerelease_labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From 2b97f7310f1b973198a2d1935df5c603a764cbd3 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Sat, 25 Feb 2023 20:39:56 -0500 Subject: [PATCH 22/69] Use pull_request_target for auto labeler. --- .github/workflows/pr_labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml index f993fcf5..69387def 100644 --- a/.github/workflows/pr_labeler.yml +++ b/.github/workflows/pr_labeler.yml @@ -1,7 +1,7 @@ name: "Pull Request Labeler" on: - pull_request: + pull_request_target: types: [opened] branches: [main] From b4549c6791232df7532bafa838a68349c53c521c Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:12:28 +0800 Subject: [PATCH 23/69] feat: Add support for loading locales from plugin dir --- .../MultiverseCore/MultiverseCore.java | 9 ++++ .../commandtools/MVCommandManager.java | 19 +++++--- .../locale/FileResClassLoader.java | 46 +++++++++++++++++++ .../MultiverseCore/locale/PluginLocales.java | 15 ++++++ 4 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java create mode 100644 src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 880e8d20..b83f1b13 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -164,6 +164,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.anchorManager.loadAnchors(); this.registerEvents(); this.registerCommands(); + this.setUpLocales(); this.registerDestinations(); this.setupMetrics(); this.saveMVConfig(); @@ -215,6 +216,14 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.commandManager.registerCommand(new UnloadCommand(this)); } + /** + * Resgister locales + */ + private void setUpLocales() { + this.commandManager.getLocales().addFileResClassLoader(this); + this.commandManager.getLocales().addMessageBundles("multiverse-core"); + } + /** * Register all the destinations. */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java index 73ea2752..979e071f 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java @@ -1,7 +1,5 @@ package com.onarandombox.MultiverseCore.commandtools; -import java.util.Locale; - import co.aikar.commands.BukkitCommandCompletionContext; import co.aikar.commands.BukkitCommandExecutionContext; import co.aikar.commands.CommandCompletions; @@ -10,6 +8,7 @@ import co.aikar.commands.PaperCommandManager; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager; import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager; +import com.onarandombox.MultiverseCore.locale.PluginLocales; import org.jetbrains.annotations.NotNull; /** @@ -20,6 +19,7 @@ public class MVCommandManager extends PaperCommandManager { private final MultiverseCore plugin; private CommandFlagsManager flagsManager; private CommandQueueManager commandQueueManager; + private PluginLocales pluginLocales; public MVCommandManager(@NotNull MultiverseCore plugin) { super(plugin); @@ -27,11 +27,6 @@ public class MVCommandManager extends PaperCommandManager { // Setup conditions MVCommandConditions.load(this, plugin); - - // Setup locale - this.addSupportedLanguage(Locale.ENGLISH); - this.locales.addMessageBundles("multiverse-core"); - this.locales.loadLanguages(); } /** @@ -46,6 +41,16 @@ public class MVCommandManager extends PaperCommandManager { return flagsManager; } + @Override + public PluginLocales getLocales() { + if (this.pluginLocales == null) { + this.pluginLocales = new PluginLocales(this); + this.locales = pluginLocales; // For parent class + this.pluginLocales.loadLanguages(); + } + return this.pluginLocales; + } + /** * Manager for command that requires /mv confirm before execution. * diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java b/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java new file mode 100644 index 00000000..9c0f51cd --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java @@ -0,0 +1,46 @@ +package com.onarandombox.MultiverseCore.locale; + +import org.bukkit.plugin.Plugin; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; + +/** + * A class loader that loads resources from the plugin's locales folder. + */ +public class FileResClassLoader extends ClassLoader { + private final transient File localesFolder; + + public FileResClassLoader(final ClassLoader classLoader, final Plugin plugin) { + super(classLoader); + this.localesFolder = new File(plugin.getDataFolder(), "locales"); + } + + @Override + public URL getResource(final String string) { + final File file = new File(localesFolder, string); + if (file.exists()) { + try { + return file.toURI().toURL(); + } catch (final MalformedURLException ignored) { + } + } + return null; + } + + @Override + public InputStream getResourceAsStream(final String string) { + final File file = new File(localesFolder, string); + if (file.exists()) { + try { + return new FileInputStream(file); + } catch (final FileNotFoundException ignored) { + } + } + return null; + } +} diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java new file mode 100644 index 00000000..309fa616 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java @@ -0,0 +1,15 @@ +package com.onarandombox.MultiverseCore.locale; + +import co.aikar.commands.BukkitCommandManager; +import co.aikar.commands.BukkitLocales; +import org.bukkit.plugin.Plugin; + +public class PluginLocales extends BukkitLocales { + public PluginLocales(BukkitCommandManager manager) { + super(manager); + } + + public boolean addFileResClassLoader(Plugin plugin) { + return this.addBundleClassLoader(new FileResClassLoader(plugin.getClass().getClassLoader(), plugin)); + } +} From 47a92deffd733bd0b39ec102790f6df827fb5dd9 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:12:54 +0800 Subject: [PATCH 24/69] refactor: Use '&' for chat color formatting --- src/main/resources/multiverse-core_en.properties | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index dc28fe11..7fe64b28 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -1,9 +1,9 @@ -mv-core.config.save.failed=§cUnable to save Multiverse-Core config.yml. Your changes will be temporary! +mv-core.config.save.failed=&cUnable to save Multiverse-Core config.yml. Your changes will be temporary! mv-core.create.description=Creates a new world and loads it. mv-core.create.name.description=New world name. mv-core.create.environment.description=The world's environment. See: /mv environments -mv-core.create.flags.description=Additional world settings. See http://gg.gg/nn8bl for all possible flags. +mv-core.create.flags.description=Additional world settings. See https://gg.gg/nn8bl for all possible flags. mv-core.create.properties=Creating world {worldName} with the following properties: mv-core.create.properties.environment=- Environment: {environment} mv-core.create.properties.seed=- Seed: {seed} @@ -12,12 +12,12 @@ mv-core.create.properties.adjustspawn=- Adjust Spawn: {adjustSpawn} mv-core.create.properties.generator=- Generator: {generator} mv-core.create.properties.structures=- Structures: {structures} mv-core.create.loading=Creating world... -mv-core.create.failed=§cFailed to create world '{worldName}'! See console for details. -mv-core.create.success=§aWorld '{worldName}' created successfully! +mv-core.create.failed=&cFailed to create world '{worldName}'! See console for details. +mv-core.create.success=&aWorld '{worldName}' created successfully! mv-core.debug.info.description=Show the current debug level. -mv-core.debug.info.off=§fMultiverse Debug mode is §cOFF§f. -mv-core.debug.info.on=§fMultiverse Debug mode is at §alevel {level}§f. +mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. +mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. mv-core.debug.change.description=Change debug level. mv-core.debug.change.syntax=level mv-core.debug.change.level.description=Debug level to set to. From 44904eaef4c99654c8c98dabf0c5bcc29b11c975 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 17 Feb 2023 00:19:04 +0800 Subject: [PATCH 25/69] feat: Allow for custom locale folder path --- .../MultiverseCore/locale/FileResClassLoader.java | 15 ++++++++++----- .../MultiverseCore/locale/PluginLocales.java | 9 +++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java b/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java index 9c0f51cd..ecc1576c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java +++ b/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java @@ -1,7 +1,5 @@ package com.onarandombox.MultiverseCore.locale; -import org.bukkit.plugin.Plugin; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -9,15 +7,22 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import org.bukkit.plugin.Plugin; + /** * A class loader that loads resources from the plugin's locales folder. */ public class FileResClassLoader extends ClassLoader { + private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales"; private final transient File localesFolder; - public FileResClassLoader(final ClassLoader classLoader, final Plugin plugin) { - super(classLoader); - this.localesFolder = new File(plugin.getDataFolder(), "locales"); + public FileResClassLoader(final Plugin plugin) { + this(plugin, DEFAULT_LOCALE_FOLDER_PATH); + } + + public FileResClassLoader(final Plugin plugin, final String localesFolderPath) { + super(plugin.getClass().getClassLoader()); + this.localesFolder = new File(plugin.getDataFolder(), localesFolderPath); } @Override diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java index 309fa616..232eff68 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java +++ b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java @@ -3,13 +3,18 @@ package com.onarandombox.MultiverseCore.locale; import co.aikar.commands.BukkitCommandManager; import co.aikar.commands.BukkitLocales; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public class PluginLocales extends BukkitLocales { public PluginLocales(BukkitCommandManager manager) { super(manager); } - public boolean addFileResClassLoader(Plugin plugin) { - return this.addBundleClassLoader(new FileResClassLoader(plugin.getClass().getClassLoader(), plugin)); + public boolean addFileResClassLoader(@NotNull Plugin plugin) { + return this.addBundleClassLoader(new FileResClassLoader(plugin)); + } + + public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) { + return this.addBundleClassLoader(new FileResClassLoader(plugin, localesFolderPath)); } } From ffc4c600c55e0cc2251cb57fbdeaa705e1c28892 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 17 Feb 2023 10:39:03 +0800 Subject: [PATCH 26/69] feat: Enable per player locale support --- .../java/com/onarandombox/MultiverseCore/MultiverseCore.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index b83f1b13..a6faa8b2 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -220,6 +220,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { * Resgister locales */ private void setUpLocales() { + this.commandManager.usePerIssuerLocale(true, true); this.commandManager.getLocales().addFileResClassLoader(this); this.commandManager.getLocales().addMessageBundles("multiverse-core"); } From 560e3ab2017660f67b76287d4b6d129bb1d36c14 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Tue, 28 Feb 2023 22:55:18 +0800 Subject: [PATCH 27/69] refactor: Make FileResClassLoader usable for other file paths. --- .../MultiverseCore/locale/FileResClassLoader.java | 14 +++++--------- .../MultiverseCore/locale/PluginLocales.java | 5 ++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java b/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java index ecc1576c..43281a7b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java +++ b/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java @@ -13,21 +13,17 @@ import org.bukkit.plugin.Plugin; * A class loader that loads resources from the plugin's locales folder. */ public class FileResClassLoader extends ClassLoader { - private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales"; - private final transient File localesFolder; - public FileResClassLoader(final Plugin plugin) { - this(plugin, DEFAULT_LOCALE_FOLDER_PATH); - } + private final transient File targetFolder; - public FileResClassLoader(final Plugin plugin, final String localesFolderPath) { + public FileResClassLoader(final Plugin plugin, final String subFolder) { super(plugin.getClass().getClassLoader()); - this.localesFolder = new File(plugin.getDataFolder(), localesFolderPath); + this.targetFolder = new File(plugin.getDataFolder(), subFolder); } @Override public URL getResource(final String string) { - final File file = new File(localesFolder, string); + final File file = new File(targetFolder, string); if (file.exists()) { try { return file.toURI().toURL(); @@ -39,7 +35,7 @@ public class FileResClassLoader extends ClassLoader { @Override public InputStream getResourceAsStream(final String string) { - final File file = new File(localesFolder, string); + final File file = new File(targetFolder, string); if (file.exists()) { try { return new FileInputStream(file); diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java index 232eff68..882eec8c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java +++ b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java @@ -6,12 +6,15 @@ import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; public class PluginLocales extends BukkitLocales { + + private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales"; + public PluginLocales(BukkitCommandManager manager) { super(manager); } public boolean addFileResClassLoader(@NotNull Plugin plugin) { - return this.addBundleClassLoader(new FileResClassLoader(plugin)); + return this.addBundleClassLoader(new FileResClassLoader(plugin, DEFAULT_LOCALE_FOLDER_PATH)); } public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) { From 7dbd29b838007e80117be4982589af8f3338637f Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Tue, 28 Feb 2023 23:06:44 +0800 Subject: [PATCH 28/69] refactor: Shift classes and add javadocs --- .../commands/CreateCommand.java | 2 +- .../MultiverseCore/commands/DebugCommand.java | 2 +- .../commandtools/MVCommandManager.java | 6 ++- .../commandtools/PluginLocales.java | 45 +++++++++++++++++++ .../MultiverseCore/locale/PluginLocales.java | 23 ---------- .../MultiverseCore/locale/package-info.java | 4 -- .../{locale => utils}/MVCorei18n.java | 2 +- .../file}/FileResClassLoader.java | 14 +++++- .../utils/{ => file}/FileUtils.java | 2 +- .../utils/file/package-info.java | 4 ++ .../world/SimpleMVWorldManager.java | 2 +- .../MultiverseCore/utils/FileUtilsTest.java | 1 + .../utils/TestInstanceCreator.java | 1 + 13 files changed, 74 insertions(+), 34 deletions(-) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/commandtools/PluginLocales.java delete mode 100644 src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java delete mode 100644 src/main/java/com/onarandombox/MultiverseCore/locale/package-info.java rename src/main/java/com/onarandombox/MultiverseCore/{locale => utils}/MVCorei18n.java (93%) rename src/main/java/com/onarandombox/MultiverseCore/{locale => utils/file}/FileResClassLoader.java (80%) rename src/main/java/com/onarandombox/MultiverseCore/utils/{ => file}/FileUtils.java (98%) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/utils/file/package-info.java diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java index b6111ffc..83b2bb2f 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java @@ -22,7 +22,7 @@ import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup; import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag; import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags; -import com.onarandombox.MultiverseCore.locale.MVCorei18n; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldType; diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java index ef6bf56e..7daf93bc 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java @@ -9,7 +9,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; -import com.onarandombox.MultiverseCore.locale.MVCorei18n; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.jetbrains.annotations.NotNull; @CommandAlias("mv") diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java index 979e071f..f217f3a0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java @@ -8,7 +8,6 @@ import co.aikar.commands.PaperCommandManager; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager; import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager; -import com.onarandombox.MultiverseCore.locale.PluginLocales; import org.jetbrains.annotations.NotNull; /** @@ -41,6 +40,11 @@ public class MVCommandManager extends PaperCommandManager { return flagsManager; } + /** + * Gets class responsible for locale handling. + * + * @return A not-null {@link PluginLocales}. + */ @Override public PluginLocales getLocales() { if (this.pluginLocales == null) { diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/PluginLocales.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/PluginLocales.java new file mode 100644 index 00000000..66c0f8c1 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/PluginLocales.java @@ -0,0 +1,45 @@ +package com.onarandombox.MultiverseCore.commandtools; + +import co.aikar.commands.BukkitCommandManager; +import co.aikar.commands.BukkitLocales; +import com.onarandombox.MultiverseCore.utils.file.FileResClassLoader; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + +/** + * Locale manager with additional methods for loading locales from plugin's locales folder. + */ +public class PluginLocales extends BukkitLocales { + + private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales"; + + /** + * Creates a new instance of {@link PluginLocales}. + * + * @param manager The command manager. + */ + public PluginLocales(BukkitCommandManager manager) { + super(manager); + } + + /** + * Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from. + * + * @param plugin The plugin. + * @return True if the class loader was added successfully. + */ + public boolean addFileResClassLoader(@NotNull Plugin plugin) { + return this.addBundleClassLoader(new FileResClassLoader(plugin, DEFAULT_LOCALE_FOLDER_PATH)); + } + + /** + * Adds a {@link FileResClassLoader} to the list of class loaders to load locales data from. + * + * @param plugin The plugin. + * @param localesFolderPath The path to the folder containing the locales. + * @return True if the class loader was added successfully. + */ + public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) { + return this.addBundleClassLoader(new FileResClassLoader(plugin, localesFolderPath)); + } +} diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java b/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java deleted file mode 100644 index 882eec8c..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/PluginLocales.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.onarandombox.MultiverseCore.locale; - -import co.aikar.commands.BukkitCommandManager; -import co.aikar.commands.BukkitLocales; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; - -public class PluginLocales extends BukkitLocales { - - private static final String DEFAULT_LOCALE_FOLDER_PATH = "locales"; - - public PluginLocales(BukkitCommandManager manager) { - super(manager); - } - - public boolean addFileResClassLoader(@NotNull Plugin plugin) { - return this.addBundleClassLoader(new FileResClassLoader(plugin, DEFAULT_LOCALE_FOLDER_PATH)); - } - - public boolean addFileResClassLoader(@NotNull Plugin plugin, @NotNull String localesFolderPath) { - return this.addBundleClassLoader(new FileResClassLoader(plugin, localesFolderPath)); - } -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/package-info.java b/src/main/java/com/onarandombox/MultiverseCore/locale/package-info.java deleted file mode 100644 index dd0e53cb..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains all the locale reference for Multiverse-Core. - */ -package com.onarandombox.MultiverseCore.locale; diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java similarity index 93% rename from src/main/java/com/onarandombox/MultiverseCore/locale/MVCorei18n.java rename to src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index dab78959..c28e4cd4 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -1,4 +1,4 @@ -package com.onarandombox.MultiverseCore.locale; +package com.onarandombox.MultiverseCore.utils; import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; diff --git a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java b/src/main/java/com/onarandombox/MultiverseCore/utils/file/FileResClassLoader.java similarity index 80% rename from src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java rename to src/main/java/com/onarandombox/MultiverseCore/utils/file/FileResClassLoader.java index 43281a7b..3342841e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/locale/FileResClassLoader.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/file/FileResClassLoader.java @@ -1,4 +1,4 @@ -package com.onarandombox.MultiverseCore.locale; +package com.onarandombox.MultiverseCore.utils.file; import java.io.File; import java.io.FileInputStream; @@ -16,11 +16,20 @@ public class FileResClassLoader extends ClassLoader { private final transient File targetFolder; + /** + * Creates a new FileResClassLoader. + * + * @param plugin The plugin to load resources from. + * @param subFolder The subfolder to load resources from. + */ public FileResClassLoader(final Plugin plugin, final String subFolder) { super(plugin.getClass().getClassLoader()); this.targetFolder = new File(plugin.getDataFolder(), subFolder); } + /** + * {@inheritDoc} + */ @Override public URL getResource(final String string) { final File file = new File(targetFolder, string); @@ -33,6 +42,9 @@ public class FileResClassLoader extends ClassLoader { return null; } + /** + * {@inheritDoc} + */ @Override public InputStream getResourceAsStream(final String string) { final File file = new File(targetFolder, string); diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java b/src/main/java/com/onarandombox/MultiverseCore/utils/file/FileUtils.java similarity index 98% rename from src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java rename to src/main/java/com/onarandombox/MultiverseCore/utils/file/FileUtils.java index 571143bb..b62384fb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/FileUtils.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/file/FileUtils.java @@ -5,7 +5,7 @@ * with this project. * ******************************************************************************/ -package com.onarandombox.MultiverseCore.utils; +package com.onarandombox.MultiverseCore.utils.file; import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/file/package-info.java b/src/main/java/com/onarandombox/MultiverseCore/utils/file/package-info.java new file mode 100644 index 00000000..f74ce7d4 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/file/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains all the classes that deal with files on disk. + */ +package com.onarandombox.MultiverseCore.utils.file; \ No newline at end of file diff --git a/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java index 214f3496..2129da1a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/world/SimpleMVWorldManager.java @@ -32,7 +32,7 @@ import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.WorldPurger; import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent; -import com.onarandombox.MultiverseCore.utils.FileUtils; +import com.onarandombox.MultiverseCore.utils.file.FileUtils; import org.bukkit.Bukkit; import org.bukkit.GameRule; import org.bukkit.Location; diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java b/src/test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java index 5dfb87f7..84e705ae 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java +++ b/src/test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java @@ -1,5 +1,6 @@ package com.onarandombox.MultiverseCore.utils; +import com.onarandombox.MultiverseCore.utils.file.FileUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java b/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java index 2ad96240..07e63562 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java +++ b/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java @@ -20,6 +20,7 @@ import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.MultiverseCore.listeners.MVEntityListener; import com.onarandombox.MultiverseCore.listeners.MVPlayerListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; +import com.onarandombox.MultiverseCore.utils.file.FileUtils; import com.onarandombox.MultiverseCore.world.SimpleMVWorldManager; import junit.framework.Assert; import org.bukkit.Bukkit; From 974afb4751be01d1266c015fa1b003e13e072905 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sat, 18 Feb 2023 14:19:25 +0800 Subject: [PATCH 29/69] feat: Implement help command --- .../MultiverseCore/MultiverseCore.java | 12 ++----- .../MultiverseCore/commands/RootCommand.java | 21 ++++++++++++ .../MultiverseCore/commands/UsageCommand.java | 33 +++++++++++++++++++ .../commandtools/MVCommandCompletions.java | 32 ++++++++++++++++++ .../commandtools/MVCommandManager.java | 18 ++++++++++ 5 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java create mode 100644 src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index a6faa8b2..a9e3c2b1 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -38,8 +38,10 @@ import com.onarandombox.MultiverseCore.commands.LoadCommand; import com.onarandombox.MultiverseCore.commands.RegenCommand; import com.onarandombox.MultiverseCore.commands.ReloadCommand; import com.onarandombox.MultiverseCore.commands.RemoveCommand; +import com.onarandombox.MultiverseCore.commands.RootCommand; import com.onarandombox.MultiverseCore.commands.TeleportCommand; import com.onarandombox.MultiverseCore.commands.UnloadCommand; +import com.onarandombox.MultiverseCore.commands.UsageCommand; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.MultiverseCore.destination.DestinationsProvider; import com.onarandombox.MultiverseCore.destination.core.AnchorDestination; @@ -164,7 +166,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.anchorManager.loadAnchors(); this.registerEvents(); this.registerCommands(); - this.setUpLocales(); this.registerDestinations(); this.setupMetrics(); this.saveMVConfig(); @@ -216,15 +217,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.commandManager.registerCommand(new UnloadCommand(this)); } - /** - * Resgister locales - */ - private void setUpLocales() { - this.commandManager.usePerIssuerLocale(true, true); - this.commandManager.getLocales().addFileResClassLoader(this); - this.commandManager.getLocales().addMessageBundles("multiverse-core"); - } - /** * Register all the destinations. */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java new file mode 100644 index 00000000..8e9f9518 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiverseCore.commands; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import com.onarandombox.MultiverseCore.MultiverseCore; +import org.bukkit.ChatColor; +import org.bukkit.plugin.PluginDescriptionFile; +import org.jetbrains.annotations.NotNull; + +public class RootCommand extends MultiverseCoreCommand { + public RootCommand(@NotNull MultiverseCore plugin) { + super(plugin); + } + + @CommandAlias("mv") + public void onRootCommand(CommandIssuer issuer) { + PluginDescriptionFile description = this.plugin.getDescription(); + issuer.sendMessage(ChatColor.GREEN + description.getName() + " version " + description.getVersion()); + issuer.sendMessage(ChatColor.GREEN + "See " + ChatColor.WHITE + "/mv help" + ChatColor.GREEN + " for commands available."); + } +} diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java new file mode 100644 index 00000000..e0c63b6e --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java @@ -0,0 +1,33 @@ +package com.onarandombox.MultiverseCore.commands; + +import co.aikar.commands.CommandHelp; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandCompletion; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.HelpCommand; +import co.aikar.commands.annotation.Subcommand; +import co.aikar.commands.annotation.Syntax; +import com.onarandombox.MultiverseCore.MultiverseCore; +import org.jetbrains.annotations.NotNull; + +@CommandAlias("mv") +public class UsageCommand extends MultiverseCoreCommand { + public UsageCommand(@NotNull MultiverseCore plugin) { + super(plugin); + } + + @HelpCommand + @Subcommand("help") + @CommandPermission("multiverse.core.help") + @CommandCompletion("@commands:mv") + @Syntax("[filter] [page]") + @Description("Show Multiverse-Core Command usage.") + public void onUsageCommand(CommandHelp help) { + if (help.getIssuer().isPlayer()) { + // Prevent flooding the chat + help.setPerPage(4); + } + this.plugin.getMVCommandManager().showUsage(help); + } +} diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java index 044dac90..ff5671d8 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandCompletions.java @@ -5,12 +5,16 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import co.aikar.commands.BukkitCommandCompletionContext; import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.CommandIssuer; import co.aikar.commands.PaperCommandCompletions; +import co.aikar.commands.RegisteredCommand; +import co.aikar.commands.RootCommand; import com.google.common.collect.Sets; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorld; @@ -30,6 +34,7 @@ public class MVCommandCompletions extends PaperCommandCompletions { this.plugin = plugin; this.worldManager = plugin.getMVWorldManager(); + registerAsyncCompletion("commands", this::suggestCommands); registerAsyncCompletion("destinations", this::suggestDestinations); registerAsyncCompletion("flags", this::suggestFlags); registerStaticCompletion("gamerules", this::suggestGamerules); @@ -41,6 +46,33 @@ public class MVCommandCompletions extends PaperCommandCompletions { setDefaultCompletion("mvworlds", MVWorld.class); } + private Collection suggestCommands(BukkitCommandCompletionContext context) { + String rootCmdName = context.getConfig(); + if (rootCmdName == null) { + return Collections.emptyList(); + } + + RootCommand rootCommand = this.plugin.getMVCommandManager().getRegisteredRootCommands().stream() + .unordered() + .filter(c -> c.getCommandName().equals(rootCmdName)) + .findFirst() + .orElse(null); + + if (rootCommand == null) { + return Collections.emptyList(); + } + + return rootCommand.getSubCommands().entries().stream() + .filter(entry -> checkPerms(context.getIssuer(), entry.getValue())) + .map(Map.Entry::getKey) + .filter(cmdName -> !cmdName.startsWith("__")) + .collect(Collectors.toList()); + } + + private boolean checkPerms(CommandIssuer issuer, RegisteredCommand command) { + return this.plugin.getMVCommandManager().hasPermission(issuer, command.getRequiredPermissions()); + } + private Collection suggestDestinations(BukkitCommandCompletionContext context) { if (context.hasConfig("playerOnly") && !context.getIssuer().isPlayer()) { return Collections.emptyList(); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java index f217f3a0..8a1cd3a7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java @@ -1,9 +1,13 @@ package com.onarandombox.MultiverseCore.commandtools; +import java.util.List; + import co.aikar.commands.BukkitCommandCompletionContext; import co.aikar.commands.BukkitCommandExecutionContext; import co.aikar.commands.CommandCompletions; import co.aikar.commands.CommandContexts; +import co.aikar.commands.CommandHelp; +import co.aikar.commands.HelpEntry; import co.aikar.commands.PaperCommandManager; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager; @@ -92,4 +96,18 @@ public class MVCommandManager extends PaperCommandManager { } return this.completions; } + + /** + * Standardise usage command formatting for all mv modules. + * + * @param help The target {@link CommandHelp}. + */ + public void showUsage(@NotNull CommandHelp help) { + List entries = help.getHelpEntries(); + if (entries.size() == 1) { + this.plugin.getMVCommandManager().getHelpFormatter().showDetailedHelp(help, entries.get(0)); + return; + } + help.showHelp(); + } } From 101ddae4434e880c4ad0d401c9b35ca8afa92457 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Tue, 28 Feb 2023 23:03:50 -0500 Subject: [PATCH 30/69] Create CODEOWNERS. --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..8ddb02e8 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @dumptruckman @benwoo1110 @nicegamer7 From d5ebde53b9b8dee278a7228079ee52ce022d1dcb Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:32:07 +0800 Subject: [PATCH 31/69] Add maven central to repositories (#2859) Co-authored-by: Jeremy Wood --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index c4b2e7ca..5328d394 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,8 @@ java.sourceCompatibility = JavaVersion.VERSION_11 repositories { mavenLocal() + mavenCentral() + maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') } From 39287f55efbfa08db5f3e1114cc961d832cbd083 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Wed, 1 Mar 2023 23:36:41 -0500 Subject: [PATCH 32/69] Delete CODEOWNERS. --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 8ddb02e8..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @dumptruckman @benwoo1110 @nicegamer7 From e536dff1a88fd3fe98e6bf13965e1818d9f3353a Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 00:37:30 -0500 Subject: [PATCH 33/69] Use a separate bukkit dependency for tests. --- build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5328d394..790907de 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ repositories { } dependencies { - implementation('org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT') { + compileOnly('org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT') { exclude group: 'junit', module: 'junit' } @@ -66,6 +66,9 @@ dependencies { api 'de.themoep.idconverter:mappings:1.2-SNAPSHOT' api 'org.jetbrains:annotations:16.0.2' + testImplementation('org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT') { + exclude group: 'junit', module: 'junit' + } testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:3.11.2' testImplementation 'commons-io:commons-io:2.4' From 85d744d79f672731247903b382dfea376081417a Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 00:44:32 -0500 Subject: [PATCH 34/69] Run tests against spigot-api 1.19.3. --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 790907de..60ebea60 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,8 @@ dependencies { api 'de.themoep.idconverter:mappings:1.2-SNAPSHOT' api 'org.jetbrains:annotations:16.0.2' - testImplementation('org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT') { + testImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT' + testImplementation('com.googlecode.json-simple:json-simple:1.1.1') { exclude group: 'junit', module: 'junit' } testImplementation 'junit:junit:4.12' From b6574245b8254468488765a105c6c5858fe6ae4e Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 00:48:54 -0500 Subject: [PATCH 35/69] Remove junit exclusion from compileOnly bukkit. --- build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 60ebea60..9e0beda1 100644 --- a/build.gradle +++ b/build.gradle @@ -43,9 +43,7 @@ repositories { } dependencies { - compileOnly('org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT') { - exclude group: 'junit', module: 'junit' - } + compileOnly 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT' implementation('com.github.MilkBowl:VaultAPI:1.7') { exclude group: 'org.bukkit', module: 'bukkit' From 87225b1c65b54f06b09bdbe0ed44c56152d55783 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 01:20:38 -0500 Subject: [PATCH 36/69] Move old tests to old-test. --- build.gradle | 34 +++++++++++++++---- .../MultiverseCore/TestDebugMode.java | 0 .../MultiverseCore/TestEntitySpawnRules.java | 0 .../TestEntryFeeConversion.java | 0 .../MultiverseCore/TestModifyCommand.java | 0 .../MultiverseCore/TestWorldProperties.java | 0 .../MultiverseCore/TestWorldPurger.java | 0 .../MultiverseCore/TestWorldStuff.java | 0 .../MultiverseCore/utils/FileUtilsTest.java | 0 .../utils/MVTestLogFormatter.java | 0 .../utils/MockWorldFactory.java | 0 .../utils/TestInstanceCreator.java | 0 .../MultiverseCore/utils/Util.java | 0 .../utils/WorldCreatorMatcher.java | 0 .../org.mockito.plugins.MockMaker | 0 15 files changed, 27 insertions(+), 7 deletions(-) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestDebugMode.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestModifyCommand.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestWorldProperties.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestWorldPurger.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/TestWorldStuff.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/utils/MVTestLogFormatter.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/utils/MockWorldFactory.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/utils/Util.java (100%) rename src/{test => old-test}/java/com/onarandombox/MultiverseCore/utils/WorldCreatorMatcher.java (100%) rename src/{test => old-test}/resources/mockito-extensions/org.mockito.plugins.MockMaker (100%) diff --git a/build.gradle b/build.gradle index d36d117a..394464cb 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,11 @@ repositories { } } +configurations { + oldTestImplementation.extendsFrom implementation + oldTestRuntime.extendsFrom runtime +} + dependencies { compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' @@ -88,6 +93,15 @@ dependencies { testImplementation 'junit:junit:4.13.1' testImplementation 'org.mockito:mockito-core:3.11.2' testImplementation 'commons-io:commons-io:2.7' + + // Old Tests + oldTestImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT' + oldTestImplementation('com.googlecode.json-simple:json-simple:1.1.1') { + exclude group: 'junit', module: 'junit' + } + oldTestImplementation 'junit:junit:4.13.1' + oldTestImplementation 'org.mockito:mockito-core:3.11.2' + oldTestImplementation 'commons-io:commons-io:2.7' } @@ -112,6 +126,19 @@ configurations { } } + +sourceSets { + oldTest { + java { + compileClasspath += main.output + runtimeClasspath += main.output + srcDir file('src/old-test/java') + } + resources.srcDir file('src/old-test/resources') + } +} + + publishing { publications { maven(MavenPublication) { @@ -191,10 +218,3 @@ shadowJar { build.dependsOn shadowJar jar.enabled = false - - -// Excludes all test -// TODO: Remove this when we have tests for MV5 -test { - exclude '**/*' -} diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestDebugMode.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestDebugMode.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestDebugMode.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestDebugMode.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestEntryFeeConversion.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java b/src/old-test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java rename to src/old-test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java rename to src/old-test/java/com/onarandombox/MultiverseCore/utils/FileUtilsTest.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/MVTestLogFormatter.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/MVTestLogFormatter.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/utils/MVTestLogFormatter.java rename to src/old-test/java/com/onarandombox/MultiverseCore/utils/MVTestLogFormatter.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/MockWorldFactory.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/MockWorldFactory.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/utils/MockWorldFactory.java rename to src/old-test/java/com/onarandombox/MultiverseCore/utils/MockWorldFactory.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java rename to src/old-test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/Util.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/Util.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/utils/Util.java rename to src/old-test/java/com/onarandombox/MultiverseCore/utils/Util.java diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/WorldCreatorMatcher.java b/src/old-test/java/com/onarandombox/MultiverseCore/utils/WorldCreatorMatcher.java similarity index 100% rename from src/test/java/com/onarandombox/MultiverseCore/utils/WorldCreatorMatcher.java rename to src/old-test/java/com/onarandombox/MultiverseCore/utils/WorldCreatorMatcher.java diff --git a/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/src/old-test/resources/mockito-extensions/org.mockito.plugins.MockMaker similarity index 100% rename from src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker rename to src/old-test/resources/mockito-extensions/org.mockito.plugins.MockMaker From ed73fd059eb59de925532dfe41f19ab007e53c14 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 02:07:38 -0500 Subject: [PATCH 37/69] Add Kotlin dependency for tests only. --- build.gradle | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 394464cb..77e6901d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,13 +5,18 @@ plugins { id 'maven-publish' id 'checkstyle' id 'com.github.johnrengelman.shadow' version '7.1.2' + id "org.jetbrains.kotlin.jvm" version "1.8.10" } version = System.getenv('GITHUB_VERSION') ?: 'local' group = 'com.onarandombox.multiversecore' description = 'Multiverse-Core' -java.sourceCompatibility = JavaVersion.VERSION_11 +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + } +} repositories { mavenLocal() @@ -86,6 +91,7 @@ dependencies { api 'org.jetbrains:annotations:22.0.0' // Tests + testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10' testImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT' testImplementation('com.googlecode.json-simple:json-simple:1.1.1') { exclude group: 'junit', module: 'junit' @@ -173,6 +179,19 @@ compileJava { source = prepareSource.outputs } +compileKotlin { + // We're not using Kotlin in the plugin itself, just tests! + enabled = false +} +configurations { + compileOnly { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' + } + runtimeOnly { + exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' + } +} + processResources { def props = [version: "${project.version}"] inputs.properties props @@ -214,6 +233,12 @@ shadowJar { configurations = [project.configurations.api] archiveFileName = "$baseName-$version.$extension" + + dependencies { + exclude(dependency { + it.moduleGroup == 'org.jetbrains.kotlin' + }) + } } build.dependsOn shadowJar From 698d1c7954ec7b9dd9295f2edb9ea90195f30d6e Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 02:10:36 -0500 Subject: [PATCH 38/69] Switch to JUnit 5 for new tests. --- build.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 77e6901d..c2c6dcd6 100644 --- a/build.gradle +++ b/build.gradle @@ -96,9 +96,7 @@ dependencies { testImplementation('com.googlecode.json-simple:json-simple:1.1.1') { exclude group: 'junit', module: 'junit' } - testImplementation 'junit:junit:4.13.1' - testImplementation 'org.mockito:mockito-core:3.11.2' - testImplementation 'commons-io:commons-io:2.7' + testImplementation 'org.jetbrains.kotlin:kotlin-test' // Old Tests oldTestImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT' @@ -243,3 +241,7 @@ shadowJar { build.dependsOn shadowJar jar.enabled = false + +test { + useJUnitPlatform() +} From eebb4a4a6d950d8e2289296eb56be97c6d627014 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 02:22:47 -0500 Subject: [PATCH 39/69] Implement initial test using MockBukkit. --- build.gradle | 4 +-- .../multiverse/core/MockBukkitTest.kt | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt diff --git a/build.gradle b/build.gradle index c2c6dcd6..2d632699 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ description = 'Multiverse-Core' java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(17)) } } @@ -92,7 +92,7 @@ dependencies { // Tests testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10' - testImplementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT' + testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.145.0' testImplementation('com.googlecode.json-simple:json-simple:1.1.1') { exclude group: 'junit', module: 'junit' } diff --git a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt new file mode 100644 index 00000000..68dffc62 --- /dev/null +++ b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt @@ -0,0 +1,33 @@ +package org.mvplugins.multiverse.core + +import be.seeseemelk.mockbukkit.MockBukkit +import com.onarandombox.MultiverseCore.MultiverseCore +import com.onarandombox.MultiverseCore.utils.TestingMode +import org.bukkit.Server +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertNotNull + +class MockBukkitTest { + + lateinit var server: Server + lateinit var plugin: MultiverseCore + + @BeforeTest + fun setUp() { + TestingMode.enable() + server = MockBukkit.mock() + plugin = MockBukkit.load(MultiverseCore::class.java) + } + + @Test + fun test() { + assertNotNull(plugin) + } + + @AfterTest + fun tearDown() { + MockBukkit.unmock() + } +} From fc7509cca6ab51360abf17f4b380be15747c1de0 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 08:35:30 -0500 Subject: [PATCH 40/69] Use a better test method name. --- src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt index 68dffc62..cf6be2f4 100644 --- a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt @@ -22,7 +22,7 @@ class MockBukkitTest { } @Test - fun test() { + fun `MockBukkit loads the plugin`() { assertNotNull(plugin) } From 65cb3f7037c271415f1a37a31c381096256e9d39 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 08:35:52 -0500 Subject: [PATCH 41/69] Put test method after tearDown. --- .../org/mvplugins/multiverse/core/MockBukkitTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt index cf6be2f4..8094910e 100644 --- a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt @@ -21,13 +21,13 @@ class MockBukkitTest { plugin = MockBukkit.load(MultiverseCore::class.java) } - @Test - fun `MockBukkit loads the plugin`() { - assertNotNull(plugin) - } - @AfterTest fun tearDown() { MockBukkit.unmock() } + + @Test + fun `MockBukkit loads the plugin`() { + assertNotNull(plugin) + } } From a4e84ad58107703c7f0c64acfb8a12a6c9ed7bfb Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Thu, 2 Mar 2023 08:36:43 -0500 Subject: [PATCH 42/69] Use ServerMock instead of Server. --- src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt index 8094910e..894125bf 100644 --- a/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/MockBukkitTest.kt @@ -1,9 +1,9 @@ package org.mvplugins.multiverse.core import be.seeseemelk.mockbukkit.MockBukkit +import be.seeseemelk.mockbukkit.ServerMock import com.onarandombox.MultiverseCore.MultiverseCore import com.onarandombox.MultiverseCore.utils.TestingMode -import org.bukkit.Server import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -11,7 +11,7 @@ import kotlin.test.assertNotNull class MockBukkitTest { - lateinit var server: Server + lateinit var server: ServerMock lateinit var plugin: MultiverseCore @BeforeTest From a255f55b6f6305d86c70f7cdb47427eda30389b2 Mon Sep 17 00:00:00 2001 From: Jeremy Wood Date: Fri, 3 Mar 2023 08:27:12 -0500 Subject: [PATCH 43/69] Downgrade MockBukkit to 2.141.0. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2d632699..98d22ad0 100644 --- a/build.gradle +++ b/build.gradle @@ -92,7 +92,7 @@ dependencies { // Tests testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10' - testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.145.0' + testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.141.0' testImplementation('com.googlecode.json-simple:json-simple:1.1.1') { exclude group: 'junit', module: 'junit' } From 3f6c3047d86b35698cad86aa6e4fa70d213781bf Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 3 Mar 2023 22:23:39 +0800 Subject: [PATCH 44/69] fix: Restore locales setup method (#2881) --- .../onarandombox/MultiverseCore/MultiverseCore.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index a9e3c2b1..41743b88 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -166,6 +166,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.anchorManager.loadAnchors(); this.registerEvents(); this.registerCommands(); + this.setUpLocales(); this.registerDestinations(); this.setupMetrics(); this.saveMVConfig(); @@ -217,6 +218,15 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.commandManager.registerCommand(new UnloadCommand(this)); } + /** + * Register locales + */ + private void setUpLocales() { + this.commandManager.usePerIssuerLocale(true, true); + this.commandManager.getLocales().addFileResClassLoader(this); + this.commandManager.getLocales().addMessageBundles("multiverse-core"); + } + /** * Register all the destinations. */ From 68c97f7ae6d1c634cc1f099f39f42cb2218e6ef7 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 3 Mar 2023 23:21:36 +0800 Subject: [PATCH 45/69] build: Add artifacting of PR build --- .github/workflows/test.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe2e3b1d..c5b55297 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,12 @@ jobs: distribution: 'adopt' cache: gradle + - name: Get PR number + id: pr + run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 @@ -26,4 +32,14 @@ jobs: with: arguments: build env: + GITHUB_VERSION: pr${{ steps.pr.outputs.pull_request_number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Staging artifact + run: mkdir staging && cp build/libs/*.jar staging + + - name: Artifact output + uses: actions/upload-artifact@v2 + with: + name: multiverse-core-pr${{ steps.pr.outputs.pull_request_number }} + path: staging From 3b44ea218dc84786addd0dc353e6ef587eeb5ed4 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 3 Mar 2023 23:28:55 +0800 Subject: [PATCH 46/69] build: Fix PR build number --- .github/workflows/test.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5b55297..68d7ff4e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,12 +18,6 @@ jobs: distribution: 'adopt' cache: gradle - - name: Get PR number - id: pr - run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 @@ -32,14 +26,11 @@ jobs: with: arguments: build env: - GITHUB_VERSION: pr${{ steps.pr.outputs.pull_request_number }} + GITHUB_VERSION: pr${{ github.event.pull_request.number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Staging artifact - run: mkdir staging && cp build/libs/*.jar staging - - name: Artifact output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: multiverse-core-pr${{ steps.pr.outputs.pull_request_number }} - path: staging + name: multiverse-core-pr${{ github.event.pull_request.number }} + path: build/libs/multiverse-core-pr${{ github.event.pull_request.number }}.jar From c9bb6180bdff69c6dd39966227e5b3e16138cd9e Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:22:11 -0500 Subject: [PATCH 47/69] i18n: Check command --- .../MultiverseCore/commands/CheckCommand.java | 11 +++++++---- .../onarandombox/MultiverseCore/utils/MVCorei18n.java | 2 ++ src/main/resources/multiverse-core_en.properties | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java index 99ebb735..95064770 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java @@ -9,6 +9,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.destination.ParsedDestination; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -22,18 +23,20 @@ public class CheckCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.check") @CommandCompletion("@players @destinations|@mvworlds") @Syntax(" ") - @Description("Checks if a player can teleport to a destination.") + @Description("{@@mv-core.check.description}") public void onCheckCommand(BukkitCommandIssuer issuer, @Syntax("") - @Description("Player to check destination on.") + @Description("{@@mv-core.check.player.description}") Player player, @Syntax("") - @Description("A destination location, e.g. a world name.") + @Description("{@@mv-core.check.destination.description}") ParsedDestination destination ) { - issuer.sendMessage("Checking " + player + " to " + destination + "..."); + issuer.sendInfo(MVCorei18n.CHECK_CHECKING, + "{player}", player.getName(), + "{destination}", destination.toString()); //TODO More detailed output on permissions required. this.plugin.getDestinationsProvider().checkTeleportPermissions(issuer, player, destination); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index c28e4cd4..51a657d7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -6,6 +6,8 @@ import co.aikar.locales.MessageKeyProvider; public enum MVCorei18n implements MessageKeyProvider { CONFIG_SAVE_FAILED, + // check command + CHECK_CHECKING, CREATE_PROPERTIES, CREATE_PROPERTIES_ENVIRONMENT, CREATE_PROPERTIES_SEED, diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 7fe64b28..aea5c824 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -1,5 +1,9 @@ mv-core.config.save.failed=&cUnable to save Multiverse-Core config.yml. Your changes will be temporary! +mv-core.check.description=Checks if a player can teleport to a destination. +mv-core.check.player.description=Player to check destination on. +mv-core.check.destination.description=A destination location, e.g. a world name. +mv-core.check.checking=Checking {player} to {destination} .. mv-core.create.description=Creates a new world and loads it. mv-core.create.name.description=New world name. mv-core.create.environment.description=The world's environment. See: /mv environments From 5e4e925bb19c2e5782c65e62950aa103d5ddf27d Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:22:45 -0500 Subject: [PATCH 48/69] i18n: Clone command --- .../MultiverseCore/commands/CloneCommand.java | 16 ++++++++++------ .../MultiverseCore/commands/ConfirmCommand.java | 2 +- .../MultiverseCore/utils/MVCorei18n.java | 5 +++++ src/main/resources/multiverse-core_en.properties | 7 +++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java index 366db444..49d88279 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java @@ -10,6 +10,7 @@ import co.aikar.commands.annotation.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; @@ -23,26 +24,29 @@ public class CloneCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.clone") @CommandCompletion("@mvworlds:scope=both @empty") @Syntax(" ") - @Description("Clones a world.") + @Description("{@@mv-core.clone.description}") public void onCloneCommand(CommandIssuer issuer, @Conditions("validWorldName:scope=both") @Syntax("") - @Description("The target world to clone.") + @Description("{@@mv-core.clone.world.description}") String worldName, @Single @Conditions("validWorldName:scope=new") @Syntax("") - @Description("The new cloned world name.") + @Description("{@@mv-core.clone.newWorld.description}") String newWorldName ) { - issuer.sendMessage(String.format("Cloning world '%s' to '%s'...", worldName, newWorldName)); + issuer.sendInfo(MVCorei18n.CLONE_CLONING, + "{world}", worldName, + "{newWorld}", newWorldName); if (!this.plugin.getMVWorldManager().cloneWorld(worldName, newWorldName)) { - issuer.sendMessage(String.format("%sWorld could not be cloned! See console for more details.", ChatColor.RED)); + issuer.sendInfo(MVCorei18n.CLONE_FAILED); return; } - issuer.sendMessage(String.format("%sCloned world '%s'!", ChatColor.GREEN, newWorldName)); + issuer.sendInfo(MVCorei18n.CLONE_SUCCESS, + "{world}", newWorldName); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java index 24d09f17..a96e4368 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java @@ -16,7 +16,7 @@ public class ConfirmCommand extends MultiverseCoreCommand { @Subcommand("confirm") @CommandPermission("multiverse.core.confirm") - @Description("Confirms dangerous commands before executing them.") + @Description("{@@mv-core.confirm.description}") public void onConfirmCommand(@NotNull BukkitCommandIssuer issuer) { this.plugin.getMVCommandManager().getCommandQueueManager().runQueuedCommand(issuer.getIssuer()); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 51a657d7..eeca6d87 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -8,6 +8,11 @@ public enum MVCorei18n implements MessageKeyProvider { // check command CHECK_CHECKING, + + // clone command + CLONE_CLONING, + CLONE_FAILED, + CLONE_SUCCESS, CREATE_PROPERTIES, CREATE_PROPERTIES_ENVIRONMENT, CREATE_PROPERTIES_SEED, diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index aea5c824..016f05ed 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -4,6 +4,13 @@ mv-core.check.description=Checks if a player can teleport to a destination. mv-core.check.player.description=Player to check destination on. mv-core.check.destination.description=A destination location, e.g. a world name. mv-core.check.checking=Checking {player} to {destination} .. + +mv-core.clone.description=Clones a world. +mv-core.clone.world.description=The target world to clone. +mv-core.clone.newWorld.description=The new cloned world name. +mv-core.clone.cloning=Cloning world '{world}' to '{newworld}'... +mv-core.clone.failed=World could not be cloned! See console for more details. +mv-core.clone.success=Cloned world '{world}'! mv-core.create.description=Creates a new world and loads it. mv-core.create.name.description=New world name. mv-core.create.environment.description=The world's environment. See: /mv environments From fa0e9f42680f02699e8766e31b39f00c68e7a8e3 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:23:27 -0500 Subject: [PATCH 49/69] i18n: Delete command --- .../MultiverseCore/commands/DeleteCommand.java | 15 ++++++++++----- .../MultiverseCore/utils/MVCorei18n.java | 5 +++++ src/main/resources/multiverse-core_en.properties | 5 +++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java index 667666c1..d6606b2f 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java @@ -10,7 +10,9 @@ import co.aikar.commands.annotation.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.api.MVCore; import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; @@ -24,7 +26,7 @@ public class DeleteCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.delete") @CommandCompletion("@mvworlds:scope=both") @Syntax("") - @Description("Deletes a world on your server PERMANENTLY.") + @Description("{@@mv-core.delete.description}") public void onDeleteCommand(BukkitCommandIssuer issuer, @Single @@ -36,14 +38,17 @@ public class DeleteCommand extends MultiverseCoreCommand { this.plugin.getMVCommandManager().getCommandQueueManager().addToQueue(new QueuedCommand( issuer.getIssuer(), () -> { - issuer.sendMessage(String.format("Deleting world '%s'...", worldName)); + issuer.sendInfo(MVCorei18n.DELETE_DELETING, + "{world}", worldName); if (!this.plugin.getMVWorldManager().deleteWorld(worldName)) { - issuer.sendMessage(String.format("%sThere was an issue deleting '%s'! Please check console for errors.", ChatColor.RED, worldName)); + issuer.sendInfo(MVCorei18n.DELETE_FAILED, + "{world}", worldName); return; } - issuer.sendMessage(String.format("%sWorld %s was deleted!", ChatColor.GREEN, worldName)); + issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, + "{world}", worldName); }, - "Are you sure you want to delete world '" + worldName + "'?" + "{@@mv-core.delete.prompt}".replace("{world}", worldName) )); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index eeca6d87..bce19508 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -24,6 +24,11 @@ public enum MVCorei18n implements MessageKeyProvider { CREATE_FAILED, CREATE_SUCCESS, + // delete command + DELETE_DELETING, + DELETE_FAILED, + DELETE_SUCCESS, + DELETE_PROMPT, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 016f05ed..6ec4f4a6 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -26,6 +26,11 @@ mv-core.create.loading=Creating world... mv-core.create.failed=&cFailed to create world '{worldName}'! See console for details. mv-core.create.success=&aWorld '{worldName}' created successfully! +mv-core.delete.description=Deletes a world on your server PERMANENTLY. +mv-core.delete.deleting=Deleting world '{world}'... +mv-core.delete.failed=There was an issue deleting '{world}'! Please check console for errors. +mv-core.delete.success=World {world} was deleted! +mv-core.delete.prompt=Are you sure you want to delete world '{world}'? mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 9e5fb2cf4b9cb6c3918b5feb000589eba4fde351 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:23:49 -0500 Subject: [PATCH 50/69] i18n: Gamerule command --- .../commands/GameruleCommand.java | 25 +++++++++++++------ .../MultiverseCore/utils/MVCorei18n.java | 5 ++++ .../resources/multiverse-core_en.properties | 8 ++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java index 003a453c..ce82400e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java @@ -11,6 +11,7 @@ import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.MultiverseCore.commandtools.context.GameRuleValue; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.bukkit.GameRule; import org.jetbrains.annotations.NotNull; @@ -25,20 +26,20 @@ public class GameruleCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.gamerule") @CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*") @Syntax(" [World or *]") - @Description("Changes a gamerule in one or more worlds") + @Description("{@@mv-core.gamerule.description}") public void onGameruleCommand(BukkitCommandIssuer issuer, @Syntax("") - @Description("Gamerule to set") + @Description("{@@mv-core.gamerule.gamerule.description}") GameRule gamerule, @Syntax("") - @Description("Value of gamerule") + @Description("{@@mv-core.gamerule.value.description}") GameRuleValue gameRuleValue, @Flags("resolve=issuerAware") @Syntax("[World or *]") - @Description("World to apply gamerule to, current world by default") + @Description("{@@mv-core.gamerule.world.description}") MVWorld[] worlds ) { Object value = gameRuleValue.getValue(); @@ -46,17 +47,27 @@ public class GameruleCommand extends MultiverseCoreCommand { for(MVWorld world : worlds) { // Set gamerules and add false to list if it fails if (!world.getCBWorld().setGameRule(gamerule, value)) { - issuer.sendMessage(ChatColor.RED + "Failed to set gamerule " + gamerule.getName() + " to " + value + " in " + world.getName() + ". It should be a " + gamerule.getType()); + issuer.sendInfo(MVCorei18n.GAMERULE_FAILED, + "{gamerule}", gamerule.getName(), + "{value}", value.toString(), + "{world}", world.getName(), + "{type}", gamerule.getType().getName()); success = false; } } // Tell user if it was successful if (success) { if (worlds.length == 1) { - issuer.sendMessage(ChatColor.GREEN + "Successfully set " + gamerule.getName() + " to " + value + " in " + worlds[0].getName()); + issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_SINGLE, + "{gamerule}", gamerule.getName(), + "{value}", value.toString(), + "{world}", worlds[0].getName()); } else if (worlds.length > 1) { - issuer.sendMessage(ChatColor.GREEN + "Successfully set " + gamerule.getName() + " to " + value + " in " + worlds.length + " worlds."); + issuer.sendInfo(MVCorei18n.GAMERULE_SUCCESS_MULTIPLE, + "{gamerule}", gamerule.getName(), + "{value}", value.toString(), + "{count}", String.valueOf(worlds.length)); } } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index bce19508..3c468410 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -29,6 +29,11 @@ public enum MVCorei18n implements MessageKeyProvider { DELETE_FAILED, DELETE_SUCCESS, DELETE_PROMPT, + + // gamerule command + GAMERULE_FAILED, + GAMERULE_SUCCESS_SINGLE, + GAMERULE_SUCCESS_MULTIPLE, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 6ec4f4a6..9767009d 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -31,6 +31,14 @@ mv-core.delete.deleting=Deleting world '{world}'... mv-core.delete.failed=There was an issue deleting '{world}'! Please check console for errors. mv-core.delete.success=World {world} was deleted! mv-core.delete.prompt=Are you sure you want to delete world '{world}'? + +mv-core.gamerule.description=Changes a gamerule in one or more worlds +mv-core.gamerule.gamerule.description=Gamerule to set +mv-core.gamerule.value.description=Value of gamerule +mv-core.gamerule.world.description=World to apply gamerule to, current world by default +mv-core.gamerule.failed=Failed to set gamerule {gamerule} to {value} in {world}. It should be a {type}. +mv-core.gamerule.success.single=Successfully set {gamerule} to {value} in {world}. +mv-core.gamerule.success.multiple=Successfully set {gamerule} to {value} in {count} worlds. mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 38002261b7c0cbbf623e5d893be80850f7ff5e92 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:24:31 -0500 Subject: [PATCH 51/69] i18n: Import command --- .../MultiverseCore/commands/ImportCommand.java | 17 ++++++++++------- .../MultiverseCore/utils/MVCorei18n.java | 5 +++++ .../resources/multiverse-core_en.properties | 8 ++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java index 2cc80ef6..10642ce9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java @@ -13,10 +13,12 @@ import co.aikar.commands.annotation.Optional; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.api.MVCore; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlag; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup; import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag; import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.World; @@ -51,26 +53,27 @@ public class ImportCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.import") @CommandCompletion("@mvworlds:scope=potential @flags:groupName=mvimport") @Syntax(" --generator [generator[:id]] --adjust-spawn") - @Description("Imports a existing world folder.") + @Description("{@@mv-core.import.description") public void onImportCommand(BukkitCommandIssuer issuer, @Conditions("validWorldName:scope=new") @Syntax("") - @Description("Name of the world folder.") + @Description("{@@mv-core.import.name.description}") String worldName, @Syntax("") - @Description("The world's environment. See: /mv env") + @Description("{@@mv-core.import.env.description}") World.Environment environment, @Optional @Syntax("--generator [generator[:id]] --adjust-spawn") - @Description("Other world settings. See: https://gg.gg/nn8c2") + @Description("{@@mv-core.import.other.description}") String[] flags) { ParsedCommandFlags parsedFlags = parseFlags(flags); - issuer.sendMessage(String.format("Starting import of world '%s'...", worldName)); + issuer.sendInfo(MVCorei18n.IMPORT_IMPORTING, + "{world}", worldName); if (!this.worldManager.addWorld( worldName, environment, @@ -80,9 +83,9 @@ public class ImportCommand extends MultiverseCoreCommand { parsedFlags.flagValue("--generator", String.class), parsedFlags.hasFlag("--adjust-spawn")) ) { - issuer.sendMessage(String.format("%sFailed! See console for more details.", ChatColor.RED)); + issuer.sendInfo(MVCorei18n.IMPORT_FAILED); return; } - issuer.sendMessage(String.format("%sComplete!", ChatColor.GREEN)); + issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 3c468410..7076bbdb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -34,6 +34,11 @@ public enum MVCorei18n implements MessageKeyProvider { GAMERULE_FAILED, GAMERULE_SUCCESS_SINGLE, GAMERULE_SUCCESS_MULTIPLE, + + // import command + IMPORT_IMPORTING, + IMPORT_FAILED, + IMPORT_SUCCESS, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 9767009d..3dc160fe 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -39,6 +39,14 @@ mv-core.gamerule.world.description=World to apply gamerule to, current world by mv-core.gamerule.failed=Failed to set gamerule {gamerule} to {value} in {world}. It should be a {type}. mv-core.gamerule.success.single=Successfully set {gamerule} to {value} in {world}. mv-core.gamerule.success.multiple=Successfully set {gamerule} to {value} in {count} worlds. + +mv-core.import.description=Imports an existing world folder. +mv-core.import.name.description=Name of the world folder. +mv-core.import.env.description=The world's environment. See: /mv env +mv-core.import.other.description=Other world settings. See: https://gg.gg/nn8c2 +mv-core.import.importing=Starting import of world '{world}'... +mv-core.import.failed=Failed! See console for more details. +mv-core.import.success=Complete! mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 8b450910ba334574219e10acb972d1c3bc7580ca Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:24:48 -0500 Subject: [PATCH 52/69] i18n: Load command --- .../MultiverseCore/commands/LoadCommand.java | 14 +++++++++----- .../MultiverseCore/utils/MVCorei18n.java | 5 +++++ src/main/resources/multiverse-core_en.properties | 6 ++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java index 0e03eab4..239bde50 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java @@ -10,6 +10,7 @@ import co.aikar.commands.annotation.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.jetbrains.annotations.NotNull; @CommandAlias("mv") @@ -22,21 +23,24 @@ public class LoadCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.load") @CommandCompletion("@mvworlds:scope=unloaded") @Syntax("") - @Description("Loads a world. World must be already in worlds.yml, else please use /mv import.") + @Description("{@@mv-core.load.description}") public void onLoadCommand(BukkitCommandIssuer issuer, @Single @Conditions("validWorldName:scope=unloaded") @Syntax("") - @Description("Name of world you want to load.") + @Description("{@@mv-core.load.world.description}") String worldName ) { - issuer.sendMessage(String.format("Loading world '%s'...", worldName)); + issuer.sendInfo(MVCorei18n.LOAD_LOADING, + "{world}", worldName); if (!this.plugin.getMVWorldManager().loadWorld(worldName)) { - issuer.sendMessage(String.format("Error trying to load world '%s'!", worldName)); + issuer.sendInfo(MVCorei18n.LOAD_FAILED, + "{world}", worldName); return; } - issuer.sendMessage(String.format("Loaded world '%s'!", worldName)); + issuer.sendInfo(MVCorei18n.LOAD_SUCCESS, + "{world}", worldName); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 7076bbdb..55d31d9d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -39,6 +39,11 @@ public enum MVCorei18n implements MessageKeyProvider { IMPORT_IMPORTING, IMPORT_FAILED, IMPORT_SUCCESS, + + // load command + LOAD_LOADING, + LOAD_FAILED, + LOAD_SUCCESS, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 3dc160fe..46c06ae8 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -47,6 +47,12 @@ mv-core.import.other.description=Other world settings. See: https://gg.gg/nn8c2 mv-core.import.importing=Starting import of world '{world}'... mv-core.import.failed=Failed! See console for more details. mv-core.import.success=Complete! + +mv-core.load.description=Loads a world. World must be already in worlds.yml, else please use /mv import. +mv-core.load.world.description=Name of world you want to load. +mv-core.load.loading=Loading world '{world}'... +mv-core.load.failed=Error trying to load world '{world}'! +mv-core.load.success=Loaded world '{world}'! mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 3e468dba4d4c8e9623b46dbc5149e1206f1a22d8 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:25:06 -0500 Subject: [PATCH 53/69] i18n: Regen command --- .../MultiverseCore/commands/RegenCommand.java | 18 +++++++++++------- .../MultiverseCore/utils/MVCorei18n.java | 6 ++++++ .../resources/multiverse-core_en.properties | 8 ++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java index 40102078..33e8ac6a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java @@ -18,6 +18,7 @@ import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagGroup; import com.onarandombox.MultiverseCore.commandtools.flags.CommandValueFlag; import com.onarandombox.MultiverseCore.commandtools.flags.ParsedCommandFlags; import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; @@ -42,17 +43,17 @@ public class RegenCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.regen") @CommandCompletion("@mvworlds:scope=both @flags:groupName=mvregen") @Syntax(" --seed [seed] --keep-gamerules") - @Description("Regenerates a world on your server. The previous state will be lost PERMANENTLY.") + @Description("{@@mv-core.regen.description}") public void onRegenCommand(BukkitCommandIssuer issuer, @Conditions("validWorldName:scope=both") @Syntax("") - @Description("World that you want to regen.") + @Description("{@@mv-core.regen.world.description}") String worldName, @Optional @Syntax("--seed [seed] --keep-gamerules") - @Description("Other world settings. See: http://gg.gg/nn8lk") + @Description("{@@mv-core.regen.other.description}") String[] flags ) { ParsedCommandFlags parsedFlags = parseFlags(flags); @@ -60,7 +61,8 @@ public class RegenCommand extends MultiverseCoreCommand { this.plugin.getMVCommandManager().getCommandQueueManager().addToQueue(new QueuedCommand( issuer.getIssuer(), () -> { - issuer.sendMessage(String.format("Regenerating world '%s'...", worldName)); + issuer.sendInfo(MVCorei18n.REGEN_REGENERATING, + "{world}", worldName); if (!this.plugin.getMVWorldManager().regenWorld( worldName, parsedFlags.hasFlag("--seed"), @@ -68,12 +70,14 @@ public class RegenCommand extends MultiverseCoreCommand { parsedFlags.flagValue("--seed", String.class), parsedFlags.hasFlag("--keep-gamerules") )) { - issuer.sendMessage(String.format("%sThere was an issue regenerating '%s'! Please check console for errors.", ChatColor.RED, worldName)); + issuer.sendInfo(MVCorei18n.REGEN_FAILED, + "{world}", worldName); return; } - issuer.sendMessage(String.format("%sWorld %s was regenerated!", ChatColor.GREEN, worldName)); + issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, + "{world}", worldName); }, - "Are you sure you want to regenerate world '" + worldName + "'?" + "{@@mv-core.regen.prompt}".replace("{world}", worldName) )); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 55d31d9d..2248652b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -44,6 +44,12 @@ public enum MVCorei18n implements MessageKeyProvider { LOAD_LOADING, LOAD_FAILED, LOAD_SUCCESS, + + // regen command + REGEN_REGENERATING, + REGEN_FAILED, + REGEN_SUCCESS, + REGEN_PROMPT, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 46c06ae8..816a4039 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -53,6 +53,14 @@ mv-core.load.world.description=Name of world you want to load. mv-core.load.loading=Loading world '{world}'... mv-core.load.failed=Error trying to load world '{world}'! mv-core.load.success=Loaded world '{world}'! + +mv-core.regen.description=Regenerates a world on your server. The previous state will be lost PERMANENTLY. +mv-core.regen.world.description=World that you want to regen. +mv-core.regen.other.description=Other world settings. See: http://gg.gg/nn8lk +mv-core.regen.regenerating=Regenerating world '{world}'... +mv-core.regen.failed=There was an issue regenerating '{world}'! Please check console for errors. +mv-core.regen.success=World {world} was regenerated! +mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'? mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From ca0f6febb5086332fd11bf9966eb14f228cac3b2 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:25:26 -0500 Subject: [PATCH 54/69] i18n: Reload command --- .../MultiverseCore/commands/ReloadCommand.java | 8 +++++--- .../com/onarandombox/MultiverseCore/utils/MVCorei18n.java | 4 ++++ src/main/resources/multiverse-core_en.properties | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java index 2f71394c..1adaba2a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java @@ -10,6 +10,7 @@ import co.aikar.commands.annotation.Description; import co.aikar.commands.annotation.Subcommand; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; @@ -21,9 +22,9 @@ public class ReloadCommand extends MultiverseCoreCommand { @Subcommand("reload") @CommandPermission("multiverse.core.reload") - @Description("Reloads config files for all multiverse modules.") + @Description("{@@mv-core.reload.description}") public void onReloadCommand(@NotNull BukkitCommandIssuer issuer) { - issuer.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs..."); + issuer.sendInfo(MVCorei18n.RELOAD_RELOADING); this.plugin.loadConfigs(); this.plugin.getAnchorManager().loadAnchors(); this.plugin.getMVWorldManager().loadWorlds(true); @@ -36,7 +37,8 @@ public class ReloadCommand extends MultiverseCoreCommand { MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded); this.plugin.getServer().getPluginManager().callEvent(configReload); + // @TODO: replace this sendMessage and format the configsLoaded above, maybe? configReload.getAllConfigsLoaded().forEach(issuer::sendMessage); - issuer.sendMessage(String.format("%sReload Complete!", ChatColor.GREEN)); + issuer.sendInfo(MVCorei18n.RELOAD_SUCCESS); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 2248652b..763c2c98 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -50,6 +50,10 @@ public enum MVCorei18n implements MessageKeyProvider { REGEN_FAILED, REGEN_SUCCESS, REGEN_PROMPT, + + // reload command + RELOAD_RELOADING, + RELOAD_SUCCESS, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 816a4039..fd2a355d 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -61,6 +61,10 @@ mv-core.regen.regenerating=Regenerating world '{world}'... mv-core.regen.failed=There was an issue regenerating '{world}'! Please check console for errors. mv-core.regen.success=World {world} was regenerated! mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'? + +mv-core.reload.description=Reloads config files for all Multiverse modules. +mv-core.reload.reloading=Reloading all Multiverse Plugin configs... +mv-core.reload.success=Reload complete! mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 12f6ceb622b2bf6d65e86d9bf1a908c924aa32e1 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:26:02 -0500 Subject: [PATCH 55/69] i18n: Remove command --- .../MultiverseCore/commands/RemoveCommand.java | 10 ++++++---- .../onarandombox/MultiverseCore/utils/MVCorei18n.java | 4 ++++ src/main/resources/multiverse-core_en.properties | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java index e011a2ca..2032af53 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java @@ -10,6 +10,7 @@ import co.aikar.commands.annotation.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; @@ -23,19 +24,20 @@ public class RemoveCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.remove") @CommandCompletion("@mvworlds:scope=both") @Syntax("") - @Description("Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.") + @Description("{@@mv-core.remove.description}") public void onRemoveCommand(BukkitCommandIssuer issuer, @Single @Conditions("mvworlds:scope=both") @Syntax("") - @Description("World you want to remove from mv's knowledge.") + @Description("{@@mv-core.remove.world.description}") String worldName ) { if (!this.plugin.getMVWorldManager().removeWorldFromConfig(worldName)) { - issuer.sendMessage(String.format("%sError trying to remove world from config!", ChatColor.RED)); + issuer.sendInfo(MVCorei18n.REMOVE_FAILED); return; } - issuer.sendMessage(String.format("World '%s' is removed from config!", worldName)); + issuer.sendInfo(MVCorei18n.REMOVE_SUCCESS, + "{world}", worldName); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 763c2c98..77274bdb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -54,6 +54,10 @@ public enum MVCorei18n implements MessageKeyProvider { // reload command RELOAD_RELOADING, RELOAD_SUCCESS, + + // remove command + REMOVE_FAILED, + REMOVE_SUCCESS, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index fd2a355d..9ffd0a31 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -65,6 +65,11 @@ mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'? mv-core.reload.description=Reloads config files for all Multiverse modules. mv-core.reload.reloading=Reloading all Multiverse Plugin configs... mv-core.reload.success=Reload complete! + +mv-core.remove.description=Unloads a world from Multiverse and removes it from worlds.yml. This does NOT delete the world folder. +mv-core.remove.world.description=World you want to remove from MV's knowledge. +mv-core.remove.failed=Error trying to remove world from config! +mv-core.remove.success=World '{world}' is removed from config! mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 216adf5fa946c8461ee66372cff95f0728f12b9c Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:26:50 -0500 Subject: [PATCH 56/69] i18n: MV Root command --- .../onarandombox/MultiverseCore/commands/RootCommand.java | 7 +++++-- .../com/onarandombox/MultiverseCore/utils/MVCorei18n.java | 4 ++++ src/main/resources/multiverse-core_en.properties | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java index 8e9f9518..8d63d32a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RootCommand.java @@ -3,6 +3,7 @@ package com.onarandombox.MultiverseCore.commands; import co.aikar.commands.CommandIssuer; import co.aikar.commands.annotation.CommandAlias; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.ChatColor; import org.bukkit.plugin.PluginDescriptionFile; import org.jetbrains.annotations.NotNull; @@ -15,7 +16,9 @@ public class RootCommand extends MultiverseCoreCommand { @CommandAlias("mv") public void onRootCommand(CommandIssuer issuer) { PluginDescriptionFile description = this.plugin.getDescription(); - issuer.sendMessage(ChatColor.GREEN + description.getName() + " version " + description.getVersion()); - issuer.sendMessage(ChatColor.GREEN + "See " + ChatColor.WHITE + "/mv help" + ChatColor.GREEN + " for commands available."); + issuer.sendInfo(MVCorei18n.ROOT_TITLE, + "{name}", description.getName(), + "{version}", description.getVersion()); + issuer.sendInfo(MVCorei18n.ROOT_HELP); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 77274bdb..fd0c8008 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -58,6 +58,10 @@ public enum MVCorei18n implements MessageKeyProvider { // remove command REMOVE_FAILED, REMOVE_SUCCESS, + + // root MV command + ROOT_TITLE, + ROOT_HELP, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 9ffd0a31..26d78efc 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -70,6 +70,9 @@ mv-core.remove.description=Unloads a world from Multiverse and removes it from w mv-core.remove.world.description=World you want to remove from MV's knowledge. mv-core.remove.failed=Error trying to remove world from config! mv-core.remove.success=World '{world}' is removed from config! + +mv-core.root.title={name} version {version} +mv-core.root.help=See /mv help for commands available. mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From a9896df2a77ce98c682dbc3c097c2738cf1ba3f6 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:27:08 -0500 Subject: [PATCH 57/69] i18n: Teleport command --- .../MultiverseCore/commands/TeleportCommand.java | 13 +++++++------ .../MultiverseCore/utils/MVCorei18n.java | 3 +++ src/main/resources/multiverse-core_en.properties | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java index 78e507f5..6b72b7f6 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/TeleportCommand.java @@ -10,6 +10,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.destination.ParsedDestination; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.bukkit.entity.Player; @CommandAlias("mv") @@ -21,23 +22,23 @@ public class TeleportCommand extends MultiverseCoreCommand { @Subcommand("teleport|tp") @CommandCompletion("@players|@mvworlds:playerOnly|@destinations:playerOnly @mvworlds|@destinations") @Syntax("[player] ") - @Description("Allows you to the teleport to a location on your server!") + @Description("{@@mv-core.teleport.description}") public void onTeleportCommand(BukkitCommandIssuer issuer, @Flags("resolve=issuerAware") @Syntax("[player]") - @Description("Target player to teleport.") + @Description("{@@mv-core.teleport.player.description}") Player[] players, @Syntax("") - @Description("Location, can be a world name.") + @Description("{@@mv-core.teleport.destination.description}") ParsedDestination destination ) { // TODO Add warning if teleporting too many players at once. for (Player player : players) { - issuer.sendMessage("Teleporting " - + (issuer.getPlayer() == player ? "you" : player.getName()) - + " to " + destination + "..."); + issuer.sendInfo(MVCorei18n.TELEPORT_SUCCESS, + "{player}", issuer.getPlayer() == player ? "you" : player.getName(), + "{destination}", destination.toString()); this.plugin.getDestinationsProvider().playerTeleport(issuer, player, destination); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index fd0c8008..eb566bd5 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -62,6 +62,9 @@ public enum MVCorei18n implements MessageKeyProvider { // root MV command ROOT_TITLE, ROOT_HELP, + + // teleport command + TELEPORT_SUCCESS, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 26d78efc..6944c621 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -73,6 +73,11 @@ mv-core.remove.success=World '{world}' is removed from config! mv-core.root.title={name} version {version} mv-core.root.help=See /mv help for commands available. + +mv-core.teleport.description=Allows you to teleport to a location on your server! +mv-core.teleport.player.description=Target player to teleport. +mv-core.teleport.destination.description=Location, can be a world name. +mv-core.teleport.success=Teleporting {player} to {destination}... mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 0512fa18202e1adf56d02470a6cd6394251c65c8 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:27:27 -0500 Subject: [PATCH 58/69] i18n: Unload command --- .../MultiverseCore/commands/UnloadCommand.java | 14 +++++++++----- .../MultiverseCore/utils/MVCorei18n.java | 5 +++++ src/main/resources/multiverse-core_en.properties | 6 ++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java index 268788bc..0142c4a0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java @@ -9,6 +9,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorld; +import com.onarandombox.MultiverseCore.utils.MVCorei18n; import org.jetbrains.annotations.NotNull; @CommandAlias("mv") @@ -21,20 +22,23 @@ public class UnloadCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.unload") @CommandCompletion("@mvworlds") @Syntax("") - @Description("Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.") + @Description("{@@mv-core.unload.description}") public void onUnloadCommand(BukkitCommandIssuer issuer, @Syntax("") - @Description("Name of the world you want to unload.") + @Description("{@@mv-core.unload.world.description}") MVWorld world ) { - issuer.sendMessage(String.format("Unloading world '%s'...", world.getColoredWorldString())); + issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING, + "{world}", world.getColoredWorldString()); //TODO API: Should be able to use MVWorld object directly if (!this.plugin.getMVWorldManager().unloadWorld(world.getName())) { - issuer.sendMessage(String.format("Error unloading world '%s'! See console for more details.", world.getColoredWorldString())); + issuer.sendInfo(MVCorei18n.UNLOAD_FAILURE, + "{world}", world.getColoredWorldString()); return; } - issuer.sendMessage(String.format("Unloaded world '%s'!", world.getColoredWorldString())); + issuer.sendInfo(MVCorei18n.UNLOAD_SUCCESS, + "{world}", world.getColoredWorldString()); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index eb566bd5..58405b8c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -65,6 +65,11 @@ public enum MVCorei18n implements MessageKeyProvider { // teleport command TELEPORT_SUCCESS, + + // unload command + UNLOAD_UNLOADING, + UNLOAD_FAILURE, + UNLOAD_SUCCESS, DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 6944c621..d33f83b1 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -78,6 +78,12 @@ mv-core.teleport.description=Allows you to teleport to a location on your server mv-core.teleport.player.description=Target player to teleport. mv-core.teleport.destination.description=Location, can be a world name. mv-core.teleport.success=Teleporting {player} to {destination}... + +mv-core.unload.description=Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file. +mv-core.unload.world.description=Name of the world you want to unload. +mv-core.unload.unloading=Unloading world '{world}'... +mv-core.unload.failure=Error unloading world '{world}'! See console for more details. +mv-core.unload.success=Unloaded world '{world}'! mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From fd237243a42cc36381f82c625a9b75f49c6eeefa Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:27:41 -0500 Subject: [PATCH 59/69] i18n: Usage command --- .../com/onarandombox/MultiverseCore/commands/UsageCommand.java | 2 +- src/main/resources/multiverse-core_en.properties | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java index e0c63b6e..b2e2acc4 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/UsageCommand.java @@ -22,7 +22,7 @@ public class UsageCommand extends MultiverseCoreCommand { @CommandPermission("multiverse.core.help") @CommandCompletion("@commands:mv") @Syntax("[filter] [page]") - @Description("Show Multiverse-Core Command usage.") + @Description("{@@mv-core.usage.description}") public void onUsageCommand(CommandHelp help) { if (help.getIssuer().isPlayer()) { // Prevent flooding the chat diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index d33f83b1..ff547a2c 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -84,6 +84,9 @@ mv-core.unload.world.description=Name of the world you want to unload. mv-core.unload.unloading=Unloading world '{world}'... mv-core.unload.failure=Error unloading world '{world}'! See console for more details. mv-core.unload.success=Unloaded world '{world}'! + +mv-core.usage.description=Show Multiverse-Core command usage. + mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 992ce7cff51bc49f868acf141394222cdb380220 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 11:27:58 -0500 Subject: [PATCH 60/69] i18n: more sections & missing confirm description --- .../com/onarandombox/MultiverseCore/utils/MVCorei18n.java | 5 +++++ src/main/resources/multiverse-core_en.properties | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java index 58405b8c..1dc79b9a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/MVCorei18n.java @@ -4,6 +4,7 @@ import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; public enum MVCorei18n implements MessageKeyProvider { + // config status CONFIG_SAVE_FAILED, // check command @@ -13,6 +14,8 @@ public enum MVCorei18n implements MessageKeyProvider { CLONE_CLONING, CLONE_FAILED, CLONE_SUCCESS, + + // create command CREATE_PROPERTIES, CREATE_PROPERTIES_ENVIRONMENT, CREATE_PROPERTIES_SEED, @@ -70,6 +73,8 @@ public enum MVCorei18n implements MessageKeyProvider { UNLOAD_UNLOADING, UNLOAD_FAILURE, UNLOAD_SUCCESS, + + // debug command DEBUG_INFO_OFF, DEBUG_INFO_ON; diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index ff547a2c..7144062a 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -11,6 +11,9 @@ mv-core.clone.newWorld.description=The new cloned world name. mv-core.clone.cloning=Cloning world '{world}' to '{newworld}'... mv-core.clone.failed=World could not be cloned! See console for more details. mv-core.clone.success=Cloned world '{world}'! + +mv-core.confirm.description=Confirms dangerous commands before executing them. + mv-core.create.description=Creates a new world and loads it. mv-core.create.name.description=New world name. mv-core.create.environment.description=The world's environment. See: /mv environments From ac31a66a459ca2b60eba412b8d206619514fba86 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 17:40:22 -0500 Subject: [PATCH 61/69] i18n: Preserve original string colorization. --- .../resources/multiverse-core_en.properties | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 7144062a..8ee14981 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -9,7 +9,7 @@ mv-core.clone.description=Clones a world. mv-core.clone.world.description=The target world to clone. mv-core.clone.newWorld.description=The new cloned world name. mv-core.clone.cloning=Cloning world '{world}' to '{newworld}'... -mv-core.clone.failed=World could not be cloned! See console for more details. +mv-core.clone.failed=&cWorld could not be cloned! &fSee console for more details. mv-core.clone.success=Cloned world '{world}'! mv-core.confirm.description=Confirms dangerous commands before executing them. @@ -26,56 +26,56 @@ mv-core.create.properties.adjustspawn=- Adjust Spawn: {adjustSpawn} mv-core.create.properties.generator=- Generator: {generator} mv-core.create.properties.structures=- Structures: {structures} mv-core.create.loading=Creating world... -mv-core.create.failed=&cFailed to create world '{worldName}'! See console for details. +mv-core.create.failed=&cFailed to create world '{worldName}'! &fSee console for details. mv-core.create.success=&aWorld '{worldName}' created successfully! mv-core.delete.description=Deletes a world on your server PERMANENTLY. mv-core.delete.deleting=Deleting world '{world}'... -mv-core.delete.failed=There was an issue deleting '{world}'! Please check console for errors. -mv-core.delete.success=World {world} was deleted! +mv-core.delete.failed=&cThere was an issue deleting '{world}'! &fPlease check console for errors. +mv-core.delete.success=&aWorld {world} was deleted! mv-core.delete.prompt=Are you sure you want to delete world '{world}'? mv-core.gamerule.description=Changes a gamerule in one or more worlds mv-core.gamerule.gamerule.description=Gamerule to set mv-core.gamerule.value.description=Value of gamerule mv-core.gamerule.world.description=World to apply gamerule to, current world by default -mv-core.gamerule.failed=Failed to set gamerule {gamerule} to {value} in {world}. It should be a {type}. -mv-core.gamerule.success.single=Successfully set {gamerule} to {value} in {world}. -mv-core.gamerule.success.multiple=Successfully set {gamerule} to {value} in {count} worlds. +mv-core.gamerule.failed=&cFailed to set gamerule {gamerule} to {value} in {world}. &fIt should be a {type}. +mv-core.gamerule.success.single=&aSuccessfully set {gamerule} to {value} in {world}. +mv-core.gamerule.success.multiple=&aSuccessfully set {gamerule} to {value} in {count} worlds. mv-core.import.description=Imports an existing world folder. mv-core.import.name.description=Name of the world folder. mv-core.import.env.description=The world's environment. See: /mv env mv-core.import.other.description=Other world settings. See: https://gg.gg/nn8c2 mv-core.import.importing=Starting import of world '{world}'... -mv-core.import.failed=Failed! See console for more details. -mv-core.import.success=Complete! +mv-core.import.failed=&cFailed! &fSee console for more details. +mv-core.import.success=&aComplete! mv-core.load.description=Loads a world. World must be already in worlds.yml, else please use /mv import. mv-core.load.world.description=Name of world you want to load. mv-core.load.loading=Loading world '{world}'... -mv-core.load.failed=Error trying to load world '{world}'! -mv-core.load.success=Loaded world '{world}'! +mv-core.load.failed=&cError trying to load world '{world}'! +mv-core.load.success=&aLoaded world '{world}'! mv-core.regen.description=Regenerates a world on your server. The previous state will be lost PERMANENTLY. mv-core.regen.world.description=World that you want to regen. mv-core.regen.other.description=Other world settings. See: http://gg.gg/nn8lk mv-core.regen.regenerating=Regenerating world '{world}'... -mv-core.regen.failed=There was an issue regenerating '{world}'! Please check console for errors. -mv-core.regen.success=World {world} was regenerated! +mv-core.regen.failed=&cThere was an issue regenerating '{world}'! &fPlease check console for errors. +mv-core.regen.success=&aWorld {world} was regenerated! mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'? mv-core.reload.description=Reloads config files for all Multiverse modules. -mv-core.reload.reloading=Reloading all Multiverse Plugin configs... -mv-core.reload.success=Reload complete! +mv-core.reload.reloading=&6Reloading all Multiverse Plugin configs... +mv-core.reload.success=&aReload complete! mv-core.remove.description=Unloads a world from Multiverse and removes it from worlds.yml. This does NOT delete the world folder. mv-core.remove.world.description=World you want to remove from MV's knowledge. -mv-core.remove.failed=Error trying to remove world from config! -mv-core.remove.success=World '{world}' is removed from config! +mv-core.remove.failed=&cError trying to remove world from config! +mv-core.remove.success=&aWorld '{world}' is removed from config! -mv-core.root.title={name} version {version} -mv-core.root.help=See /mv help for commands available. +mv-core.root.title=&a{name} version {version} +mv-core.root.help=&aSee &f/mv help&a for commands available. mv-core.teleport.description=Allows you to teleport to a location on your server! mv-core.teleport.player.description=Target player to teleport. @@ -85,8 +85,8 @@ mv-core.teleport.success=Teleporting {player} to {destination}... mv-core.unload.description=Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file. mv-core.unload.world.description=Name of the world you want to unload. mv-core.unload.unloading=Unloading world '{world}'... -mv-core.unload.failure=Error unloading world '{world}'! See console for more details. -mv-core.unload.success=Unloaded world '{world}'! +mv-core.unload.failure=&cError unloading world '{world}'! &fSee console for more details. +mv-core.unload.success=&aUnloaded world '{world}'! mv-core.usage.description=Show Multiverse-Core command usage. From ef3a50f32bf8ed659c153ccadb2daefc1204cd01 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Wed, 1 Mar 2023 18:02:52 -0500 Subject: [PATCH 62/69] i18n: section out the string file with comments --- .../resources/multiverse-core_en.properties | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 8ee14981..c969fceb 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -1,10 +1,13 @@ +# configuration mv-core.config.save.failed=&cUnable to save Multiverse-Core config.yml. Your changes will be temporary! +# /mv check mv-core.check.description=Checks if a player can teleport to a destination. mv-core.check.player.description=Player to check destination on. mv-core.check.destination.description=A destination location, e.g. a world name. mv-core.check.checking=Checking {player} to {destination} .. +# /mv clone mv-core.clone.description=Clones a world. mv-core.clone.world.description=The target world to clone. mv-core.clone.newWorld.description=The new cloned world name. @@ -12,8 +15,10 @@ mv-core.clone.cloning=Cloning world '{world}' to '{newworld}'... mv-core.clone.failed=&cWorld could not be cloned! &fSee console for more details. mv-core.clone.success=Cloned world '{world}'! +# /mv confirm mv-core.confirm.description=Confirms dangerous commands before executing them. +# /mv create mv-core.create.description=Creates a new world and loads it. mv-core.create.name.description=New world name. mv-core.create.environment.description=The world's environment. See: /mv environments @@ -29,12 +34,14 @@ mv-core.create.loading=Creating world... mv-core.create.failed=&cFailed to create world '{worldName}'! &fSee console for details. mv-core.create.success=&aWorld '{worldName}' created successfully! +# /mv delete mv-core.delete.description=Deletes a world on your server PERMANENTLY. mv-core.delete.deleting=Deleting world '{world}'... mv-core.delete.failed=&cThere was an issue deleting '{world}'! &fPlease check console for errors. mv-core.delete.success=&aWorld {world} was deleted! mv-core.delete.prompt=Are you sure you want to delete world '{world}'? +# /mv gamerule mv-core.gamerule.description=Changes a gamerule in one or more worlds mv-core.gamerule.gamerule.description=Gamerule to set mv-core.gamerule.value.description=Value of gamerule @@ -43,6 +50,7 @@ mv-core.gamerule.failed=&cFailed to set gamerule {gamerule} to {value} in {world mv-core.gamerule.success.single=&aSuccessfully set {gamerule} to {value} in {world}. mv-core.gamerule.success.multiple=&aSuccessfully set {gamerule} to {value} in {count} worlds. +# /mv import mv-core.import.description=Imports an existing world folder. mv-core.import.name.description=Name of the world folder. mv-core.import.env.description=The world's environment. See: /mv env @@ -51,12 +59,14 @@ mv-core.import.importing=Starting import of world '{world}'... mv-core.import.failed=&cFailed! &fSee console for more details. mv-core.import.success=&aComplete! +# /mv load mv-core.load.description=Loads a world. World must be already in worlds.yml, else please use /mv import. mv-core.load.world.description=Name of world you want to load. mv-core.load.loading=Loading world '{world}'... mv-core.load.failed=&cError trying to load world '{world}'! mv-core.load.success=&aLoaded world '{world}'! +# /mv regen mv-core.regen.description=Regenerates a world on your server. The previous state will be lost PERMANENTLY. mv-core.regen.world.description=World that you want to regen. mv-core.regen.other.description=Other world settings. See: http://gg.gg/nn8lk @@ -65,31 +75,38 @@ mv-core.regen.failed=&cThere was an issue regenerating '{world}'! &fPlease check mv-core.regen.success=&aWorld {world} was regenerated! mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'? +# /mv reload mv-core.reload.description=Reloads config files for all Multiverse modules. mv-core.reload.reloading=&6Reloading all Multiverse Plugin configs... mv-core.reload.success=&aReload complete! +# /mv remove mv-core.remove.description=Unloads a world from Multiverse and removes it from worlds.yml. This does NOT delete the world folder. mv-core.remove.world.description=World you want to remove from MV's knowledge. mv-core.remove.failed=&cError trying to remove world from config! mv-core.remove.success=&aWorld '{world}' is removed from config! +# /mv mv-core.root.title=&a{name} version {version} mv-core.root.help=&aSee &f/mv help&a for commands available. +# /mv tp mv-core.teleport.description=Allows you to teleport to a location on your server! mv-core.teleport.player.description=Target player to teleport. mv-core.teleport.destination.description=Location, can be a world name. mv-core.teleport.success=Teleporting {player} to {destination}... +# /mv unload mv-core.unload.description=Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file. mv-core.unload.world.description=Name of the world you want to unload. mv-core.unload.unloading=Unloading world '{world}'... mv-core.unload.failure=&cError unloading world '{world}'! &fSee console for more details. mv-core.unload.success=&aUnloaded world '{world}'! +# /mv usage mv-core.usage.description=Show Multiverse-Core command usage. +# /mv debug mv-core.debug.info.description=Show the current debug level. mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. From 1dadaa1a73ad766fe9010cdf0ed970ed5aca0e35 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Thu, 2 Mar 2023 01:48:30 -0500 Subject: [PATCH 63/69] i18n: use error message levels --- .../com/onarandombox/MultiverseCore/commands/CloneCommand.java | 2 +- .../com/onarandombox/MultiverseCore/commands/DeleteCommand.java | 2 +- .../onarandombox/MultiverseCore/commands/GameruleCommand.java | 2 +- .../com/onarandombox/MultiverseCore/commands/ImportCommand.java | 2 +- .../com/onarandombox/MultiverseCore/commands/LoadCommand.java | 2 +- .../com/onarandombox/MultiverseCore/commands/RegenCommand.java | 2 +- .../com/onarandombox/MultiverseCore/commands/RemoveCommand.java | 2 +- .../com/onarandombox/MultiverseCore/commands/UnloadCommand.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java index 49d88279..283902af 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java @@ -43,7 +43,7 @@ public class CloneCommand extends MultiverseCoreCommand { "{newWorld}", newWorldName); if (!this.plugin.getMVWorldManager().cloneWorld(worldName, newWorldName)) { - issuer.sendInfo(MVCorei18n.CLONE_FAILED); + issuer.sendError(MVCorei18n.CLONE_FAILED); return; } issuer.sendInfo(MVCorei18n.CLONE_SUCCESS, diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java index d6606b2f..35c570ac 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java @@ -41,7 +41,7 @@ public class DeleteCommand extends MultiverseCoreCommand { issuer.sendInfo(MVCorei18n.DELETE_DELETING, "{world}", worldName); if (!this.plugin.getMVWorldManager().deleteWorld(worldName)) { - issuer.sendInfo(MVCorei18n.DELETE_FAILED, + issuer.sendError(MVCorei18n.DELETE_FAILED, "{world}", worldName); return; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java index ce82400e..2a81f174 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/GameruleCommand.java @@ -47,7 +47,7 @@ public class GameruleCommand extends MultiverseCoreCommand { for(MVWorld world : worlds) { // Set gamerules and add false to list if it fails if (!world.getCBWorld().setGameRule(gamerule, value)) { - issuer.sendInfo(MVCorei18n.GAMERULE_FAILED, + issuer.sendError(MVCorei18n.GAMERULE_FAILED, "{gamerule}", gamerule.getName(), "{value}", value.toString(), "{world}", world.getName(), diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java index 10642ce9..235b057d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java @@ -83,7 +83,7 @@ public class ImportCommand extends MultiverseCoreCommand { parsedFlags.flagValue("--generator", String.class), parsedFlags.hasFlag("--adjust-spawn")) ) { - issuer.sendInfo(MVCorei18n.IMPORT_FAILED); + issuer.sendError(MVCorei18n.IMPORT_FAILED); return; } issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java index 239bde50..0e8af06c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java @@ -36,7 +36,7 @@ public class LoadCommand extends MultiverseCoreCommand { "{world}", worldName); if (!this.plugin.getMVWorldManager().loadWorld(worldName)) { - issuer.sendInfo(MVCorei18n.LOAD_FAILED, + issuer.sendError(MVCorei18n.LOAD_FAILED, "{world}", worldName); return; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java index 33e8ac6a..604fcf83 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java @@ -70,7 +70,7 @@ public class RegenCommand extends MultiverseCoreCommand { parsedFlags.flagValue("--seed", String.class), parsedFlags.hasFlag("--keep-gamerules") )) { - issuer.sendInfo(MVCorei18n.REGEN_FAILED, + issuer.sendError(MVCorei18n.REGEN_FAILED, "{world}", worldName); return; } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java index 2032af53..e4f8152c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java @@ -34,7 +34,7 @@ public class RemoveCommand extends MultiverseCoreCommand { String worldName ) { if (!this.plugin.getMVWorldManager().removeWorldFromConfig(worldName)) { - issuer.sendInfo(MVCorei18n.REMOVE_FAILED); + issuer.sendError(MVCorei18n.REMOVE_FAILED); return; } issuer.sendInfo(MVCorei18n.REMOVE_SUCCESS, diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java index 0142c4a0..720336bf 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java @@ -34,7 +34,7 @@ public class UnloadCommand extends MultiverseCoreCommand { //TODO API: Should be able to use MVWorld object directly if (!this.plugin.getMVWorldManager().unloadWorld(world.getName())) { - issuer.sendInfo(MVCorei18n.UNLOAD_FAILURE, + issuer.sendError(MVCorei18n.UNLOAD_FAILURE, "{world}", world.getColoredWorldString()); return; } From 6a5e8d25225f7c736246d26f63b1efe378bb935f Mon Sep 17 00:00:00 2001 From: Lildirt Date: Thu, 2 Mar 2023 01:52:25 -0500 Subject: [PATCH 64/69] i18n: Register root command --- .../java/com/onarandombox/MultiverseCore/MultiverseCore.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 41743b88..e246d2f0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -202,6 +202,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { */ private void registerCommands() { this.commandManager = new MVCommandManager(this); + this.commandManager.registerCommand(new RootCommand(this)); this.commandManager.registerCommand(new CheckCommand(this)); this.commandManager.registerCommand(new CloneCommand(this)); this.commandManager.registerCommand(new ConfirmCommand(this)); From 3bd6712f0eb344252b342d30749abd501ba92287 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Fri, 3 Mar 2023 02:07:31 -0500 Subject: [PATCH 65/69] i18n: Move mv-core.debug --- src/main/resources/multiverse-core_en.properties | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index c969fceb..1c54dd9e 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -34,6 +34,14 @@ mv-core.create.loading=Creating world... mv-core.create.failed=&cFailed to create world '{worldName}'! &fSee console for details. mv-core.create.success=&aWorld '{worldName}' created successfully! +# /mv debug +mv-core.debug.info.description=Show the current debug level. +mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. +mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. +mv-core.debug.change.description=Change debug level. +mv-core.debug.change.syntax=level +mv-core.debug.change.level.description=Debug level to set to. + # /mv delete mv-core.delete.description=Deletes a world on your server PERMANENTLY. mv-core.delete.deleting=Deleting world '{world}'... @@ -105,11 +113,3 @@ mv-core.unload.success=&aUnloaded world '{world}'! # /mv usage mv-core.usage.description=Show Multiverse-Core command usage. - -# /mv debug -mv-core.debug.info.description=Show the current debug level. -mv-core.debug.info.off=&fMultiverse Debug mode is &cOFF&f. -mv-core.debug.info.on=&fMultiverse Debug mode is at &alevel {level}&f. -mv-core.debug.change.description=Change debug level. -mv-core.debug.change.syntax=level -mv-core.debug.change.level.description=Debug level to set to. From 10c910f00f0a3704b4173cea1775c4c05a67c3e0 Mon Sep 17 00:00:00 2001 From: Lildirt Date: Fri, 3 Mar 2023 11:21:10 -0500 Subject: [PATCH 66/69] i18n: fix prompt message mappings --- .../MultiverseCore/commands/DeleteCommand.java | 7 ++++++- .../onarandombox/MultiverseCore/commands/RegenCommand.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java index 35c570ac..ee65b5c3 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java @@ -1,6 +1,7 @@ package com.onarandombox.MultiverseCore.commands; import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.MessageType; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -48,7 +49,11 @@ public class DeleteCommand extends MultiverseCoreCommand { issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, "{world}", worldName); }, - "{@@mv-core.delete.prompt}".replace("{world}", worldName) + this.plugin.getMVCommandManager().formatMessage( + issuer, + MessageType.INFO, + MVCorei18n.DELETE_PROMPT, + "{world}", worldName) )); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java index 604fcf83..19ef73eb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Random; import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.MessageType; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -77,7 +78,11 @@ public class RegenCommand extends MultiverseCoreCommand { issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, "{world}", worldName); }, - "{@@mv-core.regen.prompt}".replace("{world}", worldName) + this.plugin.getMVCommandManager().formatMessage( + issuer, + MessageType.INFO, + MVCorei18n.REGEN_PROMPT, + "{world}", worldName) )); } } From eaa8b1ee564b74ce872118ace5aa03cd69d3fa6b Mon Sep 17 00:00:00 2001 From: Lildirt Date: Fri, 3 Mar 2023 12:16:34 -0500 Subject: [PATCH 67/69] i18n: last bit of colorizing --- .../resources/multiverse-core_en.properties | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 1c54dd9e..483e4070 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -1,5 +1,5 @@ # configuration -mv-core.config.save.failed=&cUnable to save Multiverse-Core config.yml. Your changes will be temporary! +mv-core.config.save.failed=Unable to save Multiverse-Core config.yml. Your changes will be temporary! # /mv check mv-core.check.description=Checks if a player can teleport to a destination. @@ -12,7 +12,7 @@ mv-core.clone.description=Clones a world. mv-core.clone.world.description=The target world to clone. mv-core.clone.newWorld.description=The new cloned world name. mv-core.clone.cloning=Cloning world '{world}' to '{newworld}'... -mv-core.clone.failed=&cWorld could not be cloned! &fSee console for more details. +mv-core.clone.failed=World could not be cloned! &fSee console for more details. mv-core.clone.success=Cloned world '{world}'! # /mv confirm @@ -24,14 +24,14 @@ mv-core.create.name.description=New world name. mv-core.create.environment.description=The world's environment. See: /mv environments mv-core.create.flags.description=Additional world settings. See https://gg.gg/nn8bl for all possible flags. mv-core.create.properties=Creating world {worldName} with the following properties: -mv-core.create.properties.environment=- Environment: {environment} -mv-core.create.properties.seed=- Seed: {seed} -mv-core.create.properties.worldtype=- World Type: {worldType} -mv-core.create.properties.adjustspawn=- Adjust Spawn: {adjustSpawn} -mv-core.create.properties.generator=- Generator: {generator} -mv-core.create.properties.structures=- Structures: {structures} +mv-core.create.properties.environment=- Environment: &f{environment} +mv-core.create.properties.seed=- Seed: &f{seed} +mv-core.create.properties.worldtype=- World Type: &f{worldType} +mv-core.create.properties.adjustspawn=- Adjust Spawn: &f{adjustSpawn} +mv-core.create.properties.generator=- Generator: &f{generator} +mv-core.create.properties.structures=- Structures: &f{structures} mv-core.create.loading=Creating world... -mv-core.create.failed=&cFailed to create world '{worldName}'! &fSee console for details. +mv-core.create.failed=Failed to create world '{worldName}'! &fSee console for details. mv-core.create.success=&aWorld '{worldName}' created successfully! # /mv debug @@ -45,7 +45,7 @@ mv-core.debug.change.level.description=Debug level to set to. # /mv delete mv-core.delete.description=Deletes a world on your server PERMANENTLY. mv-core.delete.deleting=Deleting world '{world}'... -mv-core.delete.failed=&cThere was an issue deleting '{world}'! &fPlease check console for errors. +mv-core.delete.failed=There was an issue deleting '{world}'! &fPlease check console for errors. mv-core.delete.success=&aWorld {world} was deleted! mv-core.delete.prompt=Are you sure you want to delete world '{world}'? @@ -54,7 +54,7 @@ mv-core.gamerule.description=Changes a gamerule in one or more worlds mv-core.gamerule.gamerule.description=Gamerule to set mv-core.gamerule.value.description=Value of gamerule mv-core.gamerule.world.description=World to apply gamerule to, current world by default -mv-core.gamerule.failed=&cFailed to set gamerule {gamerule} to {value} in {world}. &fIt should be a {type}. +mv-core.gamerule.failed=Failed to set gamerule {gamerule} to {value} in {world}. &fIt should be a {type}. mv-core.gamerule.success.single=&aSuccessfully set {gamerule} to {value} in {world}. mv-core.gamerule.success.multiple=&aSuccessfully set {gamerule} to {value} in {count} worlds. @@ -64,14 +64,14 @@ mv-core.import.name.description=Name of the world folder. mv-core.import.env.description=The world's environment. See: /mv env mv-core.import.other.description=Other world settings. See: https://gg.gg/nn8c2 mv-core.import.importing=Starting import of world '{world}'... -mv-core.import.failed=&cFailed! &fSee console for more details. +mv-core.import.failed=Failed! &fSee console for more details. mv-core.import.success=&aComplete! # /mv load mv-core.load.description=Loads a world. World must be already in worlds.yml, else please use /mv import. mv-core.load.world.description=Name of world you want to load. mv-core.load.loading=Loading world '{world}'... -mv-core.load.failed=&cError trying to load world '{world}'! +mv-core.load.failed=Error trying to load world '{world}'! mv-core.load.success=&aLoaded world '{world}'! # /mv regen @@ -79,7 +79,7 @@ mv-core.regen.description=Regenerates a world on your server. The previous state mv-core.regen.world.description=World that you want to regen. mv-core.regen.other.description=Other world settings. See: http://gg.gg/nn8lk mv-core.regen.regenerating=Regenerating world '{world}'... -mv-core.regen.failed=&cThere was an issue regenerating '{world}'! &fPlease check console for errors. +mv-core.regen.failed=There was an issue regenerating '{world}'! &fPlease check console for errors. mv-core.regen.success=&aWorld {world} was regenerated! mv-core.regen.prompt=Are you sure you want to regenerate world '{world}'? @@ -91,7 +91,7 @@ mv-core.reload.success=&aReload complete! # /mv remove mv-core.remove.description=Unloads a world from Multiverse and removes it from worlds.yml. This does NOT delete the world folder. mv-core.remove.world.description=World you want to remove from MV's knowledge. -mv-core.remove.failed=&cError trying to remove world from config! +mv-core.remove.failed=Error trying to remove world from config! mv-core.remove.success=&aWorld '{world}' is removed from config! # /mv @@ -108,7 +108,7 @@ mv-core.teleport.success=Teleporting {player} to {destination}... mv-core.unload.description=Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file. mv-core.unload.world.description=Name of the world you want to unload. mv-core.unload.unloading=Unloading world '{world}'... -mv-core.unload.failure=&cError unloading world '{world}'! &fSee console for more details. +mv-core.unload.failure=Error unloading world '{world}'! &fSee console for more details. mv-core.unload.success=&aUnloaded world '{world}'! # /mv usage From 1f1c8240d9042edf27132c195e246e8749606e9d Mon Sep 17 00:00:00 2001 From: Lildirt Date: Sun, 5 Mar 2023 13:00:31 -0500 Subject: [PATCH 68/69] i18n: move RootCommand further down --- .../java/com/onarandombox/MultiverseCore/MultiverseCore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index e246d2f0..c03ecde5 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -202,7 +202,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore { */ private void registerCommands() { this.commandManager = new MVCommandManager(this); - this.commandManager.registerCommand(new RootCommand(this)); this.commandManager.registerCommand(new CheckCommand(this)); this.commandManager.registerCommand(new CloneCommand(this)); this.commandManager.registerCommand(new ConfirmCommand(this)); @@ -215,6 +214,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.commandManager.registerCommand(new RegenCommand(this)); this.commandManager.registerCommand(new ReloadCommand(this)); this.commandManager.registerCommand(new RemoveCommand(this)); + this.commandManager.registerCommand(new RootCommand(this)); this.commandManager.registerCommand(new TeleportCommand(this)); this.commandManager.registerCommand(new UnloadCommand(this)); } From 95c3b034ec429b3cb3f72295cafb5355b6e08a34 Mon Sep 17 00:00:00 2001 From: Zax71 <67716263+zax71@users.noreply.github.com> Date: Thu, 16 Mar 2023 12:18:36 +0000 Subject: [PATCH 69/69] feat: Add PlaceholderAPI Support (#2888) * feat:Add PlaceholderAPI Support Signed-off-by: zax71 * Implement requested changes Signed-off-by: zax71 * Add separate world functionality and half-baked i18n support. Signed-off-by: zax71 * refactor: Simplify papi world parsing * Fix spelling and remove unused i18n. Signed-off-by: zax71 * chore: Add warnings * chore: Remove unused imports * chore: Setup papi before log enable message --------- Signed-off-by: zax71 Co-authored-by: Ben Woo <30431861+benwoo1110@users.noreply.github.com> --- build.gradle | 7 + .../MultiverseCore/MultiverseCore.java | 9 +- .../MultiverseCorePlaceholders.java | 155 ++++++++++++++++++ .../resources/multiverse-core_en.properties | 1 + src/main/resources/plugin.yml | 2 +- 5 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java diff --git a/build.gradle b/build.gradle index 98d22ad0..15426427 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,10 @@ repositories { name = 'glaremasters repo' url = 'https://repo.glaremasters.me/repository/towny/' } + maven { + name = 'PlaceholderAPI' + url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' + } } configurations { @@ -70,6 +74,9 @@ dependencies { exclude group: 'org.bukkit', module: 'bukkit' } + // PlaceholderAPI + compileOnly 'me.clip:placeholderapi:2.11.2' + // Command Framework api 'co.aikar:acf-paper:0.5.1-SNAPSHOT' diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index c03ecde5..8bf9e604 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -41,7 +41,6 @@ import com.onarandombox.MultiverseCore.commands.RemoveCommand; import com.onarandombox.MultiverseCore.commands.RootCommand; import com.onarandombox.MultiverseCore.commands.TeleportCommand; import com.onarandombox.MultiverseCore.commands.UnloadCommand; -import com.onarandombox.MultiverseCore.commands.UsageCommand; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; import com.onarandombox.MultiverseCore.destination.DestinationsProvider; import com.onarandombox.MultiverseCore.destination.core.AnchorDestination; @@ -59,6 +58,7 @@ import com.onarandombox.MultiverseCore.listeners.MVPortalListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener; import com.onarandombox.MultiverseCore.listeners.MVWorldListener; +import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders; import com.onarandombox.MultiverseCore.teleportation.SimpleBlockSafety; import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation; import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter; @@ -169,6 +169,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.setUpLocales(); this.registerDestinations(); this.setupMetrics(); + this.setupPlaceholderAPI(); this.saveMVConfig(); this.logEnableMessage(); } @@ -262,6 +263,12 @@ public class MultiverseCore extends JavaPlugin implements MVCore { } } + private void setupPlaceholderAPI() { + if(getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) { + new MultiverseCorePlaceholders(this).register(); + } + } + /** * {@inheritDoc} */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java b/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java new file mode 100644 index 00000000..d768442e --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/placeholders/MultiverseCorePlaceholders.java @@ -0,0 +1,155 @@ +package com.onarandombox.MultiverseCore.placeholders; + +import java.util.Optional; + +import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.api.MVWorld; +import com.onarandombox.MultiverseCore.api.MVWorldManager; +import com.onarandombox.MultiverseCore.economy.MVEconomist; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class MultiverseCorePlaceholders extends PlaceholderExpansion { + + private final MultiverseCore plugin; + private final MVWorldManager worldManager; + private final MVEconomist economist; + + public MultiverseCorePlaceholders(MultiverseCore plugin) { + this.plugin = plugin; + this.worldManager = plugin.getMVWorldManager(); + this.economist = plugin.getEconomist(); + } + + @Override + public @NotNull String getIdentifier() { + return "multiverse-core"; + } + + @Override + public @NotNull String getAuthor() { + return plugin.getAuthors(); + } + + @Override + public @NotNull String getVersion() { + return plugin.getDescription().getVersion(); + } + + @Override + public boolean persist() { + return true; + } + + /** + * Placeholder implementation, format: %multiverse-core_<placeholder>_[world]% world is optional. + * + * @param offlinePlayer Player to get the placeholder for + * @param params Placeholder to get + * @return Placeholder value + */ + @Override + public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) { + // Split string in to an Array with underscores + String[] paramsArray = params.split("_", 2); + + // No placeholder defined + if (paramsArray.length < 1) { + warning("No placeholder defined"); + return null; + } + + final var placeholder = paramsArray[0]; + Optional targetWorld; + + // If no world is defined, use the player's world + if (paramsArray.length == 1) { + if (!offlinePlayer.isOnline()) { + return null; + } + targetWorld = Optional.ofNullable(worldManager.getMVWorld(((Player)offlinePlayer).getWorld())); + } else { + targetWorld = Optional.ofNullable(worldManager.getMVWorld(paramsArray[1])); + } + + // Fail if world is null + return targetWorld.map(world -> getWorldPlaceHolderValue(placeholder, world)) + .orElse(null); + } + + private @Nullable String getWorldPlaceHolderValue(@NotNull String placeholder, @NotNull MVWorld world) { + // Switch to find what specific placeholder we want + switch (placeholder.toLowerCase()) { + case "alias" -> { + return world.getColoredWorldString(); + } + case "animalspawn" -> { + return String.valueOf(world.canAnimalsSpawn()); + } + case "autoheal" -> { + return String.valueOf(world.getAutoHeal()); + } + case "blacklist" -> { + return String.join(", ", world.getWorldBlacklist()); + } + case "currency" -> { + return String.valueOf(world.getCurrency()); + } + case "difficulty" -> { + return world.getDifficulty().toString(); + } + case "entryfee" -> { + return economist.formatPrice(world.getPrice(), world.getCurrency()); + } + case "environment" -> { + return world.getEnvironment().toString().toLowerCase(); + } + case "flight" -> { + return String.valueOf(world.getAllowFlight()); + } + case "gamemode" -> { + return world.getGameMode().toString().toLowerCase(); + } + case "generator" -> { + return world.getGenerator(); + } + case "hunger" -> { + return String.valueOf(world.getHunger()); + } + case "monstersspawn" -> { + return String.valueOf(world.canMonstersSpawn()); + } + case "name" -> { + return world.getName(); + } + case "playerlimit" -> { + return String.valueOf(world.getPlayerLimit()); + } + case "price" -> { + return String.valueOf(world.getPrice()); + } + case "pvp" -> { + return String.valueOf(world.isPVPEnabled()); + } + case "seed" -> { + return String.valueOf(world.getSeed()); + } + case "time" -> { + return world.getTime(); + } + case "type" -> { + return world.getWorldType().toString().toLowerCase(); + } + case "weather" -> { + return String.valueOf(world.isWeatherEnabled()); + } + default -> { + warning("Unknown placeholder: " + placeholder); + return null; + } + } + } +} diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 483e4070..0cd452ea 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -113,3 +113,4 @@ mv-core.unload.success=&aUnloaded world '{world}'! # /mv usage mv-core.usage.description=Show Multiverse-Core command usage. + diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e0fac966..0681cc4c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,6 +2,6 @@ name: Multiverse-Core main: com.onarandombox.MultiverseCore.MultiverseCore authors: ['dumptruckman', 'Rigby', 'fernferret', 'lithium3141', 'main--'] website: 'https://dev.bukkit.org/projects/multiverse-core' -softdepend: ['Vault'] +softdepend: ['Vault', 'PlaceholderAPI'] api-version: 1.13 version: ${version}