mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-04 17:00:12 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35065bfa78 | ||
|
|
32f9b35d87 | ||
|
|
a1145f2568 | ||
|
|
0406c61b0f | ||
|
|
a2e59c9401 | ||
|
|
b1b5fef7bf | ||
|
|
2bdd6bc3bf | ||
|
|
f7081499b2 | ||
|
|
0f50d498cb | ||
|
|
da8d343897 | ||
|
|
ee1feb4276 | ||
|
|
24af2c03d0 | ||
|
|
6b2a3f85ac | ||
|
|
57076fb033 | ||
|
|
52ff77e6c1 | ||
|
|
146713fd48 | ||
|
|
c8e67cfd4f | ||
|
|
f4f47b2060 | ||
|
|
13cf348084 | ||
|
|
b37512be7d | ||
|
|
9097fa02fa | ||
|
|
a759884b8d | ||
|
|
f5e1387246 | ||
|
|
cddde547b1 | ||
|
|
f466a86309 | ||
|
|
9f4f39a420 | ||
|
|
46702f90ab | ||
|
|
5a490b11a3 | ||
|
|
3b51299dd6 | ||
|
|
5212296d62 | ||
|
|
67d3e70f58 | ||
|
|
8cd0b2e454 | ||
|
|
da9ec6c917 | ||
|
|
cb314dbe7b | ||
|
|
01c79862b9 | ||
|
|
c9df6acb13 | ||
|
|
ad910e9c30 | ||
|
|
d4d144fe36 | ||
|
|
1375679df8 | ||
|
|
b2c7d12b60 | ||
|
|
b363efe530 | ||
|
|
876b5ac50e | ||
|
|
d2825df01b | ||
|
|
bc85864134 | ||
|
|
4808addaa5 | ||
|
|
05e7abccbd | ||
|
|
cfd1ff851d | ||
|
|
f29bc746af | ||
|
|
e12ee8aaed | ||
|
|
fe60b25f61 | ||
|
|
503d67903e | ||
|
|
e1625d38c8 | ||
|
|
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 | ||
|
|
6ad79b6879 | ||
|
|
30cc1759e9 | ||
|
|
3bae27db2d | ||
|
|
33ea872e4d | ||
|
|
558f13dccb | ||
|
|
08aae94637 | ||
|
|
c25bd8206c | ||
|
|
da397676f6 | ||
|
|
4a56f9e87a | ||
|
|
51241b3ae5 | ||
|
|
e66e187566 | ||
|
|
031227ddaf | ||
|
|
c3b9c68d45 | ||
|
|
37ffb93808 | ||
|
|
84dd6a4cbd | ||
|
|
8eaa86ae45 | ||
|
|
55e82dab5f | ||
|
|
0f1e016483 | ||
|
|
3a8a316f3d | ||
|
|
f350025796 | ||
|
|
36bbb91b61 | ||
|
|
f468a28476 | ||
|
|
115e1c5083 | ||
|
|
420d8fae8e | ||
|
|
fef3763039 | ||
|
|
ebe79fe340 | ||
|
|
4a40e4c03d | ||
|
|
47d4a215fb | ||
|
|
ad22a4c75c | ||
|
|
9811e2e1db | ||
|
|
f81318d458 | ||
|
|
4d0c39c0dc | ||
|
|
74752b4341 | ||
|
|
099cf2e8d1 | ||
|
|
b4447054fb | ||
|
|
387ea7fb7b | ||
|
|
5a2efab233 | ||
|
|
7b415e883f | ||
|
|
339bacf6d4 | ||
|
|
650d8d4d50 | ||
|
|
c1a3a5a5fe | ||
|
|
ca550c13c4 | ||
|
|
4738fcae97 | ||
|
|
e6a4d94ea7 | ||
|
|
c4baa6b7f8 | ||
|
|
2eba58cd1c | ||
|
|
bc4c1280b0 | ||
|
|
0881f69900 | ||
|
|
e3d6fdfe4a | ||
|
|
935c86c43d | ||
|
|
ae1f846077 | ||
|
|
ddbd56e447 | ||
|
|
35cba37cbe | ||
|
|
1bd9191267 | ||
|
|
b8b1c6a02e | ||
|
|
001382558b | ||
|
|
eaf9cf6e19 | ||
|
|
5297739002 | ||
|
|
c826db3549 | ||
|
|
6b4e18338b | ||
|
|
44f1e6014f | ||
|
|
c05e978faf | ||
|
|
90f66681d0 | ||
|
|
536c18744a | ||
|
|
ee00ffbf58 | ||
|
|
8b2cf58f9f | ||
|
|
194ed5cae8 | ||
|
|
747683aa99 | ||
|
|
2f6afdb6e0 | ||
|
|
4aae97b033 | ||
|
|
51a88d0e5b | ||
|
|
d2a15f84f9 | ||
|
|
d5e456a4b6 | ||
|
|
d2530ebc72 | ||
|
|
1670c2da54 | ||
|
|
eda29fbfad | ||
|
|
daff6952e5 | ||
|
|
be12935e2f | ||
|
|
d17be1d834 | ||
|
|
38e6d6853f | ||
|
|
5e1791d953 | ||
|
|
f4f592da92 | ||
|
|
aa130710ee | ||
|
|
0a664543a7 | ||
|
|
8338dc2ac7 | ||
|
|
c621823d46 | ||
|
|
612d923b12 | ||
|
|
7c0834845b | ||
|
|
29f85228e8 | ||
|
|
c0741a3554 | ||
|
|
6e6503d480 |
No files matched your search
+25
-17
@@ -1,29 +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: true
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
java-version: [ 16, 21, 23]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: Java ${{ matrix.java-version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: SimpleClans
|
||||
path: target/SimpleClans.jar
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: "Set up JDK ${{ matrix.java-version }}"
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: "${{ matrix.java-version }}"
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
- name: Build with Maven
|
||||
run: ./mvnw -B -U package --file pom.xml
|
||||
- name: Upload Build Artifact
|
||||
if: "${{ matrix.java-version == 16 }}"
|
||||
uses: actions/upload-artifact@v4
|
||||
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@v4
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 16
|
||||
cache: 'maven'
|
||||
distribution: 'temurin'
|
||||
- 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: 11515,9974,9190,8849,8503,7915,7667,7330,7105,6588,630,591,585,531
|
||||
release_type: release
|
||||
relations: vault:optionalDependency,worldguard:optionalDependency,grief-prevention:optionalDependency
|
||||
relations: vault:optionalDependency,worldguard:optionalDependency,grief-prevention:optionalDependency,plotsquared:optionalDependency
|
||||
@@ -0,0 +1,31 @@
|
||||
name: Publish to Modrinth
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 16
|
||||
cache: 'maven'
|
||||
distribution: 'temurin'
|
||||
- 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.21,1.20,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@v4
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v4
|
||||
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: 'temurin'
|
||||
- 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
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
# 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.
|
||||
wrapperVersion=3.3.2
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
# Changelog
|
||||
|
||||
## [2.19.2](https://github.com/RoinujNosde/SimpleClans/compare/v2.19.1...v2.19.2) (2023-08-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* cause check should return true on granting ([#397](https://github.com/RoinujNosde/SimpleClans/issues/397)) ([f29bc74](https://github.com/RoinujNosde/SimpleClans/commit/f29bc746af4940b493ebc43b1e25ff0fc00ab8d0))
|
||||
|
||||
## [2.19.1](https://github.com/RoinujNosde/SimpleClans/compare/v2.19.0...v2.19.1) (2023-08-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* charge money on deposit ([#394](https://github.com/RoinujNosde/SimpleClans/issues/394)) ([fe60b25](https://github.com/RoinujNosde/SimpleClans/commit/fe60b25f6107281a9771f6498400c3f8ce81c916))
|
||||
* consider uppercase when checking for disallowed colors ([#391](https://github.com/RoinujNosde/SimpleClans/issues/391)) ([503d679](https://github.com/RoinujNosde/SimpleClans/commit/503d67903e386b1c4b6eb7903a1addbfd42a684a))
|
||||
|
||||
## [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,19 @@ 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)
|
||||
|
||||
|
||||
[](https://mikasa.host/ref/6)
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</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$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</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: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" 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:1.7" 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:16.0.2" 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:7.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.26.0-GA" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.0" 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: commons-codec:commons-codec:1.11" 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: com.google.code.findbugs:jsr305:1.3.9" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.26" 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" />
|
||||
</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,327 +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.15.1</version>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</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.bukkit</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>
|
||||
<relocation>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</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>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>16.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</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>
|
||||
</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,259 @@
|
||||
#!/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.3.2
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set -euf
|
||||
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||
|
||||
# OS specific support.
|
||||
native_path() { printf %s\\n "$1"; }
|
||||
case "$(uname)" in
|
||||
CYGWIN* | MINGW*)
|
||||
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||
native_path() { cygpath --path --windows "$1"; }
|
||||
;;
|
||||
esac
|
||||
|
||||
# set JAVACMD and JAVACCMD
|
||||
set_java_home() {
|
||||
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||
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"
|
||||
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||
|
||||
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v java
|
||||
)" || :
|
||||
JAVACCMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v javac
|
||||
)" || :
|
||||
|
||||
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# hash string like Java String::hashCode
|
||||
hash_string() {
|
||||
str="${1:-}" h=0
|
||||
while [ -n "$str" ]; do
|
||||
char="${str%"${str#?}"}"
|
||||
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||
str="${str#?}"
|
||||
done
|
||||
printf %x\\n $h
|
||||
}
|
||||
|
||||
verbose() { :; }
|
||||
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||
|
||||
die() {
|
||||
printf %s\\n "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
trim() {
|
||||
# MWRAPPER-139:
|
||||
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||
# Needed for removing poorly interpreted newline sequences when running in more
|
||||
# exotic environments such as mingw bash on Windows.
|
||||
printf "%s" "${1}" | tr -d '[:space:]'
|
||||
}
|
||||
|
||||
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||
while IFS="=" read -r key value; do
|
||||
case "${key-}" in
|
||||
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||
esac
|
||||
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
|
||||
|
||||
case "${distributionUrl##*/}" in
|
||||
maven-mvnd-*bin.*)
|
||||
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||
*)
|
||||
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||
distributionPlatform=linux-amd64
|
||||
;;
|
||||
esac
|
||||
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||
;;
|
||||
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||
|
||||
exec_maven() {
|
||||
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||
}
|
||||
|
||||
if [ -d "$MAVEN_HOME" ]; then
|
||||
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
exec_maven "$@"
|
||||
fi
|
||||
|
||||
case "${distributionUrl-}" in
|
||||
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||
esac
|
||||
|
||||
# prepare tmp dir
|
||||
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||
trap clean HUP INT TERM EXIT
|
||||
else
|
||||
die "cannot create temp dir"
|
||||
fi
|
||||
|
||||
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||
|
||||
# Download and Install Apache Maven
|
||||
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
verbose "Downloading from: $distributionUrl"
|
||||
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
# select .zip or .tar.gz
|
||||
if ! command -v unzip >/dev/null; then
|
||||
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
fi
|
||||
|
||||
# verbose opt
|
||||
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||
|
||||
# normalize http auth
|
||||
case "${MVNW_PASSWORD:+has-password}" in
|
||||
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
esac
|
||||
|
||||
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||
verbose "Found wget ... using wget"
|
||||
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||
verbose "Found curl ... using curl"
|
||||
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||
elif set_java_home; then
|
||||
verbose "Falling back to use Java to download"
|
||||
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
cat >"$javaSource" <<-END
|
||||
public class Downloader extends java.net.Authenticator
|
||||
{
|
||||
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||
{
|
||||
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||
}
|
||||
public static void main( String[] args ) throws Exception
|
||||
{
|
||||
setDefault( new Downloader() );
|
||||
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||
}
|
||||
}
|
||||
END
|
||||
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||
verbose " - Compiling Downloader.java ..."
|
||||
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||
verbose " - Running Downloader.java ..."
|
||||
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||
fi
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
if [ -n "${distributionSha256Sum-}" ]; then
|
||||
distributionSha256Result=false
|
||||
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
elif command -v sha256sum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
elif command -v shasum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ $distributionSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# unzip and move
|
||||
if command -v unzip >/dev/null; then
|
||||
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||
else
|
||||
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||
fi
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
||||
@@ -0,0 +1,149 @@
|
||||
<# : batch portion
|
||||
@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.3.2
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||
@SET __MVNW_CMD__=
|
||||
@SET __MVNW_ERROR__=
|
||||
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||
@SET PSModulePath=
|
||||
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||
)
|
||||
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||
@SET __MVNW_PSMODULEP_SAVE=
|
||||
@SET __MVNW_ARG0_NAME__=
|
||||
@SET MVNW_USERNAME=
|
||||
@SET MVNW_PASSWORD=
|
||||
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
|
||||
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||
@GOTO :EOF
|
||||
: end batch / begin powershell #>
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($env:MVNW_VERBOSE -eq "true") {
|
||||
$VerbosePreference = "Continue"
|
||||
}
|
||||
|
||||
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||
if (!$distributionUrl) {
|
||||
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
}
|
||||
|
||||
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||
"maven-mvnd-*" {
|
||||
$USE_MVND = $true
|
||||
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||
$MVN_CMD = "mvnd.cmd"
|
||||
break
|
||||
}
|
||||
default {
|
||||
$USE_MVND = $false
|
||||
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
if ($env:MVNW_REPOURL) {
|
||||
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
|
||||
}
|
||||
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
|
||||
}
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||
|
||||
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
exit $?
|
||||
}
|
||||
|
||||
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||
}
|
||||
|
||||
# prepare tmp dir
|
||||
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||
trap {
|
||||
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||
|
||||
# Download and Install Apache Maven
|
||||
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
Write-Verbose "Downloading from: $distributionUrl"
|
||||
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||
if ($distributionSha256Sum) {
|
||||
if ($USE_MVND) {
|
||||
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||
}
|
||||
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||
}
|
||||
}
|
||||
|
||||
# unzip and move
|
||||
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||
try {
|
||||
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||
} catch {
|
||||
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||
Write-Error "fail to move MAVEN_HOME"
|
||||
}
|
||||
} finally {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
@@ -1,11 +1,10 @@
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.15.2</version>
|
||||
<version>2.19.3-SNAPSHOT</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
@@ -30,13 +29,11 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<release>8</release>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
@@ -47,25 +44,25 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>3.4.2</version>
|
||||
</plugin>
|
||||
|
||||
<!-- Release plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Shade plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
@@ -85,8 +82,8 @@
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.gson</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
@@ -94,6 +91,13 @@
|
||||
<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>
|
||||
@@ -104,6 +108,74 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Dependency plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.7.1</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>io.github.git-commit-id</groupId>
|
||||
<artifactId>git-commit-id-maven-plugin</artifactId>
|
||||
<version>9.0.1</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.10.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<release>8</release>
|
||||
<doclint>all,-missing</doclint>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Dependencies -->
|
||||
@@ -119,114 +191,89 @@
|
||||
<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>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>3.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.9</version>
|
||||
<version>2.11.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
<version>24.0.1</version>
|
||||
</dependency>
|
||||
<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>7.2.1</version>
|
||||
<version>13.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.4</version>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.17.1</version>
|
||||
<version>17.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.28.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Bukkit</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>landlord-latest</artifactId>
|
||||
<version>4.363</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>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test frameworks -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.11.3</version>
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.14.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -246,7 +293,7 @@
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
@@ -257,12 +304,12 @@
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
@@ -278,12 +325,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;
|
||||
|
||||
@@ -27,10 +26,12 @@ public class ChatBlock {
|
||||
private boolean cropRight = true;
|
||||
private boolean padRight = true;
|
||||
|
||||
@Deprecated
|
||||
public void setCropRight(boolean cropRight) {
|
||||
this.cropRight = cropRight;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPadRight(boolean padRight) {
|
||||
this.padRight = padRight;
|
||||
}
|
||||
@@ -45,6 +46,7 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setColumnSizes(String prefix, double... columnPercentages) {
|
||||
int ll = LINE_LENGTH;
|
||||
|
||||
@@ -57,6 +59,7 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasContent() {
|
||||
return !rows.isEmpty();
|
||||
}
|
||||
@@ -65,22 +68,27 @@ public class ChatBlock {
|
||||
rows.add(contents);
|
||||
}
|
||||
|
||||
|
||||
public int size() {
|
||||
return rows.size();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isEmpty() {
|
||||
return rows.isEmpty();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void clear() {
|
||||
rows.clear();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean sendBlock(CommandSender player) {
|
||||
return sendBlock(player, null, 0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean sendBlock(CommandSender player, String prefix) {
|
||||
return sendBlock(player, prefix, 0);
|
||||
}
|
||||
@@ -269,6 +277,7 @@ public class ChatBlock {
|
||||
return (int) maxWidth;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String centerInLine(String msg) {
|
||||
return centerInLineOf(msg, LINE_LENGTH);
|
||||
}
|
||||
@@ -513,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) {
|
||||
@@ -524,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) {
|
||||
@@ -531,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) {
|
||||
@@ -543,24 +553,27 @@ 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
|
||||
public static void sendMessageKey(@Nullable CommandSender receiver, @NotNull String key, @NotNull Object... args) {
|
||||
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) {
|
||||
@@ -573,10 +586,12 @@ public class ChatBlock {
|
||||
/**
|
||||
* Colors each line
|
||||
*/
|
||||
@Deprecated
|
||||
public static String[] say(String message) {
|
||||
return colorize(wordWrap(message));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String[] getColorizedMessage(String msg) {
|
||||
return colorize(wordWrap(msg));
|
||||
}
|
||||
@@ -589,11 +604,11 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static @Nullable String colorize(String message) {
|
||||
return colorizeBase(new String[]{message})[0];
|
||||
}
|
||||
|
||||
|
||||
private static @Nullable String[] colorizeBase(String[] message) {
|
||||
if (message != null && message[0] != null && !message[0].isEmpty()) {
|
||||
// Go through each line
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
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.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.CurrencyFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.DateFormat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
@@ -19,10 +28,12 @@ import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.EconomyResponse.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.Cause;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger.Operation.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -45,7 +56,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<>();
|
||||
@@ -68,7 +79,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
this.lastUsed = (new Date()).getTime();
|
||||
this.verified = verified;
|
||||
this.capeUrl = "";
|
||||
if (SimpleClans.getInstance().getSettingsManager().isClanFFOnByDefault()) {
|
||||
if (SimpleClans.getInstance().getSettingsManager().is(CLAN_FF_ON_BY_DEFAULT)) {
|
||||
friendlyFire = true;
|
||||
}
|
||||
}
|
||||
@@ -104,28 +115,35 @@ 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)) {
|
||||
player.sendMessage(ChatColor.AQUA + lang("player.clan.deposit", player, amount));
|
||||
addBb(player.getName(), ChatColor.AQUA + lang("bb.clan.deposit", amount));
|
||||
if (SimpleClans.getInstance().getPermissionsManager().chargePlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, CurrencyFormat.format(amount)));
|
||||
addBb(player.getName(), lang("bb.clan.deposit", CurrencyFormat.format(amount)));
|
||||
setBalance(getBalance() + amount);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + lang("not.sufficient.money", player));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, CurrencyFormat.format(amount)));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.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) {
|
||||
return EconomyResponse.NEGATIVE_VALUE;
|
||||
response = NEGATIVE_VALUE;
|
||||
}
|
||||
|
||||
return setBalance(sender, cause, getBalance() + amount);
|
||||
if (response == null) {
|
||||
response = setBalance(sender, cause, DEPOSIT, getBalance() + amount);
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(sender, this, response, DEPOSIT, cause, amount));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,29 +152,36 @@ 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)) {
|
||||
player.sendMessage(ChatColor.AQUA + lang("player.clan.withdraw", player, amount));
|
||||
addBb(player.getName(), ChatColor.AQUA + lang("bb.clan.withdraw", amount));
|
||||
if (SimpleClans.getInstance().getPermissionsManager().grantPlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, CurrencyFormat.format(amount)));
|
||||
addBb(player.getName(), lang("bb.clan.withdraw", CurrencyFormat.format(amount)));
|
||||
setBalance(getBalance() - amount);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + lang("clan.bank.not.enough.money", player));
|
||||
player.sendMessage(AQUA + lang("clan.bank.not.enough.money", player));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
return EconomyResponse.NEGATIVE_VALUE;
|
||||
response = NEGATIVE_VALUE;
|
||||
}
|
||||
|
||||
if (getBalance() >= amount) {
|
||||
return setBalance(sender, cause, getBalance() - amount);
|
||||
} else {
|
||||
return EconomyResponse.NOT_ENOUGH_BALANCE;
|
||||
if (getBalance() < amount) {
|
||||
response = NOT_ENOUGH_BALANCE;
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
response = setBalance(sender, cause, WITHDRAW, getBalance() - amount);
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(sender, this, response, WITHDRAW, cause, amount));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,27 +248,43 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clan's balance formatted
|
||||
*
|
||||
* @return the balance formatted
|
||||
*/
|
||||
@Placeholder("balance_formatted")
|
||||
public String getBalanceFormatted() {
|
||||
return CurrencyFormat.format(balance);
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param balance the balance to set
|
||||
*/
|
||||
public void setBalance(double balance) {
|
||||
setBalance(null, Cause.API, balance);
|
||||
private void setBalance(double balance) {
|
||||
setBalance(BankOperator.INTERNAL, Cause.INTERNAL, SET, balance);
|
||||
}
|
||||
|
||||
public EconomyResponse setBalance(@Nullable CommandSender updater, @NotNull Cause cause, double balance) {
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(updater, this, getBalance(), balance, cause);
|
||||
public EconomyResponse setBalance(@NotNull BankOperator operator, @NotNull Cause cause,
|
||||
@NotNull BankLogger.Operation operation, double balance) {
|
||||
EconomyResponse response = SUCCESS;
|
||||
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(operator, this, getBalance(), balance, cause);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return EconomyResponse.CANCELLED;
|
||||
response = CANCELLED;
|
||||
}
|
||||
|
||||
this.balance = event.getNewBalance();
|
||||
if (cause != Cause.LOADING) {
|
||||
if (operation == SET) {
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(operator, this, response, SET, cause, balance));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
return EconomyResponse.SUCCESS;
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +305,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
|
||||
*
|
||||
@@ -308,17 +348,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().getPurgeClan();
|
||||
int unverifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getPurgeUnverified();
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,17 +396,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")
|
||||
@@ -420,7 +465,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("founded")
|
||||
public String getFoundedString() {
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.founded));
|
||||
return DateFormat.formatDateTime(founded);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,12 +504,15 @@ 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
|
||||
*/
|
||||
public void addBbWithoutSaving(String msg) {
|
||||
while (bb.size() > SimpleClans.getInstance().getSettingsManager().getBbSize()) {
|
||||
while (bb.size() > SimpleClans.getInstance().getSettingsManager().getInt(BB_SIZE)) {
|
||||
bb.remove(0);
|
||||
}
|
||||
|
||||
@@ -493,23 +541,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -517,7 +558,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("size")
|
||||
public int getSize() {
|
||||
return this.members.size();
|
||||
return members.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -535,12 +576,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -563,7 +599,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("is_verified")
|
||||
public boolean isVerified() {
|
||||
return !SimpleClans.getInstance().getSettingsManager().isRequireVerification() || verified;
|
||||
return !SimpleClans.getInstance().getSettingsManager().is(REQUIRE_VERIFICATION) || verified;
|
||||
|
||||
}
|
||||
|
||||
@@ -611,7 +647,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedBb
|
||||
*/
|
||||
public String getPackedBb() {
|
||||
return Helper.toMessage(bb, "|");
|
||||
return String.join("|", bb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,7 +656,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedBb the packedBb to set
|
||||
*/
|
||||
public void setPackedBb(String packedBb) {
|
||||
this.bb = Helper.fromArray(packedBb.split("[|]"));
|
||||
bb = Helper.fromArrayToList(packedBb.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -629,7 +665,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedAllies
|
||||
*/
|
||||
public String getPackedAllies() {
|
||||
return Helper.toMessage(allies, "|");
|
||||
return String.join("|", allies);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,7 +674,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedAllies the packedAllies to set
|
||||
*/
|
||||
public void setPackedAllies(String packedAllies) {
|
||||
this.allies = Helper.fromArray(packedAllies.split("[|]"));
|
||||
allies = Helper.fromArrayToList(packedAllies.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -647,7 +683,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedRivals
|
||||
*/
|
||||
public String getPackedRivals() {
|
||||
return Helper.toMessage(rivals, "|");
|
||||
return String.join("|", rivals);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -656,61 +692,52 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedRivals the packedRivals to set
|
||||
*/
|
||||
public void setPackedRivals(String packedRivals) {
|
||||
this.rivals = Helper.fromArray(packedRivals.split("[|]"));
|
||||
rivals = Helper.fromArrayToList(packedRivals.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a separator delimited string with all the ally clan's colored
|
||||
* tags
|
||||
*/
|
||||
public String getAllyString(String sep, @Nullable CommandSender viewer) {
|
||||
String coloredAllies = getAllies().stream().
|
||||
map(allyTag -> SimpleClans.getInstance().getClanManager().getClan(allyTag)).
|
||||
filter(Objects::nonNull).
|
||||
map(Clan::getColorTag).
|
||||
collect(Collectors.joining(sep));
|
||||
|
||||
return coloredAllies.isEmpty() ? lang("none", viewer) : coloredAllies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Clan#getAllyString(String, CommandSender)}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getAllyString(String sep) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
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 ChatColor.BLACK + "None";
|
||||
}
|
||||
|
||||
return ChatUtils.parseColors(out.toString());
|
||||
return getAllyString(sep, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a separator delimited string with all the rival clan's colored
|
||||
* tags
|
||||
*/
|
||||
public String getRivalString(String sep, @Nullable CommandSender viewer) {
|
||||
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));
|
||||
|
||||
return coloredRivals.isEmpty() ? lang("none", viewer) : coloredRivals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Clan#getRivalString(String, CommandSender)}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getRivalString(String sep) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String rivalTag : getRivals()) {
|
||||
Clan rival = SimpleClans.getInstance().getClanManager().getClan(rivalTag);
|
||||
|
||||
if (rival != null) {
|
||||
if (isWarring(rivalTag)) {
|
||||
out.append(ChatColor.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 ChatColor.BLACK + "None";
|
||||
}
|
||||
|
||||
return ChatUtils.parseColors(out.toString());
|
||||
return getRivalString(sep, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -719,20 +746,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, ""));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,16 +786,10 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the fee payers
|
||||
*/
|
||||
public Set<ClanPlayer> getFeePayers() {
|
||||
Set<ClanPlayer> feePayers = new HashSet<>();
|
||||
|
||||
getNonLeaders().forEach(cp -> {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(cp.getUniqueId());
|
||||
if (!SimpleClans.getInstance().getPermissionsManager().has(null, op, "simpleclans.member.bypass-fee")) {
|
||||
feePayers.add(cp);
|
||||
}
|
||||
});
|
||||
|
||||
return feePayers;
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -789,19 +798,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -811,19 +808,7 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -833,20 +818,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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -855,22 +827,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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -909,16 +866,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();
|
||||
}
|
||||
@@ -941,12 +892,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();
|
||||
}
|
||||
|
||||
@@ -964,12 +910,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();
|
||||
}
|
||||
|
||||
@@ -1040,9 +981,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public boolean reachedRivalLimit() {
|
||||
int rivalCount = rivals.size();
|
||||
int clanCount = SimpleClans.getInstance().getClanManager().getRivableClanCount() - 1;
|
||||
int rivalPercent = SimpleClans.getInstance().getSettingsManager().getRivalLimitPercent();
|
||||
double rivalPercent = SimpleClans.getInstance().getSettingsManager().getPercent(RIVAL_LIMIT_PERCENT);
|
||||
|
||||
double limit = ((double) clanCount) * (((double) rivalPercent) / ((double) 100));
|
||||
double limit = ((double) clanCount) * (rivalPercent / ((double) 100));
|
||||
|
||||
return rivalCount > limit;
|
||||
}
|
||||
@@ -1054,7 +995,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
cp.removePastClan(getColorTag());
|
||||
cp.setClan(this);
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().isClanTrustByDefault());
|
||||
cp.setJoinDate(new Date().getTime());
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().is(CLAN_TRUST_MEMBERS_BY_DEFAULT));
|
||||
if (defaultRank != null) {
|
||||
cp.setRank(defaultRank);
|
||||
}
|
||||
@@ -1097,7 +1039,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPlayerPermissions(cp);
|
||||
|
||||
cp.setClan(null);
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? ChatColor.DARK_RED + "*" : ""));
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? DARK_RED + "*" : ""));
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(false);
|
||||
cp.setJoinDate(0);
|
||||
@@ -1174,7 +1116,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());
|
||||
@@ -1225,13 +1167,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("is_anyonline")
|
||||
public boolean isAnyOnline() {
|
||||
for (String member : members) {
|
||||
if (Helper.isOnline(UUID.fromString(member))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return members.stream().anyMatch(cp -> cp.toPlayer() != null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1244,7 +1180,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> online = getOnlineLeaders();
|
||||
online.remove(cp);
|
||||
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercentageOnlineToDemote();
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercent(CLAN_PERCENTAGE_ONLINE_TO_DEMOTE);
|
||||
// all leaders minus the one being demoted
|
||||
double totalLeaders = getLeaders().size() - 1;
|
||||
double onlineLeaders = online.size();
|
||||
@@ -1269,7 +1205,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
|
||||
for (ClanPlayer leader : leaders) {
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
if (leader.toPlayer() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1289,7 +1225,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Helper.isOnline(leader.getName())) {
|
||||
if (leader.toPlayer() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1308,7 +1244,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
if (leader.toPlayer() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1328,35 +1264,27 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Announce message to a whole clan
|
||||
*/
|
||||
public void clanAnnounce(String playerName, String msg) {
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getClanChatAnnouncementColor() + msg;
|
||||
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(ChatColor.AQUA + "[" + lang("clan.announce") + ChatColor.AQUA + "] " + ChatColor.AQUA + "[" + Helper.getColorName(playerName) + ChatColor.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().getClanChatAnnouncementColor() + msg;
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getColored(CLANCHAT_ANNOUNCEMENT_COLOR) + msg;
|
||||
|
||||
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(ChatColor.AQUA + "[" + lang("leader.announce") + ChatColor.AQUA + "] " + ChatColor.WHITE + message);
|
||||
Bukkit.getConsoleSender().sendMessage(AQUA + "[" + lang("leader.announce") + AQUA + "] " + WHITE + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1364,8 +1292,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
public void addBb(String announcerName, String msg) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getBbColor() + msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
addBb(msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_PREFIX) + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,8 +1302,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
public void addBb(String announcerName, String msg, boolean updateLastUsed) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getBbColor() + msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
addBb(msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_PREFIX) + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1392,31 +1320,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().getBbAccentColor();
|
||||
String pageHeadingsColor = SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor();
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", bbAccentColor, pageHeadingsColor, getName()));
|
||||
|
||||
List<String> localBb;
|
||||
if (maxSize == -1) {
|
||||
localBb = bb;
|
||||
maxSize = SimpleClans.getInstance().getSettingsManager().getBbSize();
|
||||
} 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().getBbColor();
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1432,16 +1364,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().getBbAccentColor();
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getBbColor();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1457,54 +1392,56 @@ 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().isDisableMessages() && sender != null) {
|
||||
this.clanAnnounce(sender.getName(), AQUA + lang("clan.has.been.disbanded", this.getName()));
|
||||
if (SimpleClans.getInstance().getSettingsManager().is(DISABLE_MESSAGES) && sender != null) {
|
||||
clanAnnounce(sender.getName(), AQUA + lang("clan.has.been.disbanded", getName()));
|
||||
} else {
|
||||
SimpleClans.getInstance().getClanManager().serverAnnounce(ChatColor.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() ? ChatColor.DARK_RED + "*" : ""));
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? DARK_RED + "*" : ""));
|
||||
}
|
||||
|
||||
cp.setLeader(false);
|
||||
}
|
||||
}
|
||||
|
||||
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, ChatColor.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, ChatColor.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, ChatColor.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);
|
||||
}
|
||||
@@ -1548,8 +1485,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
warring.add(targetClan.getTag());
|
||||
flags.put(WARRING_KEY, warring);
|
||||
if (requestPlayer != null) {
|
||||
this.addBb(requestPlayer.getName(), ChatColor.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);
|
||||
}
|
||||
@@ -1622,6 +1559,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);
|
||||
}
|
||||
@@ -1640,35 +1579,20 @@ 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) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
SettingsManager sm = SimpleClans.getInstance().getSettingsManager();
|
||||
String bracketColor = isLeader ? sm.getColored(TAG_BRACKET_LEADER_COLOR) : sm.getColored(TAG_BRACKET_COLOR);
|
||||
String bracketDefaultColor = sm.getColored(TAG_DEFAULT_COLOR);
|
||||
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);
|
||||
|
||||
if (isLeader) {
|
||||
return plugin.getSettingsManager().getTagBracketLeaderColor() +
|
||||
plugin.getSettingsManager().getTagBracketLeft() +
|
||||
plugin.getSettingsManager().getTagDefaultColor() +
|
||||
getColorTag() +
|
||||
plugin.getSettingsManager().getTagBracketLeaderColor() +
|
||||
plugin.getSettingsManager().getTagBracketRight() +
|
||||
plugin.getSettingsManager().getTagSeparatorLeaderColor() +
|
||||
plugin.getSettingsManager().getTagSeparator();
|
||||
} else {
|
||||
return plugin.getSettingsManager().getTagBracketColor() +
|
||||
plugin.getSettingsManager().getTagBracketLeft() +
|
||||
plugin.getSettingsManager().getTagDefaultColor() +
|
||||
getColorTag() +
|
||||
plugin.getSettingsManager().getTagBracketColor() +
|
||||
plugin.getSettingsManager().getTagBracketRight() +
|
||||
plugin.getSettingsManager().getTagSeparatorColor() +
|
||||
plugin.getSettingsManager().getTagSeparator();
|
||||
}
|
||||
return bracketColor + bracketLeft + bracketDefaultColor + getColorTag() + bracketColor + bracketRight + tagSeparatorColor + tagSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.Placeholder;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager.Action;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.DateFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -16,8 +18,10 @@ 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.*;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -35,7 +39,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);
|
||||
@@ -45,6 +49,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
private @Nullable Locale locale;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -64,17 +69,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
|
||||
@@ -89,12 +94,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
|
||||
@@ -137,7 +142,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.displayName = name;
|
||||
displayName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +228,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,11 +436,11 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
@Placeholder("weighted_kills")
|
||||
public double getWeightedKills() {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
double kills = ((double) getRivalKills() * plugin.getSettingsManager().getKwRival()) +
|
||||
((double) getNeutralKills() * plugin.getSettingsManager().getKwNeutral()) +
|
||||
((double) getAllyKills() * plugin.getSettingsManager().getKwAlly()) +
|
||||
((double) getCivilianKills() * plugin.getSettingsManager().getKwCivilian());
|
||||
SettingsManager settings = SimpleClans.getInstance().getSettingsManager();
|
||||
double kills = getRivalKills() * settings.getDouble(KILL_WEIGHTS_RIVAL) +
|
||||
getNeutralKills() * settings.getDouble(KILL_WEIGHTS_NEUTRAL) +
|
||||
getAllyKills() * settings.getDouble(KILL_WEIGHTS_ALLY) +
|
||||
getCivilianKills() * settings.getDouble(KILL_WEIGHTS_CIVILIAN);
|
||||
if (kills < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -483,8 +488,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
if (joinDate == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.joinDate));
|
||||
return DateFormat.formatDateTime(joinDate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,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 DateFormat.formatDateTime(lastSeen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,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.fromArray2(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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -579,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,9 +616,9 @@ 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().getRejoinCooldown();
|
||||
final int cooldown = SimpleClans.getInstance().getSettingsManager().getInt(REJOIN_COOLDOWN);
|
||||
resignTimes.forEach((k, v) -> {
|
||||
long timePassed = Instant.ofEpochMilli(v).until(Instant.now(), ChronoUnit.MINUTES);
|
||||
if (timePassed < cooldown) {
|
||||
@@ -661,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;
|
||||
@@ -739,7 +731,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
if (channelName != null) {
|
||||
return Channel.valueOf(channelName);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
return Channel.NONE;
|
||||
}
|
||||
|
||||
@@ -759,13 +752,16 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setGlobalChat(boolean globalChat) {}
|
||||
public void setGlobalChat(boolean globalChat) {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setAllyChat(boolean allyChat) {}
|
||||
public void setAllyChat(boolean allyChat) {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setClanChat(boolean clanChat) {}
|
||||
public void setClanChat(boolean clanChat) {
|
||||
}
|
||||
|
||||
public void setChannel(@NotNull Channel channel) {
|
||||
flags.put("channel", channel.toString());
|
||||
@@ -781,13 +777,24 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
}
|
||||
|
||||
@Placeholder("is_invite_enabled")
|
||||
public boolean isInviteEnabled() {
|
||||
return flags.getBoolean("invite", true);
|
||||
}
|
||||
|
||||
public void setInviteEnabled(boolean inviteEnabled) {
|
||||
flags.put("invite", inviteEnabled);
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isCapeEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setCapeEnabled(boolean capeEnabled) {}
|
||||
public void setCapeEnabled(boolean capeEnabled) {
|
||||
}
|
||||
|
||||
@Placeholder("is_tag_enabled")
|
||||
public boolean isTagEnabled() {
|
||||
@@ -798,7 +805,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
|
||||
@@ -817,6 +824,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", "");
|
||||
@@ -839,10 +851,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;
|
||||
}
|
||||
|
||||
@@ -858,10 +867,29 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
}
|
||||
|
||||
public void mute(Channel channel, boolean b) {
|
||||
switch (channel) {
|
||||
case CLAN:
|
||||
clanChatMute = b;
|
||||
break;
|
||||
case ALLY:
|
||||
allyChatMute = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ClanPlayer#mute(Channel, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMuted(boolean b) {
|
||||
clanChatMute = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ClanPlayer#mute(Channel, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMutedAlly(boolean b) {
|
||||
allyChatMute = b;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CommandHelper {
|
||||
|
||||
private CommandHelper() {
|
||||
}
|
||||
|
||||
public static void registerCommand(String... aliases) {
|
||||
if (aliases != null) {
|
||||
PluginCommand command = getCommand(aliases[0], SimpleClans.getInstance());
|
||||
|
||||
if (command != null) {
|
||||
command.setAliases(Arrays.asList(aliases));
|
||||
getCommandMap().register(SimpleClans.getInstance().getDescription().getName(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static PluginCommand getCommand(String name, Plugin plugin) {
|
||||
PluginCommand command = null;
|
||||
|
||||
try {
|
||||
Constructor<PluginCommand> c = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
|
||||
c.setAccessible(true);
|
||||
|
||||
command = c.newInstance(name, plugin);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
private static CommandMap getCommandMap() {
|
||||
CommandMap commandMap = null;
|
||||
|
||||
try {
|
||||
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
|
||||
Field f = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||
f.setAccessible(true);
|
||||
|
||||
commandMap = (CommandMap) f.get(Bukkit.getPluginManager());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return commandMap;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class DamageRecord {
|
||||
private String victim;
|
||||
private String attacker;
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* @param victim
|
||||
* @param attacker
|
||||
*/
|
||||
public DamageRecord(String victim, String attacker) {
|
||||
this.victim = victim;
|
||||
this.attacker = attacker;
|
||||
this.time = new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the victim
|
||||
*/
|
||||
public String getVictim() {
|
||||
return victim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param victim the victim to set
|
||||
*/
|
||||
public void setVictim(String victim) {
|
||||
this.victim = victim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attacker
|
||||
*/
|
||||
public String getAttacker() {
|
||||
return attacker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attacker the attacker to set
|
||||
*/
|
||||
public void setAttacker(String attacker) {
|
||||
this.attacker = attacker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time
|
||||
*/
|
||||
public Date getTime() {
|
||||
return new Date(time.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time the time to set
|
||||
*/
|
||||
public void setTime(Date time) {
|
||||
this.time = new Date(time.getTime());
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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),
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.REQUEST_MAX;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -18,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,
|
||||
@@ -178,6 +179,6 @@ public final class Request {
|
||||
}
|
||||
|
||||
public boolean reachedRequestLimit() {
|
||||
return askCount > SimpleClans.getInstance().getSettingsManager().getMaxAsksPerRequest();
|
||||
return askCount > SimpleClans.getInstance().getSettingsManager().getInt(REQUEST_MAX);
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,25 @@ 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;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.charts.SingleLineChart;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@@ -29,12 +37,16 @@ import java.util.logging.Level;
|
||||
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
|
||||
*/
|
||||
public class SimpleClans extends JavaPlugin {
|
||||
|
||||
private final ArrayList<String> messages = new ArrayList<>();
|
||||
|
||||
private static SimpleClans instance;
|
||||
private static LanguageResource languageResource;
|
||||
private static final Logger logger = Logger.getLogger("SimpleClans");
|
||||
@@ -46,9 +58,14 @@ public class SimpleClans extends JavaPlugin {
|
||||
private PermissionsManager permissionsManager;
|
||||
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
|
||||
*/
|
||||
@@ -58,7 +75,8 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static void debug(String msg) {
|
||||
if (getInstance().getSettingsManager().isDebugging()) {
|
||||
//instance may be null during tests
|
||||
if (getInstance() == null || getInstance().getSettingsManager().is(DEBUG)) {
|
||||
logger.log(Level.INFO, msg);
|
||||
}
|
||||
}
|
||||
@@ -83,21 +101,27 @@ public class SimpleClans extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new LanguageMigration(this).migrate();
|
||||
settingsManager = new SettingsManager();
|
||||
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();
|
||||
migrateChatFormat();
|
||||
chatManager = new ChatManager(this);
|
||||
registerEvents();
|
||||
permissionsManager.loadPermissions();
|
||||
commandManager = new SCCommandManager(this);
|
||||
bankLogger = new CSVBankLogger(this);
|
||||
|
||||
tagValidator = new TagValidator(settingsManager, permissionsManager);
|
||||
|
||||
logStatus();
|
||||
startTasks();
|
||||
@@ -107,83 +131,79 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void logStatus() {
|
||||
getLogger().info("Multithreading: " + SimpleClans.getInstance().getSettingsManager().getUseThreads());
|
||||
getLogger().info("BungeeCord: " + SimpleClans.getInstance().getSettingsManager().getUseBungeeCord());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private void startMetrics() {
|
||||
Metrics metrics = new Metrics(this, 7131);
|
||||
SettingsManager sm = getSettingsManager();
|
||||
ClanManager cm = getClanManager();
|
||||
String on = "enabled";
|
||||
String off = "disabled";
|
||||
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("clans", () -> cm.getClans().size()));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("clan_players", () -> cm.getAllClanPlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("language", () -> sm.getLanguage().toString()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("machine_language", () -> Locale.getDefault().toString()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("language_chooser", () -> sm.isLanguagePerPlayer() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("database", () -> sm.isUseMysql() ? "MySQL" : "SQLite"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("save_periodically", () -> sm.isSavePeriodically() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("save_interval", () -> String.valueOf(sm.getSaveInterval())));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("upkeep", () -> sm.isClanUpkeep() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("member_fee", () -> sm.isMemberFee() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("rejoin_cooldown", () -> sm.isRejoinCooldown() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("clan_verification", () -> sm.isRequireVerification() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("money_per_kill", () -> sm.isMoneyPerKill() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("threads", () -> sm.getUseThreads() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("bungeecord", () -> sm.getUseBungeeCord() ? on : off));
|
||||
Metrics metrics = new Metrics(this, 7131);
|
||||
SettingsManager sm = getSettingsManager();
|
||||
ClanManager cm = getClanManager();
|
||||
String on = "enabled";
|
||||
String off = "disabled";
|
||||
metrics.addCustomChart(new SingleLineChart("clans", () -> cm.getClans().size()));
|
||||
metrics.addCustomChart(new SingleLineChart("clan_players", () -> cm.getAllClanPlayers().size()));
|
||||
metrics.addCustomChart(new SimplePie("language", () -> sm.getLanguage().toString()));
|
||||
metrics.addCustomChart(new SimplePie("machine_language", () -> Locale.getDefault().toString()));
|
||||
metrics.addCustomChart(new SimplePie("language_chooser", () -> sm.is(LANGUAGE_SELECTOR) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("database", () -> sm.is(MYSQL_ENABLE) ? "MySQL" : "SQLite"));
|
||||
metrics.addCustomChart(new SimplePie("save_periodically", () -> sm.is(PERFORMANCE_SAVE_PERIODICALLY) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("save_interval", () -> sm.getString(PERFORMANCE_SAVE_INTERVAL)));
|
||||
metrics.addCustomChart(new SimplePie("upkeep", () -> sm.is(ECONOMY_UPKEEP_ENABLED) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("member_fee", () -> sm.is(ECONOMY_MEMBER_FEE_ENABLED) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("rejoin_cooldown", () -> sm.is(ENABLE_REJOIN_COOLDOWN) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("clan_verification", () -> sm.is(REQUIRE_VERIFICATION) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("money_per_kill", () -> sm.is(ECONOMY_MONEY_PER_KILL) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("threads", () -> sm.is(PERFORMANCE_USE_THREADS) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("bungeecord", () -> sm.is(PERFORMANCE_USE_BUNGEECORD) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("discord_chat", () -> sm.is(DISCORDCHAT_ENABLE) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("default_rank", () -> sm.getString(CLAN_DEFAULT_RANK).isEmpty() ? off : on));
|
||||
}
|
||||
|
||||
private void startTasks() {
|
||||
if (getSettingsManager().isSavePeriodically()) {
|
||||
new SaveDataTask().start();
|
||||
}
|
||||
if (getSettingsManager().isMemberFee()) {
|
||||
if (getSettingsManager().is(PERFORMANCE_SAVE_PERIODICALLY)) {
|
||||
new SaveDataTask().start();
|
||||
}
|
||||
if (getSettingsManager().is(ECONOMY_MEMBER_FEE_ENABLED)) {
|
||||
new CollectFeeTask().start();
|
||||
}
|
||||
if (getSettingsManager().isClanUpkeep()) {
|
||||
if (getSettingsManager().is(ECONOMY_UPKEEP_ENABLED)) {
|
||||
new CollectUpkeepTask().start();
|
||||
new UpkeepWarningTask().start();
|
||||
}
|
||||
if (getSettingsManager().isCachePlayerHeads()) {
|
||||
if (getSettingsManager().is(PERFORMANCE_HEAD_CACHING)) {
|
||||
new PlayerHeadCacheTask(this).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
if (getSettingsManager().isSavePeriodically()) {
|
||||
getStorageManager().saveModified();
|
||||
}
|
||||
if (getSettingsManager().is(PERFORMANCE_SAVE_PERIODICALLY)) {
|
||||
getStorageManager().saveModified();
|
||||
}
|
||||
getStorageManager().closeConnection();
|
||||
getPermissionsManager().savePermissions();
|
||||
getSettingsManager().loadAndSave();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,6 +250,18 @@ public class SimpleClans extends JavaPlugin {
|
||||
return protectionManager;
|
||||
}
|
||||
|
||||
public ChatManager getChatManager() {
|
||||
return chatManager;
|
||||
}
|
||||
|
||||
public ProxyManager getProxyManager() {
|
||||
return proxyManager;
|
||||
}
|
||||
|
||||
public BankLogger getBankLogger() {
|
||||
return bankLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the path within the language file
|
||||
* @return the lang
|
||||
@@ -245,13 +277,10 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
Locale locale = getInstance().getSettingsManager().getLanguage();
|
||||
if (player != null && instance.getSettingsManager().isLanguagePerPlayer()) {
|
||||
Locale playerLocale = Helper.getLocale(player);
|
||||
if (playerLocale != null) {
|
||||
locale = playerLocale;
|
||||
}
|
||||
public static String optionalLang(@NotNull String key, @Nullable ClanPlayer clanPlayer, Object... arguments) {
|
||||
Locale locale = instance.getSettingsManager().getLanguage();
|
||||
if (clanPlayer != null && clanPlayer.getLocale() != null && instance.getSettingsManager().is(LANGUAGE_SELECTOR)) {
|
||||
locale = clanPlayer.getLocale();
|
||||
}
|
||||
|
||||
String lang = languageResource.getLang(key, locale);
|
||||
@@ -266,13 +295,25 @@ public class SimpleClans extends JavaPlugin {
|
||||
return MessageFormat.format(message, arguments);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
ClanPlayer clanPlayer = null;
|
||||
if (player != null) {
|
||||
clanPlayer = instance.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
}
|
||||
return optionalLang(key, clanPlayer, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
String lang = optionalLang(key, player, arguments);
|
||||
if (lang == null) {
|
||||
return key;
|
||||
}
|
||||
return lang;
|
||||
return (lang == null) ? key : lang;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable ClanPlayer clanPlayer, Object... arguments) {
|
||||
String lang = optionalLang(key, clanPlayer, arguments);
|
||||
return (lang == null) ? key : lang;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -311,7 +352,12 @@ public class SimpleClans extends JavaPlugin {
|
||||
return this.hasUUID;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
}
|
||||
|
||||
public TagValidator getTagValidator() {
|
||||
return tagValidator;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +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;
|
||||
|
||||
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().getWaitSecs();
|
||||
this.playerUniqueId = player.getUniqueId();
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation() {
|
||||
return this.playerLocation;
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public boolean isTeleportTime() {
|
||||
@@ -42,7 +43,7 @@ public class TeleportState {
|
||||
* @return the player
|
||||
*/
|
||||
public @Nullable Player getPlayer() {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerUniqueId);
|
||||
return offlinePlayer.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +75,4 @@ public class TeleportState {
|
||||
this.processing = processing;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return this.playerUniqueId;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,9 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
/**
|
||||
* Possible vote values
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author cc_madelg
|
||||
*/
|
||||
public enum VoteResult
|
||||
{
|
||||
public enum VoteResult {
|
||||
ACCEPT, DENY
|
||||
}
|
||||
@@ -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<>();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
|
||||
boolean canHandle(SCMessage.Source source);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SCMessage implements Cloneable {
|
||||
|
||||
private final Source source;
|
||||
private final ClanPlayer.Channel channel;
|
||||
private final ClanPlayer sender;
|
||||
private List<ClanPlayer> receivers;
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* Creates a message with initial parameters
|
||||
*
|
||||
* @param source The source of message
|
||||
* @param channel The channel of clan player
|
||||
* @param sender The clan player sender
|
||||
* @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) {
|
||||
this.source = source;
|
||||
this.channel = channel;
|
||||
this.sender = sender;
|
||||
this.content = content;
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SCMessage without receivers
|
||||
*
|
||||
* @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<>());
|
||||
}
|
||||
|
||||
public ClanPlayer.Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public ClanPlayer getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public List<ClanPlayer> getReceivers() {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void setContent(@NotNull String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setReceivers(@NotNull List<ClanPlayer> receivers) {
|
||||
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.
|
||||
*
|
||||
* @see ChatHandler initiate the handler
|
||||
*/
|
||||
public enum Source {
|
||||
SPIGOT, DISCORD, PROXY
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel;
|
||||
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.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;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_FORMAT_TO;
|
||||
|
||||
/**
|
||||
* Handles delivering messages from {@link Source#SPIGOT} to {@link Source#DISCORD}.
|
||||
*/
|
||||
public class DiscordChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull SCMessage message) {
|
||||
if (message.getChannel() != CLAN) {
|
||||
return;
|
||||
}
|
||||
|
||||
String format = settingsManager.getString(DISCORDCHAT_FORMAT_TO);
|
||||
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.getCachedChannel(clan.getTag());
|
||||
channel.ifPresent(textChannel -> DiscordUtil.sendMessage(textChannel, formattedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
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.events.ChatEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
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.PERFORMANCE_USE_BUNGEECORD;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SpigotChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
/*
|
||||
TODO: Make it async, change Type to Channel in 3.0
|
||||
*/
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatEvent event = new ChatEvent(message.getContent(), message.getSender(), message.getReceivers(),
|
||||
ChatEvent.Type.valueOf(message.getChannel().name()));
|
||||
|
||||
getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
message.setContent(stripColorsAndFormatsPerPermission(message.getSender(),event.getMessage()));
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
|
||||
String format = settingsManager.getString(configField);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message, event.getPlaceholders());
|
||||
|
||||
plugin.getLogger().info(ChatUtils.stripColors(formattedMessage));
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
}
|
||||
}
|
||||
}.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 == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|| (source == DISCORD && chatManager.isDiscordHookEnabled());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
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.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
|
||||
/**
|
||||
* 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 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> onlineSpies = getOnlineSpies();
|
||||
|
||||
// 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 == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|| (source == DISCORD && chatManager.isDiscordHookEnabled());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
+50
-35
@@ -6,6 +6,8 @@ import co.aikar.commands.CommandIssuer;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import co.aikar.locales.MessageKey;
|
||||
import co.aikar.locales.MessageKeyProvider;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.completions.AbstractAsyncCompletion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.completions.AbstractCompletion;
|
||||
@@ -22,7 +24,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
@@ -32,25 +33,28 @@ import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.optionalLang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
public class SCCommandManager extends PaperCommandManager {
|
||||
private final SimpleClans plugin;
|
||||
private static final List<String> SUBCOMMANDS;
|
||||
private static final List<String> COMPLETIONS;
|
||||
|
||||
public SCCommandManager(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
configure();
|
||||
}
|
||||
|
||||
|
||||
private void configure() {
|
||||
registerDependencies();
|
||||
enableUnstableAPI("help");
|
||||
addCommandReplacements();
|
||||
registerDependencies();
|
||||
addReplacements();
|
||||
registerContexts();
|
||||
registerCommands();
|
||||
registerConditions();
|
||||
registerCompletions();
|
||||
defaultHelpPerPage = plugin.getSettingsManager().getInt(HELP_SIZE);
|
||||
}
|
||||
|
||||
private void registerDependencies() {
|
||||
@@ -60,11 +64,13 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
registerDependency(PermissionsManager.class, plugin.getPermissionsManager());
|
||||
registerDependency(RequestManager.class, plugin.getRequestManager());
|
||||
registerDependency(ProtectionManager.class, plugin.getProtectionManager());
|
||||
registerDependency(ChatManager.class, plugin.getChatManager());
|
||||
}
|
||||
|
||||
private void registerCompletions() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.completions");
|
||||
Set<Class<? extends AbstractCompletion>> completions = reflections.getSubTypesOf(AbstractCompletion.class);
|
||||
Set<Class<? extends AbstractCompletion>> completions =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands.completions",
|
||||
AbstractCompletion.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command completions...", completions.size()));
|
||||
for (Class<? extends AbstractCompletion> c : completions) {
|
||||
if (Modifier.isAbstract(c.getModifiers())) {
|
||||
@@ -90,8 +96,9 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void registerConditions() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.conditions");
|
||||
Set<Class<? extends AbstractCondition>> conditions = reflections.getSubTypesOf(AbstractCondition.class);
|
||||
Set<Class<? extends AbstractCondition>> conditions =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands.conditions",
|
||||
AbstractCondition.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command conditions...", conditions.size()));
|
||||
for (Class<? extends AbstractCondition> c : conditions) {
|
||||
if (Modifier.isAbstract(c.getModifiers())) {
|
||||
@@ -101,11 +108,11 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
AbstractCondition obj = c.getConstructor(SimpleClans.class).newInstance(plugin);
|
||||
if (obj instanceof AbstractParameterCondition) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
AbstractParameterCondition condition = (AbstractParameterCondition) obj;
|
||||
AbstractParameterCondition condition = ((AbstractParameterCondition<?>) obj);
|
||||
getCommandConditions().addCondition(condition.getType(), condition.getId(), condition);
|
||||
}
|
||||
if (obj instanceof AbstractCommandCondition) {
|
||||
AbstractCommandCondition condition = (AbstractCommandCondition) obj;
|
||||
AbstractCommandCondition condition = ((AbstractCommandCondition) obj);
|
||||
getCommandConditions().addCondition(condition.getId(), condition);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@@ -116,8 +123,9 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private void registerContexts() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.contexts");
|
||||
Set<Class<? extends AbstractContextResolver>> resolvers = reflections.getSubTypesOf(AbstractContextResolver.class);
|
||||
Set<Class<? extends AbstractContextResolver>> resolvers =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands.contexts",
|
||||
AbstractContextResolver.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command contexts...", resolvers.size()));
|
||||
for (Class<? extends AbstractContextResolver> cr : resolvers) {
|
||||
if (Modifier.isAbstract(cr.getModifiers())) {
|
||||
@@ -138,9 +146,8 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
boolean forceCommandPriority = plugin.getSettingsManager().isForceCommandPriority();
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands");
|
||||
Set<Class<? extends BaseCommand>> commands = reflections.getSubTypesOf(BaseCommand.class);
|
||||
boolean forceCommandPriority = plugin.getSettingsManager().is(COMMANDS_FORCE_PRIORITY);
|
||||
Set<Class<? extends BaseCommand>> commands = Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands", BaseCommand.class);
|
||||
plugin.getLogger().info(String.format("Registering %d base commands...", commands.size()));
|
||||
for (Class<? extends BaseCommand> c : commands) {
|
||||
//ACF already registers nested classes
|
||||
@@ -156,29 +163,22 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void addCommandReplacements() {
|
||||
private void addReplacements() {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
getCommandReplacements().addReplacements(
|
||||
"basic_conditions", "not_blacklisted|not_banned",
|
||||
"clan", sm.getCommandClan(),
|
||||
"deny", sm.getCommandDeny() + "|deny",
|
||||
"more", sm.getCommandMore(),
|
||||
"ally_chat", sm.getCommandAlly(),
|
||||
"accept", sm.getCommandAccept() + "|accept",
|
||||
"clan_chat", sm.getCommandClanChat()
|
||||
"clan", sm.getString(COMMANDS_CLAN),
|
||||
"deny", sm.getString(COMMANDS_DENY) + "|deny",
|
||||
"more", sm.getString(COMMANDS_MORE),
|
||||
"ally_chat", sm.getString(COMMANDS_ALLY),
|
||||
"accept", sm.getString(COMMANDS_ACCEPT) + "|accept",
|
||||
"clan_chat", sm.getString(COMMANDS_CLAN_CHAT)
|
||||
);
|
||||
|
||||
SUBCOMMANDS.forEach(s -> {
|
||||
String command = optionalLang(s + ".command", null);
|
||||
if (command == null) {
|
||||
command = s;
|
||||
}
|
||||
command = command.replace(" ", "");
|
||||
String replacement = command.equals(s) ? s : command + "|" + s;
|
||||
getCommandReplacements().addReplacement(s, replacement);
|
||||
});
|
||||
SUBCOMMANDS.forEach(s -> processReplacement(s, "", ".command", true));
|
||||
COMPLETIONS.forEach(s -> processReplacement(s, "compl:", ".completion", false));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BukkitLocales getLocales() {
|
||||
if (this.locales == null) {
|
||||
@@ -206,19 +206,34 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
};
|
||||
//this.locales.loadLanguages();
|
||||
}
|
||||
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
private void processReplacement(String key, String prefix, String suffix, boolean hasFallback) {
|
||||
String replacement = optionalLang(key + suffix, (ClanPlayer) null);
|
||||
if (replacement == null) {
|
||||
replacement = key;
|
||||
}
|
||||
|
||||
replacement = replacement.replace(" ", "");
|
||||
if (hasFallback) {
|
||||
replacement = replacement + "|" + key;
|
||||
}
|
||||
|
||||
getCommandReplacements().addReplacement(prefix + key, replacement);
|
||||
}
|
||||
|
||||
static {
|
||||
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");
|
||||
"container", "permanent", "take", "give", "join", "leave", "mute", "confirm", "balance", "discord", "rename", "locale");
|
||||
|
||||
COMPLETIONS = Arrays.asList("tag", "name");
|
||||
}
|
||||
}
|
||||
+48
-10
@@ -2,29 +2,67 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
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 org.bukkit.entity.Player;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.ALLY;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.NONE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
|
||||
@CommandAlias("%ally_chat")
|
||||
@Description("{@@command.description.ally}")
|
||||
@CommandPermission("simpleclans.member.ally")
|
||||
@Conditions("%basic_conditions|clan_member|rank:name=ALLY_CHAT")
|
||||
@Conditions("%basic_conditions|clan_member|can_chat:type=ALLY|rank:name=ALLY_CHAT")
|
||||
public class AllyChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ClanManager clanManager;
|
||||
private ChatManager chatManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
@Dependency
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, @Name("message") String message) {
|
||||
if (!settingsManager.isAllyChatEnable()) {
|
||||
return;
|
||||
}
|
||||
clanManager.processAllyChat(player, message);
|
||||
public void sendMessage(ClanPlayer cp, @Name("message") String message) {
|
||||
chatManager.processChat(SPIGOT, ALLY, cp, message);
|
||||
}
|
||||
|
||||
@Subcommand("%join")
|
||||
public void join(ClanPlayer clanPlayer) {
|
||||
if (clanPlayer.getChannel() == ALLY) {
|
||||
ChatBlock.sendMessage(clanPlayer, lang("already.joined.ally.chat"));
|
||||
return;
|
||||
}
|
||||
|
||||
clanPlayer.setChannel(ALLY);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("joined.ally.chat"));
|
||||
}
|
||||
|
||||
@Subcommand("%leave")
|
||||
public void leave(ClanPlayer clanPlayer) {
|
||||
if (clanPlayer.getChannel() == ALLY) {
|
||||
clanPlayer.setChannel(NONE);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("left.ally.chat", clanPlayer));
|
||||
} else {
|
||||
ChatBlock.sendMessage(clanPlayer, lang("chat.didnt.join", clanPlayer));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%mute")
|
||||
public void mute(ClanPlayer clanPlayer) {
|
||||
if (!clanPlayer.isMutedAlly()) {
|
||||
clanPlayer.mute(ALLY, true);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("muted.ally.chat", clanPlayer));
|
||||
} else {
|
||||
clanPlayer.mute(ALLY, false);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("unmuted.ally.chat", clanPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
+35
-17
@@ -5,15 +5,18 @@ import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.EconomyResponse;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
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 net.sacredlabyrinth.phaed.simpleclans.utils.CurrencyFormat;
|
||||
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;
|
||||
|
||||
@@ -29,7 +32,7 @@ public class BankCommand extends BaseCommand {
|
||||
@Conditions("rank:name=BANK_BALANCE")
|
||||
@Description("{@@command.description.bank.status}")
|
||||
public void bankStatus(Player player, Clan clan) {
|
||||
player.sendMessage(AQUA + lang("clan.balance", player, clan.getBalance()));
|
||||
player.sendMessage(AQUA + lang("clan.balance", player, clan.getBalanceFormatted()));
|
||||
}
|
||||
|
||||
@Subcommand("%withdraw %all")
|
||||
@@ -48,7 +51,6 @@ public class BankCommand extends BaseCommand {
|
||||
processWithdraw(player, clan, amount);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void processWithdraw(Player player, Clan clan, double amount) {
|
||||
if (!clan.isAllowWithdraw()) {
|
||||
String message = getCurrentCommandManager().getCommandReplacements()
|
||||
@@ -57,24 +59,32 @@ public class BankCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
amount = Math.abs(amount);
|
||||
/*
|
||||
TODO: Remove at SimpleClans 3.0
|
||||
*/
|
||||
BankWithdrawEvent event = new BankWithdrawEvent(player, clan, amount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clan.withdraw(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount)) {
|
||||
/*
|
||||
* ——————————————————————————————————
|
||||
*/
|
||||
BankOperator operator = new BankOperator(player, permissions.playerGetMoney(player));
|
||||
switch (clan.withdraw(operator, COMMAND, amount)) {
|
||||
case SUCCESS:
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerGrantMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
if (permissions.grantPlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, CurrencyFormat.format(amount)));
|
||||
clan.addBb(player.getName(), lang("bb.clan.withdraw", CurrencyFormat.format(amount), player.getName()));
|
||||
} else {
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, 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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +104,6 @@ public class BankCommand extends BaseCommand {
|
||||
processDeposit(player, clan, amount);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void processDeposit(Player player, Clan clan, double amount) {
|
||||
if (!clan.isAllowDeposit()) {
|
||||
String message = getCurrentCommandManager().getCommandReplacements()
|
||||
@@ -103,23 +112,32 @@ public class BankCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
amount = Math.abs(amount);
|
||||
|
||||
/*
|
||||
TODO: Remove at SimpleClans 3.0
|
||||
*/
|
||||
BankDepositEvent event = new BankDepositEvent(player, clan, amount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* ——————————————————————————————————
|
||||
*/
|
||||
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, CurrencyFormat.format(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)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount));
|
||||
if (permissions.chargePlayer(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, CurrencyFormat.format(amount)));
|
||||
clan.addBb(player.getName(), lang("bb.clan.deposit", CurrencyFormat.format(amount), player.getName()));
|
||||
} else {
|
||||
//Reverts the deposit if something went wrong with Vault
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, 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);
|
||||
}
|
||||
}
|
||||
+45
-10
@@ -2,29 +2,64 @@ 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.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.NONE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
|
||||
@CommandAlias("%clan_chat")
|
||||
@Conditions("%basic_conditions|clan_member")
|
||||
@Conditions("%basic_conditions|clan_member|can_chat:type=CLAN")
|
||||
@CommandPermission("simpleclans.member.chat")
|
||||
@Description("{@@command.description.chat}")
|
||||
public class ChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ClanManager clanManager;
|
||||
private ChatManager chatManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, ClanPlayer cp, @Name("message") String message) {
|
||||
if (!settingsManager.getClanChatEnable()) {
|
||||
public void sendMessage(ClanPlayer cp, @Name("message") String message) {
|
||||
chatManager.processChat(SPIGOT, CLAN, cp, message);
|
||||
}
|
||||
|
||||
@Subcommand("%join")
|
||||
public void join(ClanPlayer clanPlayer) {
|
||||
if (clanPlayer.getChannel() == CLAN) {
|
||||
ChatBlock.sendMessage(clanPlayer, lang("already.joined.clan.chat"));
|
||||
return;
|
||||
}
|
||||
clanManager.processClanChat(player, cp.getTag(), message);
|
||||
|
||||
clanPlayer.setChannel(CLAN);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("joined.clan.chat"));
|
||||
}
|
||||
|
||||
@Subcommand("%leave")
|
||||
public void leave(ClanPlayer clanPlayer) {
|
||||
if (clanPlayer.getChannel() == CLAN) {
|
||||
clanPlayer.setChannel(NONE);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("left.clan.chat", clanPlayer));
|
||||
} else {
|
||||
ChatBlock.sendMessage(clanPlayer, lang("chat.didnt.join", clanPlayer));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%mute")
|
||||
public void mute(ClanPlayer clanPlayer) {
|
||||
if (!clanPlayer.isMuted()) {
|
||||
clanPlayer.mute(CLAN, true);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("muted.clan.chat", clanPlayer));
|
||||
} else {
|
||||
clanPlayer.mute(CLAN, false);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("unmuted.clan.chat", clanPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
+57
-34
@@ -6,18 +6,20 @@ import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.ResignPrompt;
|
||||
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.conversations.ConversationFactory;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.CurrencyFormat;
|
||||
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.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@@ -49,7 +51,7 @@ public class ClanCommands extends BaseCommand {
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(requestClan.getLeaders());
|
||||
|
||||
if (settings.isWarRequestEnabled()) {
|
||||
if (settings.is(WAR_START_REQUEST_ENABLED)) {
|
||||
if (!onlineLeaders.isEmpty()) {
|
||||
requestManager.addWarStartRequest(requester, targetClan, requestClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.have.been.asked.to.accept.the.war.request",
|
||||
@@ -67,13 +69,13 @@ public class ClanCommands extends BaseCommand {
|
||||
@Conditions("verified|rank:name=WAR_END")
|
||||
@Description("{@@command.description.war.end}")
|
||||
@CommandCompletion("@warring_clans")
|
||||
public void endWar(Player player, ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
public void endWar(ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
Clan war = other.getClan();
|
||||
if (issuerClan.isWarring(war.getTag())) {
|
||||
requestManager.addWarEndRequest(cp, war, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.asked.to.end.rivalry", player, war.getName()));
|
||||
ChatBlock.sendMessage(cp, AQUA + lang("leaders.asked.to.end.rivalry", cp, war.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("clans.not.at.war", player));
|
||||
ChatBlock.sendMessage(cp, RED + lang("clans.not.at.war", cp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +92,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;
|
||||
}
|
||||
|
||||
@@ -102,7 +104,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);
|
||||
}
|
||||
@@ -131,6 +133,10 @@ 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()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("invitedplayer.invite.off", sender));
|
||||
return;
|
||||
}
|
||||
Player invitedPlayer = invited.getClanPlayer().toPlayer();
|
||||
if (invitedPlayer == null) return;
|
||||
if (!permissions.has(invitedPlayer, "simpleclans.member.can-join")) {
|
||||
@@ -149,7 +155,7 @@ public class ClanCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getSize() >= settings.getMaxMembers()) {
|
||||
if (clan.getSize() >= settings.getInt(CLAN_MAX_MEMBERS) && settings.getInt(CLAN_MAX_MEMBERS) > 0) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.clan.members.reached.limit", sender));
|
||||
return;
|
||||
}
|
||||
@@ -180,15 +186,15 @@ public class ClanCommands extends BaseCommand {
|
||||
@Description("{@@command.description.fee.set}")
|
||||
public void setFee(Player player, Clan clan, @Name("fee") double fee) {
|
||||
fee = Math.abs(fee);
|
||||
double maxFee = settings.getMaxMemberFee();
|
||||
double maxFee = settings.getDouble(ECONOMY_MAX_MEMBER_FEE);
|
||||
if (fee > maxFee) {
|
||||
ChatBlock.sendMessage(player, RED
|
||||
+ lang("max.fee.allowed.is.0", player, maxFee));
|
||||
+ lang("max.fee.allowed.is.0", player, CurrencyFormat.format(maxFee)));
|
||||
return;
|
||||
}
|
||||
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", CurrencyFormat.format(fee)));
|
||||
ChatBlock.sendMessage(player, AQUA + lang("fee.set", player));
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
@@ -199,7 +205,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);
|
||||
}
|
||||
@@ -208,7 +214,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);
|
||||
}
|
||||
@@ -218,14 +224,14 @@ public class ClanCommands extends BaseCommand {
|
||||
@Conditions("verified|rank:name=DESCRIPTION")
|
||||
@Description("{@@command.description.description}")
|
||||
public void setDescription(Player player, Clan clan, @Name("description") String description) {
|
||||
if (description.length() < settings.getClanMinDescriptionLength()) {
|
||||
if (description.length() < settings.getInt(CLAN_MIN_DESCRIPTION_LENGTH)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.must.be.longer.than",
|
||||
player, settings.getClanMinDescriptionLength()));
|
||||
player, settings.getInt(CLAN_MIN_DESCRIPTION_LENGTH)));
|
||||
return;
|
||||
}
|
||||
if (description.length() > settings.getClanMaxDescriptionLength()) {
|
||||
if (description.length() > settings.getInt(CLAN_MAX_DESCRIPTION_LENGTH)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.cannot.be.longer.than",
|
||||
player, settings.getClanMaxDescriptionLength()));
|
||||
player, settings.getInt(CLAN_MAX_DESCRIPTION_LENGTH)));
|
||||
return;
|
||||
}
|
||||
clan.setDescription(description);
|
||||
@@ -236,7 +242,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();
|
||||
@@ -247,9 +253,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));
|
||||
@@ -281,7 +287,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,
|
||||
@@ -292,7 +298,7 @@ public class ClanCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.allies", player));
|
||||
return;
|
||||
}
|
||||
int maxAlliances = settings.getClanMaxAlliances();
|
||||
int maxAlliances = settings.getInt(CLAN_MAX_ALLIANCES);
|
||||
if (maxAlliances != -1) {
|
||||
if (issuerClan.getAllies().size() >= maxAlliances) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.reached.max.alliances", player));
|
||||
@@ -324,15 +330,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,
|
||||
@@ -349,19 +355,36 @@ 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());
|
||||
}
|
||||
|
||||
@Subcommand("%resign %confirm")
|
||||
@CommandPermission("simpleclans.member.resign")
|
||||
@Description("{@@command.description.resign}")
|
||||
@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(), lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
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()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(cp, RED +
|
||||
lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%resign")
|
||||
@CommandPermission("simpleclans.member.resign")
|
||||
@Description("{@@command.description.resign}")
|
||||
@HelpSearchTags("leave")
|
||||
public void resign(@Conditions("clan_member") Player player) {
|
||||
new ConversationFactory(plugin)
|
||||
.withFirstPrompt(new ResignPrompt())
|
||||
.withLocalEcho(true)
|
||||
.withTimeout(10)
|
||||
.buildConversation(player).begin();
|
||||
new SCConversation(plugin, player, new ResignPrompt()).begin();
|
||||
}
|
||||
}
|
||||
+19
-20
@@ -4,16 +4,19 @@ 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;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@@ -35,7 +38,7 @@ public class HomeCommands extends BaseCommand {
|
||||
@Conditions("rank:name=REGROUP_ME")
|
||||
@Description("{@@command.description.regroup.me}")
|
||||
public void regroupMe(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
if (!settings.is(ALLOW_REGROUP)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
@@ -58,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) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -76,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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,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) {
|
||||
if (settings.isHomebaseSetOnce() && clan.getHomeLocation() != null &&
|
||||
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));
|
||||
}
|
||||
@@ -109,12 +108,12 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.home-set")
|
||||
@Description("{@@command.description.home.set}")
|
||||
public void set(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (settings.isHomebaseSetOnce() && clan.getHomeLocation() != null &&
|
||||
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;
|
||||
}
|
||||
if (settings.isSetBaseOnlyInLand()) {
|
||||
if (settings.is(LAND_SET_BASE_ONLY_IN_LAND)) {
|
||||
if (!protection.isOwner(player, player.getLocation())) {
|
||||
ChatBlock.sendMessageKey(player, "you.can.only.set.base.in.your.land");
|
||||
return;
|
||||
|
||||
@@ -14,9 +14,11 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.LAND_EDIT_ALL_LANDS;
|
||||
|
||||
@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 {
|
||||
|
||||
@@ -27,7 +29,7 @@ public class LandCommand extends BaseCommand {
|
||||
|
||||
private Set<Land> getLands(ClanPlayer cp, Location location) {
|
||||
Player player = Objects.requireNonNull(cp.toPlayer());
|
||||
if (settings.isEditAllLands()) {
|
||||
if (settings.is(LAND_EDIT_ALL_LANDS)) {
|
||||
return protection.getLands(player, location);
|
||||
} else {
|
||||
return protection.getLandsAt(location).stream().filter(l -> l.getOwners().contains(player.getUniqueId()))
|
||||
@@ -47,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+101
-16
@@ -2,17 +2,23 @@ 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 net.sacredlabyrinth.phaed.simpleclans.utils.CurrencyFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
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;
|
||||
|
||||
@@ -20,6 +26,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
|
||||
@@ -30,6 +38,8 @@ public class LeaderCommands extends BaseCommand {
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
|
||||
@Subcommand("%demote")
|
||||
@CommandCompletion("@clan_leaders")
|
||||
@@ -48,13 +58,13 @@ public class LeaderCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + lang("player.is.not.a.leader.of.your.clan", player));
|
||||
return;
|
||||
}
|
||||
if (clan.getLeaders().size() > 2 && settings.isConfirmationForDemote()) {
|
||||
if (clan.getLeaders().size() > 2 && settings.is(CLAN_CONFIRMATION_FOR_DEMOTE)) {
|
||||
requestManager.addDemoteRequest(cp, otherCp.getName(), clan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("demotion.vote.has.been.requested.from.all.leaders",
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -80,14 +90,15 @@ public class LeaderCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + lang("the.player.is.already.a.leader", player));
|
||||
return;
|
||||
}
|
||||
if (settings.isConfirmationForPromote() && clan.getLeaders().size() > 1) {
|
||||
requestManager.addPromoteRequest(cp, otherPl.getName(), clan);
|
||||
if (settings.is(CLAN_CONFIRMATION_FOR_PROMOTE) && clan.getLeaders().size() > 1) {
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.PROMOTE, otherPl.getName(), "asking.for.the.promotion",
|
||||
player.getName(), 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());
|
||||
}
|
||||
|
||||
@@ -96,13 +107,14 @@ 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",
|
||||
player.getName());
|
||||
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")
|
||||
@@ -113,18 +125,18 @@ public class LeaderCommands extends BaseCommand {
|
||||
ChatBlock.sendMessageKey(player, "your.clan.already.verified");
|
||||
return;
|
||||
}
|
||||
if (!settings.isePurchaseVerification()) {
|
||||
if (!settings.is(ECONOMY_PURCHASE_CLAN_VERIFY)) {
|
||||
ChatBlock.sendMessageKey(player, "staff.member.verify.clan");
|
||||
return;
|
||||
}
|
||||
int minToVerify = settings.getMinToVerify();
|
||||
if (minToVerify > clan.getAllMembers().size()) {
|
||||
int minToVerify = settings.getInt(CLAN_MIN_TO_VERIFY);
|
||||
if (minToVerify > clan.getMembers().size()) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.must.have.members.to.verify", player, minToVerify));
|
||||
return;
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -147,7 +159,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);
|
||||
@@ -172,9 +184,82 @@ 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(Player player, ClanPlayer cp, Clan clan, @Name("name") String clanName) {
|
||||
if (clanName.contains("&")) {
|
||||
ChatBlock.sendMessageKey(cp, "your.clan.name.cannot.contain.color.codes");
|
||||
return;
|
||||
}
|
||||
boolean bypass = plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass");
|
||||
if (!bypass) {
|
||||
if (ChatUtils.stripColors(clanName).length() > plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.name.cannot.be.longer.than.characters",
|
||||
player, plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)));
|
||||
return;
|
||||
}
|
||||
if (ChatUtils.stripColors(clanName).length() <= plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.name.must.be.longer.than.characters",
|
||||
player, plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
requestManager.requestAllLeaders(cp, ClanRequest.RENAME, clanName, "asking.to.rename", cp.getName(), 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, CurrencyFormat.format(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.CreateRankNamePrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.RequestCanceller;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.SCConversation;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.DeleteRankEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerRankUpdateEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
@@ -12,8 +14,6 @@ import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -82,8 +82,8 @@ public class RankCommand extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.rank.create")
|
||||
@Description("{@@command.description.rank.create}")
|
||||
public void create(Player player, Clan clan) {
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateRankNamePrompt())
|
||||
.withLocalEcho(true).withTimeout(60).buildConversation(player);
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateRankNamePrompt(), 60);
|
||||
conversation.addConversationCanceller(new RequestCanceller(player, RED + lang("rank.create.request.cancelled", player)));
|
||||
conversation.getContext().setSessionData("clan", clan);
|
||||
conversation.begin();
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
+54
-47
@@ -16,61 +16,68 @@ import static org.bukkit.ChatColor.AQUA;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%toggle")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
@Conditions("%basic_conditions")
|
||||
public class ToggleCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
|
||||
@Subcommand("%bb")
|
||||
@CommandPermission("simpleclans.member.bb-toggle")
|
||||
@Description("{@@command.description.toggle.bb}")
|
||||
public void bb(Player player, ClanPlayer cp) {
|
||||
toggle(player, "bbon", "bboff", cp.isBbEnabled(), cp::setBbEnabled);
|
||||
@Conditions("verified")
|
||||
public class Verified extends BaseCommand {
|
||||
|
||||
@Subcommand("%bb")
|
||||
@CommandPermission("simpleclans.member.bb-toggle")
|
||||
@Description("{@@command.description.toggle.bb}")
|
||||
public void bb(Player player, ClanPlayer cp) {
|
||||
toggle(player, "bbon", "bboff", cp.isBbEnabled(), cp::setBbEnabled);
|
||||
}
|
||||
|
||||
storage.updateClanPlayer(cp);
|
||||
@Subcommand("%tag")
|
||||
@CommandPermission("simpleclans.member.tag-toggle")
|
||||
@Description("{@@command.description.toggle.tag}")
|
||||
public void tag(Player player, ClanPlayer cp) {
|
||||
toggle(player, "tagon", "tagoff", cp.isTagEnabled(), cp::setTagEnabled);
|
||||
}
|
||||
|
||||
@Subcommand("%deposit")
|
||||
@CommandPermission("simpleclans.leader.deposit-toggle")
|
||||
@Conditions("leader")
|
||||
@Description("{@@command.description.toggle.deposit}")
|
||||
public void deposit(Player player, Clan clan) {
|
||||
toggle(player, "depositon", "depositoff", clan.isAllowDeposit(),
|
||||
clan::setAllowDeposit);
|
||||
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%fee")
|
||||
@CommandPermission("simpleclans.leader.fee")
|
||||
@Conditions("rank:name=FEE_ENABLE|change_fee")
|
||||
@Description("{@@command.description.toggle.fee}")
|
||||
public void fee(Player player, Clan clan) {
|
||||
toggle(player, "feeon", "feeoff", clan.isMemberFeeEnabled(),
|
||||
clan::setMemberFeeEnabled);
|
||||
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%withdraw")
|
||||
@CommandPermission("simpleclans.leader.withdraw-toggle")
|
||||
@Conditions("leader")
|
||||
@Description("{@@command.description.toggle.withdraw}")
|
||||
public void withdraw(Player player, Clan clan) {
|
||||
toggle(player, "withdrawon", "withdrawoff", clan.isAllowWithdraw(),
|
||||
clan::setAllowWithdraw);
|
||||
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%tag")
|
||||
@CommandPermission("simpleclans.member.tag-toggle")
|
||||
@Description("{@@command.description.toggle.tag}")
|
||||
public void tag(Player player, ClanPlayer cp) {
|
||||
toggle(player, "tagon", "tagoff", cp.isTagEnabled(), cp::setTagEnabled);
|
||||
|
||||
storage.updateClanPlayer(cp);
|
||||
}
|
||||
|
||||
@Subcommand("%deposit")
|
||||
@CommandPermission("simpleclans.leader.deposit-toggle")
|
||||
@Conditions("leader")
|
||||
@Description("{@@command.description.toggle.deposit}")
|
||||
public void deposit(Player player, Clan clan) {
|
||||
toggle(player, "depositon", "depositoff", clan.isAllowDeposit(),
|
||||
clan::setAllowDeposit);
|
||||
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%fee")
|
||||
@CommandPermission("simpleclans.leader.fee")
|
||||
@Conditions("rank:name=FEE_ENABLE|change_fee")
|
||||
@Description("{@@command.description.toggle.fee}")
|
||||
public void fee(Player player, Clan clan) {
|
||||
toggle(player, "feeon", "feeoff", clan.isMemberFeeEnabled(),
|
||||
clan::setMemberFeeEnabled);
|
||||
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%withdraw")
|
||||
@CommandPermission("simpleclans.leader.withdraw-toggle")
|
||||
@Conditions("leader")
|
||||
@Description("{@@command.description.toggle.withdraw}")
|
||||
public void withdraw(Player player, Clan clan) {
|
||||
toggle(player, "withdrawon", "withdrawoff", clan.isAllowWithdraw(),
|
||||
clan::setAllowWithdraw);
|
||||
|
||||
storage.updateClan(clan);
|
||||
@Subcommand("%invite")
|
||||
@CommandPermission("simpleclans.anyone.invite-toggle")
|
||||
@Description("{@@command.description.toggle.invite}")
|
||||
public void invite(Player player, ClanPlayer cp) {
|
||||
toggle(player, "inviteon", "inviteoff", cp.isInviteEnabled(), cp::setInviteEnabled);
|
||||
}
|
||||
|
||||
private void toggle(CommandSender sender, String onMessageKey, String offMessageKey, boolean status,
|
||||
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ChatSubcommandsCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public ChatSubcommandsCompletion(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "chat_subcommands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext context) throws InvalidCommandArgument {
|
||||
Player player = context.getPlayer();
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String leave = lang("leave", player);
|
||||
List<String> subcommands = new ArrayList<>(Arrays.asList(lang("join", player), leave, lang("mute",
|
||||
player)));
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(player.getUniqueId());
|
||||
if (cp != null) {
|
||||
if (cp.getChannel() == ClanPlayer.Channel.NONE) {
|
||||
subcommands.remove(leave);
|
||||
}
|
||||
}
|
||||
|
||||
return subcommands;
|
||||
}
|
||||
}
|
||||
+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.getAllMembers().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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@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("-", "_")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Collection<String> getCompletions() {
|
||||
return availableLocales;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "locales";
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -11,6 +11,7 @@ import java.time.LocalDateTime;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.MINUTES;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CanChangeFeeCondition extends AbstractCommandCondition {
|
||||
@@ -26,7 +27,7 @@ public class CanChangeFeeCondition extends AbstractCommandCondition {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime collectTime = getCollectTime();
|
||||
long interval = now.until(collectTime, MINUTES);
|
||||
if (interval <= settingsManager.geteMemberFeeLastMinuteChangeInterval() * HOUR_IN_MINUTES) {
|
||||
if (interval <= settingsManager.getInt(ECONOMY_MEMBER_FEE_LAST_MINUTE_CHANGE_INTERVAL) * HOUR_IN_MINUTES) {
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
String error = lang("cannot.change.member.fee.now", issuer);
|
||||
if (interval <= 60) {
|
||||
@@ -40,8 +41,8 @@ public class CanChangeFeeCondition extends AbstractCommandCondition {
|
||||
|
||||
private LocalDateTime getCollectTime() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime collectTime = now.withHour(settingsManager.getTasksCollectFeeHour())
|
||||
.withMinute(settingsManager.getTasksCollectFeeMinute());
|
||||
LocalDateTime collectTime = now.withHour(settingsManager.getInt(TASKS_COLLECT_FEE_HOUR))
|
||||
.withMinute(settingsManager.getInt(TASKS_COLLECT_FEE_MINUTE));
|
||||
if (collectTime.isBefore(now)) {
|
||||
collectTime = collectTime.plusDays(1);
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
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.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
|
||||
public class CanChatCondition extends AbstractCommandCondition {
|
||||
public CanChatCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
String type = context.getConfigValue("type", (String) null).toUpperCase();
|
||||
ConfigField chatEnabled = ConfigField.valueOf(type + "CHAT_ENABLE");
|
||||
if (!settingsManager.is(chatEnabled)) {
|
||||
throw new ConditionFailedException(lang(type.toLowerCase() + ".chat.disabled", context.getIssuer()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "can_chat";
|
||||
}
|
||||
}
|
||||
+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;
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@ import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.WAR_MAX_MEMBERS_DIFFERENCE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.WAR_START_REQUEST_ENABLED;
|
||||
|
||||
public class CanWarTargetCondition extends AbstractParameterCondition<ClanInput> {
|
||||
public CanWarTargetCondition(@NotNull SimpleClans plugin) {
|
||||
@@ -32,8 +34,8 @@ public class CanWarTargetCondition extends AbstractParameterCondition<ClanInput>
|
||||
throw new ConditionFailedException(lang("clans.already.at.war", issuer));
|
||||
}
|
||||
|
||||
boolean isWarRequestEnabled = settingsManager.isWarRequestEnabled();
|
||||
int maxDifference = settingsManager.getMembersOnlineMaxDifference();
|
||||
boolean isWarRequestEnabled = settingsManager.is(WAR_START_REQUEST_ENABLED);
|
||||
int maxDifference = settingsManager.getInt(WAR_MAX_MEMBERS_DIFFERENCE);
|
||||
|
||||
if (!isWarRequestEnabled && maxDifference >= 0) {
|
||||
int difference = Math.abs(issuerClan.getOnlineMembers().size() - targetClan.getOnlineMembers().size());
|
||||
|
||||
+6
-2
@@ -1,10 +1,14 @@
|
||||
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.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.LAND_SHARING;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class LandSharingCondition extends AbstractCommandCondition {
|
||||
@@ -15,7 +19,7 @@ public class LandSharingCondition extends AbstractCommandCondition {
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
if (!settingsManager.isLandSharing()) {
|
||||
if (!settingsManager.is(LAND_SHARING)) {
|
||||
throw new ConditionFailedException(lang("land.sharing.disabled", context.getIssuer()));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.ECONOMY_MEMBER_FEE_ENABLED;
|
||||
|
||||
public class MemberFeeEnabledCondition extends AbstractCommandCondition {
|
||||
public MemberFeeEnabledCondition(@NotNull SimpleClans plugin) {
|
||||
@@ -17,7 +18,7 @@ public class MemberFeeEnabledCondition extends AbstractCommandCondition {
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
if (!settingsManager.isMemberFee()) {
|
||||
if (!settingsManager.is(ECONOMY_MEMBER_FEE_ENABLED)) {
|
||||
throw new ConditionFailedException(ChatColor.RED + lang("disabled.command",
|
||||
context.getIssuer().getIssuer()));
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,10 +6,10 @@ import co.aikar.commands.ConditionFailedException;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.CLAN_MIN_SIZE_TO_SET_ALLY;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -21,9 +21,9 @@ public class MinimumToAllyCondition extends AbstractCommandCondition {
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
Clan clan = Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
if (clan.getSize() < settingsManager.getClanMinSizeToAlly()) {
|
||||
if (clan.getSize() < settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_ALLY)) {
|
||||
throw new ConditionFailedException(RED +
|
||||
lang("minimum.to.make.alliance", context.getIssuer(), settingsManager.getClanMinSizeToAlly()));
|
||||
lang("minimum.to.make.alliance", context.getIssuer(), settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_ALLY)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.CLAN_MIN_SIZE_TO_SET_RIVAL;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -21,9 +22,9 @@ public class MinimumToRivalCondition extends AbstractCommandCondition {
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
Clan clan = Conditions.assertClanMember(clanManager, issuer);
|
||||
if (clan.getSize() < settingsManager.getClanMinSizeToRival()) {
|
||||
if (clan.getSize() < settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_RIVAL)) {
|
||||
throw new ConditionFailedException(RED + lang("min.players.rivalries", issuer,
|
||||
settingsManager.getClanMinSizeToRival()));
|
||||
settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_RIVAL)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -9,6 +9,8 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.BLACKLISTED_WORLDS;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NotBlacklistedCondition extends AbstractCommandCondition {
|
||||
|
||||
@@ -22,7 +24,7 @@ public class NotBlacklistedCondition extends AbstractCommandCondition {
|
||||
if (player != null) {
|
||||
World world = player.getLocation().getWorld();
|
||||
if (world != null) {
|
||||
if (settingsManager.isBlacklistedWorld(world.getName())) {
|
||||
if (settingsManager.getStringList(BLACKLISTED_WORLDS).contains(world.getName())) {
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -1,10 +1,12 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.debug;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@@ -24,7 +26,9 @@ public class NotInClanCondition extends AbstractParameterCondition<ClanPlayerInp
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value)
|
||||
throws InvalidCommandArgument {
|
||||
if (value.getClanPlayer().getClan() != null) {
|
||||
ClanPlayer clanPlayer = value.getClanPlayer();
|
||||
debug(String.format("NotInClanCondition -> %s %s", clanPlayer.getName(), clanPlayer.getUniqueId()));
|
||||
if (clanPlayer.getClan() != null) {
|
||||
throw new ConditionFailedException(RED + lang("the.player.is.already.member.of.another.clan",
|
||||
execContext.getSender()));
|
||||
}
|
||||
|
||||
+5
-1
@@ -1,12 +1,14 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.debug;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -23,7 +25,9 @@ public class OnlineCondition extends AbstractParameterCondition<ClanPlayerInput>
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context, BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument {
|
||||
Player player = value.getClanPlayer().toPlayer();
|
||||
ClanPlayer clanPlayer = value.getClanPlayer();
|
||||
debug(String.format("OnlineCondition -> %s %s", clanPlayer.getName(), clanPlayer.getUniqueId()));
|
||||
Player player = clanPlayer.toPlayer();
|
||||
|
||||
if (player != null) {
|
||||
boolean isVanished = VanishUtils.isVanished(execContext.getSender(), player);
|
||||
|
||||
+3
@@ -8,6 +8,8 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.debug;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerClanMemberCondition extends AbstractParameterCondition<Player> {
|
||||
public PlayerClanMemberCondition(@NotNull SimpleClans plugin) {
|
||||
@@ -23,6 +25,7 @@ public class PlayerClanMemberCondition extends AbstractParameterCondition<Player
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext,
|
||||
Player value) throws InvalidCommandArgument {
|
||||
debug(String.format("PlayerClanMemberCondition -> %s %s", value.getName(), value.getUniqueId()));
|
||||
Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
}
|
||||
|
||||
|
||||
+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";
|
||||
}
|
||||
}
|
||||
+21
-4
@@ -2,27 +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);
|
||||
cp = clanManager.getCreateClanPlayer(offlinePlayer.getUniqueId());
|
||||
Player player = Bukkit.getPlayer(arg);
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument(lang("user.hasnt.played.before", context.getSender()));
|
||||
}
|
||||
cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
return new ClanPlayerInput(cp);
|
||||
@@ -32,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;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PAGE_SEPARATOR;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.SERVER_NAME;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.DARK_GRAY;
|
||||
|
||||
@@ -30,7 +32,7 @@ public class Alliances extends Sendable {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getAllyString(DARK_GRAY + ", "));
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getAllyString(DARK_GRAY + ", ", sender));
|
||||
}
|
||||
|
||||
sendBlock();
|
||||
@@ -38,9 +40,9 @@ public class Alliances extends Sendable {
|
||||
|
||||
private void sendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " +
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " +
|
||||
lang("alliances", sender) + " " + headColor +
|
||||
Helper.generatePageSeparator(sm.getPageSep()));
|
||||
Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setAlignment("l", "l");
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.WHITE;
|
||||
|
||||
@@ -32,8 +33,8 @@ public class ClanCoords extends Sendable {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? sm.getPageLeaderColor() : (cpm.isTrusted() ?
|
||||
sm.getPageTrustedColor() : sm.getPageUnTrustedColor())) + cpm.getName();
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cpm.isTrusted() ?
|
||||
sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR))) + cpm.getName();
|
||||
Location loc = p.getLocation();
|
||||
int distance = (int) Math.ceil(loc.toVector().distance(player.getLocation().toVector()));
|
||||
String coords = loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ();
|
||||
@@ -57,8 +58,8 @@ public class ClanCoords extends Sendable {
|
||||
chatBlock.setAlignment("l", "c", "c", "c");
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("coords", player) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(player, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("coords", player) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.addRow(" " + headColor + lang("name", player), lang("distance", player),
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.utils.RankingNumberResolver.RankingType.ORDINAL;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@@ -52,7 +53,7 @@ public class ClanList extends Sendable {
|
||||
@Nullable String order) {
|
||||
boolean ascending = order == null || lang("list.order.asc").equalsIgnoreCase(order);
|
||||
if (type == null) {
|
||||
type = sm.getListDefaultOrderBy();
|
||||
type = sm.getString(LIST_DEFAULT_ORDER_BY);
|
||||
}
|
||||
if (type.equalsIgnoreCase(lang("list.type.size"))) {
|
||||
return new RankingNumberResolver<>(clans, Clan::getSize, order != null && ascending, ORDINAL);
|
||||
@@ -73,15 +74,15 @@ public class ClanList extends Sendable {
|
||||
@NotNull
|
||||
private List<Clan> getListableClans() {
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
clans = clans.stream().filter(clan -> clan.isVerified() || sm.isShowUnverifiedOnList())
|
||||
clans = clans.stream().filter(clan -> clan.isVerified() || sm.is(SHOW_UNVERIFIED_ON_LIST))
|
||||
.collect(Collectors.toList());
|
||||
return clans;
|
||||
}
|
||||
|
||||
private void sendHeader(List<Clan> clans) {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " + lang("clans.lower", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("clans.lower", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.clans", sender) + " " + subColor + clans.size());
|
||||
ChatBlock.sendBlank(sender);
|
||||
@@ -91,12 +92,11 @@ public class ClanList extends Sendable {
|
||||
lang("kdr", sender), lang("members", sender));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void addLine(RankingNumberResolver<Clan, ? extends Comparable<?>> ranking, Clan clan) {
|
||||
String tag = sm.getClanChatBracketColor() + sm.getClanChatTagBracketLeft()
|
||||
+ sm.getTagDefaultColor() + clan.getColorTag() + sm.getClanChatBracketColor()
|
||||
+ sm.getClanChatTagBracketRight();
|
||||
String name = (clan.isVerified() ? sm.getPageClanNameColor() : GRAY) + clan.getName();
|
||||
String tag = sm.getColored(CLANCHAT_BRACKET_COLOR) + sm.getString(CLANCHAT_BRACKET_LEFT)
|
||||
+ sm.getColored(TAG_DEFAULT_COLOR) + clan.getColorTag() + sm.getColored(CLANCHAT_BRACKET_COLOR)
|
||||
+ sm.getString(CLANCHAT_BRACKET_RIGHT);
|
||||
String name = (clan.isVerified() ? sm.getColored(PAGE_CLAN_NAME_COLOR) : GRAY) + clan.getName();
|
||||
String fullname = tag + " " + name;
|
||||
String size = WHITE + "" + clan.getSize();
|
||||
String kdr = clan.isVerified() ? YELLOW + "" + KDRFormat.format(clan.getTotalKDR()) : "";
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PAGE_LEADER_COLOR;
|
||||
|
||||
public class ClanProfile extends Sendable {
|
||||
|
||||
@@ -25,7 +26,7 @@ public class ClanProfile extends Sendable {
|
||||
.replace("%clan_color_tag%", clan.getColorTag())
|
||||
.replace("%clan_description%", getDescription())
|
||||
.replace("%clan_status%", Helper.getFormattedClanStatus(clan, sender))
|
||||
.replace("%clan_leaders%", clan.getLeadersString(sm.getPageLeaderColor(), subColor + ", "))
|
||||
.replace("%clan_leaders%", clan.getLeadersString(sm.getColored(PAGE_LEADER_COLOR), subColor + ", "))
|
||||
.replace("%clan_online_count%", String.valueOf(VanishUtils.getNonVanished(sender, clan).size()))
|
||||
.replace("%clan_size%", String.valueOf(clan.getSize()))
|
||||
.replace("%clan_kdr%", KDRFormat.format(clan.getTotalKDR()))
|
||||
@@ -36,8 +37,8 @@ public class ClanProfile extends Sendable {
|
||||
.replace("%clan_deaths%", String.valueOf(clan.getTotalDeaths()))
|
||||
.replace("%clan_fee_enabled%", getFeeEnabled())
|
||||
.replace("%clan_fee_value%", String.valueOf(clan.getMemberFee()))
|
||||
.replace("%clan_allies%", clan.getAllyString(subColor + ", "))
|
||||
.replace("%clan_rivals%", clan.getRivalString(subColor + ", "))
|
||||
.replace("%clan_allies%", clan.getAllyString(subColor + ", ", sender))
|
||||
.replace("%clan_rivals%", clan.getRivalString(subColor + ", ", sender))
|
||||
.replace("%clan_founded%", clan.getFoundedString())
|
||||
.replace("%clan_inactive_days%", String.valueOf(clan.getInactiveDays()))
|
||||
.replace("%clan_max_inactive_days%", Helper.formatMaxInactiveDays(clan.getMaxInactiveDays()));
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.data;
|
||||
|
||||
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;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class ClanRoster extends Sendable {
|
||||
@@ -33,12 +34,10 @@ 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 = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender) : GREEN + lang("online", sender);
|
||||
|
||||
String name = (cp.isTrusted() ? sm.getPageTrustedColor() : sm.getPageUnTrustedColor()) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,24 +45,22 @@ 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 = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender) :
|
||||
GREEN + lang("online", sender);
|
||||
|
||||
String name = sm.getPageLeaderColor() + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender)
|
||||
: WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("roster", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("roster", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("legend", sender) + " " + sm.getPageLeaderColor() +
|
||||
lang("leader", sender) + headColor + ", " + sm.getPageTrustedColor() + lang("trusted", sender) +
|
||||
headColor + ", " + sm.getPageUnTrustedColor() + lang("untrusted", sender));
|
||||
ChatBlock.sendMessage(sender, headColor + lang("legend", sender) + " " + sm.getColored(PAGE_LEADER_COLOR) +
|
||||
lang("leader", sender) + headColor + ", " + sm.getColored(PAGE_TRUSTED_COLOR) + lang("trusted", sender) +
|
||||
headColor + ", " + sm.getColored(PAGE_UNTRUSTED_COLOR) + lang("untrusted", sender));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setFlexibility(false, true, false, true);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class ClanStats extends Sendable {
|
||||
@@ -36,15 +37,15 @@ public class ClanStats extends Sendable {
|
||||
}
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.saySingle(sender, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("stats", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("stats", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("kdr", sender) + " = " + subColor +
|
||||
lang("kill.death.ratio", sender));
|
||||
ChatBlock.sendMessage(sender, headColor + lang("weights", sender) + " = " + lang("rival", sender)
|
||||
+ ": " + subColor + sm.getKwRival() + headColor + " " + lang("neutral", sender) + ": " + subColor +
|
||||
sm.getKwNeutral() + headColor + " " + lang("civilian", sender) + ": " + subColor +
|
||||
sm.getKwCivilian());
|
||||
+ ": " + subColor + sm.getDouble(KILL_WEIGHTS_RIVAL) + headColor + " " + lang("neutral", sender) + ": " + subColor +
|
||||
sm.getDouble(KILL_WEIGHTS_NEUTRAL) + headColor + " " + lang("civilian", sender) + ": " + subColor +
|
||||
sm.getDouble(KILL_WEIGHTS_CIVILIAN));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setFlexibility(true, false, false, false, false, false, false);
|
||||
@@ -55,16 +56,24 @@ public class ClanStats extends Sendable {
|
||||
}
|
||||
|
||||
private void addRows(List<ClanPlayer> clanPlayers) {
|
||||
for (ClanPlayer cpm : clanPlayers) {
|
||||
String name = (cpm.isLeader() ? sm.getPageLeaderColor() : (cpm.isTrusted() ? sm.getPageTrustedColor() :
|
||||
sm.getPageUnTrustedColor())) + cpm.getName();
|
||||
String rival = NumberFormat.getInstance().format(cpm.getRivalKills());
|
||||
String neutral = NumberFormat.getInstance().format(cpm.getNeutralKills());
|
||||
String civilian = NumberFormat.getInstance().format(cpm.getCivilianKills());
|
||||
String deaths = NumberFormat.getInstance().format(cpm.getDeaths());
|
||||
String kdr = KDRFormat.format(cpm.getKDR());
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
String color;
|
||||
if (cp.isLeader()) {
|
||||
color = sm.getColored(PAGE_LEADER_COLOR);
|
||||
} else if (cp.isTrusted()) {
|
||||
color = sm.getColored(PAGE_TRUSTED_COLOR);
|
||||
} else {
|
||||
color = sm.getColored(PAGE_UNTRUSTED_COLOR);
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + kdr, WHITE + rival, GRAY + neutral, DARK_GRAY + civilian,
|
||||
NumberFormat formatter = NumberFormat.getInstance(cp.getLocale());
|
||||
String rival = formatter.format(cp.getRivalKills());
|
||||
String neutral = formatter.format(cp.getNeutralKills());
|
||||
String civilian = formatter.format(cp.getCivilianKills());
|
||||
String deaths = formatter.format(cp.getDeaths());
|
||||
String kdr = KDRFormat.format(cp.getKDR());
|
||||
|
||||
chatBlock.addRow(color + cp.getName(), YELLOW + kdr, WHITE + rival, GRAY + neutral, DARK_GRAY + civilian,
|
||||
DARK_RED + deaths);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PAGE_CLAN_NAME_COLOR;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PAGE_SEPARATOR;
|
||||
|
||||
public class Kills extends Sendable {
|
||||
|
||||
@@ -53,9 +55,9 @@ public class Kills extends Sendable {
|
||||
chatBlock.setFlexibility(true, false);
|
||||
chatBlock.setAlignment("l", "c");
|
||||
chatBlock.addRow(" " + headColor + lang("victim", player), lang("killcount", player));
|
||||
ChatBlock.saySingle(player, sm.getPageClanNameColor() + polled + subColor
|
||||
ChatBlock.saySingle(player, sm.getColored(PAGE_CLAN_NAME_COLOR) + polled + subColor
|
||||
+ " " + lang("kills", player) + " " + headColor +
|
||||
Helper.generatePageSeparator(sm.getPageSep()));
|
||||
Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -13,6 +14,7 @@ import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class Leaderboard extends Sendable {
|
||||
@@ -36,10 +38,10 @@ 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.getPageLeaderColor() : (cp.isTrusted() ? sm.getPageTrustedColor() :
|
||||
sm.getPageUnTrustedColor())) + cp.getName();
|
||||
String name = (cp.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) :
|
||||
sm.getColored(PAGE_UNTRUSTED_COLOR))) + cp.getName();
|
||||
String lastSeen = online ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
String clanTag = WHITE + lang("free.agent", sender);
|
||||
@@ -55,8 +57,8 @@ public class Leaderboard extends Sendable {
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " + lang("leaderboard.command", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("leaderboard.command", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.clan.players.0", sender, subColor +
|
||||
clanPlayers.size()));
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class Lookup extends Sendable {
|
||||
@@ -51,7 +52,7 @@ public class Lookup extends Sendable {
|
||||
.replace("%player_last_seen%", target.getLastSeenString(sender))
|
||||
.replace("%player_past_clans%", target.getPastClansString(headColor + ", "))
|
||||
.replace("%player_inactive_days%", String.valueOf(target.getInactiveDays()))
|
||||
.replace("%player_max_inactive_days%", Helper.formatMaxInactiveDays(sm.getPurgePlayers()))
|
||||
.replace("%player_max_inactive_days%", Helper.formatMaxInactiveDays(sm.getInt(PURGE_INACTIVE_PLAYER_DAYS)))
|
||||
.replace("%kill_type_line%", getKillTypeLine());
|
||||
sender.sendMessage(lookup);
|
||||
} else {
|
||||
@@ -81,15 +82,15 @@ public class Lookup extends Sendable {
|
||||
return lang("free.agent", sender);
|
||||
}
|
||||
if (target.isLeader()) {
|
||||
return sm.getPageLeaderColor() + lang("leader", sender);
|
||||
return sm.getColored(PAGE_LEADER_COLOR) + lang("leader", sender);
|
||||
}
|
||||
if (target.isTrusted()) {
|
||||
return sm.getPageTrustedColor() + lang("trusted", sender);
|
||||
return sm.getColored(PAGE_TRUSTED_COLOR) + lang("trusted", sender);
|
||||
}
|
||||
if (!target.getRankId().isEmpty()) {
|
||||
return sm.getPageTrustedColor() + lang("in.rank", sender);
|
||||
return sm.getColored(PAGE_TRUSTED_COLOR) + lang("in.rank", sender);
|
||||
}
|
||||
return sm.getPageUnTrustedColor() + lang("untrusted", sender);
|
||||
return sm.getColored(PAGE_UNTRUSTED_COLOR) + lang("untrusted", sender);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PAGE_SEPARATOR;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.SERVER_NAME;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class MostKilled extends Sendable {
|
||||
@@ -64,8 +66,8 @@ public class MostKilled extends Sendable {
|
||||
chatBlock.addRow(" " + headColor + lang("victim", player), headColor +
|
||||
lang("killcount", player), headColor + lang("attacker", player));
|
||||
|
||||
ChatBlock.saySingle(player, sm.getServerName() + subColor + " " + lang("mostkilled",
|
||||
player) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(player, sm.getColored(SERVER_NAME) + subColor + " " + lang("mostkilled",
|
||||
player) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PAGE_SEPARATOR;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.SERVER_NAME;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class Rivalries extends Sendable {
|
||||
@@ -29,7 +31,7 @@ public class Rivalries extends Sendable {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getRivalString(DARK_GRAY + ", "));
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getRivalString(DARK_GRAY + ", ", sender));
|
||||
}
|
||||
|
||||
sendBlock();
|
||||
@@ -37,8 +39,8 @@ public class Rivalries extends Sendable {
|
||||
|
||||
private void sendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " +
|
||||
lang("rivalries", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " +
|
||||
lang("rivalries", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("legend", sender) + DARK_RED + " [" +
|
||||
lang("war", sender) + "]");
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
public abstract class Sendable {
|
||||
|
||||
@@ -25,19 +26,19 @@ public abstract class Sendable {
|
||||
sm = plugin.getSettingsManager();
|
||||
cm = plugin.getClanManager();
|
||||
this.sender = sender;
|
||||
headColor = sm.getPageHeadingsColor();
|
||||
subColor = sm.getPageSubTitleColor();
|
||||
headColor = sm.getColored(PAGE_HEADINGS_COLOR);
|
||||
subColor = sm.getColored(PAGE_SUBTITLE_COLOR);
|
||||
}
|
||||
|
||||
protected void sendBlock() {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
boolean more = chatBlock.sendBlock(sender, sm.getPageSize());
|
||||
boolean more = chatBlock.sendBlock(sender, sm.getInt(PAGE_SIZE));
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(sender, chatBlock);
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, sm.getPageHeadingsColor() + lang("view.next.page", sender,
|
||||
sm.getCommandMore()));
|
||||
ChatBlock.sendMessage(sender, sm.getColored(PAGE_HEADINGS_COLOR) + lang("view.next.page", sender,
|
||||
sm.getString(COMMANDS_MORE)));
|
||||
}
|
||||
ChatBlock.sendBlank(sender);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class Vitals extends Sendable {
|
||||
@@ -38,8 +39,8 @@ public class Vitals extends Sendable {
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("vitals", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("vitals", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("weapons", sender) + ": " +
|
||||
lang("0.s.sword.1.2.b.bow.3.4.a.arrow", sender, WHITE, DARK_GRAY, WHITE, DARK_GRAY, WHITE));
|
||||
@@ -63,10 +64,10 @@ public class Vitals extends Sendable {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? sm.getPageLeaderColor() : (cpm.isTrusted() ? sm.getPageTrustedColor()
|
||||
: sm.getPageUnTrustedColor())) + cpm.getName();
|
||||
String health = cm.getHealthString(p.getHealth());
|
||||
String hunger = cm.getHungerString(p.getFoodLevel());
|
||||
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.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());
|
||||
|
||||
+81
-24
@@ -5,31 +5,34 @@ 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.OfflinePlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanNamePrompt.NAME_KEY;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanTagPrompt.TAG_KEY;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@@ -49,10 +52,9 @@ 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.isEnableGUI()) {
|
||||
if (sender instanceof Player && settings.is(ENABLE_GUI)) {
|
||||
InventoryDrawer.open(new MainFrame((Player) sender));
|
||||
} else {
|
||||
help(sender, new CommandHelp(getCurrentCommandManager(),
|
||||
@@ -60,8 +62,25 @@ 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") @Single String locale) {
|
||||
if (!settings.is(LANGUAGE_SELECTOR)) {
|
||||
ChatBlock.sendMessageKey(cp, "locale.is.prohibited");
|
||||
return;
|
||||
}
|
||||
|
||||
cp.setLocale(Helper.forLanguageTag(locale.replace("_", "-")));
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
|
||||
ChatBlock.sendMessageKey(cp, "locale.has.been.changed");
|
||||
}
|
||||
|
||||
@Subcommand("%create")
|
||||
@CommandPermission("simpleclans.leader.create")
|
||||
@CommandCompletion("%compl:tag %compl:name")
|
||||
@Description("{@@command.description.create}")
|
||||
public void create(Player player, @Optional @Name("tag") String tag, @Optional @Name("name") String name) {
|
||||
ClanPlayer cp = cm.getAnyClanPlayer(player.getUniqueId());
|
||||
@@ -74,8 +93,8 @@ public class GeneralCommands extends BaseCommand {
|
||||
HashMap<Object, Object> initialData = new HashMap<>();
|
||||
initialData.put(TAG_KEY, tag);
|
||||
initialData.put(NAME_KEY, name);
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateClanTagPrompt())
|
||||
.withLocalEcho(true).withTimeout(60).withInitialSessionData(initialData).buildConversation(player);
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateClanTagPrompt(), initialData);
|
||||
conversation.addConversationCanceller(new RequestCanceller(player, RED + lang("clan.create.request.cancelled", player)));
|
||||
conversation.begin();
|
||||
}
|
||||
|
||||
@@ -91,8 +110,8 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandCompletion("@players")
|
||||
@CommandPermission("simpleclans.anyone.lookup")
|
||||
@Description("{@@command.description.lookup.other}")
|
||||
public void lookup(CommandSender sender, @Name("player") OfflinePlayer player) {
|
||||
Lookup l = new Lookup(plugin, sender, player.getUniqueId());
|
||||
public void lookup(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
Lookup l = new Lookup(plugin, sender, player.getClanPlayer().getUniqueId());
|
||||
l.send();
|
||||
}
|
||||
|
||||
@@ -120,7 +139,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());
|
||||
@@ -128,7 +147,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) {
|
||||
@@ -154,17 +173,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.isAllowResetKdr()) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,12 +232,12 @@ public class GeneralCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
chatBlock.sendBlock(player, settings.getPageSize());
|
||||
chatBlock.sendBlock(player, settings.getInt(PAGE_SIZE));
|
||||
|
||||
if (chatBlock.size() > 0) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, settings.getPageHeadingsColor() + lang("view.next.page", player,
|
||||
settings.getCommandMore()));
|
||||
ChatBlock.sendMessage(player, settings.getColored(PAGE_HEADINGS_COLOR) + lang("view.next.page", player,
|
||||
settings.getString(COMMANDS_MORE)));
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
@@ -234,6 +266,31 @@ public class GeneralCommands extends BaseCommand {
|
||||
mk.send();
|
||||
}
|
||||
|
||||
@Subcommand("%list %balance")
|
||||
@CommandPermission("simpleclans.anyone.list.balance")
|
||||
@Description("{@@command.description.list.balance}")
|
||||
public void listBalance(CommandSender sender) {
|
||||
List<Clan> clans = cm.getClans();
|
||||
if (clans.isEmpty()) {
|
||||
sender.sendMessage(RED + lang("no.clans.have.been.created", sender));
|
||||
return;
|
||||
}
|
||||
clans.sort(Comparator.comparingDouble(Clan::getBalance).reversed());
|
||||
|
||||
sender.sendMessage(lang("clan.list.balance.header", sender, settings.getColored(SERVER_NAME), clans.size()));
|
||||
String lineFormat = lang("clan.list.balance.line", sender);
|
||||
|
||||
String leftBracket = settings.getColored(TAG_BRACKET_COLOR) + settings.getColored(TAG_BRACKET_LEFT);
|
||||
String rightBracket = settings.getColored(TAG_BRACKET_COLOR) + settings.getColored(TAG_BRACKET_RIGHT);
|
||||
for (int i = 0; i < 10 && i < clans.size(); i++) {
|
||||
Clan clan = clans.get(i);
|
||||
String name = " " + (clan.isVerified() ? settings.getColored(PAGE_CLAN_NAME_COLOR) : GRAY) + clan.getName();
|
||||
String line = MessageFormat.format(lineFormat, i + 1, leftBracket, clan.getColorTag(),
|
||||
rightBracket, name, clan.getBalanceFormatted());
|
||||
sender.sendMessage(line);
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%list")
|
||||
@CommandPermission("simpleclans.anyone.list")
|
||||
@Description("{@@command.description.list}")
|
||||
|
||||
+21
-10
@@ -7,7 +7,12 @@ import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
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 net.sacredlabyrinth.phaed.simpleclans.utils.CurrencyFormat;
|
||||
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;
|
||||
@@ -18,13 +23,16 @@ 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")
|
||||
@Description("{@@command.description.bank.admin.status}")
|
||||
public void status(CommandSender sender, @Name("clan") ClanInput clanInput) {
|
||||
Clan clan = clanInput.getClan();
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.balance", sender, clan.getName(), clan.getBalance()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.balance", sender, clan.getName(), clan.getBalanceFormatted()));
|
||||
}
|
||||
|
||||
@Subcommand("%take")
|
||||
@@ -34,12 +42,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));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.take", sender, CurrencyFormat.format(amount), clan.getName()));
|
||||
clan.addBb(sender.getName(), lang("bb.clan.take", sender, CurrencyFormat.format(amount), sender.getName()));
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
sender.sendMessage(RED + lang("clan.admin.bank.not.enough.money", sender, clan.getName()));
|
||||
@@ -54,11 +63,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));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.give", sender, CurrencyFormat.format(amount), clan.getName()));
|
||||
clan.addBb(sender.getName(), lang("bb.clan.give", sender, CurrencyFormat.format(amount), sender.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +79,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, 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));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.set", sender, clan.getName(), CurrencyFormat.format(amount)));
|
||||
clan.addBb(sender.getName(), lang("bb.clan.set", sender, CurrencyFormat.format(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);
|
||||
}
|
||||
|
||||
}
|
||||
+102
-58
@@ -2,10 +2,12 @@ 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.ReloadEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
@@ -14,18 +16,18 @@ 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;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.GLOBAL_FRIENDLY_FIRE;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@@ -49,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")
|
||||
@@ -89,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;
|
||||
}
|
||||
|
||||
@@ -101,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));
|
||||
}
|
||||
@@ -113,13 +116,15 @@ public class StaffCommands extends BaseCommand {
|
||||
storage.saveModified();
|
||||
plugin.reloadConfig();
|
||||
LanguageResource.clearCache();
|
||||
settings.load();
|
||||
settings.loadAndSave();
|
||||
storage.importFromDatabase();
|
||||
permissions.loadPermissions();
|
||||
|
||||
for (Clan clan : cm.getClans()) {
|
||||
permissions.updateClanPermissions(clan);
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(new ReloadEvent(sender));
|
||||
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("configuration.reloaded", sender));
|
||||
}
|
||||
|
||||
@@ -127,11 +132,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));
|
||||
}
|
||||
|
||||
@@ -139,14 +151,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());
|
||||
}
|
||||
|
||||
@@ -154,8 +159,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;
|
||||
@@ -174,8 +179,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;
|
||||
@@ -194,10 +199,10 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.globalff")
|
||||
@Description("{@@command.description.globalff.allow}")
|
||||
public void allowGlobalFf(CommandSender sender) {
|
||||
if (settings.isGlobalff()) {
|
||||
if (settings.is(GLOBAL_FRIENDLY_FIRE)) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("global.friendly.fire.is.already.being.allowed", sender));
|
||||
} else {
|
||||
settings.setGlobalff(true);
|
||||
settings.set(GLOBAL_FRIENDLY_FIRE, true);
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("global.friendly.fire.is.set.to.allowed", sender));
|
||||
}
|
||||
}
|
||||
@@ -206,11 +211,11 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.globalff")
|
||||
@Description("{@@command.description.globalff.auto}")
|
||||
public void autoGlobalFf(CommandSender sender) {
|
||||
if (!settings.isGlobalff()) {
|
||||
if (!settings.is(GLOBAL_FRIENDLY_FIRE)) {
|
||||
ChatBlock.sendMessage(sender, AQUA +
|
||||
lang("global.friendy.fire.is.already.being.managed.by.each.clan", sender));
|
||||
} else {
|
||||
settings.setGlobalff(false);
|
||||
settings.set(GLOBAL_FRIENDLY_FIRE, false);
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("global.friendy.fire.is.now.managed.by.each.clan",
|
||||
sender));
|
||||
}
|
||||
@@ -225,7 +230,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));
|
||||
@@ -257,12 +262,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());
|
||||
}
|
||||
@@ -280,19 +285,20 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.admin.promote")
|
||||
@Description("{@@command.description.admin.promote}")
|
||||
public void promote(CommandSender sender, @Conditions("online|clan_member") @Name("player") ClanPlayerInput promote) {
|
||||
Player promotePl = Objects.requireNonNull(promote.getClanPlayer().toPlayer());
|
||||
ClanPlayer clanPlayer = promote.getClanPlayer();
|
||||
Player promotePl = Objects.requireNonNull(clanPlayer.toPlayer());
|
||||
if (!permissions.has(promotePl, "simpleclans.leader.promotable")) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.player.does.not.have.the.permissions.to.lead.a.clan",
|
||||
sender));
|
||||
return;
|
||||
}
|
||||
Clan clan = Objects.requireNonNull(promote.getClanPlayer().getClan());
|
||||
Clan clan = Objects.requireNonNull(clanPlayer.getClan());
|
||||
if (clan.isLeader(promotePl)) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.player.is.already.a.leader", sender));
|
||||
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));
|
||||
}
|
||||
@@ -304,13 +310,18 @@ public class StaffCommands extends BaseCommand {
|
||||
public void demote(CommandSender sender, @Conditions("clan_member") @Name("leader") ClanPlayerInput other) {
|
||||
ClanPlayer otherCp = other.getClanPlayer();
|
||||
Clan clan = Objects.requireNonNull(otherCp.getClan());
|
||||
if (clan.getLeaders().size() == 1) {
|
||||
|
||||
if (!otherCp.isLeader()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("player.is.not.a.leader", sender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getLeaders().size() == 1 && !clan.isPermanent()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.demote.the.last.leader", sender));
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -319,7 +330,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));
|
||||
}
|
||||
@@ -328,20 +343,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") @Single 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);
|
||||
}
|
||||
}
|
||||
+23
-17
@@ -4,10 +4,9 @@ import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PreCreateClanEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
@@ -17,6 +16,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanTagPrompt.TAG_KEY;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.CLAN_DEFAULT_RANK;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class CreateClanNamePrompt extends StringPrompt {
|
||||
public static final String NAME_KEY = "name";
|
||||
@@ -65,17 +68,20 @@ public class CreateClanNamePrompt extends StringPrompt {
|
||||
plugin.getClanManager().createClan(player, tag, name);
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(tag);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA +
|
||||
lang("clan.created", name));
|
||||
clan.addBb(player.getName(), lang("clan.created", name));
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
if (!plugin.getSettingsManager().getString(CLAN_DEFAULT_RANK).isEmpty()) {
|
||||
clan.setDefaultRank(plugin.getSettingsManager().getString(CLAN_DEFAULT_RANK));
|
||||
|
||||
if (plugin.getSettingsManager().isRequireVerification()) {
|
||||
boolean verified = !plugin.getSettingsManager().isRequireVerification()
|
||||
|| plugin.getPermissionsManager().has(player, "simpleclans.mod.verify");
|
||||
|
||||
if (!verified) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA +
|
||||
lang("get.your.clan.verified.to.access.advanced.features", player));
|
||||
if (plugin.getSettingsManager().is(REQUIRE_VERIFICATION)) {
|
||||
boolean verified = !plugin.getSettingsManager().is(REQUIRE_VERIFICATION)
|
||||
|| plugin.getPermissionsManager().has(player, "simpleclans.mod.verify");
|
||||
|
||||
if (!verified) {
|
||||
ChatBlock.sendMessage(player, AQUA +
|
||||
lang("get.your.clan.verified.to.access.advanced.features", player));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,19 +91,19 @@ public class CreateClanNamePrompt extends StringPrompt {
|
||||
private Prompt validateName(@NotNull SimpleClans plugin, @NotNull Player player, @NotNull String input) {
|
||||
boolean bypass = plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass");
|
||||
if (!bypass) {
|
||||
if (ChatUtils.stripColors(input).length() > plugin.getSettingsManager().getClanMaxLength()) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
if (ChatUtils.stripColors(input).length() > plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)) {
|
||||
return new MessagePromptImpl(RED +
|
||||
lang("your.clan.name.cannot.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getClanMaxLength()), this);
|
||||
plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)), this);
|
||||
}
|
||||
if (ChatUtils.stripColors(input).length() <= plugin.getSettingsManager().getClanMinLength()) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
if (ChatUtils.stripColors(input).length() <= plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)) {
|
||||
return new MessagePromptImpl(RED +
|
||||
lang("your.clan.name.must.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getClanMinLength()), this);
|
||||
plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)), this);
|
||||
}
|
||||
}
|
||||
if (input.contains("&")) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
return new MessagePromptImpl(RED +
|
||||
lang("your.clan.name.cannot.contain.color.codes", player), this);
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -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 {
|
||||
@@ -18,10 +19,11 @@ public class CreateClanTagPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
||||
Player forWhom = (Player) context.getForWhom();
|
||||
if (context.getSessionData(TAG_KEY) != null) {
|
||||
return "";
|
||||
}
|
||||
return lang("insert.clan.tag", (Player) context.getForWhom());
|
||||
return lang("insert.clan.tag", forWhom, lang("cancel", forWhom));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +41,6 @@ public class CreateClanTagPrompt extends StringPrompt {
|
||||
|
||||
Prompt errorPrompt = validateTag(plugin, player, input);
|
||||
if (errorPrompt != null) return errorPrompt;
|
||||
|
||||
context.setSessionData(TAG_KEY, input);
|
||||
return new CreateClanNamePrompt();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+9
-6
@@ -5,7 +5,6 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.CreateRankEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PreCreateRankEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
@@ -14,11 +13,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class CreateRankNamePrompt extends StringPrompt {
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
||||
return lang("insert.rank.name", (Player) context.getForWhom());
|
||||
Player forWhom = (Player) context.getForWhom();
|
||||
return lang("insert.rank.name", forWhom, lang("cancel", forWhom));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,17 +35,18 @@ public class CreateRankNamePrompt extends StringPrompt {
|
||||
PreCreateRankEvent event = new PreCreateRankEvent(player, clan, rank);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
rank = event.getRankName();
|
||||
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (clan.hasRank(rank)) {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("rank.already.exists", player), this);
|
||||
return new MessagePromptImpl(RED + lang("rank.already.exists", player), this);
|
||||
}
|
||||
|
||||
|
||||
clan.createRank(rank);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new CreateRankEvent(player, clan, clan.getRank(rank)));
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("rank.created", player));
|
||||
return new MessagePromptImpl(AQUA + lang("rank.created", player));
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.InactivityConversationCanceller;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class InactivityCanceller extends InactivityConversationCanceller {
|
||||
|
||||
/**
|
||||
* Creates an InactivityConversationCanceller.
|
||||
*
|
||||
* @param plugin The owning plugin.
|
||||
* @param timeoutSeconds The number of seconds of inactivity to wait.
|
||||
*/
|
||||
public InactivityCanceller(@NotNull Plugin plugin, int timeoutSeconds) {
|
||||
super(plugin, timeoutSeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelling(@NotNull Conversation conversation) {
|
||||
Player forWhom = (Player) conversation.getForWhom();
|
||||
forWhom.spigot().sendMessage(new TextComponent(RED + lang("you.did.not.answer.in.time", forWhom)));
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -1,18 +1,16 @@
|
||||
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) {
|
||||
this.message = message;
|
||||
}
|
||||
@@ -31,5 +29,4 @@ public class MessagePromptImpl extends org.bukkit.conversations.MessagePrompt {
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext cc) {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationCanceller;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class RequestCanceller implements ConversationCanceller {
|
||||
|
||||
@NotNull
|
||||
private final String cancelledMessage;
|
||||
@NotNull
|
||||
private final String escapeSequence;
|
||||
|
||||
public RequestCanceller(@NotNull String escapeSequence, @NotNull String cancelledMessage) {
|
||||
this.escapeSequence = escapeSequence;
|
||||
this.cancelledMessage = cancelledMessage;
|
||||
}
|
||||
|
||||
public RequestCanceller(@NotNull CommandSender sender, @NotNull String cancelledMessage) {
|
||||
this(lang("cancel", sender), cancelledMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConversation(@NotNull Conversation conversation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelBasedOnInput(@NotNull ConversationContext context, @NotNull String input) {
|
||||
if (input.equalsIgnoreCase(escapeSequence)) {
|
||||
context.getForWhom().sendRawMessage(cancelledMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//a clone that is not a clone, nice one, Bukkit
|
||||
@SuppressWarnings("MethodDoesntCallSuperMethod")
|
||||
@NotNull
|
||||
@Override
|
||||
public ConversationCanceller clone() {
|
||||
return new RequestCanceller(this.escapeSequence, this.cancelledMessage);
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
+19
-42
@@ -2,63 +2,40 @@ 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.ChatColor;
|
||||
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;
|
||||
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("resign.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(), ChatColor.AQUA + lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("resign.success", player));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband(player, true, false);
|
||||
return null;
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.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(ChatColor.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 ChatColor.RED + MessageFormat.format(
|
||||
lang("resign.confirmation", player), Arrays.asList(
|
||||
lang("resign.yes", player), lang("resign.no", player)));
|
||||
protected String getPromptTextKey() {
|
||||
return "resign.confirmation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeclineTextKey() {
|
||||
return "resign.request.cancelled";
|
||||
}
|
||||
}
|
||||
Loaded 100 of 274 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user