mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-05 09:10:14 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
+20
-12
@@ -11,19 +11,27 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
java-version: [ 8, 11, 16 ]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
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@v2
|
||||
- name: "Set up JDK ${{ matrix.java-version }}"
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: "${{ matrix.java-version }}"
|
||||
distribution: 'adopt'
|
||||
- name: Build with Maven
|
||||
run: mvn -B -U package --file pom.xml
|
||||
- name: Upload a Build Artifact
|
||||
if: "${{ matrix.java-version == 8 }}"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: SimpleClans
|
||||
path: target/SimpleClans.jar
|
||||
@@ -24,6 +24,6 @@ jobs:
|
||||
file_path: target/SimpleClans.jar
|
||||
changelog: ${{ github.event.release.body }}
|
||||
display_name: ${{ github.event.release.tag_name }}
|
||||
game_versions: 7915,7667,7330,7105,6588,630,591,585,531
|
||||
game_versions: 8849,8503,7915,7667,7330,7105,6588,630,591,585,531
|
||||
release_type: release
|
||||
relations: vault:optionalDependency,worldguard:optionalDependency,grief-prevention:optionalDependency
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Publish to Reposilite
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
server-id: reposilite # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Publish to Reposilite
|
||||
run: mvn -B deploy
|
||||
env:
|
||||
MAVEN_USERNAME: simpleclans
|
||||
MAVEN_PASSWORD: ${{ secrets.REPOSILITE_TOKEN }}
|
||||
+66
-27
@@ -1,14 +1,5 @@
|
||||
<?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>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
@@ -31,18 +22,17 @@
|
||||
<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" name="Maven: org.bstats:bstats-bukkit:2.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-base:2.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.10.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations: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" name="Maven: org.jetbrains:annotations:22.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.papermc:paperlib:1.0.8-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-paper:0.5.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.cryptomorin:XSeries:8.3.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.7.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.4" level="project" />
|
||||
@@ -63,8 +53,6 @@
|
||||
<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" />
|
||||
@@ -93,17 +81,68 @@
|
||||
<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" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.discordsrv:discordsrv:1.24.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:4.3.0_349" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.14" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: github.scarsz:configuralize:1.3.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.alexheretic:dynamics:4.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.alexheretic:fluent:2.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-jdk14:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.vdurmont:emoji-java:5.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20170516" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.zafarkhaja:java-semver:0.9.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.kevinsawicki:http-request:6.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-hla:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-dnssec:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-client:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-core:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.minidns:minidns-iterative-resolver:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-expression:5.2.7.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-core:5.2.7.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: dev.vankka:MCDiscordReserializer:4.2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: dev.vankka:SimpleAST:2.2.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-api:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-key:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-api:1.3.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-string:1.3.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-legacy:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-plain:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-bukkit:4.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-api:4.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-bungeecord:4.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-nbt:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson-legacy-impl:4.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-facet:4.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-platform-viaversion:4.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-minimessage:4.1.0-20210316.192746" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: biz.princeps:landlord-latest:4.351" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: biz.princeps:landlord-core:4.351" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: biz.princeps:landlord-api:4.351" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.github.bananapuncher714:nbteditor:7.16.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.eldoria:eldo-util:1.9.1" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+156
-31
@@ -4,8 +4,8 @@
|
||||
<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>
|
||||
<version>2.16.0</version>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -57,7 +57,7 @@
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
@@ -76,10 +76,6 @@
|
||||
<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>
|
||||
@@ -88,6 +84,37 @@
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@@ -115,14 +142,18 @@
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
@@ -190,13 +221,13 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
<version>22.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<version>5.7.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -243,24 +274,6 @@
|
||||
<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>
|
||||
@@ -309,6 +322,118 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.24.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>JDA</artifactId>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nv-websocket-client</artifactId>
|
||||
<groupId>com.neovisionaries</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>trove4j</artifactId>
|
||||
<groupId>net.sf.trove4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>configuralize</artifactId>
|
||||
<groupId>github.scarsz</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>commons-collections</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<groupId>commons-codec</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>emoji-java</artifactId>
|
||||
<groupId>com.vdurmont</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>java-semver</artifactId>
|
||||
<groupId>com.github.zafarkhaja</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>http-request</artifactId>
|
||||
<groupId>com.github.kevinsawicki</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>minidns-hla</artifactId>
|
||||
<groupId>org.minidns</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>spring-expression</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>MCDiscordReserializer</artifactId>
|
||||
<groupId>dev.vankka</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-serializer-plain</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<groupId>net.kyori</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>landlord-latest</artifactId>
|
||||
<version>4.351</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>landlord-core</artifactId>
|
||||
<groupId>biz.princeps</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.15.2</version>
|
||||
<version>2.16.2</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>
|
||||
@@ -65,7 +65,7 @@
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
@@ -84,10 +84,6 @@
|
||||
<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>
|
||||
@@ -104,6 +100,40 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>3.0.0</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.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Dependencies -->
|
||||
@@ -129,7 +159,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -141,33 +171,28 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
<version>22.0.0</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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
<version>8.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<version>5.7.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -182,24 +207,24 @@
|
||||
<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>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.plotsquared</groupId>-->
|
||||
<!-- <artifactId>PlotSquared-Core</artifactId>-->
|
||||
<!-- <version>5.13.3</version>-->
|
||||
<!-- <scope>provided</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.plotsquared</groupId>-->
|
||||
<!-- <artifactId>PlotSquared-Bukkit</artifactId>-->
|
||||
<!-- <version>5.13.3</version>-->
|
||||
<!-- <scope>provided</scope>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>*</groupId>-->
|
||||
<!-- <artifactId>PlotSquared-Core</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
@@ -228,6 +253,18 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.24.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>landlord-latest</artifactId>
|
||||
<version>4.351</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Repositories -->
|
||||
@@ -256,14 +293,22 @@
|
||||
<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>IntellectualSites</id>-->
|
||||
<!-- <url>https://mvn.intellectualsites.com/content/groups/public/</url>-->
|
||||
<!-- </repository>-->
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
@@ -278,12 +323,8 @@
|
||||
|
||||
<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>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -27,10 +27,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 +47,7 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setColumnSizes(String prefix, double... columnPercentages) {
|
||||
int ll = LINE_LENGTH;
|
||||
|
||||
@@ -57,6 +60,7 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasContent() {
|
||||
return !rows.isEmpty();
|
||||
}
|
||||
@@ -65,22 +69,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 +278,7 @@ public class ChatBlock {
|
||||
return (int) maxWidth;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String centerInLine(String msg) {
|
||||
return centerInLineOf(msg, LINE_LENGTH);
|
||||
}
|
||||
@@ -513,6 +523,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 +537,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 +547,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) {
|
||||
@@ -551,16 +562,20 @@ public class ChatBlock {
|
||||
player.sendMessage(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));
|
||||
}
|
||||
|
||||
@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 +588,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 +606,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
|
||||
|
||||
@@ -4,8 +4,14 @@ import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.Placeholder;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLog;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.*;
|
||||
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 +25,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
|
||||
@@ -68,7 +76,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;
|
||||
}
|
||||
}
|
||||
@@ -105,15 +113,15 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
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));
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, amount));
|
||||
addBb(player.getName(), AQUA + lang("bb.clan.deposit", 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, amount));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + lang("not.sufficient.money", player));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +129,18 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Deposits money to the clan
|
||||
*/
|
||||
public EconomyResponse deposit(@Nullable CommandSender 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,12 +150,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
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));
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
addBb(player.getName(), AQUA + lang("bb.clan.withdraw", 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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,15 +163,22 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Withdraws money from the clan
|
||||
*/
|
||||
public EconomyResponse withdraw(@Nullable CommandSender 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,21 +251,26 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param balance the balance to set
|
||||
*/
|
||||
public void setBalance(double balance) {
|
||||
setBalance(null, Cause.API, balance);
|
||||
setBalance(null, Cause.API, SET, balance);
|
||||
}
|
||||
|
||||
public EconomyResponse setBalance(@Nullable CommandSender updater, @NotNull Cause cause, double balance) {
|
||||
public EconomyResponse setBalance(@Nullable CommandSender updater, @NotNull Cause cause, @NotNull BankLogger.Operation operation, double balance) {
|
||||
EconomyResponse response = SUCCESS;
|
||||
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(updater, 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(updater, this, response, SET, cause, balance));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
return EconomyResponse.SUCCESS;
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,17 +335,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,7 +383,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(Player player) {
|
||||
return this.members.contains(player.getUniqueId().toString());
|
||||
return members.contains(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +393,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(UUID playerUniqueId) {
|
||||
return this.members.contains(playerUniqueId.toString());
|
||||
return members.contains(playerUniqueId.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -464,7 +491,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -500,8 +527,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.members.contains(uuid)) {
|
||||
this.members.add(uuid);
|
||||
if (!members.contains(uuid)) {
|
||||
members.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,7 +536,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* (used internally)
|
||||
*/
|
||||
public void removeMember(UUID playerUniqueId) {
|
||||
this.members.remove(playerUniqueId.toString());
|
||||
members.remove(playerUniqueId.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -517,7 +544,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("size")
|
||||
public int getSize() {
|
||||
return this.members.size();
|
||||
return members.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -535,12 +562,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 +585,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 +633,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedBb
|
||||
*/
|
||||
public String getPackedBb() {
|
||||
return Helper.toMessage(bb, "|");
|
||||
return String.join("|", bb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -620,7 +642,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 +651,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedAllies
|
||||
*/
|
||||
public String getPackedAllies() {
|
||||
return Helper.toMessage(allies, "|");
|
||||
return String.join("|", allies);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,7 +660,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 +669,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedRivals
|
||||
*/
|
||||
public String getPackedRivals() {
|
||||
return Helper.toMessage(rivals, "|");
|
||||
return String.join("|", rivals);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -656,61 +678,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 +732,12 @@ 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().
|
||||
map(member -> SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member))).
|
||||
filter(Objects::nonNull).
|
||||
filter(ClanPlayer::isLeader).
|
||||
map(clanPlayer -> prefix.concat(clanPlayer.getName())).
|
||||
collect(Collectors.joining(sep));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,16 +776,8 @@ 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;
|
||||
PermissionsManager permissions = SimpleClans.getInstance().getPermissionsManager();
|
||||
return getNonLeaders().stream().filter(cp -> !permissions.has(cp.toPlayer(), "simpleclans.member.bypass-fee")).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -826,6 +823,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all leaders in the clan
|
||||
*
|
||||
@@ -1040,9 +1038,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 +1052,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
cp.removePastClan(getColorTag());
|
||||
cp.setClan(this);
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().isClanTrustByDefault());
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().is(CLAN_TRUST_MEMBERS_BY_DEFAULT));
|
||||
if (defaultRank != null) {
|
||||
cp.setRank(defaultRank);
|
||||
}
|
||||
@@ -1097,7 +1095,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);
|
||||
@@ -1225,13 +1223,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().map(UUID::fromString).map(Bukkit::getPlayer).anyMatch(Objects::nonNull);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1244,7 +1236,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 +1261,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 +1281,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Helper.isOnline(leader.getName())) {
|
||||
if (leader.toPlayer() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1308,7 +1300,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
if (leader.toPlayer() == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1328,7 +1320,7 @@ 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();
|
||||
@@ -1338,14 +1330,14 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + lang("clan.announce") + ChatColor.AQUA + "] " + ChatColor.AQUA + "[" + Helper.getColorName(playerName) + ChatColor.WHITE + "] " + message);
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(AQUA + "[" + lang("clan.announce") + AQUA + "] " + AQUA + "[" + Helper.getColorName(playerName) + WHITE + "] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Announce message to a 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();
|
||||
|
||||
@@ -1356,7 +1348,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
ChatBlock.sendMessage(pl, message);
|
||||
}
|
||||
}
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + lang("leader.announce") + ChatColor.AQUA + "] " + ChatColor.WHITE + message);
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(AQUA + "[" + lang("leader.announce") + AQUA + "] " + WHITE + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1364,8 +1356,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(SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR) + "* " + SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,8 +1366,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(SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR) + "* " + SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1394,14 +1386,14 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void displayBb(Player player, int maxSize) {
|
||||
if (isVerified()) {
|
||||
ChatBlock.sendBlank(player);
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getBbAccentColor();
|
||||
String pageHeadingsColor = SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor();
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR);
|
||||
String pageHeadingsColor = SimpleClans.getInstance().getSettingsManager().getColored(PAGE_HEADINGS_COLOR);
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", bbAccentColor, pageHeadingsColor, getName()));
|
||||
|
||||
List<String> localBb;
|
||||
if (maxSize == -1) {
|
||||
localBb = bb;
|
||||
maxSize = SimpleClans.getInstance().getSettingsManager().getBbSize();
|
||||
maxSize = SimpleClans.getInstance().getSettingsManager().getInt(BB_SIZE);
|
||||
} else {
|
||||
localBb = new ArrayList<>(bb);
|
||||
}
|
||||
@@ -1411,7 +1403,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
for (String msg : localBb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getBbColor();
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR);
|
||||
ChatBlock.sendMessage(player, bbAccentColor + "* " + bbColor + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
@@ -1433,8 +1425,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return false;
|
||||
}
|
||||
long time = (System.currentTimeMillis() - Long.parseLong(msg.substring(0, index))) / 1000L;
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getBbAccentColor();
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getBbColor();
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR);
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR);
|
||||
msg = ChatUtils.parseColors(bbAccentColor + "* " + bbColor + msg.substring(++index));
|
||||
TextComponent textComponent = new TextComponent(msg);
|
||||
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
|
||||
@@ -1457,54 +1449,54 @@ 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) {
|
||||
if (isPermanent() && !force) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("cannot.disband.permanent"));
|
||||
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);
|
||||
|
||||
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, AQUA + 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, AQUA + 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, AQUA + 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 +1540,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(), AQUA + lang("you.are.at.war",
|
||||
getName(), targetClan.getColorTag()));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1648,27 +1640,15 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
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,7 @@ 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.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -16,8 +17,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
|
||||
@@ -45,6 +48,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
private @Nullable Locale locale;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -64,17 +68,17 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param uuid the Player's UUID
|
||||
*/
|
||||
public ClanPlayer(UUID uuid) {
|
||||
this.uniqueId = uuid;
|
||||
uniqueId = uuid;
|
||||
Player onlinePlayer = SimpleClans.getInstance().getServer().getPlayer(uuid);
|
||||
if (onlinePlayer != null) {
|
||||
this.displayName = onlinePlayer.getName();
|
||||
displayName = onlinePlayer.getName();
|
||||
} else {
|
||||
OfflinePlayer offlinePlayer = SimpleClans.getInstance().getServer().getOfflinePlayer(uuid);
|
||||
this.displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
}
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
this.joinDate = (new Date()).getTime();
|
||||
this.tag = "";
|
||||
lastSeen = (new Date()).getTime();
|
||||
joinDate = (new Date()).getTime();
|
||||
tag = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,12 +93,12 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
ClanPlayer other = (ClanPlayer) obj;
|
||||
return other.getName().equals(this.getName());
|
||||
return other.getName().equals(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClanPlayer other) {
|
||||
return this.getUniqueId().compareTo(other.getUniqueId());
|
||||
return getUniqueId().compareTo(other.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +141,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.displayName = name;
|
||||
displayName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +227,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* Updates last seen date to today
|
||||
*/
|
||||
public void updateLastSeen() {
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
lastSeen = (new Date()).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,11 +435,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;
|
||||
}
|
||||
@@ -484,7 +488,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
return "";
|
||||
}
|
||||
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.joinDate));
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(joinDate));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,7 +513,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
if (player != null && player.isOnline() && !VanishUtils.isVanished(sender, player)) {
|
||||
return lang("online", sender);
|
||||
}
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.lastSeen));
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(lastSeen));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,15 +531,7 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -544,14 +540,14 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param PackedPastClans the PackedPastClans to set
|
||||
*/
|
||||
public void setPackedPastClans(String PackedPastClans) {
|
||||
this.pastClans = Helper.fromArray2(PackedPastClans.split("[|]"));
|
||||
pastClans = Helper.fromArrayToSet(PackedPastClans.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,7 +618,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
public void setResignTimes(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,23 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
}
|
||||
|
||||
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 +804,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
flags.put("hide-tag", tagEnabled);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(this.toPlayer());
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(toPlayer());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -858,10 +864,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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class Dates {
|
||||
/**
|
||||
* @author RoboMWM, LaxWasHere
|
||||
* @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,17 +1,10 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONArray;
|
||||
@@ -19,47 +12,34 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils.stripColors;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
|
||||
public class Helper {
|
||||
|
||||
private Helper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps stacktrace to log
|
||||
*/
|
||||
@Deprecated
|
||||
public static void dumpStackTrace() {
|
||||
for (StackTraceElement el : Thread.currentThread().getStackTrace()) {
|
||||
SimpleClans.debug(el.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link KDRFormat}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String formatKDR(float kdr) {
|
||||
DecimalFormat formatter = new DecimalFormat("#.#");
|
||||
return formatter.format(kdr);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Locale forLanguageTag(@Nullable String languageTag) {
|
||||
Locale defaultLanguage = SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
@@ -68,21 +48,6 @@ public class Helper {
|
||||
}
|
||||
return Locale.forLanguageTag(languageTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Player locale
|
||||
*
|
||||
* @param player the player
|
||||
* @return the locale
|
||||
*/
|
||||
@Nullable
|
||||
public static Locale getLocale(@NotNull Player player) {
|
||||
ClanPlayer clanPlayer = SimpleClans.getInstance().getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
if (clanPlayer != null) {
|
||||
return clanPlayer.getLocale();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable JSONObject parseJson(String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
@@ -94,15 +59,71 @@ public class Helper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Set<Path> getPathsIn(String path, Predicate<? super Path> filter) {
|
||||
Set<Path> files = new LinkedHashSet<>();
|
||||
String packagePath = path.replace(".", "/");
|
||||
|
||||
try {
|
||||
URI uri = SimpleClans.class.getProtectionDomain().getCodeSource().getLocation().toURI();
|
||||
FileSystem fileSystem = FileSystems.newFileSystem(URI.create("jar:" + uri), Collections.emptyMap());
|
||||
files = Files.walk(fileSystem.getPath(packagePath)).
|
||||
filter(Objects::nonNull).
|
||||
filter(filter).
|
||||
collect(Collectors.toSet());
|
||||
fileSystem.close();
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
SimpleClans.getInstance().getLogger().
|
||||
log(Level.WARNING, "An error occurred while trying to load files: " + ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public static Set<Class<?>> getClasses(String packageName) {
|
||||
Set<Class<?>> classes = new LinkedHashSet<>();
|
||||
|
||||
Predicate<? super Path> filter = entry -> {
|
||||
String path = entry.getFileName().toString();
|
||||
return !path.contains("$") && path.endsWith(".class");
|
||||
};
|
||||
|
||||
for (Path filesPath : getPathsIn(packageName, filter)) {
|
||||
// Compatibility with different Java versions
|
||||
String path = filesPath.toString();
|
||||
if (path.charAt(0) == '/') {
|
||||
path = path.substring(1);
|
||||
}
|
||||
|
||||
String fileName = path.replace("/", ".").split(".class")[0];
|
||||
|
||||
try {
|
||||
Class<?> clazz = Class.forName(fileName);
|
||||
classes.add(clazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Set<Class<? extends T>> getSubTypesOf(String packageName, Class<?> type) {
|
||||
return getClasses(packageName).stream().
|
||||
filter(type::isAssignableFrom).
|
||||
map(aClass -> ((Class<? extends T>) aClass)).
|
||||
collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a list of ranks from the specified JSONObject
|
||||
*
|
||||
*
|
||||
* @param jo the JSON Object
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static @Nullable List<Rank> ranksFromJson(@Nullable JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
public static @Nullable List<Rank> ranksFromJson(@Nullable JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
Object ranks = jo.get("ranks");
|
||||
if (ranks != null) {
|
||||
JSONArray array = (JSONArray) ranks;
|
||||
@@ -122,7 +143,7 @@ public class Helper {
|
||||
return rankList;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,85 +153,83 @@ public class Helper {
|
||||
* @return the default rank or null if not found and/or it does not exist
|
||||
*/
|
||||
public static @Nullable String defaultRankFromJson(@Nullable JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
if (!jo.containsKey("defaultRank")) {
|
||||
return null;
|
||||
} else {
|
||||
return (String) jo.get("defaultRank");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a list of ranks and the default rank to a JSON String
|
||||
*
|
||||
* @param ranks the ranks
|
||||
*
|
||||
* @param ranks the ranks
|
||||
* @param defaultRank the default rank
|
||||
* @return a JSON String
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String ranksToJson(List<Rank> ranks, @Nullable String defaultRank) {
|
||||
if (ranks == null)
|
||||
ranks = new ArrayList<Rank>();
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
for (Rank rank : ranks) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", rank.getName());
|
||||
o.put("displayName", rank.getDisplayName());
|
||||
JSONArray permArray = new JSONArray();
|
||||
for (String p : rank.getPermissions()) {
|
||||
permArray.add(p);
|
||||
}
|
||||
o.put("permissions", permArray);
|
||||
array.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("ranks", array);
|
||||
object.put("defaultRank", defaultRank);
|
||||
return object.toJSONString();
|
||||
public static String ranksToJson(List<Rank> ranks, @Nullable String defaultRank) {
|
||||
if (ranks == null)
|
||||
ranks = new ArrayList<>();
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
for (Rank rank : ranks) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", rank.getName());
|
||||
o.put("displayName", rank.getDisplayName());
|
||||
JSONArray permArray = new JSONArray();
|
||||
permArray.addAll(rank.getPermissions());
|
||||
o.put("permissions", permArray);
|
||||
array.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("ranks", array);
|
||||
object.put("defaultRank", defaultRank);
|
||||
return object.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a resign times map to a JSON String
|
||||
*
|
||||
*
|
||||
* @param resignTimes
|
||||
* @return a JSON String
|
||||
*/
|
||||
public static String resignTimesToJson(Map<String, Long> resignTimes) {
|
||||
return JSONObject.toJSONString(resignTimes);
|
||||
return JSONObject.toJSONString(resignTimes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a JSON String to a resign times map
|
||||
*
|
||||
*
|
||||
* @param json JSON String
|
||||
* @return a map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Long> resignTimesFromJson(String json) {
|
||||
if (json != null) {
|
||||
try {
|
||||
return (Map<String, Long>) new JSONParser().parse(json);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
public static Map<String, Long> resignTimesFromJson(String json) {
|
||||
if (json != null) {
|
||||
try {
|
||||
return (Map<String, Long>) new JSONParser().parse(json);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the delay in seconds to the specified hour and minute.
|
||||
*
|
||||
* @param hour hour
|
||||
*
|
||||
* @param hour hour
|
||||
* @param minute minute
|
||||
* @return the delay in seconds
|
||||
*/
|
||||
public static long getDelayTo(int hour, int minute) {
|
||||
if (hour < 0 || hour > 23) hour = 1;
|
||||
if (minute < 0 || minute > 59) minute = 0;
|
||||
if (hour < 0 || hour > 23) hour = 1;
|
||||
if (minute < 0 || minute > 59) minute = 0;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime d = LocalDateTime.of(now.toLocalDate(), LocalTime.of(hour, minute));
|
||||
long delay;
|
||||
@@ -240,190 +259,12 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for integer
|
||||
*
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public static boolean isInteger(Object o) {
|
||||
return o instanceof java.lang.Integer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for byte
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isByte(String input) {
|
||||
try {
|
||||
Byte.parseByte(input);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for short
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isShort(String input) {
|
||||
try {
|
||||
Short.parseShort(input);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for integer
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isInteger(String input) {
|
||||
try {
|
||||
Integer.parseInt(input);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for float
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static boolean isFloat(String input) {
|
||||
try {
|
||||
Float.parseFloat(input);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for string
|
||||
*
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public static boolean isString(Object o) {
|
||||
return o instanceof java.lang.String;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for boolean
|
||||
*
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public static boolean isBoolean(Object o) {
|
||||
return o instanceof java.lang.Boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a character from a string
|
||||
*
|
||||
* @param s
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
public static String removeChar(String s, char c) {
|
||||
String r = "";
|
||||
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) != c) {
|
||||
r += s.charAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove first character from a string
|
||||
*
|
||||
* @param s
|
||||
* @param c
|
||||
* @return
|
||||
*/
|
||||
public static String removeFirstChar(String s, char c) {
|
||||
String r = "";
|
||||
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) != c) {
|
||||
r += s.charAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Capitalize first word of sentence
|
||||
*
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
public static String capitalize(String content) {
|
||||
if (content.length() < 2) {
|
||||
return content;
|
||||
}
|
||||
|
||||
String first = content.substring(0, 1).toUpperCase();
|
||||
return first + content.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return plural word if count is bigger than one
|
||||
*
|
||||
* @param count
|
||||
* @param word
|
||||
* @param ending
|
||||
* @return
|
||||
*/
|
||||
public static String plural(int count, String word, String ending) {
|
||||
return count == 1 ? word : word + ending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hex value to ChatColor
|
||||
*
|
||||
* @param hexValue
|
||||
* @return
|
||||
*/
|
||||
@NotNull
|
||||
public static String toColor(@Nullable String hexValue) {
|
||||
if (hexValue == null) {
|
||||
return "";
|
||||
}
|
||||
if (hexValue.startsWith("&#")) {
|
||||
return ChatUtils.parseColors(hexValue);
|
||||
}
|
||||
|
||||
ChatColor color = ChatColor.getByChar(hexValue);
|
||||
if (color == null) {
|
||||
return "";
|
||||
}
|
||||
return color.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts string array to ArrayList<String>, remove empty strings
|
||||
* Converts string array to {@literal ArrayList<String>}, remove empty strings
|
||||
*
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public static List<String> fromArray(String... values) {
|
||||
public static List<String> fromArrayToList(String... values) {
|
||||
List<String> results = new ArrayList<>();
|
||||
Collections.addAll(results, values);
|
||||
results.remove("");
|
||||
@@ -431,12 +272,12 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts string array to HashSet<String>, remove empty strings
|
||||
* Converts string array to {@literal HashSet<String>}, remove empty strings
|
||||
*
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> fromArray2(String... values) {
|
||||
public static Set<String> fromArrayToSet(String... values) {
|
||||
HashSet<String> results = new HashSet<>();
|
||||
Collections.addAll(results, values);
|
||||
results.remove("");
|
||||
@@ -444,150 +285,27 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a player array to ArrayList<Player>
|
||||
*
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public static List<Player> fromPlayerArray(Player... values) {
|
||||
List<Player> results = new ArrayList<>();
|
||||
Collections.addAll(results, values);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts ArrayList<String> to string array
|
||||
* Converts {@literal ArrayList<String>} to string array
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static String[] toArray(List<String> list) {
|
||||
return list.toArray(new String[list.size()]);
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the Permission values array to a String array
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String[] fromPermissionArray() {
|
||||
RankPermission[] permissions = RankPermission.values();
|
||||
String[] sa = new String[permissions.length];
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
sa[i] = permissions[i].toString();
|
||||
}
|
||||
return sa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes first item from a string array
|
||||
*
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
public static String[] removeFirst(String[] args) {
|
||||
List<String> out = fromArray(args);
|
||||
|
||||
if (!out.isEmpty()) {
|
||||
out.remove(0);
|
||||
RankPermission[] permissions = RankPermission.values();
|
||||
String[] sa = new String[permissions.length];
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
sa[i] = permissions[i].toString();
|
||||
}
|
||||
return toArray(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string array to a space separated string
|
||||
*
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
public static String toMessage(String[] args) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String arg : args) {
|
||||
out.append(arg).append(" ");
|
||||
}
|
||||
|
||||
return out.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string array to a string with custom separators
|
||||
*
|
||||
* @param args
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public static String toMessage(String[] args, String sep) {
|
||||
String out = "";
|
||||
|
||||
for (String arg : args) {
|
||||
out += arg + ", ";
|
||||
}
|
||||
|
||||
return stripTrailing(out, ", ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string array to a string with custom separators
|
||||
*
|
||||
* @param args
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public static String toMessage(List<String> args, String sep) {
|
||||
String out = "";
|
||||
|
||||
for (String arg : args) {
|
||||
out += arg + sep;
|
||||
}
|
||||
|
||||
return stripTrailing(out, sep);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ChatUtils#parseColors(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String parseColors(String msg) {
|
||||
return ChatUtils.parseColors(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes color codes from strings
|
||||
*
|
||||
* @deprecated use {@link ChatUtils#stripColors(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String stripColors(String msg) {
|
||||
return ChatUtils.stripColors(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves the last color code @param msg @return
|
||||
*/
|
||||
/**
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
public static String getLastColorCode(String msg) {
|
||||
msg = msg.replaceAll(String.valueOf((char) 194), "").trim();
|
||||
|
||||
if (msg.length() < 2) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String one = msg.substring(msg.length() - 2, msg.length() - 1);
|
||||
String two = msg.substring(msg.length() - 1);
|
||||
|
||||
if (one.equals("\u00a7")) {
|
||||
return one + two;
|
||||
}
|
||||
|
||||
if (one.equals("&")) {
|
||||
return Helper.toColor(two);
|
||||
}
|
||||
|
||||
return "";
|
||||
return sa;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -600,33 +318,6 @@ public class Helper {
|
||||
return stripColors(tag).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes trailing separators
|
||||
*
|
||||
* @param msg
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public static String stripTrailing(String msg, String sep) {
|
||||
if (msg.length() < sep.length()) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
String out = msg;
|
||||
String first = msg.substring(0, sep.length());
|
||||
String last = msg.substring(msg.length() - sep.length());
|
||||
|
||||
if (first.equals(sep)) {
|
||||
out = msg.substring(sep.length());
|
||||
}
|
||||
|
||||
if (last.equals(sep)) {
|
||||
out = msg.substring(0, msg.length() - sep.length());
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates page separator line
|
||||
*
|
||||
@@ -642,43 +333,6 @@ public class Helper {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player is online
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isOnline(String playerName) {
|
||||
Collection<Player> online = getOnlinePlayers();
|
||||
|
||||
for (Player o : online) {
|
||||
if (o.getName().equalsIgnoreCase(playerName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player is online
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return
|
||||
*/
|
||||
public static boolean isOnline(UUID playerUniqueId) {
|
||||
Collection<Player> online = getOnlinePlayers();
|
||||
|
||||
for (Player o : online) {
|
||||
if (o.getUniqueId().equals(playerUniqueId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove offline players from a ClanPlayer array
|
||||
*
|
||||
@@ -697,28 +351,6 @@ public class Helper {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a url is valid
|
||||
*
|
||||
* @param strUrl
|
||||
* @return
|
||||
*/
|
||||
public static boolean testURL(String strUrl) {
|
||||
try {
|
||||
URL url = new URL(strUrl);
|
||||
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
|
||||
urlConn.connect();
|
||||
|
||||
if (urlConn.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
return false;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes single quotes
|
||||
*
|
||||
@@ -733,7 +365,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a prettier coordinate, does not include world
|
||||
* Returns a prettier coordinate
|
||||
*
|
||||
* @param loc
|
||||
* @return
|
||||
@@ -742,29 +374,6 @@ public class Helper {
|
||||
return loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ() + " " + loc.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the two locations refer to the same block
|
||||
*
|
||||
* @param loc
|
||||
* @param loc2
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSameBlock(Location loc, Location loc2) {
|
||||
return loc.getBlockX() == loc2.getBlockX() && loc.getBlockY() == loc2.getBlockY() && loc.getBlockZ() == loc2.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the two locations refer to the same location, ignoring pitch and
|
||||
* yaw
|
||||
*
|
||||
* @param loc
|
||||
* @param loc2
|
||||
* @return
|
||||
*/
|
||||
public static boolean isSameLocation(Location loc, Location loc2) {
|
||||
return loc.getX() == loc2.getX() && loc.getY() == loc2.getY() && loc.getZ() == loc2.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a Map by value
|
||||
*
|
||||
@@ -782,140 +391,6 @@ public class Helper {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link VanishUtils#isVanished(CommandSender, Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("_, null -> false")
|
||||
public static boolean isVanished(@Nullable CommandSender viewer, @Nullable Player player) {
|
||||
if (isVanished(player)) {
|
||||
return true;
|
||||
}
|
||||
if (viewer instanceof Player && player != null) {
|
||||
return !((Player) viewer).canSee(player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link VanishUtils#isVanished(Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("null -> false")
|
||||
public static boolean isVanished(@Nullable Player player) {
|
||||
if (player != null && player.hasMetadata("vanished") && !player.getMetadata("vanished").isEmpty()) {
|
||||
return player.getMetadata("vanished").get(0).asBoolean();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<Player> getOnlinePlayers() {
|
||||
try {
|
||||
Method method = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
|
||||
Object players = method.invoke(null);
|
||||
|
||||
if (players instanceof Player[]) {
|
||||
return new ArrayList<>(Arrays.asList((Player[]) players));
|
||||
} else {
|
||||
return (Collection<Player>) players;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public static Player getPlayer(String playerName) {
|
||||
return Bukkit.getPlayerExact(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the ally chat
|
||||
*
|
||||
* @param cp Sender
|
||||
* @param msg The message
|
||||
* @param placeholders The placeholders
|
||||
* @return The formated message
|
||||
*/
|
||||
public static String formatAllyChat(ClanPlayer cp, String msg, Map<String, String> placeholders) {
|
||||
SettingsManager sm = SimpleClans.getInstance().getSettingsManager();
|
||||
|
||||
String leaderColor = sm.getAllyChatLeaderColor();
|
||||
String memberColor = sm.getAllyChatMemberColor();
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatUtils.parseColors(cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatUtils.parseColors(sm.getAllyChatRank()).replace("%rank%", rank) : "";
|
||||
|
||||
String message = replacePlaceholders(sm.getAllyChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
if (placeholders != null) {
|
||||
for (Entry<String, String> e : placeholders.entrySet()) {
|
||||
message = message.replace("%"+e.getKey()+"%", e.getValue());
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String replacePlaceholders(String messageFormat,
|
||||
ClanPlayer cp,
|
||||
String leaderColor,
|
||||
String memberColor,
|
||||
String rankFormat,
|
||||
String msg) {
|
||||
return ChatUtils.parseColors(messageFormat)
|
||||
.replace("%clan%", Objects.requireNonNull(cp.getClan()).getColorTag())
|
||||
.replace("%nick-color%", (cp.isLeader() ? leaderColor : memberColor))
|
||||
.replace("%player%", cp.getName())
|
||||
.replace("%rank%", rankFormat)
|
||||
.replace("%message%", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the clan chat
|
||||
*
|
||||
* @param cp Sender
|
||||
* @param msg The message
|
||||
* @param placeholders The placeholders
|
||||
* @return The formated message
|
||||
*/
|
||||
public static String formatClanChat(ClanPlayer cp, String msg, Map<String, String> placeholders) {
|
||||
SettingsManager sm = SimpleClans.getInstance().getSettingsManager();
|
||||
|
||||
String leaderColor = sm.getClanChatLeaderColor();
|
||||
String memberColor = sm.getClanChatMemberColor();
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatUtils.parseColors(cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatUtils.parseColors(sm.getClanChatRank()).replace("%rank%", rank) : "";
|
||||
|
||||
String message = replacePlaceholders(sm.getClanChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
|
||||
if (placeholders != null) {
|
||||
for (Entry<String, String> e : placeholders.entrySet()) {
|
||||
message = message.replace("%"+e.getKey()+"%", e.getValue());
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the chat in a way that the Clan Tag is always there, so infractors can be easily identified
|
||||
*
|
||||
* @param cp Sender
|
||||
* @param msg The chat message
|
||||
* @return The formatted message
|
||||
*/
|
||||
public static String formatSpyClanChat(ClanPlayer cp, String msg) {
|
||||
msg = stripColors(msg);
|
||||
|
||||
if (msg.contains(stripColors(cp.getClan().getColorTag()))) {
|
||||
return ChatColor.DARK_GRAY + msg;
|
||||
} else {
|
||||
return ChatColor.DARK_GRAY + "[" + cp.getTag() + "] " + msg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats max inactive days to an infinity symbol if it's negative or 0
|
||||
*
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -178,6 +180,6 @@ public final class Request {
|
||||
}
|
||||
|
||||
public boolean reachedRequestLimit() {
|
||||
return askCount > SimpleClans.getInstance().getSettingsManager().getMaxAsksPerRequest();
|
||||
return askCount > SimpleClans.getInstance().getSettingsManager().getInt(REQUEST_MAX);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ 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.tasks.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
@@ -14,6 +16,8 @@ import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
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 +33,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 +54,12 @@ public class SimpleClans extends JavaPlugin {
|
||||
private PermissionsManager permissionsManager;
|
||||
private TeleportManager teleportManager;
|
||||
private ProtectionManager protectionManager;
|
||||
private ChatManager chatManager;
|
||||
private boolean hasUUID;
|
||||
private static final Pattern ACF_PLACEHOLDER_PATTERN = Pattern.compile("\\{(?<key>[a-zA-Z]+?)}");
|
||||
|
||||
private BankLogger bankLogger;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
*/
|
||||
@@ -58,7 +69,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static void debug(String msg) {
|
||||
if (getInstance().getSettingsManager().isDebugging()) {
|
||||
if (getInstance().getSettingsManager().is(DEBUG)) {
|
||||
logger.log(Level.INFO, msg);
|
||||
}
|
||||
}
|
||||
@@ -83,7 +94,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new LanguageMigration(this).migrate();
|
||||
settingsManager = new SettingsManager();
|
||||
settingsManager = new SettingsManager(this);
|
||||
languageResource = new LanguageResource();
|
||||
this.hasUUID = UUIDMigration.canReturnUUID();
|
||||
|
||||
@@ -94,10 +105,12 @@ public class SimpleClans extends JavaPlugin {
|
||||
teleportManager = new TeleportManager();
|
||||
protectionManager = new ProtectionManager();
|
||||
protectionManager.registerListeners();
|
||||
chatManager = new ChatManager(this);
|
||||
migrateChatFormat();
|
||||
registerEvents();
|
||||
permissionsManager.loadPermissions();
|
||||
commandManager = new SCCommandManager(this);
|
||||
bankLogger = new CSVBankLogger(this);
|
||||
|
||||
logStatus();
|
||||
startTasks();
|
||||
@@ -107,16 +120,17 @@ 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);
|
||||
@@ -130,60 +144,60 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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 +244,14 @@ public class SimpleClans extends JavaPlugin {
|
||||
return protectionManager;
|
||||
}
|
||||
|
||||
public ChatManager getChatManager() {
|
||||
return chatManager;
|
||||
}
|
||||
|
||||
public BankLogger getBankLogger() {
|
||||
return bankLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the path within the language file
|
||||
* @return the lang
|
||||
@@ -245,13 +267,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 && instance.getSettingsManager().is(LANGUAGE_SELECTOR)) {
|
||||
locale = clanPlayer.getLocale();
|
||||
}
|
||||
|
||||
String lang = languageResource.getLang(key, locale);
|
||||
@@ -266,13 +285,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 +342,8 @@ public class SimpleClans extends JavaPlugin {
|
||||
return this.hasUUID;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
public interface ChatHandler {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
SettingsManager settingsManager = plugin.getSettingsManager();
|
||||
ChatManager chatManager = plugin.getChatManager();
|
||||
|
||||
void sendMessage(SCMessage message);
|
||||
|
||||
boolean canHandle(SCMessage.Source source);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
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 {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, BUNGEE
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_ENABLE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_FORMAT_TO;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
/**
|
||||
* 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 = 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 && settingsManager.is(DISCORDCHAT_ENABLE) &&
|
||||
getPluginManager().getPlugin("DiscordSRV") != null;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
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 org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_ENABLE;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == SPIGOT ? message.getChannel() : message.getSource()));
|
||||
|
||||
String format = settingsManager.getString(configField);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message, event.getPlaceholders());
|
||||
|
||||
plugin.getLogger().info(formattedMessage);
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
}
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == DISCORD && settingsManager.is(DISCORDCHAT_ENABLE) &&
|
||||
getPluginManager().getPlugin("DiscordSRV") != null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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 java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_ENABLE;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
/**
|
||||
* Handles delivering messages from {@link Source#SPIGOT} and {@link Source#DISCORD} to internal spy chat.
|
||||
*/
|
||||
public class SpyChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_SPYFORMAT",
|
||||
message.getSource() == SPIGOT ? message.getChannel() : message.getSource()));
|
||||
String format = settingsManager.getString(configField);
|
||||
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message);
|
||||
|
||||
List<ClanPlayer> onlinePlayers = getOnlineClanPlayers().stream()
|
||||
.filter(player -> plugin.getPermissionsManager().has(player.toPlayer(), "simpleclans.admin.all-seeing-eye"))
|
||||
.filter(player -> !player.isMuted())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
onlinePlayers.removeAll(message.getReceivers());
|
||||
onlinePlayers.forEach(receiver -> ChatBlock.sendMessage(receiver, formattedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == DISCORD && settingsManager.is(DISCORDCHAT_ENABLE) &&
|
||||
getPluginManager().getPlugin("DiscordSRV") != null);
|
||||
}
|
||||
|
||||
private List<ClanPlayer> getOnlineClanPlayers() {
|
||||
return plugin.getClanManager().getAllClanPlayers().stream().
|
||||
filter(cp -> cp.toPlayer() != null).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+24
-20
@@ -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,6 +33,7 @@ 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;
|
||||
@@ -44,8 +46,8 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
registerDependencies();
|
||||
enableUnstableAPI("help");
|
||||
registerDependencies();
|
||||
addCommandReplacements();
|
||||
registerContexts();
|
||||
registerCommands();
|
||||
@@ -60,11 +62,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 +94,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())) {
|
||||
@@ -116,8 +121,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 +144,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
|
||||
@@ -160,16 +165,16 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
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);
|
||||
String command = optionalLang(s + ".command", (ClanPlayer) null);
|
||||
if (command == null) {
|
||||
command = s;
|
||||
}
|
||||
@@ -206,7 +211,6 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
};
|
||||
//this.locales.loadLanguages();
|
||||
}
|
||||
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
@@ -219,6 +223,6 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
"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");
|
||||
}
|
||||
}
|
||||
+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));
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
-13
@@ -5,15 +5,16 @@ 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.managers.PermissionsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.Cause.REVERT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.Cause.COMMAND;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@@ -48,7 +49,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,19 +57,24 @@ 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)) {
|
||||
/*
|
||||
* ——————————————————————————————————
|
||||
*/
|
||||
switch (clan.withdraw(player, COMMAND, amount)) {
|
||||
case SUCCESS:
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerGrantMoney(player, amount)) {
|
||||
if (permissions.playerGrantMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount, player.getName()));
|
||||
} else {
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, clan.getBalance() + amount);
|
||||
clan.setBalance(player, REVERT, BankLogger.Operation.WITHDRAW, clan.getBalance() + amount);
|
||||
}
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
@@ -94,7 +99,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 +107,31 @@ 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, amount));
|
||||
return;
|
||||
}
|
||||
EconomyResponse response = clan.deposit(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
EconomyResponse response = clan.deposit(player, 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));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount, player.getName()));
|
||||
} else {
|
||||
//Reverts the deposit if something went wrong with Vault
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, clan.getBalance() - amount);
|
||||
clan.setBalance(player, REVERT, BankLogger.Operation.DEPOSIT, clan.getBalance() - amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
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.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;
|
||||
@Dependency
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
-20
@@ -6,11 +6,11 @@ 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 org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
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 +50,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 +68,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +132,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 +154,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,7 +185,7 @@ 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));
|
||||
@@ -218,14 +223,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 +241,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Subcommand("%rival %add")
|
||||
@CommandPermission("simpleclans.leader.rival")
|
||||
@Conditions("verified|rivable|minimum_to_rival|rank:name=RIVAL_ADD")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.rival.add}")
|
||||
public void addRival(Player player, Clan issuerClan, @Conditions("verified|different") @Name("clan") ClanInput rival) {
|
||||
Clan rivalInput = rival.getClan();
|
||||
@@ -281,7 +286,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Subcommand("%ally %add")
|
||||
@CommandPermission("simpleclans.leader.ally")
|
||||
@Conditions("verified|rank:name=ALLY_ADD|minimum_to_ally")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@Description("{@@command.description.ally.add}")
|
||||
public void addAlly(Player player,
|
||||
ClanPlayer cp,
|
||||
@@ -292,7 +297,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));
|
||||
@@ -332,7 +337,7 @@ public class ClanCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%kick")
|
||||
@CommandPermission("simpleclans.leader.kick")
|
||||
@CommandCompletion("@clan_members")
|
||||
@CommandCompletion("@clan_members:hide_own")
|
||||
@Conditions("rank:name=KICK")
|
||||
@Description("{@@command.description.kick}")
|
||||
public void kick(@Conditions("clan_member") Player sender,
|
||||
@@ -354,14 +359,31 @@ public class ClanCommands extends BaseCommand {
|
||||
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(), AQUA + 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();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ 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 +36,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;
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class HomeCommands extends BaseCommand {
|
||||
@Conditions("rank:name=REGROUP_HOME")
|
||||
@Description("{@@command.description.regroup.home}")
|
||||
public void regroupHome(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
if (!settings.is(ALLOW_REGROUP)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
@@ -77,15 +78,15 @@ public class HomeCommands extends BaseCommand {
|
||||
@Conditions("rank:name=HOME_TP")
|
||||
@Description("{@@command.description.home.tp}")
|
||||
public void teleport(Player player, Clan clan, ClanPlayer cp) {
|
||||
Location loc = clan.getHomeLocation();
|
||||
Location homeLocation = clan.getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
if (homeLocation == null) {
|
||||
ChatBlock.sendMessage(player, RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.purchaseHomeTeleport(player)) {
|
||||
plugin.getTeleportManager().addPlayer(player, clan.getHomeLocation(), clan.getName());
|
||||
plugin.getTeleportManager().addPlayer(player, homeLocation, clan.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ public class HomeCommands extends BaseCommand {
|
||||
@Conditions("rank:name=HOME_SET")
|
||||
@Description("{@@command.description.home.clear}")
|
||||
public void clear(Player player, 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;
|
||||
@@ -109,12 +110,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,6 +14,8 @@ 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")
|
||||
@@ -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()))
|
||||
|
||||
+45
-7
@@ -6,6 +6,8 @@ import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions.DiscordHookException;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,8 +15,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|leader")
|
||||
@@ -30,6 +32,8 @@ public class LeaderCommands extends BaseCommand {
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
|
||||
@Subcommand("%demote")
|
||||
@CommandCompletion("@clan_leaders")
|
||||
@@ -48,7 +52,7 @@ 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));
|
||||
@@ -80,7 +84,7 @@ 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) {
|
||||
if (settings.is(CLAN_CONFIRMATION_FOR_PROMOTE) && clan.getLeaders().size() > 1) {
|
||||
requestManager.addPromoteRequest(cp, otherPl.getName(), clan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("promotion.vote.has.been.requested.from.all.leaders",
|
||||
player));
|
||||
@@ -113,12 +117,12 @@ 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;
|
||||
}
|
||||
@@ -177,4 +181,38 @@ public class LeaderCommands extends BaseCommand {
|
||||
trustedInput.setTrusted(false);
|
||||
storage.updateClanPlayer(trustedInput);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
double amount = settings.getDouble(ECONOMY_DISCORD_CREATION_PRICE);
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!permissions.playerChargeMoney(player, amount)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
discordHook.createChannel(clan.getTag());
|
||||
ChatBlock.sendMessage(player, AQUA + "discord.created.successfully");
|
||||
} catch (DiscordHookException ex) {
|
||||
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 -> 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());
|
||||
}
|
||||
}
|
||||
+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
-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());
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -9,6 +9,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextResolver<ClanPlayerInput> {
|
||||
public ClanPlayerInputContextResolver(@NotNull SimpleClans plugin) {
|
||||
@@ -22,6 +24,9 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
if (cp == null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(arg);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
throw new InvalidCommandArgument(lang("user.hasnt.played.before", context.getSender()));
|
||||
}
|
||||
cp = clanManager.getCreateClanPlayer(offlinePlayer.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
+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,6 +1,7 @@
|
||||
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;
|
||||
@@ -9,6 +10,7 @@ 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 {
|
||||
@@ -35,10 +37,10 @@ public class ClanRoster extends Sendable {
|
||||
for (ClanPlayer cp : members) {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = (cp.isTrusted() ? sm.getPageTrustedColor() : sm.getPageUnTrustedColor()) + cp.getName();
|
||||
String name = (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR)) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,22 +50,22 @@ public class ClanRoster extends Sendable {
|
||||
for (ClanPlayer cp : leaders) {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = sm.getPageLeaderColor() + cp.getName();
|
||||
String name = sm.getColored(PAGE_LEADER_COLOR) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender)
|
||||
: WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
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);
|
||||
@@ -56,8 +57,8 @@ 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 name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) :
|
||||
sm.getColored(PAGE_UNTRUSTED_COLOR)) + cpm.getName());
|
||||
String rival = NumberFormat.getInstance().format(cpm.getRivalKills());
|
||||
String neutral = NumberFormat.getInstance().format(cpm.getNeutralKills());
|
||||
String civilian = NumberFormat.getInstance().format(cpm.getCivilianKills());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,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 {
|
||||
@@ -38,8 +39,8 @@ public class Leaderboard extends Sendable {
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
boolean online = cp.toPlayer() != null;
|
||||
|
||||
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 +56,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());
|
||||
|
||||
+42
-14
@@ -13,23 +13,26 @@ 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.SCConversation;
|
||||
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.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")
|
||||
@@ -52,7 +55,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@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(),
|
||||
@@ -74,8 +77,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 +94,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 +123,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 +131,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) {
|
||||
@@ -158,7 +161,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@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;
|
||||
}
|
||||
@@ -200,12 +203,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 +237,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.getBalance());
|
||||
sender.sendMessage(line);
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%list")
|
||||
@CommandPermission("simpleclans.anyone.list")
|
||||
@Description("{@@command.description.list}")
|
||||
|
||||
@@ -7,6 +7,7 @@ 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 org.bukkit.command.CommandSender;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.RED;
|
||||
@@ -39,7 +40,7 @@ public class BankCommand extends BaseCommand {
|
||||
switch (economyResponse) {
|
||||
case SUCCESS:
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.take", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.take", sender, amount));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.take", sender, amount, sender.getName()));
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
sender.sendMessage(RED + lang("clan.admin.bank.not.enough.money", sender, clan.getName()));
|
||||
@@ -58,7 +59,7 @@ public class BankCommand extends BaseCommand {
|
||||
EconomyResponse economyResponse = clan.deposit(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
if (economyResponse == EconomyResponse.SUCCESS) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.give", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.give", sender, amount));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.give", sender, amount, sender.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +71,10 @@ public class BankCommand extends BaseCommand {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
|
||||
EconomyResponse response = clan.setBalance(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
EconomyResponse response = clan.setBalance(sender, ClanBalanceUpdateEvent.Cause.COMMAND, BankLogger.Operation.SET, amount);
|
||||
if (response == EconomyResponse.SUCCESS) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.set", sender, clan.getName(), amount));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.set", sender, amount));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.set", sender, amount, sender.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.staff;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Dependency;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Name;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
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.StorageManager;
|
||||
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.WHITE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions")
|
||||
@Subcommand("%mod %bb")
|
||||
public class BbCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
|
||||
@Default
|
||||
@CommandPermission("simpleclans.mod.bb")
|
||||
@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")
|
||||
@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")
|
||||
@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(player.getName(), AQUA + player.getName() + ": " + WHITE + msg);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
}
|
||||
+30
-23
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -26,6 +25,7 @@ import java.util.Objects;
|
||||
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 +49,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") OfflinePlayer offlinePlayer, @Name("clan") ClanInput clanInput) {
|
||||
UUID uuid = offlinePlayer.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(), AQUA + 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(AQUA + lang("joined.the.clan", cp.getName()));
|
||||
cm.serverAnnounce(lang("has.joined", cp.getName(), newClan.getName()));
|
||||
newClan.addPlayerToClan(cp);
|
||||
}
|
||||
|
||||
@Subcommand("%mod %modtag")
|
||||
@@ -113,7 +114,7 @@ public class StaffCommands extends BaseCommand {
|
||||
storage.saveModified();
|
||||
plugin.reloadConfig();
|
||||
LanguageResource.clearCache();
|
||||
settings.load();
|
||||
settings.loadAndSave();
|
||||
storage.importFromDatabase();
|
||||
permissions.loadPermissions();
|
||||
|
||||
@@ -194,10 +195,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 +207,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));
|
||||
}
|
||||
@@ -257,7 +258,7 @@ 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;
|
||||
}
|
||||
@@ -280,13 +281,14 @@ 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;
|
||||
@@ -304,12 +306,17 @@ 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()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.demoted", sender));
|
||||
}
|
||||
|
||||
+14
-13
@@ -5,9 +5,7 @@ import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PreCreateClanEvent;
|
||||
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 +15,9 @@ 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 org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class CreateClanNamePrompt extends StringPrompt {
|
||||
public static final String NAME_KEY = "name";
|
||||
@@ -65,16 +66,16 @@ public class CreateClanNamePrompt extends StringPrompt {
|
||||
plugin.getClanManager().createClan(player, tag, name);
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(tag);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA +
|
||||
clan.addBb(player.getName(), AQUA +
|
||||
lang("clan.created", name));
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
|
||||
if (plugin.getSettingsManager().isRequireVerification()) {
|
||||
boolean verified = !plugin.getSettingsManager().isRequireVerification()
|
||||
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, ChatColor.AQUA +
|
||||
ChatBlock.sendMessage(player, AQUA +
|
||||
lang("get.your.clan.verified.to.access.advanced.features", player));
|
||||
}
|
||||
}
|
||||
@@ -85,19 +86,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);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,10 +18,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 +40,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();
|
||||
}
|
||||
|
||||
+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));
|
||||
}
|
||||
}
|
||||
+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)));
|
||||
}
|
||||
}
|
||||
-4
@@ -5,14 +5,11 @@ import org.bukkit.conversations.Prompt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class MessagePromptImpl extends org.bukkit.conversations.MessagePrompt {
|
||||
|
||||
private final String message;
|
||||
private Prompt nextPrompt;
|
||||
|
||||
public MessagePromptImpl(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
@@ -31,5 +28,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);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -16,6 +15,8 @@ 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
|
||||
@@ -27,7 +28,7 @@ public class ResignPrompt extends StringPrompt {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
|
||||
Player player = (Player) cc.getForWhom();
|
||||
String yes = lang("resign.yes", player);
|
||||
String yes = lang("yes", player);
|
||||
ClanManager cm = Objects.requireNonNull(plugin).getClanManager();
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
@@ -37,28 +38,28 @@ public class ResignPrompt extends StringPrompt {
|
||||
|
||||
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()));
|
||||
clan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("resign.success", player));
|
||||
return new MessagePromptImpl(AQUA + lang("resign.success", player));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband(player, true, false);
|
||||
return null;
|
||||
return new MessagePromptImpl(RED + lang("clan.has.been.disbanded", player, clan.getName()));
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
return new MessagePromptImpl(RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
}
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("resign.request.cancelled", player));
|
||||
return new MessagePromptImpl(RED + lang("resign.request.cancelled", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext cc) {
|
||||
Player player = (Player) cc.getForWhom();
|
||||
return ChatColor.RED + MessageFormat.format(
|
||||
return RED + MessageFormat.format(
|
||||
lang("resign.confirmation", player), Arrays.asList(
|
||||
lang("resign.yes", player), lang("resign.no", player)));
|
||||
lang("yes", player), lang("cancel", player)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationCanceller;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SCConversation extends Conversation {
|
||||
private static final Map<UUID, SCConversation> conversations = new HashMap<>();
|
||||
|
||||
public SCConversation(@NotNull Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt) {
|
||||
this(plugin, forWhom, firstPrompt, new HashMap<>(), 10);
|
||||
}
|
||||
|
||||
public SCConversation(@NotNull Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt, int timeout) {
|
||||
this(plugin, forWhom, firstPrompt, new HashMap<>(), timeout);
|
||||
}
|
||||
|
||||
public SCConversation(@NotNull Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt, @NotNull Map<Object, Object> initialSessionData) {
|
||||
this(plugin, forWhom, firstPrompt, initialSessionData, 10);
|
||||
}
|
||||
|
||||
public SCConversation(@NotNull Plugin plugin, @NotNull Conversable forWhom, @Nullable Prompt firstPrompt, @NotNull Map<Object, Object> initialSessionData, int timeout) {
|
||||
super(plugin, forWhom, firstPrompt, initialSessionData);
|
||||
this.setLocalEchoEnabled(true);
|
||||
this.addConversationCanceller(new InactivityCanceller(plugin, timeout));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void begin() {
|
||||
UUID uniqueId = ((Player) getForWhom()).getUniqueId();
|
||||
SCConversation oldConversation = conversations.get(uniqueId);
|
||||
|
||||
if (oldConversation != this && oldConversation != null) {
|
||||
getForWhom().abandonConversation(oldConversation);
|
||||
}
|
||||
|
||||
conversations.put(uniqueId, this);
|
||||
super.begin();
|
||||
}
|
||||
|
||||
public void addConversationCanceller(@NotNull ConversationCanceller canceller) {
|
||||
canceller.setConversation(this);
|
||||
cancellers.add(canceller);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,25 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public class ChatEvent extends Event implements Cancellable {
|
||||
|
||||
/*
|
||||
* Todo: refactor Type to Channel in 3.0
|
||||
*/
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private String message;
|
||||
private final ClanPlayer sender;
|
||||
@@ -23,7 +27,7 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
private final Map<String, String> placeholders = new HashMap<>();
|
||||
private final Type type;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
public ChatEvent(String message, ClanPlayer sender, List<ClanPlayer> receivers, Type type) {
|
||||
if (message == null || sender == null || receivers == null || type == null) {
|
||||
throw new IllegalArgumentException("none of the args can be null");
|
||||
@@ -32,7 +36,7 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
this.sender = sender;
|
||||
this.receivers = receivers;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
@@ -47,9 +51,10 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
public enum Type {
|
||||
ALLY, CLAN
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the chat type
|
||||
*
|
||||
* @return the chat type
|
||||
*/
|
||||
public Type getType() {
|
||||
@@ -69,10 +74,10 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
* Adds a placeholder and its value to the chat message
|
||||
*
|
||||
* @param placeholderName the placeholder name
|
||||
* @param value the String to be replaced
|
||||
* @param value the String to be replaced
|
||||
* @throws IllegalArgumentException if one of the args are null; if one of
|
||||
* the args are empty; if the placeholder name equals "clan", "nick-color",
|
||||
* "player", "rank" or "message"
|
||||
* the args are empty; if the placeholder name equals "clan", "nick-color",
|
||||
* "player", "rank" or "message"
|
||||
*/
|
||||
public void addPlaceholder(String placeholderName, String value) {
|
||||
if (placeholderName == null || value == null) {
|
||||
@@ -107,6 +112,7 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Changes the chat message
|
||||
*
|
||||
* @param message the new message
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -11,9 +14,14 @@ import org.bukkit.event.HandlerList;
|
||||
public class DisbandClanEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final CommandSender sender;
|
||||
private final Clan clan;
|
||||
|
||||
public DisbandClanEvent(Clan clan) {
|
||||
public DisbandClanEvent(CommandSender sender, Clan clan) {
|
||||
if (sender == null) {
|
||||
sender = Bukkit.getConsoleSender();
|
||||
}
|
||||
this.sender = sender;
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
@@ -21,6 +29,10 @@ public class DisbandClanEvent extends Event {
|
||||
return this.clan;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -0,0 +1,646 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.AccountLinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.AccountUnlinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent;
|
||||
import github.scarsz.discordsrv.dependencies.commons.lang3.StringUtils;
|
||||
import github.scarsz.discordsrv.dependencies.emoji.EmojiParser;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.Permission;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.*;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.requests.RestAction;
|
||||
import github.scarsz.discordsrv.dependencies.kyori.adventure.text.Component;
|
||||
import github.scarsz.discordsrv.objects.managers.AccountLinkManager;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import github.scarsz.discordsrv.util.MessageUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static github.scarsz.discordsrv.dependencies.jda.api.Permission.VIEW_CHANNEL;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook.DiscordAction.ADD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook.DiscordAction.REMOVE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
/**
|
||||
* Hooks SimpleClans and Discord, using DiscordSRV.
|
||||
* <p>
|
||||
* On server' startup:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Creates categories and channels, respecting discord's limits.</li>
|
||||
* <li>Removes invalid channels, resets permissions and roles.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Manages events:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Clan creation/deletion</li>
|
||||
* <li>ClanPlayer joining/resigning</li>
|
||||
* <li>Player linking/unlinking</li>
|
||||
* <li>ClanPlayer promoting/demoting</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Currently, works with clan chat only.
|
||||
*/
|
||||
public class DiscordHook implements Listener {
|
||||
|
||||
private static final int MAX_CHANNELS_PER_CATEGORY = 50;
|
||||
private static final int MAX_CHANNELS_PER_GUILD = 500;
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final SettingsManager settingsManager;
|
||||
private final ChatManager chatManager;
|
||||
private final ClanManager clanManager;
|
||||
private final AccountLinkManager accountManager = DiscordSRV.getPlugin().getAccountLinkManager();
|
||||
|
||||
private final Guild guild = DiscordSRV.getPlugin().getMainGuild();
|
||||
private final List<String> textCategories;
|
||||
private final List<String> discordClanTags;
|
||||
private final List<String> clanTags;
|
||||
private final Role leaderRole;
|
||||
private final List<String> whitelist;
|
||||
|
||||
public DiscordHook(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
settingsManager = plugin.getSettingsManager();
|
||||
chatManager = plugin.getChatManager();
|
||||
clanManager = plugin.getClanManager();
|
||||
textCategories = settingsManager.getStringList(DISCORDCHAT_TEXT_CATEGORY_IDS).stream().
|
||||
filter(this::categoryExists).collect(Collectors.toList());
|
||||
whitelist = settingsManager.getStringList(DISCORDCHAT_TEXT_WHITELIST);
|
||||
|
||||
clanTags = clanManager.getClans().stream().map(Clan::getTag).collect(Collectors.toList());
|
||||
discordClanTags = getCachedChannels().stream().map(GuildChannel::getName).collect(Collectors.toList());
|
||||
|
||||
leaderRole = getLeaderRole();
|
||||
setupDiscord();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMessageReceived(DiscordGuildMessageReceivedEvent event) {
|
||||
Optional<TextChannel> channel = getCachedChannel(event.getChannel().getName());
|
||||
|
||||
if (channel.isPresent()) {
|
||||
Message eventMessage = event.getMessage();
|
||||
User Author = event.getAuthor();
|
||||
TextChannel textChannel = channel.get();
|
||||
UUID uuid = accountManager.getUuid(Author.getId());
|
||||
|
||||
if (uuid == null) {
|
||||
sendPrivateMessage(textChannel, eventMessage, lang("you.did.not.link.your.account"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(uuid);
|
||||
if (clanPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Objects.equals(textChannel.getName(), clan.getTag())) {
|
||||
String channelLink = "<#" + textChannel.getId() + ">";
|
||||
sendPrivateMessage(textChannel, eventMessage, lang("cannot.send.discord.message", clanPlayer, channelLink));
|
||||
return;
|
||||
}
|
||||
// DiscordSRV start
|
||||
String emojiBehavior = DiscordSRV.config().getString("DiscordChatChannelEmojiBehavior");
|
||||
|
||||
boolean hideEmoji = emojiBehavior.equalsIgnoreCase("hide");
|
||||
boolean nameEmoji = emojiBehavior.equalsIgnoreCase("name");
|
||||
|
||||
Component component = MessageUtil.reserializeToMinecraft(eventMessage.getContentRaw());
|
||||
String message = MessageUtil.toLegacy(component);
|
||||
|
||||
if (hideEmoji && StringUtils.isBlank(EmojiParser.removeAllEmojis(message))) {
|
||||
DiscordSRV.debug("Ignoring message from "
|
||||
+ Author.getName() +
|
||||
" because it became completely blank after removing unicode emojis");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hideEmoji) {
|
||||
// remove all emojis
|
||||
message = EmojiParser.removeAllEmojis(message);
|
||||
} else if (nameEmoji) {
|
||||
// parse emojis from unicode back to :code:
|
||||
message = EmojiParser.parseToAliases(message);
|
||||
}
|
||||
// DiscordSRV end
|
||||
chatManager.processChat(DISCORD, CLAN, clanPlayer, message);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanDisband(DisbandClanEvent event) {
|
||||
deleteChannel(event.getClan().getTag());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanCreate(CreateClanEvent event) {
|
||||
try {
|
||||
createChannel(event.getClan().getTag());
|
||||
} catch (DiscordHookException ex) {
|
||||
// Clan is not following the conditions, categories are fulled or discord reaches the limit, nothing to do here.
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanLeave(PlayerKickedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Clan clan = clanPlayer.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null || clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, REMOVE);
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanJoin(PlayerJoinedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Clan clan = clanPlayer.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null || clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createChannelSilently(clanPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPromote(PlayerPromoteEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLeaderRole(member, clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDemote(PlayerDemoteEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerLinking(AccountLinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
Member member = guild.getMember(event.getUser());
|
||||
if (clanPlayer == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createChannelSilently(clanPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, ADD);
|
||||
updateLeaderRole(member, clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerUnlinking(AccountUnlinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
Member member = guild.getMember(event.getDiscordUser());
|
||||
if (clanPlayer == null || clanPlayer.getClan() == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clanPlayer.getClan(), REMOVE);
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
protected void setupDiscord() {
|
||||
clearChannels();
|
||||
resetPermissions();
|
||||
createChannels();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Guild getGuild() {
|
||||
return guild;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A leader role from guild, otherwise creates one.
|
||||
*/
|
||||
@NotNull
|
||||
public Role getLeaderRole() {
|
||||
Role role = guild.getRoleById(settingsManager.getString(DISCORDCHAT_LEADER_ID));
|
||||
|
||||
if (role == null || !role.getName().equals(settingsManager.getString(DISCORDCHAT_LEADER_ROLE))) {
|
||||
role = guild.createRole().
|
||||
setName(settingsManager.getString(DISCORDCHAT_LEADER_ROLE)).
|
||||
setColor(getLeaderColor()).
|
||||
setMentionable(true).
|
||||
complete();
|
||||
|
||||
settingsManager.set(DISCORDCHAT_LEADER_ID, role.getId());
|
||||
settingsManager.save();
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A leader color from configuration
|
||||
*/
|
||||
public Color getLeaderColor() {
|
||||
String[] colors = settingsManager.getString(DISCORDCHAT_LEADER_COLOR).
|
||||
replaceAll("\\s", "").split(",");
|
||||
try {
|
||||
int red = Integer.parseInt(colors[0]);
|
||||
int green = Integer.parseInt(colors[1]);
|
||||
int blue = Integer.parseInt(colors[2]);
|
||||
int alpha = Integer.parseInt(colors[3]);
|
||||
|
||||
return new Color(red, green, blue, alpha);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
plugin.getLogger().warning("Color is invalid, using default color: " + ex.getMessage());
|
||||
return Color.RED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SimpleClans {@link Category}
|
||||
*
|
||||
* @return Category or null, if reached the limit
|
||||
*/
|
||||
@Nullable
|
||||
public Category createCategory() {
|
||||
if (guild.getChannels().size() >= MAX_CHANNELS_PER_GUILD) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String categoryName = settingsManager.getString(DISCORDCHAT_TEXT_CATEGORY_FORMAT);
|
||||
Category category = null;
|
||||
try {
|
||||
category = guild.createCategory(categoryName).
|
||||
addRolePermissionOverride(
|
||||
guild.getPublicRole().getIdLong(),
|
||||
Collections.emptyList(),
|
||||
Collections.singletonList(VIEW_CHANNEL)).
|
||||
submit().get();
|
||||
|
||||
textCategories.add(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while trying to create {0} category: " +
|
||||
ex.getMessage(), categoryName);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link TextChannel} in available SimpleClans' categories,
|
||||
* otherwise creates one.
|
||||
*
|
||||
* <p>Sets positive {@link Permission#VIEW_CHANNEL} permission to all linked clan members.</p>
|
||||
*
|
||||
* @param clanTag the clan tag
|
||||
*
|
||||
* @throws InvalidChannelException clan is not verified or permanent,
|
||||
* no one member is linked or clan is not in the whitelist.
|
||||
* @throws ChannelExistsException if channel is already exist
|
||||
* @throws CategoriesLimitException if categories reached the limit.
|
||||
* @throws ChannelsLimitException if discord reached the channels limit.
|
||||
*/
|
||||
public void createChannel(@NotNull String clanTag)
|
||||
throws InvalidChannelException, CategoriesLimitException, ChannelsLimitException, ChannelExistsException {
|
||||
validateChannel(clanTag);
|
||||
Map<ClanPlayer, Member> discordClanPlayers = getDiscordPlayers(clanManager.getClan(clanTag));
|
||||
|
||||
if (getChannels().size() >= settingsManager.getInt(DISCORDCHAT_TEXT_LIMIT)) {
|
||||
throw new ChannelsLimitException("Discord reached the channels limit", "discord.reached.channels.limit");
|
||||
}
|
||||
|
||||
Category availableCategory = getCachedCategories().stream().
|
||||
filter(category -> category.getTextChannels().size() < MAX_CHANNELS_PER_CATEGORY).
|
||||
findAny().orElseGet(this::createCategory);
|
||||
|
||||
if (availableCategory == null) {
|
||||
throw new CategoriesLimitException("Discord reached the categories limit", "discord.reached.category.limit");
|
||||
}
|
||||
|
||||
TextChannel textChannel = availableCategory.createTextChannel(clanTag).complete();
|
||||
|
||||
for (Map.Entry<ClanPlayer, Member> entry : discordClanPlayers.entrySet()) {
|
||||
// The map is formed from clan#getMembers (so the clan exists)
|
||||
//noinspection ConstantConditions
|
||||
updateViewPermission(entry.getValue(), entry.getKey().getClan(), ADD);
|
||||
updateLeaderRole(entry.getValue(), entry.getKey(), ADD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves channel in SimpleClans categories.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
*
|
||||
* @see #getCachedCategories() retreive categories.
|
||||
*
|
||||
* @return the channel
|
||||
*/
|
||||
public Optional<TextChannel> getCachedChannel(@NotNull String channelName) {
|
||||
return getCachedChannels().stream().filter(textChannel -> textChannel.getName().equals(channelName)).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a category can be obtained by id.
|
||||
*
|
||||
* @param categoryId the category id
|
||||
* @see #channelExists(String)
|
||||
*
|
||||
* @return true if the category exists
|
||||
*/
|
||||
public boolean categoryExists(String categoryId) {
|
||||
return guild.getCategoryById(categoryId) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a channel with the specified clan tag exists
|
||||
*
|
||||
* @see #categoryExists(String)
|
||||
*/
|
||||
public boolean channelExists(String clanTag) {
|
||||
return getChannels().stream().map(TextChannel::getName).anyMatch(name -> name.equals(clanTag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes channel from SimpleClans categories.
|
||||
* If there are no channels, removes category as well.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
*
|
||||
* @return true, if channel was deleted and false if not.
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public boolean deleteChannel(@NotNull String channelName) {
|
||||
if (channelExists(channelName)) {
|
||||
for (Category category : getCachedCategories()) {
|
||||
if (category.getTextChannels().size() > 0) {
|
||||
for (TextChannel textChannel : category.getTextChannels()) {
|
||||
if (textChannel.getName().equals(channelName)) {
|
||||
textChannel.delete().complete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (category.getTextChannels().size() == 0) {
|
||||
textCategories.remove(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
category.delete().complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return categories from config
|
||||
*/
|
||||
public List<Category> getCachedCategories() {
|
||||
return textCategories.stream().
|
||||
filter(this::categoryExists).
|
||||
map(guild::getCategoryById).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* In most cases, you will use {@link #getCachedCategories()}.
|
||||
*
|
||||
* @return categories from guild
|
||||
*/
|
||||
public List<Category> getCategories() {
|
||||
return guild.getCategoriesByName(settingsManager.getString(DISCORDCHAT_TEXT_CATEGORY_FORMAT), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* In most cases, you will use {@link #getCachedChannels()}.
|
||||
*
|
||||
* @return all channels from guild
|
||||
*/
|
||||
public List<TextChannel> getChannels() {
|
||||
return getCategories().stream().map(Category::getTextChannels).flatMap(Collection::stream).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return All channels in categories
|
||||
*/
|
||||
public List<TextChannel> getCachedChannels() {
|
||||
return getCachedCategories().stream().map(Category::getTextChannels).flatMap(Collection::stream).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Member getMember(@NotNull ClanPlayer clanPlayer) {
|
||||
String discordId = accountManager.getDiscordId(clanPlayer.getUniqueId());
|
||||
return DiscordUtil.getMemberById(discordId);
|
||||
}
|
||||
|
||||
private void clearChannels() {
|
||||
// Removes abandoned channels
|
||||
ArrayList<String> clansToDelete = new ArrayList<>(discordClanTags);
|
||||
clansToDelete.removeAll(clanTags);
|
||||
clansToDelete.forEach(this::deleteChannel);
|
||||
|
||||
// Removes invalid channels
|
||||
for (String clanTag : clanTags) {
|
||||
try {
|
||||
validateChannel(clanTag);
|
||||
} catch (InvalidChannelException ex) {
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
deleteChannel(clanTag);
|
||||
|
||||
} catch (ChannelExistsException | ChannelsLimitException ex) {
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetPermissions() {
|
||||
getCachedChannels().stream().
|
||||
map(TextChannel::getMemberPermissionOverrides).
|
||||
flatMap(Collection::stream).
|
||||
filter(permissionOverride -> !Objects.equals(permissionOverride.getPermissionHolder(), guild.getPublicRole())).
|
||||
forEach(permissionOverride -> permissionOverride.delete().queue());
|
||||
|
||||
clanTags.stream().map(clanManager::getClan).
|
||||
filter(Objects::nonNull).
|
||||
map(Clan::getMembers).
|
||||
flatMap(Collection::stream).
|
||||
forEach(clanPlayer -> {
|
||||
Member member = getMember(clanPlayer);
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (member != null && clan != null) {
|
||||
updateViewPermission(member, clan, ADD);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createChannels() {
|
||||
if (!settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
return;
|
||||
}
|
||||
for (String clan : clanTags) {
|
||||
try {
|
||||
createChannel(clan);
|
||||
} catch (CategoriesLimitException | ChannelsLimitException ex) {
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
break;
|
||||
} catch (InvalidChannelException | ChannelExistsException ignored) {
|
||||
// There is already debug on #clearChannels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
private void sendPrivateMessage(TextChannel textChannel, Message eventMessage, String message) {
|
||||
RestAction<PrivateChannel> privateChannelAction = eventMessage.getAuthor().openPrivateChannel();
|
||||
textChannel.deleteMessageById(eventMessage.getId()).queue(unused -> {
|
||||
String channelLink = "<#" + textChannel.getId() + ">";
|
||||
privateChannelAction.flatMap(privateChannel -> privateChannel.sendMessage(message));
|
||||
});
|
||||
}
|
||||
|
||||
private void validateChannel(@NotNull String clanTag)
|
||||
throws InvalidChannelException, ChannelExistsException, ChannelsLimitException {
|
||||
Clan clan = clanManager.getClan(clanTag);
|
||||
if (clan == null) {
|
||||
throw new InvalidChannelException(String.format("Clan %s is null", clanTag));
|
||||
}
|
||||
if (!clan.isVerified() && !clan.isPermanent()) {
|
||||
throw new InvalidChannelException(String.format("Clan %s is not verified or permanent", clanTag));
|
||||
}
|
||||
|
||||
Map<ClanPlayer, Member> discordClanPlayers = getDiscordPlayers(clan);
|
||||
if (discordClanPlayers.size() == 0) {
|
||||
throw new InvalidChannelException(String.format("Clan %s doesn't have any linked players", clanTag),
|
||||
"your.clan.doesnt.have.any.linked.player");
|
||||
}
|
||||
|
||||
if (discordClanPlayers.size() < settingsManager.getInt(DISCORDCHAT_MINIMUM_LINKED_PLAYERS)) {
|
||||
throw new InvalidChannelException(String.format("Clan %s doesn't have minimum linked players", clanTag),
|
||||
"your.clan.doesnt.have.minimum.linked.player");
|
||||
}
|
||||
|
||||
if (!whitelist.isEmpty() && !whitelist.contains(clan.getTag())) {
|
||||
throw new InvalidChannelException(String.format("Clan %s is not listed on the whitelist", clanTag),
|
||||
"your.clan.is.not.on.the.whitelist");
|
||||
}
|
||||
|
||||
if (channelExists(clanTag)) {
|
||||
throw new ChannelExistsException(String.format("Channel %s is already exist", clanTag),
|
||||
"your.clan.already.has.channel");
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<ClanPlayer, Member> getDiscordPlayers(@NotNull Clan clan) {
|
||||
Map<ClanPlayer, Member> discordClanPlayers = new HashMap<>();
|
||||
for (ClanPlayer cp : clan.getMembers()) {
|
||||
Member member = getMember(cp);
|
||||
if (member != null) {
|
||||
discordClanPlayers.put(cp, member);
|
||||
}
|
||||
}
|
||||
return discordClanPlayers;
|
||||
}
|
||||
|
||||
private void updateLeaderRole(@NotNull Member member, @NotNull ClanPlayer clanPlayer, DiscordAction action) {
|
||||
if (!clanPlayer.isLeader()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == ADD) {
|
||||
guild.addRoleToMember(member, leaderRole).queue();
|
||||
} else {
|
||||
guild.removeRoleFromMember(member, leaderRole).queue();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViewPermission(@NotNull Member member, @NotNull Clan clan, DiscordAction action) {
|
||||
Optional<TextChannel> channel = getCachedChannel(clan.getTag());
|
||||
if (channel.isPresent()) {
|
||||
TextChannel textChannel = channel.get();
|
||||
|
||||
if (action == ADD) {
|
||||
textChannel.upsertPermissionOverride(member).
|
||||
setPermissions(Collections.singletonList(VIEW_CHANNEL), Collections.emptyList()).queue();
|
||||
} else {
|
||||
textChannel.getManager().removePermissionOverride(member).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
private boolean createChannelSilently(ClanPlayer clanPlayer) {
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
createChannel(clan.getTag());
|
||||
} catch (DiscordHookException ex) {
|
||||
// Clan is not following the conditions, categories are fulled or discord reaches the limit, nothing to do here.
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum DiscordAction {
|
||||
ADD, REMOVE
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class CategoriesLimitException extends DiscordHookException {
|
||||
|
||||
public CategoriesLimitException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class ChannelExistsException extends DiscordHookException {
|
||||
|
||||
public ChannelExistsException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class ChannelsLimitException extends DiscordHookException {
|
||||
|
||||
public ChannelsLimitException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Superclass of all discord exceptions
|
||||
*
|
||||
* @see InvalidChannelException
|
||||
* @see ChannelsLimitException
|
||||
* @see ChannelExistsException
|
||||
* @see CategoriesLimitException
|
||||
*/
|
||||
public class DiscordHookException extends Exception {
|
||||
|
||||
private String messageKey;
|
||||
|
||||
public DiscordHookException(String debugMessage) {
|
||||
super(debugMessage);
|
||||
}
|
||||
|
||||
public DiscordHookException(String debugMessage, String messageKey) {
|
||||
super(debugMessage);
|
||||
this.messageKey = messageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message key or null if this key is not used in-game
|
||||
*/
|
||||
public @Nullable String getMessageKey() {
|
||||
return messageKey;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class InvalidChannelException extends DiscordHookException {
|
||||
|
||||
public InvalidChannelException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
|
||||
public InvalidChannelException(String debugMessage) {
|
||||
super(debugMessage);
|
||||
}
|
||||
}
|
||||
+2
@@ -31,6 +31,8 @@ public abstract class PlaceholderResolver {
|
||||
* @param method the annotated method
|
||||
* @param placeholder the placeholder to resolve
|
||||
* @param config configuration for the resolver
|
||||
*
|
||||
* @return the resolved placeholder
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
|
||||
+58
-16
@@ -1,14 +1,17 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
|
||||
|
||||
import me.clip.placeholderapi.expansion.Configurable;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.Relational;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -18,7 +21,7 @@ import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SimpleClansExpansion extends PlaceholderExpansion {
|
||||
public class SimpleClansExpansion extends PlaceholderExpansion implements Relational, Configurable {
|
||||
|
||||
private static final Pattern TOP_CLANS_PATTERN = Pattern.compile("(?<strip>^topclans_(?<position>\\d+)_)clan_");
|
||||
private static final Pattern TOP_PLAYERS_PATTERN = Pattern.compile("(?<strip>^topplayers_(?<position>\\d+)_)");
|
||||
@@ -68,27 +71,54 @@ public class SimpleClansExpansion extends PlaceholderExpansion {
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
private void addPlaceholders(String prefix, Class<?> clazz, List<String> placeholders) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
Placeholder[] annotations = method.getAnnotationsByType(Placeholder.class);
|
||||
for (Placeholder annotation : annotations) {
|
||||
placeholders.add("%" + prefix + annotation.value() + "%");
|
||||
//Commented because the list would be very long
|
||||
//placeholders.add("%simpleclans_topplayers_<number>_" + annotation.value() + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDefaults() {
|
||||
Map<String, Object> defaults = new HashMap<>();
|
||||
|
||||
defaults.put("color.rival", "&c");
|
||||
defaults.put("color.ally", "&b");
|
||||
defaults.put("color.same_clan", "&a");
|
||||
|
||||
return defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String onPlaceholderRequest(Player player1, Player player2, String params) {
|
||||
if (player1 == null || player2 == null) {
|
||||
return null;
|
||||
}
|
||||
if (params.equalsIgnoreCase("color")) {
|
||||
ClanPlayer cp1 = clanManager.getClanPlayer(player1);
|
||||
if (cp1 == null) {
|
||||
return "";
|
||||
}
|
||||
//noinspection ConstantConditions -- getClanPlayer != null == getClan() != null
|
||||
if (cp1.getClan().isMember(player2)) {
|
||||
return getString("color.same_clan", null);
|
||||
}
|
||||
if (cp1.isRival(player2)) {
|
||||
return getString("color.rival", null);
|
||||
}
|
||||
if (cp1.isAlly(player2)) {
|
||||
return getString("color.ally", null);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String params) {
|
||||
ClanPlayer cp = null;
|
||||
if (player != null) {
|
||||
cp = clanManager.getAnyClanPlayer(player.getUniqueId());
|
||||
cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
}
|
||||
Clan clan = cp != null ? cp.getClan() : null;
|
||||
Matcher matcher = TOP_CLANS_PATTERN.matcher(params);
|
||||
@@ -167,8 +197,9 @@ public class SimpleClansExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
private void registerResolvers() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers");
|
||||
Set<Class<? extends PlaceholderResolver>> resolvers = reflections.getSubTypesOf(PlaceholderResolver.class);
|
||||
Set<Class<? extends PlaceholderResolver>> resolvers =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers",
|
||||
PlaceholderResolver.class);
|
||||
plugin.getLogger().info(String.format("Registering %d placeholder resolvers...", resolvers.size()));
|
||||
for (Class<? extends PlaceholderResolver> r : resolvers) {
|
||||
try {
|
||||
@@ -181,4 +212,15 @@ public class SimpleClansExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlaceholders(String prefix, Class<?> clazz, List<String> placeholders) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
Placeholder[] annotations = method.getAnnotationsByType(Placeholder.class);
|
||||
for (Placeholder annotation : annotations) {
|
||||
placeholders.add("%" + prefix + annotation.value() + "%");
|
||||
//Commented because the list would be very long
|
||||
//placeholders.add("%simpleclans_topplayers_<number>_" + annotation.value() + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+13
-6
@@ -3,6 +3,7 @@ package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -10,10 +11,16 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerColorResolver extends PlaceholderResolver {
|
||||
|
||||
private final SettingsManager settings;
|
||||
|
||||
public PlayerColorResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
settings = plugin.getSettingsManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,26 +46,26 @@ public class PlayerColorResolver extends PlaceholderResolver {
|
||||
|
||||
private String getClanChatColor(ClanPlayer player) {
|
||||
if (player.isLeader()) {
|
||||
return plugin.getSettingsManager().getClanChatLeaderColor();
|
||||
return settings.getColored(CLANCHAT_LEADER_COLOR);
|
||||
}
|
||||
if (player.isTrusted()) {
|
||||
return plugin.getSettingsManager().getClanChatTrustedColor();
|
||||
return settings.getColored(CLANCHAT_TRUSTED_COLOR);
|
||||
}
|
||||
if (player.getClan() != null) {
|
||||
return plugin.getSettingsManager().getClanChatMemberColor();
|
||||
return settings.getColored(CLANCHAT_MEMBER_COLOR);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getAllyChatColor(ClanPlayer player) {
|
||||
if (player.isLeader()) {
|
||||
return plugin.getSettingsManager().getAllyChatLeaderColor();
|
||||
return settings.getColored(ALLYCHAT_LEADER_COLOR);
|
||||
}
|
||||
if (player.isTrusted()) {
|
||||
return plugin.getSettingsManager().getAllyChatTrustedColor();
|
||||
return settings.getColored(ALLYCHAT_TRUSTED_COLOR);
|
||||
}
|
||||
if (player.getClan() != null) {
|
||||
return plugin.getSettingsManager().getAllyChatMemberColor();
|
||||
return settings.getColored(ALLYCHAT_MEMBER_COLOR);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.util.Set;
|
||||
|
||||
public interface ProtectionProvider {
|
||||
|
||||
void setup();
|
||||
void setup() throws LinkageError, Exception;
|
||||
|
||||
@NotNull
|
||||
Set<Land> getLandsAt(@NotNull Location location);
|
||||
|
||||
+28
-10
@@ -6,6 +6,7 @@ import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimCreatedEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
@@ -17,12 +18,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class GriefPreventionProvider implements ProtectionProvider {
|
||||
|
||||
@Override
|
||||
public void setup() {}
|
||||
public void setup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
@@ -33,14 +36,6 @@ public class GriefPreventionProvider implements ProtectionProvider {
|
||||
return Collections.singleton(getLand(claim));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Land getLand(@Nullable Claim claim) {
|
||||
if (claim == null) {
|
||||
return null;
|
||||
}
|
||||
return new Land(getIdPrefix() + claim.getID().toString(), Collections.singleton(claim.getOwnerID()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
@@ -69,7 +64,11 @@ public class GriefPreventionProvider implements ProtectionProvider {
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return ClaimCreatedEvent.class;
|
||||
try {
|
||||
return ClaimCreatedEvent.class;
|
||||
} catch (NoClassDefFoundError error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,4 +85,23 @@ public class GriefPreventionProvider implements ProtectionProvider {
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "GriefPrevention";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Land getLand(@Nullable Claim claim) {
|
||||
if (claim == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Land(getIdPrefix() + claim.getID().toString(), Collections.singleton(getOwnerID(claim)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@NotNull
|
||||
private UUID getOwnerID(@NotNull Claim claim) {
|
||||
try {
|
||||
return claim.getOwnerID();
|
||||
} catch (NoSuchMethodError error) {
|
||||
return Bukkit.getOfflinePlayer(claim.getOwnerName()).getUniqueId();
|
||||
}
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import biz.princeps.landlord.api.ILandLord;
|
||||
import biz.princeps.landlord.api.IOwnedLand;
|
||||
import biz.princeps.landlord.api.events.LandPreClaimEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Landlord4Provider implements ProtectionProvider {
|
||||
|
||||
private ILandLord landlord;
|
||||
|
||||
@Override
|
||||
public void setup() throws LinkageError, Exception {
|
||||
//noinspection ConstantConditions
|
||||
landlord = (ILandLord) Bukkit.getPluginManager().getPlugin("Landlord");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
IOwnedLand ownedLand = landlord.getWGManager().getRegion(location);
|
||||
if (ownedLand == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
lands.add(getLand(ownedLand));
|
||||
return lands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
Set<IOwnedLand> ownedLands = landlord.getWGManager().getRegions(player.getUniqueId(), world);
|
||||
for (IOwnedLand ownedLand : ownedLands) {
|
||||
lands.add(getLand(ownedLand));
|
||||
}
|
||||
return lands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ll";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
|
||||
landlord.getWGManager().unclaim(world, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return LandPreClaimEvent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
if (!(event instanceof LandPreClaimEvent)) {
|
||||
return null;
|
||||
}
|
||||
return ((LandPreClaimEvent) event).getPlayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "Landlord";
|
||||
}
|
||||
|
||||
private @NotNull Land getLand(@NotNull IOwnedLand ownedLand) {
|
||||
String id = getIdPrefix() + ownedLand.getName();
|
||||
HashSet<UUID> owners = new HashSet<>();
|
||||
owners.add(ownedLand.getOwner());
|
||||
|
||||
return new Land(id, owners);
|
||||
}
|
||||
}
|
||||
+4
-8
@@ -28,14 +28,10 @@ public class PlotSquared3Provider implements ProtectionProvider {
|
||||
private Method getPlots;
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
try {
|
||||
Class.forName("com.intellectualcrafters.plot.object.Location");
|
||||
Class.forName("com.intellectualcrafters.plot.object.Plot");
|
||||
getLocation = BukkitUtil.class.getMethod("getLocation", Location.class);
|
||||
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public void setup() throws ClassNotFoundException, NoSuchMethodException {
|
||||
Class.forName("com.intellectualcrafters.plot.object.Location");
|
||||
Class.forName("com.intellectualcrafters.plot.object.Plot");
|
||||
getLocation = BukkitUtil.class.getMethod("getLocation", Location.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSquared5Provider implements ProtectionProvider {
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
Plot plot = BukkitUtil.getPlot(location);
|
||||
if (plot != null) {
|
||||
return Collections.singleton(getLand(plot));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Land getLand(@NotNull Plot plot) {
|
||||
return new Land(getIdPrefix() + plot.getId().toString(), plot.getOwners());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
Set<Plot> plots = PlotSquared.get().getPlots(world.getName(), player.getUniqueId());
|
||||
return plots.stream().map(this::getLand).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
for (Plot plot : PlotSquared.get().getPlots(world.getName())) {
|
||||
if (plot.getId().toString().equals(id)) {
|
||||
plot.deletePlot(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
}
|
||||
+5
-8
@@ -28,15 +28,12 @@ public class WorldGuard6Provider implements ProtectionProvider {
|
||||
private Method getApplicableRegions;
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
public void setup() throws NoSuchMethodException {
|
||||
worldGuard = WorldGuardPlugin.inst();
|
||||
try {
|
||||
getRegionManager = worldGuard.getClass().getMethod("getRegionManager", World.class);
|
||||
//noinspection JavaReflectionMemberAccess
|
||||
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
getRegionManager = worldGuard.getClass().getMethod("getRegionManager", World.class);
|
||||
//noinspection JavaReflectionMemberAccess
|
||||
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
||||
|
||||
}
|
||||
|
||||
private @Nullable RegionManager getRegionManager(@Nullable World world) {
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ public class WorldGuardProvider implements ProtectionProvider {
|
||||
|
||||
private RegionContainer regionContainer;
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
}
|
||||
|
||||
+236
-233
@@ -1,288 +1,291 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.language;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public class LanguageResource {
|
||||
|
||||
private static final ResourceLoader DATA_FOLDER_LOADER = new ResourceLoader(SimpleClans.getInstance().getDataFolder());
|
||||
private final Locale defaultLocale;
|
||||
private static List<Locale> availableLocales;
|
||||
private static final Map<Locale, Integer> TRANSLATION_STATUS = new HashMap<>();
|
||||
private static final ResourceLoader DATA_FOLDER_LOADER = new ResourceLoader(SimpleClans.getInstance().getDataFolder());
|
||||
private final Locale defaultLocale;
|
||||
private static List<Locale> availableLocales;
|
||||
private static final Map<Locale, Integer> TRANSLATION_STATUS = new HashMap<>();
|
||||
|
||||
public LanguageResource() {
|
||||
this.defaultLocale = SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
public LanguageResource() {
|
||||
this.defaultLocale = SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLang(@NotNull String key, @NotNull Locale locale) {
|
||||
if (!key.startsWith("acf-core.parameter.") && key.startsWith("acf")) {
|
||||
return getACFLang(key, locale);
|
||||
}
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("messages", locale, DATA_FOLDER_LOADER,
|
||||
new ResourceControl(defaultLocale, false));
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
if (locale.equals(Locale.ENGLISH)) {
|
||||
// English is the root messages.properties inside the jar
|
||||
locale = Locale.ROOT;
|
||||
}
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("messages", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
@Nullable
|
||||
public String getLang(@NotNull String key, @NotNull Locale locale) {
|
||||
if (!key.startsWith("acf-core.parameter.") && key.startsWith("acf")) {
|
||||
return getACFLang(key, locale);
|
||||
}
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("messages", locale, DATA_FOLDER_LOADER,
|
||||
new ResourceControl(defaultLocale, false));
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
if (locale.equals(Locale.ENGLISH)) {
|
||||
// English is the root messages.properties inside the jar
|
||||
locale = Locale.ROOT;
|
||||
}
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("messages", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getACFMinecraftLang(@NotNull String key, @NotNull Locale locale) {
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-minecraft", locale, DATA_FOLDER_LOADER,
|
||||
new ResourceControl(defaultLocale, false));
|
||||
@Nullable
|
||||
private String getACFMinecraftLang(@NotNull String key, @NotNull Locale locale) {
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-minecraft", locale, DATA_FOLDER_LOADER,
|
||||
new ResourceControl(defaultLocale, false));
|
||||
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-minecraft", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-minecraft", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getACFLang(@NotNull String key, @NotNull Locale locale) {
|
||||
if (key.startsWith("acf-minecraft")) {
|
||||
return getACFMinecraftLang(key, locale);
|
||||
}
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-core", locale, DATA_FOLDER_LOADER,
|
||||
new ResourceControl(defaultLocale, false));
|
||||
@Nullable
|
||||
private String getACFLang(@NotNull String key, @NotNull Locale locale) {
|
||||
if (key.startsWith("acf-minecraft")) {
|
||||
return getACFMinecraftLang(key, locale);
|
||||
}
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-core", locale, DATA_FOLDER_LOADER,
|
||||
new ResourceControl(defaultLocale, false));
|
||||
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-core", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("acf-core", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getTranslationStatus(@NotNull Locale locale) {
|
||||
if (locale.equals(Locale.ENGLISH)) {
|
||||
return 100;
|
||||
}
|
||||
Integer lines = TRANSLATION_STATUS.get(locale);
|
||||
Integer englishLines = TRANSLATION_STATUS.get(Locale.ENGLISH);
|
||||
if (lines == null || englishLines == null) {
|
||||
return -1;
|
||||
}
|
||||
public static int getTranslationStatus(@NotNull Locale locale) {
|
||||
if (locale.equals(Locale.ENGLISH)) {
|
||||
return 100;
|
||||
}
|
||||
Integer lines = TRANSLATION_STATUS.get(locale);
|
||||
Integer englishLines = TRANSLATION_STATUS.get(Locale.ENGLISH);
|
||||
if (lines == null || englishLines == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return Math.round((lines / englishLines.floatValue()) * 100);
|
||||
}
|
||||
return Math.round((lines / englishLines.floatValue()) * 100);
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
ResourceBundle.clearCache(DATA_FOLDER_LOADER);
|
||||
}
|
||||
public static void clearCache() {
|
||||
ResourceBundle.clearCache(DATA_FOLDER_LOADER);
|
||||
}
|
||||
|
||||
public static List<Locale> getAvailableLocales() {
|
||||
if (availableLocales != null) {
|
||||
return availableLocales;
|
||||
}
|
||||
loadAvailableLocales();
|
||||
return availableLocales;
|
||||
}
|
||||
public static List<Locale> getAvailableLocales() {
|
||||
if (availableLocales != null) {
|
||||
return availableLocales;
|
||||
}
|
||||
loadAvailableLocales();
|
||||
return availableLocales;
|
||||
}
|
||||
|
||||
private static void loadAvailableLocales() {
|
||||
ArrayList<Locale> locales = new ArrayList<>();
|
||||
try {
|
||||
URI uri = LanguageResource.class.getProtectionDomain().getCodeSource().getLocation().toURI();
|
||||
FileSystem fileSystem = FileSystems.newFileSystem(URI.create("jar:" + uri.toString()), Collections.emptyMap());
|
||||
Files.walk(fileSystem.getPath("/")).forEach(p -> {
|
||||
String name = p.getFileName() == null ? "" : p.getFileName().toString();
|
||||
if (name.startsWith("messages") && name.endsWith(".properties")) {
|
||||
Locale locale = getLocaleByFileName(name);
|
||||
locales.add(locale);
|
||||
loadTranslationStatus(locale, name);
|
||||
}
|
||||
});
|
||||
fileSystem.close();
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
SimpleClans.getInstance().getLogger().log(Level.WARNING, "An error occurred while getting the available languages", e);
|
||||
}
|
||||
locales.sort(Comparator.comparing(Locale::toLanguageTag));
|
||||
availableLocales = locales;
|
||||
}
|
||||
private static void loadAvailableLocales() {
|
||||
ArrayList<Locale> locales = new ArrayList<>();
|
||||
|
||||
private static @NotNull Locale getLocaleByFileName(@NotNull String name) {
|
||||
Locale locale;
|
||||
if (name.equalsIgnoreCase("messages.properties")) {
|
||||
locale = Locale.ENGLISH;
|
||||
} else {
|
||||
String[] extensionSplit = name.split(".properties");
|
||||
String[] split = extensionSplit[0].split("_");
|
||||
if (split.length == 2) {
|
||||
locale = new Locale(split[1]);
|
||||
} else {
|
||||
locale = new Locale(split[1], split[2]);
|
||||
}
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
Predicate<Path> filter = entry -> {
|
||||
String path = (entry.getFileName() != null) ? entry.getFileName().toString() : "";
|
||||
return path.startsWith("messages") && path.endsWith(".properties");
|
||||
};
|
||||
|
||||
private static void loadTranslationStatus(@NotNull Locale locale, @NotNull String fileName) {
|
||||
InputStream stream = SimpleClans.getInstance().getClass().getResourceAsStream("/" + fileName);
|
||||
if (stream == null) return;
|
||||
for (Path filePath : Helper.getPathsIn("/", filter)) {
|
||||
String fileName = filePath.getFileName().toString();
|
||||
Locale locale = getLocaleByFileName(fileName);
|
||||
locales.add(locale);
|
||||
loadTranslationStatus(locale, fileName);
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
int lineCount = 0;
|
||||
try {
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
if (!line.startsWith("#")) {
|
||||
lineCount++;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
lineCount = -1;
|
||||
}
|
||||
TRANSLATION_STATUS.put(locale, lineCount);
|
||||
}
|
||||
locales.sort(Comparator.comparing(Locale::toLanguageTag));
|
||||
availableLocales = locales;
|
||||
}
|
||||
|
||||
static class ResourceLoader extends ClassLoader {
|
||||
private static @NotNull Locale getLocaleByFileName(@NotNull String name) {
|
||||
Locale locale;
|
||||
if (name.equalsIgnoreCase("messages.properties")) {
|
||||
locale = Locale.ENGLISH;
|
||||
} else {
|
||||
String[] extensionSplit = name.split(".properties");
|
||||
String[] split = extensionSplit[0].split("_");
|
||||
if (split.length == 2) {
|
||||
locale = new Locale(split[1]);
|
||||
} else {
|
||||
locale = new Locale(split[1], split[2]);
|
||||
}
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
private final File dataFolder;
|
||||
private static void loadTranslationStatus(@NotNull Locale locale, @NotNull String fileName) {
|
||||
InputStream stream = SimpleClans.getInstance().getClass().getResourceAsStream("/" + fileName);
|
||||
if (stream == null) return;
|
||||
|
||||
public ResourceLoader(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
int lineCount = 0;
|
||||
try {
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
if (!line.startsWith("#")) {
|
||||
lineCount++;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
lineCount = -1;
|
||||
}
|
||||
TRANSLATION_STATUS.put(locale, lineCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
File file = new File(dataFolder, name);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return file.toURI().toURL();
|
||||
} catch (MalformedURLException ignored) {
|
||||
}
|
||||
}
|
||||
static class ResourceLoader extends ClassLoader {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private final File dataFolder;
|
||||
|
||||
static class ResourceControl extends ResourceBundle.Control {
|
||||
public ResourceLoader(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
|
||||
private final Locale defaultLocale;
|
||||
private final boolean defaultAsFallback;
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
File file = new File(dataFolder, name);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return file.toURI().toURL();
|
||||
} catch (MalformedURLException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceControl(@NotNull Locale defaultLocale) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
this.defaultAsFallback = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceControl(@NotNull Locale defaultLocale, boolean defaultAsFallback) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
this.defaultAsFallback = defaultAsFallback;
|
||||
}
|
||||
static class ResourceControl extends ResourceBundle.Control {
|
||||
|
||||
@Override
|
||||
public List<String> getFormats(String baseName) {
|
||||
if (baseName == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
private final Locale defaultLocale;
|
||||
private final boolean defaultAsFallback;
|
||||
|
||||
return Collections.singletonList("java.properties");
|
||||
}
|
||||
public ResourceControl(@NotNull Locale defaultLocale) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
this.defaultAsFallback = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
|
||||
List<Locale> candidateLocales = new ArrayList<>(super.getCandidateLocales(baseName, locale));
|
||||
if (!defaultAsFallback && candidateLocales.size() != 1) {
|
||||
candidateLocales.remove(Locale.ROOT);
|
||||
}
|
||||
if (baseName.startsWith("acf") && !candidateLocales.contains(Locale.ENGLISH) && defaultAsFallback) {
|
||||
candidateLocales.add(Locale.ENGLISH);
|
||||
}
|
||||
return candidateLocales;
|
||||
}
|
||||
public ResourceControl(@NotNull Locale defaultLocale, boolean defaultAsFallback) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
this.defaultAsFallback = defaultAsFallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader,
|
||||
boolean reload) throws IOException {
|
||||
String bundleName = toBundleName(baseName, locale);
|
||||
@Override
|
||||
public List<String> getFormats(String baseName) {
|
||||
if (baseName == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
ResourceBundle bundle;
|
||||
if (format.equals("java.properties")) {
|
||||
return Collections.singletonList("java.properties");
|
||||
}
|
||||
|
||||
String resourceName = toResourceName(bundleName, "properties");
|
||||
@Override
|
||||
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
|
||||
List<Locale> candidateLocales = new ArrayList<>(super.getCandidateLocales(baseName, locale));
|
||||
if (!defaultAsFallback && candidateLocales.size() != 1) {
|
||||
candidateLocales.remove(Locale.ROOT);
|
||||
}
|
||||
if (baseName.startsWith("acf") && !candidateLocales.contains(Locale.ENGLISH) && defaultAsFallback) {
|
||||
candidateLocales.add(Locale.ENGLISH);
|
||||
}
|
||||
return candidateLocales;
|
||||
}
|
||||
|
||||
URL url = loader.getResource(resourceName);
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader,
|
||||
boolean reload) throws IOException {
|
||||
String bundleName = toBundleName(baseName, locale);
|
||||
|
||||
URLConnection connection = url.openConnection();
|
||||
if (reload) {
|
||||
connection.setUseCaches(false);
|
||||
}
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
bundle = new PropertyResourceBundle(reader);
|
||||
reader.close();
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown format: " + format);
|
||||
}
|
||||
ResourceBundle bundle;
|
||||
if (format.equals("java.properties")) {
|
||||
|
||||
return bundle;
|
||||
}
|
||||
String resourceName = toResourceName(bundleName, "properties");
|
||||
|
||||
URL url = loader.getResource(resourceName);
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
URLConnection connection = url.openConnection();
|
||||
if (reload) {
|
||||
connection.setUseCaches(false);
|
||||
}
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
bundle = new PropertyResourceBundle(reader);
|
||||
reader.close();
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown format: " + format);
|
||||
}
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Locale getFallbackLocale(String baseName, Locale locale) {
|
||||
if (!defaultAsFallback) {
|
||||
return null;
|
||||
}
|
||||
Locale root = baseName.startsWith("acf") ? Locale.ENGLISH : Locale.ROOT;
|
||||
if (!locale.equals(defaultLocale) && !locale.equals(root)) {
|
||||
return defaultLocale;
|
||||
}
|
||||
if (locale.equals(defaultLocale) && !defaultLocale.equals(root)) {
|
||||
return root;
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public Locale getFallbackLocale(String baseName, Locale locale) {
|
||||
if (!defaultAsFallback) {
|
||||
return null;
|
||||
}
|
||||
Locale root = baseName.startsWith("acf") ? Locale.ENGLISH : Locale.ROOT;
|
||||
if (!locale.equals(defaultLocale) && !locale.equals(root)) {
|
||||
return defaultLocale;
|
||||
}
|
||||
if (locale.equals(defaultLocale) && !defaultLocale.equals(root)) {
|
||||
return root;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -16,20 +15,20 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FriendlyFire implements Listener {
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
public class FriendlyFire extends SCListener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final Map<UUID, Long> warned = new HashMap<>();
|
||||
private static final long WARN_DELAY = 10000;
|
||||
|
||||
public FriendlyFire(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player) ||
|
||||
plugin.getSettingsManager().isBlacklistedWorld(event.getEntity().getWorld())) {
|
||||
if (!(event.getEntity() instanceof Player) || isBlacklistedWorld(event.getEntity())) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) event.getEntity();
|
||||
@@ -53,14 +52,14 @@ public class FriendlyFire implements Listener {
|
||||
@Nullable Clan victimClan,
|
||||
@Nullable Clan attackerClan) {
|
||||
if (vcp == null || victimClan == null || attackerClan == null) {
|
||||
if (plugin.getSettingsManager().getSafeCivilians()) {
|
||||
if (plugin.getSettingsManager().is(SAFE_CIVILIANS)) {
|
||||
ChatBlock.sendMessageKey(attacker, "cannot.attack.civilians");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (vcp.isFriendlyFire() || victimClan.isFriendlyFire() || plugin.getSettingsManager().isGlobalff()) {
|
||||
if (vcp.isFriendlyFire() || victimClan.isFriendlyFire() || plugin.getSettingsManager().is(GLOBAL_FRIENDLY_FIRE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
@@ -29,6 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager.Action.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
public class LandProtection implements Listener {
|
||||
|
||||
@@ -43,7 +45,7 @@ public class LandProtection implements Listener {
|
||||
protectionManager = plugin.getProtectionManager();
|
||||
clanManager = plugin.getClanManager();
|
||||
settingsManager = plugin.getSettingsManager();
|
||||
priority = settingsManager.getWarListenerPriority();
|
||||
priority = EventPriority.valueOf(settingsManager.getString(WAR_LISTENERS_PRIORITY));
|
||||
}
|
||||
|
||||
public void registerListeners() {
|
||||
@@ -59,17 +61,17 @@ public class LandProtection implements Listener {
|
||||
public void registerCreateLandEvent(ProtectionProvider provider, @Nullable Class<? extends Event> createLandEvent) {
|
||||
if (createLandEvent == null) return;
|
||||
Bukkit.getPluginManager().registerEvent(createLandEvent, this, EventPriority.NORMAL, (listener, event) -> {
|
||||
if (!createLandEvent.isInstance(createLandEvent)) {
|
||||
if (!createLandEvent.isInstance(event)) {
|
||||
return;
|
||||
}
|
||||
Player player = provider.getPlayer(event);
|
||||
if (player == null) return;
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if ((clan == null || !clan.isLeader(player)) && settingsManager.isOnlyLeadersCanCreateLands()) {
|
||||
if ((clan == null || !clan.isLeader(player)) && settingsManager.is(LAND_CREATION_ONLY_LEADERS)) {
|
||||
cancelWithMessage(player, event, "only.leaders.can.create.lands");
|
||||
return;
|
||||
}
|
||||
if (settingsManager.isOnlyOneLandPerClan()) {
|
||||
if (settingsManager.is(LAND_CREATION_ONLY_ONE_PER_CLAN)) {
|
||||
if (clan == null) {
|
||||
cancelWithMessage(player, event, "only.clan.members.can.create.lands");
|
||||
return;
|
||||
@@ -99,7 +101,11 @@ public class LandProtection implements Listener {
|
||||
return;
|
||||
}
|
||||
BlockBreakEvent blockBreakEvent = (BlockBreakEvent) event;
|
||||
if (protectionManager.can(BREAK, blockBreakEvent.getBlock().getLocation(), blockBreakEvent.getPlayer())) {
|
||||
Block block = blockBreakEvent.getBlock();
|
||||
if (settingsManager.getIgnoredList(BREAK).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, block.getLocation(), blockBreakEvent.getPlayer())) {
|
||||
blockBreakEvent.setCancelled(false);
|
||||
}
|
||||
}, plugin, false);
|
||||
@@ -188,7 +194,11 @@ public class LandProtection implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
if (protectionManager.can(BREAK, event.getBlock().getLocation(), event.getPlayer())) {
|
||||
Block block = event.getBlock();
|
||||
if (settingsManager.getIgnoredList(BREAK).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(BREAK, block.getLocation(), event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -252,6 +262,9 @@ public class LandProtection implements Listener {
|
||||
if (holder instanceof BlockState) {
|
||||
return ((BlockState) holder).getLocation();
|
||||
}
|
||||
if (holder instanceof DoubleChest) {
|
||||
return ((DoubleChest) holder).getLocation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -19,25 +18,21 @@ import java.time.LocalDateTime;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class PlayerDeath implements Listener {
|
||||
public class PlayerDeath extends SCListener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public PlayerDeath() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
public PlayerDeath(SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDeath(PlayerDeathEvent event) {
|
||||
SimpleClans.debug("A player died");
|
||||
Player victim = event.getEntity();
|
||||
if (plugin.getSettingsManager().isBlacklistedWorld(victim.getLocation().getWorld())
|
||||
|| victim.hasMetadata("NPC")) {
|
||||
SimpleClans.debug("Blacklisted world");
|
||||
if (isNPC(victim) || isBlacklistedWorld(victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +42,7 @@ public class PlayerDeath implements Listener {
|
||||
ClanPlayer victimCp = plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId());
|
||||
ClanPlayer attackerCp = plugin.getClanManager().getCreateClanPlayer(attacker.getUniqueId());
|
||||
|
||||
addKill(victimCp, attackerCp);
|
||||
classifyKill(victimCp, attackerCp);
|
||||
giveMoneyReward(victimCp, attackerCp);
|
||||
|
||||
// record death for victim
|
||||
@@ -71,7 +66,7 @@ public class PlayerDeath implements Listener {
|
||||
war.increaseCasualties(victimClan);
|
||||
}
|
||||
|
||||
private void addKill(@NotNull ClanPlayer victim, @NotNull ClanPlayer attacker) {
|
||||
private void classifyKill(@NotNull ClanPlayer victim, @NotNull ClanPlayer attacker) {
|
||||
Clan victimClan = victim.getClan();
|
||||
Clan attackerClan = attacker.getClan();
|
||||
if (victimClan == null || attackerClan == null || !victimClan.isVerified() || !attackerClan.isVerified()) {
|
||||
@@ -86,7 +81,7 @@ public class PlayerDeath implements Listener {
|
||||
}
|
||||
|
||||
private void giveMoneyReward(@NotNull ClanPlayer victim, @NotNull ClanPlayer attacker) {
|
||||
if (!plugin.getSettingsManager().isMoneyPerKill()) {
|
||||
if (!plugin.getSettingsManager().is(ECONOMY_MONEY_PER_KILL)) {
|
||||
return;
|
||||
}
|
||||
Clan attackerClan = attacker.getClan();
|
||||
@@ -115,7 +110,7 @@ public class PlayerDeath implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SimpleClans.getInstance().getSettingsManager().isDenySameIPKills()) {
|
||||
if (SimpleClans.getInstance().getSettingsManager().is(KILL_WEIGHTS_DENY_SAME_IP_KILLS)) {
|
||||
InetSocketAddress attackerAddress = attacker.getAddress();
|
||||
InetSocketAddress victimAddress = victim.getAddress();
|
||||
if (attackerAddress != null && victimAddress != null) {
|
||||
@@ -144,18 +139,20 @@ public class PlayerDeath implements Listener {
|
||||
return;
|
||||
}
|
||||
final Kill kill = new Kill(attacker, victim, LocalDateTime.now());
|
||||
if (plugin.getSettingsManager().isDelayBetweenKills() && plugin.getClanManager().isKillBeforeDelay(kill)) {
|
||||
if (plugin.getSettingsManager().is(KDR_ENABLE_KILL_DELAY) && plugin.getClanManager().isKillBeforeDelay(kill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isMaxKillsPerVictim()) {
|
||||
if (plugin.getSettingsManager().is(KDR_ENABLE_MAX_KILLS)) {
|
||||
plugin.getStorageManager().getKillsPerPlayer(attacker.getName(), data -> {
|
||||
final int max = plugin.getSettingsManager().getMaxKillsPerVictim();
|
||||
final int max = plugin.getSettingsManager().getInt(KDR_MAX_KILLS_PER_VICTIM);
|
||||
Integer kills = data.get(kill.getVictim().getName());
|
||||
if (kills != null) {
|
||||
if (kills < max) {
|
||||
saveKill(kill, type);
|
||||
}
|
||||
} else {
|
||||
saveKill(kill, type);
|
||||
}
|
||||
});
|
||||
return;
|
||||
@@ -173,7 +170,7 @@ public class PlayerDeath implements Listener {
|
||||
|
||||
private double calculateReward(@NotNull ClanPlayer attacker, @NotNull ClanPlayer victim) {
|
||||
double reward;
|
||||
double multiplier = plugin.getSettingsManager().getKDRMultipliesPerKill();
|
||||
double multiplier = plugin.getSettingsManager().getDouble(ECONOMY_MONEY_PER_KILL_KDR_MULTIPLIER);
|
||||
double kdr = attacker.getKDR() * multiplier;
|
||||
Clan attackerClan = attacker.getClan();
|
||||
Clan victimClan = victim.getClan();
|
||||
@@ -191,4 +188,16 @@ public class PlayerDeath implements Listener {
|
||||
}
|
||||
return reward;
|
||||
}
|
||||
|
||||
private boolean isNPC(Player player) {
|
||||
if (player.hasMetadata("NPC")) {
|
||||
SimpleClans.debug(String.format("%s has NPC metadata", player.getName()));
|
||||
return true;
|
||||
}
|
||||
if (Bukkit.getOfflinePlayer(player.getUniqueId()).getName() == null) {
|
||||
SimpleClans.debug(String.format("%s has a null name", player.getUniqueId()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 200 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user