Compare commits
239
Commits
v2.16.0
...
maven-wrapper
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b46b0adae | ||
|
|
0f15609401 | ||
|
|
ffa738afcc | ||
|
|
2cecee8f21 | ||
|
|
5e7f246de9 | ||
|
|
e97718ec5a | ||
|
|
4867eda532 | ||
|
|
4fa1aeaccc | ||
|
|
1b44edeec5 | ||
|
|
d21dc02dff | ||
|
|
ad6bb7b13b | ||
|
|
8269d80831 | ||
|
|
57b9987e9b | ||
|
|
f8ce0f415f | ||
|
|
3ef3169942 | ||
|
|
5cf64a672d | ||
|
|
c49b2d9dc2 | ||
|
|
8801e8e855 | ||
|
|
bc4775c293 | ||
|
|
74e39c2666 | ||
|
|
f73e798e65 | ||
|
|
f101ea4768 | ||
|
|
f5d547ab27 | ||
|
|
7fcb964f41 | ||
|
|
d4f1a74dee | ||
|
|
3e192a70da | ||
|
|
103f1e56c7 | ||
|
|
103b4055f3 | ||
|
|
c91442cd1e | ||
|
|
e368ead04a | ||
|
|
d68ec28f8e | ||
|
|
2f4ad00f1c | ||
|
|
524e407620 | ||
|
|
992166de66 | ||
|
|
0b74355467 | ||
|
|
105a8cad51 | ||
|
|
0f693329ca | ||
|
|
263d129325 | ||
|
|
442096e9da | ||
|
|
36084dbfa3 | ||
|
|
8a05dbbf00 | ||
|
|
8a3529377f | ||
|
|
5f519c477a | ||
|
|
7eb748bb9a | ||
|
|
18507016a8 | ||
|
|
ed243f72ec | ||
|
|
5021b8ad7b | ||
|
|
f98868c776 | ||
|
|
2850e59d37 | ||
|
|
86d4fac938 | ||
|
|
0258a75c81 | ||
|
|
61dcb3d440 | ||
|
|
bf1033af76 | ||
|
|
807d39afeb | ||
|
|
bc046d4b2a | ||
|
|
545dd1652f | ||
|
|
e9ec283ace | ||
|
|
718868b2d9 | ||
|
|
2a139aba03 | ||
|
|
046aa1d96d | ||
|
|
e44775e994 | ||
|
|
43da5bd1f1 | ||
|
|
8fa465da38 | ||
|
|
56c7908c33 | ||
|
|
fc81e76521 | ||
|
|
f7fe5c4ad4 | ||
|
|
8f4f763c37 | ||
|
|
7a37382264 | ||
|
|
7f9d133051 | ||
|
|
26ba9f7329 | ||
|
|
d8cb61b0fc | ||
|
|
3f1b06dcf9 | ||
|
|
b043eb0742 | ||
|
|
7691a4b719 | ||
|
|
87ece22036 | ||
|
|
f7e7ec6624 | ||
|
|
25197cdd72 | ||
|
|
30a501c063 | ||
|
|
f14c425488 | ||
|
|
cc2e32984d | ||
|
|
2c9b0f98fe | ||
|
|
f484bc16c6 | ||
|
|
37f0ecff50 | ||
|
|
c8969f2196 | ||
|
|
b9c3cfd640 | ||
|
|
a440834347 | ||
|
|
1adec0b89d | ||
|
|
d56a0a979a | ||
|
|
af07988103 | ||
|
|
96a13d8d6c | ||
|
|
2a1ad5b5c8 | ||
|
|
1311423a17 | ||
|
|
59e9c4caed | ||
|
|
4ab53d1613 | ||
|
|
2ea744443f | ||
|
|
8bd8bb6466 | ||
|
|
e7f756f306 | ||
|
|
b7961acd5c | ||
|
|
c47289c5bf | ||
|
|
7769060f4d | ||
|
|
a859928622 | ||
|
|
becb88b763 | ||
|
|
711f81f3da | ||
|
|
7fae6f8b8a | ||
|
|
62a8d304f4 | ||
|
|
fe8668abb0 | ||
|
|
36f5739f06 | ||
|
|
f7465941b2 | ||
|
|
2aa5b9aad3 | ||
|
|
51f82ba988 | ||
|
|
327bcf3980 | ||
|
|
5c3bb558cf | ||
|
|
c726e2bb3c | ||
|
|
af6c72eda9 | ||
|
|
d48c17f1f9 | ||
|
|
93eef5c727 | ||
|
|
714aa10701 | ||
|
|
b2d271b23b | ||
|
|
7dad746269 | ||
|
|
37399cd50b | ||
|
|
132eac98e2 | ||
|
|
ba68e8f70a | ||
|
|
0d3542b4aa | ||
|
|
94eed8710c | ||
|
|
0d3d4981c0 | ||
|
|
73fa75fccc | ||
|
|
a855b51617 | ||
|
|
83e7ad4ae1 | ||
|
|
05cddb7e7f | ||
|
|
8d1ed8cf41 | ||
|
|
f8862299f2 | ||
|
|
1de339addc | ||
|
|
e929b58cd7 | ||
|
|
237755b5d5 | ||
|
|
c648343cdc | ||
|
|
f34b9273cc | ||
|
|
d07bc160e6 | ||
|
|
6f1f919977 | ||
|
|
12a5aa92bb | ||
|
|
5d7ad0808d | ||
|
|
ac0e2f2116 | ||
|
|
2d553234a3 | ||
|
|
e4588fe1ef | ||
|
|
4221cc2fa1 | ||
|
|
5db69775a3 | ||
|
|
88f61a150f | ||
|
|
f0df4435be | ||
|
|
05c0f734b5 | ||
|
|
4f0b721d49 | ||
|
|
3ebb041a3f | ||
|
|
3b8dc4992d | ||
|
|
16be0c12a0 | ||
|
|
18c7c41ac4 | ||
|
|
cb201eb4b8 | ||
|
|
7a8ac9509b | ||
|
|
587bd9b445 | ||
|
|
6419e16eb0 | ||
|
|
59d2bfc5f8 | ||
|
|
e452441380 | ||
|
|
4d8fc0f0e5 | ||
|
|
6bbb12e901 | ||
|
|
002939f2df | ||
|
|
6f27da4bdb | ||
|
|
268f4752d6 | ||
|
|
204858dee7 | ||
|
|
a0ced58a02 | ||
|
|
b8cbf831b3 | ||
|
|
d6ec0c3a3d | ||
|
|
bf3fc03f93 | ||
|
|
52348096a0 | ||
|
|
00a48b24dd | ||
|
|
c9aae0d781 | ||
|
|
d0bba163a0 | ||
|
|
cd0e75483a | ||
|
|
2c365c5d54 | ||
|
|
9704562353 | ||
|
|
836fc9d6a0 | ||
|
|
cd01b0cd47 | ||
|
|
d797ab0908 | ||
|
|
fd58f4abda | ||
|
|
6653c6f8c0 | ||
|
|
4dee178403 | ||
|
|
908451c65c | ||
|
|
d468bd0df2 | ||
|
|
3779585645 | ||
|
|
c346fdf967 | ||
|
|
240a782774 | ||
|
|
dce26a784f | ||
|
|
3cac8067a6 | ||
|
|
993578f13e | ||
|
|
96da1b3936 | ||
|
|
2fc8a1aa1b | ||
|
|
b4cf94dab2 | ||
|
|
a793e933ae | ||
|
|
a0ec61cec7 | ||
|
|
10b24b99a2 | ||
|
|
4ed174970e | ||
|
|
f7b4f5dfd9 | ||
|
|
8b7d8e4a72 | ||
|
|
8ab89cd03f | ||
|
|
47a5948157 | ||
|
|
48e3da9716 | ||
|
|
05ec2241f0 | ||
|
|
4c881f4601 | ||
|
|
71ad4ce160 | ||
|
|
3c2d5c9b81 | ||
|
|
b0a0f951fa | ||
|
|
408647161e | ||
|
|
55f95b405e | ||
|
|
0aeb153293 | ||
|
|
cdc185c8e7 | ||
|
|
1f128e8368 | ||
|
|
2e68e7fe2f | ||
|
|
388d17fe99 | ||
|
|
89d59a39d9 | ||
|
|
d88c14359a | ||
|
|
ae40b35325 | ||
|
|
6a410354e5 | ||
|
|
96c2b8c718 | ||
|
|
4bf0e69734 | ||
|
|
6803b001ce | ||
|
|
366863b63e | ||
|
|
5c391e33c4 | ||
|
|
448cc6093e | ||
|
|
9d910759cb | ||
|
|
cdc1808078 | ||
|
|
87541f9742 | ||
|
|
54f3f4ba40 | ||
|
|
4e8850e734 | ||
|
|
9e55a00d68 | ||
|
|
f898631ace | ||
|
|
f71a84a70e | ||
|
|
b51f27e68b | ||
|
|
ad38548440 | ||
|
|
f69207f0d4 | ||
|
|
9fb42b7093 | ||
|
|
bf0670cb88 | ||
|
|
d4507f41fa | ||
|
|
41a978a278 |
No files matched your search
+13
-14
@@ -1,38 +1,37 @@
|
||||
# This workflow will build a Java project with Maven
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Java CI Dev Build
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ dev ]
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ dev ]
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
java-version: [ 8, 11, 16 ]
|
||||
|
||||
java-version: [ 16, 17 ]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: Java ${{ matrix.java-version }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: "Set up JDK ${{ matrix.java-version }}"
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: "${{ matrix.java-version }}"
|
||||
distribution: 'adopt'
|
||||
cache: maven
|
||||
cache: 'maven'
|
||||
- name: Build with Maven
|
||||
run: mvn -B -U package --file pom.xml
|
||||
- name: Upload a Build Artifact
|
||||
if: "${{ matrix.java-version == 8 }}"
|
||||
uses: actions/upload-artifact@v2
|
||||
run: ./mvnw -B -U package --file pom.xml
|
||||
- name: Upload Build Artifact
|
||||
if: "${{ matrix.java-version == 16 }}"
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: SimpleClans
|
||||
path: target/SimpleClans.jar
|
||||
@@ -4,17 +4,18 @@ on:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 16
|
||||
cache: 'maven'
|
||||
distribution: 'adopt'
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
run: ./mvnw -B package --file pom.xml
|
||||
- name: Upload artifact
|
||||
uses: itsmeow/curseforge-upload@v3
|
||||
with:
|
||||
@@ -23,7 +24,8 @@ jobs:
|
||||
game_endpoint: minecraft
|
||||
file_path: target/SimpleClans.jar
|
||||
changelog: ${{ github.event.release.body }}
|
||||
changelog_type: markdown
|
||||
display_name: ${{ github.event.release.tag_name }}
|
||||
game_versions: 7915,7667,7330,7105,6588,630,591,585,531
|
||||
game_versions: 8849,8503,7915,7667,7330,7105,6588,630,591,585,531
|
||||
release_type: release
|
||||
relations: vault:optionalDependency,worldguard:optionalDependency,grief-prevention:optionalDependency
|
||||
@@ -0,0 +1,31 @@
|
||||
name: Publish to Modrinth
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 16
|
||||
cache: 'maven'
|
||||
distribution: 'adopt'
|
||||
- name: Build with Maven
|
||||
run: ./mvnw -B package --file pom.xml
|
||||
- name: Upload artifact
|
||||
uses: RubixDev/modrinth-upload@v1.0.0
|
||||
with:
|
||||
token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
project_id: quLDfyDl
|
||||
file_path: target/SimpleClans.jar
|
||||
changelog: ${{ github.event.release.body }}
|
||||
name: ${{ github.event.release.tag_name }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
game_versions: 1.19,1.18,1.17,1.16,1.15,1.14,1.13,1.12,1.11,1.10,1.9,1.8
|
||||
release_type: release
|
||||
loaders: spigot
|
||||
featured: true
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Publish to Reposilite
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 16
|
||||
server-id: reposilite # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
cache: 'maven'
|
||||
distribution: 'adopt'
|
||||
- name: Build with Maven
|
||||
run: ./mvnw -B package --file pom.xml
|
||||
- name: Publish to Reposilite
|
||||
run: ./mvnw -B deploy
|
||||
env:
|
||||
MAVEN_USERNAME: simpleclans
|
||||
MAVEN_PASSWORD: ${{ secrets.REPOSILITE_TOKEN }}
|
||||
@@ -0,0 +1,15 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
name: release-please
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
with:
|
||||
release-type: maven
|
||||
package-name: SimpleClans
|
||||
token: ${{ secrets.PAT_TOKEN }}
|
||||
fork: false
|
||||
+2
-1
@@ -3,7 +3,8 @@
|
||||
/bin/
|
||||
/.classpath
|
||||
/.project
|
||||
/dependency-reduced-pom.xml
|
||||
*.jar
|
||||
.settings
|
||||
.factorypath
|
||||
SimpleClans.iml
|
||||
dependency-reduced-pom.xml
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
# Changelog
|
||||
|
||||
## [2.19.0](https://github.com/RoinujNosde/SimpleClans/compare/v2.18.1...v2.19.0) (2023-07-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add %simpleclans_has_rank% placeholder ([#379](https://github.com/RoinujNosde/SimpleClans/issues/379)) ([f8ce0f4](https://github.com/RoinujNosde/SimpleClans/commit/f8ce0f415f17748f8b4382e028dd1f5f93cae06a))
|
||||
* add a command to set player's locale ([#378](https://github.com/RoinujNosde/SimpleClans/issues/378)) ([5cf64a6](https://github.com/RoinujNosde/SimpleClans/commit/5cf64a672d0a25a62d3abd6720082bb3b4cf056f))
|
||||
* add confirmation before reset kdr ([#371](https://github.com/RoinujNosde/SimpleClans/issues/371)) ([d4f1a74](https://github.com/RoinujNosde/SimpleClans/commit/d4f1a74dee9cdeeb458ff6975715a817bfe30fa1))
|
||||
* add PlayerResetKdrEvent ([#370](https://github.com/RoinujNosde/SimpleClans/issues/370)) ([d68ec28](https://github.com/RoinujNosde/SimpleClans/commit/d68ec28f8e14926cbe9d13c09a61735e5304a97d))
|
||||
* add subcommand /clan mod bb display ([#367](https://github.com/RoinujNosde/SimpleClans/issues/367)) ([105a8ca](https://github.com/RoinujNosde/SimpleClans/commit/105a8cad51b12bf6f487cf6c2b81eb85d966a3cc))
|
||||
* adds the possibility to rename a clan ([#360](https://github.com/RoinujNosde/SimpleClans/issues/360)) ([0f69332](https://github.com/RoinujNosde/SimpleClans/commit/0f693329cae81036bfe1423344ed41cf3d535f64))
|
||||
* bb message language key ([#358](https://github.com/RoinujNosde/SimpleClans/issues/358)) ([263d129](https://github.com/RoinujNosde/SimpleClans/commit/263d129325888fb1303dda549986ab43ca93ed13))
|
||||
* **chat:** adds permissions to use colors and formats ([#341](https://github.com/RoinujNosde/SimpleClans/issues/341)) ([2a139ab](https://github.com/RoinujNosde/SimpleClans/commit/2a139aba03be174086dfb3603007312d0c7a6c33))
|
||||
* EconomyTransactionEvent creation ([#384](https://github.com/RoinujNosde/SimpleClans/issues/384)) ([d21dc02](https://github.com/RoinujNosde/SimpleClans/commit/d21dc02dff45f4f20a40303cd26215a71de7dddb))
|
||||
* hide reset kdr in main frame if perm denied ([#385](https://github.com/RoinujNosde/SimpleClans/issues/385)) ([ad6bb7b](https://github.com/RoinujNosde/SimpleClans/commit/ad6bb7b13b347be71789fbfb4b8a82f6c5481c96))
|
||||
* validating tag by regex ([#363](https://github.com/RoinujNosde/SimpleClans/issues/363)) ([3ef3169](https://github.com/RoinujNosde/SimpleClans/commit/3ef3169942f897280af15040f1243d955df001ab))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* added clan suggestion in staff bb commands ([#359](https://github.com/RoinujNosde/SimpleClans/issues/359)) ([442096e](https://github.com/RoinujNosde/SimpleClans/commit/442096e9da98410682c2cd09e0e930454fe0364f))
|
||||
* async permission reset & category deletion ([#347](https://github.com/RoinujNosde/SimpleClans/issues/347)) ([7eb748b](https://github.com/RoinujNosde/SimpleClans/commit/7eb748bb9a31a826f53fd7ac6b1eeac64e330467))
|
||||
* bump JDK to 16 ([e368ead](https://github.com/RoinujNosde/SimpleClans/commit/e368ead04aa2735f5525d88d5dcb63b78286f80e))
|
||||
* **bungee:** removes players from clan on delete ([0258a75](https://github.com/RoinujNosde/SimpleClans/commit/0258a75c819f12e5dbbaf383a572682717f34c59))
|
||||
* **bungee:** updates kills count immediately ([ed243f7](https://github.com/RoinujNosde/SimpleClans/commit/ed243f72ecc58a3af11d053d73b315bce9e20e94))
|
||||
* default username-regex ([bf1033a](https://github.com/RoinujNosde/SimpleClans/commit/bf1033af769bacbca9a790d2184ec77eeb519485))
|
||||
* **discord:** permission overrides reset only existing members ([#349](https://github.com/RoinujNosde/SimpleClans/issues/349)) ([8a35293](https://github.com/RoinujNosde/SimpleClans/commit/8a3529377f5b4a482b530e474e4921b311197a04))
|
||||
* display hex message on bulletin board ([#365](https://github.com/RoinujNosde/SimpleClans/issues/365)) ([0b74355](https://github.com/RoinujNosde/SimpleClans/commit/0b74355467625a4901944c72feb84d8de91a4283))
|
||||
* invalid colors being used in tags ([2850e59](https://github.com/RoinujNosde/SimpleClans/commit/2850e59d370da34c643de198de85d91744610467))
|
||||
* invalid colors being used in tags, pt. 2 ([f98868c](https://github.com/RoinujNosde/SimpleClans/commit/f98868c776a2e275dc7c1647748a0231e935f43e))
|
||||
* migrates land permissions on GP claim resize ([2f4ad00](https://github.com/RoinujNosde/SimpleClans/commit/2f4ad00f1c72ee7e3948267965c3a075ec4ef728))
|
||||
* NPE on EntityDamageByEntityEvent listener (LandProtection) ([524e407](https://github.com/RoinujNosde/SimpleClans/commit/524e40762011dd500a407286b72b51acf6c357f3))
|
||||
* players not able to break vehicles/exit horses ([86d4fac](https://github.com/RoinujNosde/SimpleClans/commit/86d4fac938e353f94c288c39b884027027972bba))
|
||||
* players not able to sleep on beds (WorldGuard) ([e9ec283](https://github.com/RoinujNosde/SimpleClans/commit/e9ec283ace55af10abdeb6f937d31d4c2dc198dc))
|
||||
* players not able to strip logs/fertilize blocks ([5021b8a](https://github.com/RoinujNosde/SimpleClans/commit/5021b8ad7b5633769bd87af96a0226a53a8b24b4))
|
||||
* players not able to use water buckets (WorldGuard) ([807d39a](https://github.com/RoinujNosde/SimpleClans/commit/807d39afeb51d99a96fb793099393b44e2c43b04))
|
||||
* players unable to interact with armor stands, paintings, etc ([61dcb3d](https://github.com/RoinujNosde/SimpleClans/commit/61dcb3d440e2eedfb717afcc69687194311a8973))
|
||||
* possibly fixes CME on SpyChatHandler ([8a05dbb](https://github.com/RoinujNosde/SimpleClans/commit/8a05dbbf00df97afa7df71a500e2626aaa46ed37))
|
||||
* prevent clan name renaming with colors ([#374](https://github.com/RoinujNosde/SimpleClans/issues/374)) ([7fcb964](https://github.com/RoinujNosde/SimpleClans/commit/7fcb964f41118e7d8746e87d5770cc329730834c))
|
||||
* remove abandoned channels before validating ([#348](https://github.com/RoinujNosde/SimpleClans/issues/348)) ([5f519c4](https://github.com/RoinujNosde/SimpleClans/commit/5f519c477af3e759596017010d51ddd06e26157e))
|
||||
* resets error message when validating a clan tag ([#383](https://github.com/RoinujNosde/SimpleClans/issues/383)) ([8269d80](https://github.com/RoinujNosde/SimpleClans/commit/8269d80831533e517ed2ebd94bec18021de7b0e3))
|
||||
* sets duplicate names to something unique ([046aa1d](https://github.com/RoinujNosde/SimpleClans/commit/046aa1d96d58e21496a3361c7d072f3943595304))
|
||||
* tnt explosion doesn't count a kill ([#381](https://github.com/RoinujNosde/SimpleClans/issues/381)) ([57b9987](https://github.com/RoinujNosde/SimpleClans/commit/57b9987e9b9dade59c52c88dbfd3b12fdf5eee94))
|
||||
* view permission applies only to cached channels ([#346](https://github.com/RoinujNosde/SimpleClans/issues/346)) ([1850701](https://github.com/RoinujNosde/SimpleClans/commit/18507016a843c28efc6d8109f2bb5a5106531f47))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **discord:** remove discord channels from creation ([#353](https://github.com/RoinujNosde/SimpleClans/issues/353)) ([36084db](https://github.com/RoinujNosde/SimpleClans/commit/36084dbfa3e73aedccb156e49af5062e40639927))
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* author tag isn't available at methods ([f5d547a](https://github.com/RoinujNosde/SimpleClans/commit/f5d547ab27fac7cfe1abd9c819e4f1bb3dd7c624))
|
||||
* updated version in README ([#343](https://github.com/RoinujNosde/SimpleClans/issues/343)) ([718868b](https://github.com/RoinujNosde/SimpleClans/commit/718868b2d9eea2aeb6fcfd734e85d16a2cefaa36))
|
||||
|
||||
## [2.18.1](https://github.com/RoinujNosde/SimpleClans/compare/v2.18.0...v2.18.1) (2022-11-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* added check for clan_member on land commands ([fc81e76](https://github.com/RoinujNosde/SimpleClans/commit/fc81e765211bebe22a7a6aa5d5158754580bbdc5))
|
||||
* attempt at fixing NPE on getAllClanPlayers ([26ba9f7](https://github.com/RoinujNosde/SimpleClans/commit/26ba9f73296a772eaa698d2ede6fbc3831da850c))
|
||||
* **bungee:** error deserializing clan banners ([56c7908](https://github.com/RoinujNosde/SimpleClans/commit/56c7908c332167cec9cca6a4ea054977d0d68b9f))
|
||||
* channel auto creation setting not respected on join/link ([7f9d133](https://github.com/RoinujNosde/SimpleClans/commit/7f9d133051b9011837d0a5114abc6c3637a3f02c))
|
||||
* default ranks were getting re-added on config load ([7a37382](https://github.com/RoinujNosde/SimpleClans/commit/7a37382264ff4dd5456f6930045b5102bf491897))
|
||||
* missing getHandlerList on HomeRegroupEvent ([#338](https://github.com/RoinujNosde/SimpleClans/issues/338)) ([8fa465d](https://github.com/RoinujNosde/SimpleClans/commit/8fa465da385f36b1fb075031c375ef94df78ea52))
|
||||
* money was not given back when channel creation failed ([#336](https://github.com/RoinujNosde/SimpleClans/issues/336)) ([d8cb61b](https://github.com/RoinujNosde/SimpleClans/commit/d8cb61b0fc9584bb58f421faf98596816621053f))
|
||||
* wrong path of discord economy section ([#334](https://github.com/RoinujNosde/SimpleClans/issues/334)) ([3f1b06d](https://github.com/RoinujNosde/SimpleClans/commit/3f1b06dcf996e51a878b7fc281069e236ebcbfce))
|
||||
|
||||
## [2.18.0](https://github.com/RoinujNosde/SimpleClans/compare/v2.17.0...v2.18.0) (2022-10-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add help-size config ([25197cd](https://github.com/RoinujNosde/SimpleClans/commit/25197cdd729cea63d7e223dc1e0aaef830613327))
|
||||
* added method for registering protection providers ([2ea7444](https://github.com/RoinujNosde/SimpleClans/commit/2ea744443f502970b15859818e9d5e45ca69d453))
|
||||
* adds permission to bypass the teleport delay ([d56a0a9](https://github.com/RoinujNosde/SimpleClans/commit/d56a0a979a47a140115742518e934a2469e6f880))
|
||||
* adds PlayerHomeClearEvent ([becb88b](https://github.com/RoinujNosde/SimpleClans/commit/becb88b763380bed5a2e1dd209c32c8363a7f88b))
|
||||
* adds starter-ranks ([a440834](https://github.com/RoinujNosde/SimpleClans/commit/a4408343479d7efa6ae5a65894f8b822ecd47ebb))
|
||||
* Improves Bungee support ([#327](https://github.com/RoinujNosde/SimpleClans/issues/327)) ([2c9b0f9](https://github.com/RoinujNosde/SimpleClans/commit/2c9b0f98fe3942ea74190c1a81d61be2c8647db8))
|
||||
* **lang:** new crowdin updates ([#319](https://github.com/RoinujNosde/SimpleClans/issues/319)) ([87ece22](https://github.com/RoinujNosde/SimpleClans/commit/87ece22036fb674c8c362b6a1b86fe884543e6ad))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* changes size of some frames for better visualization on Bedrock ([1adec0b](https://github.com/RoinujNosde/SimpleClans/commit/1adec0b89d676767cdb94dcdf91ba37a231eb4a8))
|
||||
* ConfigurationSerializableAdapter NPE ([30a501c](https://github.com/RoinujNosde/SimpleClans/commit/30a501c063aa9dbcf596df83adc2b15baf0e4bb9))
|
||||
* getPastClans() preserves the insertion order ([af07988](https://github.com/RoinujNosde/SimpleClans/commit/af079881030bd299b9bae1ebf0cc62353af7e6fc))
|
||||
* NoClassDefFoundError in WorldGuard6Provider ([a859928](https://github.com/RoinujNosde/SimpleClans/commit/a8599286225ba603ea124b8b52510245b94ffd24))
|
||||
* NPE while collecting fees ([c47289c](https://github.com/RoinujNosde/SimpleClans/commit/c47289c5bf8113a9d6a8e1ee74a5afb0358647b6))
|
||||
* NPE while purging data ([f14c425](https://github.com/RoinujNosde/SimpleClans/commit/f14c42548846feef01b484acbb5f02bcbcabd8db))
|
||||
* NPE while sending a message to spies ([#322](https://github.com/RoinujNosde/SimpleClans/issues/322)) ([e7f756f](https://github.com/RoinujNosde/SimpleClans/commit/e7f756f3063c646e21415e08eea73f123d2818a0))
|
||||
* removes duplicate /clan from help ([f7e7ec6](https://github.com/RoinujNosde/SimpleClans/commit/f7e7ec66243359e26d3c456a9740a53753951c48))
|
||||
* removes rank and join date on disband ([2a1ad5b](https://github.com/RoinujNosde/SimpleClans/commit/2a1ad5b5c8d2937a8ee6dd6f7f43d85c86f08307))
|
||||
* set useSSL to false ([f484bc1](https://github.com/RoinujNosde/SimpleClans/commit/f484bc16c6176ccd13e05aae2169400e7bcf5d62))
|
||||
* supports '.' and '*' as username prefix by default ([37f0ecf](https://github.com/RoinujNosde/SimpleClans/commit/37f0ecff506d06f3047e3598848117a14c2b7ead))
|
||||
* updates join date when joining a clan ([#326](https://github.com/RoinujNosde/SimpleClans/issues/326)) ([96a13d8](https://github.com/RoinujNosde/SimpleClans/commit/96a13d8d6cc18c91d4dee20dd632cd5d65db5213))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* improved UUID lookup performance ([4ab53d1](https://github.com/RoinujNosde/SimpleClans/commit/4ab53d16135ecf5a4067b1a63d058da392dc5313))
|
||||
@@ -5,7 +5,7 @@ SimpleClans
|
||||
|
||||
Full featured clan system for PVP Minecraft Servers!
|
||||
|
||||
[](https://travis-ci.com/RoinujNosde/SimpleClans)
|
||||
[](https://ci.roinujnosde.me/job/SimpleClans/)
|
||||
[](https://www.spigotmc.org/resources/simpleclans.71242/)
|
||||
[](https://github.com/RoinujNosde/SimpleClans/issues)
|
||||
[](https://crowdin.com/project/simpleclans)
|
||||
@@ -50,8 +50,8 @@ Including SimpleClans with Maven:
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
<id>roinujnosde-repo</id>
|
||||
<url>https://repo.roinujnosde.me/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
@@ -60,7 +60,7 @@ Including SimpleClans with Maven:
|
||||
<dependency>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.15.0</version> <!-- You can find the latest version at the bottom -->
|
||||
<version>2.18.1</version> <!-- You can find the latest version at the bottom -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -70,15 +70,16 @@ Using Gradle:
|
||||
```groovy
|
||||
repositories {
|
||||
maven {
|
||||
url "https://repo.codemc.org/repository/maven-public"
|
||||
url "https://repo.roinujnosde.me/releases/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.15.0"
|
||||
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.18.1"
|
||||
}
|
||||
```
|
||||
|
||||
Feel free to learn our [Javadoc](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/).
|
||||
##### Latest version:
|
||||
[]()
|
||||
[](https://repo.roinujnosde.me/#/releases/net/sacredlabyrinth/phaed/simpleclans/SimpleClans)
|
||||
##### API Examples
|
||||
* [Examples of how to use the API](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="MavenCustomPomFilePath">
|
||||
<option name="mavenPomFileUrl" value="file://$MODULE_DIR$/dependency-reduced-pom.xml" />
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$/src/main/java">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/src/main/resources">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/src/test/java">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:2.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-base:2.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.10.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:22.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.papermc:paperlib:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-paper:0.5.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.cryptomorin:XSeries:8.3.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.7.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TechFortress:GriefPrevention:16.17.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Core:5.13.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Bukkit:5.13.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-api:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-bukkitapi:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl.vault:VaultAPI:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.discordsrv:discordsrv:1.23.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:4.2.1_262" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.14" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: github.scarsz:configuralize:1.3.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.alexheretic:dynamics:4.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.alexheretic:fluent:2.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-jdk14:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.vdurmont:emoji-java:5.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20170516" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.zafarkhaja:java-semver:0.9.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.kevinsawicki:http-request:6.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-hla:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-dnssec:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-client:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-core:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-iterative-resolver:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-expression:5.2.7.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-core:5.2.7.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-jcl:5.2.7.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: dev.vankka:MCDiscordReserializer:4.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: dev.vankka:SimpleAST:2.2.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-api:4.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-key:4.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.10.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-string:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-legacy:4.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson:4.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-api:4.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-bungeecord:4.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-nbt:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson-legacy-impl:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-facet:4.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-viaversion:4.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-minimessage:4.1.0-20210316.192746" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,3 +1,7 @@
|
||||
pull_request_title: "feat(lang): new crowdin updates"
|
||||
pull_request_labels: ["l10n"]
|
||||
commit_message: "feat(lang): new translations for %language%"
|
||||
append_commit_message: false
|
||||
files:
|
||||
- source: src/main/resources/messages.properties
|
||||
translation: /src/main/resources/%file_name%_%locale_with_underscore%.%file_extension%
|
||||
@@ -1,419 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.16.0</version>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>${project.name}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.acf</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.locales</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.locales</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>org.jetbrains:annotations</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi-repo</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bstats-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.bukkit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>22.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>apiguardian-api</artifactId>
|
||||
<groupId>org.apiguardian</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>opentest4j</artifactId>
|
||||
<groupId>org.opentest4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>junit-platform-commons</artifactId>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>worldguard-core</artifactId>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commandbook</artifactId>
|
||||
<groupId>com.sk89q</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.17.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Bukkit</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<groupId>*</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-bukkitapi</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>Core</artifactId>
|
||||
<groupId>PlotSquared</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.23.0</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>JDA</artifactId>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nv-websocket-client</artifactId>
|
||||
<groupId>com.neovisionaries</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>trove4j</artifactId>
|
||||
<groupId>net.sf.trove4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>configuralize</artifactId>
|
||||
<groupId>github.scarsz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>commons-collections</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<groupId>commons-codec</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>emoji-java</artifactId>
|
||||
<groupId>com.vdurmont</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>java-semver</artifactId>
|
||||
<groupId>com.github.zafarkhaja</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>http-request</artifactId>
|
||||
<groupId>com.github.kevinsawicki</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>minidns-hla</artifactId>
|
||||
<groupId>org.minidns</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>spring-expression</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>MCDiscordReserializer</artifactId>
|
||||
<groupId>dev.vankka</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>codemc-releases</id>
|
||||
<url>https://repo.codemc.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "$(uname)" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
|
||||
else
|
||||
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=$(java-config --jre-home)
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="$(which javac)"
|
||||
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=$(which readlink)
|
||||
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
|
||||
else
|
||||
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
|
||||
fi
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=$(cd "$wdir/.." || exit 1; pwd)
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
# Remove \r in case we run on Windows within Git Bash
|
||||
# and check out the repository with auto CRLF management
|
||||
# enabled. Otherwise, we may read lines that are delimited with
|
||||
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
|
||||
# splitting rules.
|
||||
tr -s '\r\n' ' ' < "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
log() {
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
printf '%s\n' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
|
||||
log "$MAVEN_PROJECTBASEDIR"
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if [ -r "$wrapperJarPath" ]; then
|
||||
log "Found $wrapperJarPath"
|
||||
else
|
||||
log "Couldn't find $wrapperJarPath, downloading it ..."
|
||||
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
else
|
||||
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
fi
|
||||
while IFS="=" read -r key value; do
|
||||
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
|
||||
safeValue=$(echo "$value" | tr -d '\r')
|
||||
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
log "Downloading from: $wrapperUrl"
|
||||
|
||||
if $cygwin; then
|
||||
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
log "Found wget ... using wget"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
log "Found curl ... using curl"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
else
|
||||
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
else
|
||||
log "Falling back to using Java to download"
|
||||
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaSource=$(cygpath --path --windows "$javaSource")
|
||||
javaClass=$(cygpath --path --windows "$javaClass")
|
||||
fi
|
||||
if [ -e "$javaSource" ]; then
|
||||
if [ ! -e "$javaClass" ]; then
|
||||
log " - Compiling MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/javac" "$javaSource")
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
log " - Running MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
wrapperSha256Sum=""
|
||||
while IFS="=" read -r key value; do
|
||||
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ -n "$wrapperSha256Sum" ]; then
|
||||
wrapperSha256Result=false
|
||||
if command -v sha256sum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
elif command -v shasum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
|
||||
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
|
||||
exit 1
|
||||
fi
|
||||
if [ $wrapperSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
|
||||
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
# shellcheck disable=SC2086 # safe args
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||
@@ -0,0 +1,205 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %WRAPPER_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
SET WRAPPER_SHA_256_SUM=""
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
|
||||
)
|
||||
IF NOT %WRAPPER_SHA_256_SUM%=="" (
|
||||
powershell -Command "&{"^
|
||||
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
|
||||
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
|
||||
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
|
||||
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
|
||||
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
|
||||
" exit 1;"^
|
||||
"}"^
|
||||
"}"
|
||||
if ERRORLEVEL 1 goto error
|
||||
)
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.19.1-SNAPSHOT</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
|
||||
@@ -30,13 +30,11 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<release>16</release>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
@@ -47,21 +45,21 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>3.3.0</version>
|
||||
</plugin>
|
||||
|
||||
<!-- Release plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Shade plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
@@ -84,12 +82,23 @@
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.gson</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>org.jetbrains:annotations</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
|
||||
<transformers>
|
||||
<!-- Avoid overlapping MANIFEST.MF file -->
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
|
||||
<resource>MANIFEST.MF</resource>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -100,6 +109,74 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Dependency plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-installed</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>${project.packaging}</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${env.TEST_SERVER}\plugins</outputDirectory>
|
||||
<silent>true</silent>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>4.9.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
<phase>validate</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<release>16</release>
|
||||
<doclint>all,-missing</doclint>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Dependencies -->
|
||||
@@ -115,12 +192,13 @@
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<!-- No idea why, but it fails JUnit 5 tests -->
|
||||
<exclusion>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
@@ -142,25 +220,19 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
<version>8.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
@@ -170,61 +242,34 @@
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.17.1</version>
|
||||
<version>16.18.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Bukkit</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-bukkitapi</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>PlotSquared</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.23.0</version>
|
||||
<version>1.24.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>landlord-latest</artifactId>
|
||||
<version>4.351</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test frameworks -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.9.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Repositories -->
|
||||
@@ -253,18 +298,14 @@
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
@@ -279,12 +320,12 @@
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>codemc-releases</id>
|
||||
<url>https://repo.codemc.io/repository/maven-releases/</url>
|
||||
<id>reposilite</id>
|
||||
<url>https://repo.roinujnosde.me/releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
<id>reposilite</id>
|
||||
<url>https://repo.roinujnosde.me/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -1,3 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: net.sacredlabyrinth.phaed.simpleclans.SimpleClans
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -523,6 +522,9 @@ public class ChatBlock {
|
||||
|
||||
/**
|
||||
* Outputs a single line out, crops overflow
|
||||
*
|
||||
* @param receiver the receiver
|
||||
* @param msg the message
|
||||
*/
|
||||
public static void saySingle(CommandSender receiver, String msg) {
|
||||
if (receiver == null) {
|
||||
@@ -534,6 +536,9 @@ public class ChatBlock {
|
||||
|
||||
/**
|
||||
* Outputs a message to a user
|
||||
*
|
||||
* @param receiver the receiver
|
||||
* @param msg the message
|
||||
*/
|
||||
public static void sendMessage(@Nullable CommandSender receiver, @NotNull String msg) {
|
||||
if (receiver == null) {
|
||||
@@ -541,11 +546,6 @@ public class ChatBlock {
|
||||
}
|
||||
|
||||
receiver.sendMessage(ChatUtils.parseColors(msg));
|
||||
// String[] message = colorize(wordWrap(msg));
|
||||
//
|
||||
// for (String out : message) {
|
||||
// receiver.sendMessage(out);
|
||||
// }
|
||||
}
|
||||
|
||||
public static void sendMessage(@Nullable ClanPlayer receiver, @NotNull String msg) {
|
||||
@@ -553,12 +553,7 @@ public class ChatBlock {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = receiver.toPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatUtils.parseColors(msg));
|
||||
SimpleClans.getInstance().getProxyManager().sendMessage(receiver.getName(), ChatUtils.parseColors(msg));
|
||||
}
|
||||
|
||||
// ClanCommands#setbanner, LandCommands#Allow/BlockCommand/verify, StaffCommands#kick, etc
|
||||
@@ -566,13 +561,19 @@ public class ChatBlock {
|
||||
sendMessage(receiver, lang(key, receiver, args));
|
||||
}
|
||||
|
||||
public static void sendMessageKey(@NotNull ClanPlayer clanPlayer, @NotNull String key, @NotNull Object... args) {
|
||||
sendMessageKey(clanPlayer.toPlayer(), key, args);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void startColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send blank line
|
||||
* Sends a blank line
|
||||
*
|
||||
* @param receiver the receiver
|
||||
*/
|
||||
public static void sendBlank(CommandSender receiver) {
|
||||
if (receiver == null) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.Placeholder;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLog;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -53,7 +54,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private List<String> allies = new ArrayList<>();
|
||||
private List<String> rivals = new ArrayList<>();
|
||||
private List<String> bb = new ArrayList<>();
|
||||
private final List<String> members = new ArrayList<>();
|
||||
private final List<ClanPlayer> members = new ArrayList<>();
|
||||
private Flags flags = new Flags(null);
|
||||
private boolean feeEnabled;
|
||||
private List<Rank> ranks = new ArrayList<>();
|
||||
@@ -112,23 +113,23 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
@Deprecated
|
||||
public void deposit(double amount, Player player) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerHasMoney(player, amount)) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerChargeMoney(player, amount)) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().grantPlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, amount));
|
||||
addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount));
|
||||
addBb(player.getName(), lang("bb.clan.deposit", amount));
|
||||
setBalance(getBalance() + amount);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
} else {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposits money to the clan
|
||||
*/
|
||||
public EconomyResponse deposit(@Nullable CommandSender sender, @NotNull Cause cause, double amount) {
|
||||
public EconomyResponse deposit(@NotNull BankOperator sender, @NotNull Cause cause, double amount) {
|
||||
EconomyResponse response = null;
|
||||
|
||||
if (amount < 0) {
|
||||
@@ -149,9 +150,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
@Deprecated
|
||||
public void withdraw(double amount, Player player) {
|
||||
if (getBalance() >= amount) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerGrantMoney(player, amount)) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().grantPlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
addBb(player.getName(), lang("bb.clan.withdraw", amount));
|
||||
setBalance(getBalance() - amount);
|
||||
}
|
||||
} else {
|
||||
@@ -162,7 +163,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Withdraws money from the clan
|
||||
*/
|
||||
public EconomyResponse withdraw(@Nullable CommandSender sender, @NotNull Cause cause, double amount) {
|
||||
public EconomyResponse withdraw(@NotNull BankOperator sender, @NotNull Cause cause, double amount) {
|
||||
EconomyResponse response = null;
|
||||
|
||||
if (amount < 0) {
|
||||
@@ -250,14 +251,15 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @param balance the balance to set
|
||||
*/
|
||||
public void setBalance(double balance) {
|
||||
setBalance(null, Cause.API, SET, balance);
|
||||
private void setBalance(double balance) {
|
||||
setBalance(BankOperator.INTERNAL, Cause.INTERNAL, SET, balance);
|
||||
}
|
||||
|
||||
public EconomyResponse setBalance(@Nullable CommandSender updater, @NotNull Cause cause, @NotNull BankLogger.Operation operation, double balance) {
|
||||
public EconomyResponse setBalance(@NotNull BankOperator operator, @NotNull Cause cause,
|
||||
@NotNull BankLogger.Operation operation, double balance) {
|
||||
EconomyResponse response = SUCCESS;
|
||||
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(updater, this, getBalance(), balance, cause);
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(operator, this, getBalance(), balance, cause);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
response = CANCELLED;
|
||||
@@ -266,7 +268,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
this.balance = event.getNewBalance();
|
||||
if (cause != Cause.LOADING) {
|
||||
if (operation == SET) {
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(updater, this, response, SET, cause, balance));
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(operator, this, response, SET, cause, balance));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -291,7 +293,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first color in the clan's tag
|
||||
*
|
||||
@@ -335,17 +336,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
/**
|
||||
* Returns the max number of days the clan can be inactive
|
||||
* A number <= 0 means it won't be purged
|
||||
* A {@literal <=} 0 means it won't be purged
|
||||
*/
|
||||
public int getMaxInactiveDays() {
|
||||
if (this.isPermanent()) {
|
||||
if (isPermanent()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int verifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getInt(PURGE_INACTIVE_CLAN_DAYS);
|
||||
int unverifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getInt(PURGE_UNVERIFIED_CLAN_DAYS);
|
||||
|
||||
return this.isVerified() ? verifiedClanInactiveDays : unverifiedClanInactiveDays;
|
||||
return isVerified() ? verifiedClanInactiveDays : unverifiedClanInactiveDays;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -383,17 +384,22 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(Player player) {
|
||||
return this.members.contains(player.getUniqueId().toString());
|
||||
return isMember(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player is a member of this clan
|
||||
*
|
||||
* @param playerUniqueId the Player's UUID
|
||||
* @param uuid the Player's UUID
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(UUID playerUniqueId) {
|
||||
return this.members.contains(playerUniqueId.toString());
|
||||
public boolean isMember(UUID uuid) {
|
||||
for (ClanPlayer cp : members) {
|
||||
if (cp.getUniqueId().equals(uuid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -486,6 +492,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
|
||||
public void setBb(List<String> bb) {
|
||||
this.bb = new ArrayList<>(bb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bulletin board message without saving it to the database
|
||||
@@ -520,23 +529,16 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* (used internally)
|
||||
*/
|
||||
public void importMember(ClanPlayer cp) {
|
||||
String uuid;
|
||||
if (cp.getUniqueId() != null) {
|
||||
uuid = cp.getUniqueId().toString();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.members.contains(uuid)) {
|
||||
this.members.add(uuid);
|
||||
if (!members.contains(cp)) {
|
||||
members.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*/
|
||||
public void removeMember(UUID playerUniqueId) {
|
||||
this.members.remove(playerUniqueId.toString());
|
||||
public void removeMember(UUID uuid) {
|
||||
members.removeIf(cp -> cp.getUniqueId().equals(uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -544,7 +546,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("size")
|
||||
public int getSize() {
|
||||
return this.members.size();
|
||||
return members.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -562,12 +564,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
private boolean removeRival(String rival) {
|
||||
if (!rivals.contains(rival)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rivals.remove(rival);
|
||||
return true;
|
||||
return rivals.remove(rival);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,7 +635,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedBb
|
||||
*/
|
||||
public String getPackedBb() {
|
||||
return Helper.toMessage(bb, "|");
|
||||
return String.join("|", bb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -647,7 +644,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedBb the packedBb to set
|
||||
*/
|
||||
public void setPackedBb(String packedBb) {
|
||||
this.bb = Helper.fromArrayToList(packedBb.split("[|]"));
|
||||
bb = Helper.fromArrayToList(packedBb.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -656,7 +653,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedAllies
|
||||
*/
|
||||
public String getPackedAllies() {
|
||||
return Helper.toMessage(allies, "|");
|
||||
return String.join("|", allies);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -665,7 +662,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedAllies the packedAllies to set
|
||||
*/
|
||||
public void setPackedAllies(String packedAllies) {
|
||||
this.allies = Helper.fromArrayToList(packedAllies.split("[|]"));
|
||||
allies = Helper.fromArrayToList(packedAllies.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,7 +671,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedRivals
|
||||
*/
|
||||
public String getPackedRivals() {
|
||||
return Helper.toMessage(rivals, "|");
|
||||
return String.join("|", rivals);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,7 +680,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedRivals the packedRivals to set
|
||||
*/
|
||||
public void setPackedRivals(String packedRivals) {
|
||||
this.rivals = Helper.fromArrayToList(packedRivals.split("[|]"));
|
||||
rivals = Helper.fromArrayToList(packedRivals.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,23 +688,13 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* tags
|
||||
*/
|
||||
public String getAllyString(String sep, @Nullable CommandSender viewer) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
String coloredAllies = getAllies().stream().
|
||||
map(allyTag -> SimpleClans.getInstance().getClanManager().getClan(allyTag)).
|
||||
filter(Objects::nonNull).
|
||||
map(Clan::getColorTag).
|
||||
collect(Collectors.joining(sep));
|
||||
|
||||
for (String allyTag : getAllies()) {
|
||||
Clan ally = SimpleClans.getInstance().getClanManager().getClan(allyTag);
|
||||
|
||||
if (ally != null) {
|
||||
out.append(ally.getColorTag()).append(sep);
|
||||
}
|
||||
}
|
||||
|
||||
out = new StringBuilder(Helper.stripTrailing(out.toString(), sep));
|
||||
|
||||
if (out.toString().trim().isEmpty()) {
|
||||
return lang("none", viewer);
|
||||
}
|
||||
|
||||
return ChatUtils.parseColors(out.toString());
|
||||
return coloredAllies.isEmpty() ? lang("none", viewer) : coloredAllies;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -723,29 +710,14 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* tags
|
||||
*/
|
||||
public String getRivalString(String sep, @Nullable CommandSender viewer) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
String coloredRivals = getRivals().stream().
|
||||
map(rivalTag -> SimpleClans.getInstance().getClanManager().getClan(rivalTag)).
|
||||
filter(Objects::nonNull).
|
||||
map(rival -> isWarring(rival) ? DARK_RED + "[" + rival.getTag() + "]" : rival.getColorTag()).
|
||||
map(ChatUtils::parseColors).
|
||||
collect(Collectors.joining(sep));
|
||||
|
||||
for (String rivalTag : getRivals()) {
|
||||
Clan rival = SimpleClans.getInstance().getClanManager().getClan(rivalTag);
|
||||
|
||||
if (rival != null) {
|
||||
if (isWarring(rivalTag)) {
|
||||
out.append(DARK_RED).append("[").append(ChatUtils.stripColors(rival.getColorTag()))
|
||||
.append("]").append(sep);
|
||||
} else {
|
||||
out.append(rival.getColorTag()).append(sep);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
out = new StringBuilder(Helper.stripTrailing(out.toString(), sep));
|
||||
|
||||
if (out.toString().trim().isEmpty()) {
|
||||
return lang("none", viewer);
|
||||
}
|
||||
|
||||
return ChatUtils.parseColors(out.toString());
|
||||
return coloredRivals.isEmpty() ? lang("none", viewer) : coloredRivals;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -762,20 +734,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the formatted leaders string
|
||||
*/
|
||||
public String getLeadersString(String prefix, String sep) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cp.isLeader()) {
|
||||
out.append(prefix).append(cp.getName()).append(sep);
|
||||
}
|
||||
}
|
||||
|
||||
return Helper.stripTrailing(out.toString(), sep);
|
||||
return members.stream().filter(ClanPlayer::isLeader).map(ClanPlayer::getName).
|
||||
collect(Collectors.joining(sep, prefix, ""));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -814,8 +774,10 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the fee payers
|
||||
*/
|
||||
public Set<ClanPlayer> getFeePayers() {
|
||||
PermissionsManager permissions = SimpleClans.getInstance().getPermissionsManager();
|
||||
return getNonLeaders().stream().filter(cp -> !permissions.has(cp.toPlayer(), "simpleclans.member.bypass-fee")).collect(Collectors.toSet());
|
||||
return getMembers().stream().filter(cp -> !cp.isLeader()).filter(cp -> {
|
||||
Rank rank = getRank(cp.getRankId());
|
||||
return rank == null || !rank.getPermissions().contains(RankPermission.FEE_BYPASS.toString());
|
||||
}).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -824,19 +786,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the members
|
||||
*/
|
||||
public List<ClanPlayer> getMembers() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
out.add(cp);
|
||||
}
|
||||
|
||||
Collections.sort(out);
|
||||
|
||||
return out;
|
||||
return new ArrayList<>(members);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -846,22 +796,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder(value = "onlinemembers_count", resolver = "list_size", config = "filter_vanished")
|
||||
public List<ClanPlayer> getOnlineMembers() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
if (cp.toPlayer() != null) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
return members.stream().filter(cp -> cp.toPlayer() != null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all leaders in the clan
|
||||
*
|
||||
@@ -869,20 +806,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder(value = "leader_size", resolver = "list_size")
|
||||
public List<ClanPlayer> getLeaders() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cp.isLeader()) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
return members.stream().filter(ClanPlayer::isLeader).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -891,22 +815,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return non leaders
|
||||
*/
|
||||
public List<ClanPlayer> getNonLeaders() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!cp.isLeader()) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(out);
|
||||
|
||||
return out;
|
||||
return members.stream().filter(cp -> !cp.isLeader()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -945,16 +854,10 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
if (members.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double totalWeightedKills = 0;
|
||||
int totalDeaths = 0;
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
totalWeightedKills += cp.getWeightedKills();
|
||||
totalDeaths += cp.getDeaths();
|
||||
}
|
||||
@@ -977,12 +880,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return totalDeaths;
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
totalDeaths += cp.getDeaths();
|
||||
}
|
||||
|
||||
@@ -1000,12 +898,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return total;
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
total += cp.getWeightedKills();
|
||||
}
|
||||
|
||||
@@ -1090,6 +983,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
cp.removePastClan(getColorTag());
|
||||
cp.setClan(this);
|
||||
cp.setLeader(false);
|
||||
cp.setJoinDate(new Date().getTime());
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().is(CLAN_TRUST_MEMBERS_BY_DEFAULT));
|
||||
if (defaultRank != null) {
|
||||
cp.setRank(defaultRank);
|
||||
@@ -1210,7 +1104,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an ally form the clan, and the clan from the ally
|
||||
* Remove an ally from the clan, and the clan from the ally
|
||||
*/
|
||||
public void removeAlly(Clan ally) {
|
||||
removeAlly(ally.getTag());
|
||||
@@ -1261,7 +1155,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("is_anyonline")
|
||||
public boolean isAnyOnline() {
|
||||
return members.stream().map(UUID::fromString).map(Bukkit::getPlayer).anyMatch(Objects::nonNull);
|
||||
return members.stream().anyMatch(cp -> cp.toPlayer() != null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1361,18 +1255,14 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getColored(CLANCHAT_ANNOUNCEMENT_COLOR) + msg;
|
||||
|
||||
for (ClanPlayer cp : getMembers()) {
|
||||
Player pl = cp.toPlayer();
|
||||
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, message);
|
||||
}
|
||||
ChatBlock.sendMessage(cp, message);
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(AQUA + "[" + lang("clan.announce") + AQUA + "] " + AQUA + "[" + Helper.getColorName(playerName) + WHITE + "] " + message);
|
||||
Bukkit.getConsoleSender().sendMessage(AQUA + "[" + lang("clan.announce") + AQUA + "] " + AQUA + "[" + Helper.getColorName(playerName) + WHITE + "] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Announce message to a all the leaders of a clan
|
||||
* Announce message to all the leaders of a clan
|
||||
*/
|
||||
public void leaderAnnounce(String msg) {
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getColored(CLANCHAT_ANNOUNCEMENT_COLOR) + msg;
|
||||
@@ -1380,13 +1270,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
|
||||
for (ClanPlayer cp : leaders) {
|
||||
Player pl = cp.toPlayer();
|
||||
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, message);
|
||||
}
|
||||
ChatBlock.sendMessage(cp, message);
|
||||
}
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(AQUA + "[" + lang("leader.announce") + AQUA + "] " + WHITE + message);
|
||||
Bukkit.getConsoleSender().sendMessage(AQUA + "[" + lang("leader.announce") + AQUA + "] " + WHITE + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1394,8 +1280,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
public void addBb(String announcerName, String msg) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR) + "* " + SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + ChatUtils.parseColors(msg));
|
||||
addBb(msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_PREFIX) + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1404,8 +1290,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
public void addBb(String announcerName, String msg, boolean updateLastUsed) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR) + "* " + SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + ChatUtils.parseColors(msg));
|
||||
addBb(msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_PREFIX) + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1422,31 +1308,35 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param maxSize amount of lines to display
|
||||
*/
|
||||
public void displayBb(Player player, int maxSize) {
|
||||
if (isVerified()) {
|
||||
ChatBlock.sendBlank(player);
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR);
|
||||
String pageHeadingsColor = SimpleClans.getInstance().getSettingsManager().getColored(PAGE_HEADINGS_COLOR);
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", bbAccentColor, pageHeadingsColor, getName()));
|
||||
|
||||
List<String> localBb;
|
||||
if (maxSize == -1) {
|
||||
localBb = bb;
|
||||
maxSize = SimpleClans.getInstance().getSettingsManager().getInt(BB_SIZE);
|
||||
} else {
|
||||
localBb = new ArrayList<>(bb);
|
||||
}
|
||||
while (localBb.size() > maxSize) {
|
||||
localBb.remove(0);
|
||||
}
|
||||
|
||||
for (String msg : localBb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR);
|
||||
ChatBlock.sendMessage(player, bbAccentColor + "* " + bbColor + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
if (!isVerified()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SettingsManager settings = SimpleClans.getInstance().getSettingsManager();
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", getName()));
|
||||
|
||||
List<String> localBb;
|
||||
if (maxSize == -1) {
|
||||
localBb = bb;
|
||||
maxSize = settings.getInt(BB_SIZE);
|
||||
} else {
|
||||
localBb = new ArrayList<>(bb);
|
||||
}
|
||||
|
||||
while (localBb.size() > maxSize) {
|
||||
localBb.remove(0);
|
||||
}
|
||||
|
||||
for (String msg : localBb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
String bbPrefix = settings.getColored(BB_PREFIX);
|
||||
ChatBlock.sendMessage(player, bbPrefix + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1462,16 +1352,19 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
if (index < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String bbPrefix = SimpleClans.getInstance().getSettingsManager().getColored(BB_PREFIX);
|
||||
|
||||
long time = (System.currentTimeMillis() - Long.parseLong(msg.substring(0, index))) / 1000L;
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR);
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR);
|
||||
msg = ChatUtils.parseColors(bbAccentColor + "* " + bbColor + msg.substring(++index));
|
||||
TextComponent textComponent = new TextComponent(msg);
|
||||
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
|
||||
msg = ChatUtils.parseColors(bbPrefix + msg.substring(++index));
|
||||
|
||||
BaseComponent[] baseComponent = TextComponent.fromLegacyText(msg);
|
||||
TextComponent textMessage = new TextComponent(baseComponent);
|
||||
textMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
|
||||
Dates.formatTime(time, 1) + lang("bb.ago"))));
|
||||
player.spigot().sendMessage(textComponent);
|
||||
player.spigot().sendMessage(textMessage);
|
||||
return true;
|
||||
} catch (Throwable rock) {
|
||||
} catch (Exception rock) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1487,24 +1380,25 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
Collection<ClanPlayer> clanPlayers = SimpleClans.getInstance().getClanManager().getAllClanPlayers();
|
||||
List<Clan> clans = SimpleClans.getInstance().getClanManager().getClans();
|
||||
|
||||
if (this.isPermanent() && !force) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("cannot.disband.permanent"));
|
||||
if (isPermanent() && !force) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("cannot.disband.permanent", sender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (announce) {
|
||||
if (SimpleClans.getInstance().getSettingsManager().is(DISABLE_MESSAGES) && sender != null) {
|
||||
this.clanAnnounce(sender.getName(), AQUA + lang("clan.has.been.disbanded", this.getName()));
|
||||
clanAnnounce(sender.getName(), AQUA + lang("clan.has.been.disbanded", getName()));
|
||||
} else {
|
||||
SimpleClans.getInstance().getClanManager().serverAnnounce(AQUA + lang("clan.has.been.disbanded", this.getName()));
|
||||
SimpleClans.getInstance().getClanManager().serverAnnounce(AQUA + lang("clan.has.been.disbanded", getName()));
|
||||
}
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPermissions(this);
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
if (cp.getTag().equals(getTag())) {
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPermissions(this);
|
||||
cp.setClan(null);
|
||||
|
||||
cp.setJoinDate(0);
|
||||
cp.setRank(null);
|
||||
if (isVerified()) {
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? DARK_RED + "*" : ""));
|
||||
}
|
||||
@@ -1513,28 +1407,29 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new DisbandClanEvent(this));
|
||||
Bukkit.getPluginManager().callEvent(new DisbandClanEvent(sender, this));
|
||||
clans.remove(this);
|
||||
|
||||
for (Clan c : clans) {
|
||||
String disbanded = lang("clan.disbanded");
|
||||
|
||||
if (c.removeWarringClan(this)) {
|
||||
c.addBb(disbanded, AQUA + lang("you.are.no.longer.at.war", c.getName(), getColorTag()));
|
||||
c.addBb(disbanded, lang("you.are.no.longer.at.war", c.getName(), getColorTag()));
|
||||
}
|
||||
|
||||
if (c.removeRival(getTag())) {
|
||||
c.addBb(disbanded, AQUA + lang("has.been.disbanded.rivalry.ended", getName()));
|
||||
c.addBb(disbanded, lang("has.been.disbanded.rivalry.ended", getName()));
|
||||
}
|
||||
|
||||
if (c.removeAlly(getTag())) {
|
||||
c.addBb(disbanded, AQUA + lang("has.been.disbanded.alliance.ended", getName()));
|
||||
c.addBb(disbanded, lang("has.been.disbanded.alliance.ended", getName()));
|
||||
}
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getRequestManager().removeRequest(getTag());
|
||||
|
||||
SimpleClans.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(SimpleClans.getInstance(), () -> {
|
||||
SimpleClans.getInstance().getClanManager().removeClan(this.getTag());
|
||||
SimpleClans.getInstance().getClanManager().removeClan(getTag());
|
||||
SimpleClans.getInstance().getStorageManager().deleteClan(this);
|
||||
}, 1);
|
||||
}
|
||||
@@ -1578,8 +1473,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
warring.add(targetClan.getTag());
|
||||
flags.put(WARRING_KEY, warring);
|
||||
if (requestPlayer != null) {
|
||||
this.addBb(requestPlayer.getName(), AQUA + lang("you.are.at.war",
|
||||
this.getName(), targetClan.getColorTag()));
|
||||
addBb(requestPlayer.getName(), lang("you.are.at.war",
|
||||
getName(), targetClan.getColorTag()));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1652,6 +1547,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
flags.put("homeYaw", home != null ? home.getYaw() : 0);
|
||||
String world = home != null && home.getWorld() != null ? home.getWorld().getName() : "";
|
||||
flags.put("homeWorld", world);
|
||||
String name = SimpleClans.getInstance().getProxyManager().getServerName();
|
||||
flags.put("homeServer", name);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1670,11 +1567,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
double z = flags.getNumber("homeZ").doubleValue();
|
||||
float yaw = flags.getNumber("homeYaw").floatValue();
|
||||
float pitch = flags.getNumber("homePitch").floatValue();
|
||||
Location location = new Location(world, x, y, z, yaw, pitch);
|
||||
if (!Helper.isAir(location.getBlock().getType(), location.clone().add(0, 1, 0).getBlock().getType())) {
|
||||
location.setY(world.getHighestBlockYAt(location) + 1);
|
||||
}
|
||||
return location;
|
||||
|
||||
return new Location(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public String getTagLabel(boolean isLeader) {
|
||||
@@ -1684,7 +1578,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
String bracketLeft = sm.getColored(TAG_BRACKET_LEFT);
|
||||
String bracketRight = sm.getColored(TAG_BRACKET_RIGHT);
|
||||
String tagSeparatorColor = isLeader ? sm.getColored(TAG_SEPARATOR_LEADER_COLOR) : sm.getColored(TAG_SEPARATOR_COLOR);
|
||||
String tagSeparator = sm.getString(TAG_SEPARATOR_char);
|
||||
String tagSeparator = sm.getString(TAG_SEPARATOR_CHAR);
|
||||
|
||||
return bracketColor + bracketLeft + bracketDefaultColor + getColorTag() + bracketColor + bracketRight + tagSeparatorColor + tagSeparator;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
@@ -37,7 +38,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
private int deaths;
|
||||
private long lastSeen;
|
||||
private long joinDate;
|
||||
private Set<String> pastClans = new HashSet<>();
|
||||
private final Set<String> pastClans = new LinkedHashSet<>();
|
||||
private final Map<String, Long> resignTimes = new HashMap<>();
|
||||
private @Nullable VoteResult vote;
|
||||
private Flags flags = new Flags(null);
|
||||
@@ -47,6 +48,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
private @Nullable Locale locale;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -66,17 +68,17 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param uuid the Player's UUID
|
||||
*/
|
||||
public ClanPlayer(UUID uuid) {
|
||||
this.uniqueId = uuid;
|
||||
uniqueId = uuid;
|
||||
Player onlinePlayer = SimpleClans.getInstance().getServer().getPlayer(uuid);
|
||||
if (onlinePlayer != null) {
|
||||
this.displayName = onlinePlayer.getName();
|
||||
displayName = onlinePlayer.getName();
|
||||
} else {
|
||||
OfflinePlayer offlinePlayer = SimpleClans.getInstance().getServer().getOfflinePlayer(uuid);
|
||||
this.displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
}
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
this.joinDate = (new Date()).getTime();
|
||||
this.tag = "";
|
||||
lastSeen = (new Date()).getTime();
|
||||
joinDate = (new Date()).getTime();
|
||||
tag = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,12 +93,12 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
ClanPlayer other = (ClanPlayer) obj;
|
||||
return other.getName().equals(this.getName());
|
||||
return other.getName().equals(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClanPlayer other) {
|
||||
return this.getUniqueId().compareTo(other.getUniqueId());
|
||||
return getUniqueId().compareTo(other.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +141,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.displayName = name;
|
||||
displayName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +227,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* Updates last seen date to today
|
||||
*/
|
||||
public void updateLastSeen() {
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
lastSeen = (new Date()).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,7 +488,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
return "";
|
||||
}
|
||||
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.joinDate));
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(joinDate));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -507,11 +509,10 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
public String getLastSeenString(@Nullable CommandSender sender) {
|
||||
Player player = toPlayer();
|
||||
if (player != null && player.isOnline() && !VanishUtils.isVanished(sender, player)) {
|
||||
if (!VanishUtils.isVanished(sender, this)) {
|
||||
return lang("online", sender);
|
||||
}
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.lastSeen));
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(lastSeen));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,31 +530,24 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @return the PackedPastClans
|
||||
*/
|
||||
public String getPackedPastClans() {
|
||||
StringBuilder packedPastClans = new StringBuilder();
|
||||
|
||||
Set<String> pt = getPastClans();
|
||||
|
||||
for (String pastClan : pt) {
|
||||
packedPastClans.append(pastClan).append("|");
|
||||
}
|
||||
|
||||
return Helper.stripTrailing(packedPastClans.toString(), "|");
|
||||
return String.join("|", getPastClans());
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param PackedPastClans the PackedPastClans to set
|
||||
* @param packedPastClans the packedPastClans to set
|
||||
*/
|
||||
public void setPackedPastClans(String PackedPastClans) {
|
||||
this.pastClans = Helper.fromArrayToSet(PackedPastClans.split("[|]"));
|
||||
public void setPackedPastClans(String packedPastClans) {
|
||||
String[] clans = packedPastClans.split("\\|");
|
||||
Collections.addAll(pastClans, clans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a past clan to the player (does not update the clanplayer to db)
|
||||
*/
|
||||
public void addPastClan(String tag) {
|
||||
this.getPastClans().add(tag);
|
||||
getPastClans().add(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -562,7 +556,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param tag is the clan's colored tag
|
||||
*/
|
||||
public void removePastClan(String tag) {
|
||||
this.getPastClans().remove(tag);
|
||||
getPastClans().remove(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -581,19 +575,15 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
@NotNull
|
||||
public String getPastClansString(String sep, @Nullable Player viewer) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String pastClan : getPastClans()) {
|
||||
out.append(pastClan).append(sep);
|
||||
}
|
||||
|
||||
out = new StringBuilder(Helper.stripTrailing(out.toString(), sep));
|
||||
|
||||
if (out.toString().trim().isEmpty()) {
|
||||
if (getPastClans().isEmpty()) {
|
||||
return lang("none", viewer);
|
||||
}
|
||||
|
||||
return out.toString();
|
||||
SettingsManager settings = SimpleClans.getInstance().getSettingsManager();
|
||||
return getPastClans().stream().
|
||||
sorted(Collections.reverseOrder()).
|
||||
limit(settings.getInt(PAST_CLANS_LIMIT)).
|
||||
collect(Collectors.joining(sep));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,7 +616,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
/**
|
||||
* Sets the resign times (does not update to db)
|
||||
*/
|
||||
public void setResignTimes(Map<String, Long> resignTimes) {
|
||||
public void setResignTimes(@Nullable Map<String, Long> resignTimes) {
|
||||
if (resignTimes != null) {
|
||||
final int cooldown = SimpleClans.getInstance().getSettingsManager().getInt(REJOIN_COOLDOWN);
|
||||
resignTimes.forEach((k, v) -> {
|
||||
@@ -663,9 +653,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
public void setClan(@Nullable Clan clan) {
|
||||
if (clan == null) {
|
||||
this.tag = "";
|
||||
tag = "";
|
||||
} else {
|
||||
this.tag = clan.getTag();
|
||||
tag = clan.getTag();
|
||||
}
|
||||
|
||||
this.clan = clan;
|
||||
@@ -814,7 +804,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
flags.put("hide-tag", tagEnabled);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(this.toPlayer());
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(toPlayer());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -833,6 +823,11 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Placeholder("has_rank")
|
||||
public boolean hasRank() {
|
||||
return !getRankId().isEmpty();
|
||||
}
|
||||
|
||||
@Placeholder("rank")
|
||||
public @NotNull String getRankId() {
|
||||
return flags.getString("rank", "");
|
||||
@@ -855,10 +850,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
flags.put("rank", rank == null ? "" : rank);
|
||||
}
|
||||
|
||||
public @NotNull Locale getLocale() {
|
||||
if (locale == null) {
|
||||
return SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
public @Nullable Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
*/
|
||||
public enum ClanRequest
|
||||
{
|
||||
DEMOTE, PROMOTE, DISBAND, INVITE, CREATE_ALLY, BREAK_RIVALRY, START_WAR, END_WAR
|
||||
DEMOTE, PROMOTE, DISBAND, INVITE, CREATE_ALLY, BREAK_RIVALRY, START_WAR, END_WAR, RENAME
|
||||
}
|
||||
@@ -75,9 +75,11 @@ public class Dates {
|
||||
}
|
||||
|
||||
/**
|
||||
* @author RoboMWM, LaxWasHere
|
||||
* <p>
|
||||
* authors: RoboMWM, LaxWasHere
|
||||
* </p>
|
||||
* @param seconds the time in seconds
|
||||
* @param depth Max amount of detail (e.g. only display days and hours if set to 1 and seconds > 1 day)
|
||||
* @param depth Max amount of detail (e.g. only display days and hours if set to 1 and seconds {@literal >} 1 day)
|
||||
* @return the string representation of the amount of time labeled as days, hours, minutes, seconds
|
||||
*/
|
||||
public static String formatTime(Long seconds, int depth) {
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Flags {
|
||||
|
||||
private final JSONObject flags;
|
||||
private static final Gson gson = new Gson();
|
||||
private final JsonObject flags;
|
||||
|
||||
public Flags(@Nullable String json) {
|
||||
JSONObject flags = null;
|
||||
if (json != null && !json.isEmpty()) {
|
||||
flags = (JSONObject) JSONValue.parse(json);
|
||||
flags = gson.fromJson(json, JsonObject.class);
|
||||
} else {
|
||||
flags = new JsonObject();
|
||||
}
|
||||
if (flags == null) {
|
||||
flags = new JSONObject();
|
||||
}
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getStringList(@NotNull String key) {
|
||||
Object object = flags.get(key);
|
||||
JsonElement object = flags.get(key);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
if (object instanceof JSONArray) {
|
||||
for (Object o : ((JSONArray) object)) {
|
||||
list.add(String.valueOf(o));
|
||||
if (object != null && object.isJsonArray()) {
|
||||
for (JsonElement element : object.getAsJsonArray()) {
|
||||
list.add(element.getAsString());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -38,11 +36,11 @@ public class Flags {
|
||||
|
||||
@Nullable
|
||||
public String getString(@NotNull String key) {
|
||||
Object object = flags.get(key);
|
||||
if (object == null) {
|
||||
JsonElement element = flags.get(key);
|
||||
if (element == null || element.isJsonNull()) {
|
||||
return null;
|
||||
}
|
||||
return String.valueOf(object);
|
||||
return element.getAsString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -56,11 +54,11 @@ public class Flags {
|
||||
|
||||
@NotNull
|
||||
public Number getNumber(@NotNull String key) {
|
||||
Object object = flags.get(key);
|
||||
if (object instanceof Number) {
|
||||
return (Number) object;
|
||||
JsonElement element = flags.get(key);
|
||||
if (element == null || element.isJsonNull()) {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
return element.getAsNumber();
|
||||
}
|
||||
|
||||
public boolean getBoolean(@NotNull String key) {
|
||||
@@ -68,26 +66,22 @@ public class Flags {
|
||||
}
|
||||
|
||||
public boolean getBoolean(@NotNull String key, boolean def) {
|
||||
Object object = flags.get(key);
|
||||
if (object instanceof Boolean) {
|
||||
return (Boolean) object;
|
||||
JsonElement element = flags.get(key);
|
||||
if (element == null || element.isJsonNull()) {
|
||||
return def;
|
||||
}
|
||||
return def;
|
||||
return element.getAsBoolean();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void put(@NotNull String key, @NotNull List<?> value) {
|
||||
JSONArray array = new JSONArray();
|
||||
array.addAll(value);
|
||||
flags.put(key, array);
|
||||
flags.add(key, gson.toJsonTree(value));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void put(@NotNull String key, @NotNull Object object) {
|
||||
flags.put(key, object);
|
||||
flags.add(key, gson.toJsonTree(object));
|
||||
}
|
||||
|
||||
public String toJSONString() {
|
||||
return flags.toJSONString();
|
||||
return flags.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.FileSystem;
|
||||
@@ -35,8 +36,11 @@ import static net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils.stripColors;
|
||||
* @author phaed
|
||||
*/
|
||||
|
||||
public class Helper {
|
||||
public final class Helper {
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final Type RANKS_TYPE = TypeToken.getParameterized(List.class, Rank.class).getType();
|
||||
private static final Type RESIGN_TYPE = TypeToken.getParameterized(Map.class, String.class, Long.class).getType();
|
||||
private Helper() {
|
||||
}
|
||||
|
||||
@@ -49,15 +53,10 @@ public class Helper {
|
||||
return Locale.forLanguageTag(languageTag);
|
||||
}
|
||||
|
||||
public static @Nullable JSONObject parseJson(String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
try {
|
||||
return (JSONObject) new JSONParser().parse(json);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@Contract("null -> null")
|
||||
@Nullable
|
||||
public static String toLanguageTag(@Nullable Locale locale) {
|
||||
return locale != null ? locale.toLanguageTag() : null;
|
||||
}
|
||||
|
||||
public static Set<Path> getPathsIn(String path, Predicate<? super Path> filter) {
|
||||
@@ -117,47 +116,32 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a list of ranks from the specified JSONObject
|
||||
* Parses a list of ranks from the specified Json String
|
||||
*
|
||||
* @param jo the JSON Object
|
||||
* @param json the Json String
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static @Nullable List<Rank> ranksFromJson(@Nullable JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
Object ranks = jo.get("ranks");
|
||||
if (ranks != null) {
|
||||
JSONArray array = (JSONArray) ranks;
|
||||
List<Rank> rankList = new ArrayList<>();
|
||||
for (Object o : array) {
|
||||
JSONObject r = (JSONObject) o;
|
||||
String name = (String) r.get("name");
|
||||
String displayName = (String) r.get("displayName");
|
||||
Set<String> permissions = new HashSet<>();
|
||||
for (Object p : (JSONArray) r.get("permissions")) {
|
||||
permissions.add((String) p);
|
||||
}
|
||||
Rank rank = new Rank(name, displayName, permissions);
|
||||
rankList.add(rank);
|
||||
}
|
||||
|
||||
return rankList;
|
||||
}
|
||||
public static @Nullable List<Rank> ranksFromJson(@Nullable String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
JsonObject object = GSON.fromJson(json, JsonObject.class);
|
||||
JsonElement ranks = object.get("ranks");
|
||||
return GSON.fromJson(ranks, RANKS_TYPE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the default rank from the specified JSONObject
|
||||
* Parses the default rank from the specified Json String
|
||||
*
|
||||
* @param jo the JSON object
|
||||
* @param json the Json String
|
||||
* @return the default rank or null if not found and/or it does not exist
|
||||
*/
|
||||
public static @Nullable String defaultRankFromJson(@Nullable JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
if (!jo.containsKey("defaultRank")) {
|
||||
return null;
|
||||
} else {
|
||||
return (String) jo.get("defaultRank");
|
||||
public static @Nullable String defaultRankFromJson(@Nullable String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
JsonObject object = GSON.fromJson(json, JsonObject.class);
|
||||
JsonElement defaultRank = object.get("defaultRank");
|
||||
if (defaultRank != null && !defaultRank.isJsonNull()) {
|
||||
return defaultRank.getAsString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -170,36 +154,24 @@ public class Helper {
|
||||
* @param defaultRank the default rank
|
||||
* @return a JSON String
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String ranksToJson(List<Rank> ranks, @Nullable String defaultRank) {
|
||||
if (ranks == null)
|
||||
ranks = new ArrayList<>();
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
for (Rank rank : ranks) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", rank.getName());
|
||||
o.put("displayName", rank.getDisplayName());
|
||||
JSONArray permArray = new JSONArray();
|
||||
permArray.addAll(rank.getPermissions());
|
||||
o.put("permissions", permArray);
|
||||
array.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("ranks", array);
|
||||
object.put("defaultRank", defaultRank);
|
||||
return object.toJSONString();
|
||||
JsonObject object = new JsonObject();
|
||||
object.add("ranks", GSON.toJsonTree(ranks));
|
||||
object.addProperty("defaultRank", defaultRank);
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a resign times map to a JSON String
|
||||
*
|
||||
* @param resignTimes
|
||||
* @param resignTimes the resign times
|
||||
* @return a JSON String
|
||||
*/
|
||||
public static String resignTimesToJson(Map<String, Long> resignTimes) {
|
||||
return JSONObject.toJSONString(resignTimes);
|
||||
return GSON.toJson(resignTimes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,14 +180,9 @@ public class Helper {
|
||||
* @param json JSON String
|
||||
* @return a map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Long> resignTimesFromJson(String json) {
|
||||
if (json != null) {
|
||||
try {
|
||||
return (Map<String, Long>) new JSONParser().parse(json);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static @Nullable Map<String, Long> resignTimesFromJson(String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
return GSON.fromJson(json, RESIGN_TYPE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -259,7 +226,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts string array to ArrayList<String>, remove empty strings
|
||||
* Converts string array to {@literal ArrayList<String>}, remove empty strings
|
||||
*
|
||||
* @param values
|
||||
* @return
|
||||
@@ -272,11 +239,12 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts string array to HashSet<String>, remove empty strings
|
||||
* Converts string array to {@literal HashSet<String>}, remove empty strings
|
||||
*
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static Set<String> fromArrayToSet(String... values) {
|
||||
HashSet<String> results = new HashSet<>();
|
||||
Collections.addAll(results, values);
|
||||
@@ -285,7 +253,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts ArrayList<String> to string array
|
||||
* Converts {@literal ArrayList<String>} to string array
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
@@ -308,40 +276,6 @@ public class Helper {
|
||||
return sa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string array to a string with custom separators
|
||||
*
|
||||
* @param args
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public static String toMessage(String[] args, String sep) {
|
||||
String out = "";
|
||||
|
||||
for (String arg : args) {
|
||||
out += arg + ", ";
|
||||
}
|
||||
|
||||
return stripTrailing(out, ", ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string array to a string with custom separators
|
||||
*
|
||||
* @param args
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public static String toMessage(List<String> args, String sep) {
|
||||
String out = "";
|
||||
|
||||
for (String arg : args) {
|
||||
out += arg + sep;
|
||||
}
|
||||
|
||||
return stripTrailing(out, sep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the tag from color codes and makes it lowercase
|
||||
*
|
||||
@@ -352,33 +286,6 @@ public class Helper {
|
||||
return stripColors(tag).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes trailing separators
|
||||
*
|
||||
* @param msg
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public static String stripTrailing(String msg, String sep) {
|
||||
if (msg.length() < sep.length()) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
String out = msg;
|
||||
String first = msg.substring(0, sep.length());
|
||||
String last = msg.substring(msg.length() - sep.length());
|
||||
|
||||
if (first.equals(sep)) {
|
||||
out = msg.substring(sep.length());
|
||||
}
|
||||
|
||||
if (last.equals(sep)) {
|
||||
out = msg.substring(0, msg.length() - sep.length());
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates page separator line
|
||||
*
|
||||
@@ -426,7 +333,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a prettier coordinate, does not include world
|
||||
* Returns a prettier coordinate
|
||||
*
|
||||
* @param loc
|
||||
* @return
|
||||
@@ -435,17 +342,6 @@ public class Helper {
|
||||
return loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ() + " " + loc.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the two locations refer to the same block
|
||||
*
|
||||
* @param loc
|
||||
* @param loc2
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSameBlock(Location loc, Location loc2) {
|
||||
return loc.getBlockX() == loc2.getBlockX() && loc.getBlockY() == loc2.getBlockY() && loc.getBlockZ() == loc2.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a Map by value
|
||||
*
|
||||
@@ -490,19 +386,4 @@ public class Helper {
|
||||
}
|
||||
return String.join(", ", statuses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all passed materials are some kind of AIR
|
||||
*
|
||||
* @param materials materials to test
|
||||
* @return true if all materials are AIR
|
||||
*/
|
||||
public static boolean isAir(@NotNull Material... materials) {
|
||||
for (Material m : materials) {
|
||||
if (!m.name().contains("AIR")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -15,11 +17,11 @@ public class Rank implements Comparable<Rank> {
|
||||
|
||||
public Rank(String name) {
|
||||
setName(name);
|
||||
permissions = new HashSet<String>();
|
||||
permissions = new HashSet<>();
|
||||
setDisplayName(displayName);
|
||||
}
|
||||
|
||||
public Rank(String name, String displayName, Set<String> permissions) {
|
||||
public Rank(String name, @Nullable String displayName, Set<String> permissions) {
|
||||
setName(name);
|
||||
setDisplayName(displayName);
|
||||
setPermissions(permissions);
|
||||
@@ -32,7 +34,7 @@ public class Rank implements Comparable<Rank> {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
public void setDisplayName(@Nullable String displayName) {
|
||||
if (displayName == null || displayName.isEmpty()) {
|
||||
displayName = name;
|
||||
}
|
||||
@@ -41,7 +43,7 @@ public class Rank implements Comparable<Rank> {
|
||||
|
||||
public void setPermissions(Set<String> permissions) {
|
||||
if (permissions == null) {
|
||||
permissions = new HashSet<String>();
|
||||
permissions = new HashSet<>();
|
||||
}
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public enum RankPermission {
|
||||
COORDS("simpleclans.member.coords", PermissionLevel.TRUSTED),
|
||||
FEE_ENABLE("simpleclans.leader.fee", PermissionLevel.LEADER),
|
||||
FEE_SET("simpleclans.leader.fee", PermissionLevel.LEADER),
|
||||
FEE_BYPASS("", PermissionLevel.LEADER),
|
||||
REGROUP_HOME("simpleclans.leader.regroup.home", PermissionLevel.LEADER),
|
||||
REGROUP_ME("simpleclans.leader.regroup.me", PermissionLevel.LEADER),
|
||||
HOME_SET("simpleclans.leader.home-set", PermissionLevel.LEADER),
|
||||
|
||||
@@ -20,8 +20,7 @@ public final class Request {
|
||||
private ClanPlayer requester;
|
||||
private int askCount;
|
||||
|
||||
public Request(SimpleClans plugin,
|
||||
ClanRequest type,
|
||||
public Request(ClanRequest type,
|
||||
@Nullable List<ClanPlayer> acceptors,
|
||||
ClanPlayer requester,
|
||||
String target,
|
||||
|
||||
@@ -3,16 +3,20 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.SCCommandManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.SimpleClansExpansion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.CSVBankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.migrations.BbMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.migrations.ChatFormatMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.migrations.LanguageMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.proxy.BungeeManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.proxy.ProxyManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatFormatMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.UpdateChecker;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@@ -34,6 +38,7 @@ import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
/**
|
||||
* @author Phaed
|
||||
@@ -54,10 +59,12 @@ public class SimpleClans extends JavaPlugin {
|
||||
private TeleportManager teleportManager;
|
||||
private ProtectionManager protectionManager;
|
||||
private ChatManager chatManager;
|
||||
private ProxyManager proxyManager;
|
||||
private boolean hasUUID;
|
||||
private static final Pattern ACF_PLACEHOLDER_PATTERN = Pattern.compile("\\{(?<key>[a-zA-Z]+?)}");
|
||||
|
||||
private BankLogger bankLogger;
|
||||
private TagValidator tagValidator;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
@@ -94,23 +101,27 @@ public class SimpleClans extends JavaPlugin {
|
||||
instance = this;
|
||||
new LanguageMigration(this).migrate();
|
||||
settingsManager = new SettingsManager(this);
|
||||
new BbMigration(settingsManager);
|
||||
new ChatFormatMigration(settingsManager);
|
||||
languageResource = new LanguageResource();
|
||||
this.hasUUID = UUIDMigration.canReturnUUID();
|
||||
|
||||
permissionsManager = new PermissionsManager();
|
||||
requestManager = new RequestManager();
|
||||
clanManager = new ClanManager();
|
||||
proxyManager = new BungeeManager(this);
|
||||
storageManager = new StorageManager();
|
||||
teleportManager = new TeleportManager();
|
||||
protectionManager = new ProtectionManager();
|
||||
protectionManager.registerListeners();
|
||||
chatManager = new ChatManager(this);
|
||||
migrateChatFormat();
|
||||
registerEvents();
|
||||
permissionsManager.loadPermissions();
|
||||
commandManager = new SCCommandManager(this);
|
||||
bankLogger = new CSVBankLogger(this);
|
||||
|
||||
tagValidator = new TagValidator(settingsManager, permissionsManager);
|
||||
|
||||
logStatus();
|
||||
startTasks();
|
||||
startMetrics();
|
||||
@@ -119,30 +130,25 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void logStatus() {
|
||||
getLogger().info("Multithreading: " + SimpleClans.getInstance().getSettingsManager().is(PERFORMANCE_USE_THREADS));
|
||||
getLogger().info("BungeeCord: " + SimpleClans.getInstance().getSettingsManager().is(PERFORMANCE_USE_BUNGEECORD));
|
||||
getLogger().info("Multithreading: " + settingsManager.is(PERFORMANCE_USE_THREADS));
|
||||
getLogger().info("BungeeCord: " + settingsManager.is(PERFORMANCE_USE_BUNGEECORD));
|
||||
getLogger().info("HEX support: " + ChatUtils.HEX_COLOR_SUPPORT);
|
||||
getLogger().info("Help us translate SimpleClans to your language! " +
|
||||
"Access https://crowdin.com/project/simpleclans/");
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(new PlayerDeath(), this);
|
||||
pm.registerEvents(new SCPlayerListener(), this);
|
||||
pm.registerEvents(new PlayerDeath(this), this);
|
||||
pm.registerEvents(new SCPlayerListener(this), this);
|
||||
pm.registerEvents(new InventoryController(), this);
|
||||
pm.registerEvents(new TamableMobsSharing(this), this);
|
||||
pm.registerEvents(new PvPOnlyInWar(this), this);
|
||||
pm.registerEvents(new FriendlyFire(this), this);
|
||||
}
|
||||
|
||||
private void migrateChatFormat() {
|
||||
ChatFormatMigration chatFormatMigration = new ChatFormatMigration();
|
||||
chatFormatMigration.migrateAllyChat();
|
||||
chatFormatMigration.migrateClanChat();
|
||||
}
|
||||
|
||||
private void hookIntoPAPI() {
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
if (getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
getLogger().info("PlaceholderAPI found. Registering hook...");
|
||||
new SimpleClansExpansion(this).register();
|
||||
}
|
||||
@@ -246,6 +252,10 @@ public class SimpleClans extends JavaPlugin {
|
||||
return chatManager;
|
||||
}
|
||||
|
||||
public ProxyManager getProxyManager() {
|
||||
return proxyManager;
|
||||
}
|
||||
|
||||
public BankLogger getBankLogger() {
|
||||
return bankLogger;
|
||||
}
|
||||
@@ -267,7 +277,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable ClanPlayer clanPlayer, Object... arguments) {
|
||||
Locale locale = instance.getSettingsManager().getLanguage();
|
||||
if (clanPlayer != null && instance.getSettingsManager().is(LANGUAGE_SELECTOR)) {
|
||||
if (clanPlayer != null && clanPlayer.getLocale() != null && instance.getSettingsManager().is(LANGUAGE_SELECTOR)) {
|
||||
locale = clanPlayer.getLocale();
|
||||
}
|
||||
|
||||
@@ -344,4 +354,8 @@ public class SimpleClans extends JavaPlugin {
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
|
||||
public TagValidator getTagValidator() {
|
||||
return tagValidator;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,31 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.CLAN_TELEPORT_DELAY;
|
||||
|
||||
public class TeleportState {
|
||||
private final UUID playerUniqueId;
|
||||
private final Location playerLocation;
|
||||
|
||||
private final OfflinePlayer offlinePlayer;
|
||||
private final Location origin;
|
||||
private final Location destination;
|
||||
private int counter;
|
||||
private final String clanName;
|
||||
private boolean processing;
|
||||
|
||||
public TeleportState(Player player, Location destination, String clanName) {
|
||||
public TeleportState(Player player, Location destination, String clanName, int counter) {
|
||||
this.offlinePlayer = player;
|
||||
this.destination = destination;
|
||||
this.playerLocation = player.getLocation();
|
||||
this.origin = player.getLocation();
|
||||
this.clanName = clanName;
|
||||
this.counter = SimpleClans.getInstance().getSettingsManager().getInt(CLAN_TELEPORT_DELAY);
|
||||
this.playerUniqueId = player.getUniqueId();
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation() {
|
||||
return this.playerLocation;
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public boolean isTeleportTime() {
|
||||
@@ -44,7 +43,7 @@ public class TeleportState {
|
||||
* @return the player
|
||||
*/
|
||||
public @Nullable Player getPlayer() {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerUniqueId);
|
||||
return offlinePlayer.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +75,4 @@ public class TeleportState {
|
||||
this.processing = processing;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return this.playerUniqueId;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class War {
|
||||
private final Map<Clan, Integer> clans = new HashMap<>();
|
||||
|
||||
@@ -2,12 +2,15 @@ package net.sacredlabyrinth.phaed.simpleclans.chat;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
public interface ChatHandler {
|
||||
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
SettingsManager settingsManager = plugin.getSettingsManager();
|
||||
ChatManager chatManager = plugin.getChatManager();
|
||||
PermissionsManager permissionsManager = plugin.getPermissionsManager();
|
||||
|
||||
void sendMessage(SCMessage message);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SCMessage {
|
||||
public class SCMessage implements Cloneable {
|
||||
|
||||
private final Source source;
|
||||
private final ClanPlayer.Channel channel;
|
||||
@@ -23,7 +23,8 @@ public class SCMessage {
|
||||
* @param content The content of message
|
||||
* @param receivers The clan players, who will receive the content
|
||||
*/
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel, @NotNull ClanPlayer sender, String content, @NotNull List<ClanPlayer> receivers) {
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel,
|
||||
@NotNull ClanPlayer sender, String content, @NotNull List<ClanPlayer> receivers) {
|
||||
this.source = source;
|
||||
this.channel = channel;
|
||||
this.sender = sender;
|
||||
@@ -34,7 +35,7 @@ public class SCMessage {
|
||||
/**
|
||||
* Creates a new SCMessage without receivers
|
||||
*
|
||||
* @see SCMessage#SCMessage(Source, ClanPlayer.Channel, ClanPlayer, String, List instantiate with initial receievers
|
||||
* @see SCMessage#SCMessage(Source, ClanPlayer.Channel, ClanPlayer, String, List) instantiate with initial receievers
|
||||
*/
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel, @NotNull ClanPlayer sender, String content) {
|
||||
this(source, channel, sender, content, new ArrayList<>());
|
||||
@@ -68,6 +69,15 @@ public class SCMessage {
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SCMessage clone() {
|
||||
try {
|
||||
return (SCMessage) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new Error(); //never thrown
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The place where the message came from.
|
||||
* Used by ChatHandlers to know which SCMessages they can handle.
|
||||
@@ -75,6 +85,6 @@ public class SCMessage {
|
||||
* @see ChatHandler initiate the handler
|
||||
*/
|
||||
public enum Source {
|
||||
SPIGOT, DISCORD, BUNGEE
|
||||
SPIGOT, DISCORD, PROXY
|
||||
}
|
||||
}
|
||||
+9
-10
@@ -5,17 +5,17 @@ import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.DiscordHook;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_ENABLE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_FORMAT_TO;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
/**
|
||||
* Handles delivering messages from {@link Source#SPIGOT} to {@link Source#DISCORD}.
|
||||
@@ -23,27 +23,26 @@ import static org.bukkit.Bukkit.getPluginManager;
|
||||
public class DiscordChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
public void sendMessage(@NotNull SCMessage message) {
|
||||
if (message.getChannel() != CLAN) {
|
||||
return;
|
||||
}
|
||||
|
||||
String format = settingsManager.getString(DISCORDCHAT_FORMAT_TO);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message);
|
||||
String formattedMessage = ChatUtils.stripColors(chatManager.parseChatFormat(format, message));
|
||||
|
||||
Clan clan = message.getSender().getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DiscordHook discordHook = Objects.requireNonNull(chatManager.getDiscordHook(), "DiscordHook cannot be null");
|
||||
Optional<TextChannel> channel = discordHook.getChannel(clan.getTag());
|
||||
Optional<TextChannel> channel = discordHook.getCachedChannel(clan.getTag());
|
||||
channel.ifPresent(textChannel -> DiscordUtil.sendMessage(textChannel, formattedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT && settingsManager.is(DISCORDCHAT_ENABLE) &&
|
||||
getPluginManager().getPlugin("DiscordSRV") != null;
|
||||
return source == SPIGOT && chatManager.isDiscordHookEnabled();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
|
||||
public class ProxyChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
plugin.getProxyManager().sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(Source source) {
|
||||
return source == Source.SPIGOT && settingsManager.is(PERFORMANCE_USE_BUNGEECORD);
|
||||
}
|
||||
}
|
||||
+27
-7
@@ -5,14 +5,15 @@ import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ChatEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_ENABLE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SpigotChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
@@ -30,14 +31,15 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
message.setContent(stripColorsAndFormatsPerPermission(message.getSender(),event.getMessage()));
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == SPIGOT ? message.getChannel() : message.getSource()));
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
|
||||
String format = settingsManager.getString(configField);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message, event.getPlaceholders());
|
||||
|
||||
plugin.getLogger().info(formattedMessage);
|
||||
plugin.getLogger().info(ChatUtils.stripColors(formattedMessage));
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
@@ -46,9 +48,27 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
private String stripColorsAndFormatsPerPermission(ClanPlayer sender, String message) {
|
||||
if (!permissionsManager.has(sender.toPlayer(), "simpleclans.member.chat.color")) {
|
||||
message = stripColors(message);
|
||||
}
|
||||
if (!permissionsManager.has(sender.toPlayer(), "simpleclans.member.chat.format")) {
|
||||
message = stripFormats(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private String stripColors(String message) {
|
||||
return message.replaceAll("[§&][0-9a-fA-FxX]", "");
|
||||
}
|
||||
|
||||
private String stripFormats(String message) {
|
||||
return message.replaceAll("[§&][k-orK-OR]", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == DISCORD && settingsManager.is(DISCORDCHAT_ENABLE) &&
|
||||
getPluginManager().getPlugin("DiscordSRV") != null);
|
||||
return source == SPIGOT || (source == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|| (source == DISCORD && chatManager.isDiscordHookEnabled());
|
||||
}
|
||||
}
|
||||
+24
-20
@@ -4,48 +4,52 @@ import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_ENABLE;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
|
||||
/**
|
||||
* Handles delivering messages from {@link Source#SPIGOT} and {@link Source#DISCORD} to internal spy chat.
|
||||
* Handles delivering messages from {@link Source#SPIGOT} or {@link Source#DISCORD} to internal spy chat.
|
||||
*/
|
||||
public class SpyChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_SPYFORMAT",
|
||||
message.getSource() == SPIGOT ? message.getChannel() : message.getSource()));
|
||||
String format = settingsManager.getString(configField);
|
||||
|
||||
ConfigField formatField = ConfigField.valueOf(String.format("%sCHAT_SPYFORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
String format = settingsManager.getString(formatField);
|
||||
message.setContent(ChatUtils.stripColors(message.getContent()));
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message);
|
||||
|
||||
List<ClanPlayer> onlinePlayers = getOnlineClanPlayers().stream()
|
||||
.filter(player -> plugin.getPermissionsManager().has(player.toPlayer(), "simpleclans.admin.all-seeing-eye"))
|
||||
.filter(player -> !player.isMuted())
|
||||
.collect(Collectors.toList());
|
||||
List<ClanPlayer> onlineSpies = getOnlineSpies();
|
||||
|
||||
onlinePlayers.removeAll(message.getReceivers());
|
||||
onlinePlayers.forEach(receiver -> ChatBlock.sendMessage(receiver, formattedMessage));
|
||||
// Don't send a duplicate message if a spy is inside the clan
|
||||
onlineSpies.removeAll(message.getReceivers());
|
||||
onlineSpies.forEach(receiver -> ChatBlock.sendMessage(receiver, formattedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == DISCORD && settingsManager.is(DISCORDCHAT_ENABLE) &&
|
||||
getPluginManager().getPlugin("DiscordSRV") != null);
|
||||
return source == SPIGOT || (source == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|| (source == DISCORD && chatManager.isDiscordHookEnabled());
|
||||
}
|
||||
|
||||
private List<ClanPlayer> getOnlineClanPlayers() {
|
||||
return plugin.getClanManager().getAllClanPlayers().stream().
|
||||
filter(cp -> cp.toPlayer() != null).
|
||||
private List<ClanPlayer> getOnlineSpies() {
|
||||
return new ArrayList<>(Bukkit.getOnlinePlayers()).stream().
|
||||
filter(Objects::nonNull).
|
||||
filter(player -> permissionsManager.has(player, "simpleclans.admin.all-seeing-eye")).
|
||||
map(player -> plugin.getClanManager().getCreateClanPlayer(player.getUniqueId())).
|
||||
filter(Objects::nonNull).
|
||||
filter(clanPlayer -> !clanPlayer.isMuted()).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
registerCommands();
|
||||
registerConditions();
|
||||
registerCompletions();
|
||||
defaultHelpPerPage = plugin.getSettingsManager().getInt(HELP_SIZE);
|
||||
}
|
||||
|
||||
private void registerDependencies() {
|
||||
@@ -218,11 +219,11 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
SUBCOMMANDS = Arrays.asList("setbanner", "resetkdr", "place", "rank", "home", "war", "regroup",
|
||||
"mostkilled", "kills", "globalff", "reload", "unban", "ban", "verify", "disband", "resign", "ff",
|
||||
"clanff", "demote", "promote", "untrust", "trust", "purge", "fee", "bank", "kick", "invite", "toggle",
|
||||
"modtag", "bb", "clear", "rival", "ally", "add", "remove", "stats", "coords", "vitals", "rivalries",
|
||||
"modtag", "bb", "display", "clear", "rival", "ally", "add", "remove", "stats", "coords", "vitals", "rivalries",
|
||||
"alliances", "leaderboard", "allow", "block", "auto", "check", "assign", "unassign", "delete", "me",
|
||||
"setdisplayname", "permissions", "tag", "deposit", "withdraw", "set", "status", "tp", "all", "everyone",
|
||||
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help", "mod",
|
||||
"setdefault", "removedefault", "land", "break", "interact", "place_block", "damage", "interact_entity",
|
||||
"container", "permanent", "take", "give", "join", "leave", "mute", "confirm", "balance");
|
||||
"container", "permanent", "take", "give", "join", "leave", "mute", "confirm", "balance", "discord", "rename", "locale");
|
||||
}
|
||||
}
|
||||
+17
-15
@@ -7,13 +7,15 @@ import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.EconomyResponse;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.BankDepositEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.BankWithdrawEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.Cause.COMMAND;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.Cause.REVERT;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@@ -67,18 +69,17 @@ public class BankCommand extends BaseCommand {
|
||||
/*
|
||||
* ——————————————————————————————————
|
||||
*/
|
||||
switch (clan.withdraw(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount)) {
|
||||
case SUCCESS:
|
||||
if (permissions.playerGrantMoney(player, amount)) {
|
||||
BankOperator operator = new BankOperator(player, permissions.playerGetMoney(player));
|
||||
switch (clan.withdraw(operator, COMMAND, amount)) {
|
||||
case SUCCESS -> {
|
||||
if (permissions.grantPlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
clan.addBb(player.getName(), lang("bb.clan.withdraw", amount, player.getName()));
|
||||
} else {
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, BankLogger.Operation.WITHDRAW, clan.getBalance() + amount);
|
||||
clan.setBalance(operator, REVERT, BankLogger.Operation.WITHDRAW, clan.getBalance() + amount);
|
||||
}
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
player.sendMessage(lang("clan.bank.not.enough.money", player));
|
||||
break;
|
||||
}
|
||||
case NOT_ENOUGH_BALANCE -> player.sendMessage(lang("clan.bank.not.enough.money", player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,17 +121,18 @@ public class BankCommand extends BaseCommand {
|
||||
*/
|
||||
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
return;
|
||||
}
|
||||
EconomyResponse response = clan.deposit(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
BankOperator operator = new BankOperator(player, permissions.playerGetMoney(player));
|
||||
EconomyResponse response = clan.deposit(operator, COMMAND, amount);
|
||||
if (response == EconomyResponse.SUCCESS) {
|
||||
if (permissions.playerChargeMoney(player, amount)) {
|
||||
if (permissions.chargePlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount));
|
||||
clan.addBb(player.getName(), lang("bb.clan.deposit", amount, player.getName()));
|
||||
} else {
|
||||
//Reverts the deposit if something went wrong with Vault
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, BankLogger.Operation.DEPOSIT, clan.getBalance() - amount);
|
||||
clan.setBalance(operator, REVERT, BankLogger.Operation.DEPOSIT, clan.getBalance() - amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
@@ -21,6 +22,8 @@ public class BbCommand extends BaseCommand {
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
|
||||
@Subcommand("%bb")
|
||||
@CommandPermission("simpleclans.member.bb")
|
||||
@@ -46,7 +49,8 @@ public class BbCommand extends BaseCommand {
|
||||
@Description("{@@command.description.bb.post}")
|
||||
public void postMessage(Player player, @Name("message") String msg) {
|
||||
Clan clan = Objects.requireNonNull(cm.getClanByPlayerUniqueId(player.getUniqueId()));
|
||||
clan.addBb(player.getName(), AQUA + player.getName() + ": " + WHITE + msg);
|
||||
clan.addBb(lang("bulletin.board.message", player.getName(), msg));
|
||||
clan.displayBb(player);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
@@ -22,8 +21,6 @@ public class ChatCommand extends BaseCommand {
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
@Dependency
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Default
|
||||
|
||||
+19
-19
@@ -10,12 +10,12 @@ import net.sacredlabyrinth.phaed.simpleclans.conversation.SCConversation;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
@@ -91,9 +91,9 @@ public class ClanCommands extends BaseCommand {
|
||||
tag = event.getNewTag();
|
||||
String cleanTag = Helper.cleanTag(tag);
|
||||
|
||||
TagValidator validator = new TagValidator(plugin, player, tag);
|
||||
if (validator.getErrorMessage() != null) {
|
||||
ChatBlock.sendMessage(player, validator.getErrorMessage());
|
||||
Optional<String> validationError = plugin.getTagValidator().validate(player, tag);
|
||||
if (validationError.isPresent()) {
|
||||
ChatBlock.sendMessage(player, validationError.get());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ClanCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.addBb(player.getName(), lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.changeClanTag(tag);
|
||||
cm.updateDisplayName(player);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Description("{@@command.description.invite}")
|
||||
public void invite(Player sender, ClanPlayer cp, Clan clan,
|
||||
@Conditions("not_banned|not_in_clan|online:ignore_vanished") @Name("player") ClanPlayerInput invited) {
|
||||
if (!invited.getClanPlayer().isInviteEnabled()){
|
||||
if (!invited.getClanPlayer().isInviteEnabled()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("invitedplayer.invite.off", sender));
|
||||
return;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class ClanCommands extends BaseCommand {
|
||||
}
|
||||
if (cm.purchaseMemberFeeSet(player)) {
|
||||
clan.setMemberFee(fee);
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.fee.set", fee));
|
||||
clan.addBb(player.getName(), lang("bb.fee.set", fee));
|
||||
ChatBlock.sendMessage(player, AQUA + lang("fee.set", player));
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Conditions("rank:name=FRIENDLYFIRE")
|
||||
@Description("{@@command.description.clanff.allow}")
|
||||
public void allowClanFf(Player player, Clan clan) {
|
||||
clan.addBb(player.getName(), AQUA + lang("clan.wide.friendly.fire.is.allowed"));
|
||||
clan.addBb(player.getName(), lang("clan.wide.friendly.fire.is.allowed"));
|
||||
clan.setFriendlyFire(true);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.ff")
|
||||
@Description("{@@command.description.clanff.block}")
|
||||
public void blockClanFf(Player player, Clan clan) {
|
||||
clan.addBb(player.getName(), AQUA + lang("clan.wide.friendly.fire.blocked"));
|
||||
clan.addBb(player.getName(), lang("clan.wide.friendly.fire.blocked"));
|
||||
clan.setFriendlyFire(false);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Subcommand("%rival %add")
|
||||
@CommandPermission("simpleclans.leader.rival")
|
||||
@Conditions("verified|rivable|minimum_to_rival|rank:name=RIVAL_ADD")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.rival.add}")
|
||||
public void addRival(Player player, Clan issuerClan, @Conditions("verified|different") @Name("clan") ClanInput rival) {
|
||||
Clan rivalInput = rival.getClan();
|
||||
@@ -252,9 +252,9 @@ public class ClanCommands extends BaseCommand {
|
||||
if (!issuerClan.reachedRivalLimit()) {
|
||||
if (!issuerClan.isRival(rivalInput.getTag())) {
|
||||
issuerClan.addRival(rivalInput);
|
||||
rivalInput.addBb(player.getName(), AQUA + lang("has.initiated.a.rivalry", issuerClan.getName(),
|
||||
rivalInput.addBb(player.getName(), lang("has.initiated.a.rivalry", issuerClan.getName(),
|
||||
rivalInput.getName()), false);
|
||||
issuerClan.addBb(player.getName(), AQUA + lang("has.initiated.a.rivalry", player.getName(),
|
||||
issuerClan.addBb(player.getName(), lang("has.initiated.a.rivalry", player.getName(),
|
||||
rivalInput.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.rivals", player));
|
||||
@@ -286,7 +286,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Subcommand("%ally %add")
|
||||
@CommandPermission("simpleclans.leader.ally")
|
||||
@Conditions("verified|rank:name=ALLY_ADD|minimum_to_ally")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.ally.add}")
|
||||
public void addAlly(Player player,
|
||||
ClanPlayer cp,
|
||||
@@ -329,15 +329,15 @@ public class ClanCommands extends BaseCommand {
|
||||
public void removeAlly(Player player, Clan issuerClan, @Conditions("different|allied_clan") @Name("clan") ClanInput ally) {
|
||||
Clan allyInput = ally.getClan();
|
||||
issuerClan.removeAlly(allyInput);
|
||||
allyInput.addBb(player.getName(), AQUA + lang("has.broken.the.alliance", issuerClan.getName(),
|
||||
allyInput.addBb(player.getName(), lang("has.broken.the.alliance", issuerClan.getName(),
|
||||
allyInput.getName()), false);
|
||||
issuerClan.addBb(player.getName(), AQUA + lang("has.broken.the.alliance", player.getName(),
|
||||
issuerClan.addBb(player.getName(), lang("has.broken.the.alliance", player.getName(),
|
||||
allyInput.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("%kick")
|
||||
@CommandPermission("simpleclans.leader.kick")
|
||||
@CommandCompletion("@clan_members")
|
||||
@CommandCompletion("@clan_members:hide_own")
|
||||
@Conditions("rank:name=KICK")
|
||||
@Description("{@@command.description.kick}")
|
||||
public void kick(@Conditions("clan_member") Player sender,
|
||||
@@ -354,7 +354,7 @@ public class ClanCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(sender.getName(), AQUA + lang("has.been.kicked.by", clanPlayer.getName(),
|
||||
clan.addBb(sender.getName(), lang("has.been.kicked.by", clanPlayer.getName(),
|
||||
sender.getName(), sender));
|
||||
clan.removePlayerFromClan(clanPlayer.getUniqueId());
|
||||
}
|
||||
@@ -365,11 +365,11 @@ public class ClanCommands extends BaseCommand {
|
||||
@HelpSearchTags("leave")
|
||||
public void resignConfirm(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (clan.isPermanent() || !clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
|
||||
clan.addBb(player.getName(), lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
ChatBlock.sendMessage(cp,AQUA + lang("resign.success", player));
|
||||
ChatBlock.sendMessage(cp, AQUA + lang("resign.success", player));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband(player, true, false);
|
||||
ChatBlock.sendMessage(cp, RED + lang("clan.has.been.disbanded", player, clan.getName()));
|
||||
|
||||
+13
-15
@@ -4,12 +4,14 @@ import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.HomeRegroupEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeClearEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -59,17 +61,12 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.regroup.home")
|
||||
@Conditions("rank:name=REGROUP_HOME")
|
||||
@Description("{@@command.description.regroup.home}")
|
||||
public void regroupHome(Player player, ClanPlayer cp, Clan clan) {
|
||||
public void regroupHome(Player player, ClanPlayer cp, @Conditions("can_teleport") Clan clan) {
|
||||
if (!settings.is(ALLOW_REGROUP)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
Location location = clan.getHomeLocation();
|
||||
if (location == null) {
|
||||
ChatBlock.sendMessage(player, RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
processRegroup(player, cp, clan, location);
|
||||
}
|
||||
|
||||
@@ -77,16 +74,11 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.member.home")
|
||||
@Conditions("rank:name=HOME_TP")
|
||||
@Description("{@@command.description.home.tp}")
|
||||
public void teleport(Player player, Clan clan, ClanPlayer cp) {
|
||||
Location loc = clan.getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
public void teleport(Player player, @Conditions("can_teleport") Clan clan, ClanPlayer cp) {
|
||||
Location homeLocation = clan.getHomeLocation();
|
||||
|
||||
if (cm.purchaseHomeTeleport(player)) {
|
||||
plugin.getTeleportManager().addPlayer(player, clan.getHomeLocation(), clan.getName());
|
||||
plugin.getTeleportManager().addPlayer(player, homeLocation, clan.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,13 +86,19 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.home-set")
|
||||
@Conditions("rank:name=HOME_SET")
|
||||
@Description("{@@command.description.home.clear}")
|
||||
public void clear(Player player, Clan clan) {
|
||||
public void clear(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (settings.is(CLAN_HOMEBASE_CAN_BE_SET_ONLY_ONCE) && clan.getHomeLocation() != null &&
|
||||
!permissions.has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("home.base.only.once", player));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHomeClearEvent event = new PlayerHomeClearEvent(clan, cp);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(null);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.cleared", player));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.Con
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%land")
|
||||
@Conditions("%basic_conditions|land_sharing|own_land")
|
||||
@Conditions("%basic_conditions|clan_member|land_sharing|own_land")
|
||||
@CommandPermission("simpleclans.member.land")
|
||||
public class LandCommand extends BaseCommand {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class LandCommand extends BaseCommand {
|
||||
cp.allow(action, land.getId());
|
||||
}
|
||||
if (notify) {
|
||||
ChatBlock.sendMessageKey(cp.toPlayer(), "land.allowed.action");
|
||||
ChatBlock.sendMessageKey(cp, "land.allowed.action");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class LandCommand extends BaseCommand {
|
||||
cp.disallow(action, land.getId());
|
||||
}
|
||||
if (notify) {
|
||||
ChatBlock.sendMessageKey(cp.toPlayer(), "land.blocked.action");
|
||||
ChatBlock.sendMessageKey(cp, "land.blocked.action");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+78
-11
@@ -2,10 +2,12 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.DisbandPrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.SCConversation;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions.DiscordHookException;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,6 +15,7 @@ import org.bukkit.entity.Player;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.EconomyTransactionEvent.Cause.DISCORD_CREATION;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
@@ -21,6 +24,8 @@ import static org.bukkit.ChatColor.RED;
|
||||
@Conditions("%basic_conditions|leader")
|
||||
public class LeaderCommands extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private SimpleClans plugin;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
@@ -31,6 +36,8 @@ public class LeaderCommands extends BaseCommand {
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
|
||||
@Subcommand("%demote")
|
||||
@CommandCompletion("@clan_leaders")
|
||||
@@ -55,7 +62,7 @@ public class LeaderCommands extends BaseCommand {
|
||||
player));
|
||||
return;
|
||||
}
|
||||
clan.addBb(player.getName(), AQUA + lang("demoted.back.to.member", otherCp.getName()));
|
||||
clan.addBb(player.getName(), lang("demoted.back.to.member", otherCp.getName()));
|
||||
clan.demote(otherCp.getUniqueId());
|
||||
}
|
||||
|
||||
@@ -82,13 +89,13 @@ public class LeaderCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
if (settings.is(CLAN_CONFIRMATION_FOR_PROMOTE) && clan.getLeaders().size() > 1) {
|
||||
requestManager.addPromoteRequest(cp, otherPl.getName(), clan);
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.PROMOTE, otherPl.getName(), "asking.for.the.promotion", otherPl.getName());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("promotion.vote.has.been.requested.from.all.leaders",
|
||||
player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("promoted.to.leader", otherPl.getName()));
|
||||
clan.addBb(player.getName(), lang("promoted.to.leader", otherPl.getName()));
|
||||
clan.promote(otherPl.getUniqueId());
|
||||
}
|
||||
|
||||
@@ -97,13 +104,13 @@ public class LeaderCommands extends BaseCommand {
|
||||
@Description("{@@command.description.disband}")
|
||||
public void disband(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
requestManager.addDisbandRequest(cp, clan);
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.DISBAND, clan.getTag(), "asking.to.disband");
|
||||
ChatBlock.sendMessage(player, AQUA +
|
||||
lang("clan.disband.vote.has.been.requested.from.all.leaders", player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.disband(player, true, false);
|
||||
new SCConversation(plugin, player, new DisbandPrompt()).begin();
|
||||
}
|
||||
|
||||
@Subcommand("%verify")
|
||||
@@ -125,7 +132,7 @@ public class LeaderCommands extends BaseCommand {
|
||||
}
|
||||
if (cm.purchaseVerification(player)) {
|
||||
clan.verifyClan();
|
||||
clan.addBb(player.getName(), AQUA + lang("clan.0.has.been.verified", clan.getName()));
|
||||
clan.addBb(player.getName(), lang("clan.0.has.been.verified", clan.getName()));
|
||||
ChatBlock.sendMessage(player, AQUA + lang("the.clan.has.been.verified", player));
|
||||
}
|
||||
}
|
||||
@@ -148,7 +155,7 @@ public class LeaderCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("this.player.is.already.trusted", player));
|
||||
return;
|
||||
}
|
||||
clan.addBb(player.getName(), AQUA + lang("has.been.given.trusted.status.by", trustedInput.getName(),
|
||||
clan.addBb(player.getName(), lang("has.been.given.trusted.status.by", trustedInput.getName(),
|
||||
player.getName()));
|
||||
trustedInput.setTrusted(true);
|
||||
storage.updateClanPlayer(trustedInput);
|
||||
@@ -173,9 +180,69 @@ public class LeaderCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("has.been.given.untrusted.status.by", trustedInput.getName(),
|
||||
clan.addBb(player.getName(), lang("has.been.given.untrusted.status.by", trustedInput.getName(),
|
||||
player.getName()));
|
||||
trustedInput.setTrusted(false);
|
||||
storage.updateClanPlayer(trustedInput);
|
||||
}
|
||||
|
||||
@Subcommand("%rename")
|
||||
@CommandPermission("simpleclans.leader.rename")
|
||||
@CommandCompletion("@nothing")
|
||||
@Description("{@@command.description.rename}")
|
||||
public void rename(ClanPlayer cp, Clan clan, @Name("name") String clanName) {
|
||||
if (clanName.contains("&")) {
|
||||
ChatBlock.sendMessageKey(cp, "your.clan.name.cannot.contain.color.codes");
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.RENAME, "asking.to.rename", clanName);
|
||||
ChatBlock.sendMessageKey(cp, "rename.vote.has.been.requested.from.all.leaders");
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setName(clanName);
|
||||
storage.updateClan(clan);
|
||||
|
||||
ChatBlock.sendMessageKey(cp, "you.have.successfully.renamed.your.clan", clanName);
|
||||
}
|
||||
|
||||
@Subcommand("%discord %create")
|
||||
@CommandPermission("simpleclans.leader.discord.create")
|
||||
@Description("{@@command.description.discord.create}")
|
||||
@Conditions("verified")
|
||||
public void discord(Player player, Clan clan) {
|
||||
DiscordHook discordHook = chatManager.getDiscordHook();
|
||||
if (discordHook == null) {
|
||||
ChatBlock.sendMessageKey(player, "discordhook.is.disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
double amount = settings.getDouble(ECONOMY_DISCORD_CREATION_PRICE);
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!permissions.chargePlayer(player, amount, DISCORD_CREATION)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
discordHook.createChannel(clan.getTag());
|
||||
ChatBlock.sendMessageKey(player, "discord.created.successfully");
|
||||
} catch (DiscordHookException ex) {
|
||||
// Return player's money if clan creation went wrong
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
permissions.grantPlayer(player, amount, DISCORD_CREATION);
|
||||
}
|
||||
String messageKey = ex.getMessageKey();
|
||||
if (messageKey != null) {
|
||||
ChatBlock.sendMessage(player, RED + lang(messageKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class RankCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("%permissions")
|
||||
public class PermissionsCommand extends BaseCommand {
|
||||
private final String validPermissionsToMessage = Helper.toMessage(Helper.fromPermissionArray(), ",");
|
||||
private final String validPermissionsToMessage = String.join(",", Helper.fromPermissionArray());
|
||||
|
||||
@Default
|
||||
@CommandPermission("simpleclans.leader.rank.permissions.available")
|
||||
@@ -178,7 +178,7 @@ public class RankCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.permissions", player, rank.getDisplayName()));
|
||||
ChatBlock.sendMessage(player, AQUA + Helper.toMessage(permissions.toArray(new String[0]), ","));
|
||||
ChatBlock.sendMessage(player, AQUA + String.join(",", permissions));
|
||||
}
|
||||
|
||||
@Subcommand("%add")
|
||||
|
||||
+7
-1
@@ -10,8 +10,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanMembersCompletion extends AbstractSyncCompletion {
|
||||
public ClanMembersCompletion(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
@@ -23,7 +25,11 @@ public class ClanMembersCompletion extends AbstractSyncCompletion {
|
||||
if (player != null) {
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
return clan.getMembers().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
List<String> list = clan.getMembers().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
if (c.hasConfig("hide_own")) {
|
||||
list.remove(player.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
+17
-5
@@ -1,14 +1,16 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ClansCompletion extends AbstractSyncCompletion {
|
||||
public ClansCompletion(@NotNull SimpleClans plugin) {
|
||||
@@ -17,18 +19,28 @@ public class ClansCompletion extends AbstractSyncCompletion {
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext c) throws InvalidCommandArgument {
|
||||
Stream<Clan> clans = clanManager.getClans().stream();
|
||||
List<Clan> clans = clanManager.getClans();
|
||||
if (c.hasConfig("has_home")) {
|
||||
clans = clans.filter(clan -> clan.getHomeLocation() != null);
|
||||
clans.removeIf(clan -> clan.getHomeLocation() == null);
|
||||
}
|
||||
if (c.hasConfig("unverified")) {
|
||||
clans = clans.filter(clan -> !clan.isVerified());
|
||||
clans.removeIf(Clan::isVerified);
|
||||
}
|
||||
return clans.map(Clan::getTag).collect(Collectors.toList());
|
||||
if (c.hasConfig("hide_own")) {
|
||||
Clan clan = getClan(c.getIssuer());
|
||||
if (clan != null) {
|
||||
clans.remove(clan);
|
||||
}
|
||||
}
|
||||
return clans.stream().map(Clan::getTag).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "clans";
|
||||
}
|
||||
|
||||
private @Nullable Clan getClan(CommandIssuer issuer) {
|
||||
return clanManager.getClanByPlayerUniqueId(issuer.getUniqueId());
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class LocaleCompletion extends AbstractStaticCompletion {
|
||||
|
||||
private final List<String> availableLocales;
|
||||
|
||||
public LocaleCompletion(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
availableLocales = LanguageResource.getAvailableLocales().stream().
|
||||
map(locale -> locale.toLanguageTag().replace("-", "_")).
|
||||
toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<String> getCompletions() {
|
||||
return availableLocales;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "locales";
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Flags;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class TeleportCondition extends AbstractParameterCondition<Clan> {
|
||||
|
||||
public TeleportCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Clan> getType() {
|
||||
return Clan.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext,
|
||||
Clan value) throws InvalidCommandArgument {
|
||||
Player player = execContext.getPlayer();
|
||||
if (value.getHomeLocation() == null) {
|
||||
throw new ConditionFailedException(lang("hombase.not.set", player));
|
||||
}
|
||||
Flags flags = new Flags(value.getFlags());
|
||||
String homeServer = flags.getString("homeServer", "");
|
||||
if (!homeServer.isEmpty() && !plugin.getProxyManager().getServerName().equals(homeServer)) {
|
||||
throw new ConditionFailedException(lang("home.set.in.different.server"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "can_teleport";
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TeleportInputCondition extends AbstractParameterCondition<ClanInput> {
|
||||
|
||||
public TeleportInputCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
return ClanInput.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context, BukkitCommandExecutionContext execContext, ClanInput value) throws InvalidCommandArgument {
|
||||
new TeleportCondition(plugin).validateCondition(context, execContext, value.getClan());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "can_teleport";
|
||||
}
|
||||
}
|
||||
+17
-5
@@ -2,32 +2,43 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.MinecraftMessageKeys;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.USERNAME_REGEX;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextResolver<ClanPlayerInput> {
|
||||
|
||||
private final Pattern validUsername;
|
||||
|
||||
public ClanPlayerInputContextResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
validUsername = Pattern.compile(plugin.getSettingsManager().getString(USERNAME_REGEX));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanPlayerInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
String arg = context.popFirstArg();
|
||||
if (!validUsername.matcher(arg).matches()) {
|
||||
throw new InvalidCommandArgument(MinecraftMessageKeys.IS_NOT_A_VALID_NAME, "{name}", arg);
|
||||
}
|
||||
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(arg);
|
||||
if (cp == null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(arg);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
Player player = Bukkit.getPlayer(arg);
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument(lang("user.hasnt.played.before", context.getSender()));
|
||||
}
|
||||
cp = clanManager.getCreateClanPlayer(offlinePlayer.getUniqueId());
|
||||
cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
return new ClanPlayerInput(cp);
|
||||
@@ -37,4 +48,5 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
return ClanPlayerInput.class;
|
||||
}
|
||||
|
||||
}
|
||||
+11
-2
@@ -2,12 +2,12 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.MessageKeys;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static co.aikar.commands.MessageKeys.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class Contexts {
|
||||
@@ -30,8 +30,17 @@ public class Contexts {
|
||||
public static Player assertPlayer(@NotNull BukkitCommandIssuer issuer) {
|
||||
Player player = issuer.getPlayer();
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false);
|
||||
throw new InvalidCommandArgument(NOT_ALLOWED_ON_CONSOLE, false);
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
public static void validateMinMax(Number val, Number minValue, Number maxValue) throws InvalidCommandArgument {
|
||||
if (maxValue != null && val.doubleValue() > maxValue.doubleValue()) {
|
||||
throw new InvalidCommandArgument(PLEASE_SPECIFY_AT_MOST, "{max}", String.valueOf(maxValue));
|
||||
}
|
||||
if (minValue != null && val.doubleValue() < minValue.doubleValue()) {
|
||||
throw new InvalidCommandArgument(PLEASE_SPECIFY_AT_LEAST, "{min}", String.valueOf(minValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class DoubleContextResolver extends DoublePrimitiveContextResolver {
|
||||
public DoubleContextResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Double> getType() {
|
||||
return Double.class;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.MessageKeys;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.commands.contexts.Contexts.validateMinMax;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class DoublePrimitiveContextResolver extends AbstractInputOnlyContextResolver<Double> {
|
||||
|
||||
public DoublePrimitiveContextResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
String number = context.popFirstArg();
|
||||
try {
|
||||
double val = Double.parseDouble(number);
|
||||
if (!Double.isFinite(val)) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
validateMinMax(val, Double.MIN_VALUE, Double.MAX_VALUE);
|
||||
return val;
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER, "{num}", number);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Double> getType() {
|
||||
return double.class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class FloatContextResolver extends FloatPrimitiveContextResolver {
|
||||
public FloatContextResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Float> getType() {
|
||||
return Float.class;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.MessageKeys;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.commands.contexts.Contexts.validateMinMax;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class FloatPrimitiveContextResolver extends AbstractInputOnlyContextResolver<Float> {
|
||||
public FloatPrimitiveContextResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
String number = context.popFirstArg();
|
||||
try {
|
||||
float val = Float.parseFloat(number);
|
||||
if (!Float.isFinite(val)) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
validateMinMax(val, Float.MIN_VALUE, Float.MAX_VALUE);
|
||||
return val;
|
||||
} catch (NumberFormatException e) {
|
||||
throw new InvalidCommandArgument(MessageKeys.MUST_BE_A_NUMBER, "{num}", number);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Float> getType() {
|
||||
return float.class;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,10 +34,8 @@ public class ClanRoster extends Sendable {
|
||||
List<ClanPlayer> members = clan.getNonLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(members);
|
||||
for (ClanPlayer cp : members) {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR)) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender) : GREEN + lang("online", sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
@@ -48,11 +45,9 @@ public class ClanRoster extends Sendable {
|
||||
List<ClanPlayer> leaders = clan.getLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(leaders);
|
||||
for (ClanPlayer cp : leaders) {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = sm.getColored(PAGE_LEADER_COLOR) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender)
|
||||
: WHITE + cp.getLastSeenDaysString(sender);
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender) :
|
||||
GREEN + lang("online", sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.RankingNumberResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class Leaderboard extends Sendable {
|
||||
|
||||
private void addLines() {
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
boolean online = cp.toPlayer() != null;
|
||||
boolean online = !VanishUtils.isVanished(cp);
|
||||
|
||||
String name = (cp.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) :
|
||||
sm.getColored(PAGE_UNTRUSTED_COLOR))) + cp.getName();
|
||||
|
||||
@@ -66,8 +66,8 @@ public class Vitals extends Sendable {
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR)
|
||||
: sm.getColored(PAGE_UNTRUSTED_COLOR))) + cpm.getName();
|
||||
String health = cm.getHealthString(p.getHealth());
|
||||
String hunger = cm.getHungerString(p.getFoodLevel());
|
||||
String health = cm.getBar(p.getHealth());
|
||||
String hunger = cm.getBar(p.getFoodLevel());
|
||||
String armor = cm.getArmorString(p.getInventory());
|
||||
String weapons = cm.getWeaponString(p.getInventory());
|
||||
String food = cm.getFoodString(p.getInventory());
|
||||
|
||||
+35
-12
@@ -5,22 +5,22 @@ import co.aikar.commands.CommandHelp;
|
||||
import co.aikar.commands.CommandParameter;
|
||||
import co.aikar.commands.HelpEntry;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.data.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanTagPrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.RequestCanceller;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.ResetKdrPrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.SCConversation;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerResetKdrEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.RequestManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.MainFrame;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -52,7 +52,6 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Default
|
||||
@Description("{@@command.description.clan}")
|
||||
@CommandAlias("%clan")
|
||||
@HelpSearchTags("menu gui interface ui")
|
||||
public void main(CommandSender sender) {
|
||||
if (sender instanceof Player && settings.is(ENABLE_GUI)) {
|
||||
@@ -63,6 +62,17 @@ public class GeneralCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%locale")
|
||||
@CommandPermission("simpleclans.anyone.locale")
|
||||
@Description("{@@command.description.locale}")
|
||||
@CommandCompletion("@locales")
|
||||
public void locale(ClanPlayer cp, @Values("@locales") @Name("locale") String locale) {
|
||||
cp.setLocale(Helper.forLanguageTag(locale.replace("_", "-")));
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
|
||||
ChatBlock.sendMessage(cp, lang("locale.has.been.changed"));
|
||||
}
|
||||
|
||||
@Subcommand("%create")
|
||||
@CommandPermission("simpleclans.leader.create")
|
||||
@Description("{@@command.description.create}")
|
||||
@@ -123,7 +133,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%profile")
|
||||
@CommandPermission("simpleclans.anyone.profile")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.profile.other}")
|
||||
public void profile(CommandSender sender, @Conditions("verified") @Name("clan") ClanInput clan) {
|
||||
ClanProfile p = new ClanProfile(plugin, sender, clan.getClan());
|
||||
@@ -131,7 +141,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
}
|
||||
|
||||
@Subcommand("%roster")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@CommandPermission("simpleclans.anyone.roster")
|
||||
@Description("{@@command.description.roster.other}")
|
||||
public void roster(CommandSender sender, @Conditions("verified") @Name("clan") ClanInput clan) {
|
||||
@@ -157,17 +167,30 @@ public class GeneralCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, AQUA + lang("friendy.fire.is.now.managed.by.your.clan", player));
|
||||
}
|
||||
|
||||
@Subcommand("%resetkdr %confirm")
|
||||
@CommandPermission("simpleclans.vip.resetkdr")
|
||||
@Description("{@@command.description.resetkdr}")
|
||||
public void resetKdrConfirm(Player player, ClanPlayer cp) {
|
||||
if (!settings.is(ALLOW_RESET_KDR)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("disabled.command", player));
|
||||
return;
|
||||
}
|
||||
PlayerResetKdrEvent event = new PlayerResetKdrEvent(cp);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && cm.purchaseResetKdr(player)) {
|
||||
cm.resetKdr(cp);
|
||||
ChatBlock.sendMessage(player, RED + lang("you.have.reseted.your.kdr", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%resetkdr")
|
||||
@CommandPermission("simpleclans.vip.resetkdr")
|
||||
@Description("{@@command.description.resetkdr}")
|
||||
public void resetKdr(Player player, ClanPlayer cp) {
|
||||
if (!settings.is(ALLOW_RESET_KDR)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("disabled.command", player));
|
||||
return;
|
||||
}
|
||||
if (cm.purchaseResetKdr(player)) {
|
||||
cm.resetKdr(cp);
|
||||
ChatBlock.sendMessage(player, RED + lang("you.have.reseted.your.kdr", player));
|
||||
} else {
|
||||
new SCConversation(plugin, player, new ResetKdrPrompt(cm), 60).begin();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-6
@@ -8,7 +8,10 @@ import net.sacredlabyrinth.phaed.simpleclans.EconomyResponse;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.RED;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -19,6 +22,9 @@ import static org.bukkit.ChatColor.AQUA;
|
||||
@Subcommand("%admin %bank")
|
||||
public class BankCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
|
||||
@Subcommand("%status")
|
||||
@CommandPermission("simpleclans.admin.bank.status")
|
||||
@CommandCompletion("@clans")
|
||||
@@ -35,12 +41,13 @@ public class BankCommand extends BaseCommand {
|
||||
public void take(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
BankOperator operator = new BankOperator(sender, sender instanceof Player ? permissions.playerGetMoney((Player) sender) : 0);
|
||||
|
||||
EconomyResponse economyResponse = clan.withdraw(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
EconomyResponse economyResponse = clan.withdraw(operator, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
switch (economyResponse) {
|
||||
case SUCCESS:
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.take", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.take", sender, amount));
|
||||
clan.addBb(sender.getName(), lang("bb.clan.take", sender, amount, sender.getName()));
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
sender.sendMessage(RED + lang("clan.admin.bank.not.enough.money", sender, clan.getName()));
|
||||
@@ -55,11 +62,12 @@ public class BankCommand extends BaseCommand {
|
||||
public void give(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
BankOperator operator = new BankOperator(sender, sender instanceof Player ? permissions.playerGetMoney((Player) sender) : 0);
|
||||
|
||||
EconomyResponse economyResponse = clan.deposit(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
EconomyResponse economyResponse = clan.deposit(operator, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
if (economyResponse == EconomyResponse.SUCCESS) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.give", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.give", sender, amount));
|
||||
clan.addBb(sender.getName(), lang("bb.clan.give", sender, amount, sender.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,11 +78,12 @@ public class BankCommand extends BaseCommand {
|
||||
public void set(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
BankOperator operator = new BankOperator(sender, sender instanceof Player ? permissions.playerGetMoney((Player) sender) : 0);
|
||||
|
||||
EconomyResponse response = clan.setBalance(sender, ClanBalanceUpdateEvent.Cause.COMMAND, BankLogger.Operation.SET, amount);
|
||||
EconomyResponse response = clan.setBalance(operator, ClanBalanceUpdateEvent.Cause.COMMAND, BankLogger.Operation.SET, amount);
|
||||
if (response == EconomyResponse.SUCCESS) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.set", sender, clan.getName(), amount));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.set", sender, amount));
|
||||
clan.addBb(sender.getName(), lang("bb.clan.set", sender, amount, sender.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.staff;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions")
|
||||
@Subcommand("%mod %bb")
|
||||
public class BbCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
|
||||
@Subcommand("%display")
|
||||
@CommandPermission("simpleclans.mod.bb")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.mod.bb.display}")
|
||||
public void display(Player sender, @Name("clan") ClanInput input) {
|
||||
input.getClan().displayBb(sender);
|
||||
}
|
||||
|
||||
@Subcommand("%clear")
|
||||
@CommandPermission("simpleclans.mod.bb-clear")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.mod.bb.clear}")
|
||||
public void clear(Player player, @Name("clan") ClanInput input) {
|
||||
input.getClan().clearBb();
|
||||
ChatBlock.sendMessage(player, RED + lang("cleared.bb", player));
|
||||
}
|
||||
|
||||
@Subcommand("%add")
|
||||
@CommandPermission("simpleclans.mod.bb-add")
|
||||
@CommandCompletion("@clans @nothing")
|
||||
@Description("{@@command.description.mod.bb.post}")
|
||||
public void postMessage(Player player, @Name("clan") ClanInput input, @Name("message") String msg) {
|
||||
Clan clan = input.getClan();
|
||||
clan.addBb(lang("bulletin.board.message", player.getName(), msg));
|
||||
clan.displayBb(player);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
}
|
||||
+87
-49
@@ -2,24 +2,28 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.staff;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import co.aikar.commands.bukkit.contexts.OnlinePlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerResetKdrEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -47,31 +51,32 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandCompletion("@players @clans")
|
||||
@HelpSearchTags("move put")
|
||||
@Description("{@@command.description.place}")
|
||||
public void place(CommandSender sender, @Name("player") OnlinePlayer onlinePlayer, @Name("clan") ClanInput clan) {
|
||||
Player player = onlinePlayer.getPlayer();
|
||||
ClanPlayer oldCp = cm.getClanPlayer(player);
|
||||
Clan newClanInput = clan.getClan();
|
||||
public void place(CommandSender sender, @Name("player") ClanPlayerInput cpInput, @Name("clan") ClanInput clanInput) {
|
||||
UUID uuid = cpInput.getClanPlayer().getUniqueId();
|
||||
ClanPlayer oldCp = cm.getClanPlayer(uuid);
|
||||
Clan newClan = clanInput.getClan();
|
||||
|
||||
if (oldCp != null) {
|
||||
Clan oldClan = Objects.requireNonNull(oldCp.getClan());
|
||||
|
||||
if (oldClan.equals(newClanInput)) {
|
||||
if (oldClan.equals(newClan)) {
|
||||
ChatBlock.sendMessage(sender, lang("player.already.in.this.clan", sender));
|
||||
return;
|
||||
}
|
||||
if (!oldClan.isPermanent() && oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
|
||||
if (!oldClan.isPermanent() && oldClan.isLeader(uuid) && oldClan.getLeaders().size() <= 1) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.move.the.last.leader", sender));
|
||||
return;
|
||||
} else {
|
||||
oldClan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
oldClan.addBb(oldCp.getName(), lang("0.has.resigned", oldCp.getName()));
|
||||
oldClan.removePlayerFromClan(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
ClanPlayer cp = Objects.requireNonNull(cm.getCreateClanPlayerUUID(player.getName()));
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(uuid);
|
||||
|
||||
newClanInput.addBb(AQUA + lang("joined.the.clan", player.getName()));
|
||||
cm.serverAnnounce(lang("has.joined", player.getName(), newClanInput.getName()));
|
||||
newClanInput.addPlayerToClan(cp);
|
||||
newClan.addBb(lang("joined.the.clan", cp.getName()));
|
||||
cm.serverAnnounce(lang("has.joined", cp.getName(), newClan.getName()));
|
||||
newClan.addPlayerToClan(cp);
|
||||
}
|
||||
|
||||
@Subcommand("%mod %modtag")
|
||||
@@ -87,9 +92,9 @@ public class StaffCommands extends BaseCommand {
|
||||
tag = event.getNewTag();
|
||||
String cleanTag = Helper.cleanTag(tag);
|
||||
|
||||
TagValidator validator = new TagValidator(plugin, player, tag);
|
||||
if (validator.getErrorMessage() != null) {
|
||||
ChatBlock.sendMessage(player, validator.getErrorMessage());
|
||||
Optional<String> validationError = plugin.getTagValidator().validate(player, tag);
|
||||
if (validationError.isPresent()) {
|
||||
ChatBlock.sendMessage(player, validationError.get());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,7 +104,7 @@ public class StaffCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.addBb(player.getName(), lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.changeClanTag(tag);
|
||||
player.sendMessage(lang("0.tag.changed.to.1", player, clan.getTag(), tag));
|
||||
}
|
||||
@@ -125,11 +130,18 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.home")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.mod.home.set}")
|
||||
public void homeSet(Player player, @Name("clan") ClanInput clan) {
|
||||
public void homeSet(Player player, ClanPlayer cp, @Name("clan") ClanInput clanInput) {
|
||||
Location loc = player.getLocation();
|
||||
Clan clan = clanInput.getClan();
|
||||
|
||||
clan.getClan().setHomeLocation(loc);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.mod.set", player, clan.getClan().getName()) + " " +
|
||||
PlayerHomeSetEvent event = new PlayerHomeSetEvent(clan, cp, loc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(loc);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.mod.set", player, clan.getName()) + " " +
|
||||
ChatColor.YELLOW + Helper.toLocationString(loc));
|
||||
}
|
||||
|
||||
@@ -137,14 +149,7 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandCompletion("@clans:has_home")
|
||||
@CommandPermission("simpleclans.mod.hometp")
|
||||
@Description("{@@command.description.mod.home.tp}")
|
||||
public void homeTp(Player player, @Name("clan") ClanInput clan) {
|
||||
Location loc = clan.getClan().getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
public void homeTp(Player player, @Name("clan") @Conditions("can_teleport") ClanInput clan) {
|
||||
plugin.getTeleportManager().teleportToHome(player, clan.getClan());
|
||||
}
|
||||
|
||||
@@ -152,8 +157,8 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.ban}")
|
||||
public void ban(CommandSender sender, @Name("player") OfflinePlayer player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
public void ban(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
UUID uuid = player.getClanPlayer().getUniqueId();
|
||||
if (settings.isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("this.player.is.already.banned", sender));
|
||||
return;
|
||||
@@ -172,8 +177,8 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.unban}")
|
||||
public void unban(CommandSender sender, @Name("player") OfflinePlayer player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
public void unban(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
UUID uuid = player.getClanPlayer().getUniqueId();
|
||||
if (!settings.isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("this.player.is.not.banned", sender));
|
||||
return;
|
||||
@@ -223,7 +228,7 @@ public class StaffCommands extends BaseCommand {
|
||||
|
||||
if (!clanInput.isVerified()) {
|
||||
clanInput.verifyClan();
|
||||
clanInput.addBb(sender.getName(), AQUA + lang("clan.0.has.been.verified", clanInput.getName()));
|
||||
clanInput.addBb(sender.getName(), lang("clan.0.has.been.verified", clanInput.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("the.clan.has.been.verified", sender));
|
||||
} else {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.clan.is.already.verified", sender));
|
||||
@@ -255,12 +260,12 @@ public class StaffCommands extends BaseCommand {
|
||||
public void kick(CommandSender sender, @Conditions("clan_member") @Name("player") ClanPlayerInput cp) {
|
||||
ClanPlayer clanPlayer = cp.getClanPlayer();
|
||||
Clan clan = Objects.requireNonNull(clanPlayer.getClan());
|
||||
if (clan.getLeaders().size() == 1) {
|
||||
if (clanPlayer.isLeader() && clan.getLeaders().size() == 1) {
|
||||
ChatBlock.sendMessageKey(sender, "cannot.kick.last.leader");
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(sender.getName(), AQUA + lang("has.been.kicked.by", clanPlayer.getName(),
|
||||
clan.addBb(sender.getName(), lang("has.been.kicked.by", clanPlayer.getName(),
|
||||
sender.getName(), sender));
|
||||
clan.removePlayerFromClan(clanPlayer.getUniqueId());
|
||||
}
|
||||
@@ -291,7 +296,7 @@ public class StaffCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(sender.getName(), AQUA + lang("promoted.to.leader", promotePl.getName()));
|
||||
clan.addBb(sender.getName(), lang("promoted.to.leader", promotePl.getName()));
|
||||
clan.promote(promotePl.getUniqueId());
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.promoted", sender));
|
||||
}
|
||||
@@ -314,7 +319,7 @@ public class StaffCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
clan.demote(otherCp.getUniqueId());
|
||||
clan.addBb(sender.getName(), AQUA + lang("demoted.back.to.member", otherCp.getName()));
|
||||
clan.addBb(sender.getName(), lang("demoted.back.to.member", otherCp.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.demoted", sender));
|
||||
}
|
||||
|
||||
@@ -323,7 +328,11 @@ public class StaffCommands extends BaseCommand {
|
||||
@Description("{@@command.description.resetkdr.everyone}")
|
||||
public void resetKdr(CommandSender sender) {
|
||||
for (ClanPlayer cp : cm.getAllClanPlayers()) {
|
||||
cm.resetKdr(cp);
|
||||
PlayerResetKdrEvent event = new PlayerResetKdrEvent(cp);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
cm.resetKdr(cp);
|
||||
}
|
||||
}
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.have.reseted.kdr.of.all.players", sender));
|
||||
}
|
||||
@@ -332,20 +341,49 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandCompletion("@players")
|
||||
@CommandPermission("simpleclans.admin.resetkdr")
|
||||
@Description("{@@command.description.resetkdr.player}")
|
||||
public void resetKdr(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
ClanPlayer cp = player.getClanPlayer();
|
||||
cm.resetKdr(cp);
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.have.reseted.0.kdr", sender, cp.getName()));
|
||||
public void resetKdr(CommandSender sender, @Name("player") ClanPlayerInput clanPlayer) {
|
||||
ClanPlayer cp = clanPlayer.getClanPlayer();
|
||||
PlayerResetKdrEvent event = new PlayerResetKdrEvent(cp);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
cm.resetKdr(cp);
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.have.reseted.0.kdr", sender, cp.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%admin %permanent")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandPermission("simpleclans.admin.permanent")
|
||||
@Description("{@@command.description.admin.permanent}")
|
||||
public void togglePermanent(CommandSender sender, @Name("clan") ClanInput clan) {
|
||||
boolean permanent = !clan.getClan().isPermanent();
|
||||
clan.getClan().setPermanent(permanent);
|
||||
clan.getClan().addBb(sender.getName(), lang((permanent) ? "permanent.status.enabled" : "permanent.status.disabled", sender.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("you.have.toggled.permanent.status", sender, clan.getClan().getName()));
|
||||
public void togglePermanent(CommandSender sender, @Name("clan") ClanInput clanInput) {
|
||||
Clan clan = clanInput.getClan();
|
||||
boolean permanent = !clan.isPermanent();
|
||||
clan.setPermanent(permanent);
|
||||
clan.addBb(sender.getName(), lang((permanent) ? "permanent.status.enabled" : "permanent.status.disabled", sender.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("you.have.toggled.permanent.status", sender, clan.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("%mod %rename")
|
||||
@CommandCompletion("@clans @nothing")
|
||||
@CommandPermission("simpleclans.mod.rename")
|
||||
@Description("{@@command.description.mod.rename}")
|
||||
public void rename(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("name") String clanName) {
|
||||
Clan clan = clanInput.getClan();
|
||||
clan.setName(clanName);
|
||||
storage.updateClan(clan);
|
||||
|
||||
ChatBlock.sendMessageKey(sender, "you.have.successfully.renamed.the.clan", clanName);
|
||||
}
|
||||
|
||||
@Subcommand("%mod %locale")
|
||||
@CommandPermission("simpleclans.mod.locale")
|
||||
@Description("{@@command.description.mod.locale}")
|
||||
@CommandCompletion("@locales")
|
||||
public void locale(CommandSender sender, @Name("player") ClanPlayerInput input, @Values("@locales") @Name("locale") String locale) {
|
||||
ClanPlayer cp = input.getClanPlayer();
|
||||
cp.setLocale(Helper.forLanguageTag(locale.replace("_", "-")));
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
|
||||
ChatBlock.sendMessage(sender, lang("locale.has.been.changed"));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
abstract public class ConfirmationPrompt extends StringPrompt {
|
||||
|
||||
protected abstract Prompt confirm(ClanPlayer sender, Clan clan);
|
||||
|
||||
protected Prompt decline(ClanPlayer sender) {
|
||||
return new MessagePromptImpl(RED + lang(getDeclineTextKey(), sender));
|
||||
}
|
||||
|
||||
protected abstract String getPromptTextKey();
|
||||
|
||||
protected abstract String getDeclineTextKey();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPromptText(@NotNull ConversationContext context) {
|
||||
Player player = (Player) context.getForWhom();
|
||||
List<String> options = Arrays.asList(lang("yes", player), lang("cancel", player));
|
||||
|
||||
return RED + lang(getPromptTextKey(), player, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(@NotNull ConversationContext cc, @Nullable String input) {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
|
||||
Player player = (Player) cc.getForWhom();
|
||||
String yes = lang("yes", player);
|
||||
ClanManager cm = Objects.requireNonNull(plugin).getClanManager();
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan == null) {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
return yes.equalsIgnoreCase(input) ? confirm(cp, clan) : decline(cp);
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -66,8 +66,7 @@ public class CreateClanNamePrompt extends StringPrompt {
|
||||
plugin.getClanManager().createClan(player, tag, name);
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(tag);
|
||||
clan.addBb(player.getName(), AQUA +
|
||||
lang("clan.created", name));
|
||||
clan.addBb(player.getName(), lang("clan.created", name));
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
|
||||
if (plugin.getSettingsManager().is(REQUIRE_VERIFICATION)) {
|
||||
|
||||
+4
-8
@@ -2,7 +2,6 @@ package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
@@ -11,6 +10,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class CreateClanTagPrompt extends StringPrompt {
|
||||
@@ -52,12 +53,7 @@ public class CreateClanTagPrompt extends StringPrompt {
|
||||
lang("clan.with.this.tag.already.exists", player), this);
|
||||
}
|
||||
|
||||
TagValidator validator = new TagValidator(plugin, player, clanTag);
|
||||
String errorMessage = validator.getErrorMessage();
|
||||
if (errorMessage == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new MessagePromptImpl(errorMessage, this);
|
||||
}
|
||||
Optional<String> validationError = plugin.getTagValidator().validate(player, clanTag);
|
||||
return validationError.map(error -> new MessagePromptImpl(error, this)).orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class DisbandPrompt extends ConfirmationPrompt {
|
||||
|
||||
@Override
|
||||
protected Prompt confirm(ClanPlayer sender, Clan clan) {
|
||||
if (clan.isPermanent()) {
|
||||
return new MessagePromptImpl(RED + lang("cannot.disband.permanent", sender));
|
||||
}
|
||||
|
||||
clan.disband(sender.toPlayer(), true, false);
|
||||
return new MessagePromptImpl(RED + lang("clan.has.been.disbanded", sender, clan.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPromptTextKey() {
|
||||
return "disband.confirmation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeclineTextKey() {
|
||||
return "disband.request.cancelled";
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -1,13 +1,14 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.MessagePrompt;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class MessagePromptImpl extends org.bukkit.conversations.MessagePrompt {
|
||||
public class MessagePromptImpl extends MessagePrompt {
|
||||
private final String message;
|
||||
private Prompt nextPrompt;
|
||||
public MessagePromptImpl(String message) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerResetKdrEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class ResetKdrPrompt extends ConfirmationPrompt {
|
||||
|
||||
private final ClanManager cm;
|
||||
|
||||
public ResetKdrPrompt(ClanManager cm) {
|
||||
this.cm = cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt confirm(ClanPlayer sender, Clan clan) {
|
||||
PlayerResetKdrEvent event = new PlayerResetKdrEvent(sender);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && cm.purchaseResetKdr(sender.toPlayer())) {
|
||||
cm.resetKdr(sender);
|
||||
return new MessagePromptImpl(RED + lang("you.have.reseted.your.kdr", sender));
|
||||
} else {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPromptTextKey() {
|
||||
return "resetkdr.confirmation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeclineTextKey() {
|
||||
return "resetkdr.request.cancelled";
|
||||
}
|
||||
|
||||
}
|
||||
+17
-41
@@ -2,17 +2,7 @@ package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
@@ -21,45 +11,31 @@ import static org.bukkit.ChatColor.RED;
|
||||
/**
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class ResignPrompt extends StringPrompt {
|
||||
public class ResignPrompt extends ConfirmationPrompt {
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
protected Prompt confirm(ClanPlayer sender, Clan clan) {
|
||||
if (clan.isPermanent() || !sender.isLeader() || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(sender.getName(), lang("0.has.resigned", sender.getName()));
|
||||
sender.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(sender.getUniqueId());
|
||||
|
||||
Player player = (Player) cc.getForWhom();
|
||||
String yes = lang("yes", player);
|
||||
ClanManager cm = Objects.requireNonNull(plugin).getClanManager();
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan == null) {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
if (yes.equalsIgnoreCase(input)) {
|
||||
if (clan.isPermanent() || !clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
return new MessagePromptImpl(AQUA + lang("resign.success", player));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband(player, true, false);
|
||||
return new MessagePromptImpl(RED + lang("clan.has.been.disbanded", player, clan.getName()));
|
||||
} else {
|
||||
return new MessagePromptImpl(RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
}
|
||||
return new MessagePromptImpl(AQUA + lang("resign.success", sender));
|
||||
} else if (sender.isLeader() && clan.getLeaders().size() == 1) {
|
||||
clan.disband(sender.toPlayer(), true, false);
|
||||
return new MessagePromptImpl(RED + lang("clan.has.been.disbanded", sender, clan.getName()));
|
||||
} else {
|
||||
return new MessagePromptImpl(RED + lang("resign.request.cancelled", player));
|
||||
return new MessagePromptImpl(RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", sender));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext cc) {
|
||||
Player player = (Player) cc.getForWhom();
|
||||
return RED + MessageFormat.format(
|
||||
lang("resign.confirmation", player), Arrays.asList(
|
||||
lang("yes", player), lang("cancel", player)));
|
||||
protected String getPromptTextKey() {
|
||||
return "resign.confirmation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeclineTextKey() {
|
||||
return "resign.request.cancelled";
|
||||
}
|
||||
}
|
||||
+9
-6
@@ -1,25 +1,24 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final CommandSender updater;
|
||||
private final BankOperator updater;
|
||||
private final Clan clan;
|
||||
private final Cause cause;
|
||||
private final double balance;
|
||||
private double newBalance;
|
||||
private boolean cancelled;
|
||||
|
||||
public ClanBalanceUpdateEvent(@Nullable CommandSender updater,
|
||||
public ClanBalanceUpdateEvent(@NotNull BankOperator updater,
|
||||
@NotNull Clan clan,
|
||||
double balance,
|
||||
double newBalance,
|
||||
@@ -32,9 +31,9 @@ public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the balance updater, may be null
|
||||
* @return the balance updater
|
||||
*/
|
||||
public @Nullable CommandSender getUpdater() {
|
||||
public @NotNull BankOperator getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
@@ -115,6 +114,10 @@ public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
* When the balance is updated via API methods
|
||||
*/
|
||||
API,
|
||||
/**
|
||||
* WHen the balance is updated via Internal methods
|
||||
*/
|
||||
INTERNAL,
|
||||
/**
|
||||
* When the clan data is being loaded and the balance is set, usually on server start up or plugin reload
|
||||
*/
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClanPlayerTeleportEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ClanPlayer player;
|
||||
private final Location origin;
|
||||
private final Location destination;
|
||||
|
||||
public ClanPlayerTeleportEvent(ClanPlayer player, Location origin, Location destination) {
|
||||
this.player = player;
|
||||
this.origin = origin;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
public ClanPlayer getClanPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Location getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public Location getDestination() {
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -11,9 +13,14 @@ import org.bukkit.event.HandlerList;
|
||||
public class DisbandClanEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final CommandSender sender;
|
||||
private final Clan clan;
|
||||
|
||||
public DisbandClanEvent(Clan clan) {
|
||||
public DisbandClanEvent(CommandSender sender, Clan clan) {
|
||||
if (sender == null) {
|
||||
sender = Bukkit.getConsoleSender();
|
||||
}
|
||||
this.sender = sender;
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
@@ -21,6 +28,10 @@ public class DisbandClanEvent extends Event {
|
||||
return this.clan;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is fired when money is granted or charged from a player's account.
|
||||
* <p>Note: Cancelling this event will deny the transaction.</p>
|
||||
*
|
||||
* @see PermissionsManager#grantPlayer(OfflinePlayer, double, Cause)
|
||||
* @see PermissionsManager#chargePlayer(OfflinePlayer, double, Cause)
|
||||
*/
|
||||
public class EconomyTransactionEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final OfflinePlayer player;
|
||||
private double amount;
|
||||
private final Cause cause;
|
||||
private final TransactionType transactionType;
|
||||
private boolean cancelled;
|
||||
|
||||
public EconomyTransactionEvent(@NotNull OfflinePlayer affected, double amount,
|
||||
@NotNull Cause cause, @NotNull TransactionType transactionType) {
|
||||
this.player = affected;
|
||||
this.amount = amount;
|
||||
this.cause = cause;
|
||||
this.transactionType = transactionType;
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Cause getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public TransactionType getTransactionType() {
|
||||
return transactionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* If cancelled, the transaction will result as denied.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public enum Cause {
|
||||
CLAN_CREATION,
|
||||
CLAN_VERIFICATION,
|
||||
CLAN_INVITATION,
|
||||
CLAN_REGROUP,
|
||||
CLAN_HOME_TELEPORT,
|
||||
CLAN_HOME_TELEPORT_SET,
|
||||
DISCORD_CREATION,
|
||||
PLAYER_KILLED,
|
||||
MEMBER_FEE_SET,
|
||||
RESET_KDR
|
||||
}
|
||||
|
||||
public enum TransactionType {
|
||||
DEPOSIT, WITHDRAW
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,8 +5,6 @@
|
||||
*/
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.Location;
|
||||
@@ -14,6 +12,9 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author edson
|
||||
@@ -50,12 +51,16 @@ public class HomeRegroupEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerHomeClearEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Clan clan;
|
||||
private final ClanPlayer cp;
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerHomeClearEvent(Clan clan, ClanPlayer cp) {
|
||||
this.clan = clan;
|
||||
this.cp = cp;
|
||||
}
|
||||
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
public ClanPlayer getCp() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author ThiagoROX
|
||||
*/
|
||||
public class PlayerResetKdrEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ClanPlayer clanPlayer;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* Event called before a player's kill death rate is reset
|
||||
*
|
||||
* @param clanPlayer The ClanPlayer whose kill death rate going to be reset
|
||||
*/
|
||||
public PlayerResetKdrEvent(@NotNull ClanPlayer clanPlayer) {
|
||||
this.clanPlayer = clanPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player whose kill death rate going to be reset
|
||||
*
|
||||
* @return The player whose kill death rate going to be reset
|
||||
*/
|
||||
@NotNull
|
||||
public ClanPlayer getClanPlayer() {
|
||||
return clanPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,482 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.AccountLinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.AccountUnlinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent;
|
||||
import github.scarsz.discordsrv.dependencies.commons.lang3.StringUtils;
|
||||
import github.scarsz.discordsrv.dependencies.emoji.EmojiParser;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.Permission;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.*;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.requests.RestAction;
|
||||
import github.scarsz.discordsrv.dependencies.kyori.adventure.text.Component;
|
||||
import github.scarsz.discordsrv.objects.managers.AccountLinkManager;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import github.scarsz.discordsrv.util.MessageUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static github.scarsz.discordsrv.dependencies.jda.api.Permission.VIEW_CHANNEL;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.DiscordHook.DiscordAction.ADD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.DiscordHook.DiscordAction.REMOVE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
/**
|
||||
* Hooks SimpleClans and Discord, using DiscordSRV.
|
||||
* <p>
|
||||
* On server' startup:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Creates categories and channels, respecting discord's limits.</li>
|
||||
* <li>Removes invalid channels, resets permissions and roles.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Manages events:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Clan creation/deletion</li>
|
||||
* <li>ClanPlayer joining/resigning</li>
|
||||
* <li>Player linking</li>
|
||||
* <li>ClanPlayer promoting/demoting</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Currently, works with clan chat only.
|
||||
*/
|
||||
public class DiscordHook implements Listener {
|
||||
|
||||
private static final int MAX_CHANNELS_PER_CATEGORY = 50;
|
||||
private static final int MAX_CHANNELS_PER_GUILD = 500;
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final SettingsManager settingsManager;
|
||||
private final ChatManager chatManager;
|
||||
private final ClanManager clanManager;
|
||||
private final AccountLinkManager accountManager = DiscordSRV.getPlugin().getAccountLinkManager();
|
||||
|
||||
private final Guild guild = DiscordSRV.getPlugin().getMainGuild();
|
||||
private final List<String> textCategories;
|
||||
private final List<String> discordClanTags;
|
||||
private final List<String> clanTags;
|
||||
private final Role leaderRole;
|
||||
|
||||
public DiscordHook(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
settingsManager = plugin.getSettingsManager();
|
||||
chatManager = plugin.getChatManager();
|
||||
clanManager = plugin.getClanManager();
|
||||
textCategories = settingsManager.getStringList(DISCORDCHAT_TEXT_CATEGORY_IDS).stream().
|
||||
filter(this::categoryExists).collect(Collectors.toList());
|
||||
|
||||
List<String> whitelist = settingsManager.getStringList(DISCORDCHAT_TEXT_WHITELIST);
|
||||
|
||||
clanTags = clanManager.getClans().stream().
|
||||
filter(Clan::isVerified).
|
||||
filter(clan -> clan.getMembers().stream().
|
||||
anyMatch(clanPlayer -> getMember(clanPlayer) != null) || clan.isPermanent()).
|
||||
map(Clan::getTag).
|
||||
filter(clanTag -> whitelist.isEmpty() || whitelist.contains(clanTag)).
|
||||
limit(settingsManager.getInt(DISCORDCHAT_TEXT_LIMIT)).
|
||||
collect(Collectors.toList());
|
||||
|
||||
discordClanTags = getChannels().stream().
|
||||
map(GuildChannel::getName).
|
||||
collect(Collectors.toList());
|
||||
|
||||
leaderRole = getLeaderRole();
|
||||
setupDiscord();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMessageReceived(DiscordGuildMessageReceivedEvent event) {
|
||||
Optional<TextChannel> channel = getChannel(event.getChannel().getName());
|
||||
|
||||
if (channel.isPresent()) {
|
||||
Message eventMessage = event.getMessage();
|
||||
User Author = event.getAuthor();
|
||||
TextChannel textChannel = channel.get();
|
||||
UUID uuid = accountManager.getUuid(Author.getId());
|
||||
|
||||
if (uuid == null) {
|
||||
sendPrivateMessage(textChannel, eventMessage, lang("you.did.not.link.your.account"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(uuid);
|
||||
if (clanPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Objects.equals(textChannel.getName(), clan.getTag())) {
|
||||
String channelLink = "<#" + textChannel.getId() + ">";
|
||||
sendPrivateMessage(textChannel, eventMessage, lang("cannot.send.discord.message", clanPlayer, channelLink));
|
||||
return;
|
||||
}
|
||||
|
||||
String emojiBehavior = DiscordSRV.config().getString("DiscordChatChannelEmojiBehavior");
|
||||
|
||||
boolean hideEmoji = emojiBehavior.equalsIgnoreCase("hide");
|
||||
boolean nameEmoji = emojiBehavior.equalsIgnoreCase("name");
|
||||
|
||||
Component component = MessageUtil.reserializeToMinecraft(eventMessage.getContentRaw());
|
||||
String message = MessageUtil.toLegacy(component);
|
||||
|
||||
if (hideEmoji && StringUtils.isBlank(EmojiParser.removeAllEmojis(message))) {
|
||||
DiscordSRV.debug("Ignoring message from "
|
||||
+ Author.getName() +
|
||||
" because it became completely blank after removing unicode emojis");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hideEmoji) {
|
||||
// remove all emojis
|
||||
message = EmojiParser.removeAllEmojis(message);
|
||||
} else if (nameEmoji) {
|
||||
// parse emojis from unicode back to :code:
|
||||
message = EmojiParser.parseToAliases(message);
|
||||
}
|
||||
|
||||
chatManager.processChat(DISCORD, CLAN, clanPlayer, message);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanDisband(DisbandClanEvent event) {
|
||||
deleteChannel(event.getClan().getTag());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanCreate(CreateClanEvent event) {
|
||||
createChannel(event.getClan().getTag());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanLeave(PlayerKickedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
|
||||
updatePermissions(clanPlayer, REMOVE);
|
||||
updateRole(clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanJoin(PlayerJoinedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
|
||||
updatePermissions(clanPlayer, ADD);
|
||||
updateRole(clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPromote(PlayerPromoteEvent event) {
|
||||
updateRole(event.getClanPlayer(), ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDemote(PlayerDemoteEvent event) {
|
||||
updateRole(event.getClanPlayer(), REMOVE);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerLinking(AccountLinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
if (clanPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updatePermissions(clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerUnlinking(AccountUnlinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
if (clanPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updatePermissions(clanPlayer, REMOVE);
|
||||
guild.removeRoleFromMember(event.getDiscordId(), leaderRole).queue();
|
||||
}
|
||||
|
||||
protected void setupDiscord() {
|
||||
removeInvalidChannels();
|
||||
resetPermissions();
|
||||
createChannels();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Guild getGuild() {
|
||||
return guild;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A leader role from guild, otherwise creates one.
|
||||
*/
|
||||
@NotNull
|
||||
public Role getLeaderRole() {
|
||||
Role role = guild.getRoleById(settingsManager.getString(DISCORDCHAT_LEADER_ID));
|
||||
|
||||
if (role == null || !role.getName().equals(settingsManager.getString(DISCORDCHAT_LEADER_ROLE))) {
|
||||
role = guild.createRole().
|
||||
setName(settingsManager.getString(DISCORDCHAT_LEADER_ROLE)).
|
||||
setColor(getLeaderColor()).
|
||||
setMentionable(true).
|
||||
complete();
|
||||
|
||||
settingsManager.set(DISCORDCHAT_LEADER_ID, role.getId());
|
||||
settingsManager.save();
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A leader color from configuration
|
||||
*/
|
||||
public Color getLeaderColor() {
|
||||
String[] colors = settingsManager.getString(DISCORDCHAT_LEADER_COLOR).
|
||||
replaceAll("\\s", "").split(",");
|
||||
try {
|
||||
int red = Integer.parseInt(colors[0]);
|
||||
int green = Integer.parseInt(colors[1]);
|
||||
int blue = Integer.parseInt(colors[2]);
|
||||
int alpha = Integer.parseInt(colors[3]);
|
||||
|
||||
return new Color(red, green, blue, alpha);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning("Color is invalid, using default color: " + ex.getMessage());
|
||||
return Color.RED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SimpleClans {@link Category}
|
||||
*
|
||||
* @return Category or null, if reached the limit
|
||||
*/
|
||||
@Nullable
|
||||
public Category createCategory() {
|
||||
if (guild.getChannels().size() >= MAX_CHANNELS_PER_GUILD) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String categoryName = settingsManager.getString(DISCORDCHAT_TEXT_CATEGORY_FORMAT);
|
||||
Category category = null;
|
||||
try {
|
||||
category = guild.createCategory(categoryName).
|
||||
addRolePermissionOverride(
|
||||
guild.getPublicRole().getIdLong(),
|
||||
Collections.emptyList(),
|
||||
Collections.singletonList(VIEW_CHANNEL)).
|
||||
submit().get();
|
||||
|
||||
textCategories.add(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while trying to create {0} category: " +
|
||||
ex.getMessage(), categoryName);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ClanPlayer.Channel} in available categories,
|
||||
* otherwise creates one
|
||||
*/
|
||||
public boolean createChannel(@NotNull String clanTag) {
|
||||
Category availableCategory = getCategories().stream().
|
||||
filter(category -> category.getTextChannels().size() < MAX_CHANNELS_PER_CATEGORY).
|
||||
findAny().orElseGet(this::createCategory);
|
||||
|
||||
return availableCategory != null && createChannel(availableCategory, clanTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves channel in SimpleClans categories.
|
||||
*
|
||||
* @see #getCategories() retreive categories.
|
||||
*/
|
||||
public Optional<TextChannel> getChannel(@NotNull String channelName) {
|
||||
return getChannels().stream().filter(textChannel -> textChannel.getName().equals(channelName)).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if category can be obtained by id.
|
||||
*/
|
||||
public boolean categoryExists(String categoryId) {
|
||||
return guild.getCategoryById(categoryId) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link ClanPlayer.Channel} in defined {@link Category}
|
||||
*
|
||||
* <p>Sets {@link Permission#VIEW_CHANNEL} permission to all linked clan members.</p>
|
||||
*
|
||||
* @return true, if channel was created. False, if category reached the limit.
|
||||
*/
|
||||
public boolean createChannel(@NotNull Category category, @NotNull String clanTag) {
|
||||
if (category.getTextChannels().size() >= MAX_CHANNELS_PER_CATEGORY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TextChannel textChannel = category.createTextChannel(clanTag).complete();
|
||||
Clan clan = clanManager.getClan(clanTag);
|
||||
|
||||
if (clan != null) {
|
||||
for (ClanPlayer member : clan.getMembers()) {
|
||||
updatePermissions(member, ADD);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes channel from SimpleClans categories.
|
||||
* If there are no channels, removes category as well.
|
||||
*/
|
||||
public void deleteChannel(@NotNull String channelName) {
|
||||
for (Category category : getCategories()) {
|
||||
if (category.getTextChannels().size() > 0) {
|
||||
for (TextChannel textChannel : category.getTextChannels()) {
|
||||
if (textChannel.getName().equals(channelName)) {
|
||||
textChannel.delete().complete();
|
||||
}
|
||||
}
|
||||
|
||||
if (category.getTextChannels().size() == 0) {
|
||||
textCategories.remove(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
category.delete().complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All categories, which contains in configuration.
|
||||
*/
|
||||
public List<Category> getCategories() {
|
||||
return textCategories.stream().
|
||||
filter(this::categoryExists).
|
||||
map(guild::getCategoryById).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All channels in categories
|
||||
*/
|
||||
public List<TextChannel> getChannels() {
|
||||
return getCategories().stream().map(Category::getTextChannels).flatMap(Collection::stream).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Member getMember(@NotNull ClanPlayer clanPlayer) {
|
||||
String discordId = accountManager.getDiscordId(clanPlayer.getUniqueId());
|
||||
return DiscordUtil.getMemberById(discordId);
|
||||
}
|
||||
|
||||
private void removeInvalidChannels() {
|
||||
ArrayList<String> clansToDelete = new ArrayList<>(discordClanTags);
|
||||
clansToDelete.removeAll(clanTags);
|
||||
clansToDelete.forEach(this::deleteChannel);
|
||||
}
|
||||
|
||||
private void resetPermissions() {
|
||||
getChannels().stream().
|
||||
map(TextChannel::getMemberPermissionOverrides).
|
||||
flatMap(Collection::stream).
|
||||
filter(permissionOverride -> !Objects.equals(permissionOverride.getPermissionHolder(), guild.getPublicRole())).
|
||||
forEach(permissionOverride -> permissionOverride.delete().queue());
|
||||
|
||||
clanTags.stream().map(clanManager::getClan).
|
||||
filter(Objects::nonNull).
|
||||
map(Clan::getMembers).
|
||||
flatMap(Collection::stream).
|
||||
forEach(clanPlayer -> updatePermissions(clanPlayer, ADD));
|
||||
}
|
||||
|
||||
private void createChannels() {
|
||||
clanTags.removeAll(discordClanTags);
|
||||
Iterator<String> tagIter = clanTags.iterator();
|
||||
while (tagIter.hasNext()) {
|
||||
if (createChannel(tagIter.next())) {
|
||||
tagIter.remove();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void sendPrivateMessage(TextChannel textChannel, Message eventMessage, String message) {
|
||||
RestAction<PrivateChannel> privateChannelAction = eventMessage.getAuthor().openPrivateChannel();
|
||||
textChannel.deleteMessageById(eventMessage.getId()).queue(unused -> {
|
||||
String channelLink = "<#" + textChannel.getId() + ">";
|
||||
privateChannelAction.flatMap(privateChannel -> privateChannel.sendMessage(message));
|
||||
});
|
||||
}
|
||||
|
||||
private void updateRole(ClanPlayer clanPlayer, DiscordAction action) {
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == ADD) {
|
||||
guild.addRoleToMember(member, leaderRole).queue();
|
||||
} else {
|
||||
guild.removeRoleFromMember(member, leaderRole).queue();
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePermissions(@NotNull ClanPlayer clanPlayer, DiscordAction action) {
|
||||
Clan clan = clanPlayer.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (clan == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<TextChannel> channel = getChannel(clan.getTag());
|
||||
if (channel.isPresent()) {
|
||||
TextChannel textChannel = channel.get();
|
||||
|
||||
if (action == ADD) {
|
||||
textChannel.upsertPermissionOverride(member).
|
||||
setPermissions(Collections.singletonList(VIEW_CHANNEL), Collections.emptyList()).queue();
|
||||
} else {
|
||||
textChannel.getManager().removePermissionOverride(member).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum DiscordAction {
|
||||
ADD, REMOVE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,682 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.AccountLinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.AccountUnlinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent;
|
||||
import github.scarsz.discordsrv.dependencies.commons.lang3.StringUtils;
|
||||
import github.scarsz.discordsrv.dependencies.emoji.EmojiParser;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.Permission;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.*;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.exceptions.ErrorResponseException;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.requests.Response;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.requests.RestAction;
|
||||
import github.scarsz.discordsrv.dependencies.kyori.adventure.text.Component;
|
||||
import github.scarsz.discordsrv.objects.managers.AccountLinkManager;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import github.scarsz.discordsrv.util.MessageUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static github.scarsz.discordsrv.dependencies.jda.api.Permission.MANAGE_CHANNEL;
|
||||
import static github.scarsz.discordsrv.dependencies.jda.api.Permission.VIEW_CHANNEL;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook.DiscordAction.ADD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook.DiscordAction.REMOVE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
/**
|
||||
* Hooks SimpleClans and Discord, using DiscordSRV.
|
||||
* <p>
|
||||
* On server' startup:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Creates categories and channels, respecting discord's limits.</li>
|
||||
* <li>Removes invalid channels, resets permissions and roles.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Manages events:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Clan creation/deletion</li>
|
||||
* <li>ClanPlayer joining/resigning</li>
|
||||
* <li>Player linking/unlinking</li>
|
||||
* <li>ClanPlayer promoting/demoting</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Currently, works with clan chat only.
|
||||
*/
|
||||
public class DiscordHook implements Listener {
|
||||
|
||||
private static final int MAX_CHANNELS_PER_CATEGORY = 50;
|
||||
private static final int MAX_CHANNELS_PER_GUILD = 500;
|
||||
private final SimpleClans plugin;
|
||||
private final SettingsManager settingsManager;
|
||||
private final ChatManager chatManager;
|
||||
private final ClanManager clanManager;
|
||||
private final AccountLinkManager accountManager = DiscordSRV.getPlugin().getAccountLinkManager();
|
||||
private final Guild guild = DiscordSRV.getPlugin().getMainGuild();
|
||||
private final List<String> textCategories;
|
||||
private final List<String> clanTags;
|
||||
private final Role leaderRole;
|
||||
private final List<String> whitelist;
|
||||
|
||||
public DiscordHook(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
settingsManager = plugin.getSettingsManager();
|
||||
chatManager = plugin.getChatManager();
|
||||
clanManager = plugin.getClanManager();
|
||||
|
||||
textCategories = settingsManager.getStringList(DISCORDCHAT_TEXT_CATEGORY_IDS).stream().
|
||||
filter(this::categoryExists).collect(Collectors.toList());
|
||||
whitelist = settingsManager.getStringList(DISCORDCHAT_TEXT_WHITELIST);
|
||||
|
||||
clanTags = clanManager.getClans().stream().map(Clan::getTag).collect(Collectors.toList());
|
||||
|
||||
leaderRole = getLeaderRole();
|
||||
|
||||
setupDiscord();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMessageReceived(DiscordGuildMessageReceivedEvent event) {
|
||||
Optional<TextChannel> channel = getCachedChannel(event.getChannel().getName());
|
||||
|
||||
if (channel.isPresent()) {
|
||||
Message eventMessage = event.getMessage();
|
||||
User Author = event.getAuthor();
|
||||
TextChannel textChannel = channel.get();
|
||||
UUID uuid = accountManager.getUuid(Author.getId());
|
||||
|
||||
if (uuid == null) {
|
||||
sendPrivateMessage(textChannel, eventMessage, lang("you.did.not.link.your.account"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(uuid);
|
||||
if (clanPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Objects.equals(textChannel.getName(), clan.getTag())) {
|
||||
String channelLink = "<#" + textChannel.getId() + ">";
|
||||
sendPrivateMessage(textChannel, eventMessage, lang("cannot.send.discord.message", clanPlayer, channelLink));
|
||||
return;
|
||||
}
|
||||
// DiscordSRV start
|
||||
String emojiBehavior = DiscordSRV.config().getString("DiscordChatChannelEmojiBehavior");
|
||||
|
||||
boolean hideEmoji = emojiBehavior.equalsIgnoreCase("hide");
|
||||
boolean nameEmoji = emojiBehavior.equalsIgnoreCase("name");
|
||||
|
||||
Component component = MessageUtil.reserializeToMinecraft(eventMessage.getContentRaw());
|
||||
String message = MessageUtil.toLegacy(component);
|
||||
|
||||
if (hideEmoji && StringUtils.isBlank(EmojiParser.removeAllEmojis(message))) {
|
||||
DiscordSRV.debug("Ignoring message from "
|
||||
+ Author.getName() +
|
||||
" because it became completely blank after removing unicode emojis");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hideEmoji) {
|
||||
// remove all emojis
|
||||
message = EmojiParser.removeAllEmojis(message);
|
||||
} else if (nameEmoji) {
|
||||
// parse emojis from unicode back to :code:
|
||||
message = EmojiParser.parseToAliases(message);
|
||||
}
|
||||
// DiscordSRV end
|
||||
chatManager.processChat(DISCORD, CLAN, clanPlayer, message);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanDisband(DisbandClanEvent event) {
|
||||
deleteChannel(event.getClan().getTag());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanCreate(CreateClanEvent event) {
|
||||
try {
|
||||
if (settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
createChannel(event.getClan().getTag());
|
||||
}
|
||||
} catch (DiscordHookException ex) {
|
||||
// Clan is not following the conditions, categories are fulled or discord reaches the limit, nothing to do here.
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanLeave(PlayerKickedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Clan clan = event.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null || clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, REMOVE);
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanJoin(PlayerJoinedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Clan clan = event.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null || clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createChannelSilently(clanPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPromote(PlayerPromoteEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLeaderRole(member, clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDemote(PlayerDemoteEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerLinking(AccountLinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
Member member = guild.getMember(event.getUser());
|
||||
if (clanPlayer == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createChannelSilently(clanPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, ADD);
|
||||
updateLeaderRole(member, clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerUnlinking(AccountUnlinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
Member member = guild.getMember(event.getDiscordUser());
|
||||
if (clanPlayer == null || clanPlayer.getClan() == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clanPlayer.getClan(), REMOVE);
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
protected void setupDiscord() {
|
||||
Map<String, TextChannel> discordTagChannels = getCachedChannels().stream().
|
||||
collect(Collectors.toMap(TextChannel::getName, textChannel -> textChannel));
|
||||
|
||||
clearChannels(discordTagChannels);
|
||||
resetPermissions(discordTagChannels);
|
||||
createChannels(discordTagChannels);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Guild getGuild() {
|
||||
return guild;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A leader role from guild, otherwise creates one.
|
||||
*/
|
||||
@NotNull
|
||||
public Role getLeaderRole() {
|
||||
Role role = guild.getRoleById(settingsManager.getString(DISCORDCHAT_LEADER_ID));
|
||||
|
||||
if (role == null || !role.getName().equals(settingsManager.getString(DISCORDCHAT_LEADER_ROLE))) {
|
||||
role = guild.createRole().
|
||||
setName(settingsManager.getString(DISCORDCHAT_LEADER_ROLE)).
|
||||
setColor(getLeaderColor()).
|
||||
setMentionable(true).
|
||||
complete();
|
||||
|
||||
settingsManager.set(DISCORDCHAT_LEADER_ID, role.getId());
|
||||
settingsManager.save();
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A leader color from configuration
|
||||
*/
|
||||
public Color getLeaderColor() {
|
||||
String[] colors = settingsManager.getString(DISCORDCHAT_LEADER_COLOR).
|
||||
replaceAll("\\s", "").split(",");
|
||||
try {
|
||||
int red = Integer.parseInt(colors[0]);
|
||||
int green = Integer.parseInt(colors[1]);
|
||||
int blue = Integer.parseInt(colors[2]);
|
||||
int alpha = Integer.parseInt(colors[3]);
|
||||
|
||||
return new Color(red, green, blue, alpha);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning("Color is invalid, using default color: " + ex.getMessage());
|
||||
return Color.RED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SimpleClans {@link Category}
|
||||
*
|
||||
* @return Category or null, if reached the limit
|
||||
*/
|
||||
@Nullable
|
||||
public Category createCategory() {
|
||||
if (guild.getChannels().size() >= MAX_CHANNELS_PER_GUILD) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String categoryName = settingsManager.getString(DISCORDCHAT_TEXT_CATEGORY_FORMAT);
|
||||
Category category = null;
|
||||
try {
|
||||
category = guild.createCategory(categoryName).
|
||||
addRolePermissionOverride(
|
||||
guild.getPublicRole().getIdLong(),
|
||||
Collections.emptyList(),
|
||||
Collections.singletonList(VIEW_CHANNEL)).
|
||||
addMemberPermissionOverride(guild.getSelfMember().getIdLong(),
|
||||
Arrays.asList(VIEW_CHANNEL, MANAGE_CHANNEL),
|
||||
Collections.emptyList()).
|
||||
submit().get();
|
||||
|
||||
textCategories.add(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while trying to create {0} category: " +
|
||||
ex.getMessage(), categoryName);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link TextChannel} in available SimpleClans' categories,
|
||||
* otherwise creates one.
|
||||
*
|
||||
* <p>Sets positive {@link Permission#VIEW_CHANNEL} permission to all linked clan members.</p>
|
||||
*
|
||||
* @param clanTag the clan tag
|
||||
* @throws InvalidChannelException clan is not verified or permanent,
|
||||
* no one member is linked or clan is not in the whitelist.
|
||||
* @throws ChannelExistsException if channel is already exist
|
||||
* @throws CategoriesLimitException if categories reached the limit.
|
||||
* @throws ChannelsLimitException if discord reached the channels limit.
|
||||
*/
|
||||
public void createChannel(@NotNull String clanTag)
|
||||
throws InvalidChannelException, CategoriesLimitException, ChannelsLimitException, ChannelExistsException {
|
||||
validateChannel(clanTag);
|
||||
Map<ClanPlayer, Member> discordClanPlayers = getDiscordPlayers(clanManager.getClan(clanTag));
|
||||
|
||||
if (getChannels().size() >= settingsManager.getInt(DISCORDCHAT_TEXT_LIMIT)) {
|
||||
throw new ChannelsLimitException("Discord reached the channels limit", "discord.reached.channels.limit");
|
||||
}
|
||||
|
||||
Category availableCategory = getCachedCategories().stream().
|
||||
filter(category -> category.getTextChannels().size() < MAX_CHANNELS_PER_CATEGORY).
|
||||
findAny().orElseGet(this::createCategory);
|
||||
|
||||
if (availableCategory == null) {
|
||||
throw new CategoriesLimitException("Discord reached the categories limit", "discord.reached.category.limit");
|
||||
}
|
||||
|
||||
try {
|
||||
availableCategory.createTextChannel(clanTag).complete();
|
||||
} catch (ErrorResponseException ex) {
|
||||
Response response = ex.getResponse();
|
||||
plugin.getLogger().warning(String.format("Could not create a channel for clan %s, error %d - %s",
|
||||
clanTag, response.code, response.message));
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<ClanPlayer, Member> entry : discordClanPlayers.entrySet()) {
|
||||
// The map is formed from clan#getMembers (so the clan exists)
|
||||
//noinspection ConstantConditions
|
||||
updateViewPermission(entry.getValue(), entry.getKey().getClan(), ADD);
|
||||
updateLeaderRole(entry.getValue(), entry.getKey(), ADD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves channel in SimpleClans categories.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
* @return the channel
|
||||
* @see #getCachedCategories() retreive categories.
|
||||
*/
|
||||
public Optional<TextChannel> getCachedChannel(@NotNull String channelName) {
|
||||
return getCachedChannels().stream().filter(textChannel -> textChannel.getName().equals(channelName)).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a category can be obtained by id.
|
||||
*
|
||||
* @param categoryId the category id
|
||||
* @return true if the category exists
|
||||
* @see #channelExists(String)
|
||||
*/
|
||||
public boolean categoryExists(String categoryId) {
|
||||
return guild.getCategoryById(categoryId) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a channel with the specified clan tag exists
|
||||
*
|
||||
* @see #categoryExists(String)
|
||||
*/
|
||||
public boolean channelExists(String clanTag) {
|
||||
return getChannel(clanTag).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the channel in SimpleClans categories.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
* @return the channel
|
||||
* @see #getCachedChannel(String) retreive the <b>cached</b> channel.
|
||||
*/
|
||||
public Optional<TextChannel> getChannel(@NotNull String channelName) {
|
||||
return getChannels().stream().filter(textChannel -> textChannel.getName().equals(channelName)).findAny();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes channel from SimpleClans categories.
|
||||
* If there are no channels, removes category as well.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
* @return true, if channel was deleted and false if not.
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public boolean deleteChannel(@NotNull String channelName) {
|
||||
boolean deleted = false;
|
||||
|
||||
if (channelExists(channelName)) {
|
||||
for (Category category : getCachedCategories()) {
|
||||
if (category.getTextChannels().size() > 0) {
|
||||
for (TextChannel textChannel : category.getTextChannels()) {
|
||||
if (textChannel.getName().equals(channelName)) {
|
||||
textChannel.delete().complete();
|
||||
deleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (category.getTextChannels().size() == 0) {
|
||||
textCategories.remove(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
category.delete().complete();
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return categories from config
|
||||
*/
|
||||
public List<Category> getCachedCategories() {
|
||||
return textCategories.stream().
|
||||
filter(this::categoryExists).
|
||||
map(guild::getCategoryById).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* In most cases, you will use {@link #getCachedCategories()}.
|
||||
*
|
||||
* @return categories from guild
|
||||
*/
|
||||
public List<Category> getCategories() {
|
||||
return guild.getCategoriesByName(settingsManager.getString(DISCORDCHAT_TEXT_CATEGORY_FORMAT), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* In most cases, you will use {@link #getCachedChannels()}.
|
||||
*
|
||||
* @return all channels from guild
|
||||
*/
|
||||
public List<TextChannel> getChannels() {
|
||||
return getCategories().stream().map(Category::getTextChannels).flatMap(Collection::stream).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All channels in categories
|
||||
*/
|
||||
public List<TextChannel> getCachedChannels() {
|
||||
return getCachedCategories().stream().map(Category::getTextChannels).flatMap(Collection::stream).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Member getMember(@NotNull ClanPlayer clanPlayer) {
|
||||
String discordId = accountManager.getDiscordId(clanPlayer.getUniqueId());
|
||||
return DiscordUtil.getMemberById(discordId);
|
||||
}
|
||||
|
||||
private void clearChannels(Map<String, TextChannel> discordTagChannels) {
|
||||
// Removes abandoned channels
|
||||
ArrayList<String> clansToDelete = new ArrayList<>(discordTagChannels.keySet());
|
||||
clansToDelete.removeAll(clanTags);
|
||||
clansToDelete.forEach(clanChannel -> {
|
||||
deleteChannel(clanChannel);
|
||||
discordTagChannels.remove(clanChannel);
|
||||
});
|
||||
|
||||
// Removes invalid channels
|
||||
Iterator<String> iterator = discordTagChannels.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String clanChannel = iterator.next();
|
||||
try {
|
||||
validateChannel(clanChannel);
|
||||
} catch (InvalidChannelException ex) {
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
deleteChannel(clanChannel);
|
||||
iterator.remove();
|
||||
} catch (ChannelExistsException | ChannelsLimitException ex) {
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetPermissions(Map<String, TextChannel> discordClanChannels) {
|
||||
for (Map.Entry<String, TextChannel> channelEntry : discordClanChannels.entrySet()) {
|
||||
TextChannel channel = channelEntry.getValue();
|
||||
Clan clan = clanManager.getClan(channelEntry.getKey());
|
||||
Map<ClanPlayer, Member> discordPlayers = getDiscordPlayers(clan);
|
||||
|
||||
for (Member member : discordPlayers.values()) {
|
||||
PermissionOverride override = channel.getPermissionOverride(member);
|
||||
if (override != null) {
|
||||
override.delete().queue(afterSuccess -> updateViewPermission(member, channel, ADD));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createChannels(Map<String, TextChannel> discordClanChannels) {
|
||||
if (!settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Removes already used discord channels from creation
|
||||
clanTags.removeAll(discordClanChannels.keySet());
|
||||
|
||||
for (String clan : clanTags) {
|
||||
try {
|
||||
createChannel(clan);
|
||||
} catch (CategoriesLimitException | ChannelsLimitException ex) {
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
break;
|
||||
} catch (InvalidChannelException | ChannelExistsException ignored) {
|
||||
// There is already debug on #clearChannels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void sendPrivateMessage(TextChannel textChannel, Message eventMessage, String message) {
|
||||
RestAction<PrivateChannel> privateChannelAction = eventMessage.getAuthor().openPrivateChannel();
|
||||
textChannel.deleteMessageById(eventMessage.getId()).queue(unused ->
|
||||
privateChannelAction.flatMap(privateChannel -> privateChannel.sendMessage(message)));
|
||||
}
|
||||
|
||||
private void validateChannel(@NotNull String clanTag)
|
||||
throws InvalidChannelException, ChannelExistsException, ChannelsLimitException {
|
||||
Clan clan = clanManager.getClan(clanTag);
|
||||
if (clan == null) {
|
||||
throw new InvalidChannelException(String.format("Clan %s is null", clanTag));
|
||||
}
|
||||
if (!clan.isVerified() && !clan.isPermanent()) {
|
||||
throw new InvalidChannelException(String.format("Clan %s is not verified or permanent", clanTag));
|
||||
}
|
||||
|
||||
Map<ClanPlayer, Member> discordClanPlayers = getDiscordPlayers(clan);
|
||||
if (discordClanPlayers.size() == 0) {
|
||||
throw new InvalidChannelException(String.format("Clan %s doesn't have any linked players", clanTag),
|
||||
"your.clan.doesnt.have.any.linked.player");
|
||||
}
|
||||
|
||||
if (discordClanPlayers.size() < settingsManager.getInt(DISCORDCHAT_MINIMUM_LINKED_PLAYERS)) {
|
||||
throw new InvalidChannelException(String.format("Clan %s doesn't have minimum linked players", clanTag),
|
||||
"your.clan.doesnt.have.minimum.linked.player");
|
||||
}
|
||||
|
||||
if (!whitelist.isEmpty() && !whitelist.contains(clan.getTag())) {
|
||||
throw new InvalidChannelException(String.format("Clan %s is not listed on the whitelist", clanTag),
|
||||
"your.clan.is.not.on.the.whitelist");
|
||||
}
|
||||
|
||||
if (channelExists(clanTag)) {
|
||||
throw new ChannelExistsException(String.format("Channel %s is already exist", clanTag),
|
||||
"your.clan.already.has.channel");
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<ClanPlayer, Member> getDiscordPlayers(@NotNull Clan clan) {
|
||||
Map<ClanPlayer, Member> discordClanPlayers = new HashMap<>();
|
||||
for (ClanPlayer cp : clan.getMembers()) {
|
||||
Member member = getMember(cp);
|
||||
if (member != null) {
|
||||
discordClanPlayers.put(cp, member);
|
||||
}
|
||||
}
|
||||
return discordClanPlayers;
|
||||
}
|
||||
|
||||
private void updateLeaderRole(@NotNull Member member, @NotNull ClanPlayer clanPlayer, DiscordAction action) {
|
||||
if (!clanPlayer.isLeader()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == ADD) {
|
||||
guild.addRoleToMember(member, leaderRole).queue();
|
||||
} else {
|
||||
guild.removeRoleFromMember(member, leaderRole).queue();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViewPermission(@Nullable Member member, @NotNull GuildChannel channel, @NotNull DiscordAction action) {
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == ADD) {
|
||||
channel.upsertPermissionOverride(member).
|
||||
setPermissions(Collections.singletonList(VIEW_CHANNEL), Collections.emptyList()).queue();
|
||||
} else {
|
||||
channel.getManager().removePermissionOverride(member).queue();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViewPermission(@NotNull Member member, @NotNull Clan clan, DiscordAction action) {
|
||||
String tag = clan.getTag();
|
||||
Optional<TextChannel> channel = getCachedChannel(tag).map(Optional::of).orElse(getChannel(tag));
|
||||
if (channel.isPresent()) {
|
||||
TextChannel textChannel = channel.get();
|
||||
updateViewPermission(member, textChannel, action);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
private boolean createChannelSilently(ClanPlayer clanPlayer) {
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null || !settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
createChannel(clan.getTag());
|
||||
} catch (DiscordHookException ex) {
|
||||
// Clan is not following the conditions, categories are fulled or discord reaches the limit, nothing to do here.
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum DiscordAction {
|
||||
ADD, REMOVE
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class CategoriesLimitException extends DiscordHookException {
|
||||
|
||||
public CategoriesLimitException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class ChannelExistsException extends DiscordHookException {
|
||||
|
||||
public ChannelExistsException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class ChannelsLimitException extends DiscordHookException {
|
||||
|
||||
public ChannelsLimitException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Superclass of all discord exceptions
|
||||
*
|
||||
* @see InvalidChannelException
|
||||
* @see ChannelsLimitException
|
||||
* @see ChannelExistsException
|
||||
* @see CategoriesLimitException
|
||||
*/
|
||||
public class DiscordHookException extends Exception {
|
||||
|
||||
private String messageKey;
|
||||
|
||||
public DiscordHookException(String debugMessage) {
|
||||
super(debugMessage);
|
||||
}
|
||||
|
||||
public DiscordHookException(String debugMessage, String messageKey) {
|
||||
super(debugMessage);
|
||||
this.messageKey = messageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message key or null if this key is not used in-game
|
||||
*/
|
||||
public @Nullable String getMessageKey() {
|
||||
return messageKey;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class InvalidChannelException extends DiscordHookException {
|
||||
|
||||
public InvalidChannelException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
|
||||
public InvalidChannelException(String debugMessage) {
|
||||
super(debugMessage);
|
||||
}
|
||||
}
|
||||
+2
@@ -31,6 +31,8 @@ public abstract class PlaceholderResolver {
|
||||
* @param method the annotated method
|
||||
* @param placeholder the placeholder to resolve
|
||||
* @param config configuration for the resolver
|
||||
*
|
||||
* @return the resolved placeholder
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
|
||||
+17
-6
@@ -1,5 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
|
||||
|
||||
import me.clip.placeholderapi.expansion.Configurable;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.Relational;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
@@ -20,9 +21,7 @@ import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class SimpleClansExpansion extends PlaceholderExpansion implements Relational {
|
||||
public class SimpleClansExpansion extends PlaceholderExpansion implements Relational, Configurable {
|
||||
|
||||
private static final Pattern TOP_CLANS_PATTERN = Pattern.compile("(?<strip>^topclans_(?<position>\\d+)_)clan_");
|
||||
private static final Pattern TOP_PLAYERS_PATTERN = Pattern.compile("(?<strip>^topplayers_(?<position>\\d+)_)");
|
||||
@@ -77,6 +76,18 @@ public class SimpleClansExpansion extends PlaceholderExpansion implements Relati
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDefaults() {
|
||||
Map<String, Object> defaults = new HashMap<>();
|
||||
|
||||
defaults.put("color.rival", "&c");
|
||||
defaults.put("color.ally", "&b");
|
||||
defaults.put("color.same_clan", "&a");
|
||||
|
||||
return defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String onPlaceholderRequest(Player player1, Player player2, String params) {
|
||||
@@ -90,13 +101,13 @@ public class SimpleClansExpansion extends PlaceholderExpansion implements Relati
|
||||
}
|
||||
//noinspection ConstantConditions -- getClanPlayer != null == getClan() != null
|
||||
if (cp1.getClan().isMember(player2)) {
|
||||
return GREEN.toString();
|
||||
return getString("color.same_clan", null);
|
||||
}
|
||||
if (cp1.isRival(player2)) {
|
||||
return RED.toString();
|
||||
return getString("color.rival", null);
|
||||
}
|
||||
if (cp1.isAlly(player2)) {
|
||||
return AQUA.toString();
|
||||
return getString("color.ally", null);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Coordinate {
|
||||
|
||||
private final double x;
|
||||
private final double z;
|
||||
|
||||
|
||||
public Coordinate(double x, double z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Coordinate(Location location) {
|
||||
this.x = location.getX();
|
||||
this.z = location.getZ();
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Coordinate that = (Coordinate) o;
|
||||
return Double.compare(that.getX(), getX()) == 0 && Double.compare(that.getZ(), getZ()) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getX(), getZ());
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,22 @@ package net.sacredlabyrinth.phaed.simpleclans.hooks.protection;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class Land {
|
||||
|
||||
private final String id;
|
||||
private final Set<UUID> owners;
|
||||
private final List<Coordinate> coordinates;
|
||||
|
||||
public Land(@NotNull String id, @NotNull Set<UUID> owners) {
|
||||
this(id, owners, Collections.emptyList());
|
||||
}
|
||||
|
||||
public Land(@NotNull String id, @NotNull Set<UUID> owners, @NotNull List<Coordinate> coordinates) {
|
||||
this.id = id;
|
||||
this.owners = owners;
|
||||
this.coordinates = coordinates;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -26,6 +30,10 @@ public class Land {
|
||||
return owners;
|
||||
}
|
||||
|
||||
public @NotNull List<Coordinate> getCoordinates() {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
+5
@@ -1,5 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
@@ -12,6 +13,10 @@ import java.util.Set;
|
||||
|
||||
public interface ProtectionProvider {
|
||||
|
||||
default void register() {
|
||||
SimpleClans.getInstance().getProtectionManager().registerProvider(this);
|
||||
}
|
||||
|
||||
void setup() throws LinkageError, Exception;
|
||||
|
||||
@NotNull
|
||||
|
||||
+61
-20
@@ -4,29 +4,34 @@ import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimCreatedEvent;
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimResizeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Coordinate;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.debug;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class GriefPreventionProvider implements ProtectionProvider {
|
||||
public class GriefPreventionProvider implements ProtectionProvider, Listener {
|
||||
|
||||
@Override
|
||||
public void setup() throws NoSuchMethodException {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
Claim.class.getMethod("getOwnerID");
|
||||
public void setup() {
|
||||
Bukkit.getPluginManager().registerEvents(this, SimpleClans.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,16 +43,6 @@ public class GriefPreventionProvider implements ProtectionProvider {
|
||||
return Collections.singleton(getLand(claim));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Land getLand(@Nullable Claim claim) {
|
||||
if (claim == null) {
|
||||
return null;
|
||||
}
|
||||
debug(String.format("id %s name %s uuid %s", claim.getID(), claim.getOwnerName(), claim.getOwnerID()));
|
||||
|
||||
return new Land(getIdPrefix() + claim.getID().toString(), Collections.singleton(claim.getOwnerID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
@@ -76,7 +71,11 @@ public class GriefPreventionProvider implements ProtectionProvider {
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return ClaimCreatedEvent.class;
|
||||
try {
|
||||
return ClaimCreatedEvent.class;
|
||||
} catch (NoClassDefFoundError error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,4 +92,46 @@ public class GriefPreventionProvider implements ProtectionProvider {
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "GriefPrevention";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Land getLand(@Nullable Claim claim) {
|
||||
if (claim == null) {
|
||||
return null;
|
||||
}
|
||||
List<Coordinate> coords = Arrays.asList(new Coordinate(claim.getLesserBoundaryCorner()),
|
||||
new Coordinate(claim.getGreaterBoundaryCorner()));
|
||||
|
||||
return new Land(getIdPrefix() + claim.getID().toString(), Collections.singleton(getOwnerID(claim)), coords);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@NotNull
|
||||
private UUID getOwnerID(@NotNull Claim claim) {
|
||||
try {
|
||||
return claim.getOwnerID();
|
||||
} catch (NoSuchMethodError error) {
|
||||
return Bukkit.getOfflinePlayer(claim.getOwnerName()).getUniqueId();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
private void onResize(ClaimResizeEvent event) {
|
||||
ClanManager clanManager = SimpleClans.getInstance().getClanManager();
|
||||
|
||||
Land originalLand = getLand(event.getFrom());
|
||||
Land newLand = getLand(event.getTo());
|
||||
if (originalLand == null || newLand == null) {
|
||||
return;
|
||||
}
|
||||
for (UUID owner : originalLand.getOwners()) {
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(owner);
|
||||
if (cp == null) continue;
|
||||
for (ProtectionManager.Action action : ProtectionManager.Action.values()) {
|
||||
if (cp.isAllowed(action, originalLand.getId())) {
|
||||
cp.disallow(action, originalLand.getId());
|
||||
cp.allow(action, newLand.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import biz.princeps.landlord.api.ILandLord;
|
||||
import biz.princeps.landlord.api.IOwnedLand;
|
||||
import biz.princeps.landlord.api.events.LandPreClaimEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Landlord4Provider implements ProtectionProvider {
|
||||
|
||||
private ILandLord landlord;
|
||||
|
||||
@Override
|
||||
public void setup() throws LinkageError, Exception {
|
||||
//noinspection ConstantConditions
|
||||
landlord = (ILandLord) Bukkit.getPluginManager().getPlugin("Landlord");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
IOwnedLand ownedLand = landlord.getWGManager().getRegion(location);
|
||||
if (ownedLand == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
lands.add(getLand(ownedLand));
|
||||
return lands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
Set<IOwnedLand> ownedLands = landlord.getWGManager().getRegions(player.getUniqueId(), world);
|
||||
for (IOwnedLand ownedLand : ownedLands) {
|
||||
lands.add(getLand(ownedLand));
|
||||
}
|
||||
return lands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ll";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
|
||||
landlord.getWGManager().unclaim(world, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return LandPreClaimEvent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
if (!(event instanceof LandPreClaimEvent)) {
|
||||
return null;
|
||||
}
|
||||
return ((LandPreClaimEvent) event).getPlayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "Landlord";
|
||||
}
|
||||
|
||||
private @NotNull Land getLand(@NotNull IOwnedLand ownedLand) {
|
||||
String id = getIdPrefix() + ownedLand.getName();
|
||||
HashSet<UUID> owners = new HashSet<>();
|
||||
owners.add(ownedLand.getOwner());
|
||||
|
||||
return new Land(id, owners);
|
||||
}
|
||||
}
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSquared3Provider implements ProtectionProvider {
|
||||
|
||||
private Method getLocation;
|
||||
private Method getPlots;
|
||||
|
||||
@Override
|
||||
public void setup() throws ClassNotFoundException, NoSuchMethodException {
|
||||
Class.forName("com.intellectualcrafters.plot.object.Location");
|
||||
Class.forName("com.intellectualcrafters.plot.object.Plot");
|
||||
getLocation = BukkitUtil.class.getMethod("getLocation", Location.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
Plot plot = getPlot(location);
|
||||
if (plot != null) {
|
||||
return Collections.singleton(getLand(plot));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
private @Nullable Plot getPlot(@NotNull Location location) {
|
||||
try {
|
||||
return Plot.getPlot((com.intellectualcrafters.plot.object.Location) getLocation.invoke(null, location));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Land getLand(@NotNull Plot plot) {
|
||||
String id = getIdPrefix() + plot.getId().toString();
|
||||
return new Land(id, plot.getOwners());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
Set<Plot> plots = PS.get().getPlots(world.getName(), player.getUniqueId());
|
||||
|
||||
return plots.stream().map(this::getLand).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
Collection<Plot> plots = PS.get().getPlots(world.getName());
|
||||
for (Plot plot : plots) {
|
||||
if (plot.getId().toString().equals(id)) {
|
||||
plot.deletePlot(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return PlayerClaimPlotEvent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
if (event instanceof PlayerClaimPlotEvent) {
|
||||
return ((PlayerClaimPlotEvent) event).getPlayer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSquared5Provider implements ProtectionProvider {
|
||||
|
||||
@Override
|
||||
public void setup() throws NoSuchMethodException {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
BukkitUtil.class.getMethod("getPlot", Location.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
Plot plot = BukkitUtil.getPlot(location);
|
||||
if (plot != null) {
|
||||
return Collections.singleton(getLand(plot));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Land getLand(@NotNull Plot plot) {
|
||||
return new Land(getIdPrefix() + plot.getId(), plot.getOwners());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
Set<Plot> plots = PlotSquared.get().getPlots(world.getName(), player.getUniqueId());
|
||||
return plots.stream().map(this::getLand).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
for (Plot plot : PlotSquared.get().getPlots(world.getName())) {
|
||||
if (plot.getId().toString().equals(id)) {
|
||||
plot.deletePlot(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
}
|
||||
+30
-7
@@ -4,6 +4,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Coordinate;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Location;
|
||||
@@ -16,9 +17,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class WorldGuard6Provider implements ProtectionProvider {
|
||||
@@ -26,14 +25,20 @@ public class WorldGuard6Provider implements ProtectionProvider {
|
||||
private WorldGuardPlugin worldGuard;
|
||||
private Method getRegionManager;
|
||||
private Method getApplicableRegions;
|
||||
private Method getPoints;
|
||||
private Method getX;
|
||||
private Method getZ;
|
||||
|
||||
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||
@Override
|
||||
public void setup() throws NoSuchMethodException {
|
||||
public void setup() throws NoSuchMethodException, ClassNotFoundException {
|
||||
worldGuard = WorldGuardPlugin.inst();
|
||||
getRegionManager = worldGuard.getClass().getMethod("getRegionManager", World.class);
|
||||
//noinspection JavaReflectionMemberAccess
|
||||
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
||||
|
||||
getPoints = ProtectedRegion.class.getMethod("getPoints");
|
||||
Class<?> blockVector = Class.forName("com.sk89q.worldedit.BlockVector2");
|
||||
getX = blockVector.getMethod("getX");
|
||||
getZ = blockVector.getMethod("getZ");
|
||||
}
|
||||
|
||||
private @Nullable RegionManager getRegionManager(@Nullable World world) {
|
||||
@@ -56,7 +61,25 @@ public class WorldGuard6Provider implements ProtectionProvider {
|
||||
|
||||
@NotNull
|
||||
private Land getLand(ProtectedRegion region) {
|
||||
return new Land(getIdPrefix() + region.getId(), region.getOwners().getUniqueIds());
|
||||
List<Coordinate> coordinates = getCoordinates(region);
|
||||
|
||||
return new Land(getIdPrefix() + region.getId(), region.getOwners().getUniqueIds(), coordinates);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Coordinate> getCoordinates(ProtectedRegion region) {
|
||||
List<Coordinate> coordinates = new ArrayList<>();
|
||||
try {
|
||||
List<?> points = (List<?>) getPoints.invoke(region);
|
||||
for (Object point : points) {
|
||||
double x = (double) getX.invoke(point);
|
||||
double z = (double) getZ.invoke(point);
|
||||
coordinates.add(new Coordinate(x, z));
|
||||
}
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-4
@@ -1,11 +1,13 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Coordinate;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Location;
|
||||
@@ -16,9 +18,7 @@ import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public class WorldGuardProvider implements ProtectionProvider {
|
||||
@@ -46,7 +46,12 @@ public class WorldGuardProvider implements ProtectionProvider {
|
||||
|
||||
@NotNull
|
||||
private Land getLand(ProtectedRegion region) {
|
||||
return new Land(getIdPrefix() + region.getId(), region.getOwners().getUniqueIds());
|
||||
//noinspection DuplicatedCode
|
||||
List<Coordinate> coordinates = new ArrayList<>();
|
||||
for (BlockVector2 point : region.getPoints()) {
|
||||
coordinates.add(new Coordinate(point.getX(), point.getZ()));
|
||||
}
|
||||
return new Land(getIdPrefix() + region.getId(), region.getOwners().getUniqueIds(), coordinates);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,33 +1,38 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Events {
|
||||
public final class Events {
|
||||
|
||||
private Events() {}
|
||||
private Events() {
|
||||
// Can't instantiate this class
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Contract("null -> null")
|
||||
public static Player getAttacker(@Nullable EntityDamageEvent parentEvent) {
|
||||
if (parentEvent instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) parentEvent;
|
||||
if (parentEvent instanceof EntityDamageByEntityEvent sub) {
|
||||
Entity damager = sub.getDamager();
|
||||
|
||||
if (sub.getDamager() instanceof Player) {
|
||||
return (Player) sub.getDamager();
|
||||
if (damager instanceof Player attacker) {
|
||||
return attacker;
|
||||
}
|
||||
|
||||
if (sub.getDamager() instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) sub.getDamager();
|
||||
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
return (Player) projectile.getShooter();
|
||||
}
|
||||
if (damager instanceof Projectile projectile && projectile.getShooter() instanceof Player attacker) {
|
||||
return attacker;
|
||||
}
|
||||
|
||||
if (damager instanceof TNTPrimed tnt && tnt.getSource() instanceof Player attacker) {
|
||||
return attacker;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -16,22 +15,21 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.GLOBAL_FRIENDLY_FIRE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.SAFE_CIVILIANS;
|
||||
|
||||
public class FriendlyFire implements Listener {
|
||||
public class FriendlyFire extends SCListener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final Map<UUID, Long> warned = new HashMap<>();
|
||||
private static final long WARN_DELAY = 10000;
|
||||
|
||||
public FriendlyFire(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player) ||
|
||||
plugin.getSettingsManager().getStringList(BLACKLISTED_WORLDS).contains(event.getEntity().getWorld().getName())) {
|
||||
if (!(event.getEntity() instanceof Player) || isBlacklistedWorld(event.getEntity())) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) event.getEntity();
|
||||
|
||||
+168
-174
@@ -13,20 +13,33 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager.Action.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
@@ -48,19 +61,160 @@ public class LandProtection implements Listener {
|
||||
}
|
||||
|
||||
public void registerListeners() {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
registerBlockBreakListener();
|
||||
registerBlockPlaceListener();
|
||||
registerEntityDamageListener();
|
||||
registerInteractEntityListener();
|
||||
registerInteractListener();
|
||||
registerInventoryOpenListener();
|
||||
registerListener(BlockBreakEvent.class, (event, cancel) -> {
|
||||
Block block = event.getBlock();
|
||||
if (settingsManager.getIgnoredList(BREAK).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(HangingBreakByEntityEvent.class, (event, cancel) -> {
|
||||
Entity remover = event.getRemover();
|
||||
if (!(remover instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, event.getEntity().getLocation(), ((Player) remover))) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(HangingPlaceEvent.class, (event, cancel) -> {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, event.getBlock().getLocation(), player)) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(StructureGrowEvent.class, (event, cancel) -> {
|
||||
if (event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, event.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(BlockPlaceEvent.class, (event, cancel) -> {
|
||||
Block block = event.getBlock();
|
||||
if (settingsManager.getIgnoredList(PLACE).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(PlayerBucketEmptyEvent.class, (event, cancel) -> {
|
||||
Block block = event.getBlockClicked();
|
||||
if (settingsManager.getIgnoredList(PLACE).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(PlayerBucketFillEvent.class, (event, cancel) -> {
|
||||
Block block = event.getBlockClicked().getRelative(event.getBlockFace());
|
||||
if (settingsManager.getIgnoredList(BREAK).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(VehicleDestroyEvent.class, (event, cancel) -> {
|
||||
if (!(event.getAttacker() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, event.getVehicle().getLocation(), ((Player) event.getAttacker()))) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(EntityChangeBlockEvent.class, (event, cancel) -> {
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, event.getBlock().getLocation(), ((Player) event.getEntity()))) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(EntityDamageByEntityEvent.class, (event, cancel) -> {
|
||||
Player attacker = Events.getAttacker(event);
|
||||
if (attacker == null) {
|
||||
return;
|
||||
}
|
||||
Player victim = event.getEntity() instanceof Player ? ((Player) event.getEntity()) : null;
|
||||
if (victim == null) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(DAMAGE, event.getEntity().getLocation(), attacker, victim)) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(PlayerInteractAtEntityEvent.class, (event, cancel) -> {
|
||||
if (protectionManager.can(INTERACT_ENTITY, event.getRightClicked().getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(PlayerInteractEntityEvent.class, (event, cancel) -> {
|
||||
if (protectionManager.can(INTERACT_ENTITY, event.getRightClicked().getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(VehicleExitEvent.class, (event, cancel) -> {
|
||||
Vehicle vehicle = event.getVehicle();
|
||||
if (vehicle instanceof Tameable && event.getExited() instanceof Player) {
|
||||
if (protectionManager.can(INTERACT_ENTITY, vehicle.getLocation(), ((Player) event.getExited()))) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
}
|
||||
});
|
||||
registerListener(InventoryOpenEvent.class, (event, cancel) -> {
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
Location location = getLocation(holder);
|
||||
if (holder instanceof Entity && holder == event.getPlayer()) return;
|
||||
if (location == null) return;
|
||||
|
||||
if (protectionManager.can(CONTAINER, location, ((Player) event.getPlayer()))) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(PlayerInteractEvent.class, (event, cancel) -> {
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
ProtectionManager.Action action = getInteractEventAction(event);
|
||||
if (protectionManager.can(action, event.getClickedBlock().getLocation(), event.getPlayer())) {
|
||||
event.setUseInteractedBlock(cancel ? Result.DENY : Result.ALLOW);
|
||||
event.setUseItemInHand(cancel ? Result.DENY : Result.ALLOW);
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
registerListener(PlayerBedEnterEvent.class, (event, cancel) -> {
|
||||
if (protectionManager.can(INTERACT, event.getBed().getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(cancel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private <T extends Event> void registerListener(Class<T> clazz, BiConsumer<T, Boolean> listener) {
|
||||
Bukkit.getPluginManager().registerEvent(clazz, this, EventPriority.LOWEST, (l, event) -> {
|
||||
if (clazz.isInstance(event)) {
|
||||
listener.accept(clazz.cast(event), true);
|
||||
}
|
||||
}, plugin, false);
|
||||
Bukkit.getPluginManager().registerEvent(clazz, this, priority, (l, event) -> {
|
||||
if (clazz.isInstance(event)) {
|
||||
listener.accept(clazz.cast(event), false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
public void registerCreateLandEvent(ProtectionProvider provider, @Nullable Class<? extends Event> createLandEvent) {
|
||||
if (createLandEvent == null) return;
|
||||
Bukkit.getPluginManager().registerEvent(createLandEvent, this, EventPriority.NORMAL, (listener, event) -> {
|
||||
if (!createLandEvent.isInstance(createLandEvent)) {
|
||||
if (!createLandEvent.isInstance(event)) {
|
||||
return;
|
||||
}
|
||||
Player player = provider.getPlayer(event);
|
||||
@@ -94,173 +248,13 @@ public class LandProtection implements Listener {
|
||||
((Cancellable) event).setCancelled(true);
|
||||
}
|
||||
|
||||
private void registerBlockBreakListener() {
|
||||
Bukkit.getPluginManager().registerEvent(BlockBreakEvent.class, this, priority, (listener, event) -> {
|
||||
if (!(event instanceof BlockBreakEvent)) {
|
||||
return;
|
||||
}
|
||||
BlockBreakEvent blockBreakEvent = (BlockBreakEvent) event;
|
||||
Block block = blockBreakEvent.getBlock();
|
||||
if (settingsManager.getIgnoredList(BREAK).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, block.getLocation(), blockBreakEvent.getPlayer())) {
|
||||
blockBreakEvent.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
private void registerBlockPlaceListener() {
|
||||
Bukkit.getPluginManager().registerEvent(BlockPlaceEvent.class, this, priority, (listener, event) -> {
|
||||
if (!(event instanceof BlockPlaceEvent)) {
|
||||
return;
|
||||
}
|
||||
BlockPlaceEvent blockPlaceEvent = (BlockPlaceEvent) event;
|
||||
Block block = blockPlaceEvent.getBlock();
|
||||
if (settingsManager.getIgnoredList(PLACE).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, block.getLocation(), blockPlaceEvent.getPlayer())) {
|
||||
blockPlaceEvent.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
private void registerEntityDamageListener() {
|
||||
Bukkit.getPluginManager().registerEvent(EntityDamageByEntityEvent.class, this, priority,
|
||||
(listener, event) -> {
|
||||
if (!(event instanceof EntityDamageByEntityEvent)) {
|
||||
return;
|
||||
}
|
||||
EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event;
|
||||
if (!(entityEvent.getDamager() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player attacker = ((Player) entityEvent.getDamager());
|
||||
Player victim = entityEvent.getEntity() instanceof Player ? ((Player) entityEvent.getEntity()) : null;
|
||||
if (protectionManager.can(DAMAGE, entityEvent.getEntity().getLocation(), attacker, victim)) {
|
||||
entityEvent.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
private void registerInteractEntityListener() {
|
||||
Bukkit.getPluginManager().registerEvent(PlayerInteractEntityEvent.class, this, priority, (listener, event) -> {
|
||||
if (!(event instanceof PlayerInteractEntityEvent)) {
|
||||
return;
|
||||
}
|
||||
PlayerInteractEntityEvent interactEvent = (PlayerInteractEntityEvent) event;
|
||||
if (protectionManager.can(INTERACT_ENTITY, interactEvent.getRightClicked().getLocation(), interactEvent.getPlayer())) {
|
||||
interactEvent.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
private void registerInventoryOpenListener() {
|
||||
Bukkit.getPluginManager().registerEvent(InventoryOpenEvent.class, this, priority, (l, e) -> {
|
||||
if (!(e instanceof InventoryOpenEvent)) {
|
||||
return;
|
||||
}
|
||||
InventoryOpenEvent event = ((InventoryOpenEvent) e);
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
Location location = getLocation(holder);
|
||||
if (holder instanceof Entity && holder == event.getPlayer()) return;
|
||||
if (location == null) return;
|
||||
|
||||
if (protectionManager.can(CONTAINER, location, ((Player) event.getPlayer()))) {
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
private void registerInteractListener() {
|
||||
Bukkit.getPluginManager().registerEvent(PlayerInteractEvent.class, this, priority, (listener, event) -> {
|
||||
if (!(event instanceof PlayerInteractEvent)) {
|
||||
return;
|
||||
}
|
||||
PlayerInteractEvent interactEvent = (PlayerInteractEvent) event;
|
||||
if (interactEvent.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
ProtectionManager.Action action = getInteractEventAction(interactEvent);
|
||||
if (protectionManager.can(action, interactEvent.getClickedBlock().getLocation(), interactEvent.getPlayer())) {
|
||||
interactEvent.setUseInteractedBlock(Event.Result.ALLOW);
|
||||
interactEvent.setUseItemInHand(Event.Result.ALLOW);
|
||||
interactEvent.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
if (settingsManager.getIgnoredList(BREAK).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlace(BlockPlaceEvent event) {
|
||||
Block block = event.getBlock();
|
||||
if (settingsManager.getIgnoredList(PLACE).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onDamage(EntityDamageByEntityEvent event) {
|
||||
Entity damager = event.getDamager();
|
||||
if (!(damager instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player victim = event.getEntity() instanceof Player ? ((Player) event.getEntity()) : null;
|
||||
if (protectionManager.can(DAMAGE, event.getEntity().getLocation(), (Player) damager, victim)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
InventoryHolder holder = event.getInventory().getHolder();
|
||||
Location location = getLocation(holder);
|
||||
if (holder instanceof Entity && holder == event.getPlayer()) return;
|
||||
if (location == null) return;
|
||||
|
||||
if (protectionManager.can(CONTAINER, location, ((Player) event.getPlayer()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (protectionManager.can(INTERACT_ENTITY, event.getRightClicked().getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
ProtectionManager.Action action = getInteractEventAction(event);
|
||||
if (protectionManager.can(action, event.getClickedBlock().getLocation(), event.getPlayer())) {
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable Location getLocation(@Nullable InventoryHolder holder) {
|
||||
if (holder instanceof BlockState) {
|
||||
return ((BlockState) holder).getLocation();
|
||||
}
|
||||
if (holder instanceof DoubleChest) {
|
||||
return ((DoubleChest) holder).getLocation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -19,26 +18,22 @@ import java.time.LocalDateTime;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.EconomyTransactionEvent.Cause.PLAYER_KILLED;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class PlayerDeath implements Listener {
|
||||
public class PlayerDeath extends SCListener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public PlayerDeath() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
public PlayerDeath(SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDeath(PlayerDeathEvent event) {
|
||||
SimpleClans.debug("A player died");
|
||||
Player victim = event.getEntity();
|
||||
if (plugin.getSettingsManager().getStringList(BLACKLISTED_WORLDS).contains(victim.getLocation().getWorld().getName())
|
||||
|| victim.hasMetadata("NPC")) {
|
||||
SimpleClans.debug("Blacklisted world");
|
||||
if (isNPC(victim) || isBlacklistedWorld(victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,6 +49,7 @@ public class PlayerDeath implements Listener {
|
||||
// record death for victim
|
||||
victimCp.addDeath();
|
||||
plugin.getStorageManager().updateClanPlayer(victimCp);
|
||||
plugin.getStorageManager().updateClanPlayer(attackerCp);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -104,7 +100,7 @@ public class PlayerDeath implements Listener {
|
||||
}
|
||||
player.sendMessage(ChatColor.AQUA + lang("player.got.money", player, money,
|
||||
victim.getName(), attacker.getKDR()));
|
||||
plugin.getPermissionsManager().playerGrantMoney(player, money);
|
||||
plugin.getPermissionsManager().grantPlayer(player, money, PLAYER_KILLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,4 +190,16 @@ public class PlayerDeath implements Listener {
|
||||
}
|
||||
return reward;
|
||||
}
|
||||
|
||||
private boolean isNPC(Player player) {
|
||||
if (player.hasMetadata("NPC")) {
|
||||
SimpleClans.debug(String.format("%s has NPC metadata", player.getName()));
|
||||
return true;
|
||||
}
|
||||
if (Bukkit.getOfflinePlayer(player.getUniqueId()).getName() == null) {
|
||||
SimpleClans.debug(String.format("%s has a null name", player.getUniqueId()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -6,26 +6,20 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.BLACKLISTED_WORLDS;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PVP_ONLY_WHILE_IN_WAR;
|
||||
|
||||
public class PvPOnlyInWar implements Listener {
|
||||
public class PvPOnlyInWar extends SCListener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public PvPOnlyInWar(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
public PvPOnlyInWar(SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player) ||
|
||||
plugin.getSettingsManager().getStringList(BLACKLISTED_WORLDS).contains(event.getEntity().getWorld().getName())) {
|
||||
if (!(event.getEntity() instanceof Player) || isBlacklistedWorld(event.getEntity())) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) event.getEntity();
|
||||
|
||||
Loaded 100 of 205 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user