Compare commits

...

99 Commits

Author SHA1 Message Date
1b5dab3ddd Merge branch 'v6' into refactor/v6/update-mm 2021-12-23 11:09:43 +01:00
6198d98488 refactor: Restore API in favor of deprecation 2021-12-23 11:04:04 +01:00
1f26808c7b Don't return the "side" for world plots when accessing default home locations 2021-12-22 17:47:48 +00:00
a7026047d0 Adding gold at the end might stop the prefix weirdness? 2021-12-22 17:46:39 +00:00
af2613202d refactor: Satisfy Semgrep 2021-12-22 02:06:07 +01:00
3da1e9255a build: Update dependency me.clip:placeholderapi to v2.11.0 (#3395)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-21 10:49:47 +01:00
9394906a79 build: Update dependency org.checkerframework:checker-qual to v3.21.0 (#3394)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-20 13:47:16 +01:00
d881cb6084 build: Update dependency com.intellectualsites.paster:Paster to v1.1.3 (#3391)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-20 11:55:54 +01:00
b9d43897af build: Update dependency net.essentialsx:EssentialsX to v2.19.2 (#3392)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-20 11:55:46 +01:00
76b58485a9 build: Update actions/checkout action to v2.4.0 (#3393)
* build: Update actions/checkout action to v2.4.0

* chore: Invert bolt's status

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: NotMyFault <mc.cache@web.de>
2021-12-20 11:55:14 +01:00
7002df0bc7 build: Bump dependencies for 1.18 2021-12-18 23:10:41 +01:00
958aac3cb1 chore: Configure bolt 2021-12-18 13:12:00 +01:00
5325f90f7b Update captions 2021-12-18 00:49:16 +01:00
b07bd6f39c Merge branch 'v6' into refactor/v6/update-mm 2021-12-18 00:48:39 +01:00
b7d5fd4eaf Fix more MM builder issues (#3373)
* fix unpair of signed IDs

* Fix MM builder issues + invalid translation

* Remove disrupting line breaks for help page and inbox list

* Fix loop of mm parsing in /plot f set

* de-clutter help page
2021-12-18 00:44:32 +01:00
a93402e27b fix: Standardize projectile permissions (#3374)
* fix: Standardize projectile permissions

- Let all projectiles (not just splash potions) have a permissions check on throwing
- Fixes snowballs, eggs, etc. being able to be thrown when not added to the plot, etc.
- Fixes #2986 (splash potions only able being to be thrown when also added to the plot)
- Remove the specialized code for egg hatching as now eggs are cancelled entirely
- Remove the non-standard plots.projectile.unowned and plots.projectile.other permissions in favor of the standard admin ones

* docs: Add back deprecated projectile permissions

* docs: Update Core/src/main/java/com/plotsquared/core/permissions/Permission.java

Co-authored-by: Alex <mc.cache@web.de>

Co-authored-by: Alex <mc.cache@web.de>
2021-12-17 22:06:56 +01:00
92f41f43c5 fix: Ignore the use flag for liquid placement/removal (#3375)
Fixes #3069
2021-12-17 21:52:15 +01:00
392ee9fa07 ci: Escape workflow tasks 2021-12-17 21:36:56 +01:00
0886f9ccd3 style: Javadoc fixup 2021-12-15 11:33:14 +01:00
51abe5565c style: Address style issues from previous commit 2021-12-15 01:29:44 +01:00
fda01502b2 refactor!: Update minimessage implementation 2021-12-15 01:20:26 +01:00
8859871e89 build: Back to snapshot for development 2021-12-14 23:14:35 +01:00
93d99630a9 build: Release 6.2.1 2021-12-14 23:06:55 +01:00
47ae79e123 Revert "refactor: Address MiniMessage deprecations (#3354)" (#3371)
This reverts commit f086826942.
2021-12-14 23:04:36 +01:00
f9ad00c2c8 build: Update dependency org.apache.logging.log4j:log4j-api to v2.16.0 (#3368)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-14 13:57:16 +01:00
566af259db build: Update dependency org.checkerframework:checker-qual to v3.20.0 (#3369)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-13 15:11:48 +01:00
d9a6431078 build: Back to snapshot for development 2021-12-13 13:47:28 +01:00
e9c9375e78 build: Release 6.2.0 2021-12-13 13:35:37 +01:00
7c99c8aabf build: Update dependency com.intellectualsites.arkitektonika:Arkitektonika-Client to v2.1.1 (#3365)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-13 11:31:15 +01:00
88eb8f88a7 build: Update com.fastasyncworldedit to v1.17-419
Closes #3363
2021-12-13 11:11:00 +01:00
fd118c2c37 build: Update com.sk89q.worldedit to v7.2.8 (#3364)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-13 10:42:47 +01:00
858b6b5471 tests: Move to JUnit 5 (#3357) 2021-12-13 10:41:36 +01:00
f086826942 refactor: Address MiniMessage deprecations (#3354)
* refactor: Address MiniMessage deprecations

* refactor: More MiniMessage deprecations

* Move away from our `Templates#of`

* Address comments

* style: Address migration style issues

* docs: Add javadoc link for MiniMessage
2021-12-13 09:48:34 +01:00
9c84dc2bc0 build: Update pipeline version to release build 2021-12-10 11:25:21 +01:00
cba0f3ac1f build: Switch PRTree GAV to our deployment (#3360)
* build: Switch PRTree repository

* build: Use our GAV
2021-12-09 18:30:35 +01:00
b9a130ab00 feat: Add -Post events firing after operational plot events (#3334)
* Create Post* events

* Address license violations

* address review

* standardize post event calls in EventDispatcher

* Add package-info.java

* Add @since-tag to Post* events

* fix licenser issue

Co-authored-by: Alex <mc.cache@web.de>
2021-12-06 19:50:04 +01:00
688056352b build: Update dependency net.kyori:adventure-platform-bukkit to v4.0.1 (#3356)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-12-06 14:33:04 +01:00
2a40f52dea docs: Update issue template to 1.18 2021-12-05 23:29:28 +01:00
3ed369de19 style: Add missing bracket for deny example (#3351) 2021-11-29 20:56:48 +01:00
bec51401a3 build: Update dependency org.junit.jupiter:junit-jupiter to v5.8.2 (#3350)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-29 11:25:01 +01:00
109f884b5f build: Update dependency io.papermc:paperlib to v1.0.7 (#3349)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-29 11:13:23 +01:00
8f3fa419c4 Fixes #3344, Wrong iterator algorithm in PlotRangeIterator (#3345) 2021-11-23 19:52:23 +00:00
a9f08bc885 build: Update dependencies
Closes #3330
2021-11-15 12:41:52 +01:00
a8923ec729 build: Back to snapshot for development 2021-11-11 23:01:37 +01:00
4eafd043a3 Release 6.1.4 2021-11-11 22:49:46 +01:00
826cc8c835 build: Update Gradle 2021-11-11 22:43:48 +01:00
d1dbf777a4 Don't check/set if a chunk should be saved if it's a world-plot 2021-11-11 17:57:59 +00:00
823e78377b feat: Better deciding of heights to use for generation and schematics (#3300)
* Better deciding of heights to use for generation and schematics
 - If bedrock is disabled, we should still be filling the space with something
 - Use minBuildHeight instead of hardcoding "1" for schematics (it is still 1 by default) to ensure all-encompassing schematics
 - Schematic generation/handling for roads etc. should be accounting for all of wall, road, and plot heights for deciding point of origin
 - Fixes #3269
 - Starts to address #3175

* Also do for HybridPlotManager clear
2021-11-11 17:33:38 +00:00
87a2e81ec3 Don't write biome data to schematics if it's not present 2021-11-10 19:51:14 +00:00
88775334b7 Schematic paths are configurable (#3303) 2021-11-09 10:32:07 +00:00
e126547e97 chore: Update com.fastasyncworldedit to v1.17-390 (#3324)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-09 10:00:14 +01:00
c1163cdb2e feat: Split configuration for teleport on claim/auto (#3308)
- Fixes #2953
2021-11-07 22:29:49 +01:00
30d06b7801 build: Reduce consumer dependencies 2021-11-05 11:57:58 +01:00
a5cf7bf2c2 Fix BlockLoc to the requirements for use as a home location
- Add home locations to #fromString
 - Switch to y=Integer#minValue more
 - May help with #3321
2021-11-04 20:47:56 +00:00
3d4d413de8 Minor adjustment to plot home location logic
- Allow "centre" spelling
 - ClassicPlotWorld contains the PLOT_HEIGHT config setting, not HPW
2021-11-02 15:41:16 +00:00
b97e843849 perf: Get rid of Guice overhead when accessing the plot area manager (#3315)
Fixes #3311
Co-authored-by: Jordan <dordsor21@gmail.com>
2021-11-02 13:38:48 +00:00
48c7a3e94e refactor: Use player friendly done message on restricted building (#3309) 2021-11-02 13:32:04 +00:00
7263290bbe fix: Untrusted visit flag not working with untrusted visit permission
Fixes #3317 
Co-authored-by: Alex <mc.cache@web.de>
2021-11-02 13:28:39 +00:00
e99c4e3289 chore: Update dependency org.checkerframework:checker-qual to v3.19.0 (#3320)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-01 21:51:53 +01:00
87cb26189f Closes #3313 2021-11-01 14:07:44 +01:00
2dae336a5f chore: Update com.fastasyncworldedit to v1.17-380 (#3312)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-01 14:06:47 +01:00
258ed1469b chore: Update dependency net.kyori:adventure-api to v4.9.3 (#3314)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-11-01 14:06:40 +01:00
6f3eabba0e feat: Don't display the default plot title if on a server-plot, unless configured otherwise. (#3305)
- If plot-title flag is set, title will still be displayed.
2021-11-01 11:23:53 +00:00
804228fa6c Allow pitch and yaw to be used in default home location (#3304) 2021-10-29 10:48:35 +01:00
be85708e5a feat: Add border bypass permission (#3302)
* Add border bypass permission
 - Fixes #3297

* Add permission to plots.admin permpack

* Implement messages on leaving/entering border area

* Rename to border.denied and make border msg red

* change too le/ge as tthey are likely to be equal to border when hit.
 - Since we check for being across the border beforehand, it will hopefully not be spammed too much?
 - If it's spammed then either we use meta to set if a player's left the border, or we just remove the come-back-in altogether because it's a little looong
2021-10-28 10:13:36 +02:00
f2368f97df chore: Update com.sk89q.worldedit to v7.2.7 (#3299)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-25 11:22:31 +02:00
df87bcb743 build: Back to snapshot for development 2021-10-18 20:30:28 +02:00
5653d0f175 Release 6.1.3 2021-10-18 20:22:13 +02:00
b022a97196 fix: Flag list parsing for console players (#3277)
Instead of recreating the logic, we can simply reuse what we created above and string-ify that for parsing.
2021-10-18 20:20:52 +02:00
cb596ee6ea Fix StackOverFlow 2021-10-18 17:27:51 +01:00
4e391136c0 Add and Trust permission now count correctly (#3290) 2021-10-15 11:28:23 +01:00
a6a0e1d12f chore: Update dependency org.checkerframework:checker-qual to v3.18.1 (#3283)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-10 00:23:32 +02:00
d2776eed5a [ci skip] Move to work level templates 2021-10-08 18:09:58 +02:00
6528c60f4d fix: Fix greeting & farewell captions not being used (#3272)
* fix: Fix greeting & farewell captions not being used

Fixes #3250

* feat: Allow alias in greeting & farewell flag
2021-10-07 08:10:00 +00:00
7ee46be2ac feat: Allow plot alias in title (#3273)
Fixes #3171
2021-10-07 08:07:13 +00:00
13bc231091 chore: Update com.fastasyncworldedit to v1.17-343 (#3282)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-05 10:26:42 +02:00
55d1a40394 chore: Update plugin shadow to v7.1.0 (#3284)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-04 20:18:56 +02:00
d70f99b489 fix: Respect tab-complete aliases (Fixes #3266) (#3268)
* Fixes #3250

* ListFlag#merge should not allow duplicates (Fixes #3157) (#3265)

* feat: Respect non-visible players in tab completion (Closes #3263) (#3264)

* Respect non-visible players in tab completion (Closes #3263)

* Deprecate old Tab-Complete methods instead of hard-replacing them

* wtf git

* Mark for removal, useless new-lines

* Pass ConsolePlayer.getConsole() instead of Nullable param

* Respect tab-complete aliases (Fixes #3266)

* Useless import

Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: dordsor21 <dordsor21@gmail.com>
2021-10-04 17:10:36 +02:00
fde9735da2 chore: Update dependency net.kyori:adventure-api to v4.9.2 (#3278)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-04 17:05:52 +02:00
20f0aa3656 chore: Update com.fastasyncworldedit to v1.17-341 (#3275)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-04 17:05:38 +02:00
0b7bf2d26d chore: Update dependency dev.notmyfault.serverlib:ServerLib to v2.3.1 (#3276)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-04 17:05:24 +02:00
f10e38af63 [ci skip] chore: Improve pr template fields 2021-10-04 15:43:44 +02:00
21727ebfc7 build: Overhaul build & deployment workflow (#3267)
* Fixes #3250

* build: Overhaul build & deployment workflow

- Move to release drafter
- Replace publishing with gradle nexus
- Conventional commits are handy
- Determine build status in gh actions before deploying
2021-10-04 15:28:47 +02:00
e322ee85fd feat: Respect non-visible players in tab completion (Closes #3263) (#3264)
* Respect non-visible players in tab completion (Closes #3263)

* Deprecate old Tab-Complete methods instead of hard-replacing them

* wtf git

* Mark for removal, useless new-lines

* Pass ConsolePlayer.getConsole() instead of Nullable param
2021-10-03 14:32:02 +02:00
541255fe7e ListFlag#merge should not allow duplicates (Fixes #3157) (#3265) 2021-10-03 14:31:57 +02:00
20c2f36f6c Update com.fastasyncworldedit to v1.17-336 (#3258)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-29 18:09:46 +02:00
744f7a18ae Update dependency org.junit.jupiter:junit-jupiter to v5.8.1 (#3259)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-29 18:09:35 +02:00
18eece0b71 [ci skip] chore: Renovate
Closes #3260
2021-09-29 18:09:12 +02:00
4f12dcf966 Return base plot when using alias (#3253) 2021-09-25 15:58:31 +02:00
ee832528db [ci skip] Adjust renovate config
Closes #3252
2021-09-21 00:52:25 +02:00
bb5d6c91da Update Fawe version 2021-09-20 16:21:18 +02:00
6d4adecb32 6.1.3 2021-09-18 23:07:10 +01:00
c37b13dcb3 Fix bad move to adventure 2021-09-18 21:54:22 +01:00
086dac2ea4 Update dependency net.kyori:adventure-platform-bukkit to v4.0.0 (#3245)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-16 15:29:17 +02:00
b2b8598b5b Fix #3246 2021-09-15 13:19:25 +01:00
61e5d9f1b6 Move /p components title to translations file matching other parts of components
- Also component-ify title, this must not be limited to a String.
2021-09-15 11:13:03 +02:00
c8989b3332 Update dependency org.junit.jupiter:junit-jupiter to v5.8.0 (#3244)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-13 10:23:38 +02:00
9f54472dd6 Relocate annotations properly 2021-09-12 13:56:08 +02:00
115932c65a 6.1.2 2021-09-11 14:28:08 +02:00
283 changed files with 4044 additions and 3099 deletions

View File

@ -1008,6 +1008,6 @@ ij_html_uniform_ident = false
indent_size = 2 indent_size = 2
ij_yaml_keep_indents_on_empty_lines = false ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true ij_yaml_keep_line_breaks = true
ij_yaml_space_before_colon = true ij_yaml_space_before_colon = false
ij_yaml_spaces_within_braces = true ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = true ij_yaml_spaces_within_brackets = true

12
.github/FUNDING.yml vendored
View File

@ -1,12 +0,0 @@
# These are supported funding model platforms
github: [NotMyFault, dordsor21, SirYwell]
patreon: IntellectualSites # Replace with a single Patreon username
open_collective: IntellectualSites
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://www.paypal.me/AlexanderBrandes # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@ -18,8 +18,6 @@ body:
options: options:
- Paper - Paper
- Spigot - Spigot
- Tuinity
- Purpur
validations: validations:
required: true required: true
@ -29,6 +27,8 @@ body:
description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first. description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
multiple: false multiple: false
options: options:
- '1.18.1'
- '1.18'
- '1.17.1' - '1.17.1'
- '1.16.5' - '1.16.5'
- '1.15.2' - '1.15.2'

View File

@ -1,17 +0,0 @@
## Overview
<!-- Please describe which issue this Pull Request targets
If there is no issue, please create one so we can look into it before approving your PR.
You can do so here: https://github.com/IntellectualSites/PlotSquared/issues
-->
**Fixes {Link to issue}**
## Description
## Checklist
<!-- Make sure you have completed the following steps (put an "X" between of brackets): -->
- [] I included all information required in the sections above
- [] I tested my changes and approved their functionality
- [] I ensured my changes do not break other parts of the code
- [] I read and followed the [contribution guidelines](https://github.com/IntellectualSites/PlotSquared/blob/v6/CONTRIBUTING.md)

1
.github/release-drafter.yml vendored Normal file
View File

@ -0,0 +1 @@
_extends: .github

2
.github/stale.yml vendored
View File

@ -1,4 +1,4 @@
daysUntilStale: 60 daysUntilStale: 30
daysUntilClose: 7 daysUntilClose: 7
only: issues only: issues
exemptLabels: exemptLabels:

View File

@ -1,17 +1,41 @@
name: "build" name: build
on: ["pull_request", "push"] on: [ pull_request, push ]
jobs: jobs:
build: build:
runs-on: "ubuntu-20.04" runs-on: ubuntu-latest
steps: steps:
- name: "Checkout Repository" - name: Checkout Repository
uses: "actions/checkout@v2.3.4" uses: actions/checkout@v2.4.0
- name: "Setup JDK 16" - name: Validate Gradle Wrapper"
uses: "actions/setup-java@v2.2.0" uses: gradle/wrapper-validation-action@v1.0.4
- name: Setup Java
uses: actions/setup-java@v2.4.0
with: with:
distribution: "temurin" distribution: temurin
java-version: "16" java-version: 17
- name: "Clean Build" - name: Clean Build
run: "./gradlew clean build" run: ./gradlew clean build
- name: Determine release status
if: ${{ runner.os == 'Linux' }}
run: |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
echo "STATUS=snapshot" >> $GITHUB_ENV
else
echo "STATUS=release" >> $GITHUB_ENV
fi
- name: Publish Release
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
- name: Publish Snapshot
if: ${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6' }}
run: ./gradlew publishToSonatype
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}

14
.github/workflows/release-drafter.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: draft release
on:
push:
branches:
- v6
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5.15.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,12 +0,0 @@
name: "validate gradle wrapper"
on: ["pull_request", "push"]
jobs:
build:
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2.3.4"
- name: "Validate Gradle Wrapper"
uses: "gradle/wrapper-validation-action@v1.0.4"

13
.whitesource Normal file
View File

@ -0,0 +1,13 @@
{
"scanSettings": {
"baseBranches": ["v6"]
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "success",
"displayMode": "diff"
},
"issueSettings": {
"minSeverityLevel": "LOW"
},
"enableRenovate": "true"
}

View File

@ -24,7 +24,7 @@ dependencies {
implementation(libs.bstats) implementation(libs.bstats)
// Paper // Paper
compileOnlyApi(libs.paper) compileOnly(libs.paper)
implementation(libs.paperlib) implementation(libs.paperlib)
// Plugins // Plugins
@ -32,8 +32,8 @@ dependencies {
exclude(group = "org.bukkit") exclude(group = "org.bukkit")
exclude(group = "org.spigotmc") exclude(group = "org.spigotmc")
} }
compileOnlyApi(libs.fastasyncworldeditBukkit) compileOnly(libs.fastasyncworldeditBukkit) { isTransitive = false }
testImplementation(libs.fastasyncworldeditBukkit) testImplementation(libs.fastasyncworldeditBukkit) { isTransitive = false }
compileOnly(libs.vault) { compileOnly(libs.vault) {
exclude(group = "org.bukkit") exclude(group = "org.bukkit")
} }
@ -80,6 +80,10 @@ tasks.named<ShadowJar>("shadowJar") {
relocate("com.intellectualsites.http", "com.plotsquared.core.http") relocate("com.intellectualsites.http", "com.plotsquared.core.http")
relocate("com.intellectualsites.paster", "com.plotsquared.core.paster") relocate("com.intellectualsites.paster", "com.plotsquared.core.paster")
relocate("org.incendo.serverlib", "com.plotsquared.bukkit.serverlib") relocate("org.incendo.serverlib", "com.plotsquared.bukkit.serverlib")
relocate("org.jetbrains", "com.plotsquared.core.annotations")
relocate("org.intellij.lang", "com.plotsquared.core.intellij.annotations")
relocate("javax.annotation", "com.plotsquared.core.annotation")
relocate("javax.inject", "com.plotsquared.core.annotation.inject")
// Get rid of all the libs which are 100% unused. // Get rid of all the libs which are 100% unused.
minimize() minimize()
@ -91,10 +95,11 @@ tasks {
withType<Javadoc> { withType<Javadoc> {
val opt = options as StandardJavadocDocletOptions val opt = options as StandardJavadocDocletOptions
opt.links("https://papermc.io/javadocs/paper/1.17/") opt.links("https://papermc.io/javadocs/paper/1.17/")
opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-core/7.2.6/") opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-core/7.2.7/")
opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/7.2.6/") opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/7.2.7/")
opt.links("https://jd.adventure.kyori.net/api/4.9.1/") opt.links("https://jd.adventure.kyori.net/api/4.9.3/")
opt.links("https://google.github.io/guice/api-docs/5.0.1/javadoc/") opt.links("https://google.github.io/guice/api-docs/5.0.1/javadoc/")
opt.links("https://checkerframework.org/api/") opt.links("https://checkerframework.org/api/")
opt.links("https://notmyfault.github.io/MiniMessage-Javadocs/") // Temporary hosting until Kyori adds hosted Javadocs
} }
} }

View File

@ -27,6 +27,7 @@ package com.plotsquared.bukkit;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.command.MainCommand; import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -42,6 +43,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
public class BukkitCommand implements CommandExecutor, TabCompleter { public class BukkitCommand implements CommandExecutor, TabCompleter {
@ -63,7 +65,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
@Override @Override
public List<String> onTabComplete( public List<String> onTabComplete(
CommandSender commandSender, Command command, String s, CommandSender commandSender, Command command, String label,
String[] args String[] args
) { ) {
if (!(commandSender instanceof Player)) { if (!(commandSender instanceof Player)) {
@ -73,8 +75,11 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
if (args.length == 0) { if (args.length == 0) {
return Collections.singletonList("plots"); return Collections.singletonList("plots");
} }
if (!Settings.Enabled_Components.TAB_COMPLETED_ALIASES.contains(label.toLowerCase(Locale.ENGLISH))) {
return List.of();
}
Collection<com.plotsquared.core.command.Command> objects = Collection<com.plotsquared.core.command.Command> objects =
MainCommand.getInstance().tab(player, args, s.endsWith(" ")); MainCommand.getInstance().tab(player, args, label.endsWith(" "));
if (objects == null) { if (objects == null) {
return null; return null;
} }

View File

@ -1180,6 +1180,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return this.injector; return this.injector;
} }
@Override
public @NonNull PlotAreaManager plotAreaManager() {
return this.plotAreaManager;
}
@NonNull @NonNull
@Override @Override
public Locale getLocale() { public Locale getLocale() {

View File

@ -68,7 +68,7 @@ import com.plotsquared.core.util.task.TaskTime;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
@ -282,16 +282,16 @@ public class BlockEventListener implements Listener {
.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { .hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true); event.setCancelled(true);
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("height.height_limit"), TranslatableCaption.miniMessage("height.height_limit"),
Template.of("minHeight", String.valueOf(area.getMinBuildHeight())), Placeholder.miniMessage("minHeight", String.valueOf(area.getMinBuildHeight())),
Template.of("maxHeight", String.valueOf(area.getMaxBuildHeight())) Placeholder.miniMessage("maxHeight", String.valueOf(area.getMaxBuildHeight()))
); );
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -307,8 +307,8 @@ public class BlockEventListener implements Listener {
} }
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
plot.debug(player.getName() + " could not place " + event.getBlock().getType() plot.debug(player.getName() + " could not place " + event.getBlock().getType()
@ -318,8 +318,7 @@ public class BlockEventListener implements Listener {
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("done.building_restricted")
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -335,8 +334,8 @@ public class BlockEventListener implements Listener {
} }
} else if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { } else if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -357,8 +356,8 @@ public class BlockEventListener implements Listener {
if (!Permissions if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL))
); );
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -368,9 +367,9 @@ public class BlockEventListener implements Listener {
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true); event.setCancelled(true);
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("height.height_limit"), TranslatableCaption.miniMessage("height.height_limit"),
Template.of("minHeight", String.valueOf(area.getMinBuildHeight())), Placeholder.miniMessage("minHeight", String.valueOf(area.getMinBuildHeight())),
Template.of("maxHeight", String.valueOf(area.getMaxBuildHeight())) Placeholder.miniMessage("maxHeight", String.valueOf(area.getMaxBuildHeight()))
); );
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
@ -394,15 +393,14 @@ public class BlockEventListener implements Listener {
return; return;
} }
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("done.building_restricted")
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -421,8 +419,8 @@ public class BlockEventListener implements Listener {
} }
} }
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1096,24 +1094,24 @@ public class BlockEventListener implements Listener {
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -32,6 +32,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.util.ReflectionUtils.RefClass; import com.plotsquared.core.util.ReflectionUtils.RefClass;
import com.plotsquared.core.util.ReflectionUtils.RefField; import com.plotsquared.core.util.ReflectionUtils.RefField;
import com.plotsquared.core.util.ReflectionUtils.RefMethod; import com.plotsquared.core.util.ReflectionUtils.RefMethod;
@ -295,7 +296,7 @@ public class ChunkListener implements Listener {
Chunk chunk = event.getChunk(); Chunk chunk = event.getChunk();
if (Settings.Chunk_Processor.AUTO_TRIM) { if (Settings.Chunk_Processor.AUTO_TRIM) {
String world = chunk.getWorld().getName(); String world = chunk.getWorld().getName();
if (this.plotAreaManager.hasPlotArea(world)) { if ((!Settings.Enabled_Components.WORLDS || !SinglePlotArea.isSinglePlotWorld(world)) && this.plotAreaManager.hasPlotArea(world)) {
if (unloadChunk(world, chunk, true)) { if (unloadChunk(world, chunk, true)) {
return; return;
} }
@ -365,8 +366,7 @@ public class ChunkListener implements Listener {
} }
private void cleanChunk(final Chunk chunk) { private void cleanChunk(final Chunk chunk) {
TaskManager.index.incrementAndGet(); final int currentIndex = TaskManager.index.incrementAndGet();
final int currentIndex = TaskManager.index.get();
PlotSquaredTask task = TaskManager.runTaskRepeat(() -> { PlotSquaredTask task = TaskManager.runTaskRepeat(() -> {
if (!chunk.isLoaded()) { if (!chunk.isLoaded()) {
Objects.requireNonNull(TaskManager.removeTask(currentIndex)).cancel(); Objects.requireNonNull(TaskManager.removeTask(currentIndex)).cancel();

View File

@ -371,14 +371,14 @@ public class EntityEventListener implements Listener {
if (shooter instanceof Player) { if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_PROJECTILE_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (plot.isAdded(pp.getUUID()) || Permissions if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, Permission.PERMISSION_PROJECTILE_OTHER)) { .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();

View File

@ -75,7 +75,7 @@ public class EntitySpawnListener implements Listener {
public static void testCreate(final Entity entity) { public static void testCreate(final Entity entity) {
@NonNull World world = entity.getWorld(); @NonNull World world = entity.getWorld();
if (areaName == world.getName()) { if (areaName.equals(world.getName())) {
} else { } else {
areaName = world.getName(); areaName = world.getName();
hasPlotArea = PlotSquared.get().getPlotAreaManager().hasPlotArea(areaName); hasPlotArea = PlotSquared.get().getPlotAreaManager().hasPlotArea(areaName);

View File

@ -39,12 +39,14 @@ import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template; import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.TileState; import org.bukkit.block.TileState;
@ -53,7 +55,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -301,8 +302,8 @@ public class PaperListener implements Listener {
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) { if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer()); final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("errors.tile_entity_cap_reached"), TranslatableCaption.miniMessage("errors.tile_entity_cap_reached"),
Template.of("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES)) Placeholder.miniMessage("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))
); );
event.setCancelled(true); event.setCancelled(true);
event.setBuild(false); event.setBuild(false);
@ -321,9 +322,6 @@ public class PaperListener implements Listener {
return; return;
} }
Projectile entity = event.getProjectile(); Projectile entity = event.getProjectile();
if (!(entity instanceof ThrownPotion)) {
return;
}
ProjectileSource shooter = entity.getShooter(); ProjectileSource shooter = entity.getShooter();
if (!(shooter instanceof Player)) { if (!(shooter instanceof Player)) {
return; return;
@ -332,12 +330,37 @@ public class PaperListener implements Listener {
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) { if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
return; return;
} }
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
if (plot != null && !plot.isAdded(pp.getUUID())) {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) {
pp.sendMessage(
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))
);
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
);
entity.remove();
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
pp.sendMessage(
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
);
entity.remove();
event.setCancelled(true);
}
}
} }
@EventHandler @EventHandler

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.block.Banner; import org.bukkit.block.Banner;
import org.bukkit.block.Beacon; import org.bukkit.block.Beacon;
import org.bukkit.block.Bed; import org.bukkit.block.Bed;
@ -83,8 +83,8 @@ public class PaperListener113 extends PaperListener {
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) { if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer()); final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("errors.tile_entity_cap_reached"), TranslatableCaption.miniMessage("errors.tile_entity_cap_reached"),
Template.of("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES)) Placeholder.miniMessage("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))
); );
event.setCancelled(true); event.setCancelled(true);
event.setBuild(false); event.setBuild(false);

View File

@ -87,7 +87,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.FluidCollisionMode; import org.bukkit.FluidCollisionMode;
@ -127,7 +127,6 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
@ -309,7 +308,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
perm = "plots.admin.command.blocked-cmds.road"; perm = "plots.admin.command.blocked-cmds.road";
} }
if (!Permissions.hasPermission(plotPlayer, perm)) { if (!Permissions.hasPermission(plotPlayer, perm)) {
plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked")); plotPlayer.sendMessage(TranslatableCaption.miniMessage("blockedcmds.command_blocked"));
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
@ -362,11 +361,11 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_UPDATE_NOTIFICATION.toString()) && Settings.Enabled_Components.UPDATE_NOTIFICATIONS if (pp.hasPermission(Permission.PERMISSION_ADMIN_UPDATE_NOTIFICATION.toString()) && Settings.Enabled_Components.UPDATE_NOTIFICATIONS
&& PremiumVerification.isPremium() && UpdateUtility.hasUpdate) { && PremiumVerification.isPremium() && UpdateUtility.hasUpdate) {
Caption boundary = TranslatableCaption.of("update.update_boundary"); Caption boundary = TranslatableCaption.miniMessage("update.update_boundary");
Caption updateNotification = TranslatableCaption.of("update.update_notification"); Caption updateNotification = TranslatableCaption.miniMessage("update.update_notification");
Template internalVersion = Template.of("p2version", UpdateUtility.internalVersion.versionString()); Placeholder<?> internalVersion = Placeholder.miniMessage("p2version", UpdateUtility.internalVersion.versionString());
Template spigotVersion = Template.of("spigotversion", UpdateUtility.spigotVersion); Placeholder<?> spigotVersion = Placeholder.miniMessage("spigotversion", UpdateUtility.spigotVersion);
Template downloadUrl = Template.of("downloadurl", "https://www.spigotmc.org/resources/77506/updates"); Placeholder<?> downloadUrl = Placeholder.miniMessage("downloadurl", "https://www.spigotmc.org/resources/77506/updates");
pp.sendMessage(boundary); pp.sendMessage(boundary);
pp.sendMessage(updateNotification, internalVersion, spigotVersion, downloadUrl); pp.sendMessage(updateNotification, internalVersion, spigotVersion, downloadUrl);
pp.sendMessage(boundary); pp.sendMessage(boundary);
@ -418,8 +417,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
.getHomeSynchronous() .getHomeSynchronous()
.equals(BukkitUtil.adaptComplete(to)))) { .equals(BukkitUtil.adaptComplete(to)))) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -507,7 +506,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(player); BukkitPlayer pp = BukkitUtil.adapt(player);
// Cancel teleport // Cancel teleport
if (TaskManager.removeFromTeleportQueue(pp.getName())) { if (TaskManager.removeFromTeleportQueue(pp.getName())) {
pp.sendMessage(TranslatableCaption.of("teleport.teleport_failed")); pp.sendMessage(TranslatableCaption.miniMessage("teleport.teleport_failed"));
} }
// Set last location // Set last location
Location location = BukkitUtil.adapt(to); Location location = BukkitUtil.adapt(to);
@ -534,8 +533,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) { pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !kickAccess.get().orElse(false)) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !kickAccess.get().orElse(false)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED))
); );
this.tmpTeleport = false; this.tmpTeleport = false;
if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) { if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) {
@ -552,8 +551,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
ForceFieldListener.handleForcefield(player, pp, now); ForceFieldListener.handleForcefield(player, pp, now);
} else if (!plotEntry(pp, now) && this.tmpTeleport) { } else if (!plotEntry(pp, now) && this.tmpTeleport) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
); );
this.tmpTeleport = false; this.tmpTeleport = false;
to.setX(from.getBlockX()); to.setX(from.getBlockX());
@ -564,19 +563,31 @@ public class PlayerEventListener extends PlotListener implements Listener {
return; return;
} }
int border = area.getBorder(); int border = area.getBorder();
int x1;
if (x2 > border && this.tmpTeleport) { if (x2 > border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setX(border - 1); to.setX(border - 1);
this.tmpTeleport = false; this.tmpTeleport = false;
player.teleport(event.getTo()); player.teleport(event.getTo());
this.tmpTeleport = true; this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.border")); pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
} }
if (x2 < -border && this.tmpTeleport) { } else if (x2 < -border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setX(-border + 1); to.setX(-border + 1);
this.tmpTeleport = false; this.tmpTeleport = false;
player.teleport(event.getTo()); player.teleport(event.getTo());
this.tmpTeleport = true; this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.border")); pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (((x1 = MathMan.roundInt(from.getX())) >= border && x2 <= border) || (x1 <= -border && x2 >= -border)) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.entered"));
}
} }
} }
int z2; int z2;
@ -585,7 +596,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(player); BukkitPlayer pp = BukkitUtil.adapt(player);
// Cancel teleport // Cancel teleport
if (TaskManager.removeFromTeleportQueue(pp.getName())) { if (TaskManager.removeFromTeleportQueue(pp.getName())) {
pp.sendMessage(TranslatableCaption.of("teleport.teleport_failed")); pp.sendMessage(TranslatableCaption.miniMessage("teleport.teleport_failed"));
} }
// Set last location // Set last location
Location location = BukkitUtil.adapt(to); Location location = BukkitUtil.adapt(to);
@ -612,8 +623,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) { pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !kickAccess.get().orElse(false)) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !kickAccess.get().orElse(false)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED))
); );
this.tmpTeleport = false; this.tmpTeleport = false;
if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) { if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) {
@ -630,8 +641,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
ForceFieldListener.handleForcefield(player, pp, now); ForceFieldListener.handleForcefield(player, pp, now);
} else if (!plotEntry(pp, now) && this.tmpTeleport) { } else if (!plotEntry(pp, now) && this.tmpTeleport) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
); );
this.tmpTeleport = false; this.tmpTeleport = false;
player.teleport(from); player.teleport(from);
@ -643,18 +654,31 @@ public class PlayerEventListener extends PlotListener implements Listener {
return; return;
} }
int border = area.getBorder(); int border = area.getBorder();
int z1;
if (z2 > border && this.tmpTeleport) { if (z2 > border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setZ(border - 1); to.setZ(border - 1);
this.tmpTeleport = false; this.tmpTeleport = false;
player.teleport(event.getTo()); player.teleport(event.getTo());
this.tmpTeleport = true; this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.border")); pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (z2 < -border && this.tmpTeleport) { } else if (z2 < -border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
to.setZ(-border + 1); to.setZ(-border + 1);
this.tmpTeleport = false; this.tmpTeleport = false;
player.teleport(event.getTo()); player.teleport(event.getTo());
this.tmpTeleport = true; this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.border")); pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (((z1 = MathMan.roundInt(from.getZ())) >= border && z2 <= border) || (z1 <= -border && z2 >= -border)) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.entered"));
}
} }
} }
} }
@ -702,45 +726,45 @@ public class PlayerEventListener extends PlotListener implements Listener {
String sender = event.getPlayer().getDisplayName(); String sender = event.getPlayer().getDisplayName();
PlotId id = plot.getId(); PlotId id = plot.getId();
String worldName = plot.getWorldName(); String worldName = plot.getWorldName();
Caption msg = TranslatableCaption.of("chat.plot_chat_format"); Caption msg = TranslatableCaption.miniMessage("chat.plot_chat_format");
Template msgTemplate; Placeholder<?> msgTemplate;
Template worldNameTemplate = Template.of("world", worldName); Placeholder<?> worldNameTemplate = Placeholder.miniMessage("world", worldName);
Template plotTemplate = Template.of("plot_id", id.toString()); Placeholder<?> plotTemplate = Placeholder.miniMessage("plot_id", id.toString());
Template senderTemplate = Template.of("sender", sender); Placeholder<?> senderTemplate = Placeholder.miniMessage("sender", sender);
// If we do/don't want colour, we need to be careful about how to go about it, as players could attempt either <gold></gold> or &6 etc. // If we do/don't want colour, we need to be careful about how to go about it, as players could attempt either <gold></gold> or &6 etc.
// In both cases, we want to use a Component Template to ensure that the player cannot use any placeholders in their message on purpose // In both cases, we want to use a Component Template to ensure that the player cannot use any placeholders in their message on purpose
// or accidentally, as component templates are done at the end. We also need to deserialize from legacy color codes to a Component if // or accidentally, as component templates are done at the end. We also need to deserialize from legacy color codes to a Component if
// allowing colour. // allowing colour.
if (plotPlayer.hasPermission("plots.chat.color")) { if (plotPlayer.hasPermission("plots.chat.color")) {
msgTemplate = Template msgTemplate = Placeholder
.of( .miniMessage(
"msg", "msg",
BukkitUtil.LEGACY_COMPONENT_SERIALIZER.deserialize(ChatColor.translateAlternateColorCodes( BukkitUtil.LEGACY_COMPONENT_SERIALIZER.deserialize(ChatColor.translateAlternateColorCodes(
'&', '&',
message message
)) )).toString()
); );
} else { } else {
msgTemplate = Template.of("msg", BukkitUtil.MINI_MESSAGE.deserialize( msgTemplate = Placeholder.miniMessage("msg", BukkitUtil.MINI_MESSAGE.deserialize(
ChatColor.stripColor(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(Component.text(message))))); ChatColor.stripColor(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(Component.text(message)))).toString());
} }
for (PlotPlayer<?> receiver : plotRecipients) { for (PlotPlayer<?> receiver : plotRecipients) {
receiver.sendMessage(msg, worldNameTemplate, msgTemplate, plotTemplate, senderTemplate); receiver.sendMessage(msg, worldNameTemplate, msgTemplate, plotTemplate, senderTemplate);
} }
if (!spies.isEmpty()) { if (!spies.isEmpty()) {
Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format"); Caption spymsg = TranslatableCaption.miniMessage("chat.plot_chat_spy_format");
Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY()); Placeholder<?> plotidTemplate = Placeholder.miniMessage("plot_id", id.getX() + ";" + id.getY());
Template spysenderTemplate = Template.of("sender", sender); Placeholder<?> spysenderTemplate = Placeholder.miniMessage("sender", sender);
Template spymessageTemplate = Template.of("msg", Component.text(message)); Placeholder<?> spymessageTemplate = Placeholder.miniMessage("msg", Component.text(message).toString());
for (PlotPlayer<?> player : spies) { for (PlotPlayer<?> player : spies) {
player.sendMessage(spymsg, worldNameTemplate, plotidTemplate, spysenderTemplate, spymessageTemplate); player.sendMessage(spymsg, worldNameTemplate, plotidTemplate, spysenderTemplate, spymessageTemplate);
} }
} }
if (Settings.Chat.LOG_PLOTCHAT_TO_CONSOLE) { if (Settings.Chat.LOG_PLOTCHAT_TO_CONSOLE) {
Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format"); Caption spymsg = TranslatableCaption.miniMessage("chat.plot_chat_spy_format");
Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY()); Placeholder<?> plotidTemplate = Placeholder.miniMessage("plot_id", id.getX() + ";" + id.getY());
Template spysenderTemplate = Template.of("sender", sender); Placeholder<?> spysenderTemplate = Placeholder.miniMessage("sender", sender);
Template spymessageTemplate = Template.of("msg", Component.text(message)); Placeholder<?> spymessageTemplate = Placeholder.miniMessage("msg", Component.text(message).toString());
ConsolePlayer.getConsole().sendMessage(spymsg, worldNameTemplate, plotidTemplate, spysenderTemplate, ConsolePlayer.getConsole().sendMessage(spymsg, worldNameTemplate, plotidTemplate, spysenderTemplate,
spymessageTemplate spymessageTemplate
); );
@ -895,16 +919,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
); );
cancelled = true; cancelled = true;
} }
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
); );
cancelled = true; cancelled = true;
} }
@ -913,8 +937,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.isAdded(uuid)) { if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
); );
cancelled = true; cancelled = true;
} }
@ -951,8 +975,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { .hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
); );
e.setCancelled(true); e.setCancelled(true);
} }
@ -960,8 +984,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("done.building_restricted")
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
e.setCancelled(true); e.setCancelled(true);
return; return;
@ -970,8 +993,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
); );
e.setCancelled(true); e.setCancelled(true);
} }
@ -985,8 +1008,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
); );
e.setCancelled(true); e.setCancelled(true);
plot.debug(pp.getName() + " could not interact with " + entity.getType() plot.debug(pp.getName() + " could not interact with " + entity.getType()
@ -1201,8 +1224,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
return; return;
} }
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
@ -1210,31 +1233,23 @@ public class PlayerEventListener extends PlotListener implements Listener {
return; return;
} }
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
for (final BlockTypeWrapper blockTypeWrapper : use) {
if (blockTypeWrapper.accepts(blockType)) {
return;
}
}
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
} }
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("done.building_restricted")
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1274,8 +1289,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
return; return;
} }
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
@ -1283,32 +1298,23 @@ public class PlayerEventListener extends PlotListener implements Listener {
return; return;
} }
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
List<BlockTypeWrapper> use = plot.getFlag(UseFlag.class);
Block block = event.getBlockClicked();
final BlockType blockType = BukkitAdapter.asBlockType(block.getType());
for (final BlockTypeWrapper blockTypeWrapper : use) {
if (blockTypeWrapper.accepts(blockType)) {
return;
}
}
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
} }
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("done.building_restricted")
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1333,8 +1339,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1342,8 +1348,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1353,8 +1359,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.getFlag(HangingPlaceFlag.class)) { if (!plot.getFlag(HangingPlaceFlag.class)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1382,16 +1388,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1401,8 +1407,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
plot.debug(p.getName() plot.debug(p.getName()
@ -1423,8 +1429,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) { .hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1433,8 +1439,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
plot.debug(player.getName() plot.debug(player.getName()
@ -1465,16 +1471,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null && !area.isRoadFlags()) { if (plot == null && !area.isRoadFlags()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
} else if (plot != null && !plot.hasOwner()) { } else if (plot != null && !plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1531,8 +1537,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1553,8 +1559,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD))
); );
event.setCancelled(true); event.setCancelled(true);
} }
@ -1562,8 +1568,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED))
); );
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -1576,8 +1582,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) {
pp.sendMessage( pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER))
); );
event.setCancelled(true); event.setCancelled(true);
plot.debug(pp.getName() plot.debug(pp.getName()
@ -1588,43 +1594,6 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
Location location = BukkitUtil.adapt(event.getEgg().getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Player player = event.getPlayer();
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))
);
event.setHatching(false);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
);
event.setHatching(false);
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
);
event.setHatching(false);
}
}
}
@EventHandler @EventHandler
public void onItemDrop(PlayerDropItemEvent event) { public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -28,6 +28,7 @@ package com.plotsquared.bukkit.listener;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.plotsquared.bukkit.util.BukkitEntityUtil; import com.plotsquared.bukkit.util.BukkitEntityUtil;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -36,6 +37,7 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotHandler; import com.plotsquared.core.plot.PlotHandler;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -96,9 +98,6 @@ public class ProjectileEventListener implements Listener {
@EventHandler @EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) {
return;
}
ProjectileSource shooter = entity.getShooter(); ProjectileSource shooter = entity.getShooter();
if (!(shooter instanceof Player)) { if (!(shooter instanceof Player)) {
return; return;
@ -109,10 +108,35 @@ public class ProjectileEventListener implements Listener {
} }
PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
if (plot != null && !plot.isAdded(pp.getUUID())) {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) {
pp.sendMessage(
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))
);
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
);
entity.remove();
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
pp.sendMessage(
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
);
entity.remove();
event.setCancelled(true);
}
}
} }
@EventHandler @EventHandler
@ -131,14 +155,14 @@ public class ProjectileEventListener implements Listener {
if (shooter instanceof Player) { if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_PROJECTILE_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (plot.isAdded(pp.getUUID()) || Permissions if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, Permission.PERMISSION_PROJECTILE_OTHER)) { .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();

View File

@ -50,7 +50,7 @@ public class ServerListener implements Listener {
public void onServerLoad(ServerLoadEvent event) { public void onServerLoad(ServerLoadEvent event) {
if (Bukkit.getPluginManager().getPlugin("MVdWPlaceholderAPI") != null && Settings.Enabled_Components.USE_MVDWAPI) { if (Bukkit.getPluginManager().getPlugin("MVdWPlaceholderAPI") != null && Settings.Enabled_Components.USE_MVDWAPI) {
new MVdWPlaceholders(this.plugin, this.plugin.placeholderRegistry()); new MVdWPlaceholders(this.plugin, this.plugin.placeholderRegistry());
ConsolePlayer.getConsole().sendMessage(TranslatableCaption.of("placeholder.hooked")); ConsolePlayer.getConsole().sendMessage(TranslatableCaption.miniMessage("placeholder.hooked"));
} }
} }

View File

@ -27,6 +27,7 @@ package com.plotsquared.bukkit.listener;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.util.ReflectionUtils; import com.plotsquared.core.util.ReflectionUtils;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -86,7 +87,7 @@ public class SingleWorldListener implements Listener {
if (!(man instanceof SinglePlotAreaManager)) { if (!(man instanceof SinglePlotAreaManager)) {
return; return;
} }
if (!isPlotId(name)) { if (!SinglePlotArea.isSinglePlotWorld(name)) {
return; return;
} }
@ -103,31 +104,4 @@ public class SingleWorldListener implements Listener {
handle(event); handle(event);
} }
private boolean isPlotId(String worldName) {
int len = worldName.length();
int separator = 0;
for (int i = 0; i < len; i++) {
switch (worldName.charAt(i)) {
case '_':
separator++;
break;
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
default:
return false;
}
}
return separator == 1;
}
} }

View File

@ -50,7 +50,7 @@ import com.plotsquared.core.util.EntityUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.entity.EntityCategories; import com.plotsquared.core.util.entity.EntityCategories;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -178,8 +178,7 @@ public class BukkitEntityUtil {
if (!Permissions if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("done.building_restricted")
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
); );
return false; return false;
} }
@ -188,8 +187,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
); );
return false; return false;
} }
@ -200,8 +199,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
); );
if (plot != null) { if (plot != null) {
plot.debug(player.getName() plot.debug(player.getName()
@ -221,8 +220,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
); );
if (plot != null) { if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType plot.debug(player.getName() + " could not attack " + entityType
@ -242,8 +241,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
); );
if (plot != null) { if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType plot.debug(player.getName() + " could not attack " + entityType
@ -256,8 +255,8 @@ public class BukkitEntityUtil {
if (!plot.getFlag(PvpFlag.class) && !Permissions if (!plot.getFlag(PvpFlag.class) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) { .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
); );
plot.debug(player.getName() + " could not attack " + entityType plot.debug(player.getName() + " could not attack " + entityType
+ " because pve = false"); + " because pve = false");
@ -270,8 +269,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
); );
return false; return false;
} }
@ -287,8 +286,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
); );
if (plot != null) { if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType plot.debug(player.getName() + " could not attack " + entityType
@ -309,8 +308,8 @@ public class BukkitEntityUtil {
} }
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage( plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"), TranslatableCaption.miniMessage("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
); );
if (plot != null) { if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType plot.debug(player.getName() + " could not attack " + entityType

View File

@ -176,7 +176,7 @@ public class BukkitRegionManager extends RegionManager {
final boolean ignoreAugment, final boolean ignoreAugment,
final @Nullable Runnable whenDone final @Nullable Runnable whenDone
) { ) {
final BukkitWorld world = new BukkitWorld((World) pos1.getWorld()); final BukkitWorld world = (BukkitWorld) worldUtil.getWeWorld(pos1.getWorldName());
final int p1x = pos1.getX(); final int p1x = pos1.getX();
final int p1z = pos1.getZ(); final int p1z = pos1.getZ();

View File

@ -53,7 +53,8 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -337,7 +338,7 @@ public class BukkitUtil extends WorldUtil {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void setSign( public void setSign(
final @NonNull Location location, final @NonNull Caption[] lines, final @NonNull Location location, final @NonNull Caption[] lines,
final @NonNull Template... replacements final @NonNull Placeholder<?>... replacements
) { ) {
ensureLoaded(location.getWorldName(), location.getX(), location.getZ(), chunk -> { ensureLoaded(location.getWorldName(), location.getX(), location.getZ(), chunk -> {
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
@ -369,7 +370,8 @@ public class BukkitUtil extends WorldUtil {
if (blockstate instanceof final Sign sign) { if (blockstate instanceof final Sign sign) {
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {
sign.setLine(i, LEGACY_COMPONENT_SERIALIZER sign.setLine(i, LEGACY_COMPONENT_SERIALIZER
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements))); .serialize(MINI_MESSAGE.deserialize(lines[i].getComponent(LocaleHolder.console()),
PlaceholderResolver.placeholders(replacements))));
} }
sign.update(true); sign.update(true);
} }

View File

@ -248,9 +248,12 @@ permissions:
plots.admin.components.other: true plots.admin.components.other: true
plots.admin.vehicle.break.unowned: true plots.admin.vehicle.break.unowned: true
plots.admin.pve.unowned: true plots.admin.pve.unowned: true
plots.admin.border.bypass: true
plots.teleport.delay.bypass: plots.teleport.delay.bypass:
default: op default: op
plots.admin.border.bypass:
default: op
plots.worldedit.bypass: plots.worldedit.bypass:
default: op default: op
plots.gamemode.bypass: plots.gamemode.bypass:

View File

@ -1,8 +0,0 @@
# Contributing
If you feel like you can improve the plugin any way, then you are more than welcome to contribute to PlotSquared. It would be highly appreciated if you made sure to test your code before committing it, as it will save us a lot of time and effort.
### Code Style
If you are planning to commit any changes to the project, it would be highly appreciated if you were to follow the project
code style conventions. To make this easier we have provided settings that can be picked up by your IDE.
IntelliJ: Install the `EditorConfig` plugin. Now IntelliJ is able to pick up the provided `.editorconfig` file automatically.

View File

@ -5,8 +5,8 @@ dependencies {
compileOnlyApi(libs.checkerqual) compileOnlyApi(libs.checkerqual)
// Minecraft expectations // Minecraft expectations
compileOnlyApi(libs.guava)
compileOnlyApi(libs.gson) compileOnlyApi(libs.gson)
compileOnly(libs.guava)
// Platform expectations // Platform expectations
compileOnlyApi(libs.snakeyaml) compileOnlyApi(libs.snakeyaml)
@ -25,14 +25,14 @@ dependencies {
compileOnlyApi(libs.findbugs) compileOnlyApi(libs.findbugs)
// Plugins // Plugins
compileOnlyApi(libs.worldeditCore) { compileOnly(libs.worldeditCore) {
exclude(group = "bukkit-classloader-check") exclude(group = "bukkit-classloader-check")
exclude(group = "mockito-core") exclude(group = "mockito-core")
exclude(group = "dummypermscompat") exclude(group = "dummypermscompat")
} }
testImplementation(libs.worldeditCore) testImplementation(libs.worldeditCore)
compileOnlyApi(libs.fastasyncworldeditCore) compileOnly(libs.fastasyncworldeditCore) { isTransitive = false }
testImplementation(libs.fastasyncworldeditCore) testImplementation(libs.fastasyncworldeditCore) { isTransitive = false }
// Logging // Logging
compileOnlyApi(libs.log4j) compileOnlyApi(libs.log4j)
@ -40,7 +40,7 @@ dependencies {
// Other libraries // Other libraries
api(libs.prtree) api(libs.prtree)
api(libs.aopalliance) api(libs.aopalliance)
api(libs.pipeline) { api(libs.rorledning) {
exclude(group = "com.google.guava") exclude(group = "com.google.guava")
} }
api(libs.arkitektonika) api(libs.arkitektonika)

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -152,9 +152,9 @@ public class PlotAPI {
*/ */
public void sendConsoleMessage( public void sendConsoleMessage(
final @NonNull String message, final @NonNull String message,
final @NonNull Template @NonNull ... replacements final @NonNull Placeholder<?> @NonNull ... replacements
) { ) {
ConsolePlayer.getConsole().sendMessage(StaticCaption.of(message), replacements); ConsolePlayer.getConsole().sendMessage(StaticCaption.miniMessage(message), replacements);
} }
/** /**
@ -165,7 +165,7 @@ public class PlotAPI {
*/ */
public void sendConsoleMessage( public void sendConsoleMessage(
final @NonNull Caption caption, final @NonNull Caption caption,
final @NonNull Template @NonNull ... replacements final @NonNull Placeholder<?> @NonNull ... replacements
) { ) {
ConsolePlayer.getConsole().sendMessage(caption, replacements); ConsolePlayer.getConsole().sendMessage(caption, replacements);
} }

View File

@ -38,6 +38,7 @@ import com.plotsquared.core.inject.annotations.DefaultGenerator;
import com.plotsquared.core.location.World; import com.plotsquared.core.location.World;
import com.plotsquared.core.permissions.PermissionHandler; import com.plotsquared.core.permissions.PermissionHandler;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
@ -268,6 +269,13 @@ public interface PlotPlatform<P> extends LocaleHolder {
return injector().getInstance(ChunkManager.class); return injector().getInstance(ChunkManager.class);
} }
/**
* Get the {@link PlotAreaManager} implementation.
*
* @return the PlotAreaManager
*/
@NonNull PlotAreaManager plotAreaManager();
/** /**
* Get the platform specific console {@link Audience} * Get the platform specific console {@link Audience}
* *

View File

@ -283,7 +283,7 @@ public class PlotSquared {
* @return Plot area manager * @return Plot area manager
*/ */
public @NonNull PlotAreaManager getPlotAreaManager() { public @NonNull PlotAreaManager getPlotAreaManager() {
return this.platform.injector().getInstance(PlotAreaManager.class); return this.platform.plotAreaManager();
} }
public void startExpiryTasks() { public void startExpiryTasks() {
@ -758,6 +758,9 @@ public class PlotSquared {
if (this_max < last_max) { if (this_max < last_max) {
plot.getArea().setMeta("lastPlot", plot.getId()); plot.getArea().setMeta("lastPlot", plot.getId());
} }
if (callEvent) {
eventDispatcher.callPostDelete(plot);
}
return true; return true;
} }
return false; return false;

View File

@ -193,7 +193,15 @@ public class PlayerBackupProfile implements BackupProfile {
future.completeExceptionally(new IllegalArgumentException( future.completeExceptionally(new IllegalArgumentException(
"The backup is non-existent or not in the correct format")); "The backup is non-existent or not in the correct format"));
} else { } else {
this.schematicHandler.paste(schematic, plot, 0, 1, 0, false, player, new RunnableVal<Boolean>() { this.schematicHandler.paste(
schematic,
plot,
0,
plot.getArea().getMinBuildHeight(),
0,
false,
player,
new RunnableVal<>() {
@Override @Override
public void run(Boolean value) { public void run(Boolean value) {
if (value) { if (value) {
@ -201,11 +209,12 @@ public class PlayerBackupProfile implements BackupProfile {
} else { } else {
future.completeExceptionally(new RuntimeException(MINI_MESSAGE.stripTokens( future.completeExceptionally(new RuntimeException(MINI_MESSAGE.stripTokens(
TranslatableCaption TranslatableCaption
.of("schematics.schematic_paste_failed") .miniMessage("schematics.schematic_paste_failed")
.getComponent(ConsolePlayer.getConsole())))); .getComponent(ConsolePlayer.getConsole()))));
} }
} }
}); }
);
} }
}); });
} }

View File

@ -31,13 +31,12 @@ import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.inject.factory.PlayerBackupProfileFactory; import com.plotsquared.core.inject.factory.PlayerBackupProfileFactory;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -106,22 +105,22 @@ public class SimpleBackupManager implements BackupManager {
} else { } else {
if (player != null) { if (player != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_automatic_started"), TranslatableCaption.miniMessage("backups.backup_automatic_started"),
Template.of("plot", plot.getId().toString()) Placeholders.miniMessage("plot", plot.getId().toString())
); );
} }
profile.createBackup().whenComplete((backup, throwable) -> { profile.createBackup().whenComplete((backup, throwable) -> {
if (throwable != null) { if (throwable != null) {
if (player != null) { if (player != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_automatic_failure"), TranslatableCaption.miniMessage("backups.backup_automatic_failure"),
Templates.of("reason", throwable.getMessage()) Placeholders.miniMessage("reason", throwable.getMessage())
); );
} }
throwable.printStackTrace(); throwable.printStackTrace();
} else { } else {
if (player != null) { if (player != null) {
player.sendMessage(TranslatableCaption.of("backups.backup_automatic_finished")); player.sendMessage(TranslatableCaption.miniMessage("backups.backup_automatic_finished"));
TaskManager.runTaskAsync(whenDone); TaskManager.runTaskAsync(whenDone);
} }
} }

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -69,33 +69,33 @@ public class Add extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone RunnableVal2<Command, CommandResult> whenDone
) throws CommandException { ) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue(plot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
checkTrue( checkTrue(
plot.isOwner(player.getUUID()) || Permissions plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST), .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST),
TranslatableCaption.of("permission.no_plot_perms") TranslatableCaption.miniMessage("permission.no_plot_perms")
); );
checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"), checkTrue(args.length == 1, TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot add <player | *>") Placeholder.miniMessage("value", "/plot add <player | *>")
); );
final CompletableFuture<Boolean> future = new CompletableFuture<>(); final CompletableFuture<Boolean> future = new CompletableFuture<>();
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> { PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable != null) { if (throwable != null) {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
} }
future.completeExceptionally(throwable); future.completeExceptionally(throwable);
return; return;
} else { } else {
try { try {
checkTrue(!uuids.isEmpty(), TranslatableCaption.of("errors.invalid_player"), checkTrue(!uuids.isEmpty(), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
Iterator<UUID> iterator = uuids.iterator(); Iterator<UUID> iterator = uuids.iterator();
int size = plot.getTrusted().size() + plot.getMembers().size(); int size = plot.getTrusted().size() + plot.getMembers().size();
@ -105,24 +105,24 @@ public class Add extends Command {
Permissions.hasPermission(player, Permission.PERMISSION_TRUST_EVERYONE) || Permissions Permissions.hasPermission(player, Permission.PERMISSION_TRUST_EVERYONE) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", PlayerManager.getName(uuid)) Placeholder.miniMessage("value", PlayerManager.getName(uuid))
); );
iterator.remove(); iterator.remove();
continue; continue;
} }
if (plot.isOwner(uuid)) { if (plot.isOwner(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("member.already_added"), TranslatableCaption.miniMessage("member.already_added"),
Template.of("player", PlayerManager.getName(uuid)) Placeholder.miniMessage("player", PlayerManager.getName(uuid))
); );
iterator.remove(); iterator.remove();
continue; continue;
} }
if (plot.getMembers().contains(uuid)) { if (plot.getMembers().contains(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("member.already_added"), TranslatableCaption.miniMessage("member.already_added"),
Template.of("player", PlayerManager.getName(uuid)) Placeholder.miniMessage("player", PlayerManager.getName(uuid))
); );
iterator.remove(); iterator.remove();
continue; continue;
@ -132,10 +132,10 @@ public class Add extends Command {
checkTrue(!uuids.isEmpty(), null); checkTrue(!uuids.isEmpty(), null);
int localAddSize = plot.getMembers().size(); int localAddSize = plot.getMembers().size();
int maxAddSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS); int maxAddSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS);
if (localAddSize > maxAddSize) { if (localAddSize >= maxAddSize) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("members.plot_max_members_added"), TranslatableCaption.miniMessage("members.plot_max_members_added"),
Template.of("amount", String.valueOf(localAddSize)) Placeholder.miniMessage("amount", String.valueOf(localAddSize))
); );
return; return;
} }
@ -151,7 +151,7 @@ public class Add extends Command {
} }
plot.addMember(uuid); plot.addMember(uuid);
this.eventDispatcher.callMember(player, plot, uuid, true); this.eventDispatcher.callMember(player, plot, uuid, true);
player.sendMessage(TranslatableCaption.of("member.member_added")); player.sendMessage(TranslatableCaption.miniMessage("member.member_added"));
} }
}, null); }, null);
} catch (final Throwable exception) { } catch (final Throwable exception) {
@ -166,7 +166,7 @@ public class Add extends Command {
@Override @Override
public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) { public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -35,7 +35,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -67,12 +67,12 @@ public class Alias extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
return false; return false;
} }
@ -90,7 +90,7 @@ public class Alias extends SubCommand {
permission = isPermitted(player, Permission.PERMISSION_ALIAS_SET); permission = isPermitted(player, Permission.PERMISSION_ALIAS_SET);
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_SET); admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_SET);
if (!admin && !owner) { if (!admin && !owner) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (permission) { // is either admin or owner if (permission) { // is either admin or owner
@ -98,8 +98,8 @@ public class Alias extends SubCommand {
return true; return true;
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_SET)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ALIAS_SET))
); );
} }
} }
@ -107,15 +107,15 @@ public class Alias extends SubCommand {
permission = isPermitted(player, Permission.PERMISSION_ALIAS_REMOVE); permission = isPermitted(player, Permission.PERMISSION_ALIAS_REMOVE);
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_REMOVE); admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_REMOVE);
if (!admin && !owner) { if (!admin && !owner) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (permission) { if (permission) {
result = removeAlias(player, plot); result = removeAlias(player, plot);
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_REMOVE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ALIAS_REMOVE))
); );
} }
} }
@ -147,37 +147,37 @@ public class Alias extends SubCommand {
if (alias.isEmpty()) { if (alias.isEmpty()) {
sendUsage(player); sendUsage(player);
} else if (alias.length() >= 50) { } else if (alias.length() >= 50) {
player.sendMessage(TranslatableCaption.of("alias.alias_too_long")); player.sendMessage(TranslatableCaption.miniMessage("alias.alias_too_long"));
} else if (MathMan.isInteger(alias)) { } else if (MathMan.isInteger(alias)) {
player.sendMessage(TranslatableCaption.of("flag.not_valid_value")); // TODO this is obviously wrong player.sendMessage(TranslatableCaption.miniMessage("flag.not_valid_value")); // TODO this is obviously wrong
} else { } else {
if (PlotQuery.newQuery().inArea(plot.getArea()) if (PlotQuery.newQuery().inArea(plot.getArea())
.withAlias(alias) .withAlias(alias)
.anyMatch()) { .anyMatch()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("alias.alias_is_taken"), TranslatableCaption.miniMessage("alias.alias_is_taken"),
Template.of("alias", alias) Placeholder.miniMessage("alias", alias)
); );
return; return;
} }
if (Settings.UUID.OFFLINE) { if (Settings.UUID.OFFLINE) {
plot.setAlias(alias); plot.setAlias(alias);
player.sendMessage(TranslatableCaption.of("alias.alias_set_to"), Template.of("alias", alias)); player.sendMessage(TranslatableCaption.miniMessage("alias.alias_set_to"), Placeholder.miniMessage("alias", alias));
return; return;
} }
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(alias, ((uuid, throwable) -> { PlotSquared.get().getImpromptuUUIDPipeline().getSingle(alias, ((uuid, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (uuid != null) { } else if (uuid != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("alias.alias_is_taken"), TranslatableCaption.miniMessage("alias.alias_is_taken"),
Template.of("alias", alias) Placeholder.miniMessage("alias", alias)
); );
} else { } else {
plot.setAlias(alias); plot.setAlias(alias);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("alias.alias_set_to"), TranslatableCaption.miniMessage("alias.alias_set_to"),
Template.of("alias", alias) Placeholder.miniMessage("alias", alias)
); );
} }
})); }));
@ -188,12 +188,12 @@ public class Alias extends SubCommand {
String alias = plot.getAlias(); String alias = plot.getAlias();
if (!plot.getAlias().isEmpty()) { if (!plot.getAlias().isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("alias.alias_removed"), TranslatableCaption.miniMessage("alias.alias_removed"),
Template.of("alias", alias) Placeholder.miniMessage("alias", alias)
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("alias.no_alias_set") TranslatableCaption.miniMessage("alias.no_alias_set")
); );
} }
plot.setAlias(null); plot.setAlias(null);

View File

@ -29,8 +29,9 @@ import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.CaptionHolder; import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.events.TeleportCause;
@ -74,7 +75,8 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File; import java.io.File;
@ -145,26 +147,26 @@ public class Area extends SubCommand {
} }
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_CREATE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_CREATE))
); );
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("single.single_area_needs_name"), TranslatableCaption.miniMessage("single.single_area_needs_name"),
Template.of("command", "/plot area single <name>") Placeholder.miniMessage("command", "/plot area single <name>")
); );
return false; return false;
} }
final PlotArea existingArea = this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]); final PlotArea existingArea = this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]);
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) { if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
player.sendMessage(TranslatableCaption.of("single.single_area_name_taken")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_name_taken"));
return false; return false;
} }
final LocalSession localSession = WorldEdit.getInstance().getSessionManager().getIfPresent(player.toActor()); final LocalSession localSession = WorldEdit.getInstance().getSessionManager().getIfPresent(player.toActor());
if (localSession == null) { if (localSession == null) {
player.sendMessage(TranslatableCaption.of("single.single_area_missing_selection")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_missing_selection"));
return false; return false;
} }
Region playerSelectedRegion = null; Region playerSelectedRegion = null;
@ -173,18 +175,18 @@ public class Area extends SubCommand {
} catch (final Exception ignored) { } catch (final Exception ignored) {
} }
if (playerSelectedRegion == null) { if (playerSelectedRegion == null) {
player.sendMessage(TranslatableCaption.of("single.single_area_missing_selection")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_missing_selection"));
return false; return false;
} }
if (playerSelectedRegion.getWidth() != playerSelectedRegion.getLength()) { if (playerSelectedRegion.getWidth() != playerSelectedRegion.getLength()) {
player.sendMessage(TranslatableCaption.of("single.single_area_not_square")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_not_square"));
return false; return false;
} }
if (this.plotAreaManager.getPlotAreas( if (this.plotAreaManager.getPlotAreas(
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(), Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(),
CuboidRegion.makeCuboid(playerSelectedRegion) CuboidRegion.makeCuboid(playerSelectedRegion)
).length != 0) { ).length != 0) {
player.sendMessage(TranslatableCaption.of("single.single_area_overlapping")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_overlapping"));
} }
// Alter the region // Alter the region
final BlockVector3 playerSelectionMin = playerSelectedRegion.getMinimumPoint(); final BlockVector3 playerSelectionMin = playerSelectedRegion.getMinimumPoint();
@ -222,11 +224,11 @@ public class Area extends SubCommand {
hybridPlotWorld.setAllowSigns(false); hybridPlotWorld.setAllowSigns(false);
final File parentFile = FileUtils.getFile( final File parentFile = FileUtils.getFile(
PlotSquared.platform().getDirectory(), PlotSquared.platform().getDirectory(),
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld.getWorldName() + File.separator Settings.Paths.SCHEMATICS + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld.getWorldName() + File.separator
+ hybridPlotWorld.getId() + hybridPlotWorld.getId()
); );
if (!parentFile.exists() && !parentFile.mkdirs()) { if (!parentFile.exists() && !parentFile.mkdirs()) {
player.sendMessage(TranslatableCaption.of("single.single_area_could_not_make_directories")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_could_not_make_directories"));
return false; return false;
} }
final File file = new File(parentFile, "plot.schem"); final File file = new File(parentFile, "plot.schem");
@ -244,7 +246,7 @@ public class Area extends SubCommand {
Operations.complete(forwardExtentCopy); Operations.complete(forwardExtentCopy);
clipboardWriter.write(clipboard); clipboardWriter.write(clipboard);
} catch (final Exception e) { } catch (final Exception e) {
player.sendMessage(TranslatableCaption.of("single.single_area_failed_to_save")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_failed_to_save"));
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
@ -280,11 +282,11 @@ public class Area extends SubCommand {
final String world = this.setupUtils.setupWorld(singleBuilder); final String world = this.setupUtils.setupWorld(singleBuilder);
if (this.worldUtil.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
player.sendMessage(TranslatableCaption.of("single.single_area_created")); player.sendMessage(TranslatableCaption.miniMessage("single.single_area_created"));
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.error_create"), TranslatableCaption.miniMessage("errors.error_create"),
Template.of("world", hybridPlotWorld.getWorldName()) Placeholder.miniMessage("world", hybridPlotWorld.getWorldName())
); );
} }
}; };
@ -294,16 +296,16 @@ public class Area extends SubCommand {
case "c", "setup", "create" -> { case "c", "setup", "create" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_CREATE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_CREATE))
); );
return false; return false;
} }
switch (args.length) { switch (args.length) {
case 1: case 1:
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...") Placeholders.miniMessage("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
); );
return false; return false;
case 2: case 2:
@ -316,8 +318,8 @@ public class Area extends SubCommand {
.get("area_create_area"); .get("area_create_area");
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...") Placeholders.miniMessage("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
); );
return false; return false;
} }
@ -327,13 +329,13 @@ public class Area extends SubCommand {
location location
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("set.set_attribute"), TranslatableCaption.miniMessage("set.set_attribute"),
Template.of("attribute", "area_pos1"), Placeholder.miniMessage("attribute", "area_pos1"),
Template.of("value", location.getX() + "," + location.getZ()) Placeholder.miniMessage("value", location.getX() + "," + location.getZ())
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("area.set_pos2"), TranslatableCaption.miniMessage("area.set_pos2"),
Template.of("command", "/plot area create pos2") Placeholder.miniMessage("command", "/plot area create pos2")
); );
return true; return true;
} }
@ -346,8 +348,8 @@ public class Area extends SubCommand {
.get("area_create_area"); .get("area_create_area");
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...") Placeholders.miniMessage("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
); );
return false; return false;
} }
@ -372,8 +374,8 @@ public class Area extends SubCommand {
final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(area.getWorldName(), region); final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(area.getWorldName(), region);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"), TranslatableCaption.miniMessage("cluster.cluster_intersection"),
Template.of("cluster", areas.iterator().next().toString()) Placeholder.miniMessage("cluster", areas.iterator().next().toString())
); );
return false; return false;
} }
@ -396,7 +398,7 @@ public class Area extends SubCommand {
if (this.worldUtil.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE); player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE);
player.sendMessage(TranslatableCaption.of("setup.setup_finished")); player.sendMessage(TranslatableCaption.miniMessage("setup.setup_finished"));
if (area.getTerrain() != PlotAreaTerrainType.ALL) { if (area.getTerrain() != PlotAreaTerrainType.ALL) {
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world)); QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
queue.setChunkConsumer(chunk -> AugmentedUtils.generate( queue.setChunkConsumer(chunk -> AugmentedUtils.generate(
@ -411,8 +413,8 @@ public class Area extends SubCommand {
} }
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.error_create"), TranslatableCaption.miniMessage("errors.error_create"),
Template.of("world", area.getWorldName()) Placeholder.miniMessage("world", area.getWorldName())
); );
} }
}; };
@ -445,8 +447,8 @@ public class Area extends SubCommand {
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id); PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
if (other != null && Objects.equals(pa.getId(), other.getId())) { if (other != null && Objects.equals(pa.getId(), other.getId())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("setup.setup_world_taken"), TranslatableCaption.miniMessage("setup.setup_world_taken"),
Template.of("value", pa.toString()) Placeholder.miniMessage("value", pa.toString())
); );
return false; return false;
} }
@ -460,9 +462,9 @@ public class Area extends SubCommand {
String[] pair = args[i].split("="); String[] pair = args[i].split("=");
if (pair.length != 2) { if (pair.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"), TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Template.of("value1,", getCommandString()), Placeholder.miniMessage("value1,", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...") Placeholder.miniMessage("value2", " create [world[:id]] [<modifier>=<value>]...")
); );
return false; return false;
} }
@ -497,9 +499,9 @@ public class Area extends SubCommand {
} }
default -> { default -> {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"), TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()), Placeholder.miniMessage("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...") Placeholder.miniMessage("value2", " create [world[:id]] [<modifier>=<value>]...")
); );
return false; return false;
} }
@ -508,8 +510,8 @@ public class Area extends SubCommand {
if (pa.getType() != PlotAreaType.PARTIAL) { if (pa.getType() != PlotAreaType.PARTIAL) {
if (this.worldUtil.isWorld(pa.getWorldName())) { if (this.worldUtil.isWorld(pa.getWorldName())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("setup.setup_world_taken"), TranslatableCaption.miniMessage("setup.setup_world_taken"),
Template.of("value", pa.getWorldName()) Placeholder.miniMessage("value", pa.getWorldName())
); );
return false; return false;
} }
@ -526,11 +528,11 @@ public class Area extends SubCommand {
String world = this.setupUtils.setupWorld(builder); String world = this.setupUtils.setupWorld(builder);
if (this.worldUtil.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE); player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE);
player.sendMessage(TranslatableCaption.of("setup.setup_finished")); player.sendMessage(TranslatableCaption.miniMessage("setup.setup_finished"));
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.error_create"), TranslatableCaption.miniMessage("errors.error_create"),
Template.of("world", pa.getWorldName()) Placeholder.miniMessage("world", pa.getWorldName())
); );
} }
try { try {
@ -548,13 +550,13 @@ public class Area extends SubCommand {
} }
if (pa.getId() == null) { if (pa.getId() == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", getUsage()) Placeholder.miniMessage("value", getUsage())
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"), TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()), Placeholder.miniMessage("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...") Placeholder.miniMessage("value2", " create [world[:id]] [<modifier>=<value>]...")
); );
return false; return false;
} }
@ -570,8 +572,8 @@ public class Area extends SubCommand {
} }
metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa); metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("single.get_position"), TranslatableCaption.miniMessage("single.get_position"),
Template.of("command", getCommandString()) Placeholder.miniMessage("command", getCommandString())
); );
break; break;
} }
@ -580,8 +582,8 @@ public class Area extends SubCommand {
case "i", "info" -> { case "i", "info" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_INFO)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_INFO))
); );
return false; return false;
} }
@ -591,18 +593,18 @@ public class Area extends SubCommand {
case 2 -> area = this.plotAreaManager.getPlotAreaByString(args[1]); case 2 -> area = this.plotAreaManager.getPlotAreaByString(args[1]);
default -> { default -> {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"), TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()), Placeholder.miniMessage("value1", getCommandString()),
Template.of("value2", " info [area]") Placeholder.miniMessage("value2", " info [area]")
); );
return false; return false;
} }
} }
if (area == null) { if (area == null) {
if (args.length == 2) { if (args.length == 2) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), Template.of("value", args[1])); player.sendMessage(TranslatableCaption.miniMessage("errors.not_valid_plot_world"), Placeholder.miniMessage("value", args[1]));
} else { } else {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
return false; return false;
} }
@ -624,24 +626,24 @@ public class Area extends SubCommand {
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE; percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A"; region = "N/A";
} }
Template headerTemplate = Template.of( Placeholder<?> headerTemplate = Placeholder.miniMessage(
"header", "header",
TranslatableCaption.of("info.plot_info_header").getComponent(player) TranslatableCaption.miniMessage("info.plot_info_header").getComponent(player)
); );
Template nameTemplate = Template.of("name", name); Placeholder<?> nameTemplate = Placeholder.miniMessage("name", name);
Template typeTemplate = Template.of("type", area.getType().name()); Placeholder<?> typeTemplate = Placeholder.miniMessage("type", area.getType().name());
Template terrainTemplate = Template.of("terrain", area.getTerrain().name()); Placeholder<?> terrainTemplate = Placeholder.miniMessage("terrain", area.getTerrain().name());
Template usageTemplate = Template.of("usage", String.format("%.2f", percent)); Placeholder<?> usageTemplate = Placeholder.miniMessage("usage", String.format("%.2f", percent));
Template claimedTemplate = Template.of("claimed", String.valueOf(claimed)); Placeholder<?> claimedTemplate = Placeholder.miniMessage("claimed", String.valueOf(claimed));
Template clustersTemplate = Template.of("clusters", String.valueOf(clusters)); Placeholder<?> clustersTemplate = Placeholder.miniMessage("clusters", String.valueOf(clusters));
Template regionTemplate = Template.of("region", region); Placeholder<?> regionTemplate = Placeholder.miniMessage("region", region);
Template generatorTemplate = Template.of("generator", generator); Placeholder<?> generatorTemplate = Placeholder.miniMessage("generator", generator);
Template footerTemplate = Template.of( Placeholder<?> footerTemplate = Placeholder.miniMessage(
"footer", "footer",
TranslatableCaption.of("info.plot_info_footer").getComponent(player) TranslatableCaption.miniMessage("info.plot_info_footer").getComponent(player)
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("info.area_info_format"), TranslatableCaption.miniMessage("info.area_info_format"),
headerTemplate, headerTemplate,
nameTemplate, nameTemplate,
typeTemplate, typeTemplate,
@ -658,8 +660,8 @@ public class Area extends SubCommand {
case "l", "list" -> { case "l", "list" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_LIST)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_LIST))
); );
return false; return false;
} }
@ -675,9 +677,9 @@ public class Area extends SubCommand {
} }
default: default:
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"), TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()), Placeholder.miniMessage("value1", getCommandString()),
Template.of("value2", " list [#]") Placeholder.miniMessage("value2", " list [#]")
); );
return false; return false;
} }
@ -703,29 +705,30 @@ public class Area extends SubCommand {
percent = claimed == 0 ? 0 : (double) claimed / Short.MAX_VALUE * Short.MAX_VALUE; percent = claimed == 0 ? 0 : (double) claimed / Short.MAX_VALUE * Short.MAX_VALUE;
region = "N/A"; region = "N/A";
} }
Template claimedTemplate = Template.of("claimed", String.valueOf(claimed)); Placeholder<?> claimedTemplate = Placeholder.miniMessage("claimed", String.valueOf(claimed));
Template usageTemplate = Template.of("usage", String.format("%.2f", percent) + "%"); Placeholder<?> usageTemplate = Placeholder.miniMessage("usage", String.format("%.2f", percent) + "%");
Template clustersTemplate = Template.of("clusters", String.valueOf(clusters)); Placeholder<?> clustersTemplate = Placeholder.miniMessage("clusters", String.valueOf(clusters));
Template regionTemplate = Template.of("region", region); Placeholder<?> regionTemplate = Placeholder.miniMessage("region", region);
Template generatorTemplate = Template.of("generator", generator); Placeholder<?> generatorTemplate = Placeholder.miniMessage("generator", generator);
String tooltip = MINI_MESSAGE.serialize(MINI_MESSAGE String tooltip = MINI_MESSAGE.serialize(MINI_MESSAGE
.parse( .deserialize(
TranslatableCaption.of("info.area_list_tooltip").getComponent(player), TranslatableCaption.miniMessage("info.area_list_tooltip").getComponent(player),
PlaceholderResolver.placeholders(
claimedTemplate, claimedTemplate,
usageTemplate, usageTemplate,
clustersTemplate, clustersTemplate,
regionTemplate, regionTemplate,
generatorTemplate generatorTemplate
)); )));
Template tooltipTemplate = Template.of("hover_info", tooltip); Placeholder<?> tooltipTemplate = Placeholder.miniMessage("hover_info", tooltip);
Template visitcmdTemplate = Template.of("command_tp", "/plot area tp " + area); Placeholder<?> visitcmdTemplate = Placeholder.miniMessage("command_tp", "/plot area tp " + area);
Template infocmdTemplate = Template.of("command_info", "/plot area info " + area); Placeholder<?> infocmdTemplate = Placeholder.miniMessage("command_info", "/plot area info " + area);
Template numberTemplate = Template.of("number", String.valueOf(i)); Placeholder<?> numberTemplate = Placeholder.miniMessage("number", String.valueOf(i));
Template nameTemplate = Template.of("area_name", name); Placeholder<?> nameTemplate = Placeholder.miniMessage("area_name", name);
Template typeTemplate = Template.of("area_type", area.getType().name()); Placeholder<?> typeTemplate = Placeholder.miniMessage("area_type", area.getType().name());
Template terrainTemplate = Template.of("area_terrain", area.getTerrain().name()); Placeholder<?> terrainTemplate = Placeholder.miniMessage("area_terrain", area.getTerrain().name());
caption.set(TranslatableCaption.of("info.area_list_item")); caption.set(TranslatableCaption.miniMessage("info.area_list_item"));
caption.setTemplates( caption.parsePlaceholders(
tooltipTemplate, tooltipTemplate,
visitcmdTemplate, visitcmdTemplate,
numberTemplate, numberTemplate,
@ -735,26 +738,26 @@ public class Area extends SubCommand {
infocmdTemplate infocmdTemplate
); );
} }
}, "/plot area list", TranslatableCaption.of("list.area_list_header_paged")); }, "/plot area list", TranslatableCaption.miniMessage("list.area_list_header_paged"));
return true; return true;
} }
case "regen", "clear", "reset", "regenerate" -> { case "regen", "clear", "reset", "regenerate" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_REGEN)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_REGEN)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_REGEN)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_REGEN))
); );
return false; return false;
} }
final PlotArea area = player.getApplicablePlotArea(); final PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
if (area.getType() != PlotAreaType.PARTIAL) { if (area.getType() != PlotAreaType.PARTIAL) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("single.delete_world_region"), TranslatableCaption.miniMessage("single.delete_world_region"),
Template.of("world", area.getWorldName()) Placeholder.miniMessage("world", area.getWorldName())
); );
return false; return false;
} }
@ -767,28 +770,28 @@ public class Area extends SubCommand {
null null
)); ));
queue.addReadChunks(area.getRegion().getChunks()); queue.addReadChunks(area.getRegion().getChunks());
queue.setCompleteTask(() -> player.sendMessage(TranslatableCaption.of("single.regeneration_complete"))); queue.setCompleteTask(() -> player.sendMessage(TranslatableCaption.miniMessage("single.regeneration_complete")));
queue.enqueue(); queue.enqueue();
return true; return true;
} }
case "goto", "v", "teleport", "visit", "tp" -> { case "goto", "v", "teleport", "visit", "tp" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_TP)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_TP))
); );
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot area tp [area]") Placeholder.miniMessage("value", "/plot area tp [area]")
); );
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), Template.of("value", args[1])); player.sendMessage(TranslatableCaption.miniMessage("errors.not_valid_plot_world"), Placeholder.miniMessage("value", args[1]));
return false; return false;
} }
Location center; Location center;
@ -816,7 +819,7 @@ public class Area extends SubCommand {
return true; return true;
} }
case "delete", "remove" -> { case "delete", "remove" -> {
player.sendMessage(TranslatableCaption.of("single.worldcreation_location")); player.sendMessage(TranslatableCaption.miniMessage("single.worldcreation_location"));
return true; return true;
} }
} }
@ -856,11 +859,11 @@ public class Area extends SubCommand {
) { ) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_AREA) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_AREA) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -51,7 +51,7 @@ import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.AutoClaimFinishTask; import com.plotsquared.core.util.task.AutoClaimFinishTask;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -116,14 +116,14 @@ public class Auto extends SubCommand {
int grantedPlots = metaDataAccess.get().orElse(0); int grantedPlots = metaDataAccess.get().orElse(0);
if (diff < 0 && grantedPlots < sizeX * sizeZ) { if (diff < 0 && grantedPlots < sizeX * sizeZ) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(diff + grantedPlots)) Placeholder.miniMessage("amount", String.valueOf(diff + grantedPlots))
); );
return false; return false;
} else if (diff >= 0 && grantedPlots + diff < sizeX * sizeZ) { } else if (diff >= 0 && grantedPlots + diff < sizeX * sizeZ) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(diff + grantedPlots)) Placeholder.miniMessage("amount", String.valueOf(diff + grantedPlots))
); );
return false; return false;
} else { } else {
@ -134,15 +134,15 @@ public class Auto extends SubCommand {
metaDataAccess.set(left); metaDataAccess.set(left);
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_granted_plot"), TranslatableCaption.miniMessage("economy.removed_granted_plot"),
Template.of("usedGrants", String.valueOf(grantedPlots - left)), Placeholder.miniMessage("usedGrants", String.valueOf(grantedPlots - left)),
Template.of("remainingGrants", String.valueOf(left)) Placeholder.miniMessage("remainingGrants", String.valueOf(left))
); );
} }
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots()) Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots())
) )
); );
return false; return false;
@ -205,7 +205,7 @@ public class Auto extends SubCommand {
plotarea = this.plotAreaManager.getAllPlotAreas()[0]; plotarea = this.plotAreaManager.getAllPlotAreas()[0];
} }
if (plotarea == null) { if (plotarea == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
} }
@ -221,13 +221,13 @@ public class Auto extends SubCommand {
sizeZ = Integer.parseInt(split[1]); sizeZ = Integer.parseInt(split[1]);
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", getUsage()) Placeholder.miniMessage("value", getUsage())
); );
return true; return true;
} }
if (sizeX < 1 || sizeZ < 1) { if (sizeX < 1 || sizeZ < 1) {
player.sendMessage(TranslatableCaption.of("error.plot_size_negative")); player.sendMessage(TranslatableCaption.miniMessage("error.plot_size_negative"));
return true; return true;
} }
if (args.length > 1) { if (args.length > 1) {
@ -244,8 +244,8 @@ public class Auto extends SubCommand {
.callAuto(player, plotarea, schematic, sizeX, sizeZ); .callAuto(player, plotarea, schematic, sizeX, sizeZ);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Auto claim") Placeholder.miniMessage("value", "Auto claim")
); );
return true; return true;
} }
@ -255,14 +255,14 @@ public class Auto extends SubCommand {
schematic = event.getSchematic(); schematic = event.getSchematic();
if (!force && mega && !Permissions.hasPermission(player, Permission.PERMISSION_AUTO_MEGA)) { if (!force && mega && !Permissions.hasPermission(player, Permission.PERMISSION_AUTO_MEGA)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA))
); );
} }
if (!force && sizeX * sizeZ > Settings.Claim.MAX_AUTO_AREA) { if (!force && sizeX * sizeZ > Settings.Claim.MAX_AUTO_AREA) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots_num"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots_num"),
Template.of("amount", String.valueOf(Settings.Claim.MAX_AUTO_AREA)) Placeholder.miniMessage("amount", String.valueOf(Settings.Claim.MAX_AUTO_AREA))
); );
return false; return false;
} }
@ -279,9 +279,9 @@ public class Auto extends SubCommand {
if (schematic != null && !schematic.isEmpty()) { if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.hasSchematic(schematic)) { if (!plotarea.hasSchematic(schematic)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid_named"), TranslatableCaption.miniMessage("schematics.schematic_invalid_named"),
Template.of("schemname", schematic), Placeholder.miniMessage("schemname", schematic),
Template.of("reason", "non-existent") Placeholder.miniMessage("reason", "non-existent")
); );
return true; return true;
} }
@ -291,8 +291,8 @@ public class Auto extends SubCommand {
) && !Permissions ) && !Permissions
.hasPermission(player, "plots.admin.command.schematic")) { .hasPermission(player, "plots.admin.command.schematic")) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", "plots.claim.%s0") Placeholder.miniMessage("node", "plots.claim.%s0")
); );
return true; return true;
} }
@ -305,21 +305,21 @@ public class Auto extends SubCommand {
cost = (sizeX * sizeZ) * cost; cost = (sizeX * sizeZ) * cost;
if (cost > 0d) { if (cost > 0d) {
if (!this.econHandler.isSupported()) { if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null")); player.sendMessage(TranslatableCaption.miniMessage("economy.vault_or_consumer_null"));
return false; return false;
} }
if (!force && this.econHandler.getMoney(player) < cost) { if (!force && this.econHandler.getMoney(player) < cost) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"), TranslatableCaption.miniMessage("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(cost)), Placeholder.miniMessage("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
); );
return false; return false;
} }
this.econHandler.withdrawMoney(player, cost); this.econHandler.withdrawMoney(player, cost);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.miniMessage("economy.removed_balance"),
Template.of("money", this.econHandler.format(cost)) Placeholder.miniMessage("money", this.econHandler.format(cost))
); );
} }
} }
@ -332,7 +332,7 @@ public class Auto extends SubCommand {
plots = this.eventDispatcher.callAutoPlotsChosen(player, plots).getPlots(); plots = this.eventDispatcher.callAutoPlotsChosen(player, plots).getPlots();
if (plots.isEmpty()) { if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("errors.no_free_plots")); player.sendMessage(TranslatableCaption.miniMessage("errors.no_free_plots"));
return false; return false;
} else if (plots.size() == 1) { } else if (plots.size() == 1) {
this.claimSingle(player, plots.get(0), plotarea, schematic); this.claimSingle(player, plots.get(0), plotarea, schematic);
@ -344,6 +344,7 @@ public class Auto extends SubCommand {
continue; continue;
} }
plot.claim(player, !plotIterator.hasNext(), null, true, true); plot.claim(player, !plotIterator.hasNext(), null, true, true);
eventDispatcher.callPostAuto(player, plot);
} }
final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge( final PlotAutoMergeEvent mergeEvent = this.eventDispatcher.callAutoMerge(
plots.get(0), plots.get(0),
@ -351,8 +352,8 @@ public class Auto extends SubCommand {
); );
if (!force && mergeEvent.getEventResult() == Result.DENY) { if (!force && mergeEvent.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Auto merge") Placeholder.miniMessage("value", "Auto merge")
); );
return false; return false;
} }

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.nio.file.Files; import java.nio.file.Files;
@ -73,8 +73,8 @@ public final class Backup extends Command {
private static boolean sendMessage(PlotPlayer<?> player) { private static boolean sendMessage(PlotPlayer<?> player) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot backup <save | list | load>") Placeholder.miniMessage("value", "/plot backup <save | list | load>")
); );
return true; return true;
} }
@ -138,42 +138,42 @@ public final class Backup extends Command {
) { ) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_unowned").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_unowned").getComponent(player))
); );
} else if (plot.getVolume() > Integer.MAX_VALUE) { } else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
} else if (plot.isMerged()) { } else if (plot.isMerged()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_merged").getComponent(player))
); );
} else if (!plot.isOwner(player.getUUID()) && !Permissions } else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
); );
} else { } else {
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot)); final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) { if (backupProfile instanceof NullBackupProfile) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_other").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_other").getComponent(player))
); );
} else { } else {
backupProfile.createBackup().whenComplete((backup, throwable) -> { backupProfile.createBackup().whenComplete((backup, throwable) -> {
if (throwable != null) { if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_save_failed"), TranslatableCaption.miniMessage("backups.backup_save_failed"),
Template.of("reason", throwable.getMessage()) Placeholder.miniMessage("reason", throwable.getMessage())
); );
throwable.printStackTrace(); throwable.printStackTrace();
} else { } else {
player.sendMessage(TranslatableCaption.of("backups.backup_save_success")); player.sendMessage(TranslatableCaption.miniMessage("backups.backup_save_success"));
} }
}); });
} }
@ -192,51 +192,51 @@ public final class Backup extends Command {
) { ) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_unowned").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_unowned").getComponent(player))
); );
} else if (plot.isMerged()) { } else if (plot.isMerged()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_merged").getComponent(player))
); );
} else if (plot.getVolume() > Integer.MAX_VALUE) { } else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
} else if (!plot.isOwner(player.getUUID()) && !Permissions } else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
); );
} else { } else {
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot)); final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) { if (backupProfile instanceof NullBackupProfile) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_other").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_other").getComponent(player))
); );
} else { } else {
backupProfile.listBackups().whenComplete((backups, throwable) -> { backupProfile.listBackups().whenComplete((backups, throwable) -> {
if (throwable != null) { if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_list_failed"), TranslatableCaption.miniMessage("backups.backup_list_failed"),
Template.of("reason", throwable.getMessage()) Placeholder.miniMessage("reason", throwable.getMessage())
); );
throwable.printStackTrace(); throwable.printStackTrace();
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_list_header"), TranslatableCaption.miniMessage("backups.backup_list_header"),
Template.of("plot", plot.getId().toCommaSeparatedString()) Placeholder.miniMessage("plot", plot.getId().toCommaSeparatedString())
); );
try { try {
for (int i = 0; i < backups.size(); i++) { for (int i = 0; i < backups.size(); i++) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_list_entry"), TranslatableCaption.miniMessage("backups.backup_list_entry"),
Template.of("number", Integer.toString(i + 1)), Placeholder.miniMessage("number", Integer.toString(i + 1)),
Template.of("value", DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant( Placeholder.miniMessage("value", DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(
Instant.ofEpochMilli(backups.get(i).getCreationTime()), Instant.ofEpochMilli(backups.get(i).getCreationTime()),
ZoneId.systemDefault() ZoneId.systemDefault()
))) )))
@ -263,29 +263,29 @@ public final class Backup extends Command {
) { ) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (!plot.hasOwner()) { } else if (!plot.hasOwner()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_unowned").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_unowned").getComponent(player))
); );
} else if (plot.isMerged()) { } else if (plot.isMerged()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_merged").getComponent(player))
); );
} else if (plot.getVolume() > Integer.MAX_VALUE) { } else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
} else if (!plot.isOwner(player.getUUID()) && !Permissions } else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
); );
} else if (args.length == 0) { } else if (args.length == 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Usage: /plot backup save/list/load") Placeholder.miniMessage("value", "Usage: /plot backup save/list/load")
); );
} else { } else {
final int number; final int number;
@ -293,32 +293,32 @@ public final class Backup extends Command {
number = Integer.parseInt(args[0]); number = Integer.parseInt(args[0]);
} catch (final Exception e) { } catch (final Exception e) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"), TranslatableCaption.miniMessage("invalid.not_a_number"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
return; return;
} }
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot)); final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) { if (backupProfile instanceof NullBackupProfile) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_other").getComponent(player)) Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_other").getComponent(player))
); );
} else { } else {
backupProfile.listBackups().whenComplete((backups, throwable) -> { backupProfile.listBackups().whenComplete((backups, throwable) -> {
if (throwable != null) { if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_load_failure"), TranslatableCaption.miniMessage("backups.backup_load_failure"),
Template.of("reason", throwable.getMessage()) Placeholder.miniMessage("reason", throwable.getMessage())
); );
throwable.printStackTrace(); throwable.printStackTrace();
} else { } else {
if (number < 1 || number > backups.size()) { if (number < 1 || number > backups.size()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of( Placeholder.miniMessage(
"plot", "plot",
TranslatableCaption.of("generic.generic_invalid_choice").getComponent(player) TranslatableCaption.miniMessage("generic.generic_invalid_choice").getComponent(player)
) )
); );
} else { } else {
@ -327,10 +327,10 @@ public final class Backup extends Command {
if (backup == null || backup.getFile() == null || !Files if (backup == null || backup.getFile() == null || !Files
.exists(backup.getFile())) { .exists(backup.getFile())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"), TranslatableCaption.miniMessage("backups.backup_impossible"),
Template.of( Placeholder.miniMessage(
"plot", "plot",
TranslatableCaption.of("generic.generic_invalid_choice").getComponent(player) TranslatableCaption.miniMessage("generic.generic_invalid_choice").getComponent(player)
) )
); );
} else { } else {
@ -339,11 +339,11 @@ public final class Backup extends Command {
.whenComplete((n, error) -> { .whenComplete((n, error) -> {
if (error != null) { if (error != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("backups.backup_load_failure"), TranslatableCaption.miniMessage("backups.backup_load_failure"),
Template.of("reason", error.getMessage()) Placeholder.miniMessage("reason", error.getMessage())
); );
} else { } else {
player.sendMessage(TranslatableCaption.of("backups.backup_load_success")); player.sendMessage(TranslatableCaption.miniMessage("backups.backup_load_success"));
} }
}) })
); );

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.util.StringMan;
import com.sk89q.worldedit.command.util.SuggestionHelper; import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection; import java.util.Collection;
import java.util.Locale; import java.util.Locale;
@ -57,30 +57,30 @@ public class Biome extends SetCommand {
String biomes = StringMan.join( String biomes = StringMan.join(
BiomeType.REGISTRY.values(), BiomeType.REGISTRY.values(),
MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption
.of("blocklist.block_list_separator") .miniMessage("blocklist.block_list_separator")
.getComponent(player))) .getComponent(player)))
); );
player.sendMessage(TranslatableCaption.of("biome.need_biome")); player.sendMessage(TranslatableCaption.miniMessage("biome.need_biome"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.subcommand_set_options_header"), TranslatableCaption.miniMessage("commandconfig.subcommand_set_options_header"),
Template.of("values", biomes) Placeholder.miniMessage("values", biomes)
); );
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
plot.addRunning(); plot.addRunning();
plot.getPlotModificationManager().setBiome(biome, () -> { plot.getPlotModificationManager().setBiome(biome, () -> {
plot.removeRunning(); plot.removeRunning();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("biome.biome_set_to"), TranslatableCaption.miniMessage("biome.biome_set_to"),
Template.of("value", value.toLowerCase()) Placeholder.miniMessage("value", value.toLowerCase())
); );
}); });
return true; return true;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set; import java.util.Set;
@ -73,8 +73,8 @@ public class Buy extends Command {
) { ) {
PlotArea area = player.getPlotAreaAbs(); PlotArea area = player.getPlotAreaAbs();
check(area, TranslatableCaption.of("errors.not_in_plot_world")); check(area, TranslatableCaption.miniMessage("errors.not_in_plot_world"));
check(this.econHandler.isEnabled(area), TranslatableCaption.of("economy.econ_disabled")); check(this.econHandler.isEnabled(area), TranslatableCaption.miniMessage("economy.econ_disabled"));
final Plot plot; final Plot plot;
if (args.length != 0) { if (args.length != 0) {
if (args.length != 1) { if (args.length != 1) {
@ -83,37 +83,37 @@ public class Buy extends Command {
} }
plot = check(Plot.getPlotFromString(player, args[0], true), null); plot = check(Plot.getPlotFromString(player, args[0], true), null);
} else { } else {
plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
} }
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue(plot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
checkTrue(!plot.isOwner(player.getUUID()), TranslatableCaption.of("economy.cannot_buy_own")); checkTrue(!plot.isOwner(player.getUUID()), TranslatableCaption.miniMessage("economy.cannot_buy_own"));
Set<Plot> plots = plot.getConnectedPlots(); Set<Plot> plots = plot.getConnectedPlots();
checkTrue( checkTrue(
player.getPlotCount() + plots.size() <= player.getAllowedPlots(), player.getPlotCount() + plots.size() <= player.getAllowedPlots(),
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots())) Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
); );
double price = plot.getFlag(PriceFlag.class); double price = plot.getFlag(PriceFlag.class);
if (price <= 0) { if (price <= 0) {
throw new CommandException(TranslatableCaption.of("economy.not_for_sale")); throw new CommandException(TranslatableCaption.miniMessage("economy.not_for_sale"));
} }
checkTrue( checkTrue(
this.econHandler.isSupported(), this.econHandler.isSupported(),
TranslatableCaption.of("economy.vault_or_consumer_null") TranslatableCaption.miniMessage("economy.vault_or_consumer_null")
); );
checkTrue( checkTrue(
this.econHandler.getMoney(player) >= price, this.econHandler.getMoney(player) >= price,
TranslatableCaption.of("economy.cannot_afford_plot"), TranslatableCaption.miniMessage("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(price)), Placeholder.miniMessage("money", this.econHandler.format(price)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
); );
this.econHandler.withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
// Failure // Failure
// Success // Success
confirm.run(this, () -> { confirm.run(this, () -> {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.miniMessage("economy.removed_balance"),
Template.of("money", this.econHandler.format(price)) Placeholder.miniMessage("money", this.econHandler.format(price))
); );
this.econHandler.depositMoney(PlotSquared.platform().playerManager().getOfflinePlayer(plot.getOwnerAbs()), price); this.econHandler.depositMoney(PlotSquared.platform().playerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
@ -121,10 +121,10 @@ public class Buy extends Command {
PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs()); PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs());
if (owner != null) { if (owner != null) {
owner.sendMessage( owner.sendMessage(
TranslatableCaption.of("economy.plot_sold"), TranslatableCaption.miniMessage("economy.plot_sold"),
Template.of("plot", plot.getId().toString()), Placeholder.miniMessage("plot", plot.getId().toString()),
Template.of("player", player.getName()), Placeholder.miniMessage("player", player.getName()),
Template.of("price", this.econHandler.format(price)) Placeholder.miniMessage("price", this.econHandler.format(price))
); );
} }
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class); PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
@ -134,8 +134,8 @@ public class Buy extends Command {
} }
plot.setOwner(player.getUUID()); plot.setOwner(player.getUUID());
player.sendMessage( player.sendMessage(
TranslatableCaption.of("working.claimed"), TranslatableCaption.miniMessage("working.claimed"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
whenDone.run(Buy.this, CommandResult.SUCCESS); whenDone.run(Buy.this, CommandResult.SUCCESS);
}, () -> { }, () -> {

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.plot.flag.implementations.MiscCapFlag;
import com.plotsquared.core.plot.flag.implementations.MobCapFlag; import com.plotsquared.core.plot.flag.implementations.MobCapFlag;
import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag; import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL; import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ENTITY; import static com.plotsquared.core.util.entity.EntityCategories.CAP_ENTITY;
@ -55,22 +55,22 @@ public class Caps extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, final String[] args) { public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.isAdded(player.getUUID()) && !Permissions if (!plot.isAdded(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_CAPS_OTHER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_CAPS_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_CAPS_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_CAPS_OTHER))
); );
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("info.plot_caps_header")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_caps_header"));
final int[] countedEntities = plot.countEntities(); final int[] countedEntities = plot.countEntities();
sendFormatted(plot, player, MobCapFlag.class, countedEntities, "mobs", CAP_MOB); sendFormatted(plot, player, MobCapFlag.class, countedEntities, "mobs", CAP_MOB);
sendFormatted(plot, player, HostileCapFlag.class, countedEntities, "hostile", CAP_MONSTER); sendFormatted(plot, player, HostileCapFlag.class, countedEntities, "hostile", CAP_MONSTER);
@ -90,14 +90,14 @@ public class Caps extends SubCommand {
final int max = plot.getFlag(capFlag); final int max = plot.getFlag(capFlag);
final String percentage = String.format("%.1f", 100 * ((float) current / max)); final String percentage = String.format("%.1f", 100 * ((float) current / max));
String maxBeautified = max >= Integer.MAX_VALUE String maxBeautified = max >= Integer.MAX_VALUE
? TranslatableCaption.of("info.infinite").getComponent(player) ? TranslatableCaption.miniMessage("info.infinite").getComponent(player)
: String.valueOf(max); : String.valueOf(max);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("info.plot_caps_format"), TranslatableCaption.miniMessage("info.plot_caps_format"),
Template.of("cap", name), Placeholder.miniMessage("cap", name),
Template.of("current", String.valueOf(current)), Placeholder.miniMessage("current", String.valueOf(current)),
Template.of("limit", maxBeautified), Placeholder.miniMessage("limit", maxBeautified),
Template.of("percentage", percentage) Placeholder.miniMessage("percentage", percentage)
); );
} }

View File

@ -28,7 +28,7 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
/** /**
* @deprecated In favor of "/plot toggle chat" and * @deprecated In favor of "/plot toggle chat" and
@ -45,13 +45,13 @@ public class Chat extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer<?> player, String[] args) { public boolean onCommand(PlotPlayer<?> player, String[] args) {
PlotArea area = player.getPlotAreaAbs(); PlotArea area = player.getPlotAreaAbs();
check(area, TranslatableCaption.of("errors.not_in_plot_world")); check(area, TranslatableCaption.miniMessage("errors.not_in_plot_world"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.deprecated_commands"), TranslatableCaption.miniMessage("errors.deprecated_commands"),
Template.of("replacement", "/plot toggle chat") Placeholder.miniMessage("replacement", "/plot toggle chat")
); );
if (player.getPlotAreaAbs().isForcingPlotChat()) { if (player.getPlotAreaAbs().isForcingPlotChat()) {
player.sendMessage(TranslatableCaption.of("chat.plot_chat_forced")); player.sendMessage(TranslatableCaption.miniMessage("chat.plot_chat_forced"));
return true; return true;
} }
MainCommand.getInstance().toggle.chat(this, player, args, null, null); MainCommand.getInstance().toggle.chat(this, player, args, null, null);

View File

@ -45,7 +45,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -81,15 +81,15 @@ public class Claim extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
final PlayerClaimPlotEvent event = this.eventDispatcher.callClaim(player, plot, schematic); final PlayerClaimPlotEvent event = this.eventDispatcher.callClaim(player, plot, schematic);
schematic = event.getSchematic(); schematic = event.getSchematic();
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Claim") Placeholder.miniMessage("value", "Claim")
); );
return true; return true;
} }
@ -107,31 +107,31 @@ public class Claim extends SubCommand {
grants = metaDataAccess.get().orElse(0); grants = metaDataAccess.get().orElse(0);
if (grants <= 0) { if (grants <= 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(grants)) Placeholder.miniMessage("amount", String.valueOf(grants))
); );
metaDataAccess.remove(); metaDataAccess.remove();
} }
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots())) Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
); );
return false; return false;
} }
} }
if (!plot.canClaim(player)) { if (!plot.canClaim(player)) {
player.sendMessage(TranslatableCaption.of("working.plot_is_claimed")); player.sendMessage(TranslatableCaption.miniMessage("working.plot_is_claimed"));
return false; return false;
} }
if (schematic != null && !schematic.isEmpty()) { if (schematic != null && !schematic.isEmpty()) {
if (area.isSchematicClaimSpecify()) { if (area.isSchematicClaimSpecify()) {
if (!area.hasSchematic(schematic)) { if (!area.hasSchematic(schematic)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid_named"), TranslatableCaption.miniMessage("schematics.schematic_invalid_named"),
Template.of("schemname", schematic), Placeholder.miniMessage("schemname", schematic),
Template.of("reason", "non-existent") Placeholder.miniMessage("reason", "non-existent")
); );
} }
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLAIM_SCHEMATIC if (!Permissions.hasPermission(player, Permission.PERMISSION_CLAIM_SCHEMATIC
@ -140,8 +140,8 @@ public class Claim extends SubCommand {
"plots.admin.command.schematic" "plots.admin.command.schematic"
) && !force) { ) && !force) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_schematic_permission"), TranslatableCaption.miniMessage("permission.no_schematic_permission"),
Template.of("value", schematic) Placeholder.miniMessage("value", schematic)
); );
} }
} }
@ -151,22 +151,22 @@ public class Claim extends SubCommand {
double cost = costExr.evaluate(currentPlots); double cost = costExr.evaluate(currentPlots);
if (cost > 0d) { if (cost > 0d) {
if (!this.econHandler.isSupported()) { if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null")); player.sendMessage(TranslatableCaption.miniMessage("economy.vault_or_consumer_null"));
return false; return false;
} }
if (this.econHandler.getMoney(player) < cost) { if (this.econHandler.getMoney(player) < cost) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"), TranslatableCaption.miniMessage("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(cost)), Placeholder.miniMessage("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
); );
return false; return false;
} }
this.econHandler.withdrawMoney(player, cost); this.econHandler.withdrawMoney(player, cost);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.miniMessage("economy.removed_balance"),
Template.of("money", this.econHandler.format(cost)), Placeholder.miniMessage("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
); );
} }
} }
@ -177,17 +177,19 @@ public class Claim extends SubCommand {
metaDataAccess.set(grants - 1); metaDataAccess.set(grants - 1);
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_granted_plot"), TranslatableCaption.miniMessage("economy.removed_granted_plot"),
Template.of("usedGrants", String.valueOf((grants - 1))), Placeholder.miniMessage("usedGrants", String.valueOf((grants - 1))),
Template.of("remainingGrants", String.valueOf(grants)) Placeholder.miniMessage("remainingGrants", String.valueOf(grants))
); );
} }
} }
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
int border = area.getBorder(); int border = area.getBorder();
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) { if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
player.sendMessage(TranslatableCaption.of("border.border")); player.sendMessage(TranslatableCaption.miniMessage("border.denied"));
return false; return false;
} }
}
plot.setOwnerAbs(player.getUUID()); plot.setOwnerAbs(player.getUUID());
final String finalSchematic = schematic; final String finalSchematic = schematic;
DBFunc.createPlotSafe(plot, () -> { DBFunc.createPlotSafe(plot, () -> {
@ -195,24 +197,26 @@ public class Claim extends SubCommand {
TaskManager.getPlatformImplementation().sync(() -> { TaskManager.getPlatformImplementation().sync(() -> {
if (!plot.claim(player, true, finalSchematic, false, false)) { if (!plot.claim(player, true, finalSchematic, false, false)) {
LOGGER.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString()); LOGGER.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
plot.setOwnerAbs(null); plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) { } else if (area.isAutoMerge()) {
PlotMergeEvent mergeEvent = Claim.this.eventDispatcher PlotMergeEvent mergeEvent = Claim.this.eventDispatcher
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); .callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
if (mergeEvent.getEventResult() == Result.DENY) { if (mergeEvent.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Auto merge on claim") Placeholder.miniMessage("value", "Auto merge on claim")
); );
} else { } else {
plot.getPlotModificationManager().autoMerge( if (plot.getPlotModificationManager().autoMerge(
mergeEvent.getDir(), mergeEvent.getDir(),
mergeEvent.getMax(), mergeEvent.getMax(),
player.getUUID(), player.getUUID(),
player, player,
true true
); )) {
eventDispatcher.callPostMerge(player, plot);
}
} }
} }
return null; return null;
@ -222,7 +226,7 @@ public class Claim extends SubCommand {
} }
}, () -> { }, () -> {
LOGGER.info("Failed to add plot to database: {}", plot.getId().toCommaSeparatedString()); LOGGER.info("Failed to add plot to database: {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
plot.setOwnerAbs(null); plot.setOwnerAbs(null);
}); });
return true; return true;

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -80,28 +80,28 @@ public class Clear extends Command {
sendUsage(player); sendUsage(player);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
Result eventResult = this.eventDispatcher.callClear(plot).getEventResult(); Result eventResult = this.eventDispatcher.callClear(plot).getEventResult();
if (eventResult == Result.DENY) { if (eventResult == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Clear") Placeholder.miniMessage("value", "Clear")
); );
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
boolean force = eventResult == Result.FORCE; boolean force = eventResult == Result.FORCE;
checkTrue( checkTrue(
force || plot.isOwner(player.getUUID()) || Permissions force || plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.admin.command.clear"), .hasPermission(player, "plots.admin.command.clear"),
TranslatableCaption.of("permission.no_plot_perms") TranslatableCaption.miniMessage("permission.no_plot_perms")
); );
checkTrue(plot.getRunning() == 0, TranslatableCaption.of("errors.wait_for_timer")); checkTrue(plot.getRunning() == 0, TranslatableCaption.miniMessage("errors.wait_for_timer"));
checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
.hasPermission(player, "plots.continue"), TranslatableCaption.of("done.done_already_done")); .hasPermission(player, "plots.continue"), TranslatableCaption.miniMessage("done.done_already_done"));
confirm.run(this, () -> { confirm.run(this, () -> {
if (Settings.Teleport.ON_CLEAR) { if (Settings.Teleport.ON_CLEAR) {
plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND_CLEAR, plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND_CLEAR,
@ -135,14 +135,14 @@ public class Clear extends Command {
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("working.clearing_done"), TranslatableCaption.miniMessage("working.clearing_done"),
Template.of("amount", String.valueOf(System.currentTimeMillis() - start)), Placeholder.miniMessage("amount", String.valueOf(System.currentTimeMillis() - start)),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
}); });
}); });
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
} else { } else {
plot.addRunning(); plot.addRunning();
} }

View File

@ -42,13 +42,14 @@ import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -68,8 +69,8 @@ public class Cluster extends SubCommand {
if (args.length == 0) { if (args.length == 0) {
// return arguments // return arguments
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_available_args"), TranslatableCaption.miniMessage("cluster.cluster_available_args"),
Template.of( Placeholder.miniMessage(
"list", "list",
"<dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>" "<dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>"
) )
@ -78,77 +79,75 @@ public class Cluster extends SubCommand {
} }
String sub = args[0].toLowerCase(); String sub = args[0].toLowerCase();
switch (sub) { switch (sub) {
case "l": case "l", "list" -> {
case "list": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LIST)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LIST)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_LIST)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_LIST))
); );
return false; return false;
} }
if (args.length != 1) { if (args.length != 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster list") Placeholder.miniMessage("value", "/plot cluster list")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
Set<PlotCluster> clusters = area.getClusters(); Set<PlotCluster> clusters = area.getClusters();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_heading"), TranslatableCaption.miniMessage("cluster.cluster_list_heading"),
Template.of("amount", clusters.size() + "") Placeholder.miniMessage("amount", clusters.size() + "")
); );
for (PlotCluster cluster : clusters) { for (PlotCluster cluster : clusters) {
// Ignore unmanaged clusters // Ignore unmanaged clusters
String name = "'" + cluster.getName() + "' : " + cluster; String name = "'" + cluster.getName() + "' : " + cluster;
if (player.getUUID().equals(cluster.owner)) { if (player.getUUID().equals(cluster.owner)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_owner"), TranslatableCaption.miniMessage("cluster.cluster_list_element_owner"),
Template.of("cluster", name) Placeholder.miniMessage("cluster", name)
); );
} else if (cluster.helpers.contains(player.getUUID())) { } else if (cluster.helpers.contains(player.getUUID())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_helpers"), TranslatableCaption.miniMessage("cluster.cluster_list_element_helpers"),
Template.of("cluster", name) Placeholder.miniMessage("cluster", name)
); );
} else if (cluster.invited.contains(player.getUUID())) { } else if (cluster.invited.contains(player.getUUID())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_invited"), TranslatableCaption.miniMessage("cluster.cluster_list_element_invited"),
Template.of("cluster", name) Placeholder.miniMessage("cluster", name)
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element"), TranslatableCaption.miniMessage("cluster.cluster_list_element"),
Template.of("cluster", cluster.toString()) Placeholder.miniMessage("cluster", cluster.toString())
); );
} }
} }
return true; return true;
} }
case "c": case "c", "create" -> {
case "create": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_CREATE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_CREATE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE))
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
if (args.length != 4) { if (args.length != 4) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster create <name> <id-bot> <id-top>") Placeholder.miniMessage("value", "/plot cluster create <name> <id-bot> <id-top>")
); );
return false; return false;
} }
@ -157,8 +156,8 @@ public class Cluster extends SubCommand {
player.getPlotCount(player.getLocation().getWorldName()); player.getPlotCount(player.getLocation().getWorldName());
if (currentClusters >= player.getAllowedPlots()) { if (currentClusters >= player.getAllowedPlots()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_clusters"), TranslatableCaption.miniMessage("permission.cant_claim_more_clusters"),
Template.of("amount", String.valueOf(player.getAllowedPlots())) Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
); );
} }
PlotId pos1; PlotId pos1;
@ -168,15 +167,15 @@ public class Cluster extends SubCommand {
pos1 = PlotId.fromString(args[2]); pos1 = PlotId.fromString(args[2]);
pos2 = PlotId.fromString(args[3]); pos2 = PlotId.fromString(args[3]);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id")); player.sendMessage(TranslatableCaption.miniMessage("invalid.not_valid_plot_id"));
return false; return false;
} }
// check if name is taken // check if name is taken
String name = args[1]; String name = args[1];
if (area.getCluster(name) != null) { if (area.getCluster(name) != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("alias.alias_is_taken"), TranslatableCaption.miniMessage("alias.alias_is_taken"),
Template.of("alias", name) Placeholder.miniMessage("alias", name)
); );
return false; return false;
} }
@ -189,16 +188,16 @@ public class Cluster extends SubCommand {
PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2); PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2);
if (cluster != null) { if (cluster != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"), TranslatableCaption.miniMessage("cluster.cluster_intersection"),
Template.of("cluster", cluster.getName()) Placeholder.miniMessage("cluster", cluster.getName())
); );
return false; return false;
} }
// Check if it occupies existing plots // Check if it occupies existing plots
if (!area.contains(pos1) || !area.contains(pos2)) { if (!area.contains(pos1) || !area.contains(pos2)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_outside"), TranslatableCaption.miniMessage("cluster.cluster_outside"),
Template.of("area", String.valueOf(area)) Placeholder.miniMessage("area", String.valueOf(area))
); );
return false; return false;
} }
@ -210,8 +209,8 @@ public class Cluster extends SubCommand {
for (Plot plot : plots) { for (Plot plot : plots) {
if (!plot.isOwner(uuid)) { if (!plot.isOwner(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE_OTHER))
); );
return false; return false;
} }
@ -232,8 +231,8 @@ public class Cluster extends SubCommand {
); );
if (current + cluster.getArea() > allowed) { if (current + cluster.getArea() > allowed) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea())) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()))
); );
return false; return false;
} }
@ -251,31 +250,29 @@ public class Cluster extends SubCommand {
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_created"), TranslatableCaption.miniMessage("cluster.cluster_created"),
Template.of("name", name) Placeholder.miniMessage("name", name)
); );
return true; return true;
} }
case "disband": case "disband", "del", "delete" -> {
case "del":
case "delete": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE))
); );
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster delete [name]") Placeholder.miniMessage("value", "/plot cluster delete [name]")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
PlotCluster cluster; PlotCluster cluster;
@ -283,15 +280,15 @@ public class Cluster extends SubCommand {
cluster = area.getCluster(args[1]); cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"), TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Template.of("cluster", args[1]) Placeholder.miniMessage("cluster", args[1])
); );
return false; return false;
} }
} else { } else {
cluster = area.getCluster(player.getLocation()); cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
} }
@ -299,32 +296,31 @@ public class Cluster extends SubCommand {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE_OTHER)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE_OTHER))
); );
return false; return false;
} }
} }
DBFunc.delete(cluster); DBFunc.delete(cluster);
player.sendMessage(TranslatableCaption.of("cluster.cluster_deleted"), Template.of( player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_deleted"), Placeholder.miniMessage(
"cluster", "cluster",
String.valueOf(cluster) String.valueOf(cluster)
)); ));
return true; return true;
} }
case "res": case "res", "resize" -> {
case "resize": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE))
); );
return false; return false;
} }
if (args.length != 3) { if (args.length != 3) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster resize [name]") Placeholder.miniMessage("value", "/plot cluster resize [name]")
); );
return false; return false;
} }
@ -335,7 +331,7 @@ public class Cluster extends SubCommand {
pos1 = PlotId.fromString(args[2]); pos1 = PlotId.fromString(args[2]);
pos2 = PlotId.fromString(args[3]); pos2 = PlotId.fromString(args[3]);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id")); player.sendMessage(TranslatableCaption.miniMessage("invalid.not_valid_plot_id"));
return false; return false;
} }
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) { if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
@ -345,20 +341,20 @@ public class Cluster extends SubCommand {
// check if in cluster // check if in cluster
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
PlotCluster cluster = area.getCluster(player.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
if (!cluster.hasHelperRights(player.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_OTHER))
); );
return false; return false;
} }
@ -367,8 +363,8 @@ public class Cluster extends SubCommand {
PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2); PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2);
if (intersect != null) { if (intersect != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"), TranslatableCaption.miniMessage("cluster.cluster_intersection"),
Template.of("cluster", intersect.getName()) Placeholder.miniMessage("cluster", intersect.getName())
); );
return false; return false;
} }
@ -383,8 +379,8 @@ public class Cluster extends SubCommand {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_SHRINK))
); );
return false; return false;
} }
@ -394,8 +390,8 @@ public class Cluster extends SubCommand {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_EXPAND))
); );
return false; return false;
} }
@ -413,49 +409,47 @@ public class Cluster extends SubCommand {
); );
if (current + cluster.getArea() > allowed) { if (current + cluster.getArea() > allowed) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER + "." + (current + cluster.getArea())) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER + "." + (current + cluster.getArea()))
); );
return false; return false;
} }
// resize cluster // resize cluster
DBFunc.resizeCluster(cluster, pos1, pos2); DBFunc.resizeCluster(cluster, pos1, pos2);
player.sendMessage(TranslatableCaption.of("cluster.cluster_resized")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_resized"));
return true; return true;
} }
case "add": case "add", "inv", "invite" -> {
case "inv":
case "invite": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_INVITE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_INVITE))
); );
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster invite <player>") Placeholder.miniMessage("value", "/plot cluster invite <player>")
); );
return false; return false;
} }
// check if in cluster // check if in cluster
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
PlotCluster cluster = area.getCluster(player.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
if (!cluster.hasHelperRights(player.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE_OTHER)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_INVITE_OTHER.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_INVITE_OTHER.toString())
); );
return false; return false;
} }
@ -464,11 +458,11 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline() PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[1], (uuid, throwable) -> { .getSingle(args[1], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) { } else if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[1]) Placeholder.miniMessage("value", args[1])
); );
} else { } else {
if (!cluster.isAdded(uuid)) { if (!cluster.isAdded(uuid)) {
@ -479,48 +473,46 @@ public class Cluster extends SubCommand {
PlotSquared.platform().playerManager().getPlayerIfExists(uuid); PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (otherPlayer != null) { if (otherPlayer != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_invited"), TranslatableCaption.miniMessage("cluster.cluster_invited"),
Template.of("cluster", cluster.getName()) Placeholder.miniMessage("cluster", cluster.getName())
); );
} }
} }
player.sendMessage(TranslatableCaption.of("cluster.cluster_added_user")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_added_user"));
} }
}); });
return true; return true;
} }
case "k": case "k", "remove", "kick" -> {
case "remove":
case "kick": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_KICK.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_KICK.toString())
); );
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster kick <player>") Placeholder.miniMessage("value", "/plot cluster kick <player>")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
PlotCluster cluster = area.getCluster(player.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
if (!cluster.hasHelperRights(player.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK_OTHER)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_KICK_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_KICK_OTHER.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_KICK_OTHER.toString())
); );
return false; return false;
} }
@ -529,19 +521,19 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline() PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[1], (uuid, throwable) -> { .getSingle(args[1], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) { } else if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[1]) Placeholder.miniMessage("value", args[1])
); );
} else { } else {
// Can't kick if the player is yourself, the owner, or not added to the cluster // Can't kick if the player is yourself, the owner, or not added to the cluster
if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner) if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner)
|| !cluster.isAdded(uuid)) { || !cluster.isAdded(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cannot_kick_player"), TranslatableCaption.miniMessage("cluster.cannot_kick_player"),
Template.of("value", cluster.getName()) Placeholder.miniMessage("value", cluster.getName())
); );
} else { } else {
if (cluster.helpers.contains(uuid)) { if (cluster.helpers.contains(uuid)) {
@ -555,8 +547,8 @@ public class Cluster extends SubCommand {
PlotSquared.platform().playerManager().getPlayerIfExists(uuid); PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (player2 != null) { if (player2 != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"), TranslatableCaption.miniMessage("cluster.cluster_removed"),
Template.of("cluster", cluster.getName()) Placeholder.miniMessage("cluster", cluster.getName())
); );
} }
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation() for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
@ -566,56 +558,55 @@ public class Cluster extends SubCommand {
plot.unclaim(); plot.unclaim();
} }
} }
player.sendMessage(TranslatableCaption.of("cluster.cluster_kicked_user")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_kicked_user"));
} }
} }
}); });
return true; return true;
} }
case "quit": case "quit", "leave" -> {
case "leave": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LEAVE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LEAVE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_LEAVE.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_LEAVE.toString())
); );
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster leave [name]") Placeholder.miniMessage("value", "/plot cluster leave [name]")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
PlotCluster cluster; PlotCluster cluster;
if (args.length == 2) { if (args.length == 2) {
cluster = area.getCluster(args[1]); cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"), TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Template.of("cluster", args[1]) Placeholder.miniMessage("cluster", args[1])
); );
return false; return false;
} }
} else { } else {
cluster = area.getCluster(player.getLocation()); cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
} }
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
if (!cluster.isAdded(uuid)) { if (!cluster.isAdded(uuid)) {
player.sendMessage(TranslatableCaption.of("cluster.cluster_not_added")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_not_added"));
return false; return false;
} }
if (uuid.equals(cluster.owner)) { if (uuid.equals(cluster.owner)) {
player.sendMessage(TranslatableCaption.of("cluster.cluster_cannot_leave")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_cannot_leave"));
return false; return false;
} }
if (cluster.helpers.contains(uuid)) { if (cluster.helpers.contains(uuid)) {
@ -625,8 +616,8 @@ public class Cluster extends SubCommand {
cluster.invited.remove(uuid); cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid); DBFunc.removeInvited(cluster, uuid);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"), TranslatableCaption.miniMessage("cluster.cluster_removed"),
Template.of("cluster", cluster.getName()) Placeholder.miniMessage("cluster", cluster.getName())
); );
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName()) for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName())
.ownedBy(uuid)) { .ownedBy(uuid)) {
@ -637,86 +628,84 @@ public class Cluster extends SubCommand {
} }
return true; return true;
} }
case "members": { case "members" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_HELPERS)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_HELPERS)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_HELPERS.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_HELPERS.toString())
); );
return false; return false;
} }
if (args.length != 3) { if (args.length != 3) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster members <add | remove> <player>") Placeholder.miniMessage("value", "/plot cluster members <add | remove> <player>")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
PlotCluster cluster = area.getCluster(player.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
PlotSquared.get().getImpromptuUUIDPipeline() PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[2], (uuid, throwable) -> { .getSingle(args[2], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) { } else if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[2]) Placeholder.miniMessage("value", args[2])
); );
} else { } else {
if (args[1].equalsIgnoreCase("add")) { if (args[1].equalsIgnoreCase("add")) {
cluster.helpers.add(uuid); cluster.helpers.add(uuid);
DBFunc.setHelper(cluster, uuid); DBFunc.setHelper(cluster, uuid);
player.sendMessage(TranslatableCaption.of("cluster.cluster_added_helper")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_added_helper"));
} else if (args[1].equalsIgnoreCase("remove")) { } else if (args[1].equalsIgnoreCase("remove")) {
cluster.helpers.remove(uuid); cluster.helpers.remove(uuid);
DBFunc.removeHelper(cluster, uuid); DBFunc.removeHelper(cluster, uuid);
player.sendMessage(TranslatableCaption.of("cluster.cluster_removed_helper")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_removed_helper"));
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster members <add | remove> <player>") Placeholder.miniMessage("value", "/plot cluster members <add | remove> <player>")
); );
} }
} }
}); });
return true; return true;
} }
case "spawn": case "spawn", "home", "tp" -> {
case "home":
case "tp": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_TP.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_TP.toString())
); );
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster tp <name>") Placeholder.miniMessage("value", "/plot cluster tp <name>")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
PlotCluster cluster = area.getCluster(args[1]); PlotCluster cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"), TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Template.of("cluster", args[1]) Placeholder.miniMessage("cluster", args[1])
); );
return false; return false;
} }
@ -724,36 +713,33 @@ public class Cluster extends SubCommand {
if (!cluster.isAdded(uuid)) { if (!cluster.isAdded(uuid)) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP_OTHER)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_TP_OTHER.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_TP_OTHER.toString())
); );
return false; return false;
} }
} }
cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND_CLUSTER_TELEPORT)); cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND_CLUSTER_TELEPORT));
player.sendMessage(TranslatableCaption.of("cluster.cluster_teleporting")); player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_teleporting"));
return true; return true;
} }
case "i": case "i", "info", "show", "information" -> {
case "info":
case "show":
case "information": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INFO)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INFO)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_TP.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_TP.toString())
); );
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster info [name]") Placeholder.miniMessage("value", "/plot cluster info [name]")
); );
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
PlotCluster cluster; PlotCluster cluster;
@ -761,15 +747,15 @@ public class Cluster extends SubCommand {
cluster = area.getCluster(args[1]); cluster = area.getCluster(args[1]);
if (cluster == null) { if (cluster == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"), TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Template.of("cluster", args[1]) Placeholder.miniMessage("cluster", args[1])
); );
return false; return false;
} }
} else { } else {
cluster = area.getCluster(player.getLocation()); cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
} }
@ -778,24 +764,20 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline() PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(cluster.owner, (username, throwable) -> { .getSingle(cluster.owner, (username, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else { } else {
final String owner; final String owner;
if (username == null) { owner = Objects.requireNonNullElse(username, "unknown");
owner = "unknown";
} else {
owner = username;
}
String name = cluster.getName(); String name = cluster.getName();
String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + ( String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + (
cluster.getP2().getY() - cluster.getP1().getY() + 1); cluster.getP2().getY() - cluster.getP1().getY() + 1);
String rights = cluster.isAdded(player.getUUID()) + ""; String rights = cluster.isAdded(player.getUUID()) + "";
Caption message = TranslatableCaption.of("cluster.cluster_info"); Caption message = TranslatableCaption.miniMessage("cluster.cluster_info");
Template idTemplate = Template.of("id", id); Placeholder<?> idTemplate = Placeholder.miniMessage("id", id);
Template ownerTemplate = Template.of("owner", owner); Placeholder<?> ownerTemplate = Placeholder.miniMessage("owner", owner);
Template nameTemplate = Template.of("name", name); Placeholder<?> nameTemplate = Placeholder.miniMessage("name", name);
Template sizeTemplate = Template.of("size", size); Placeholder<?> sizeTemplate = Placeholder.miniMessage("size", size);
Template rightsTemplate = Template.of("rights", rights); Placeholder<?> rightsTemplate = Placeholder.miniMessage("rights", rights);
player.sendMessage( player.sendMessage(
message, message,
idTemplate, idTemplate,
@ -808,38 +790,36 @@ public class Cluster extends SubCommand {
}); });
return true; return true;
} }
case "sh": case "sh", "setspawn", "sethome" -> {
case "setspawn":
case "sethome": {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_SETHOME.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_SETHOME.toString())
); );
return false; return false;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot cluster sethome") Placeholder.miniMessage("value", "/plot cluster sethome")
); );
return false; return false;
} }
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
PlotCluster cluster = area.getCluster(player.getLocation()); PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) { if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false; return false;
} }
if (!cluster.hasHelperRights(player.getUUID())) { if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME_OTHER)) { .hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_SETHOME_OTHER.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_SETHOME_OTHER.toString())
); );
return false; return false;
} }
@ -852,13 +832,13 @@ public class Cluster extends SubCommand {
cluster, cluster,
relative.getX() + "," + relative.getY() + "," + relative.getZ() relative.getX() + "," + relative.getY() + "," + relative.getZ()
); );
player.sendMessage(TranslatableCaption.of("position.position_set")); player.sendMessage(TranslatableCaption.miniMessage("position.position_set"));
return true; return true;
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cluster_available_args"), TranslatableCaption.miniMessage("cluster.cluster_available_args"),
Template.of( Placeholder.miniMessage(
"list", "list",
"<dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>" "<dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>"
) )
@ -916,11 +896,11 @@ public class Cluster extends SubCommand {
) { ) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.player.PlayerMetaDataKeys;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime; import com.plotsquared.core.util.task.TaskTime;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public class CmdConfirm { public class CmdConfirm {
@ -58,10 +58,10 @@ public class CmdConfirm {
removePending(player); removePending(player);
if (commandStr != null) { if (commandStr != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("confirm.requires_confirm"), TranslatableCaption.miniMessage("confirm.requires_confirm"),
Template.of("command", commandStr), Placeholder.miniMessage("command", commandStr),
Template.of("timeout", String.valueOf(Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS)), Placeholder.miniMessage("timeout", String.valueOf(Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS)),
Template.of("value", "/plot confirm") Placeholder.miniMessage("value", "/plot confirm")
); );
} }
TaskManager.runTaskLater(() -> { TaskManager.runTaskLater(() -> {

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -213,9 +213,9 @@ public abstract class Command {
} }
Collections.reverse(path); Collections.reverse(path);
String descriptionKey = String.join(".", path); String descriptionKey = String.join(".", path);
this.description = TranslatableCaption.of(String.format("commands.description.%s", descriptionKey)); this.description = TranslatableCaption.miniMessage(String.format("commands.description.%s", descriptionKey));
} else { } else {
this.description = StaticCaption.of(declaration.description()); this.description = StaticCaption.miniMessage(declaration.description());
} }
this.usage = declaration.usage(); this.usage = declaration.usage();
this.confirmation = declaration.confirmation(); this.confirmation = declaration.confirmation();
@ -263,9 +263,9 @@ public abstract class Command {
max = c.size(); max = c.size();
} }
// Send the header // Send the header
Template curTemplate = Template.of("cur", String.valueOf(page + 1)); Placeholder<?> curTemplate = Placeholder.miniMessage("cur", String.valueOf(page + 1));
Template maxTemplate = Template.of("max", String.valueOf(totalPages + 1)); Placeholder<?> maxTemplate = Placeholder.miniMessage("max", String.valueOf(totalPages + 1));
Template amountTemplate = Template.of("amount", String.valueOf(c.size())); Placeholder<?> amountTemplate = Placeholder.miniMessage("amount", String.valueOf(c.size()));
player.sendMessage(header, curTemplate, maxTemplate, amountTemplate); player.sendMessage(header, curTemplate, maxTemplate, amountTemplate);
// Send the page content // Send the page content
List<T> subList = c.subList(page * size, max); List<T> subList = c.subList(page * size, max);
@ -274,13 +274,14 @@ public abstract class Command {
i++; i++;
final CaptionHolder msg = new CaptionHolder(); final CaptionHolder msg = new CaptionHolder();
add.run(i, obj, msg); add.run(i, obj, msg);
player.sendMessage(msg.get(), msg.getTemplates()); player.sendMessage(msg.caption(), msg.placeholders());
} }
// Send the footer // Send the footer
Template command1 = Template.of("command1", baseCommand + " " + page); Placeholder<?> command1 = Placeholder.miniMessage("command1", baseCommand + " " + page);
Template command2 = Template.of("command2", baseCommand + " " + (page + 2)); Placeholder<?> command2 = Placeholder.miniMessage("command2", baseCommand + " " + (page + 2));
Template clickable = Template.of("clickable", TranslatableCaption.of("list.clickable").getComponent(player)); Placeholder<?> clickable = Placeholder.miniMessage("clickable",
player.sendMessage(TranslatableCaption.of("list.page_turn"), command1, command2, clickable); TranslatableCaption.miniMessage("list.clickable").getComponent(player));
player.sendMessage(TranslatableCaption.miniMessage("list.page_turn"), command1, command2, clickable);
} }
/** /**
@ -306,7 +307,7 @@ public abstract class Command {
} }
if (this.allCommands.isEmpty()) { if (this.allCommands.isEmpty()) {
player.sendMessage( player.sendMessage(
StaticCaption.of("Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues")); StaticCaption.miniMessage("Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
Command cmd = getCommand(args[0]); Command cmd = getCommand(args[0]);
@ -327,12 +328,12 @@ public abstract class Command {
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
// Command recommendation // Command recommendation
player.sendMessage(TranslatableCaption.of("commandconfig.not_valid_subcommand")); player.sendMessage(TranslatableCaption.miniMessage("commandconfig.not_valid_subcommand"));
List<Command> commands = getCommands(player); List<Command> commands = getCommands(player);
if (commands.isEmpty()) { if (commands.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.did_you_mean"), TranslatableCaption.miniMessage("commandconfig.did_you_mean"),
Template.of("value", MainCommand.getInstance().help.getUsage()) Placeholder.miniMessage("value", MainCommand.getInstance().help.getUsage())
); );
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -352,8 +353,8 @@ public abstract class Command {
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject(); cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.did_you_mean"), TranslatableCaption.miniMessage("commandconfig.did_you_mean"),
Template.of("value", cmd.getUsage()) Placeholder.miniMessage("value", cmd.getUsage())
); );
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -388,8 +389,8 @@ public abstract class Command {
if (failed) { if (failed) {
// TODO improve or remove the Argument system // TODO improve or remove the Argument system
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", StringMan.join(fullSplit, " ")) Placeholder.miniMessage("value", StringMan.join(fullSplit, " "))
); );
return false; return false;
} }
@ -477,8 +478,8 @@ public abstract class Command {
} else if (!Permissions.hasPermission(player, getPermission())) { } else if (!Permissions.hasPermission(player, getPermission())) {
if (message) { if (message) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", getPermission()) Placeholder.miniMessage("node", getPermission())
); );
} }
} else { } else {
@ -502,8 +503,8 @@ public abstract class Command {
public void sendUsage(PlotPlayer<?> player) { public void sendUsage(PlotPlayer<?> player) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", getUsage()) Placeholder.miniMessage("value", getUsage())
); );
} }
@ -607,13 +608,29 @@ public abstract class Command {
return this.getFullId().hashCode(); return this.getFullId().hashCode();
} }
public void checkTrue(boolean mustBeTrue, Caption message, Template... args) { /**
* Check whether a given condition is true
*
* @param mustBeTrue The condition to check, that must be true
* @param message The message to send
* @param args The arguments to send with the message
*/
public void checkTrue(boolean mustBeTrue, Caption message, Placeholder<?>... args) {
if (!mustBeTrue) { if (!mustBeTrue) {
throw new CommandException(message, args); throw new CommandException(message, args);
} }
} }
public <T> T check(T object, Caption message, Template... args) { /**
* Check whether a given condition is true
*
* @param object The condition to check, that must be true
* @param message The message to send
* @param args The arguments to send with the message
* @param <T> The type of the object
* @return The object
*/
public <T> T check(T object, Caption message, Placeholder<?>... args) {
if (object == null) { if (object == null) {
throw new CommandException(message, args); throw new CommandException(message, args);
} }
@ -629,17 +646,23 @@ public abstract class Command {
public static class CommandException extends RuntimeException { public static class CommandException extends RuntimeException {
private final Template[] args; private final Placeholder<?>[] placeholders;
private final Caption message; private final Caption message;
public CommandException(final @Nullable Caption message, final Template... args) { /**
* Create a new CommandException
*
* @param message The message to send
* @param placeholders The placeholders to send with the message
*/
public CommandException(final @Nullable Caption message, final Placeholder<?>... placeholders) {
this.message = message; this.message = message;
this.args = args; this.placeholders = placeholders;
} }
public void perform(final @Nullable PlotPlayer<?> player) { public void perform(final @Nullable PlotPlayer<?> player) {
if (player != null && message != null) { if (player != null && message != null) {
player.sendMessage(message, args); player.sendMessage(message, placeholders);
} }
} }

View File

@ -26,7 +26,7 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.Caption;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
/** /**
@ -41,7 +41,7 @@ public interface CommandCaller {
* @param caption Caption to send * @param caption Caption to send
* @param replacements Variable replacements * @param replacements Variable replacements
*/ */
void sendMessage(@NonNull Caption caption, @NonNull Template... replacements); void sendMessage(@NonNull Caption caption, @NonNull Placeholder<?>... replacements);
/** /**
* Check the player's permissions. <i>Will be cached if permission caching is enabled.</i> * Check the player's permissions. <i>Will be cached if permission caching is enabled.</i>

View File

@ -38,42 +38,42 @@ public enum CommandCategory implements Caption {
* Claiming CommandConfig. * Claiming CommandConfig.
* Such as: /plot claim * Such as: /plot claim
*/ */
CLAIMING(TranslatableCaption.of("category.command_category_claiming")), CLAIMING(TranslatableCaption.miniMessage("category.command_category_claiming")),
/** /**
* Teleportation CommandConfig. * Teleportation CommandConfig.
* Such as: /plot visit * Such as: /plot visit
*/ */
TELEPORT(TranslatableCaption.of("category.command_category_teleport")), TELEPORT(TranslatableCaption.miniMessage("category.command_category_teleport")),
/** /**
* Protection. * Protection.
*/ */
SETTINGS(TranslatableCaption.of("category.command_category_settings")), SETTINGS(TranslatableCaption.miniMessage("category.command_category_settings")),
/** /**
* Chat. * Chat.
*/ */
CHAT(TranslatableCaption.of("category.command_category_chat")), CHAT(TranslatableCaption.miniMessage("category.command_category_chat")),
/** /**
* Web. * Web.
*/ */
SCHEMATIC(TranslatableCaption.of("category.command_category_schematic")), SCHEMATIC(TranslatableCaption.miniMessage("category.command_category_schematic")),
/** /**
* Cosmetic. * Cosmetic.
*/ */
APPEARANCE(TranslatableCaption.of("category.command_category_appearance")), APPEARANCE(TranslatableCaption.miniMessage("category.command_category_appearance")),
/** /**
* Information CommandConfig. * Information CommandConfig.
* Such as: /plot info * Such as: /plot info
*/ */
INFO(TranslatableCaption.of("category.command_category_info")), INFO(TranslatableCaption.miniMessage("category.command_category_info")),
/** /**
* Debug CommandConfig. * Debug CommandConfig.
* Such as: /plot debug * Such as: /plot debug
*/ */
DEBUG(TranslatableCaption.of("category.command_category_debug")), DEBUG(TranslatableCaption.miniMessage("category.command_category_debug")),
/** /**
* Administration commands. * Administration commands.
*/ */
ADMINISTRATION(TranslatableCaption.of("category.command_category_administration")); ADMINISTRATION(TranslatableCaption.miniMessage("category.command_category_administration"));
/** /**
* The category name (Readable). * The category name (Readable).
*/ */

View File

@ -34,7 +34,7 @@ import com.plotsquared.core.plot.comment.CommentInbox;
import com.plotsquared.core.plot.comment.CommentManager; import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.comment.PlotComment; import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
@ -50,9 +50,9 @@ public class Comment extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) { public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length < 2) { if (args.length < 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"), TranslatableCaption.miniMessage("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"), Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
); );
return false; return false;
} }
@ -70,9 +70,9 @@ public class Comment extends SubCommand {
} else { } else {
if (args.length < 3) { if (args.length < 3) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"), TranslatableCaption.miniMessage("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"), Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
); );
return false; return false;
} }
@ -82,15 +82,15 @@ public class Comment extends SubCommand {
CommentInbox inbox = CommentManager.inboxes.get(args[index - 1].toLowerCase()); CommentInbox inbox = CommentManager.inboxes.get(args[index - 1].toLowerCase());
if (inbox == null) { if (inbox == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"), TranslatableCaption.miniMessage("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"), Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
); );
return false; return false;
} }
if (!inbox.canWrite(plot, player)) { if (!inbox.canWrite(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox")); player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox"));
return false; return false;
} }
@ -101,22 +101,22 @@ public class Comment extends SubCommand {
); );
boolean result = inbox.addComment(plot, comment); boolean result = inbox.addComment(plot, comment);
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("comment.no_plot_inbox")); player.sendMessage(TranslatableCaption.miniMessage("comment.no_plot_inbox"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"), TranslatableCaption.miniMessage("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"), Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
); );
return false; return false;
} }
for (final PlotPlayer<?> pp : PlotSquared.platform().playerManager().getPlayers()) { for (final PlotPlayer<?> pp : PlotSquared.platform().playerManager().getPlayers()) {
if (pp.getAttribute("chatspy")) { if (pp.getAttribute("chatspy")) {
pp.sendMessage(StaticCaption.of("/plot comment " + StringMan.join(args, " "))); pp.sendMessage(StaticCaption.miniMessage("/plot comment " + StringMan.join(args, " ")));
} }
} }
player.sendMessage(TranslatableCaption.of("comment.comment_added")); player.sendMessage(TranslatableCaption.miniMessage("comment.comment_added"));
return true; return true;
} }

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime; import com.plotsquared.core.util.task.TaskTime;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
@ -73,31 +73,31 @@ public class Condense extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length != 2 && args.length != 3) { if (args.length != 2 && args.length != 3) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot condense <area> <start | stop | info> [radius]") Placeholder.miniMessage("value", "/plot condense <area> <start | stop | info> [radius]")
); );
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
if (area == null || !this.worldUtil.isWorld(area.getWorldName())) { if (area == null || !this.worldUtil.isWorld(area.getWorldName())) {
player.sendMessage(TranslatableCaption.of("invalid.invalid_area")); player.sendMessage(TranslatableCaption.miniMessage("invalid.invalid_area"));
return false; return false;
} }
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "start" -> { case "start" -> {
if (args.length == 2) { if (args.length == 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot condense" + area + " start <radius>") Placeholder.miniMessage("value", "/plot condense" + area + " start <radius>")
); );
return false; return false;
} }
if (Condense.TASK) { if (Condense.TASK) {
player.sendMessage(TranslatableCaption.of("condense.task_already_started")); player.sendMessage(TranslatableCaption.miniMessage("condense.task_already_started"));
return false; return false;
} }
if (!MathMan.isInteger(args[2])) { if (!MathMan.isInteger(args[2])) {
player.sendMessage(TranslatableCaption.of("condense.invalid_radius")); player.sendMessage(TranslatableCaption.miniMessage("condense.invalid_radius"));
return false; return false;
} }
int radius = Integer.parseInt(args[2]); int radius = Integer.parseInt(args[2]);
@ -141,7 +141,7 @@ public class Condense extends SubCommand {
int size = allPlots.size(); int size = allPlots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1); int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) { if (radius < minimumRadius) {
player.sendMessage(TranslatableCaption.of("condense.radius_too_small")); player.sendMessage(TranslatableCaption.miniMessage("condense.radius_too_small"));
return false; return false;
} }
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius)); List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
@ -155,20 +155,20 @@ public class Condense extends SubCommand {
start = start.getNextId(); start = start.getNextId();
} }
if (free.isEmpty() || toMove.isEmpty()) { if (free.isEmpty() || toMove.isEmpty()) {
player.sendMessage(TranslatableCaption.of("condense.no_free_plots_found")); player.sendMessage(TranslatableCaption.miniMessage("condense.no_free_plots_found"));
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("condense.task_started")); player.sendMessage(TranslatableCaption.miniMessage("condense.task_started"));
Condense.TASK = true; Condense.TASK = true;
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
if (!Condense.TASK) { if (!Condense.TASK) {
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_cancelled"));
} }
if (allPlots.isEmpty()) { if (allPlots.isEmpty()) {
Condense.TASK = false; Condense.TASK = false;
player.sendMessage(TranslatableCaption.of("condense.task_complete")); player.sendMessage(TranslatableCaption.miniMessage("condense.task_complete"));
return; return;
} }
final Runnable task = this; final Runnable task = this;
@ -186,9 +186,9 @@ public class Condense extends SubCommand {
result.set(origin.getPlotModificationManager().move(possible, player, () -> { result.set(origin.getPlotModificationManager().move(possible, player, () -> {
if (result.get()) { if (result.get()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("condense.moving"), TranslatableCaption.miniMessage("condense.moving"),
Template.of("origin", String.valueOf(origin)), Placeholder.miniMessage("origin", String.valueOf(origin)),
Template.of("possible", String.valueOf(possible)) Placeholder.miniMessage("possible", String.valueOf(possible))
); );
TaskManager.runTaskLater(task, TaskTime.ticks(1L)); TaskManager.runTaskLater(task, TaskTime.ticks(1L));
} }
@ -202,13 +202,13 @@ public class Condense extends SubCommand {
} }
if (free.isEmpty()) { if (free.isEmpty()) {
Condense.TASK = false; Condense.TASK = false;
player.sendMessage(TranslatableCaption.of("condense.task_failed")); player.sendMessage(TranslatableCaption.miniMessage("condense.task_failed"));
return; return;
} }
if (i >= free.size()) { if (i >= free.size()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("condense.skipping"), TranslatableCaption.miniMessage("condense.skipping"),
Template.of("plot", String.valueOf(origin)) Placeholder.miniMessage("plot", String.valueOf(origin))
); );
} }
} }
@ -218,23 +218,23 @@ public class Condense extends SubCommand {
} }
case "stop" -> { case "stop" -> {
if (!Condense.TASK) { if (!Condense.TASK) {
player.sendMessage(TranslatableCaption.of("condense.task_stopped")); player.sendMessage(TranslatableCaption.miniMessage("condense.task_stopped"));
return false; return false;
} }
Condense.TASK = false; Condense.TASK = false;
player.sendMessage(TranslatableCaption.of("condense.task_stopped")); player.sendMessage(TranslatableCaption.miniMessage("condense.task_stopped"));
return true; return true;
} }
case "info" -> { case "info" -> {
if (args.length == 2) { if (args.length == 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot condense " + area + " info <radius>") Placeholder.miniMessage("value", "/plot condense " + area + " info <radius>")
); );
return false; return false;
} }
if (!MathMan.isInteger(args[2])) { if (!MathMan.isInteger(args[2])) {
player.sendMessage(TranslatableCaption.of("condense.invalid_radius")); player.sendMessage(TranslatableCaption.miniMessage("condense.invalid_radius"));
return false; return false;
} }
int radius = Integer.parseInt(args[2]); int radius = Integer.parseInt(args[2]);
@ -242,37 +242,37 @@ public class Condense extends SubCommand {
int size = plots.size(); int size = plots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1); int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) { if (radius < minimumRadius) {
player.sendMessage(TranslatableCaption.of("condense.radius_too_small")); player.sendMessage(TranslatableCaption.miniMessage("condense.radius_too_small"));
return false; return false;
} }
int maxMove = getPlots(plots, minimumRadius).size(); int maxMove = getPlots(plots, minimumRadius).size();
int userMove = getPlots(plots, radius).size(); int userMove = getPlots(plots, radius).size();
player.sendMessage(TranslatableCaption.of("condense.default_eval")); player.sendMessage(TranslatableCaption.miniMessage("condense.default_eval"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("condense.minimum_radius"), TranslatableCaption.miniMessage("condense.minimum_radius"),
Template.of("minimumRadius", String.valueOf(minimumRadius)) Placeholder.miniMessage("minimumRadius", String.valueOf(minimumRadius))
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("condense.minimum_radius"), TranslatableCaption.miniMessage("condense.minimum_radius"),
Template.of("maxMove", String.valueOf(maxMove)) Placeholder.miniMessage("maxMove", String.valueOf(maxMove))
); );
player.sendMessage(TranslatableCaption.of("condense.input_eval")); player.sendMessage(TranslatableCaption.miniMessage("condense.input_eval"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("condense.input_radius"), TranslatableCaption.miniMessage("condense.input_radius"),
Template.of("radius", String.valueOf(radius)) Placeholder.miniMessage("radius", String.valueOf(radius))
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("condense.estimated_moves"), TranslatableCaption.miniMessage("condense.estimated_moves"),
Template.of("userMove", String.valueOf(userMove)) Placeholder.miniMessage("userMove", String.valueOf(userMove))
); );
player.sendMessage(TranslatableCaption.of("condense.eta")); player.sendMessage(TranslatableCaption.miniMessage("condense.eta"));
player.sendMessage(TranslatableCaption.of("condense.radius_measured")); player.sendMessage(TranslatableCaption.miniMessage("condense.radius_measured"));
return true; return true;
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot condense " + area.getWorldName() + " <start | stop | info> [radius]") Placeholder.miniMessage("value", "/plot condense " + area.getWorldName() + " <start | stop | info> [radius]")
); );
return false; return false;
} }

View File

@ -39,13 +39,13 @@ public class Confirm extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) { public boolean onCommand(PlotPlayer<?> player, String[] args) {
CmdInstance command = CmdConfirm.getPending(player); CmdInstance command = CmdConfirm.getPending(player);
if (command == null) { if (command == null) {
player.sendMessage(TranslatableCaption.of("confirm.failed_confirm")); player.sendMessage(TranslatableCaption.miniMessage("confirm.failed_confirm"));
return false; return false;
} }
CmdConfirm.removePending(player); CmdConfirm.removePending(player);
if ((System.currentTimeMillis() - command.timestamp) if ((System.currentTimeMillis() - command.timestamp)
> Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS * 1000) { > Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS * 1000) {
player.sendMessage(TranslatableCaption.of("confirm.expired_confirm")); player.sendMessage(TranslatableCaption.miniMessage("confirm.expired_confirm"));
return false; return false;
} }
TaskManager.runTaskAsync(command.command); TaskManager.runTaskAsync(command.command);

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "continue", @CommandDeclaration(command = "continue",
@ -57,32 +57,32 @@ public class Continue extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) { public boolean onCommand(PlotPlayer<?> player, String[] args) {
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_CONTINUE)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", TranslatableCaption.of("permission.no_plot_perms").getComponent(player)) Placeholder.miniMessage("node", TranslatableCaption.miniMessage("permission.no_plot_perms").getComponent(player))
); );
return false; return false;
} }
if (!DoneFlag.isDone(plot)) { if (!DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("done.done_not_done")); player.sendMessage(TranslatableCaption.miniMessage("done.done_not_done"));
return false; return false;
} }
int size = plot.getConnectedPlots().size(); int size = plot.getConnectedPlots().size();
if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots()
< player.getPlotCount() + size)) { < player.getPlotCount() + size)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"), TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots())) Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
); );
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class); PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
@ -90,13 +90,13 @@ public class Continue extends SubCommand {
this.eventDispatcher.callFlagRemove(plotFlag, plot); this.eventDispatcher.callFlagRemove(plotFlag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Done flag removal") Placeholder.miniMessage("value", "Done flag removal")
); );
return true; return true;
} }
plot.removeFlag(event.getFlag()); plot.removeFlag(event.getFlag());
player.sendMessage(TranslatableCaption.of("done.done_removed")); player.sendMessage(TranslatableCaption.miniMessage("done.done_removed"));
return true; return true;
} }

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "copy", @CommandDeclaration(command = "copy",
permission = "plots.copy", permission = "plots.copy",
@ -46,18 +46,18 @@ public class Copy extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot1 = location.getPlotAbs(); Plot plot1 = location.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot1.isOwner(player.getUUID()) && !Permissions if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN.toString())) { .hasPermission(player, Permission.PERMISSION_ADMIN.toString())) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (args.length != 1) { if (args.length != 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot copy <X;Z>") Placeholder.miniMessage("value", "/plot copy <X;Z>")
); );
return false; return false;
} }
@ -66,21 +66,21 @@ public class Copy extends SubCommand {
return false; return false;
} }
if (plot1.equals(plot2)) { if (plot1.equals(plot2)) {
player.sendMessage(TranslatableCaption.of("invalid.origin_cant_be_target")); player.sendMessage(TranslatableCaption.miniMessage("invalid.origin_cant_be_target"));
return false; return false;
} }
if (!plot1.getArea().isCompatible(plot2.getArea())) { if (!plot1.getArea().isCompatible(plot2.getArea())) {
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible")); player.sendMessage(TranslatableCaption.miniMessage("errors.plotworld_incompatible"));
return false; return false;
} }
plot1.getPlotModificationManager().copy(plot2, player).thenAccept(result -> { plot1.getPlotModificationManager().copy(plot2, player).thenAccept(result -> {
if (result) { if (result) {
player.sendMessage(TranslatableCaption.of("move.copy_success"), Template.of("origin", String.valueOf(plot1)), player.sendMessage(TranslatableCaption.miniMessage("move.copy_success"), Placeholder.miniMessage("origin", String.valueOf(plot1)),
Template.of("target", String.valueOf(plot2)) Placeholder.miniMessage("target", String.valueOf(plot2))
); );
} else { } else {
player.sendMessage(TranslatableCaption.of("move.requires_unowned")); player.sendMessage(TranslatableCaption.miniMessage("move.requires_unowned"));
} }
}); });

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "createroadschematic", @CommandDeclaration(command = "createroadschematic",
@ -55,20 +55,20 @@ public class CreateRoadSchematic extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
if (!(location.getPlotArea() instanceof HybridPlotWorld)) { if (!(location.getPlotArea() instanceof HybridPlotWorld)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
this.hybridUtils.setupRoadSchematic(plot); this.hybridUtils.setupRoadSchematic(plot);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_road_created"), TranslatableCaption.miniMessage("schematics.schematic_road_created"),
Template.of("command", "/plot debugroadregen") Placeholder.miniMessage("command", "/plot debugroadregen")
); );
return true; return true;
} }

View File

@ -47,7 +47,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.FileUtils; import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File; import java.io.File;
@ -91,13 +91,13 @@ public class DatabaseCommand extends SubCommand {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
try { try {
ArrayList<Plot> ps = new ArrayList<>(plots); ArrayList<Plot> ps = new ArrayList<>(plots);
player.sendMessage(TranslatableCaption.of("database.starting_conversion")); player.sendMessage(TranslatableCaption.miniMessage("database.starting_conversion"));
manager.createPlotsAndData(ps, () -> { manager.createPlotsAndData(ps, () -> {
player.sendMessage(TranslatableCaption.of("database.conversion_done")); player.sendMessage(TranslatableCaption.miniMessage("database.conversion_done"));
manager.close(); manager.close();
}); });
} catch (Exception e) { } catch (Exception e) {
player.sendMessage(TranslatableCaption.of("database.conversion_failed")); player.sendMessage(TranslatableCaption.miniMessage("database.conversion_failed"));
e.printStackTrace(); e.printStackTrace();
} }
}); });
@ -107,8 +107,8 @@ public class DatabaseCommand extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot database [area] <sqlite | mysql | import>") Placeholder.miniMessage("value", "/plot database [area] <sqlite | mysql | import>")
); );
return false; return false;
} }
@ -122,10 +122,10 @@ public class DatabaseCommand extends SubCommand {
} }
if (args.length < 1) { if (args.length < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot database [area] <sqlite|mysql|import>") Placeholder.miniMessage("value", "/plot database [area] <sqlite|mysql|import>")
); );
player.sendMessage(TranslatableCaption.of("database.arg")); player.sendMessage(TranslatableCaption.miniMessage("database.arg"));
return false; return false;
} }
try { try {
@ -135,8 +135,8 @@ public class DatabaseCommand extends SubCommand {
case "import" -> { case "import" -> {
if (args.length < 2) { if (args.length < 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot database import <sqlite file> [prefix]") Placeholder.miniMessage("value", "/plot database import <sqlite file> [prefix]")
); );
return false; return false;
} }
@ -146,12 +146,12 @@ public class DatabaseCommand extends SubCommand {
); );
if (!file.exists()) { if (!file.exists()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("database.does_not_exist"), TranslatableCaption.miniMessage("database.does_not_exist"),
Template.of("value", String.valueOf(file)) Placeholder.miniMessage("value", String.valueOf(file))
); );
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("database.starting_conversion")); player.sendMessage(TranslatableCaption.miniMessage("database.starting_conversion"));
implementation = new SQLite(file); implementation = new SQLite(file);
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "", SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "",
this.eventDispatcher, this.plotListener, this.worldConfiguration this.eventDispatcher, this.plotListener, this.worldConfiguration
@ -190,9 +190,9 @@ public class DatabaseCommand extends SubCommand {
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("database.skipping_duplicated_plot"), TranslatableCaption.miniMessage("database.skipping_duplicated_plot"),
Template.of("plot", String.valueOf(plot)), Placeholder.miniMessage("plot", String.valueOf(plot)),
Template.of("id", String.valueOf(plot.temp)) Placeholder.miniMessage("id", String.valueOf(plot.temp))
); );
continue; continue;
} }
@ -207,13 +207,13 @@ public class DatabaseCommand extends SubCommand {
} }
DBFunc.createPlotsAndData( DBFunc.createPlotsAndData(
plots, plots,
() -> player.sendMessage(TranslatableCaption.of("database.conversion_done")) () -> player.sendMessage(TranslatableCaption.miniMessage("database.conversion_done"))
); );
return true; return true;
} }
case "mysql" -> { case "mysql" -> {
if (args.length < 6) { if (args.length < 6) {
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"/plot database mysql [host] [port] [username] [password] [database] {prefix}")); "/plot database mysql [host] [port] [username] [password] [database] {prefix}"));
return false; return false;
} }
@ -229,7 +229,7 @@ public class DatabaseCommand extends SubCommand {
} }
case "sqlite" -> { case "sqlite" -> {
if (args.length < 2) { if (args.length < 2) {
player.sendMessage(StaticCaption.of("/plot database sqlite [file]")); player.sendMessage(StaticCaption.miniMessage("/plot database sqlite [file]"));
return false; return false;
} }
File sqliteFile = File sqliteFile =
@ -237,7 +237,7 @@ public class DatabaseCommand extends SubCommand {
implementation = new SQLite(sqliteFile); implementation = new SQLite(sqliteFile);
} }
default -> { default -> {
player.sendMessage(StaticCaption.of("/plot database [sqlite/mysql]")); player.sendMessage(StaticCaption.miniMessage("/plot database [sqlite/mysql]"));
return false; return false;
} }
} }
@ -252,19 +252,19 @@ public class DatabaseCommand extends SubCommand {
DatabaseCommand.insertPlots(manager, plots, player); DatabaseCommand.insertPlots(manager, plots, player);
return true; return true;
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
player.sendMessage(TranslatableCaption.of("database.failed_to_save_plots")); player.sendMessage(TranslatableCaption.miniMessage("database.failed_to_save_plots"));
player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin")); player.sendMessage(TranslatableCaption.miniMessage("errors.stacktrace_begin"));
e.printStackTrace(); e.printStackTrace();
player.sendMessage(TranslatableCaption.of(("errors.stacktrace_end"))); player.sendMessage(TranslatableCaption.miniMessage(("errors.stacktrace_end")));
player.sendMessage(TranslatableCaption.of("database.invalid_args")); player.sendMessage(TranslatableCaption.miniMessage("database.invalid_args"));
return false; return false;
} }
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
player.sendMessage(TranslatableCaption.of("database.failed_to_open")); player.sendMessage(TranslatableCaption.miniMessage("database.failed_to_open"));
player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin")); player.sendMessage(TranslatableCaption.miniMessage("errors.stacktrace_begin"));
e.printStackTrace(); e.printStackTrace();
player.sendMessage(TranslatableCaption.of("errors.stacktrace_end")); player.sendMessage(TranslatableCaption.miniMessage("errors.stacktrace_end"));
player.sendMessage(TranslatableCaption.of("database.invalid_args")); player.sendMessage(TranslatableCaption.miniMessage("database.invalid_args"));
return false; return false;
} }
} }

View File

@ -41,7 +41,8 @@ import com.plotsquared.core.uuid.UUIDMapping;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -74,14 +75,14 @@ public class Debug extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) { public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot debug <loadedchunks | player | debug-players | entitytypes | msg>") Placeholder.miniMessage("value", "/plot debug <loadedchunks | player | debug-players | entitytypes | msg>")
); );
} }
if (args.length > 0) { if (args.length > 0) {
if ("player".equalsIgnoreCase(args[0])) { if ("player".equalsIgnoreCase(args[0])) {
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) { for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {
player.sendMessage(StaticCaption.of("Key: " + meta.getKey() + " Value: " + meta player.sendMessage(StaticCaption.miniMessage("Key: " + meta.getKey() + " Value: " + meta
.getValue() .getValue()
.toString() + " , ")); .toString() + " , "));
} }
@ -90,9 +91,9 @@ public class Debug extends SubCommand {
} }
if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) { if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
player.sendMessage(TranslatableCaption.of("debug.fetching_loaded_chunks")); player.sendMessage(TranslatableCaption.miniMessage("debug.fetching_loaded_chunks"));
TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption
.of("Loaded chunks: " + this.worldUtil .miniMessage("Loaded chunks: " + this.worldUtil
.getChunkChunks(player.getLocation().getWorldName()) .getChunkChunks(player.getLocation().getWorldName())
.size() + " (" + (System.currentTimeMillis() .size() + " (" + (System.currentTimeMillis()
- start) + "ms) using thread: " + Thread.currentThread().getName()))); - start) + "ms) using thread: " + Thread.currentThread().getName())));
@ -101,31 +102,31 @@ public class Debug extends SubCommand {
if (args.length > 0 && "uuids".equalsIgnoreCase(args[0])) { if (args.length > 0 && "uuids".equalsIgnoreCase(args[0])) {
final Collection<UUIDMapping> mappings = PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately(); final Collection<UUIDMapping> mappings = PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debug.cached_uuids"), TranslatableCaption.miniMessage("debug.cached_uuids"),
Template.of("value", String.valueOf(mappings.size())) Placeholder.miniMessage("value", String.valueOf(mappings.size()))
); );
return true; return true;
} }
if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) { if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) {
player.sendMessage(TranslatableCaption.of("debug.player_in_debugmode")); player.sendMessage(TranslatableCaption.miniMessage("debug.player_in_debugmode"));
for (final PlotPlayer<?> pp : PlotPlayer.getDebugModePlayers()) { for (final PlotPlayer<?> pp : PlotPlayer.getDebugModePlayers()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debug.player_in_debugmode_list"), TranslatableCaption.miniMessage("debug.player_in_debugmode_list"),
Template.of("value", pp.getName()) Placeholder.miniMessage("value", pp.getName())
); );
} }
return true; return true;
} }
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) { if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
EntityCategories.init(); EntityCategories.init();
player.sendMessage(TranslatableCaption.of("debug.entity_categories")); player.sendMessage(TranslatableCaption.miniMessage("debug.entity_categories"));
EntityCategory.REGISTRY.forEach(category -> { EntityCategory.REGISTRY.forEach(category -> {
final StringBuilder builder = final StringBuilder builder =
new StringBuilder("§7- §6").append(category.getId()).append("§7: §6"); new StringBuilder("§7- §6").append(category.getId()).append("§7: §6");
for (final EntityType entityType : category.getAll()) { for (final EntityType entityType : category.getAll()) {
builder.append(entityType.getId()).append(" "); builder.append(entityType.getId()).append(" ");
} }
player.sendMessage(StaticCaption.of("<prefix>" + builder)); player.sendMessage(StaticCaption.miniMessage("<prefix>" + builder));
}); });
EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId)) EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId))
.forEach(entityType -> { .forEach(entityType -> {
@ -134,7 +135,7 @@ public class Debug extends SubCommand {
if (categoryCount > 0) { if (categoryCount > 0) {
return; return;
} }
player.sendMessage(StaticCaption.of("<prefix>" + entityType.getName() + " is in " player.sendMessage(StaticCaption.miniMessage("<prefix>" + entityType.getName() + " is in "
+ categoryCount + " categories")); + categoryCount + " categories"));
}); });
return true; return true;
@ -144,30 +145,32 @@ public class Debug extends SubCommand {
.getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE) .getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE)
.getCaptions(); .getCaptions();
TextComponent.Builder information = Component.text(); TextComponent.Builder information = Component.text();
Component header = MINI_MESSAGE.parse(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n"); Component header = MINI_MESSAGE.parse(TranslatableCaption.miniMessage("debug.debug_header").getComponent(player) + "\n");
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n"; String line = TranslatableCaption.miniMessage("debug.debug_line").getComponent(player) + "\n";
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n"; String section = TranslatableCaption.miniMessage("debug.debug_section").getComponent(player) + "\n";
information.append(header); information.append(header);
information.append(MINI_MESSAGE.parse(section, Template.of("val", "PlotArea"))); information.append(MINI_MESSAGE.deserialize(section,
PlaceholderResolver.placeholders(Placeholder.miniMessage("val", "PlotArea"))));
information.append(MINI_MESSAGE information.append(MINI_MESSAGE
.parse( .deserialize(
line, line,
Template.of("var", "Plot Worlds"), PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Plot Worlds"),
Template.of("val", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", ")) Placeholder.miniMessage("val", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", ")))
)); ));
information.append( information.append(
MINI_MESSAGE.parse( MINI_MESSAGE.deserialize(
line, line,
Template.of("var", "Owned Plots"), PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Owned Plots"),
Template.of("val", String.valueOf(PlotQuery.newQuery().allPlots().count())) Placeholder.miniMessage("val", String.valueOf(PlotQuery.newQuery().allPlots().count())))
)); ));
information.append(MINI_MESSAGE.parse(section, Template.of("val", "Messages"))); information.append(MINI_MESSAGE.deserialize(section,
information.append(MINI_MESSAGE.parse( PlaceholderResolver.placeholders(Placeholder.miniMessage("val", "Messages"))));
information.append(MINI_MESSAGE.deserialize(
line, line,
Template.of("var", "Total Messages"), PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Total Messages"),
Template.of("val", String.valueOf(captions.size())) Placeholder.miniMessage("val", String.valueOf(captions.size())))
)); ));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(information.build()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(information.build())));
return true; return true;
} }

View File

@ -46,10 +46,10 @@ public class DebugAllowUnsafe extends SubCommand {
if (unsafeAllowed.contains(player.getUUID())) { if (unsafeAllowed.contains(player.getUUID())) {
unsafeAllowed.remove(player.getUUID()); unsafeAllowed.remove(player.getUUID());
player.sendMessage(TranslatableCaption.of("unsafe.debugallowunsafe_off")); player.sendMessage(TranslatableCaption.miniMessage("unsafe.debugallowunsafe_off"));
} else { } else {
unsafeAllowed.add(player.getUUID()); unsafeAllowed.add(player.getUUID());
player.sendMessage(TranslatableCaption.of("unsafe.debugallowunsafe_on")); player.sendMessage(TranslatableCaption.miniMessage("unsafe.debugallowunsafe_on"));
} }
return true; return true;
} }

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Arrays; import java.util.Arrays;
@ -95,24 +95,24 @@ public class DebugExec extends SubCommand {
case "analyze" -> { case "analyze" -> {
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
PlotAnalysis analysis = plot.getComplexity(null); PlotAnalysis analysis = plot.getComplexity(null);
if (analysis != null) { if (analysis != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugexec.changes_column"), TranslatableCaption.miniMessage("debugexec.changes_column"),
Template.of("value", String.valueOf(analysis.changes)) Placeholder.miniMessage("value", String.valueOf(analysis.changes))
); );
return true; return true;
} }
player.sendMessage(TranslatableCaption.of("debugexec.starting_task")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.starting_task"));
this.hybridUtils.analyzePlot(plot, new RunnableVal<>() { this.hybridUtils.analyzePlot(plot, new RunnableVal<>() {
@Override @Override
public void run(PlotAnalysis value) { public void run(PlotAnalysis value) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugexec.analyze_done"), TranslatableCaption.miniMessage("debugexec.analyze_done"),
Template.of("command", "/plot debugexec analyze") Placeholder.miniMessage("command", "/plot debugexec analyze")
); );
} }
}); });
@ -121,10 +121,10 @@ public class DebugExec extends SubCommand {
case "calibrate-analysis" -> { case "calibrate-analysis" -> {
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot debugexec analyze <threshold>") Placeholder.miniMessage("value", "/plot debugexec analyze <threshold>")
); );
player.sendMessage(TranslatableCaption.of("debugexec.threshold_default")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.threshold_default"));
return false; return false;
} }
double threshold; double threshold;
@ -132,14 +132,14 @@ public class DebugExec extends SubCommand {
threshold = Integer.parseInt(args[1]) / 100d; threshold = Integer.parseInt(args[1]) / 100d;
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugexec.invalid_threshold"), TranslatableCaption.miniMessage("debugexec.invalid_threshold"),
Template.of("value", args[1]) Placeholder.miniMessage("value", args[1])
); );
player.sendMessage(TranslatableCaption.of("debugexec.threshold_default_double")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.threshold_default_double"));
return false; return false;
} }
PlotAnalysis.calcOptimalModifiers( PlotAnalysis.calcOptimalModifiers(
() -> player.sendMessage(TranslatableCaption.of("debugexec.calibration_done")), () -> player.sendMessage(TranslatableCaption.miniMessage("debugexec.calibration_done")),
threshold threshold
); );
return true; return true;
@ -149,25 +149,25 @@ public class DebugExec extends SubCommand {
ExpireManager.IMP = new ExpireManager(this.eventDispatcher); ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
} }
if (ExpireManager.IMP.runAutomatedTask()) { if (ExpireManager.IMP.runAutomatedTask()) {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_started")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.expiry_started"));
} else { } else {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.expiry_already_started"));
} }
return true; return true;
} }
case "stop-expire" -> { case "stop-expire" -> {
if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) { if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
player.sendMessage(TranslatableCaption.of("debugexec.task_halted")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_halted"));
} else { } else {
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_cancelled"));
} }
return true; return true;
} }
case "remove-flag" -> { case "remove-flag" -> {
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot debugexec remove-flag <flag>") Placeholder.miniMessage("value", "/plot debugexec remove-flag <flag>")
); );
return false; return false;
} }
@ -184,24 +184,24 @@ public class DebugExec extends SubCommand {
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugexec.cleared_flag"), TranslatableCaption.miniMessage("debugexec.cleared_flag"),
Template.of("value", flag) Placeholder.miniMessage("value", flag)
); );
return true; return true;
} }
case "start-rgar" -> { case "start-rgar" -> {
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Invalid syntax: /plot debugexec start-rgar <world>") Placeholder.miniMessage("value", "Invalid syntax: /plot debugexec start-rgar <world>")
); );
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"), TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Template.of("value", args[1]) Placeholder.miniMessage("value", args[1])
); );
return false; return false;
} }
@ -212,23 +212,23 @@ public class DebugExec extends SubCommand {
result = this.hybridUtils.scheduleRoadUpdate(area, 0); result = this.hybridUtils.scheduleRoadUpdate(area, 0);
} }
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.mass_schematic_update_in_progress"));
return false; return false;
} }
return true; return true;
} }
case "stop-rgar" -> { case "stop-rgar" -> {
if (!HybridUtils.UPDATE) { if (!HybridUtils.UPDATE) {
player.sendMessage(TranslatableCaption.of("debugexec.task_not_running")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_not_running"));
return false; return false;
} }
HybridUtils.UPDATE = false; HybridUtils.UPDATE = false;
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_cancelled"));
return true; return true;
} }
} }
} }
player.sendMessage(StaticCaption.of("<prefix><gold>Possible sub commands: </gold><gray>/plot debugexec <" player.sendMessage(StaticCaption.miniMessage("<prefix><gold>Possible sub commands: </gold><gray>/plot debugexec <"
+ StringMan.join(allowedParams, " | ") + "></gray>")); + StringMan.join(allowedParams, " | ") + "></gray>"));
return false; return false;
} }

View File

@ -70,14 +70,14 @@ public class DebugImportWorlds extends Command {
) throws CommandException { ) throws CommandException {
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8)) // UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
if (!(this.plotAreaManager instanceof SinglePlotAreaManager)) { if (!(this.plotAreaManager instanceof SinglePlotAreaManager)) {
player.sendMessage(TranslatableCaption.of("debugimportworlds.single_plot_area")); player.sendMessage(TranslatableCaption.miniMessage("debugimportworlds.single_plot_area"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea(); SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
PlotId id = PlotId.of(0, 0); PlotId id = PlotId.of(0, 0);
File container = PlotSquared.platform().worldContainer(); File container = PlotSquared.platform().worldContainer();
if (container.equals(new File("."))) { if (container.equals(new File("."))) {
player.sendMessage(TranslatableCaption.of("debugimportworlds.world_container")); player.sendMessage(TranslatableCaption.miniMessage("debugimportworlds.world_container"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
for (File folder : container.listFiles()) { for (File folder : container.listFiles()) {
@ -87,7 +87,7 @@ public class DebugImportWorlds extends Command {
if (name.length() > 16) { if (name.length() > 16) {
uuid = UUID.fromString(name); uuid = UUID.fromString(name);
} else { } else {
player.sendMessage(TranslatableCaption.of("players.fetching_player")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_player"));
uuid = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(name, 60000L); uuid = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(name, 60000L);
} }
if (uuid == null) { if (uuid == null) {
@ -103,7 +103,7 @@ public class DebugImportWorlds extends Command {
} }
} }
} }
player.sendMessage(TranslatableCaption.of("players.done")); player.sendMessage(TranslatableCaption.miniMessage("players.done"));
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.inject.annotations.WorldFile;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.PremiumVerification; import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File; import java.io.File;
@ -132,9 +132,9 @@ public class DebugPaste extends SubCommand {
.addFile(logFile); .addFile(logFile);
} catch (IOException ignored) { } catch (IOException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.latest_log"), TranslatableCaption.miniMessage("debugpaste.latest_log"),
Template.of("file", "latest.log"), Placeholder.miniMessage("file", "latest.log"),
Template.of("size", "14MB") Placeholder.miniMessage("size", "14MB")
); );
} }
@ -142,16 +142,16 @@ public class DebugPaste extends SubCommand {
incendoPaster.addFile(this.configFile); incendoPaster.addFile(this.configFile);
} catch (final IllegalArgumentException ignored) { } catch (final IllegalArgumentException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.empty_file"), TranslatableCaption.miniMessage("debugpaste.empty_file"),
Template.of("file", "settings.yml") Placeholder.miniMessage("file", "settings.yml")
); );
} }
try { try {
incendoPaster.addFile(this.worldfile); incendoPaster.addFile(this.worldfile);
} catch (final IllegalArgumentException ignored) { } catch (final IllegalArgumentException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.empty_file"), TranslatableCaption.miniMessage("debugpaste.empty_file"),
Template.of("file", "worlds.yml") Placeholder.miniMessage("file", "worlds.yml")
); );
} }
@ -163,8 +163,8 @@ public class DebugPaste extends SubCommand {
incendoPaster.addFile(MultiverseWorlds, "Multiverse-Core/worlds.yml"); incendoPaster.addFile(MultiverseWorlds, "Multiverse-Core/worlds.yml");
} catch (final IOException ignored) { } catch (final IOException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.skip_multiverse"), TranslatableCaption.miniMessage("debugpaste.skip_multiverse"),
Template.of("file", "worlds.yml") Placeholder.miniMessage("file", "worlds.yml")
); );
} }
@ -178,21 +178,21 @@ public class DebugPaste extends SubCommand {
final String link = final String link =
String.format("https://athion.net/ISPaster/paste/view/%s", pasteId); String.format("https://athion.net/ISPaster/paste/view/%s", pasteId);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.debug_report_created"), TranslatableCaption.miniMessage("debugpaste.debug_report_created"),
Template.of("url", link) Placeholder.miniMessage("url", link)
); );
} else { } else {
final String responseMessage = jsonObject.get("response").getAsString(); final String responseMessage = jsonObject.get("response").getAsString();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.creation_failed"), TranslatableCaption.miniMessage("debugpaste.creation_failed"),
Template.of("value", responseMessage) Placeholder.miniMessage("value", responseMessage)
); );
} }
} catch (final Throwable throwable) { } catch (final Throwable throwable) {
throwable.printStackTrace(); throwable.printStackTrace();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugpaste.creation_failed"), TranslatableCaption.miniMessage("debugpaste.creation_failed"),
Template.of("value", throwable.getMessage()) Placeholder.miniMessage("value", throwable.getMessage())
); );
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -35,7 +35,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.queue.QueueCoordinator; import com.plotsquared.core.queue.QueueCoordinator;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Arrays; import java.util.Arrays;
@ -66,16 +66,16 @@ public class DebugRoadRegen extends SubCommand {
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (args.length < 1) { if (args.length < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE) Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
); );
return false; return false;
} }
PlotArea area = player.getPlotAreaAbs(); PlotArea area = player.getPlotAreaAbs();
check(area, TranslatableCaption.of("errors.not_in_plot_world")); check(area, TranslatableCaption.miniMessage("errors.not_in_plot_world"));
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
String kind = args[0].toLowerCase(); String kind = args[0].toLowerCase();
@ -86,8 +86,8 @@ public class DebugRoadRegen extends SubCommand {
return regenRegion(player, Arrays.copyOfRange(args, 1, args.length)); return regenRegion(player, Arrays.copyOfRange(args, 1, args.length));
default: default:
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE) Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
); );
return false; return false;
} }
@ -97,24 +97,24 @@ public class DebugRoadRegen extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (plot.isMerged()) { } else if (plot.isMerged()) {
player.sendMessage(TranslatableCaption.of("debug.requires_unmerged")); player.sendMessage(TranslatableCaption.miniMessage("debug.requires_unmerged"));
} else { } else {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
QueueCoordinator queue = area.getQueue(); QueueCoordinator queue = area.getQueue();
queue.setCompleteTask(() -> { queue.setCompleteTask(() -> {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugroadregen.regen_done"), TranslatableCaption.miniMessage("debugroadregen.regen_done"),
Template.of("value", plot.getId().toString()) Placeholder.miniMessage("value", plot.getId().toString())
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugroadregen.regen_all"), TranslatableCaption.miniMessage("debugroadregen.regen_all"),
Template.of("value", "/plot regenallroads") Placeholder.miniMessage("value", "/plot regenallroads")
); );
}); });
manager.createRoadEast(plot, queue); manager.createRoadEast(plot, queue);
@ -132,19 +132,19 @@ public class DebugRoadRegen extends SubCommand {
height = Integer.parseInt(args[0]); height = Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"), TranslatableCaption.miniMessage("invalid.not_valid_number"),
Template.of("value", "0, 256") Placeholder.miniMessage("value", "0, 256")
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE) Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
); );
return false; return false;
} }
} else if (args.length != 0) { } else if (args.length != 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE) Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
); );
return false; return false;
} }
@ -152,25 +152,25 @@ public class DebugRoadRegen extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
} }
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) { if (!(manager instanceof HybridPlotManager)) {
player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_plot_world"));
return true; return true;
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugroadregen.schematic"), TranslatableCaption.miniMessage("debugroadregen.schematic"),
Template.of("command", "/plot createroadschematic") Placeholder.miniMessage("command", "/plot createroadschematic")
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugroadregen.regenallroads"), TranslatableCaption.miniMessage("debugroadregen.regenallroads"),
Template.of("command", "/plot regenallroads") Placeholder.miniMessage("command", "/plot regenallroads")
); );
boolean result = this.hybridUtils.scheduleSingleRegionRoadUpdate(plot, height); boolean result = this.hybridUtils.scheduleSingleRegionRoadUpdate(plot, height);
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.mass_schematic_update_in_progress"));
return false; return false;
} }
return true; return true;

View File

@ -43,10 +43,10 @@ public class DebugSaveTest extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
final List<Plot> plots = PlotQuery.newQuery().allPlots().asList(); final List<Plot> plots = PlotQuery.newQuery().allPlots().asList();
player.sendMessage(TranslatableCaption.of("debugsavetest.starting")); player.sendMessage(TranslatableCaption.miniMessage("debugsavetest.starting"));
DBFunc.createPlotsAndData( DBFunc.createPlotsAndData(
plots, plots,
() -> player.sendMessage(TranslatableCaption.of("debugsavetest.done")) () -> player.sendMessage(TranslatableCaption.miniMessage("debugsavetest.done"))
); );
return true; return true;
} }

View File

@ -40,7 +40,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -70,29 +70,29 @@ public class Delete extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
Result eventResult = this.eventDispatcher.callDelete(plot).getEventResult(); Result eventResult = this.eventDispatcher.callDelete(plot).getEventResult();
if (eventResult == Result.DENY) { if (eventResult == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Delete") Placeholder.miniMessage("value", "Delete")
); );
return true; return true;
} }
boolean force = eventResult == Result.FORCE; boolean force = eventResult == Result.FORCE;
if (!force && !plot.isOwner(player.getUUID()) && !Permissions if (!force && !plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DELETE)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DELETE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
final PlotArea plotArea = plot.getArea(); final PlotArea plotArea = plot.getArea();
@ -102,7 +102,7 @@ public class Delete extends SubCommand {
player.getPlotCount(location.getWorldName()); player.getPlotCount(location.getWorldName());
Runnable run = () -> { Runnable run = () -> {
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return; return;
} }
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
@ -120,21 +120,22 @@ public class Delete extends SubCommand {
if (value > 0d) { if (value > 0d) {
this.econHandler.depositMoney(player, value); this.econHandler.depositMoney(player, value);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.added_balance"), TranslatableCaption.miniMessage("economy.added_balance"),
Template.of("money", this.econHandler.format(value)) Placeholder.miniMessage("money", this.econHandler.format(value))
); );
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("working.deleting_done"), TranslatableCaption.miniMessage("working.deleting_done"),
Template.of("amount", String.valueOf(System.currentTimeMillis() - start)), Placeholder.miniMessage("amount", String.valueOf(System.currentTimeMillis() - start)),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
eventDispatcher.callPostDelete(plot);
}); });
if (result) { if (result) {
plot.addRunning(); plot.addRunning();
} else { } else {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
} }
}; };
if (hasConfirmation(player)) { if (hasConfirmation(player)) {

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -52,7 +52,7 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "deny", @CommandDeclaration(command = "deny",
aliases = {"d", "ban"}, aliases = {"d", "ban"},
usage = "/plot deny <player", usage = "/plot deny <player>",
category = CommandCategory.SETTINGS, category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER) requiredType = RequiredType.PLAYER)
public class Deny extends SubCommand { public class Deny extends SubCommand {
@ -79,36 +79,36 @@ public class Deny extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return true; return true;
} }
int maxDenySize = Permissions.hasPermissionRange(player, Permission.PERMISSION_DENY, Settings.Limit.MAX_PLOTS); int maxDenySize = Permissions.hasPermissionRange(player, Permission.PERMISSION_DENY, Settings.Limit.MAX_PLOTS);
int size = plot.getDenied().size(); int size = plot.getDenied().size();
if (size > (maxDenySize - 1)) { if (size >= maxDenySize) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("members.plot_max_members_denied"), TranslatableCaption.miniMessage("members.plot_max_members_denied"),
Template.of("amount", String.valueOf(size)) Placeholder.miniMessage("amount", String.valueOf(size))
); );
return false; return false;
} }
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> { PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.isEmpty()) { } else if (throwable != null || uuids.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
} else { } else {
for (UUID uuid : uuids) { for (UUID uuid : uuids) {
@ -116,16 +116,16 @@ public class Deny extends SubCommand {
Permissions.hasPermission(player, Permission.PERMISSION_DENY_EVERYONE) || Permissions Permissions.hasPermission(player, Permission.PERMISSION_DENY_EVERYONE) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY))) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY))) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
} else if (plot.isOwner(uuid)) { } else if (plot.isOwner(uuid)) {
player.sendMessage(TranslatableCaption.of("deny.cant_remove_owner")); player.sendMessage(TranslatableCaption.miniMessage("deny.cant_remove_owner"));
return; return;
} else if (plot.getDenied().contains(uuid)) { } else if (plot.getDenied().contains(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("member.already_added"), TranslatableCaption.miniMessage("member.already_added"),
Template.of("player", PlayerManager.getName(uuid)) Placeholder.miniMessage("player", PlayerManager.getName(uuid))
); );
return; return;
} else { } else {
@ -148,7 +148,7 @@ public class Deny extends SubCommand {
} }
} }
} }
player.sendMessage(TranslatableCaption.of("deny.denied_added")); player.sendMessage(TranslatableCaption.miniMessage("deny.denied_added"));
} }
}); });
@ -157,7 +157,7 @@ public class Deny extends SubCommand {
@Override @Override
public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) { public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
private void handleKick(PlotPlayer<?> player, Plot plot) { private void handleKick(PlotPlayer<?> player, Plot plot) {
@ -175,7 +175,7 @@ public class Deny extends SubCommand {
} }
Location location = player.getLocation(); Location location = player.getLocation();
Location spawn = this.worldUtil.getSpawn(location.getWorldName()); Location spawn = this.worldUtil.getSpawn(location.getWorldName());
player.sendMessage(TranslatableCaption.of("deny.you_got_denied")); player.sendMessage(TranslatableCaption.miniMessage("deny.you_got_denied"));
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]); Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
if (plot.equals(newSpawn.getPlot())) { if (plot.equals(newSpawn.getPlot())) {

View File

@ -34,7 +34,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag; import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "setdescription", @CommandDeclaration(command = "setdescription",
@ -60,13 +60,13 @@ public class Desc extends SetCommand {
.getFlag(DescriptionFlag.class), plot); .getFlag(DescriptionFlag.class), plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Description removal") Placeholder.miniMessage("value", "Description removal")
); );
return false; return false;
} }
plot.removeFlag(event.getFlag()); plot.removeFlag(event.getFlag());
player.sendMessage(TranslatableCaption.of("desc.desc_unset")); player.sendMessage(TranslatableCaption.miniMessage("desc.desc_unset"));
return true; return true;
} }
PlotFlagAddEvent event = this.eventDispatcher.callFlagAdd(plot PlotFlagAddEvent event = this.eventDispatcher.callFlagAdd(plot
@ -75,17 +75,17 @@ public class Desc extends SetCommand {
.createFlagInstance(desc), plot); .createFlagInstance(desc), plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Description set") Placeholder.miniMessage("value", "Description set")
); );
return false; return false;
} }
boolean result = plot.setFlag(event.getFlag()); boolean result = plot.setFlag(event.getFlag());
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_added")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_added"));
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("desc.desc_set")); player.sendMessage(TranslatableCaption.miniMessage("desc.desc_set"));
return true; return true;
} }

View File

@ -70,11 +70,11 @@ public class Dislike extends SubCommand {
.map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "done", @CommandDeclaration(command = "done",
@ -70,35 +70,35 @@ public class Done extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if ((plot == null) || !plot.hasOwner()) { if ((plot == null) || !plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
PlotDoneEvent event = this.eventDispatcher.callDone(plot); PlotDoneEvent event = this.eventDispatcher.callDone(plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Done") Placeholder.miniMessage("value", "Done")
); );
return true; return true;
} }
boolean force = event.getEventResult() == Result.FORCE; boolean force = event.getEventResult() == Result.FORCE;
if (!force && !plot.isOwner(player.getUUID()) && !Permissions if (!force && !plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DONE)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DONE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (DoneFlag.isDone(plot)) { if (DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("done.done_already_done")); player.sendMessage(TranslatableCaption.miniMessage("done.done_already_done"));
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
plot.addRunning(); plot.addRunning();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.generating_link"), TranslatableCaption.miniMessage("web.generating_link"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done"); final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done");
if (ExpireManager.IMP == null || doneRequirements == null) { if (ExpireManager.IMP == null || doneRequirements == null) {
@ -120,7 +120,7 @@ public class Done extends SubCommand {
private void finish(Plot plot, PlotPlayer<?> player, boolean success) { private void finish(Plot plot, PlotPlayer<?> player, boolean success) {
if (!success) { if (!success) {
player.sendMessage(TranslatableCaption.of("done.done_insufficient_complexity")); player.sendMessage(TranslatableCaption.miniMessage("done.done_insufficient_complexity"));
return; return;
} }
long flagValue = System.currentTimeMillis() / 1000; long flagValue = System.currentTimeMillis() / 1000;
@ -128,11 +128,11 @@ public class Done extends SubCommand {
.createFlagInstance(Long.toString(flagValue)); .createFlagInstance(Long.toString(flagValue));
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage(TranslatableCaption.of("events.event_denied")); player.sendMessage(TranslatableCaption.miniMessage("events.event_denied"));
return; return;
} }
plot.setFlag(plotFlag); plot.setFlag(plotFlag);
player.sendMessage(TranslatableCaption.of("done.done_success")); player.sendMessage(TranslatableCaption.miniMessage("done.done_success"));
} }
} }

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.URL; import java.net.URL;
@ -82,36 +82,36 @@ public class Download extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
String world = player.getLocation().getWorldName(); String world = player.getLocation().getWorldName();
if (!this.plotAreaManager.hasPlotArea(world)) { if (!this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) && !Permissions if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
player.sendMessage(TranslatableCaption.of("done.done_not_done")); player.sendMessage(TranslatableCaption.miniMessage("done.done_not_done"));
return false; return false;
} }
if ((!plot.isOwner(player.getUUID())) && !Permissions if ((!plot.isOwner(player.getUUID())) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN.toString())) { .hasPermission(player, Permission.PERMISSION_ADMIN.toString())) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
if (args.length == 0 || (args.length == 1 && StringMan if (args.length == 0 || (args.length == 1 && StringMan
.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) { .isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
plot.addRunning(); plot.addRunning();
@ -120,12 +120,12 @@ public class Download extends SubCommand {
.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) { .isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD_WORLD)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD_WORLD)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_DOWNLOAD_WORLD.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_DOWNLOAD_WORLD.toString())
); );
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("schematics.mca_file_size")); player.sendMessage(TranslatableCaption.miniMessage("schematics.mca_file_size"));
plot.addRunning(); plot.addRunning();
this.worldUtil.saveWorld(world); this.worldUtil.saveWorld(world);
this.worldUtil.upload(plot, null, null, new RunnableVal<>() { this.worldUtil.upload(plot, null, null, new RunnableVal<>() {
@ -134,19 +134,19 @@ public class Download extends SubCommand {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.generating_link_failed"), TranslatableCaption.miniMessage("web.generating_link_failed"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
return; return;
} }
player.sendMessage(TranslatableCaption.of("web.generation_link_success_legacy_world"), Template.of("url", url.toString())); player.sendMessage(TranslatableCaption.miniMessage("web.generation_link_success_legacy_world"), Placeholder.miniMessage("url", url.toString()));
} }
}); });
} else { } else {
sendUsage(player); sendUsage(player);
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("web.generating_link"), Template.of("plot", plot.getId().toString())); player.sendMessage(TranslatableCaption.miniMessage("web.generating_link"), Placeholder.miniMessage("plot", plot.getId().toString()));
return true; return true;
} }
@ -173,11 +173,11 @@ public class Download extends SubCommand {
) { ) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
private void upload(PlotPlayer<?> player, Plot plot) { private void upload(PlotPlayer<?> player, Plot plot) {
@ -189,11 +189,11 @@ public class Download extends SubCommand {
@Override @Override
public void run(URL value) { public void run(URL value) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.generation_link_success"), TranslatableCaption.miniMessage("web.generation_link_success"),
Template.of("download", value.toString()), Placeholder.miniMessage("download", value.toString()),
Template.of("delete", "Not available") Placeholder.miniMessage("delete", "Not available")
); );
player.sendMessage(StaticCaption.of(value.toString())); player.sendMessage(StaticCaption.miniMessage(value.toString()));
} }
}); });
}); });
@ -204,14 +204,14 @@ public class Download extends SubCommand {
.whenComplete((result, throwable) -> { .whenComplete((result, throwable) -> {
if (throwable != null || !result.isSuccess()) { if (throwable != null || !result.isSuccess()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.generating_link_failed"), TranslatableCaption.miniMessage("web.generating_link_failed"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.generation_link_success"), TranslatableCaption.miniMessage("web.generation_link_success"),
Template.of("download", result.getDownloadUrl()), Placeholder.miniMessage("download", result.getDownloadUrl()),
Template.of("delete", result.getDeletionUrl()) Placeholder.miniMessage("delete", result.getDeletionUrl())
); );
} }
}); });

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.CaptionUtility; import com.plotsquared.core.configuration.caption.CaptionUtility;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -53,7 +53,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -85,8 +86,8 @@ public final class FlagCommand extends Command {
private static boolean sendMessage(PlotPlayer<?> player) { private static boolean sendMessage(PlotPlayer<?> player) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot flag <set | remove | add | list | info> <flag> <value>") Placeholder.miniMessage("value", "/plot flag <set | remove | add | list | info> <flag> <value>")
); );
return true; return true;
} }
@ -111,8 +112,8 @@ public final class FlagCommand extends Command {
} }
if (!result) { if (!result) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of( Placeholder.miniMessage(
"node", "node",
perm perm
) )
@ -131,16 +132,16 @@ public final class FlagCommand extends Command {
); );
final boolean result = Permissions.hasPermission(player, permission); final boolean result = Permissions.hasPermission(player, permission);
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", permission)); player.sendMessage(TranslatableCaption.miniMessage("permission.no_permission"), Placeholder.miniMessage("node", permission));
return false; return false;
} }
} }
} catch (final FlagParseException e) { } catch (final FlagParseException e) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"), TranslatableCaption.miniMessage("flag.flag_parse_error"),
Template.of("flag_name", flag.getName()), Placeholder.miniMessage("flag_name", flag.getName()),
Template.of("flag_value", e.getValue()), Placeholder.miniMessage("flag_value", e.getValue()),
Template.of("error", e.getErrorMessage().getComponent(player)) Placeholder.miniMessage("error", e.getErrorMessage().getComponent(player))
); );
return false; return false;
} catch (final Exception e) { } catch (final Exception e) {
@ -157,7 +158,7 @@ public final class FlagCommand extends Command {
perm = basePerm; perm = basePerm;
} }
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", perm)); player.sendMessage(TranslatableCaption.miniMessage("permission.no_permission"), Placeholder.miniMessage("node", perm));
} }
return result; return result;
} }
@ -171,18 +172,18 @@ public final class FlagCommand extends Command {
final Location location = player.getLocation(); final Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_SET_FLAG_OTHER)) { .hasPermission(player, Permission.PERMISSION_SET_FLAG_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SET_FLAG_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SET_FLAG_OTHER))
); );
return false; return false;
} }
@ -216,14 +217,14 @@ public final class FlagCommand extends Command {
final String best = stringComparison.getBestMatch(); final String best = stringComparison.getBestMatch();
if (best != null) { if (best != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.not_valid_flag_suggested"), TranslatableCaption.miniMessage("flag.not_valid_flag_suggested"),
Template.of("value", best) Placeholder.miniMessage("value", best)
); );
suggested = true; suggested = true;
} }
} catch (final Exception ignored) { /* Happens sometimes because of mean code */ } } catch (final Exception ignored) { /* Happens sometimes because of mean code */ }
if (!suggested) { if (!suggested) {
player.sendMessage(TranslatableCaption.of("flag.not_valid_flag")); player.sendMessage(TranslatableCaption.miniMessage("flag.not_valid_flag"));
} }
return null; return null;
} }
@ -325,8 +326,8 @@ public final class FlagCommand extends Command {
} }
if (args.length < 2) { if (args.length < 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot flag set <flag> <value>") Placeholder.component("value", Component.text("/plot flag set <flag> <value>"))
); );
return; return;
} }
@ -338,8 +339,8 @@ public final class FlagCommand extends Command {
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Flag set") Placeholder.miniMessage("value", "Flag set")
); );
return; return;
} }
@ -354,16 +355,16 @@ public final class FlagCommand extends Command {
parsed = plotFlag.parse(value); parsed = plotFlag.parse(value);
} catch (final FlagParseException e) { } catch (final FlagParseException e) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"), TranslatableCaption.miniMessage("flag.flag_parse_error"),
Template.of("flag_name", plotFlag.getName()), Placeholder.miniMessage("flag_name", plotFlag.getName()),
Template.of("flag_value", e.getValue()), Placeholder.miniMessage("flag_value", e.getValue()),
Template.of("error", e.getErrorMessage().getComponent(player)) Placeholder.miniMessage("error", e.getErrorMessage().getComponent(player))
); );
return; return;
} }
plot.setFlag(parsed); plot.setFlag(parsed);
player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(args[0])), player.sendMessage(TranslatableCaption.miniMessage("flag.flag_added"), Placeholder.miniMessage("flag", String.valueOf(args[0])),
Template.of("value", String.valueOf(parsed)) Placeholder.miniMessage("value", String.valueOf(parsed))
); );
} }
@ -383,8 +384,8 @@ public final class FlagCommand extends Command {
} }
if (args.length < 2) { if (args.length < 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot flag add <flag> <values>") Placeholder.miniMessage("value", "/plot flag add <flag> <values>")
); );
return; return;
} }
@ -396,8 +397,8 @@ public final class FlagCommand extends Command {
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Flag add") Placeholder.miniMessage("value", "Flag add")
); );
return; return;
} }
@ -417,21 +418,21 @@ public final class FlagCommand extends Command {
parsed = event.getFlag().parse(value); parsed = event.getFlag().parse(value);
} catch (FlagParseException e) { } catch (FlagParseException e) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"), TranslatableCaption.miniMessage("flag.flag_parse_error"),
Template.of("flag_name", plotFlag.getName()), Placeholder.miniMessage("flag_name", plotFlag.getName()),
Template.of("flag_value", e.getValue()), Placeholder.miniMessage("flag_value", e.getValue()),
Template.of("error", e.getErrorMessage().getComponent(player)) Placeholder.miniMessage("error", e.getErrorMessage().getComponent(player))
); );
return; return;
} }
boolean result = boolean result =
player.getLocation().getPlotAbs().setFlag(localFlag.merge(parsed.getValue())); player.getLocation().getPlotAbs().setFlag(localFlag.merge(parsed.getValue()));
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_added")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_added"));
return; return;
} }
player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(args[0])), player.sendMessage(TranslatableCaption.miniMessage("flag.flag_added"), Placeholder.miniMessage("flag", String.valueOf(args[0])),
Template.of("value", String.valueOf(parsed)) Placeholder.miniMessage("value", String.valueOf(parsed))
); );
} }
@ -451,8 +452,8 @@ public final class FlagCommand extends Command {
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot flag remove <flag> [values]") Placeholder.miniMessage("value", "/plot flag remove <flag> [values]")
); );
return; return;
} }
@ -464,8 +465,8 @@ public final class FlagCommand extends Command {
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot); PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Flag remove") Placeholder.miniMessage("value", "Flag remove")
); );
return; return;
} }
@ -474,8 +475,8 @@ public final class FlagCommand extends Command {
if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))) { if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))) {
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase())) Placeholder.miniMessage("node", Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))
); );
return; return;
} }
@ -489,27 +490,27 @@ public final class FlagCommand extends Command {
parsedFlag = listFlag.parse(value); parsedFlag = listFlag.parse(value);
} catch (final FlagParseException e) { } catch (final FlagParseException e) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"), TranslatableCaption.miniMessage("flag.flag_parse_error"),
Template.of("flag_name", flag.getName()), Placeholder.miniMessage("flag_name", flag.getName()),
Template.of("flag_value", e.getValue()), Placeholder.miniMessage("flag_value", e.getValue()),
Template.of("error", String.valueOf(e.getErrorMessage())) Placeholder.miniMessage("error", String.valueOf(e.getErrorMessage()))
); );
return; return;
} }
if (((List<?>) parsedFlag.getValue()).isEmpty()) { if (((List<?>) parsedFlag.getValue()).isEmpty()) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return; return;
} }
if (list.removeAll((List) parsedFlag.getValue())) { if (list.removeAll((List) parsedFlag.getValue())) {
if (list.isEmpty()) { if (list.isEmpty()) {
if (plot.removeFlag(flag)) { if (plot.removeFlag(flag)) {
player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", args[0]), Template.of( player.sendMessage(TranslatableCaption.miniMessage("flag.flag_removed"), Placeholder.miniMessage("flag", args[0]), Placeholder.miniMessage(
"value", "value",
String.valueOf(flag) String.valueOf(flag)
)); ));
return; return;
} else { } else {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return; return;
} }
} else { } else {
@ -517,31 +518,31 @@ public final class FlagCommand extends Command {
PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot);
if (addEvent.getEventResult() == Result.DENY) { if (addEvent.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Re-addition of " + plotFlag.getName()) Placeholder.miniMessage("value", "Re-addition of " + plotFlag.getName())
); );
return; return;
} }
if (plot.setFlag(addEvent.getFlag())) { if (plot.setFlag(addEvent.getFlag())) {
player.sendMessage(TranslatableCaption.of("flag.flag_partially_removed")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_partially_removed"));
return; return;
} else { } else {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return; return;
} }
} }
} else { } else {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return; return;
} }
} else { } else {
boolean result = plot.removeFlag(flag); boolean result = plot.removeFlag(flag);
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return; return;
} }
} }
player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", args[0]), Template.of( player.sendMessage(TranslatableCaption.miniMessage("flag.flag_removed"), Placeholder.miniMessage("flag", args[0]), Placeholder.miniMessage(
"value", "value",
String.valueOf(flag) String.valueOf(flag)
)); ));
@ -576,23 +577,25 @@ public final class FlagCommand extends Command {
for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) { for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
Collections.sort(entry.getValue()); Collections.sort(entry.getValue());
Component category = Component category =
MINI_MESSAGE.parse( MINI_MESSAGE.deserialize(
TranslatableCaption.of("flag.flag_list_categories").getComponent(player), TranslatableCaption.miniMessage("flag.flag_list_categories").getComponent(player),
Template.of("category", entry.getKey()) PlaceholderResolver.placeholders(Placeholder.miniMessage("category", entry.getKey()))
); );
TextComponent.Builder builder = Component.text().append(category); TextComponent.Builder builder = Component.text().append(category);
final Iterator<String> flagIterator = entry.getValue().iterator(); final Iterator<String> flagIterator = entry.getValue().iterator();
while (flagIterator.hasNext()) { while (flagIterator.hasNext()) {
final String flag = flagIterator.next(); final String flag = flagIterator.next();
builder.append(MINI_MESSAGE builder.append(MINI_MESSAGE
.parse( .deserialize(
TranslatableCaption.of("flag.flag_list_flag").getComponent(player), TranslatableCaption.miniMessage("flag.flag_list_flag").getComponent(player),
Template.of("command", "/plot flag info " + flag), PlaceholderResolver.placeholders(
Template.of("flag", flag), Placeholder.miniMessage("command", "/plot flag info " + flag),
Template.of("suffix", flagIterator.hasNext() ? ", " : "") Placeholder.miniMessage("flag", flag),
Placeholder.miniMessage("suffix", flagIterator.hasNext() ? ", " : "")
)
)); ));
} }
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(builder.build())));
} }
} }
@ -612,41 +615,41 @@ public final class FlagCommand extends Command {
} }
if (args.length < 1) { if (args.length < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot flag info <flag>") Placeholder.miniMessage("value", "/plot flag info <flag>")
); );
return; return;
} }
final PlotFlag<?, ?> plotFlag = getFlag(player, args[0]); final PlotFlag<?, ?> plotFlag = getFlag(player, args[0]);
if (plotFlag != null) { if (plotFlag != null) {
player.sendMessage(TranslatableCaption.of("flag.flag_info_header")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_header"));
// Flag name // Flag name
player.sendMessage(TranslatableCaption.of("flag.flag_info_name"), Template.of("flag", plotFlag.getName())); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_name"), Placeholder.miniMessage("flag", plotFlag.getName()));
// Flag category // Flag category
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_info_category"), TranslatableCaption.miniMessage("flag.flag_info_category"),
Templates.of(player, "value", plotFlag.getFlagCategory()) Placeholder.component("value", MINI_MESSAGE.parse(plotFlag.getFlagCategory().getComponent(player)))
); );
// Flag description // Flag description
// TODO maybe merge and \n instead? // TODO maybe merge and \n instead?
player.sendMessage(TranslatableCaption.of("flag.flag_info_description")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_description"));
player.sendMessage(plotFlag.getFlagDescription()); player.sendMessage(plotFlag.getFlagDescription());
// Flag example // Flag example
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_info_example"), TranslatableCaption.miniMessage("flag.flag_info_example"),
Template.of("command", "/plot flag set"), Placeholder.miniMessage("command", "/plot flag set"),
Template.of("flag", plotFlag.getName()), Placeholder.miniMessage("flag", plotFlag.getName()),
Template.of("value", plotFlag.getExample()) Placeholder.miniMessage("value", plotFlag.getExample())
); );
// Default value // Default value
final String defaultValue = player.getLocation().getPlotArea().getFlagContainer() final String defaultValue = player.getLocation().getPlotArea().getFlagContainer()
.getFlagErased(plotFlag.getClass()).toString(); .getFlagErased(plotFlag.getClass()).toString();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("flag.flag_info_default_value"), TranslatableCaption.miniMessage("flag.flag_info_default_value"),
Template.of("value", defaultValue) Placeholder.miniMessage("value", defaultValue)
); );
// Footer. Done this way to prevent the duplicate-message-thingy from catching it // Footer. Done this way to prevent the duplicate-message-thingy from catching it
player.sendMessage(TranslatableCaption.of("flag.flag_info_footer")); player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_footer"));
} }
} }

View File

@ -40,7 +40,7 @@ import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -70,16 +70,16 @@ public class Grant extends Command {
) throws CommandException { ) throws CommandException {
checkTrue( checkTrue(
args.length >= 1 && args.length <= 2, args.length >= 1 && args.length <= 2,
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot grant <check | add> [player]") Placeholder.miniMessage("value", "/plot grant <check | add> [player]")
); );
final String arg0 = args[0].toLowerCase(); final String arg0 = args[0].toLowerCase();
switch (arg0) { switch (arg0) {
case "add", "check" -> { case "add", "check" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_GRANT.format(arg0))) { if (!Permissions.hasPermission(player, Permission.PERMISSION_GRANT.format(arg0))) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_GRANT.format(arg0)) Placeholder.miniMessage("node", Permission.PERMISSION_GRANT.format(arg0))
); );
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -88,11 +88,11 @@ public class Grant extends Command {
} }
PlayerManager.getUUIDsFromString(args[1], (uuids, throwable) -> { PlayerManager.getUUIDsFromString(args[1], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.size() != 1) { } else if (throwable != null || uuids.size() != 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", String.valueOf(uuids)) Placeholder.miniMessage("value", String.valueOf(uuids))
); );
} else { } else {
final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0]; final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0];
@ -102,8 +102,8 @@ public class Grant extends Command {
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) { PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
if (args[0].equalsIgnoreCase("check")) { if (args[0].equalsIgnoreCase("check")) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("grants.granted_plots"), TranslatableCaption.miniMessage("grants.granted_plots"),
Template.of("amount", String.valueOf(access.get().orElse(0))) Placeholder.miniMessage("amount", String.valueOf(access.get().orElse(0)))
); );
} else { } else {
access.set(access.get().orElse(0) + 1); access.set(access.get().orElse(0) + 1);
@ -122,8 +122,8 @@ public class Grant extends Command {
granted = Ints.fromByteArray(array); granted = Ints.fromByteArray(array);
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("grants.granted_plots"), TranslatableCaption.miniMessage("grants.granted_plots"),
Template.of("amount", String.valueOf(granted)) Placeholder.miniMessage("amount", String.valueOf(granted))
); );
} else { // add } else { // add
int amount; int amount;
@ -137,8 +137,8 @@ public class Grant extends Command {
byte[] rawData = Ints.toByteArray(amount); byte[] rawData = Ints.toByteArray(amount);
DBFunc.addPersistentMeta(uuid.getUuid(), key, rawData, replace); DBFunc.addPersistentMeta(uuid.getUuid(), key, rawData, replace);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("grants.added"), TranslatableCaption.miniMessage("grants.added"),
Template.of("grants", String.valueOf(amount)) Placeholder.miniMessage("grants", String.valueOf(amount))
); );
} }
} }
@ -176,11 +176,11 @@ public class Grant extends Command {
) { ) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_GRANT_SINGLE) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_GRANT_SINGLE) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -35,7 +35,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import java.util.Collection; import java.util.Collection;
import java.util.Locale; import java.util.Locale;
@ -117,27 +118,31 @@ public class Help extends Command {
} }
if (cat == null && page == 0) { if (cat == null && page == 0) {
TextComponent.Builder builder = Component.text(); TextComponent.Builder builder = Component.text();
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_header").getComponent(player))); builder.append(MINI_MESSAGE.parse(TranslatableCaption.miniMessage("help.help_header").getComponent(player)));
for (CommandCategory c : CommandCategory.values()) { for (CommandCategory c : CommandCategory.values()) {
builder.append(Component.newline()).append(MINI_MESSAGE builder.append(Component.newline()).append(MINI_MESSAGE
.parse( .deserialize(
TranslatableCaption.of("help.help_info_item").getComponent(player), TranslatableCaption.miniMessage("help.help_info_item").getComponent(player),
Template.of("command", "/plot help"), PlaceholderResolver.placeholders(
Template.of("category", c.name().toLowerCase()), Placeholder.miniMessage("command", "/plot help"),
Template.of("category_desc", c.getComponent(player)) Placeholder.miniMessage("category", c.name().toLowerCase()),
Placeholder.miniMessage("category_desc", c.getComponent(player))
)
)); ));
} }
builder.append(Component.newline()).append(MINI_MESSAGE builder.append(Component.newline()).append(MINI_MESSAGE
.parse( .deserialize(
TranslatableCaption.of("help.help_info_item").getComponent(player), TranslatableCaption.miniMessage("help.help_info_item").getComponent(player),
Template.of("command", "/plot help"), PlaceholderResolver.placeholders(
Template.of("category", "all"), Placeholder.miniMessage("command", "/plot help"),
Template.of("category_desc", "Display all commands") Placeholder.miniMessage("category", "all"),
Placeholder.miniMessage("category_desc", "Display all commands")
)
)); ));
builder.append(Component.newline()).append(MINI_MESSAGE.parse(TranslatableCaption builder.append(Component.newline()).append(MINI_MESSAGE.parse(TranslatableCaption
.of("help.help_footer") .miniMessage("help.help_footer")
.getComponent(player))); .getComponent(player)));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.asComponent()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(builder.asComponent())));
return true; return true;
} }
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage( new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy; import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
@ -74,13 +74,13 @@ public class HomeCommand extends Command {
) { ) {
List<Plot> plots = query.asList(); List<Plot> plots = query.asList();
if (plots.isEmpty()) { if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return; return;
} else if (plots.size() < page || page < 1) { } else if (plots.size() < page || page < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.number_not_in_range"), TranslatableCaption.miniMessage("invalid.number_not_in_range"),
Template.of("min", "1"), Placeholder.miniMessage("min", "1"),
Template.of("max", String.valueOf(plots.size())) Placeholder.miniMessage("max", String.valueOf(plots.size()))
); );
return; return;
} }
@ -114,8 +114,8 @@ public class HomeCommand extends Command {
if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OWNED) && !Permissions if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OWNED) && !Permissions
.hasPermission(player, Permission.PERMISSION_HOME)) { .hasPermission(player, Permission.PERMISSION_HOME)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_VISIT_OWNED.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_VISIT_OWNED.toString())
); );
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -136,8 +136,8 @@ public class HomeCommand extends Command {
page = Integer.parseInt(identifier); page = Integer.parseInt(identifier);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"), TranslatableCaption.miniMessage("invalid.not_a_number"),
Template.of("value", identifier) Placeholder.miniMessage("value", identifier)
); );
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -177,8 +177,8 @@ public class HomeCommand extends Command {
page = Integer.parseInt(identifier); page = Integer.parseInt(identifier);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"), TranslatableCaption.miniMessage("invalid.not_a_number"),
Template.of("value", identifier) Placeholder.miniMessage("value", identifier)
); );
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.MetaDataAccess; import com.plotsquared.core.player.MetaDataAccess;
@ -43,7 +43,8 @@ import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -60,7 +61,7 @@ public class Inbox extends SubCommand {
public void displayComments(PlotPlayer<?> player, List<PlotComment> oldComments, int page) { public void displayComments(PlotPlayer<?> player, List<PlotComment> oldComments, int page) {
if (oldComments == null || oldComments.isEmpty()) { if (oldComments == null || oldComments.isEmpty()) {
player.sendMessage(TranslatableCaption.of("comment.inbox_empty")); player.sendMessage(TranslatableCaption.miniMessage("comment.inbox_empty"));
return; return;
} }
PlotComment[] comments = oldComments.toArray(new PlotComment[0]); PlotComment[] comments = oldComments.toArray(new PlotComment[0]);
@ -79,55 +80,55 @@ public class Inbox extends SubCommand {
max = comments.length; max = comments.length;
} }
TextComponent.Builder builder = Component.text(); TextComponent.Builder builder = Component.text();
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("list.comment_list_header_paged").getComponent(player) + '\n', builder.append(MINI_MESSAGE.deserialize(TranslatableCaption.miniMessage("list.comment_list_header_paged").getComponent(player) + '\n',
Template.of("amount", String.valueOf(comments.length)), Template.of("cur", String.valueOf(page + 1)), PlaceholderResolver.placeholders(
Template.of("max", String.valueOf(totalPages + 1)), Template.of("word", "all") Placeholder.miniMessage("amount", String.valueOf(comments.length)), Placeholder.miniMessage("cur", String.valueOf(page + 1)),
Placeholder.miniMessage("max", String.valueOf(totalPages + 1)), Placeholder.miniMessage("word", "all")
)
)); ));
// This might work xD // This might work xD
for (int x = page * 12; x < max; x++) { for (int x = page * 12; x < max; x++) {
PlotComment comment = comments[x]; PlotComment comment = comments[x];
Component commentColored; String localeKey = player.getName().equals(comment.senderName) ?
if (player.getName().equals(comment.senderName)) { "list.comment_list_by_lister" : "list.comment_list_by_other";
commentColored = MINI_MESSAGE
.parse( Placeholder<Component> commentColored = Placeholder.component("comment", MINI_MESSAGE.deserialize(
TranslatableCaption.of("list.comment_list_by_lister").getComponent(player), TranslatableCaption.miniMessage(localeKey).getComponent(player), PlaceholderResolver.placeholders(
Template.of("comment", comment.comment) Placeholder.miniMessage("comment", comment.comment)
))
); );
} else { Placeholder<?> number = Placeholder.miniMessage("number", String.valueOf(x));
commentColored = MINI_MESSAGE Placeholder<?> world = Placeholder.miniMessage("world", comment.world);
.parse( Placeholder<?> plot_id = Placeholder.miniMessage("plot_id", comment.id.getX() + ";" + comment.id.getY());
TranslatableCaption.of("list.comment_list_by_other").getComponent(player), Placeholder<?> commenter = Placeholder.miniMessage("commenter", comment.senderName);
Template.of("comment", comment.comment)
);
}
Template number = Template.of("number", String.valueOf(x));
Template world = Template.of("world", comment.world);
Template plot_id = Template.of("plot_id", comment.id.getX() + ";" + comment.id.getY());
Template commenter = Template.of("commenter", comment.senderName);
Template commentTemplate = Template.of("comment", commentColored);
builder.append(MINI_MESSAGE builder.append(MINI_MESSAGE
.parse( .deserialize(
TranslatableCaption.of("list.comment_list_comment").getComponent(player), TranslatableCaption.miniMessage("list.comment_list_comment").getComponent(player),
PlaceholderResolver.placeholders(
number, number,
world, world,
plot_id, plot_id,
commenter, commenter,
commentTemplate commentColored
)); )));
// Apply line break if not last entry
if (x != max - 1) {
builder.append(Component.newline());
} }
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build()))); }
player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(builder.build())));
} }
@Override @Override
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (args.length == 0) { if (args.length == 0) {
@ -149,21 +150,21 @@ public class Inbox extends SubCommand {
} }
if (total != 0) { if (total != 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.inbox_item"), TranslatableCaption.miniMessage("comment.inbox_item"),
Template.of("value", inbox + " (" + total + '/' + unread + ')') Placeholder.miniMessage("value", inbox + " (" + total + '/' + unread + ')')
); );
return; return;
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.inbox_item"), TranslatableCaption.miniMessage("comment.inbox_item"),
Template.of("value", inbox.toString()) Placeholder.miniMessage("value", inbox.toString())
); );
} }
})) { })) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.inbox_item"), TranslatableCaption.miniMessage("comment.inbox_item"),
Template.of("value", inbox.toString()) Placeholder.miniMessage("value", inbox.toString())
); );
} }
} }
@ -173,8 +174,8 @@ public class Inbox extends SubCommand {
final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase()); final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
if (inbox == null) { if (inbox == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.invalid_inbox"), TranslatableCaption.miniMessage("comment.invalid_inbox"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), ", ")) Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), ", "))
); );
return false; return false;
} }
@ -191,13 +192,13 @@ public class Inbox extends SubCommand {
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "delete": case "delete":
if (!inbox.canModify(plot, player)) { if (!inbox.canModify(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify")); player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox_modify"));
return false; return false;
} }
if (args.length != 3) { if (args.length != 3) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot inbox " + inbox + " delete <index>") Placeholder.miniMessage("value", "/plot inbox " + inbox + " delete <index>")
); );
return true; return true;
} }
@ -206,15 +207,15 @@ public class Inbox extends SubCommand {
index = Integer.parseInt(args[2]); index = Integer.parseInt(args[2]);
if (index < 1) { if (index < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.not_valid_inbox_index"), TranslatableCaption.miniMessage("comment.not_valid_inbox_index"),
Templates.of("number", index) Placeholders.miniMessage("number", index)
); );
return false; return false;
} }
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot inbox " + inbox + " delete <index>") Placeholder.miniMessage("value", "/plot inbox " + inbox + " delete <index>")
); );
return false; return false;
} }
@ -224,8 +225,8 @@ public class Inbox extends SubCommand {
public void run(List<PlotComment> value) { public void run(List<PlotComment> value) {
if (index > value.size()) { if (index > value.size()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.not_valid_inbox_index"), TranslatableCaption.miniMessage("comment.not_valid_inbox_index"),
Templates.of("number", index) Placeholders.miniMessage("number", index)
); );
return; return;
} }
@ -234,29 +235,29 @@ public class Inbox extends SubCommand {
boolean success = plot.getPlotCommentContainer().removeComment(comment); boolean success = plot.getPlotCommentContainer().removeComment(comment);
if (success) { if (success) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"), TranslatableCaption.miniMessage("comment.comment_removed_success"),
Template.of("value", comment.comment) Placeholder.miniMessage("value", comment.comment)
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_removed_failure")); TranslatableCaption.miniMessage("comment.comment_removed_failure"));
} }
} }
})) { })) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
return true; return true;
case "clear": case "clear":
if (!inbox.canModify(plot, player)) { if (!inbox.canModify(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify")); player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox_modify"));
} }
inbox.clearInbox(plot); inbox.clearInbox(plot);
List<PlotComment> comments = plot.getPlotCommentContainer().getComments(inbox.toString()); List<PlotComment> comments = plot.getPlotCommentContainer().getComments(inbox.toString());
if (!comments.isEmpty()) { if (!comments.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"), TranslatableCaption.miniMessage("comment.comment_removed_success"),
Template.of("value", String.valueOf(comments)) Placeholder.miniMessage("value", String.valueOf(comments))
); );
plot.getPlotCommentContainer().removeComments(comments); plot.getPlotCommentContainer().removeComments(comments);
} }
@ -273,7 +274,7 @@ public class Inbox extends SubCommand {
page = 1; page = 1;
} }
if (!inbox.canRead(plot, player)) { if (!inbox.canRead(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox")); player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox"));
return false; return false;
} }
if (!inbox.getComments(plot, new RunnableVal<>() { if (!inbox.getComments(plot, new RunnableVal<>() {
@ -282,7 +283,7 @@ public class Inbox extends SubCommand {
displayComments(player, value, page); displayComments(player, value, page);
} }
})) { })) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
return true; return true;
@ -307,11 +308,11 @@ public class Inbox extends SubCommand {
.map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.CHAT) { .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.CHAT) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_INBOX) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_INBOX) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.HideInfoFlag; import com.plotsquared.core.plot.flag.implementations.HideInfoFlag;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -76,7 +76,7 @@ public class Info extends SubCommand {
plot = player.getCurrentPlot(); plot = player.getCurrentPlot();
} }
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
@ -96,8 +96,8 @@ public class Info extends SubCommand {
if (!player if (!player
.hasPermission(Permission.PERMISSION_AREA_INFO_FORCE.toString())) { .hasPermission(Permission.PERMISSION_AREA_INFO_FORCE.toString())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_AREA_INFO_FORCE.toString()) Placeholder.miniMessage("node", Permission.PERMISSION_AREA_INFO_FORCE.toString())
); );
return true; return true;
} }
@ -106,7 +106,7 @@ public class Info extends SubCommand {
} }
} }
if (!allowed) { if (!allowed) {
player.sendMessage(TranslatableCaption.of("info.plot_info_hidden")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_info_hidden"));
return true; return true;
} }
} }
@ -118,22 +118,22 @@ public class Info extends SubCommand {
// Unclaimed? // Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) { if (!hasOwner && !containsEveryone && !trustedEveryone) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("info.plot_info_unclaimed"), TranslatableCaption.miniMessage("info.plot_info_unclaimed"),
Template.of("plot", plot.getId().getX() + ";" + plot.getId().getY()) Placeholder.miniMessage("plot", plot.getId().getX() + ";" + plot.getId().getY())
); );
return true; return true;
} }
Caption info = TranslatableCaption.of("info.plot_info_format"); Caption info = TranslatableCaption.miniMessage("info.plot_info_format");
boolean full; boolean full;
if (arg != null) { if (arg != null) {
info = getCaption(arg); info = getCaption(arg);
if (info == null) { if (info == null) {
if (Settings.Ratings.USE_LIKES) { if (Settings.Ratings.USE_LIKES) {
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + " &alikes")); + "&aowner&7, " + " &alikes"));
} else { } else {
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + " &arating")); + "&aowner&7, " + " &arating"));
} }
@ -161,7 +161,7 @@ public class Info extends SubCommand {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO_FORCE) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO_FORCE) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
@ -169,19 +169,19 @@ public class Info extends SubCommand {
private Caption getCaption(String string) { private Caption getCaption(String string) {
return switch (string) { return switch (string) {
case "trusted" -> TranslatableCaption.of("info.plot_info_trusted"); case "trusted" -> TranslatableCaption.miniMessage("info.plot_info_trusted");
case "alias" -> TranslatableCaption.of("info.plot_info_alias"); case "alias" -> TranslatableCaption.miniMessage("info.plot_info_alias");
case "biome" -> TranslatableCaption.of("info.plot_info_biome"); case "biome" -> TranslatableCaption.miniMessage("info.plot_info_biome");
case "denied" -> TranslatableCaption.of("info.plot_info_denied"); case "denied" -> TranslatableCaption.miniMessage("info.plot_info_denied");
case "flags" -> TranslatableCaption.of("info.plot_info_flags"); case "flags" -> TranslatableCaption.miniMessage("info.plot_info_flags");
case "id" -> TranslatableCaption.of("info.plot_info_id"); case "id" -> TranslatableCaption.miniMessage("info.plot_info_id");
case "size" -> TranslatableCaption.of("info.plot_info_size"); case "size" -> TranslatableCaption.miniMessage("info.plot_info_size");
case "members" -> TranslatableCaption.of("info.plot_info_members"); case "members" -> TranslatableCaption.miniMessage("info.plot_info_members");
case "owner" -> TranslatableCaption.of("info.plot_info_owner"); case "owner" -> TranslatableCaption.miniMessage("info.plot_info_owner");
case "rating" -> TranslatableCaption.of("info.plot_info_rating"); case "rating" -> TranslatableCaption.miniMessage("info.plot_info_rating");
case "likes" -> TranslatableCaption.of("info.plot_info_likes"); case "likes" -> TranslatableCaption.miniMessage("info.plot_info_likes");
case "seen" -> TranslatableCaption.of("info.plot_info_seen"); case "seen" -> TranslatableCaption.miniMessage("info.plot_info_seen");
case "creationdate" -> TranslatableCaption.of("info.plot_info_creationdate"); case "creationdate" -> TranslatableCaption.miniMessage("info.plot_info_creationdate");
default -> null; default -> null;
}; };
} }

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -74,22 +74,22 @@ public class Kick extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlot(); Plot plot = location.getPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_KICK)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_KICK)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> { PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.isEmpty()) { } else if (throwable != null || uuids.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
} else { } else {
Set<PlotPlayer<?>> players = new HashSet<>(); Set<PlotPlayer<?>> players = new HashSet<>();
@ -112,28 +112,28 @@ public class Kick extends SubCommand {
players.remove(player); // Don't ever kick the calling player players.remove(player); // Don't ever kick the calling player
if (players.isEmpty()) { if (players.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
return; return;
} }
for (PlotPlayer<?> player2 : players) { for (PlotPlayer<?> player2 : players) {
if (!plot.equals(player2.getCurrentPlot())) { if (!plot.equals(player2.getCurrentPlot())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
return; return;
} }
if (Permissions.hasPermission(player2, Permission.PERMISSION_ADMIN_ENTRY_DENIED)) { if (Permissions.hasPermission(player2, Permission.PERMISSION_ADMIN_ENTRY_DENIED)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("cluster.cannot_kick_player"), TranslatableCaption.miniMessage("cluster.cannot_kick_player"),
Template.of("name", player2.getName()) Placeholder.miniMessage("name", player2.getName())
); );
return; return;
} }
Location spawn = this.worldUtil.getSpawn(location.getWorldName()); Location spawn = this.worldUtil.getSpawn(location.getWorldName());
player2.sendMessage(TranslatableCaption.of("kick.you_got_kicked")); player2.sendMessage(TranslatableCaption.miniMessage("kick.you_got_kicked"));
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]); Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
if (plot.equals(newSpawn.getPlot())) { if (plot.equals(newSpawn.getPlot())) {

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID; import java.util.UUID;
@ -59,10 +59,10 @@ public class Leave extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone RunnableVal2<Command, CommandResult> whenDone
) throws CommandException { ) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue(plot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
if (plot.isOwner(player.getUUID())) { if (plot.isOwner(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("member.plot_cant_leave_owner")); player.sendMessage(TranslatableCaption.miniMessage("member.plot_cant_leave_owner"));
} else { } else {
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
if (plot.isAdded(uuid)) { if (plot.isAdded(uuid)) {
@ -73,12 +73,12 @@ public class Leave extends Command {
this.eventDispatcher.callMember(player, plot, uuid, false); this.eventDispatcher.callMember(player, plot, uuid, false);
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("member.plot_left"), TranslatableCaption.miniMessage("member.plot_left"),
Template.of("player", player.getName()) Placeholder.miniMessage("player", player.getName())
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("members.not_added_trusted") TranslatableCaption.miniMessage("members.not_added_trusted")
); );
} }
} }

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -115,17 +115,17 @@ public class Like extends SubCommand {
.isBasePlot() && (!plot.getLikes().containsKey(uuid))) { .isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
plot.teleportPlayer(player, TeleportCause.COMMAND_LIKE, result -> { plot.teleportPlayer(player, TeleportCause.COMMAND_LIKE, result -> {
}); });
player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); player.sendMessage(TranslatableCaption.miniMessage("tutorial.rate_this"));
return true; return true;
} }
} }
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return true; return true;
} }
case "purge" -> { case "purge" -> {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!Permissions if (!Permissions
@ -133,34 +133,34 @@ public class Like extends SubCommand {
return false; return false;
} }
plot.clearRatings(); plot.clearRatings();
player.sendMessage(TranslatableCaption.of("ratings.ratings_purged")); player.sendMessage(TranslatableCaption.miniMessage("ratings.ratings_purged"));
return true; return true;
} }
} }
} }
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_owned")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_owned"));
return false; return false;
} }
if (plot.isOwner(player.getUUID())) { if (plot.isOwner(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_your_own")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_your_own"));
return false; return false;
} }
if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) { if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_done")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_done"));
return false; return false;
} }
final Runnable run = () -> { final Runnable run = () -> {
final Boolean oldRating = plot.getLikes().get(uuid); final Boolean oldRating = plot.getLikes().get(uuid);
if (oldRating != null) { if (oldRating != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("ratings.rating_already_exists"), TranslatableCaption.miniMessage("ratings.rating_already_exists"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
return; return;
} }
@ -177,13 +177,13 @@ public class Like extends SubCommand {
plot.addRating(uuid, event.getRating()); plot.addRating(uuid, event.getRating());
if (like) { if (like) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("ratings.rating_liked"), TranslatableCaption.miniMessage("ratings.rating_liked"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("ratings.rating_disliked"), TranslatableCaption.miniMessage("ratings.rating_disliked"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
} }
} }
@ -220,11 +220,11 @@ public class Like extends SubCommand {
.map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.CaptionHolder; import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -53,7 +53,8 @@ import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
@ -129,8 +130,8 @@ public class ListCmd extends SubCommand {
public void noArgs(PlotPlayer<?> player) { public void noArgs(PlotPlayer<?> player) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.subcommand_set_options_header"), TranslatableCaption.miniMessage("commandconfig.subcommand_set_options_header"),
Templates.of("values", Arrays.toString(getArgumentList(player))) Placeholders.miniMessage("values", Arrays.toString(getArgumentList(player)))
); );
} }
@ -165,8 +166,8 @@ public class ListCmd extends SubCommand {
final Consumer<PlotQuery> plotConsumer = query -> { final Consumer<PlotQuery> plotConsumer = query -> {
if (query == null) { if (query == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.did_you_mean"), TranslatableCaption.miniMessage("commandconfig.did_you_mean"),
Template.of( Placeholder.miniMessage(
"value", "value",
new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch() new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch()
) )
@ -185,7 +186,7 @@ public class ListCmd extends SubCommand {
final List<Plot> plots = query.asList(); final List<Plot> plots = query.asList();
if (plots.isEmpty()) { if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return; return;
} }
displayPlots(player, plots, 12, page, args); displayPlots(player, plots, 12, page, args);
@ -195,8 +196,8 @@ public class ListCmd extends SubCommand {
case "mine" -> { case "mine" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.mine") Placeholders.miniMessage("node", "plots.list.mine")
); );
return false; return false;
} }
@ -210,8 +211,8 @@ public class ListCmd extends SubCommand {
case "shared" -> { case "shared" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.shared") Placeholders.miniMessage("node", "plots.list.shared")
); );
return false; return false;
} }
@ -223,15 +224,15 @@ public class ListCmd extends SubCommand {
case "world" -> { case "world" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.world") Placeholders.miniMessage("node", "plots.list.world")
); );
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.list.world." + world)) { if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.world." + world) Placeholders.miniMessage("node", "plots.list.world." + world)
); );
return false; return false;
} }
@ -240,8 +241,8 @@ public class ListCmd extends SubCommand {
case "expired" -> { case "expired" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.expired") Placeholders.miniMessage("node", "plots.list.expired")
); );
return false; return false;
} }
@ -254,15 +255,15 @@ public class ListCmd extends SubCommand {
case "area" -> { case "area" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.area") Placeholders.miniMessage("node", "plots.list.area")
); );
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.list.world." + world)) { if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.world." + world) Placeholders.miniMessage("node", "plots.list.world." + world)
); );
return false; return false;
} }
@ -275,8 +276,8 @@ public class ListCmd extends SubCommand {
case "all" -> { case "all" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.all") Placeholders.miniMessage("node", "plots.list.all")
); );
return false; return false;
} }
@ -285,8 +286,8 @@ public class ListCmd extends SubCommand {
case "done" -> { case "done" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.done") Placeholders.miniMessage("node", "plots.list.done")
); );
return false; return false;
} }
@ -300,8 +301,8 @@ public class ListCmd extends SubCommand {
case "top" -> { case "top" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.top") Placeholders.miniMessage("node", "plots.list.top")
); );
return false; return false;
} }
@ -311,8 +312,8 @@ public class ListCmd extends SubCommand {
case "forsale" -> { case "forsale" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.forsale") Placeholders.miniMessage("node", "plots.list.forsale")
); );
return false; return false;
} }
@ -324,8 +325,8 @@ public class ListCmd extends SubCommand {
case "unowned" -> { case "unowned" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.unowned") Placeholders.miniMessage("node", "plots.list.unowned")
); );
return false; return false;
} }
@ -334,15 +335,15 @@ public class ListCmd extends SubCommand {
case "fuzzy" -> { case "fuzzy" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.fuzzy") Placeholders.miniMessage("node", "plots.list.fuzzy")
); );
return false; return false;
} }
if (args.length < (page == -1 ? 2 : 3)) { if (args.length < (page == -1 ? 2 : 3)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Templates.of("value", "/plot list fuzzy <search...> [#]") Placeholders.miniMessage("value", "/plot list fuzzy <search...> [#]")
); );
return false; return false;
} }
@ -359,15 +360,15 @@ public class ListCmd extends SubCommand {
if (this.plotAreaManager.hasPlotArea(args[0])) { if (this.plotAreaManager.hasPlotArea(args[0])) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.world") Placeholders.miniMessage("node", "plots.list.world")
); );
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) { if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.world." + args[0]) Placeholders.miniMessage("node", "plots.list.world." + args[0])
); );
return false; return false;
} }
@ -376,7 +377,7 @@ public class ListCmd extends SubCommand {
} }
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> { PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) { } else if (throwable != null) {
if (uuid == null) { if (uuid == null) {
try { try {
@ -386,12 +387,12 @@ public class ListCmd extends SubCommand {
} }
} }
if (uuid == null) { if (uuid == null) {
player.sendMessage(TranslatableCaption.of("errors.invalid_player"), Templates.of("value", args[0])); player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_player"), Placeholders.miniMessage("value", args[0]));
} else { } else {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Templates.of("node", "plots.list.player") Placeholders.miniMessage("node", "plots.list.player")
); );
} else { } else {
sort[0] = false; sort[0] = false;
@ -416,28 +417,30 @@ public class ListCmd extends SubCommand {
public void run(Integer i, Plot plot, CaptionHolder caption) { public void run(Integer i, Plot plot, CaptionHolder caption) {
Caption color; Caption color;
if (plot.getOwner() == null) { if (plot.getOwner() == null) {
color = TranslatableCaption.of("info.plot_list_no_owner"); color = TranslatableCaption.miniMessage("info.plot_list_no_owner");
} else if (plot.isOwner(player.getUUID())) { } else if (plot.isOwner(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_owned_by"); color = TranslatableCaption.miniMessage("info.plot_list_owned_by");
} else if (plot.isAdded(player.getUUID())) { } else if (plot.isAdded(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_added_to"); color = TranslatableCaption.miniMessage("info.plot_list_added_to");
} else if (plot.isDenied(player.getUUID())) { } else if (plot.isDenied(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_denied_on"); color = TranslatableCaption.miniMessage("info.plot_list_denied_on");
} else { } else {
color = TranslatableCaption.of("info.plot_list_default"); color = TranslatableCaption.miniMessage("info.plot_list_default");
} }
Component trusted = MINI_MESSAGE.parse( Component trusted = MINI_MESSAGE.deserialize(
TranslatableCaption.of("info.plot_info_trusted").getComponent(player), TranslatableCaption.miniMessage("info.plot_info_trusted").getComponent(player),
Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted(), player)) PlaceholderResolver.placeholders(Placeholder.component("trusted",
PlayerManager.getPlayerList(plot.getTrusted(), player)))
); );
Component members = MINI_MESSAGE.parse( Component members = MINI_MESSAGE.deserialize(
TranslatableCaption.of("info.plot_info_members").getComponent(player), TranslatableCaption.miniMessage("info.plot_info_members").getComponent(player),
Template.of("members", PlayerManager.getPlayerList(plot.getMembers(), player)) PlaceholderResolver.placeholders(Placeholder.component("members",
PlayerManager.getPlayerList(plot.getTrusted(), player)))
); );
Template command_tp = Template.of("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId()); Placeholder<?> command_tp = Placeholder.miniMessage("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId());
Template command_info = Template.of("command_info", "/plot info " + plot.getArea() + ";" + plot.getId()); Placeholder<?> command_info = Placeholder.miniMessage("command_info", "/plot info " + plot.getArea() + ";" + plot.getId());
Template hover_info = Placeholder<?> hover_info =
Template.of( Placeholder.miniMessage(
"hover_info", "hover_info",
MINI_MESSAGE.serialize(Component MINI_MESSAGE.serialize(Component
.text() .text()
@ -446,27 +449,30 @@ public class ListCmd extends SubCommand {
.append(members) .append(members)
.asComponent()) .asComponent())
); );
Template numberTemplate = Template.of("number", String.valueOf(i)); Placeholder<?> numberTemplate = Placeholder.miniMessage("number", String.valueOf(i));
Template plotTemplate = Template.of( Placeholder<?> plotTemplate = Placeholder.component(
"plot", "plot",
MINI_MESSAGE.parse(color.getComponent(player), Template.of("plot", plot.toString())) MINI_MESSAGE.deserialize(color.getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.component("plot", Component.text(plot.toString()))
))
); );
String prefix = ""; String prefix = "";
String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player); String online = TranslatableCaption.miniMessage("info.plot_list_player_online").getComponent(player);
String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player); String offline = TranslatableCaption.miniMessage("info.plot_list_player_offline").getComponent(player);
TextComponent.Builder builder = Component.text(); TextComponent.Builder builder = Component.text();
try { try {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) { for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid()); PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid());
Template prefixTemplate = Template.of("prefix", prefix); Placeholder<?> prefixTemplate = Placeholder.miniMessage("prefix", prefix);
Template playerTemplate = Template.of("player", uuidMapping.getUsername()); Placeholder<?> playerTemplate = Placeholder.miniMessage("player", uuidMapping.getUsername());
if (pp != null) { if (pp != null) {
builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate)); builder.append(MINI_MESSAGE.deserialize(online, PlaceholderResolver.placeholders(prefixTemplate, playerTemplate)));
} else { } else {
builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate)); builder.append(MINI_MESSAGE.deserialize(offline, PlaceholderResolver.placeholders(prefixTemplate, playerTemplate)));
} }
prefix = ", "; prefix = ", ";
} }
@ -481,17 +487,17 @@ public class ListCmd extends SubCommand {
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Templates.of("value", playerBuilder.toString()) Placeholders.miniMessage("value", playerBuilder.toString())
); );
} catch (TimeoutException e) { } catch (TimeoutException e) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} }
Template players = Template.of("players", builder.asComponent()); Placeholder<?> players = Placeholder.component("players", builder.asComponent());
caption.set(TranslatableCaption.of("info.plot_list_item")); caption.set(TranslatableCaption.miniMessage("info.plot_list_item"));
caption.setTemplates(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players); caption.parsePlaceholders(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players);
} }
}, "/plot list " + args[0], TranslatableCaption.of("list.plot_list_header_paged")); }, "/plot list " + args[0], TranslatableCaption.miniMessage("list.plot_list_header_paged"));
} }
@Override @Override
@ -532,7 +538,7 @@ public class ListCmd extends SubCommand {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -74,25 +74,25 @@ public class Load extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, final String[] args) { public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
final String world = player.getLocation().getWorldName(); final String world = player.getLocation().getWorldName();
if (!this.plotAreaManager.hasPlotArea(world)) { if (!this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_LOAD)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_LOAD)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
@ -104,8 +104,8 @@ public class Load extends SubCommand {
if (schematics == null) { if (schematics == null) {
// No schematics found: // No schematics found:
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.load_null"), TranslatableCaption.miniMessage("web.load_null"),
Template.of("command", "/plot load") Placeholder.miniMessage("command", "/plot load")
); );
return false; return false;
} }
@ -115,8 +115,8 @@ public class Load extends SubCommand {
} catch (Exception ignored) { } catch (Exception ignored) {
// use /plot load <index> // use /plot load <index>
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"), TranslatableCaption.miniMessage("invalid.not_valid_number"),
Template.of("value", "(1, " + schematics.size() + ')') Placeholder.miniMessage("value", "(1, " + schematics.size() + ')')
); );
return false; return false;
} }
@ -125,18 +125,18 @@ public class Load extends SubCommand {
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic); url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
player.sendMessage(TranslatableCaption.of("web.load_failed")); player.sendMessage(TranslatableCaption.miniMessage("web.load_failed"));
return false; return false;
} }
plot.addRunning(); plot.addRunning();
player.sendMessage(TranslatableCaption.of("working.generating_component")); player.sendMessage(TranslatableCaption.miniMessage("working.generating_component"));
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
Schematic taskSchematic = this.schematicHandler.getSchematic(url); Schematic taskSchematic = this.schematicHandler.getSchematic(url);
if (taskSchematic == null) { if (taskSchematic == null) {
plot.removeRunning(); plot.removeRunning();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid"), TranslatableCaption.miniMessage("schematics.schematic_invalid"),
Template.of("reason", "non-existent or not in gzip format") Placeholder.miniMessage("reason", "non-existent or not in gzip format")
); );
return; return;
} }
@ -149,14 +149,14 @@ public class Load extends SubCommand {
0, 0,
false, false,
player, player,
new RunnableVal<Boolean>() { new RunnableVal<>() {
@Override @Override
public void run(Boolean value) { public void run(Boolean value) {
plot.removeRunning(); plot.removeRunning();
if (value) { if (value) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_success"));
} else { } else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_failed"));
} }
} }
} }
@ -166,8 +166,8 @@ public class Load extends SubCommand {
} }
plot.removeRunning(); plot.removeRunning();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot load <index>") Placeholder.miniMessage("value", "/plot load <index>")
); );
return false; return false;
} }
@ -181,7 +181,7 @@ public class Load extends SubCommand {
List<String> schematics1 = this.schematicHandler.getSaves(player.getUUID()); List<String> schematics1 = this.schematicHandler.getSaves(player.getUUID());
plot.removeRunning(); plot.removeRunning();
if ((schematics1 == null) || schematics1.isEmpty()) { if ((schematics1 == null) || schematics1.isEmpty()) {
player.sendMessage(TranslatableCaption.of("web.load_failed")); player.sendMessage(TranslatableCaption.miniMessage("web.load_failed"));
return; return;
} }
metaDataAccess.set(schematics1); metaDataAccess.set(schematics1);
@ -210,15 +210,15 @@ public class Load extends SubCommand {
PlotId id = PlotId.fromString(split[2] + ';' + split[3]); PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
String size = split[4]; String size = split[4];
String color = "<dark_aqua>"; String color = "<dark_aqua>";
player.sendMessage(StaticCaption.of("<dark_gray>[</dark_gray><gray>" + (i + 1) + "</gray><dark_aqua>] </dark_aqua>" + color + time + "<dark_gray> | </dark_gray>" + color + world + ';' + id player.sendMessage(StaticCaption.miniMessage("<dark_gray>[</dark_gray><gray>" + (i + 1) + "</gray><dark_aqua>] </dark_aqua>" + color + time + "<dark_gray> | </dark_gray>" + color + world + ';' + id
+ "<dark_gray> | </dark_gray>" + color + size + 'x' + size)); + "<dark_gray> | </dark_gray>" + color + size + 'x' + size));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("web.load_list"), TranslatableCaption.miniMessage("web.load_list"),
Template.of("command", "/plot load #") Placeholder.miniMessage("command", "/plot load #")
); );
} }
} }

View File

@ -43,6 +43,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -274,7 +275,7 @@ public class MainCommand extends Command {
} }
tp = true; tp = true;
} else { } else {
player.sendMessage(TranslatableCaption.of("border.border")); player.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} }
// Trim command // Trim command
args = Arrays.copyOfRange(args, 1, args.length); args = Arrays.copyOfRange(args, 1, args.length);
@ -303,7 +304,7 @@ public class MainCommand extends Command {
}; };
args = Arrays.copyOfRange(args, 1, args.length); args = Arrays.copyOfRange(args, 1, args.length);
} else { } else {
player.sendMessage(TranslatableCaption.of("errors.invalid_command_flag")); player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_command_flag"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
} }
@ -317,12 +318,12 @@ public class MainCommand extends Command {
String message = e.getMessage(); String message = e.getMessage();
if (message != null) { if (message != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.error"), TranslatableCaption.miniMessage("errors.error"),
net.kyori.adventure.text.minimessage.Template.of("value", message) Placeholder.miniMessage("value", message)
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.error_console")); TranslatableCaption.miniMessage("errors.error_console"));
} }
} }
// Reset command scope // // Reset command scope //

View File

@ -42,7 +42,8 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression; import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID; import java.util.UUID;
@ -88,15 +89,15 @@ public class Merge extends SubCommand {
Location location = player.getLocationFull(); Location location = player.getLocationFull();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
Direction direction = null; Direction direction = null;
@ -121,12 +122,12 @@ public class Merge extends SubCommand {
} }
if (direction == null) { if (direction == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]") Placeholder.miniMessage("value", "/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]")
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("help.direction"), TranslatableCaption.miniMessage("help.direction"),
Template.of("dir", direction(location.getYaw())) Placeholder.miniMessage("dir", direction(location.getYaw()))
); );
return false; return false;
} }
@ -136,8 +137,8 @@ public class Merge extends SubCommand {
this.eventDispatcher.callMerge(plot, direction, max, player); this.eventDispatcher.callMerge(plot, direction, max, player);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Merge") Placeholder.miniMessage("value", "Merge")
); );
return false; return false;
} }
@ -147,8 +148,8 @@ public class Merge extends SubCommand {
if (!force && size - 1 > maxSize) { if (!force && size - 1 > maxSize) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_MERGE + "." + (size + 1)) Placeholder.miniMessage("node", Permission.PERMISSION_MERGE + "." + (size + 1))
); );
return false; return false;
} }
@ -160,7 +161,7 @@ public class Merge extends SubCommand {
if (!force && !plot.isOwner(uuid)) { if (!force && !plot.isOwner(uuid)) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} else { } else {
uuid = plot.getOwnerAbs(); uuid = plot.getOwnerAbs();
@ -174,8 +175,8 @@ public class Merge extends SubCommand {
if (!force && !terrain && !Permissions if (!force && !terrain && !Permissions
.hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) { .hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD))
); );
return true; return true;
} }
@ -183,22 +184,23 @@ public class Merge extends SubCommand {
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && price > 0d) {
this.econHandler.withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.miniMessage("economy.removed_balance"),
Template.of("money", this.econHandler.format(price)), Placeholder.miniMessage("money", this.econHandler.format(price)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player))) Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
); );
} }
player.sendMessage(TranslatableCaption.of("merge.success_merge")); player.sendMessage(TranslatableCaption.miniMessage("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
return true; return true;
} }
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); player.sendMessage(TranslatableCaption.miniMessage("merge.no_available_automerge"));
return false; return false;
} }
if (!force && this.econHandler.isEnabled(plotArea) && price > 0d if (!force && this.econHandler.isEnabled(plotArea) && price > 0d
&& this.econHandler.getMoney(player) < price) { && this.econHandler.getMoney(player) < price) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"), TranslatableCaption.miniMessage("economy.cannot_afford_merge"),
Template.of("money", this.econHandler.format(price)) Placeholder.miniMessage("money", this.econHandler.format(price))
); );
return false; return false;
} }
@ -211,8 +213,8 @@ public class Merge extends SubCommand {
if (!force && !terrain && !Permissions if (!force && !terrain && !Permissions
.hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) { .hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD))
); );
return true; return true;
} }
@ -220,23 +222,24 @@ public class Merge extends SubCommand {
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && price > 0d) {
this.econHandler.withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.miniMessage("economy.removed_balance"),
Template.of("money", this.econHandler.format(price)) Placeholder.miniMessage("money", this.econHandler.format(price))
); );
} }
player.sendMessage(TranslatableCaption.of("merge.success_merge")); player.sendMessage(TranslatableCaption.miniMessage("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
return true; return true;
} }
Plot adjacent = plot.getRelative(direction); Plot adjacent = plot.getRelative(direction);
if (adjacent == null || !adjacent.hasOwner() || adjacent if (adjacent == null || !adjacent.hasOwner() || adjacent
.isMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) { .isMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) {
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); player.sendMessage(TranslatableCaption.miniMessage("merge.no_available_automerge"));
return false; return false;
} }
if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_MERGE_OTHER)) { if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_MERGE_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_MERGE_OTHER))
); );
return false; return false;
} }
@ -250,35 +253,38 @@ public class Merge extends SubCommand {
isOnline = true; isOnline = true;
final Direction dir = direction; final Direction dir = direction;
Runnable run = () -> { Runnable run = () -> {
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted")); accepter.sendMessage(TranslatableCaption.miniMessage("merge.merge_accepted"));
plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain); plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain);
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID()); PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
if (plotPlayer == null) { if (plotPlayer == null) {
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid")); accepter.sendMessage(TranslatableCaption.miniMessage("merge.merge_not_valid"));
return; return;
} }
if (this.econHandler.isEnabled(plotArea) && price > 0d) { if (this.econHandler.isEnabled(plotArea) && price > 0d) {
if (!force && this.econHandler.getMoney(player) < price) { if (!force && this.econHandler.getMoney(player) < price) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"), TranslatableCaption.miniMessage("economy.cannot_afford_merge"),
Template.of("money", this.econHandler.format(price)) Placeholder.miniMessage("money", this.econHandler.format(price))
); );
return; return;
} }
this.econHandler.withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.miniMessage("economy.removed_balance"),
Template.of("money", this.econHandler.format(price)) Placeholder.miniMessage("money", this.econHandler.format(price))
); );
} }
player.sendMessage(TranslatableCaption.of("merge.success_merge")); player.sendMessage(TranslatableCaption.miniMessage("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
}; };
if (!force && hasConfirmation(player)) { if (!force && hasConfirmation(player)) {
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
.parse( .deserialize(
TranslatableCaption.of("merge.merge_request_confirm").getComponent(player), TranslatableCaption.miniMessage("merge.merge_request_confirm").getComponent(player),
Template.of("player", player.getName()), PlaceholderResolver.placeholders(
Template.of("location", plot.getWorldName() + ";" + plot.getId()) Placeholder.miniMessage("player", player.getName()),
Placeholder.miniMessage("location", plot.getWorldName() + ";" + plot.getId())
)
)), )),
run run
); );
@ -287,10 +293,10 @@ public class Merge extends SubCommand {
} }
} }
if (!force && !isOnline) { if (!force && !isOnline) {
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); player.sendMessage(TranslatableCaption.miniMessage("merge.no_available_automerge"));
return false; return false;
} }
player.sendMessage(TranslatableCaption.of("merge.merge_requested")); player.sendMessage(TranslatableCaption.miniMessage("merge.merge_requested"));
return true; return true;
} }

View File

@ -46,11 +46,11 @@ public class Middle extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlot(); Plot plot = location.getPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND_MIDDLE)); plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND_MIDDLE));
player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot")); player.sendMessage(TranslatableCaption.miniMessage("teleport.teleported_to_plot"));
return true; return true;
} }

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -64,12 +64,12 @@ public class Move extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot1 = location.getPlotAbs(); Plot plot1 = location.getPlotAbs();
if (plot1 == null) { if (plot1 == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (!plot1.isOwner(player.getUUID()) && !Permissions if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN)) { .hasPermission(player, Permission.PERMISSION_ADMIN)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
boolean override = false; boolean override = false;
@ -92,16 +92,16 @@ public class Move extends SubCommand {
plot2 = area.getPlotAbs(plot1.getId()); plot2 = area.getPlotAbs(plot1.getId());
} }
if (plot1.equals(plot2)) { if (plot1.equals(plot2)) {
player.sendMessage(TranslatableCaption.of("invalid.origin_cant_be_target")); player.sendMessage(TranslatableCaption.miniMessage("invalid.origin_cant_be_target"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN))) { .hasPermission(player, Permission.PERMISSION_ADMIN))) {
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible")); player.sendMessage(TranslatableCaption.miniMessage("errors.plotworld_incompatible"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (plot1.isMerged() || plot2.isMerged()) { if (plot1.isMerged() || plot2.isMerged()) {
player.sendMessage(TranslatableCaption.of("move.move_merged")); player.sendMessage(TranslatableCaption.miniMessage("move.move_merged"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -109,13 +109,13 @@ public class Move extends SubCommand {
}, false).thenApply(result -> { }, false).thenApply(result -> {
if (result) { if (result) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("move.move_success"), TranslatableCaption.miniMessage("move.move_success"),
Template.of("origin", plot1.toString()), Placeholder.miniMessage("origin", plot1.toString()),
Template.of("target", plot2.toString()) Placeholder.miniMessage("target", plot2.toString())
); );
return true; return true;
} else { } else {
player.sendMessage(TranslatableCaption.of("move.requires_unowned")); player.sendMessage(TranslatableCaption.miniMessage("move.requires_unowned"));
return false; return false;
} }
}); });

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.plot.flag.implementations.MusicFlag;
import com.plotsquared.core.util.InventoryUtil; import com.plotsquared.core.util.InventoryUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
@ -73,14 +73,14 @@ public class Music extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.isAdded(player.getUUID()) && !Permissions if (!plot.isAdded(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_MUSIC_OTHER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_MUSIC_OTHER)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_MUSIC_OTHER)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_MUSIC_OTHER))
); );
return true; return true;
} }
@ -88,7 +88,7 @@ public class Music extends SubCommand {
this.inventoryUtil, this.inventoryUtil,
player, player,
2, 2,
TranslatableCaption.of("plotjukebox.jukebox_header").getComponent(player) TranslatableCaption.miniMessage("plotjukebox.jukebox_header").getComponent(player)
) { ) {
@Override @Override
public boolean onClick(int index) { public boolean onClick(int index) {
@ -102,16 +102,16 @@ public class Music extends SubCommand {
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(plotFlag, plot); PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Music removal") Placeholder.miniMessage("value", "Music removal")
); );
return true; return true;
} }
plot.removeFlag(event.getFlag()); plot.removeFlag(event.getFlag());
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("flag.flag_removed"), TranslatableCaption.miniMessage("flag.flag_removed"),
Template.of("flag", "music"), Placeholder.miniMessage("flag", "music"),
Template.of("value", "music_disc") Placeholder.miniMessage("value", "music_disc")
); );
} else if (item.getName().toLowerCase(Locale.ENGLISH).contains("disc")) { } else if (item.getName().toLowerCase(Locale.ENGLISH).contains("disc")) {
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class) PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
@ -119,17 +119,17 @@ public class Music extends SubCommand {
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Music addition") Placeholder.miniMessage("value", "Music addition")
); );
return true; return true;
} }
plot.setFlag(event.getFlag()); plot.setFlag(event.getFlag());
getPlayer().sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", "music"), getPlayer().sendMessage(TranslatableCaption.miniMessage("flag.flag_added"), Placeholder.miniMessage("flag", "music"),
Template.of("value", String.valueOf(event.getFlag().getValue())) Placeholder.miniMessage("value", String.valueOf(event.getFlag().getValue()))
); );
} else { } else {
getPlayer().sendMessage(TranslatableCaption.of("flag.flag_not_added")); getPlayer().sendMessage(TranslatableCaption.miniMessage("flag.flag_not_added"));
} }
return false; return false;
} }
@ -138,15 +138,15 @@ public class Music extends SubCommand {
for (final String disc : DISCS) { for (final String disc : DISCS) {
final String name = String.format("<gold>%s</gold>", disc); final String name = String.format("<gold>%s</gold>", disc);
final String[] lore = {TranslatableCaption.of("plotjukebox.click_to_play").getComponent(player)}; final String[] lore = {TranslatableCaption.miniMessage("plotjukebox.click_to_play").getComponent(player)};
final PlotItemStack item = new PlotItemStack(disc, 1, name, lore); final PlotItemStack item = new PlotItemStack(disc, 1, name, lore);
inv.setItem(index++, item); inv.setItem(index++, item);
} }
// Always add the cancel button // Always add the cancel button
// if (player.getMeta("music") != null) { // if (player.getMeta("music") != null) {
String name = TranslatableCaption.of("plotjukebox.cancel_music").getComponent(player); String name = TranslatableCaption.miniMessage("plotjukebox.cancel_music").getComponent(player);
String[] lore = {TranslatableCaption.of("plotjukebox.reset_music").getComponent(player)}; String[] lore = {TranslatableCaption.miniMessage("plotjukebox.reset_music").getComponent(player)};
inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore)); inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore));
// } // }

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -52,10 +52,10 @@ public class Near extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone RunnableVal2<Command, CommandResult> whenDone
) throws CommandException { ) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("near.plot_near"), TranslatableCaption.miniMessage("near.plot_near"),
Template.of("list", StringMan.join(plot.getPlayersInPlot(), ", ")) Placeholder.miniMessage("list", StringMan.join(plot.getPlayersInPlot(), ", "))
); );
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }

View File

@ -42,8 +42,9 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -71,19 +72,20 @@ public class Owner extends SetCommand {
public boolean set(final PlotPlayer<?> player, final Plot plot, String value) { public boolean set(final PlotPlayer<?> player, final Plot plot, String value) {
if (value == null || value.isEmpty()) { if (value == null || value.isEmpty()) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot setowner <owner>") Placeholder.miniMessage("value", "/plot setowner <owner>")
); );
return false; return false;
} }
@Nullable final UUID oldOwner = plot.getOwnerAbs();
Set<Plot> plots = plot.getConnectedPlots(); Set<Plot> plots = plot.getConnectedPlots();
final Consumer<UUID> uuidConsumer = uuid -> { final Consumer<UUID> uuidConsumer = uuid -> {
if (uuid == null && !value.equalsIgnoreCase("none") && !value.equalsIgnoreCase("null") if (uuid == null && !value.equalsIgnoreCase("none") && !value.equalsIgnoreCase("null")
&& !value.equalsIgnoreCase("-")) { && !value.equalsIgnoreCase("-")) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", value) Placeholder.miniMessage("value", value)
); );
return; return;
} }
@ -96,8 +98,8 @@ public class Owner extends SetCommand {
); );
if (event.getEventResult() == Result.DENY) { if (event.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Owner change") Placeholder.miniMessage("value", "Owner change")
); );
return; return;
} }
@ -119,25 +121,28 @@ public class Owner extends SetCommand {
); );
if (unlinkEvent.getEventResult() == Result.DENY) { if (unlinkEvent.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("events.event_denied"), TranslatableCaption.miniMessage("events.event_denied"),
Template.of("value", "Unlink on owner change") Placeholder.miniMessage("value", "Unlink on owner change")
); );
return; return;
} }
plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad()); if (plot.getPlotModificationManager().unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad())) {
eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.NEW_OWNER);
}
Set<Plot> connected = plot.getConnectedPlots(); Set<Plot> connected = plot.getConnectedPlots();
for (Plot current : connected) { for (Plot current : connected) {
current.unclaim(); current.unclaim();
current.getPlotModificationManager().removeSign(); current.getPlotModificationManager().removeSign();
} }
player.sendMessage(TranslatableCaption.of("owner.set_owner")); eventDispatcher.callPostOwnerChange(player, plot, oldOwner);
player.sendMessage(TranslatableCaption.miniMessage("owner.set_owner"));
return; return;
} }
final PlotPlayer<?> other = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); final PlotPlayer<?> other = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (plot.isOwner(uuid)) { if (plot.isOwner(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("member.already_owner"), TranslatableCaption.miniMessage("member.already_owner"),
Template.of("player", PlayerManager.getName(uuid, false)) Placeholder.miniMessage("player", PlayerManager.getName(uuid, false))
); );
return; return;
} }
@ -145,8 +150,8 @@ public class Owner extends SetCommand {
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
if (other == null) { if (other == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player_offline"), TranslatableCaption.miniMessage("errors.invalid_player_offline"),
Template.of("player", PlayerManager.getName(uuid)) Placeholder.miniMessage("player", PlayerManager.getName(uuid))
); );
return; return;
} }
@ -161,7 +166,7 @@ public class Owner extends SetCommand {
grants = metaDataAccess.get().orElse(0); grants = metaDataAccess.get().orElse(0);
if (grants <= 0) { if (grants <= 0) {
metaDataAccess.remove(); metaDataAccess.remove();
player.sendMessage(TranslatableCaption.of("permission.cant_transfer_more_plots")); player.sendMessage(TranslatableCaption.miniMessage("permission.cant_transfer_more_plots"));
return; return;
} }
} }
@ -177,15 +182,16 @@ public class Owner extends SetCommand {
plot.removeDenied(finalUUID); plot.removeDenied(finalUUID);
} }
plot.getPlotModificationManager().setSign(finalName); plot.getPlotModificationManager().setSign(finalName);
player.sendMessage(TranslatableCaption.of("owner.set_owner")); player.sendMessage(TranslatableCaption.miniMessage("owner.set_owner"));
eventDispatcher.callPostOwnerChange(player, plot, oldOwner);
if (other != null) { if (other != null) {
other.sendMessage( other.sendMessage(
TranslatableCaption.of("owner.now_owner"), TranslatableCaption.miniMessage("owner.now_owner"),
Template.of("plot", plot.getArea() + ";" + plot.getId()) Placeholder.miniMessage("plot", plot.getArea() + ";" + plot.getId())
); );
} }
} else { } else {
player.sendMessage(TranslatableCaption.of("owner.set_owner_cancelled")); player.sendMessage(TranslatableCaption.miniMessage("owner.set_owner_cancelled"));
} }
}; };
if (hasConfirmation(player)) { if (hasConfirmation(player)) {
@ -209,7 +215,7 @@ public class Owner extends SetCommand {
@Override @Override
public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) { public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.PremiumVerification; import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "plugin", @CommandDeclaration(command = "plugin",
permission = "plots.use", permission = "plots.use",
@ -43,20 +43,24 @@ public class PluginCmd extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
TaskManager.getPlatformImplementation().taskAsync(() -> { TaskManager.getPlatformImplementation().taskAsync(() -> {
player.sendMessage( player.sendMessage(
StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared StaticCaption.miniMessage("<gray>>> </gray><gold><bold>" + PlotSquared
.platform() .platform()
.pluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"), .pluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"),
Template.of("version", String.valueOf(PlotSquared.get().getVersion())) Placeholder.miniMessage("version", String.valueOf(PlotSquared.get().getVersion()))
); );
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"<gray>>> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray><gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray><gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>")); "<gray>>> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray>" +
player.sendMessage(StaticCaption.of( "<gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray>" +
"<gray>>> </gray><gold><bold>Wiki<reset><gray>: </gray><gold><click:open_url:https://github.com/IntellectualSites/PlotSquared-Documentation/wiki>https://github.com/IntellectualSites/PlotSquared-Documentation/wiki</gold>")); "<gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>"));
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"<gray>>> </gray><gold><bold>Discord<reset><gray>: </gray><gold><click:open_url:https://discord.gg/intellectualsites>https://discord.gg/intellectualsites</gold>")); "<gray>>> </gray><gold><bold>Wiki<reset><gray>:" +
"</gray><gold><click:open_url:https://github.com/IntellectualSites/PlotSquared-Documentation/wiki>https://github.com/IntellectualSites/PlotSquared-Documentation/wiki</gold>"));
player.sendMessage(StaticCaption.miniMessage(
"<gray>>> </gray><gold><bold>Discord<reset><gray>:" +
"</gray><gold><click:open_url:https://discord.gg/intellectualsites>https://discord.gg/intellectualsites</gold>"));
player.sendMessage( player.sendMessage(
StaticCaption.of("<gray>>> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"), StaticCaption.miniMessage("<gray>>> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"),
Template.of("value", String.valueOf(PremiumVerification.isPremium())) Placeholder.miniMessage("value", String.valueOf(PremiumVerification.isPremium()))
); );
}); });
return true; return true;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -102,8 +102,8 @@ public class Purge extends SubCommand {
area = this.plotAreaManager.getPlotAreaByString(split[1]); area = this.plotAreaManager.getPlotAreaByString(split[1]);
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"), TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Template.of("value", split[1]) Placeholder.miniMessage("value", split[1])
); );
return false; return false;
} }
@ -114,8 +114,8 @@ public class Purge extends SubCommand {
id = PlotId.fromString(split[1]); id = PlotId.fromString(split[1]);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_valid_plot_id"), TranslatableCaption.miniMessage("invalid.not_valid_plot_id"),
Template.of("value", split[1]) Placeholder.miniMessage("value", split[1])
); );
return false; return false;
} }
@ -125,8 +125,8 @@ public class Purge extends SubCommand {
UUIDMapping ownerMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]); UUIDMapping ownerMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]);
if (ownerMapping == null) { if (ownerMapping == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", split[1]) Placeholder.miniMessage("value", split[1])
); );
return false; return false;
} }
@ -137,8 +137,8 @@ public class Purge extends SubCommand {
UUIDMapping addedMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]); UUIDMapping addedMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]);
if (addedMapping == null) { if (addedMapping == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", split[1]) Placeholder.miniMessage("value", split[1])
); );
return false; return false;
} }
@ -198,7 +198,7 @@ public class Purge extends SubCommand {
} }
} }
if (toDelete.isEmpty()) { if (toDelete.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return false; return false;
} }
String cmd = String cmd =
@ -242,8 +242,8 @@ public class Purge extends SubCommand {
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
DBFunc.purgeIds(ids); DBFunc.purgeIds(ids);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("purge.purge_success"), TranslatableCaption.miniMessage("purge.purge_success"),
Template.of("amount", ids.size() + "/" + toDelete.size()) Placeholder.miniMessage("amount", ids.size() + "/" + toDelete.size())
); );
}); });
} }

View File

@ -45,7 +45,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -108,17 +108,17 @@ public class Rate extends SubCommand {
.isAdded(uuid)) { .isAdded(uuid)) {
p.teleportPlayer(player, TeleportCause.COMMAND_RATE, result -> { p.teleportPlayer(player, TeleportCause.COMMAND_RATE, result -> {
}); });
player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); player.sendMessage(TranslatableCaption.miniMessage("tutorial.rate_this"));
return true; return true;
} }
} }
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return false; return false;
} }
case "purge" -> { case "purge" -> {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!Permissions if (!Permissions
@ -126,26 +126,26 @@ public class Rate extends SubCommand {
return false; return false;
} }
plot.clearRatings(); plot.clearRatings();
player.sendMessage(TranslatableCaption.of("ratings.ratings_purged")); player.sendMessage(TranslatableCaption.miniMessage("ratings.ratings_purged"));
return true; return true;
} }
} }
} }
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_owned")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_owned"));
return false; return false;
} }
if (plot.isOwner(player.getUUID())) { if (plot.isOwner(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_your_own")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_your_own"));
return false; return false;
} }
if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) { if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_done")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_done"));
return false; return false;
} }
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) { if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
@ -154,8 +154,8 @@ public class Rate extends SubCommand {
public void run() { public void run() {
if (plot.getRatings().containsKey(player.getUUID())) { if (plot.getRatings().containsKey(player.getUUID())) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("ratings.rating_already_exists"), TranslatableCaption.miniMessage("ratings.rating_already_exists"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
return; return;
} }
@ -174,8 +174,8 @@ public class Rate extends SubCommand {
if (event.getRating() != null) { if (event.getRating() != null) {
plot.addRating(this.getPlayer().getUUID(), event.getRating()); plot.addRating(this.getPlayer().getUUID(), event.getRating());
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("ratings.rating_applied"), TranslatableCaption.miniMessage("ratings.rating_applied"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
} }
return false; return false;
@ -185,31 +185,31 @@ public class Rate extends SubCommand {
} }
}; };
inventory.setItem(0, new PlotItemStack(Settings.Ratings.BLOCK_0, 1, inventory.setItem(0, new PlotItemStack(Settings.Ratings.BLOCK_0, 1,
TranslatableCaption.of("ratings.0-8").getComponent(player) TranslatableCaption.miniMessage("ratings.0-8").getComponent(player)
)); ));
inventory.setItem(1, new PlotItemStack(Settings.Ratings.BLOCK_1, 1, inventory.setItem(1, new PlotItemStack(Settings.Ratings.BLOCK_1, 1,
TranslatableCaption.of("ratings.1-8").getComponent(player) TranslatableCaption.miniMessage("ratings.1-8").getComponent(player)
)); ));
inventory.setItem(2, new PlotItemStack(Settings.Ratings.BLOCK_2, 2, inventory.setItem(2, new PlotItemStack(Settings.Ratings.BLOCK_2, 2,
TranslatableCaption.of("ratings.2-8").getComponent(player) TranslatableCaption.miniMessage("ratings.2-8").getComponent(player)
)); ));
inventory.setItem(3, new PlotItemStack(Settings.Ratings.BLOCK_3, 3, inventory.setItem(3, new PlotItemStack(Settings.Ratings.BLOCK_3, 3,
TranslatableCaption.of("ratings.3-8").getComponent(player) TranslatableCaption.miniMessage("ratings.3-8").getComponent(player)
)); ));
inventory.setItem(4, new PlotItemStack(Settings.Ratings.BLOCK_4, 4, inventory.setItem(4, new PlotItemStack(Settings.Ratings.BLOCK_4, 4,
TranslatableCaption.of("ratings.4-8").getComponent(player) TranslatableCaption.miniMessage("ratings.4-8").getComponent(player)
)); ));
inventory.setItem(5, new PlotItemStack(Settings.Ratings.BLOCK_5, 5, inventory.setItem(5, new PlotItemStack(Settings.Ratings.BLOCK_5, 5,
TranslatableCaption.of("ratings.5-8").getComponent(player) TranslatableCaption.miniMessage("ratings.5-8").getComponent(player)
)); ));
inventory.setItem(6, new PlotItemStack(Settings.Ratings.BLOCK_6, 6, inventory.setItem(6, new PlotItemStack(Settings.Ratings.BLOCK_6, 6,
TranslatableCaption.of("ratings.6-8").getComponent(player) TranslatableCaption.miniMessage("ratings.6-8").getComponent(player)
)); ));
inventory.setItem(7, new PlotItemStack(Settings.Ratings.BLOCK_7, 7, inventory.setItem(7, new PlotItemStack(Settings.Ratings.BLOCK_7, 7,
TranslatableCaption.of("ratings.7-8").getComponent(player) TranslatableCaption.miniMessage("ratings.7-8").getComponent(player)
)); ));
inventory.setItem(8, new PlotItemStack(Settings.Ratings.BLOCK_8, 8, inventory.setItem(8, new PlotItemStack(Settings.Ratings.BLOCK_8, 8,
TranslatableCaption.of("ratings.8-8").getComponent(player) TranslatableCaption.miniMessage("ratings.8-8").getComponent(player)
)); ));
inventory.openInventory(); inventory.openInventory();
} }
@ -228,7 +228,7 @@ public class Rate extends SubCommand {
return true; return true;
} }
if (args.length < 1) { if (args.length < 1) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_valid"));
return true; return true;
} }
String arg = args[0]; String arg = args[0];
@ -236,19 +236,19 @@ public class Rate extends SubCommand {
if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) { if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) {
rating = Integer.parseInt(arg); rating = Integer.parseInt(arg);
if (rating > 10 || rating < 1) { if (rating > 10 || rating < 1) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_valid"));
return false; return false;
} }
} else { } else {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid")); player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_valid"));
return false; return false;
} }
final UUID uuid = player.getUUID(); final UUID uuid = player.getUUID();
final Runnable run = () -> { final Runnable run = () -> {
if (plot.getRatings().containsKey(uuid)) { if (plot.getRatings().containsKey(uuid)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("ratings.rating_already_exists"), TranslatableCaption.miniMessage("ratings.rating_already_exists"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
return; return;
} }
@ -257,8 +257,8 @@ public class Rate extends SubCommand {
if (event.getRating() != null) { if (event.getRating() != null) {
plot.addRating(uuid, event.getRating()); plot.addRating(uuid, event.getRating());
player.sendMessage( player.sendMessage(
TranslatableCaption.of("ratings.rating_applied"), TranslatableCaption.miniMessage("ratings.rating_applied"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
} }
}; };
@ -292,11 +292,11 @@ public class Rate extends SubCommand {
.map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) { .map(completion -> new Command(null, true, completion, "", RequiredType.PLAYER, CommandCategory.INFO) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_RATE) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
private static class MutableInt { private static class MutableInt {

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "regenallroads", @CommandDeclaration(command = "regenallroads",
@ -64,44 +64,44 @@ public class RegenAllRoads extends SubCommand {
height = Integer.parseInt(args[1]); height = Integer.parseInt(args[1]);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"), TranslatableCaption.miniMessage("invalid.not_valid_number"),
Template.of("value", "(0, 256)") Placeholder.miniMessage("value", "(0, 256)")
); );
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot regenallroads <world> [height]") Placeholder.miniMessage("value", "/plot regenallroads <world> [height]")
); );
return false; return false;
} }
} else if (args.length != 1) { } else if (args.length != 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "/plot regenallroads <world> [height]") Placeholder.miniMessage("value", "/plot regenallroads <world> [height]")
); );
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"), TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
return false; return false;
} }
String name = args[0]; String name = args[0];
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) { if (!(manager instanceof HybridPlotManager)) {
player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_plot_world"));
return false; return false;
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("debugroadregen.schematic"), TranslatableCaption.miniMessage("debugroadregen.schematic"),
Template.of("command", "/plot createroadschematic") Placeholder.miniMessage("command", "/plot createroadschematic")
); );
player.sendMessage(TranslatableCaption.of("debugroadregen.regenallroads_started")); player.sendMessage(TranslatableCaption.miniMessage("debugroadregen.regenallroads_started"));
boolean result = this.hybridUtils.scheduleRoadUpdate(area, height); boolean result = this.hybridUtils.scheduleRoadUpdate(area, height);
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress")); player.sendMessage(TranslatableCaption.miniMessage("debugexec.mass_schematic_update_in_progress"));
return false; return false;
} }
return true; return true;

View File

@ -120,10 +120,10 @@ public class Reload extends SubCommand {
} }
}); });
this.worldConfiguration.save(this.worldFile); this.worldConfiguration.save(this.worldFile);
player.sendMessage(TranslatableCaption.of("reload.reloaded_configs")); player.sendMessage(TranslatableCaption.miniMessage("reload.reloaded_configs"));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
player.sendMessage(TranslatableCaption.of("reload.reload_failed")); player.sendMessage(TranslatableCaption.miniMessage("reload.reload_failed"));
} }
return true; return true;
} }

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection; import java.util.Collection;
@ -65,28 +65,28 @@ public class Remove extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_REMOVE)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_REMOVE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return true; return true;
} }
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> { PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
int count = 0; int count = 0;
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
return; return;
} else if (throwable != null) { } else if (throwable != null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
return; return;
} else if (!uuids.isEmpty()) { } else if (!uuids.isEmpty()) {
@ -122,13 +122,13 @@ public class Remove extends SubCommand {
} }
if (count == 0) { if (count == 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.miniMessage("errors.invalid_player"),
Template.of("value", args[0]) Placeholder.miniMessage("value", args[0])
); );
} else { } else {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("member.removed_players"), TranslatableCaption.miniMessage("member.removed_players"),
Template.of("amount", count + "") Placeholder.miniMessage("amount", count + "")
); );
} }
}); });
@ -142,7 +142,7 @@ public class Remove extends SubCommand {
if (plot == null) { if (plot == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
return TabCompletions.completeAddedPlayers(plot, String.join(",", args).trim(), return TabCompletions.completeAddedPlayers(player, plot, String.join(",", args).trim(),
Collections.singletonList(player.getName()) Collections.singletonList(player.getName())
); );
} }

View File

@ -31,9 +31,9 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
public enum RequiredType { public enum RequiredType {
CONSOLE(TranslatableCaption.of("console.not_console")), CONSOLE(TranslatableCaption.miniMessage("console.not_console")),
PLAYER(TranslatableCaption.of("console.is_console")), PLAYER(TranslatableCaption.miniMessage("console.is_console")),
NONE(StaticCaption.of("Something went wrong: RequiredType=NONE")); // this caption should never be sent NONE(StaticCaption.miniMessage("Something went wrong: RequiredType=NONE")); // this caption should never be sent
private final Caption caption; private final Caption caption;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.URL; import java.net.URL;
@ -73,29 +73,29 @@ public class Save extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, final String[] args) { public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
final String world = player.getLocation().getWorldName(); final String world = player.getLocation().getWorldName();
if (!this.plotAreaManager.hasPlotArea(world)) { if (!this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false; return false;
} }
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SAVE)) { .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SAVE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
plot.addRunning(); plot.addRunning();
@ -117,13 +117,13 @@ public class Save extends SubCommand {
public void run(URL url) { public void run(URL url) {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {
player.sendMessage(TranslatableCaption.of("backups.backup_save_failed")); player.sendMessage(TranslatableCaption.miniMessage("backups.backup_save_failed"));
return; return;
} }
player.sendMessage(TranslatableCaption.of("web.save_success")); player.sendMessage(TranslatableCaption.miniMessage("web.save_success"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.deprecated_commands"), TranslatableCaption.miniMessage("errors.deprecated_commands"),
Template.of("replacement", "/plot download") Placeholder.miniMessage("replacement", "/plot download")
); );
try (final MetaDataAccess<List<String>> schematicAccess = try (final MetaDataAccess<List<String>> schematicAccess =
player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) { player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) {

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.URL; import java.net.URL;
@ -79,8 +79,8 @@ public class SchematicCmd extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Possible values: save, paste, exportall, list") Placeholder.miniMessage("value", "Possible values: save, paste, exportall, list")
); );
return true; return true;
} }
@ -89,39 +89,39 @@ public class SchematicCmd extends SubCommand {
case "paste" -> { case "paste" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_PASTE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_PASTE))
); );
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Possible values: save, paste, exportall, list") Placeholder.miniMessage("value", "Possible values: save, paste, exportall, list")
); );
break; break;
} }
Location loc = player.getLocation(); Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.command.schematic.paste")) { .hasPermission(player, "plots.admin.command.schematic.paste")) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
if (this.running) { if (this.running) {
player.sendMessage(TranslatableCaption.of("error.task_in_process")); player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false; return false;
} }
final String location = args[1]; final String location = args[1];
@ -137,8 +137,8 @@ public class SchematicCmd extends SubCommand {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid"), TranslatableCaption.miniMessage("schematics.schematic_invalid"),
Template.of("reason", "non-existent url: " + location) Placeholder.miniMessage("reason", "non-existent url: " + location)
); );
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
return; return;
@ -153,8 +153,8 @@ public class SchematicCmd extends SubCommand {
if (schematic == null) { if (schematic == null) {
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid"), TranslatableCaption.miniMessage("schematics.schematic_invalid"),
Template.of("reason", "non-existent or not in gzip format") Placeholder.miniMessage("reason", "non-existent or not in gzip format")
); );
return; return;
} }
@ -166,14 +166,14 @@ public class SchematicCmd extends SubCommand {
0, 0,
false, false,
player, player,
new RunnableVal<Boolean>() { new RunnableVal<>() {
@Override @Override
public void run(Boolean value) { public void run(Boolean value) {
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
if (value) { if (value) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_success"));
} else { } else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_failed"));
} }
} }
} }
@ -184,108 +184,108 @@ public class SchematicCmd extends SubCommand {
Location loc = player.getLocation(); Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (!(player instanceof ConsolePlayer)) { if (!(player instanceof ConsolePlayer)) {
player.sendMessage(TranslatableCaption.of("console.not_console")); player.sendMessage(TranslatableCaption.miniMessage("console.not_console"));
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_world_args")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_world_args"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Use /plot schematic exportall <area>") Placeholder.miniMessage("value", "Use /plot schematic exportall <area>")
); );
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"), TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Template.of("value", args[1]) Placeholder.miniMessage("value", args[1])
); );
return false; return false;
} }
Collection<Plot> plots = area.getPlots(); Collection<Plot> plots = area.getPlots();
if (plots.isEmpty()) { if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("schematic.schematic_exportall_world")); player.sendMessage(TranslatableCaption.miniMessage("schematic.schematic_exportall_world"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Use /plot sch exportall <area>") Placeholder.miniMessage("value", "Use /plot sch exportall <area>")
); );
return false; return false;
} }
boolean result = this.schematicHandler.exportAll(plots, null, null, boolean result = this.schematicHandler.exportAll(plots, null, null,
() -> player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_finished")) () -> player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_finished"))
); );
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("error.task_in_process")); player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false; return false;
} else { } else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_started"));
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.plot_to_schem"), TranslatableCaption.miniMessage("schematics.plot_to_schem"),
Template.of("amount", String.valueOf(plots.size())) Placeholder.miniMessage("amount", String.valueOf(plots.size()))
); );
} }
} }
case "export", "save" -> { case "export", "save" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_SAVE)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_SAVE))
); );
return false; return false;
} }
if (this.running) { if (this.running) {
player.sendMessage(TranslatableCaption.of("error.task_in_process")); player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false; return false;
} }
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.command.schematic.save")) { .hasPermission(player, "plots.admin.command.schematic.save")) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
ArrayList<Plot> plots = Lists.newArrayList(plot); ArrayList<Plot> plots = Lists.newArrayList(plot);
boolean result = this.schematicHandler.exportAll(plots, null, null, () -> { boolean result = this.schematicHandler.exportAll(plots, null, null, () -> {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_single_finished")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_single_finished"));
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
}); });
if (!result) { if (!result) {
player.sendMessage(TranslatableCaption.of("error.task_in_process")); player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false; return false;
} else { } else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_started"));
} }
} }
case "list" -> { case "list" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_LIST)) Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_LIST))
); );
return false; return false;
} }
final String string = StringMan.join(this.schematicHandler.getSchematicNames(), "$2, $1"); final String string = StringMan.join(this.schematicHandler.getSchematicNames(), "$2, $1");
player.sendMessage( player.sendMessage(
TranslatableCaption.of("schematics.schematic_list"), TranslatableCaption.miniMessage("schematics.schematic_list"),
Template.of("list", string) Placeholder.miniMessage("list", string)
); );
} }
default -> player.sendMessage( default -> player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Possible values: save, paste, exportall, list") Placeholder.miniMessage("value", "Possible values: save, paste, exportall, list")
); );
} }
return true; return true;
@ -317,11 +317,11 @@ public class SchematicCmd extends SubCommand {
) { ) {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} }
return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList()); return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList());
} }
} }

View File

@ -47,7 +47,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
@ -129,8 +129,8 @@ public class Set extends SubCommand {
continue; continue;
} }
player.sendMessage( player.sendMessage(
TranslatableCaption.of("invalid.component_illegal_block"), TranslatableCaption.miniMessage("invalid.component_illegal_block"),
Template.of("value", forbiddenType) Placeholder.miniMessage("value", forbiddenType)
); );
return true; return true;
} }
@ -141,20 +141,20 @@ public class Set extends SubCommand {
if (component.equalsIgnoreCase(args[0])) { if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SET_COMPONENT.format(component))) { if (!Permissions.hasPermission(player, Permission.PERMISSION_SET_COMPONENT.format(component))) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_SET_COMPONENT.format(component)) Placeholder.miniMessage("node", Permission.PERMISSION_SET_COMPONENT.format(component))
); );
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
player.sendMessage(TranslatableCaption.of("need.need_block")); player.sendMessage(TranslatableCaption.miniMessage("need.need_block"));
return true; return true;
} }
Pattern pattern = PatternUtil.parse(player, material, false); Pattern pattern = PatternUtil.parse(player, material, false);
if (plot.getRunning() > 0) { if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false; return false;
} }
@ -164,8 +164,8 @@ public class Set extends SubCommand {
queue.setCompleteTask(() -> { queue.setCompleteTask(() -> {
plot.removeRunning(); plot.removeRunning();
player.sendMessage( player.sendMessage(
TranslatableCaption.of("working.component_complete"), TranslatableCaption.miniMessage("working.component_complete"),
Template.of("plot", plot.getId().toString()) Placeholder.miniMessage("plot", plot.getId().toString())
); );
}); });
if (Settings.QUEUE.NOTIFY_PROGRESS) { if (Settings.QUEUE.NOTIFY_PROGRESS) {
@ -180,7 +180,7 @@ public class Set extends SubCommand {
current.getPlotModificationManager().setComponent(component, pattern, player, queue); current.getPlotModificationManager().setComponent(component, pattern, player, queue);
} }
queue.enqueue(); queue.enqueue();
player.sendMessage(TranslatableCaption.of("working.generating_component")); player.sendMessage(TranslatableCaption.miniMessage("working.generating_component"));
}); });
return true; return true;
} }
@ -204,10 +204,10 @@ public class Set extends SubCommand {
if (plot != null) { if (plot != null) {
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId()))); newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
} }
player.sendMessage(StaticCaption.of(TranslatableCaption player.sendMessage(StaticCaption.miniMessage(TranslatableCaption
.of("commandconfig.subcommand_set_options_header_only") .miniMessage("commandconfig.subcommand_set_options_header_only")
.getComponent(player) + StringMan .getComponent(player) + StringMan
.join(newValues, TranslatableCaption.of("blocklist.block_list_separator").getComponent(player)))); .join(newValues, TranslatableCaption.miniMessage("blocklist.block_list_separator").getComponent(player))));
return false; return false;
} }
@ -227,11 +227,11 @@ public class Set extends SubCommand {
// Additional checks // Additional checks
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (plot.getVolume() > Integer.MAX_VALUE) { if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large")); player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false; return false;
} }
// components // components
@ -288,7 +288,7 @@ public class Set extends SubCommand {
}).collect(Collectors.toCollection(LinkedList::new)); }).collect(Collectors.toCollection(LinkedList::new));
if (Permissions.hasPermission(player, Permission.PERMISSION_SET) && args[0].length() > 0) { if (Permissions.hasPermission(player, Permission.PERMISSION_SET) && args[0].length() > 0) {
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} else if (args.length > 1) { } else if (args.length > 1) {

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
public abstract class SetCommand extends SubCommand { public abstract class SetCommand extends SubCommand {
@ -41,26 +41,26 @@ public abstract class SetCommand extends SubCommand {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) { if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId())) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))
); );
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
return false; return false;
} }
} }
if (!plot.isOwner(player.getUUID())) { if (!plot.isOwner(player.getUUID())) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) { if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("permission.no_permission"), TranslatableCaption.miniMessage("permission.no_permission"),
Template.of("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId())) Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))
); );
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false; return false;
} }
} }

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "sethome", @CommandDeclaration(command = "sethome",
permission = "plots.set.home", permission = "plots.set.home",
@ -43,14 +43,14 @@ public class SetHome extends SetCommand {
@Override @Override
public boolean set(PlotPlayer<?> player, Plot plot, String value) { public boolean set(PlotPlayer<?> player, Plot plot, String value) {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned")); player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false; return false;
} }
switch (value.toLowerCase()) { switch (value.toLowerCase()) {
case "unset", "reset", "remove", "none" -> { case "unset", "reset", "remove", "none" -> {
Plot base = plot.getBasePlot(false); Plot base = plot.getBasePlot(false);
base.setHome(null); base.setHome(null);
player.sendMessage(TranslatableCaption.of("position.position_unset")); player.sendMessage(TranslatableCaption.miniMessage("position.position_unset"));
return true; return true;
} }
case "" -> { case "" -> {
@ -61,13 +61,13 @@ public class SetHome extends SetCommand {
location.getZ() - bottom.getZ(), location.getYaw(), location.getPitch() location.getZ() - bottom.getZ(), location.getYaw(), location.getPitch()
); );
base.setHome(rel); base.setHome(rel);
player.sendMessage(TranslatableCaption.of("position.position_set")); player.sendMessage(TranslatableCaption.miniMessage("position.position_set"));
return true; return true;
} }
default -> { default -> {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"), TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Template.of("value", "Use /plot set home [none]") Placeholder.miniMessage("value", "Use /plot set home [none]")
); );
return false; return false;
} }

Some files were not shown because too many files have changed in this diff Show More