mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-05 01:10:04 -05:00
Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fce8399840 | ||
|
|
cc2fc201fe | ||
|
|
373f41f9ee | ||
|
|
f1e4bbf043 | ||
|
|
b902f5f71d | ||
|
|
6461b5bc8c | ||
|
|
169ebe543e | ||
|
|
6018c793d4 | ||
|
|
ded9077dda | ||
|
|
0dd519dabd | ||
|
|
9563fc383c | ||
|
|
846574e613 | ||
|
|
cd40fdc704 | ||
|
|
7f01696a56 | ||
|
|
52da3def88 | ||
|
|
baea60473a | ||
|
|
4d6d2b550a | ||
|
|
ae99204f58 | ||
|
|
03e95cfa23 | ||
|
|
25f854b155 | ||
|
|
a32c751aaa | ||
|
|
e212e17bef | ||
|
|
4a7036cd82 | ||
|
|
d7d7620c24 | ||
|
|
3d545acda5 |
No files matched your search
+17
-25
@@ -1,37 +1,29 @@
|
||||
# This workflow will build a Java project with Maven
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: CI
|
||||
name: Java CI Dev Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [ dev ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [ dev ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
java-version: [ 8, 11, 16, 17 ]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
name: Java ${{ matrix.java-version }}
|
||||
|
||||
steps:
|
||||
- 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'
|
||||
cache: 'maven'
|
||||
- name: Build with Maven
|
||||
run: mvn -B -U package --file pom.xml
|
||||
- name: Upload Build Artifact
|
||||
if: "${{ matrix.java-version == 8 }}"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: SimpleClans
|
||||
path: target/SimpleClans.jar
|
||||
- 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
|
||||
@@ -4,16 +4,15 @@ on:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 8
|
||||
cache: 'maven'
|
||||
distribution: 'adopt'
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Upload artifact
|
||||
@@ -24,8 +23,7 @@ jobs:
|
||||
game_endpoint: minecraft
|
||||
file_path: target/SimpleClans.jar
|
||||
changelog: ${{ github.event.release.body }}
|
||||
changelog_type: markdown
|
||||
display_name: ${{ github.event.release.tag_name }}
|
||||
game_versions: 8849,8503,7915,7667,7330,7105,6588,630,591,585,531
|
||||
game_versions: 7915,7667,7330,7105,6588,630,591,585,531
|
||||
release_type: release
|
||||
relations: vault:optionalDependency,worldguard:optionalDependency,grief-prevention:optionalDependency
|
||||
@@ -1,31 +0,0 @@
|
||||
name: Publish to Modrinth
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: 8
|
||||
cache: 'maven'
|
||||
distribution: 'adopt'
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Upload artifact
|
||||
uses: RubixDev/modrinth-upload@v1.0.0
|
||||
with:
|
||||
token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
project_id: quLDfyDl
|
||||
file_path: target/SimpleClans.jar
|
||||
changelog: ${{ github.event.release.body }}
|
||||
name: ${{ github.event.release.tag_name }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
game_versions: 1.19,1.18,1.17,1.16,1.15,1.14,1.13,1.12,1.11,1.10,1.9,1.8
|
||||
release_type: release
|
||||
loaders: spigot
|
||||
featured: true
|
||||
@@ -1,29 +0,0 @@
|
||||
name: Publish to Reposilite
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: 8
|
||||
server-id: reposilite # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
cache: 'maven'
|
||||
distribution: 'adopt'
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Publish to Reposilite
|
||||
run: mvn -B deploy
|
||||
env:
|
||||
MAVEN_USERNAME: simpleclans
|
||||
MAVEN_PASSWORD: ${{ secrets.REPOSILITE_TOKEN }}
|
||||
@@ -1,15 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
name: release-please
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
with:
|
||||
release-type: maven
|
||||
package-name: SimpleClans
|
||||
token: ${{ secrets.PAT_TOKEN }}
|
||||
fork: false
|
||||
@@ -1,49 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [2.18.1](https://github.com/RoinujNosde/SimpleClans/compare/v2.18.0...v2.18.1) (2022-11-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* added check for clan_member on land commands ([fc81e76](https://github.com/RoinujNosde/SimpleClans/commit/fc81e765211bebe22a7a6aa5d5158754580bbdc5))
|
||||
* attempt at fixing NPE on getAllClanPlayers ([26ba9f7](https://github.com/RoinujNosde/SimpleClans/commit/26ba9f73296a772eaa698d2ede6fbc3831da850c))
|
||||
* **bungee:** error deserializing clan banners ([56c7908](https://github.com/RoinujNosde/SimpleClans/commit/56c7908c332167cec9cca6a4ea054977d0d68b9f))
|
||||
* channel auto creation setting not respected on join/link ([7f9d133](https://github.com/RoinujNosde/SimpleClans/commit/7f9d133051b9011837d0a5114abc6c3637a3f02c))
|
||||
* default ranks were getting re-added on config load ([7a37382](https://github.com/RoinujNosde/SimpleClans/commit/7a37382264ff4dd5456f6930045b5102bf491897))
|
||||
* missing getHandlerList on HomeRegroupEvent ([#338](https://github.com/RoinujNosde/SimpleClans/issues/338)) ([8fa465d](https://github.com/RoinujNosde/SimpleClans/commit/8fa465da385f36b1fb075031c375ef94df78ea52))
|
||||
* money was not given back when channel creation failed ([#336](https://github.com/RoinujNosde/SimpleClans/issues/336)) ([d8cb61b](https://github.com/RoinujNosde/SimpleClans/commit/d8cb61b0fc9584bb58f421faf98596816621053f))
|
||||
* wrong path of discord economy section ([#334](https://github.com/RoinujNosde/SimpleClans/issues/334)) ([3f1b06d](https://github.com/RoinujNosde/SimpleClans/commit/3f1b06dcf996e51a878b7fc281069e236ebcbfce))
|
||||
|
||||
## [2.18.0](https://github.com/RoinujNosde/SimpleClans/compare/v2.17.0...v2.18.0) (2022-10-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add help-size config ([25197cd](https://github.com/RoinujNosde/SimpleClans/commit/25197cdd729cea63d7e223dc1e0aaef830613327))
|
||||
* added method for registering protection providers ([2ea7444](https://github.com/RoinujNosde/SimpleClans/commit/2ea744443f502970b15859818e9d5e45ca69d453))
|
||||
* adds permission to bypass the teleport delay ([d56a0a9](https://github.com/RoinujNosde/SimpleClans/commit/d56a0a979a47a140115742518e934a2469e6f880))
|
||||
* adds PlayerHomeClearEvent ([becb88b](https://github.com/RoinujNosde/SimpleClans/commit/becb88b763380bed5a2e1dd209c32c8363a7f88b))
|
||||
* adds starter-ranks ([a440834](https://github.com/RoinujNosde/SimpleClans/commit/a4408343479d7efa6ae5a65894f8b822ecd47ebb))
|
||||
* Improves Bungee support ([#327](https://github.com/RoinujNosde/SimpleClans/issues/327)) ([2c9b0f9](https://github.com/RoinujNosde/SimpleClans/commit/2c9b0f98fe3942ea74190c1a81d61be2c8647db8))
|
||||
* **lang:** new crowdin updates ([#319](https://github.com/RoinujNosde/SimpleClans/issues/319)) ([87ece22](https://github.com/RoinujNosde/SimpleClans/commit/87ece22036fb674c8c362b6a1b86fe884543e6ad))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* changes size of some frames for better visualization on Bedrock ([1adec0b](https://github.com/RoinujNosde/SimpleClans/commit/1adec0b89d676767cdb94dcdf91ba37a231eb4a8))
|
||||
* ConfigurationSerializableAdapter NPE ([30a501c](https://github.com/RoinujNosde/SimpleClans/commit/30a501c063aa9dbcf596df83adc2b15baf0e4bb9))
|
||||
* getPastClans() preserves the insertion order ([af07988](https://github.com/RoinujNosde/SimpleClans/commit/af079881030bd299b9bae1ebf0cc62353af7e6fc))
|
||||
* NoClassDefFoundError in WorldGuard6Provider ([a859928](https://github.com/RoinujNosde/SimpleClans/commit/a8599286225ba603ea124b8b52510245b94ffd24))
|
||||
* NPE while collecting fees ([c47289c](https://github.com/RoinujNosde/SimpleClans/commit/c47289c5bf8113a9d6a8e1ee74a5afb0358647b6))
|
||||
* NPE while purging data ([f14c425](https://github.com/RoinujNosde/SimpleClans/commit/f14c42548846feef01b484acbb5f02bcbcabd8db))
|
||||
* NPE while sending a message to spies ([#322](https://github.com/RoinujNosde/SimpleClans/issues/322)) ([e7f756f](https://github.com/RoinujNosde/SimpleClans/commit/e7f756f3063c646e21415e08eea73f123d2818a0))
|
||||
* removes duplicate /clan from help ([f7e7ec6](https://github.com/RoinujNosde/SimpleClans/commit/f7e7ec66243359e26d3c456a9740a53753951c48))
|
||||
* removes rank and join date on disband ([2a1ad5b](https://github.com/RoinujNosde/SimpleClans/commit/2a1ad5b5c8d2937a8ee6dd6f7f43d85c86f08307))
|
||||
* set useSSL to false ([f484bc1](https://github.com/RoinujNosde/SimpleClans/commit/f484bc16c6176ccd13e05aae2169400e7bcf5d62))
|
||||
* supports '.' and '*' as username prefix by default ([37f0ecf](https://github.com/RoinujNosde/SimpleClans/commit/37f0ecff506d06f3047e3598848117a14c2b7ead))
|
||||
* updates join date when joining a clan ([#326](https://github.com/RoinujNosde/SimpleClans/issues/326)) ([96a13d8](https://github.com/RoinujNosde/SimpleClans/commit/96a13d8d6cc18c91d4dee20dd632cd5d65db5213))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* improved UUID lookup performance ([4ab53d1](https://github.com/RoinujNosde/SimpleClans/commit/4ab53d16135ecf5a4067b1a63d058da392dc5313))
|
||||
@@ -5,7 +5,7 @@ SimpleClans
|
||||
|
||||
Full featured clan system for PVP Minecraft Servers!
|
||||
|
||||
[](https://ci.roinujnosde.me/job/SimpleClans/)
|
||||
[](https://travis-ci.com/RoinujNosde/SimpleClans)
|
||||
[](https://www.spigotmc.org/resources/simpleclans.71242/)
|
||||
[](https://github.com/RoinujNosde/SimpleClans/issues)
|
||||
[](https://crowdin.com/project/simpleclans)
|
||||
@@ -50,8 +50,8 @@ Including SimpleClans with Maven:
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>roinujnosde-repo</id>
|
||||
<url>https://repo.roinujnosde.me/releases/</url>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
@@ -60,7 +60,7 @@ Including SimpleClans with Maven:
|
||||
<dependency>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.17.0</version> <!-- You can find the latest version at the bottom -->
|
||||
<version>2.15.0</version> <!-- You can find the latest version at the bottom -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -70,16 +70,15 @@ Using Gradle:
|
||||
```groovy
|
||||
repositories {
|
||||
maven {
|
||||
url "https://repo.roinujnosde.me/releases/"
|
||||
url "https://repo.codemc.org/repository/maven-public"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.17.0"
|
||||
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.15.0"
|
||||
}
|
||||
```
|
||||
|
||||
Feel free to learn our [Javadoc](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/).
|
||||
##### Latest version:
|
||||
[](https://repo.roinujnosde.me/#/releases/net/sacredlabyrinth/phaed/simpleclans/SimpleClans)
|
||||
[]()
|
||||
##### API Examples
|
||||
* [Examples of how to use the API](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
|
||||
+31
-67
@@ -1,5 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
@@ -14,6 +23,7 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
|
||||
@@ -21,17 +31,18 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:2.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-base:2.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.10.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations: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" name="Maven: org.jetbrains:annotations:16.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.papermc:paperlib:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-paper:0.5.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.cryptomorin:XSeries:7.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.26.0-GA" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.4" level="project" />
|
||||
@@ -52,6 +63,8 @@
|
||||
<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" />
|
||||
@@ -80,66 +93,17 @@
|
||||
<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.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" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.9.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Core:5.13.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Bukkit:5.13.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-api:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-bukkitapi:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl.vault:VaultAPI:1.7" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,7 +1,3 @@
|
||||
pull_request_title: "feat(lang): new crowdin updates"
|
||||
pull_request_labels: ["l10n"]
|
||||
commit_message: "feat(lang): new translations for %language%"
|
||||
append_commit_message: false
|
||||
files:
|
||||
- source: src/main/resources/messages.properties
|
||||
translation: /src/main/resources/%file_name%_%locale_with_underscore%.%file_extension%
|
||||
+76
-161
@@ -4,8 +4,8 @@
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.18.1-SNAPSHOT</version>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
<version>2.15.1</version>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -29,6 +29,7 @@
|
||||
<target>1.8</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
@@ -56,7 +57,7 @@
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
@@ -76,8 +77,8 @@
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.gson</shadedPattern>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
@@ -87,62 +88,6 @@
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-installed</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>${project.packaging}</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${env.TEST_SERVER}\plugins</outputDirectory>
|
||||
<silent>true</silent>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>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>
|
||||
@@ -171,12 +116,12 @@
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
<id>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
@@ -198,6 +143,10 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
@@ -220,6 +169,18 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
@@ -229,13 +190,13 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>22.0.0</version>
|
||||
<version>16.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.2</version>
|
||||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -283,98 +244,40 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.24.1-SNAPSHOT</version>
|
||||
<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>JDA</artifactId>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<groupId>*</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>nv-websocket-client</artifactId>
|
||||
<groupId>com.neovisionaries</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</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>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
@@ -383,26 +286,38 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>landlord-latest</artifactId>
|
||||
<version>4.351</version>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-bukkitapi</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>landlord-core</artifactId>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>Core</artifactId>
|
||||
<groupId>PlotSquared</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>reposilite</id>
|
||||
<url>https://repo.roinujnosde.me/releases/</url>
|
||||
<id>codemc-releases</id>
|
||||
<url>https://repo.codemc.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>reposilite</id>
|
||||
<url>https://repo.roinujnosde.me/snapshots/</url>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.18.2-SNAPSHOT</version>
|
||||
<version>2.15.2</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
@@ -35,6 +36,7 @@
|
||||
<target>1.8</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
@@ -63,7 +65,7 @@
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
@@ -83,8 +85,8 @@
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.gson</shadedPattern>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
@@ -102,68 +104,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Dependency plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-installed</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>${project.packaging}</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${env.TEST_SERVER}\plugins</outputDirectory>
|
||||
<silent>true</silent>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<version>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 -->
|
||||
@@ -180,10 +120,16 @@
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -195,28 +141,33 @@
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>22.0.0</version>
|
||||
<version>16.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.8-SNAPSHOT</version>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<version>0.5.1-SNAPSHOT</version>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
<version>8.3.0</version>
|
||||
<version>7.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.7.2</version>
|
||||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -232,21 +183,50 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.24.1-SNAPSHOT</version>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>biz.princeps</groupId>
|
||||
<artifactId>landlord-latest</artifactId>
|
||||
<version>4.351</version>
|
||||
<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.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-bukkitapi</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>PlotSquared</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -277,12 +257,12 @@
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Scarsz-Nexus</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
<id>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>eldonexus</id>
|
||||
<url>https://eldonexus.de/repository/maven-public</url>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
@@ -298,12 +278,12 @@
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>reposilite</id>
|
||||
<url>https://repo.roinujnosde.me/releases/</url>
|
||||
<id>codemc-releases</id>
|
||||
<url>https://repo.codemc.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>reposilite</id>
|
||||
<url>https://repo.roinujnosde.me/snapshots/</url>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
</project>
|
||||
@@ -3,6 +3,7 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,12 +27,10 @@ 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;
|
||||
}
|
||||
@@ -46,7 +45,6 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setColumnSizes(String prefix, double... columnPercentages) {
|
||||
int ll = LINE_LENGTH;
|
||||
|
||||
@@ -59,7 +57,6 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasContent() {
|
||||
return !rows.isEmpty();
|
||||
}
|
||||
@@ -68,27 +65,22 @@ 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);
|
||||
}
|
||||
@@ -277,7 +269,6 @@ public class ChatBlock {
|
||||
return (int) maxWidth;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String centerInLine(String msg) {
|
||||
return centerInLineOf(msg, LINE_LENGTH);
|
||||
}
|
||||
@@ -522,9 +513,6 @@ 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) {
|
||||
@@ -536,9 +524,6 @@ 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) {
|
||||
@@ -546,6 +531,11 @@ public class ChatBlock {
|
||||
}
|
||||
|
||||
receiver.sendMessage(ChatUtils.parseColors(msg));
|
||||
// String[] message = colorize(wordWrap(msg));
|
||||
//
|
||||
// for (String out : message) {
|
||||
// receiver.sendMessage(out);
|
||||
// }
|
||||
}
|
||||
|
||||
public static void sendMessage(@Nullable ClanPlayer receiver, @NotNull String msg) {
|
||||
@@ -553,23 +543,24 @@ public class ChatBlock {
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getProxyManager().sendMessage(receiver.getName(), ChatUtils.parseColors(msg));
|
||||
Player player = receiver.toPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a blank line
|
||||
*
|
||||
* @param receiver the receiver
|
||||
* Send blank line
|
||||
*/
|
||||
public static void sendBlank(CommandSender receiver) {
|
||||
if (receiver == null) {
|
||||
@@ -582,12 +573,10 @@ 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));
|
||||
}
|
||||
@@ -600,11 +589,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,14 +4,8 @@ import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.Placeholder;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLog;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
@@ -25,12 +19,10 @@ 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.Cause;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.loggers.BankLogger.Operation.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -53,7 +45,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private List<String> allies = new ArrayList<>();
|
||||
private List<String> rivals = new ArrayList<>();
|
||||
private List<String> bb = new ArrayList<>();
|
||||
private final List<ClanPlayer> members = new ArrayList<>();
|
||||
private final List<String> members = new ArrayList<>();
|
||||
private Flags flags = new Flags(null);
|
||||
private boolean feeEnabled;
|
||||
private List<Rank> ranks = new ArrayList<>();
|
||||
@@ -76,7 +68,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
this.lastUsed = (new Date()).getTime();
|
||||
this.verified = verified;
|
||||
this.capeUrl = "";
|
||||
if (SimpleClans.getInstance().getSettingsManager().is(CLAN_FF_ON_BY_DEFAULT)) {
|
||||
if (SimpleClans.getInstance().getSettingsManager().isClanFFOnByDefault()) {
|
||||
friendlyFire = true;
|
||||
}
|
||||
}
|
||||
@@ -113,34 +105,27 @@ 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(AQUA + lang("player.clan.deposit", player, amount));
|
||||
addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount));
|
||||
player.sendMessage(ChatColor.AQUA + lang("player.clan.deposit", player, amount));
|
||||
addBb(player.getName(), ChatColor.AQUA + lang("bb.clan.deposit", amount));
|
||||
setBalance(getBalance() + amount);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
} else {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
player.sendMessage(ChatColor.AQUA + lang("not.sufficient.money", player));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
player.sendMessage(ChatColor.AQUA + lang("not.sufficient.money", player));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposits money to the clan
|
||||
*/
|
||||
public EconomyResponse deposit(@NotNull BankOperator sender, @NotNull Cause cause, double amount) {
|
||||
EconomyResponse response = null;
|
||||
|
||||
public EconomyResponse deposit(@Nullable CommandSender sender, @NotNull Cause cause, double amount) {
|
||||
if (amount < 0) {
|
||||
response = NEGATIVE_VALUE;
|
||||
return EconomyResponse.NEGATIVE_VALUE;
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
response = setBalance(sender, cause, DEPOSIT, getBalance() + amount);
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(sender, this, response, DEPOSIT, cause, amount));
|
||||
return response;
|
||||
return setBalance(sender, cause, getBalance() + amount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,35 +135,28 @@ 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(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
player.sendMessage(ChatColor.AQUA + lang("player.clan.withdraw", player, amount));
|
||||
addBb(player.getName(), ChatColor.AQUA + lang("bb.clan.withdraw", amount));
|
||||
setBalance(getBalance() - amount);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(AQUA + lang("clan.bank.not.enough.money", player));
|
||||
player.sendMessage(ChatColor.AQUA + lang("clan.bank.not.enough.money", player));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Withdraws money from the clan
|
||||
*/
|
||||
public EconomyResponse withdraw(@NotNull BankOperator sender, @NotNull Cause cause, double amount) {
|
||||
EconomyResponse response = null;
|
||||
|
||||
public EconomyResponse withdraw(@Nullable CommandSender sender, @NotNull Cause cause, double amount) {
|
||||
if (amount < 0) {
|
||||
response = NEGATIVE_VALUE;
|
||||
return EconomyResponse.NEGATIVE_VALUE;
|
||||
}
|
||||
|
||||
if (getBalance() < amount) {
|
||||
response = NOT_ENOUGH_BALANCE;
|
||||
if (getBalance() >= amount) {
|
||||
return setBalance(sender, cause, getBalance() - amount);
|
||||
} else {
|
||||
return EconomyResponse.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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,28 +228,22 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @param balance the balance to set
|
||||
*/
|
||||
private void setBalance(double balance) {
|
||||
setBalance(BankOperator.INTERNAL, Cause.INTERNAL, SET, balance);
|
||||
public void setBalance(double balance) {
|
||||
setBalance(null, Cause.API, balance);
|
||||
}
|
||||
|
||||
public EconomyResponse setBalance(@NotNull BankOperator operator, @NotNull Cause cause,
|
||||
@NotNull BankLogger.Operation operation, double balance) {
|
||||
EconomyResponse response = SUCCESS;
|
||||
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(operator, this, getBalance(), balance, cause);
|
||||
public EconomyResponse setBalance(@Nullable CommandSender updater, @NotNull Cause cause, double balance) {
|
||||
ClanBalanceUpdateEvent event = new ClanBalanceUpdateEvent(updater, this, getBalance(), balance, cause);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
response = CANCELLED;
|
||||
return EconomyResponse.CANCELLED;
|
||||
}
|
||||
|
||||
this.balance = event.getNewBalance();
|
||||
if (cause != Cause.LOADING) {
|
||||
if (operation == SET) {
|
||||
SimpleClans.getInstance().getBankLogger().log(new BankLog(operator, this, response, SET, cause, balance));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
return response;
|
||||
return EconomyResponse.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,17 +308,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
/**
|
||||
* Returns the max number of days the clan can be inactive
|
||||
* A {@literal <=} 0 means it won't be purged
|
||||
* A number <= 0 means it won't be purged
|
||||
*/
|
||||
public int getMaxInactiveDays() {
|
||||
if (isPermanent()) {
|
||||
if (this.isPermanent()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int verifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getInt(PURGE_INACTIVE_CLAN_DAYS);
|
||||
int unverifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getInt(PURGE_UNVERIFIED_CLAN_DAYS);
|
||||
int verifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getPurgeClan();
|
||||
int unverifiedClanInactiveDays = SimpleClans.getInstance().getSettingsManager().getPurgeUnverified();
|
||||
|
||||
return isVerified() ? verifiedClanInactiveDays : unverifiedClanInactiveDays;
|
||||
return this.isVerified() ? verifiedClanInactiveDays : unverifiedClanInactiveDays;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,22 +356,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(Player player) {
|
||||
return isMember(player.getUniqueId());
|
||||
return this.members.contains(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player is a member of this clan
|
||||
*
|
||||
* @param uuid the Player's UUID
|
||||
* @param playerUniqueId the Player's UUID
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(UUID uuid) {
|
||||
for (ClanPlayer cp : members) {
|
||||
if (cp.getUniqueId().equals(uuid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean isMember(UUID playerUniqueId) {
|
||||
return this.members.contains(playerUniqueId.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -497,7 +464,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().getInt(BB_SIZE)) {
|
||||
while (bb.size() > SimpleClans.getInstance().getSettingsManager().getBbSize()) {
|
||||
bb.remove(0);
|
||||
}
|
||||
|
||||
@@ -526,16 +493,23 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* (used internally)
|
||||
*/
|
||||
public void importMember(ClanPlayer cp) {
|
||||
if (!members.contains(cp)) {
|
||||
members.add(cp);
|
||||
String uuid;
|
||||
if (cp.getUniqueId() != null) {
|
||||
uuid = cp.getUniqueId().toString();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.members.contains(uuid)) {
|
||||
this.members.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*/
|
||||
public void removeMember(UUID uuid) {
|
||||
members.removeIf(cp -> cp.getUniqueId().equals(uuid));
|
||||
public void removeMember(UUID playerUniqueId) {
|
||||
this.members.remove(playerUniqueId.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -543,7 +517,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("size")
|
||||
public int getSize() {
|
||||
return members.size();
|
||||
return this.members.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,7 +535,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
private boolean removeRival(String rival) {
|
||||
return rivals.remove(rival);
|
||||
if (!rivals.contains(rival)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rivals.remove(rival);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,7 +563,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("is_verified")
|
||||
public boolean isVerified() {
|
||||
return !SimpleClans.getInstance().getSettingsManager().is(REQUIRE_VERIFICATION) || verified;
|
||||
return !SimpleClans.getInstance().getSettingsManager().isRequireVerification() || verified;
|
||||
|
||||
}
|
||||
|
||||
@@ -632,7 +611,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedBb
|
||||
*/
|
||||
public String getPackedBb() {
|
||||
return String.join("|", bb);
|
||||
return Helper.toMessage(bb, "|");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -641,7 +620,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedBb the packedBb to set
|
||||
*/
|
||||
public void setPackedBb(String packedBb) {
|
||||
bb = Helper.fromArrayToList(packedBb.split("[|]"));
|
||||
this.bb = Helper.fromArray(packedBb.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -650,7 +629,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedAllies
|
||||
*/
|
||||
public String getPackedAllies() {
|
||||
return String.join("|", allies);
|
||||
return Helper.toMessage(allies, "|");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -659,7 +638,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedAllies the packedAllies to set
|
||||
*/
|
||||
public void setPackedAllies(String packedAllies) {
|
||||
allies = Helper.fromArrayToList(packedAllies.split("[|]"));
|
||||
this.allies = Helper.fromArray(packedAllies.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,7 +647,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the packedRivals
|
||||
*/
|
||||
public String getPackedRivals() {
|
||||
return String.join("|", rivals);
|
||||
return Helper.toMessage(rivals, "|");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,52 +656,61 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param packedRivals the packedRivals to set
|
||||
*/
|
||||
public void setPackedRivals(String packedRivals) {
|
||||
rivals = Helper.fromArrayToList(packedRivals.split("[|]"));
|
||||
this.rivals = Helper.fromArray(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) {
|
||||
return getAllyString(sep, null);
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
return getRivalString(sep, null);
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -731,8 +719,20 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the formatted leaders string
|
||||
*/
|
||||
public String getLeadersString(String prefix, String sep) {
|
||||
return members.stream().filter(ClanPlayer::isLeader).map(ClanPlayer::getName).
|
||||
collect(Collectors.joining(sep, prefix, ""));
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,10 +771,16 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the fee payers
|
||||
*/
|
||||
public Set<ClanPlayer> getFeePayers() {
|
||||
return getMembers().stream().filter(cp -> !cp.isLeader()).filter(cp -> {
|
||||
Rank rank = getRank(cp.getRankId());
|
||||
return rank == null || !rank.getPermissions().contains(RankPermission.FEE_BYPASS.toString());
|
||||
}).collect(Collectors.toSet());
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -783,7 +789,19 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the members
|
||||
*/
|
||||
public List<ClanPlayer> getMembers() {
|
||||
return new ArrayList<>(members);
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
out.add(cp);
|
||||
}
|
||||
|
||||
Collections.sort(out);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -793,7 +811,19 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder(value = "onlinemembers_count", resolver = "list_size", config = "filter_vanished")
|
||||
public List<ClanPlayer> getOnlineMembers() {
|
||||
return members.stream().filter(cp -> cp.toPlayer() != null).collect(Collectors.toList());
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
if (cp.toPlayer() != null) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -803,7 +833,20 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder(value = "leader_size", resolver = "list_size")
|
||||
public List<ClanPlayer> getLeaders() {
|
||||
return members.stream().filter(ClanPlayer::isLeader).collect(Collectors.toList());
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cp.isLeader()) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -812,7 +855,22 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return non leaders
|
||||
*/
|
||||
public List<ClanPlayer> getNonLeaders() {
|
||||
return members.stream().filter(cp -> !cp.isLeader()).collect(Collectors.toList());
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!cp.isLeader()) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(out);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -851,10 +909,16 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
if (members.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double totalWeightedKills = 0;
|
||||
int totalDeaths = 0;
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
totalWeightedKills += cp.getWeightedKills();
|
||||
totalDeaths += cp.getDeaths();
|
||||
}
|
||||
@@ -877,7 +941,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return totalDeaths;
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
totalDeaths += cp.getDeaths();
|
||||
}
|
||||
|
||||
@@ -895,7 +964,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return total;
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
total += cp.getWeightedKills();
|
||||
}
|
||||
|
||||
@@ -966,9 +1040,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public boolean reachedRivalLimit() {
|
||||
int rivalCount = rivals.size();
|
||||
int clanCount = SimpleClans.getInstance().getClanManager().getRivableClanCount() - 1;
|
||||
double rivalPercent = SimpleClans.getInstance().getSettingsManager().getPercent(RIVAL_LIMIT_PERCENT);
|
||||
int rivalPercent = SimpleClans.getInstance().getSettingsManager().getRivalLimitPercent();
|
||||
|
||||
double limit = ((double) clanCount) * (rivalPercent / ((double) 100));
|
||||
double limit = ((double) clanCount) * (((double) rivalPercent) / ((double) 100));
|
||||
|
||||
return rivalCount > limit;
|
||||
}
|
||||
@@ -980,8 +1054,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
cp.removePastClan(getColorTag());
|
||||
cp.setClan(this);
|
||||
cp.setLeader(false);
|
||||
cp.setJoinDate(new Date().getTime());
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().is(CLAN_TRUST_MEMBERS_BY_DEFAULT));
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().isClanTrustByDefault());
|
||||
if (defaultRank != null) {
|
||||
cp.setRank(defaultRank);
|
||||
}
|
||||
@@ -1024,7 +1097,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPlayerPermissions(cp);
|
||||
|
||||
cp.setClan(null);
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? DARK_RED + "*" : ""));
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? ChatColor.DARK_RED + "*" : ""));
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(false);
|
||||
cp.setJoinDate(0);
|
||||
@@ -1101,7 +1174,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an ally from the clan, and the clan from the ally
|
||||
* Remove an ally form the clan, and the clan from the ally
|
||||
*/
|
||||
public void removeAlly(Clan ally) {
|
||||
removeAlly(ally.getTag());
|
||||
@@ -1152,7 +1225,13 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
@Placeholder("is_anyonline")
|
||||
public boolean isAnyOnline() {
|
||||
return members.stream().anyMatch(cp -> cp.toPlayer() != null);
|
||||
for (String member : members) {
|
||||
if (Helper.isOnline(UUID.fromString(member))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1165,7 +1244,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> online = getOnlineLeaders();
|
||||
online.remove(cp);
|
||||
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercent(CLAN_PERCENTAGE_ONLINE_TO_DEMOTE);
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercentageOnlineToDemote();
|
||||
// all leaders minus the one being demoted
|
||||
double totalLeaders = getLeaders().size() - 1;
|
||||
double onlineLeaders = online.size();
|
||||
@@ -1190,7 +1269,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
|
||||
for (ClanPlayer leader : leaders) {
|
||||
if (leader.toPlayer() == null) {
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1210,7 +1289,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (leader.toPlayer() == null) {
|
||||
if (!Helper.isOnline(leader.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1229,7 +1308,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (leader.toPlayer() == null) {
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1249,27 +1328,35 @@ 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().getColored(CLANCHAT_ANNOUNCEMENT_COLOR) + msg;
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getClanChatAnnouncementColor() + msg;
|
||||
|
||||
for (ClanPlayer cp : getMembers()) {
|
||||
ChatBlock.sendMessage(cp, message);
|
||||
Player pl = cp.toPlayer();
|
||||
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, message);
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(AQUA + "[" + lang("clan.announce") + AQUA + "] " + AQUA + "[" + Helper.getColorName(playerName) + WHITE + "] " + message);
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + lang("clan.announce") + ChatColor.AQUA + "] " + ChatColor.AQUA + "[" + Helper.getColorName(playerName) + ChatColor.WHITE + "] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Announce message to all the leaders of a clan
|
||||
* Announce message to a all the leaders of a clan
|
||||
*/
|
||||
public void leaderAnnounce(String msg) {
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getColored(CLANCHAT_ANNOUNCEMENT_COLOR) + msg;
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getClanChatAnnouncementColor() + msg;
|
||||
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
|
||||
for (ClanPlayer cp : leaders) {
|
||||
ChatBlock.sendMessage(cp, message);
|
||||
Player pl = cp.toPlayer();
|
||||
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, message);
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(AQUA + "[" + lang("leader.announce") + AQUA + "] " + WHITE + message);
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + lang("leader.announce") + ChatColor.AQUA + "] " + ChatColor.WHITE + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1277,8 +1364,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
public void addBb(String announcerName, String msg) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR) + "* " + SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + ChatUtils.parseColors(msg));
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getBbColor() + msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1287,8 +1374,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*/
|
||||
public void addBb(String announcerName, String msg, boolean updateLastUsed) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getColored(BB_ACCENT_COLOR) + "* " + SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR) + ChatUtils.parseColors(msg));
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getBbColor() + msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1307,14 +1394,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().getColored(BB_ACCENT_COLOR);
|
||||
String pageHeadingsColor = SimpleClans.getInstance().getSettingsManager().getColored(PAGE_HEADINGS_COLOR);
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getBbAccentColor();
|
||||
String pageHeadingsColor = SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor();
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", bbAccentColor, pageHeadingsColor, getName()));
|
||||
|
||||
List<String> localBb;
|
||||
if (maxSize == -1) {
|
||||
localBb = bb;
|
||||
maxSize = SimpleClans.getInstance().getSettingsManager().getInt(BB_SIZE);
|
||||
maxSize = SimpleClans.getInstance().getSettingsManager().getBbSize();
|
||||
} else {
|
||||
localBb = new ArrayList<>(bb);
|
||||
}
|
||||
@@ -1324,7 +1411,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
for (String msg : localBb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR);
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getBbColor();
|
||||
ChatBlock.sendMessage(player, bbAccentColor + "* " + bbColor + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
@@ -1346,8 +1433,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().getColored(BB_ACCENT_COLOR);
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getColored(BB_COLOR);
|
||||
String bbAccentColor = SimpleClans.getInstance().getSettingsManager().getBbAccentColor();
|
||||
String bbColor = SimpleClans.getInstance().getSettingsManager().getBbColor();
|
||||
msg = ChatUtils.parseColors(bbAccentColor + "* " + bbColor + msg.substring(++index));
|
||||
TextComponent textComponent = new TextComponent(msg);
|
||||
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
|
||||
@@ -1370,55 +1457,54 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
Collection<ClanPlayer> clanPlayers = SimpleClans.getInstance().getClanManager().getAllClanPlayers();
|
||||
List<Clan> clans = SimpleClans.getInstance().getClanManager().getClans();
|
||||
|
||||
if (isPermanent() && !force) {
|
||||
if (this.isPermanent() && !force) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("cannot.disband.permanent"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (announce) {
|
||||
if (SimpleClans.getInstance().getSettingsManager().is(DISABLE_MESSAGES) && sender != null) {
|
||||
clanAnnounce(sender.getName(), AQUA + lang("clan.has.been.disbanded", getName()));
|
||||
if (SimpleClans.getInstance().getSettingsManager().isDisableMessages() && sender != null) {
|
||||
this.clanAnnounce(sender.getName(), AQUA + lang("clan.has.been.disbanded", this.getName()));
|
||||
} else {
|
||||
SimpleClans.getInstance().getClanManager().serverAnnounce(AQUA + lang("clan.has.been.disbanded", getName()));
|
||||
SimpleClans.getInstance().getClanManager().serverAnnounce(ChatColor.AQUA + lang("clan.has.been.disbanded", this.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPermissions(this);
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
if (cp.getTag().equals(getTag())) {
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPermissions(this);
|
||||
cp.setClan(null);
|
||||
cp.setJoinDate(0);
|
||||
cp.setRank(null);
|
||||
|
||||
if (isVerified()) {
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? DARK_RED + "*" : ""));
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? ChatColor.DARK_RED + "*" : ""));
|
||||
}
|
||||
|
||||
cp.setLeader(false);
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new DisbandClanEvent(sender, this));
|
||||
Bukkit.getPluginManager().callEvent(new DisbandClanEvent(this));
|
||||
clans.remove(this);
|
||||
|
||||
for (Clan c : clans) {
|
||||
String disbanded = lang("clan.disbanded");
|
||||
|
||||
if (c.removeWarringClan(this)) {
|
||||
c.addBb(disbanded, AQUA + lang("you.are.no.longer.at.war", c.getName(), getColorTag()));
|
||||
c.addBb(disbanded, ChatColor.AQUA + lang("you.are.no.longer.at.war", c.getName(), getColorTag()));
|
||||
}
|
||||
|
||||
if (c.removeRival(getTag())) {
|
||||
c.addBb(disbanded, AQUA + lang("has.been.disbanded.rivalry.ended", getName()));
|
||||
c.addBb(disbanded, ChatColor.AQUA + lang("has.been.disbanded.rivalry.ended", getName()));
|
||||
}
|
||||
|
||||
if (c.removeAlly(getTag())) {
|
||||
c.addBb(disbanded, AQUA + lang("has.been.disbanded.alliance.ended", getName()));
|
||||
c.addBb(disbanded, ChatColor.AQUA + lang("has.been.disbanded.alliance.ended", getName()));
|
||||
}
|
||||
}
|
||||
SimpleClans.getInstance().getRequestManager().removeRequest(getTag());
|
||||
|
||||
SimpleClans.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(SimpleClans.getInstance(), () -> {
|
||||
SimpleClans.getInstance().getClanManager().removeClan(getTag());
|
||||
SimpleClans.getInstance().getClanManager().removeClan(this.getTag());
|
||||
SimpleClans.getInstance().getStorageManager().deleteClan(this);
|
||||
}, 1);
|
||||
}
|
||||
@@ -1462,8 +1548,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
warring.add(targetClan.getTag());
|
||||
flags.put(WARRING_KEY, warring);
|
||||
if (requestPlayer != null) {
|
||||
addBb(requestPlayer.getName(), AQUA + lang("you.are.at.war",
|
||||
getName(), targetClan.getColorTag()));
|
||||
this.addBb(requestPlayer.getName(), ChatColor.AQUA + lang("you.are.at.war",
|
||||
this.getName(), targetClan.getColorTag()));
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1536,8 +1622,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
flags.put("homeYaw", home != null ? home.getYaw() : 0);
|
||||
String world = home != null && home.getWorld() != null ? home.getWorld().getName() : "";
|
||||
flags.put("homeWorld", world);
|
||||
String name = SimpleClans.getInstance().getProxyManager().getServerName();
|
||||
flags.put("homeServer", name);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1556,20 +1640,35 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
double z = flags.getNumber("homeZ").doubleValue();
|
||||
float yaw = flags.getNumber("homeYaw").floatValue();
|
||||
float pitch = flags.getNumber("homePitch").floatValue();
|
||||
|
||||
return new Location(world, x, y, z, yaw, pitch);
|
||||
Location location = new Location(world, x, y, z, yaw, pitch);
|
||||
if (!Helper.isAir(location.getBlock().getType(), location.clone().add(0, 1, 0).getBlock().getType())) {
|
||||
location.setY(world.getHighestBlockYAt(location) + 1);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getTagLabel(boolean isLeader) {
|
||||
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);
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
return bracketColor + bracketLeft + bracketDefaultColor + getColorTag() + bracketColor + bracketRight + tagSeparatorColor + tagSeparator;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -17,10 +16,8 @@ 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
|
||||
@@ -38,7 +35,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
private int deaths;
|
||||
private long lastSeen;
|
||||
private long joinDate;
|
||||
private final Set<String> pastClans = new LinkedHashSet<>();
|
||||
private Set<String> pastClans = new HashSet<>();
|
||||
private final Map<String, Long> resignTimes = new HashMap<>();
|
||||
private @Nullable VoteResult vote;
|
||||
private Flags flags = new Flags(null);
|
||||
@@ -48,7 +45,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
|
||||
private @Nullable Locale locale;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -68,17 +64,17 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param uuid the Player's UUID
|
||||
*/
|
||||
public ClanPlayer(UUID uuid) {
|
||||
uniqueId = uuid;
|
||||
this.uniqueId = uuid;
|
||||
Player onlinePlayer = SimpleClans.getInstance().getServer().getPlayer(uuid);
|
||||
if (onlinePlayer != null) {
|
||||
displayName = onlinePlayer.getName();
|
||||
this.displayName = onlinePlayer.getName();
|
||||
} else {
|
||||
OfflinePlayer offlinePlayer = SimpleClans.getInstance().getServer().getOfflinePlayer(uuid);
|
||||
displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
this.displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
}
|
||||
lastSeen = (new Date()).getTime();
|
||||
joinDate = (new Date()).getTime();
|
||||
tag = "";
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
this.joinDate = (new Date()).getTime();
|
||||
this.tag = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,12 +89,12 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
ClanPlayer other = (ClanPlayer) obj;
|
||||
return other.getName().equals(getName());
|
||||
return other.getName().equals(this.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClanPlayer other) {
|
||||
return getUniqueId().compareTo(other.getUniqueId());
|
||||
return this.getUniqueId().compareTo(other.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,7 +137,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
displayName = name;
|
||||
this.displayName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +223,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* Updates last seen date to today
|
||||
*/
|
||||
public void updateLastSeen() {
|
||||
lastSeen = (new Date()).getTime();
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -435,11 +431,11 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
@Placeholder("weighted_kills")
|
||||
public double getWeightedKills() {
|
||||
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);
|
||||
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());
|
||||
if (kills < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -488,7 +484,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
return "";
|
||||
}
|
||||
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(joinDate));
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.joinDate));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,10 +505,11 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
}
|
||||
|
||||
public String getLastSeenString(@Nullable CommandSender sender) {
|
||||
if (!VanishUtils.isVanished(sender, this)) {
|
||||
Player player = toPlayer();
|
||||
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(lastSeen));
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.lastSeen));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,24 +527,31 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @return the PackedPastClans
|
||||
*/
|
||||
public String getPackedPastClans() {
|
||||
return String.join("|", getPastClans());
|
||||
StringBuilder packedPastClans = new StringBuilder();
|
||||
|
||||
Set<String> pt = getPastClans();
|
||||
|
||||
for (String pastClan : pt) {
|
||||
packedPastClans.append(pastClan).append("|");
|
||||
}
|
||||
|
||||
return Helper.stripTrailing(packedPastClans.toString(), "|");
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param packedPastClans the packedPastClans to set
|
||||
* @param PackedPastClans the PackedPastClans to set
|
||||
*/
|
||||
public void setPackedPastClans(String packedPastClans) {
|
||||
String[] clans = packedPastClans.split("\\|");
|
||||
Collections.addAll(pastClans, clans);
|
||||
public void setPackedPastClans(String PackedPastClans) {
|
||||
this.pastClans = Helper.fromArray2(PackedPastClans.split("[|]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a past clan to the player (does not update the clanplayer to db)
|
||||
*/
|
||||
public void addPastClan(String tag) {
|
||||
getPastClans().add(tag);
|
||||
this.getPastClans().add(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,7 +560,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
* @param tag is the clan's colored tag
|
||||
*/
|
||||
public void removePastClan(String tag) {
|
||||
getPastClans().remove(tag);
|
||||
this.getPastClans().remove(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -575,15 +579,19 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
@NotNull
|
||||
public String getPastClansString(String sep, @Nullable Player viewer) {
|
||||
if (getPastClans().isEmpty()) {
|
||||
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()) {
|
||||
return lang("none", viewer);
|
||||
}
|
||||
|
||||
SettingsManager settings = SimpleClans.getInstance().getSettingsManager();
|
||||
return getPastClans().stream().
|
||||
sorted(Collections.reverseOrder()).
|
||||
limit(settings.getInt(PAST_CLANS_LIMIT)).
|
||||
collect(Collectors.joining(sep));
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -616,9 +624,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
/**
|
||||
* Sets the resign times (does not update to db)
|
||||
*/
|
||||
public void setResignTimes(@Nullable Map<String, Long> resignTimes) {
|
||||
public void setResignTimes(Map<String, Long> resignTimes) {
|
||||
if (resignTimes != null) {
|
||||
final int cooldown = SimpleClans.getInstance().getSettingsManager().getInt(REJOIN_COOLDOWN);
|
||||
final int cooldown = SimpleClans.getInstance().getSettingsManager().getRejoinCooldown();
|
||||
resignTimes.forEach((k, v) -> {
|
||||
long timePassed = Instant.ofEpochMilli(v).until(Instant.now(), ChronoUnit.MINUTES);
|
||||
if (timePassed < cooldown) {
|
||||
@@ -653,9 +661,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
*/
|
||||
public void setClan(@Nullable Clan clan) {
|
||||
if (clan == null) {
|
||||
tag = "";
|
||||
this.tag = "";
|
||||
} else {
|
||||
tag = clan.getTag();
|
||||
this.tag = clan.getTag();
|
||||
}
|
||||
|
||||
this.clan = clan;
|
||||
@@ -731,8 +739,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
if (channelName != null) {
|
||||
return Channel.valueOf(channelName);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
return Channel.NONE;
|
||||
}
|
||||
|
||||
@@ -752,16 +759,13 @@ 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());
|
||||
@@ -777,23 +781,13 @@ 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() {
|
||||
@@ -804,7 +798,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
flags.put("hide-tag", tagEnabled);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(toPlayer());
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(this.toPlayer());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -845,7 +839,10 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer> {
|
||||
flags.put("rank", rank == null ? "" : rank);
|
||||
}
|
||||
|
||||
public @Nullable Locale getLocale() {
|
||||
public @NotNull Locale getLocale() {
|
||||
if (locale == null) {
|
||||
return SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
@@ -861,29 +858,10 @@ 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
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 {@literal >} 1 day)
|
||||
* @param depth Max amount of detail (e.g. only display days and hours if set to 1 and seconds > 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,34 +1,36 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Flags {
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
private final JsonObject flags;
|
||||
private final JSONObject flags;
|
||||
|
||||
public Flags(@Nullable String json) {
|
||||
JSONObject flags = null;
|
||||
if (json != null && !json.isEmpty()) {
|
||||
flags = gson.fromJson(json, JsonObject.class);
|
||||
} else {
|
||||
flags = new JsonObject();
|
||||
flags = (JSONObject) JSONValue.parse(json);
|
||||
}
|
||||
if (flags == null) {
|
||||
flags = new JSONObject();
|
||||
}
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getStringList(@NotNull String key) {
|
||||
JsonElement object = flags.get(key);
|
||||
Object object = flags.get(key);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
if (object != null && object.isJsonArray()) {
|
||||
for (JsonElement element : object.getAsJsonArray()) {
|
||||
list.add(element.getAsString());
|
||||
if (object instanceof JSONArray) {
|
||||
for (Object o : ((JSONArray) object)) {
|
||||
list.add(String.valueOf(o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -36,11 +38,11 @@ public class Flags {
|
||||
|
||||
@Nullable
|
||||
public String getString(@NotNull String key) {
|
||||
JsonElement element = flags.get(key);
|
||||
if (element == null || element.isJsonNull()) {
|
||||
Object object = flags.get(key);
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
return element.getAsString();
|
||||
return String.valueOf(object);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -54,11 +56,11 @@ public class Flags {
|
||||
|
||||
@NotNull
|
||||
public Number getNumber(@NotNull String key) {
|
||||
JsonElement element = flags.get(key);
|
||||
if (element == null || element.isJsonNull()) {
|
||||
return 0;
|
||||
Object object = flags.get(key);
|
||||
if (object instanceof Number) {
|
||||
return (Number) object;
|
||||
}
|
||||
return element.getAsNumber();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean getBoolean(@NotNull String key) {
|
||||
@@ -66,22 +68,26 @@ public class Flags {
|
||||
}
|
||||
|
||||
public boolean getBoolean(@NotNull String key, boolean def) {
|
||||
JsonElement element = flags.get(key);
|
||||
if (element == null || element.isJsonNull()) {
|
||||
return def;
|
||||
Object object = flags.get(key);
|
||||
if (object instanceof Boolean) {
|
||||
return (Boolean) object;
|
||||
}
|
||||
return element.getAsBoolean();
|
||||
return def;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void put(@NotNull String key, @NotNull List<?> value) {
|
||||
flags.add(key, gson.toJsonTree(value));
|
||||
JSONArray array = new JSONArray();
|
||||
array.addAll(value);
|
||||
flags.put(key, array);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void put(@NotNull String key, @NotNull Object object) {
|
||||
flags.add(key, gson.toJsonTree(object));
|
||||
flags.put(key, object);
|
||||
}
|
||||
|
||||
public String toJSONString() {
|
||||
return flags.toString();
|
||||
return flags.toJSONString();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,5 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -17,11 +15,11 @@ public class Rank implements Comparable<Rank> {
|
||||
|
||||
public Rank(String name) {
|
||||
setName(name);
|
||||
permissions = new HashSet<>();
|
||||
permissions = new HashSet<String>();
|
||||
setDisplayName(displayName);
|
||||
}
|
||||
|
||||
public Rank(String name, @Nullable String displayName, Set<String> permissions) {
|
||||
public Rank(String name, String displayName, Set<String> permissions) {
|
||||
setName(name);
|
||||
setDisplayName(displayName);
|
||||
setPermissions(permissions);
|
||||
@@ -34,7 +32,7 @@ public class Rank implements Comparable<Rank> {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDisplayName(@Nullable String displayName) {
|
||||
public void setDisplayName(String displayName) {
|
||||
if (displayName == null || displayName.isEmpty()) {
|
||||
displayName = name;
|
||||
}
|
||||
@@ -43,7 +41,7 @@ public class Rank implements Comparable<Rank> {
|
||||
|
||||
public void setPermissions(Set<String> permissions) {
|
||||
if (permissions == null) {
|
||||
permissions = new HashSet<>();
|
||||
permissions = new HashSet<String>();
|
||||
}
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ public enum RankPermission {
|
||||
COORDS("simpleclans.member.coords", PermissionLevel.TRUSTED),
|
||||
FEE_ENABLE("simpleclans.leader.fee", PermissionLevel.LEADER),
|
||||
FEE_SET("simpleclans.leader.fee", PermissionLevel.LEADER),
|
||||
FEE_BYPASS("", PermissionLevel.LEADER),
|
||||
REGROUP_HOME("simpleclans.leader.regroup.home", PermissionLevel.LEADER),
|
||||
REGROUP_ME("simpleclans.leader.regroup.me", PermissionLevel.LEADER),
|
||||
HOME_SET("simpleclans.leader.home-set", PermissionLevel.LEADER),
|
||||
|
||||
@@ -6,8 +6,6 @@ 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
|
||||
*/
|
||||
@@ -180,6 +178,6 @@ public final class Request {
|
||||
}
|
||||
|
||||
public boolean reachedRequestLimit() {
|
||||
return askCount > SimpleClans.getInstance().getSettingsManager().getInt(REQUEST_MAX);
|
||||
return askCount > SimpleClans.getInstance().getSettingsManager().getMaxAsksPerRequest();
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,7 @@ 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.proxy.BungeeManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.proxy.ProxyManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatFormatMigration;
|
||||
@@ -18,8 +14,6 @@ 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;
|
||||
@@ -35,16 +29,12 @@ 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");
|
||||
@@ -56,13 +46,9 @@ public class SimpleClans extends JavaPlugin {
|
||||
private PermissionsManager permissionsManager;
|
||||
private TeleportManager teleportManager;
|
||||
private ProtectionManager protectionManager;
|
||||
private ChatManager chatManager;
|
||||
private ProxyManager proxyManager;
|
||||
private boolean hasUUID;
|
||||
private static final Pattern ACF_PLACEHOLDER_PATTERN = Pattern.compile("\\{(?<key>[a-zA-Z]+?)}");
|
||||
|
||||
private BankLogger bankLogger;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
*/
|
||||
@@ -72,7 +58,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static void debug(String msg) {
|
||||
if (getInstance().getSettingsManager().is(DEBUG)) {
|
||||
if (getInstance().getSettingsManager().isDebugging()) {
|
||||
logger.log(Level.INFO, msg);
|
||||
}
|
||||
}
|
||||
@@ -97,24 +83,21 @@ public class SimpleClans extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new LanguageMigration(this).migrate();
|
||||
settingsManager = new SettingsManager(this);
|
||||
settingsManager = new SettingsManager();
|
||||
languageResource = new LanguageResource();
|
||||
this.hasUUID = UUIDMigration.canReturnUUID();
|
||||
|
||||
permissionsManager = new PermissionsManager();
|
||||
requestManager = new RequestManager();
|
||||
clanManager = new ClanManager();
|
||||
proxyManager = new BungeeManager(this);
|
||||
storageManager = new StorageManager();
|
||||
teleportManager = new TeleportManager();
|
||||
protectionManager = new ProtectionManager();
|
||||
protectionManager.registerListeners();
|
||||
chatManager = new ChatManager(this);
|
||||
migrateChatFormat();
|
||||
registerEvents();
|
||||
permissionsManager.loadPermissions();
|
||||
commandManager = new SCCommandManager(this);
|
||||
bankLogger = new CSVBankLogger(this);
|
||||
|
||||
logStatus();
|
||||
startTasks();
|
||||
@@ -124,17 +107,16 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void logStatus() {
|
||||
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("Multithreading: " + SimpleClans.getInstance().getSettingsManager().getUseThreads());
|
||||
getLogger().info("BungeeCord: " + SimpleClans.getInstance().getSettingsManager().getUseBungeeCord());
|
||||
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), this);
|
||||
pm.registerEvents(new SCPlayerListener(this), this);
|
||||
pm.registerEvents(new PlayerDeath(), this);
|
||||
pm.registerEvents(new SCPlayerListener(), this);
|
||||
pm.registerEvents(new InventoryController(), this);
|
||||
pm.registerEvents(new TamableMobsSharing(this), this);
|
||||
pm.registerEvents(new PvPOnlyInWar(this), this);
|
||||
@@ -148,60 +130,60 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void hookIntoPAPI() {
|
||||
if (getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
if (getServer().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 SingleLineChart("clans", () -> cm.getClans().size()));
|
||||
metrics.addCustomChart(new SingleLineChart("clan_players", () -> cm.getAllClanPlayers().size()));
|
||||
metrics.addCustomChart(new SimplePie("language", () -> sm.getLanguage().toString()));
|
||||
metrics.addCustomChart(new SimplePie("machine_language", () -> Locale.getDefault().toString()));
|
||||
metrics.addCustomChart(new SimplePie("language_chooser", () -> sm.is(LANGUAGE_SELECTOR) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("database", () -> sm.is(MYSQL_ENABLE) ? "MySQL" : "SQLite"));
|
||||
metrics.addCustomChart(new SimplePie("save_periodically", () -> sm.is(PERFORMANCE_SAVE_PERIODICALLY) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("save_interval", () -> sm.getString(PERFORMANCE_SAVE_INTERVAL)));
|
||||
metrics.addCustomChart(new SimplePie("upkeep", () -> sm.is(ECONOMY_UPKEEP_ENABLED) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("member_fee", () -> sm.is(ECONOMY_MEMBER_FEE_ENABLED) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("rejoin_cooldown", () -> sm.is(ENABLE_REJOIN_COOLDOWN) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("clan_verification", () -> sm.is(REQUIRE_VERIFICATION) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("money_per_kill", () -> sm.is(ECONOMY_MONEY_PER_KILL) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("threads", () -> sm.is(PERFORMANCE_USE_THREADS) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("bungeecord", () -> sm.is(PERFORMANCE_USE_BUNGEECORD) ? on : off));
|
||||
metrics.addCustomChart(new SimplePie("discord_chat", () -> sm.is(DISCORDCHAT_ENABLE) ? on : off));
|
||||
Metrics 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));
|
||||
}
|
||||
|
||||
private void startTasks() {
|
||||
if (getSettingsManager().is(PERFORMANCE_SAVE_PERIODICALLY)) {
|
||||
new SaveDataTask().start();
|
||||
}
|
||||
if (getSettingsManager().is(ECONOMY_MEMBER_FEE_ENABLED)) {
|
||||
if (getSettingsManager().isSavePeriodically()) {
|
||||
new SaveDataTask().start();
|
||||
}
|
||||
if (getSettingsManager().isMemberFee()) {
|
||||
new CollectFeeTask().start();
|
||||
}
|
||||
if (getSettingsManager().is(ECONOMY_UPKEEP_ENABLED)) {
|
||||
if (getSettingsManager().isClanUpkeep()) {
|
||||
new CollectUpkeepTask().start();
|
||||
new UpkeepWarningTask().start();
|
||||
}
|
||||
if (getSettingsManager().is(PERFORMANCE_HEAD_CACHING)) {
|
||||
if (getSettingsManager().isCachePlayerHeads()) {
|
||||
new PlayerHeadCacheTask(this).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (getSettingsManager().is(PERFORMANCE_SAVE_PERIODICALLY)) {
|
||||
getStorageManager().saveModified();
|
||||
}
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
if (getSettingsManager().isSavePeriodically()) {
|
||||
getStorageManager().saveModified();
|
||||
}
|
||||
getStorageManager().closeConnection();
|
||||
getPermissionsManager().savePermissions();
|
||||
getSettingsManager().loadAndSave();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,18 +230,6 @@ public class SimpleClans extends JavaPlugin {
|
||||
return protectionManager;
|
||||
}
|
||||
|
||||
public ChatManager getChatManager() {
|
||||
return chatManager;
|
||||
}
|
||||
|
||||
public ProxyManager getProxyManager() {
|
||||
return proxyManager;
|
||||
}
|
||||
|
||||
public BankLogger getBankLogger() {
|
||||
return bankLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the path within the language file
|
||||
* @return the lang
|
||||
@@ -275,10 +245,13 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable ClanPlayer clanPlayer, Object... arguments) {
|
||||
Locale locale = instance.getSettingsManager().getLanguage();
|
||||
if (clanPlayer != null && clanPlayer.getLocale() != null && instance.getSettingsManager().is(LANGUAGE_SELECTOR)) {
|
||||
locale = clanPlayer.getLocale();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
String lang = languageResource.getLang(key, locale);
|
||||
@@ -293,25 +266,13 @@ 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);
|
||||
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;
|
||||
if (lang == null) {
|
||||
return key;
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -350,8 +311,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
return this.hasUUID;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,30 @@
|
||||
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 OfflinePlayer offlinePlayer;
|
||||
private final Location origin;
|
||||
private final UUID playerUniqueId;
|
||||
private final Location playerLocation;
|
||||
private final Location destination;
|
||||
private int counter;
|
||||
private final String clanName;
|
||||
private boolean processing;
|
||||
|
||||
public TeleportState(Player player, Location destination, String clanName, int counter) {
|
||||
this.offlinePlayer = player;
|
||||
public TeleportState(Player player, Location destination, String clanName) {
|
||||
this.destination = destination;
|
||||
this.origin = player.getLocation();
|
||||
this.playerLocation = player.getLocation();
|
||||
this.clanName = clanName;
|
||||
this.counter = counter;
|
||||
this.counter = SimpleClans.getInstance().getSettingsManager().getWaitSecs();
|
||||
this.playerUniqueId = player.getUniqueId();
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation() {
|
||||
return this.origin;
|
||||
return this.playerLocation;
|
||||
}
|
||||
|
||||
public boolean isTeleportTime() {
|
||||
@@ -43,7 +42,7 @@ public class TeleportState {
|
||||
* @return the player
|
||||
*/
|
||||
public @Nullable Player getPlayer() {
|
||||
return offlinePlayer.getPlayer();
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerUniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,4 +74,7 @@ public class TeleportState {
|
||||
this.processing = processing;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return this.playerUniqueId;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,12 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
/**
|
||||
* Possible vote values
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author cc_madelg
|
||||
*/
|
||||
public enum VoteResult {
|
||||
public enum VoteResult
|
||||
{
|
||||
ACCEPT, DENY
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
public interface ChatHandler {
|
||||
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
SettingsManager settingsManager = plugin.getSettingsManager();
|
||||
ChatManager chatManager = plugin.getChatManager();
|
||||
PermissionsManager permissionsManager = plugin.getPermissionsManager();
|
||||
|
||||
void sendMessage(SCMessage message);
|
||||
|
||||
boolean canHandle(SCMessage.Source source);
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SCMessage implements Cloneable {
|
||||
|
||||
private final Source source;
|
||||
private final ClanPlayer.Channel channel;
|
||||
private final ClanPlayer sender;
|
||||
private List<ClanPlayer> receivers;
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* Creates a message with initial parameters
|
||||
*
|
||||
* @param source The source of message
|
||||
* @param channel The channel of clan player
|
||||
* @param sender The clan player sender
|
||||
* @param content The content of message
|
||||
* @param receivers The clan players, who will receive the content
|
||||
*/
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel,
|
||||
@NotNull ClanPlayer sender, String content, @NotNull List<ClanPlayer> receivers) {
|
||||
this.source = source;
|
||||
this.channel = channel;
|
||||
this.sender = sender;
|
||||
this.content = content;
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SCMessage without receivers
|
||||
*
|
||||
* @see SCMessage#SCMessage(Source, ClanPlayer.Channel, ClanPlayer, String, List) instantiate with initial receievers
|
||||
*/
|
||||
public SCMessage(@NotNull Source source, @NotNull ClanPlayer.Channel channel, @NotNull ClanPlayer sender, String content) {
|
||||
this(source, channel, sender, content, new ArrayList<>());
|
||||
}
|
||||
|
||||
public ClanPlayer.Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public ClanPlayer getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public List<ClanPlayer> getReceivers() {
|
||||
return receivers;
|
||||
}
|
||||
|
||||
public void setContent(@NotNull String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setReceivers(@NotNull List<ClanPlayer> receivers) {
|
||||
this.receivers = receivers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SCMessage clone() {
|
||||
try {
|
||||
return (SCMessage) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new Error(); //never thrown
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The place where the message came from.
|
||||
* Used by ChatHandlers to know which SCMessages they can handle.
|
||||
*
|
||||
* @see ChatHandler initiate the handler
|
||||
*/
|
||||
public enum Source {
|
||||
SPIGOT, DISCORD, PROXY
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.SPIGOT;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.DISCORDCHAT_FORMAT_TO;
|
||||
|
||||
/**
|
||||
* Handles delivering messages from {@link Source#SPIGOT} to {@link Source#DISCORD}.
|
||||
*/
|
||||
public class DiscordChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull SCMessage message) {
|
||||
if (message.getChannel() != CLAN) {
|
||||
return;
|
||||
}
|
||||
|
||||
String format = settingsManager.getString(DISCORDCHAT_FORMAT_TO);
|
||||
String formattedMessage = ChatUtils.stripColors(chatManager.parseChatFormat(format, message));
|
||||
|
||||
Clan clan = message.getSender().getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DiscordHook discordHook = Objects.requireNonNull(chatManager.getDiscordHook(), "DiscordHook cannot be null");
|
||||
Optional<TextChannel> channel = discordHook.getCachedChannel(clan.getTag());
|
||||
channel.ifPresent(textChannel -> DiscordUtil.sendMessage(textChannel, formattedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT && chatManager.isDiscordHookEnabled();
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
|
||||
public class ProxyChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
plugin.getProxyManager().sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(Source source) {
|
||||
return source == Source.SPIGOT && settingsManager.is(PERFORMANCE_USE_BUNGEECORD);
|
||||
}
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ChatEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SpigotChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
/*
|
||||
TODO: Make it async, change Type to Channel in 3.0
|
||||
*/
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatEvent event = new ChatEvent(message.getContent(), message.getSender(), message.getReceivers(),
|
||||
ChatEvent.Type.valueOf(message.getChannel().name()));
|
||||
|
||||
getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
message.setContent(stripColorsAndFormatsPerPermission(message.getSender(),event.getMessage()));
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
|
||||
String format = settingsManager.getString(configField);
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message, event.getPlaceholders());
|
||||
|
||||
plugin.getLogger().info(ChatUtils.stripColors(formattedMessage));
|
||||
|
||||
for (ClanPlayer cp : message.getReceivers()) {
|
||||
ChatBlock.sendMessage(cp, formattedMessage);
|
||||
}
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
private String stripColorsAndFormatsPerPermission(ClanPlayer sender, String message) {
|
||||
if (!permissionsManager.has(sender.toPlayer(), "simpleclans.member.chat.color")) {
|
||||
message = stripColors(message);
|
||||
}
|
||||
if (!permissionsManager.has(sender.toPlayer(), "simpleclans.member.chat.format")) {
|
||||
message = stripFormats(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private String stripColors(String message) {
|
||||
return message.replaceAll("[§&][0-9a-fA-FxX]", "");
|
||||
}
|
||||
|
||||
private String stripFormats(String message) {
|
||||
return message.replaceAll("[§&][k-orK-OR]", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|| (source == DISCORD && chatManager.isDiscordHookEnabled());
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.chat.handlers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.ChatHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
|
||||
/**
|
||||
* Handles delivering messages from {@link Source#SPIGOT} or {@link Source#DISCORD} to internal spy chat.
|
||||
*/
|
||||
public class SpyChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
public void sendMessage(SCMessage message) {
|
||||
ConfigField formatField = ConfigField.valueOf(String.format("%sCHAT_SPYFORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
String format = settingsManager.getString(formatField);
|
||||
message.setContent(ChatUtils.stripColors(message.getContent()));
|
||||
String formattedMessage = chatManager.parseChatFormat(format, message);
|
||||
|
||||
List<ClanPlayer> onlineSpies = getOnlineSpies();
|
||||
|
||||
// Don't send a duplicate message if a spy is inside the clan
|
||||
onlineSpies.removeAll(message.getReceivers());
|
||||
onlineSpies.forEach(receiver -> ChatBlock.sendMessage(receiver, formattedMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|| (source == DISCORD && chatManager.isDiscordHookEnabled());
|
||||
}
|
||||
|
||||
private List<ClanPlayer> getOnlineSpies() {
|
||||
return Bukkit.getOnlinePlayers().stream().
|
||||
filter(Objects::nonNull).
|
||||
filter(player -> permissionsManager.has(player, "simpleclans.admin.all-seeing-eye")).
|
||||
map(player -> plugin.getClanManager().getCreateClanPlayer(player.getUniqueId())).
|
||||
filter(Objects::nonNull).
|
||||
filter(clanPlayer -> !clanPlayer.isMuted()).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+20
-25
@@ -6,8 +6,6 @@ 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;
|
||||
@@ -24,6 +22,7 @@ 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;
|
||||
@@ -33,7 +32,6 @@ 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;
|
||||
@@ -46,14 +44,13 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
enableUnstableAPI("help");
|
||||
registerDependencies();
|
||||
enableUnstableAPI("help");
|
||||
addCommandReplacements();
|
||||
registerContexts();
|
||||
registerCommands();
|
||||
registerConditions();
|
||||
registerCompletions();
|
||||
defaultHelpPerPage = plugin.getSettingsManager().getInt(HELP_SIZE);
|
||||
}
|
||||
|
||||
private void registerDependencies() {
|
||||
@@ -63,13 +60,11 @@ 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() {
|
||||
Set<Class<? extends AbstractCompletion>> completions =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands.completions",
|
||||
AbstractCompletion.class);
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.completions");
|
||||
Set<Class<? extends AbstractCompletion>> completions = reflections.getSubTypesOf(AbstractCompletion.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command completions...", completions.size()));
|
||||
for (Class<? extends AbstractCompletion> c : completions) {
|
||||
if (Modifier.isAbstract(c.getModifiers())) {
|
||||
@@ -95,9 +90,8 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void registerConditions() {
|
||||
Set<Class<? extends AbstractCondition>> conditions =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands.conditions",
|
||||
AbstractCondition.class);
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.conditions");
|
||||
Set<Class<? extends AbstractCondition>> conditions = reflections.getSubTypesOf(AbstractCondition.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command conditions...", conditions.size()));
|
||||
for (Class<? extends AbstractCondition> c : conditions) {
|
||||
if (Modifier.isAbstract(c.getModifiers())) {
|
||||
@@ -122,9 +116,8 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private void registerContexts() {
|
||||
Set<Class<? extends AbstractContextResolver>> resolvers =
|
||||
Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands.contexts",
|
||||
AbstractContextResolver.class);
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.contexts");
|
||||
Set<Class<? extends AbstractContextResolver>> resolvers = reflections.getSubTypesOf(AbstractContextResolver.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command contexts...", resolvers.size()));
|
||||
for (Class<? extends AbstractContextResolver> cr : resolvers) {
|
||||
if (Modifier.isAbstract(cr.getModifiers())) {
|
||||
@@ -145,8 +138,9 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
boolean forceCommandPriority = plugin.getSettingsManager().is(COMMANDS_FORCE_PRIORITY);
|
||||
Set<Class<? extends BaseCommand>> commands = Helper.getSubTypesOf("net.sacredlabyrinth.phaed.simpleclans.commands", BaseCommand.class);
|
||||
boolean forceCommandPriority = plugin.getSettingsManager().isForceCommandPriority();
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands");
|
||||
Set<Class<? extends BaseCommand>> commands = reflections.getSubTypesOf(BaseCommand.class);
|
||||
plugin.getLogger().info(String.format("Registering %d base commands...", commands.size()));
|
||||
for (Class<? extends BaseCommand> c : commands) {
|
||||
//ACF already registers nested classes
|
||||
@@ -166,16 +160,16 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
getCommandReplacements().addReplacements(
|
||||
"basic_conditions", "not_blacklisted|not_banned",
|
||||
"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)
|
||||
"clan", sm.getCommandClan(),
|
||||
"deny", sm.getCommandDeny() + "|deny",
|
||||
"more", sm.getCommandMore(),
|
||||
"ally_chat", sm.getCommandAlly(),
|
||||
"accept", sm.getCommandAccept() + "|accept",
|
||||
"clan_chat", sm.getCommandClanChat()
|
||||
);
|
||||
|
||||
SUBCOMMANDS.forEach(s -> {
|
||||
String command = optionalLang(s + ".command", (ClanPlayer) null);
|
||||
String command = optionalLang(s + ".command", null);
|
||||
if (command == null) {
|
||||
command = s;
|
||||
}
|
||||
@@ -212,6 +206,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
};
|
||||
//this.locales.loadLanguages();
|
||||
}
|
||||
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
@@ -224,6 +219,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", "join", "leave", "mute", "confirm", "balance", "discord");
|
||||
"container", "permanent", "take", "give");
|
||||
}
|
||||
}
|
||||
+8
-46
@@ -2,67 +2,29 @@ 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.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
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;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%ally_chat")
|
||||
@Description("{@@command.description.ally}")
|
||||
@CommandPermission("simpleclans.member.ally")
|
||||
@Conditions("%basic_conditions|clan_member|can_chat:type=ALLY|rank:name=ALLY_CHAT")
|
||||
@Conditions("%basic_conditions|clan_member|rank:name=ALLY_CHAT")
|
||||
public class AllyChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
private ClanManager clanManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
@Dependency
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
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"));
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, @Name("message") String message) {
|
||||
if (!settingsManager.isAllyChatEnable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clanPlayer.setChannel(ALLY);
|
||||
storageManager.updateClanPlayer(clanPlayer);
|
||||
ChatBlock.sendMessage(clanPlayer, lang("joined.ally.chat"));
|
||||
clanManager.processAllyChat(player, message);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-28
@@ -5,17 +5,15 @@ 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.loggers.BankLogger;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent;
|
||||
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;
|
||||
|
||||
@@ -50,6 +48,7 @@ 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()
|
||||
@@ -58,25 +57,19 @@ 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;
|
||||
}
|
||||
/*
|
||||
* ——————————————————————————————————
|
||||
*/
|
||||
BankOperator operator = new BankOperator(player, permissions.playerGetMoney(player));
|
||||
switch (clan.withdraw(operator, COMMAND, amount)) {
|
||||
|
||||
switch (clan.withdraw(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount)) {
|
||||
case SUCCESS:
|
||||
if (permissions.playerGrantMoney(player, amount)) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerGrantMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount, player.getName()));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
} else {
|
||||
clan.setBalance(operator, REVERT, BankLogger.Operation.WITHDRAW, clan.getBalance() + amount);
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, clan.getBalance() + amount);
|
||||
}
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
@@ -101,6 +94,7 @@ 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()
|
||||
@@ -109,32 +103,23 @@ 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, amount));
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player));
|
||||
return;
|
||||
}
|
||||
BankOperator operator = new BankOperator(player, permissions.playerGetMoney(player));
|
||||
EconomyResponse response = clan.deposit(operator, COMMAND, amount);
|
||||
EconomyResponse response = clan.deposit(player, ClanBalanceUpdateEvent.Cause.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, player.getName()));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount));
|
||||
} else {
|
||||
//Reverts the deposit if something went wrong with Vault
|
||||
clan.setBalance(operator, REVERT, BankLogger.Operation.DEPOSIT, clan.getBalance() - amount);
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, clan.getBalance() - amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,65 +2,29 @@ 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.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
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;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%clan_chat")
|
||||
@Conditions("%basic_conditions|clan_member|can_chat:type=CLAN")
|
||||
@Conditions("%basic_conditions|clan_member")
|
||||
@CommandPermission("simpleclans.member.chat")
|
||||
@Description("{@@command.description.chat}")
|
||||
public class ChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
private ClanManager clanManager;
|
||||
@Dependency
|
||||
private StorageManager storageManager;
|
||||
private SettingsManager settingsManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
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"));
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, ClanPlayer cp, @Name("message") String message) {
|
||||
if (!settingsManager.getClanChatEnable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
clanManager.processClanChat(player, cp.getTag(), message);
|
||||
}
|
||||
}
|
||||
+20
-42
@@ -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,7 +18,6 @@ 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;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class ClanCommands extends BaseCommand {
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(requestClan.getLeaders());
|
||||
|
||||
if (settings.is(WAR_START_REQUEST_ENABLED)) {
|
||||
if (settings.isWarRequestEnabled()) {
|
||||
if (!onlineLeaders.isEmpty()) {
|
||||
requestManager.addWarStartRequest(requester, targetClan, requestClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.have.been.asked.to.accept.the.war.request",
|
||||
@@ -68,13 +67,13 @@ public class ClanCommands extends BaseCommand {
|
||||
@Conditions("verified|rank:name=WAR_END")
|
||||
@Description("{@@command.description.war.end}")
|
||||
@CommandCompletion("@warring_clans")
|
||||
public void endWar(ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
public void endWar(Player player, ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
Clan war = other.getClan();
|
||||
if (issuerClan.isWarring(war.getTag())) {
|
||||
requestManager.addWarEndRequest(cp, war, issuerClan);
|
||||
ChatBlock.sendMessage(cp, AQUA + lang("leaders.asked.to.end.rivalry", cp, war.getName()));
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.asked.to.end.rivalry", player, war.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(cp, RED + lang("clans.not.at.war", cp));
|
||||
ChatBlock.sendMessage(player, RED + lang("clans.not.at.war", player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,10 +131,6 @@ 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")) {
|
||||
@@ -154,7 +149,7 @@ public class ClanCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getSize() >= settings.getInt(CLAN_MAX_MEMBERS) && settings.getInt(CLAN_MAX_MEMBERS) > 0) {
|
||||
if (clan.getSize() >= settings.getMaxMembers()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.clan.members.reached.limit", sender));
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +180,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.getDouble(ECONOMY_MAX_MEMBER_FEE);
|
||||
double maxFee = settings.getMaxMemberFee();
|
||||
if (fee > maxFee) {
|
||||
ChatBlock.sendMessage(player, RED
|
||||
+ lang("max.fee.allowed.is.0", player, maxFee));
|
||||
@@ -223,14 +218,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.getInt(CLAN_MIN_DESCRIPTION_LENGTH)) {
|
||||
if (description.length() < settings.getClanMinDescriptionLength()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.must.be.longer.than",
|
||||
player, settings.getInt(CLAN_MIN_DESCRIPTION_LENGTH)));
|
||||
player, settings.getClanMinDescriptionLength()));
|
||||
return;
|
||||
}
|
||||
if (description.length() > settings.getInt(CLAN_MAX_DESCRIPTION_LENGTH)) {
|
||||
if (description.length() > settings.getClanMaxDescriptionLength()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.cannot.be.longer.than",
|
||||
player, settings.getInt(CLAN_MAX_DESCRIPTION_LENGTH)));
|
||||
player, settings.getClanMaxDescriptionLength()));
|
||||
return;
|
||||
}
|
||||
clan.setDescription(description);
|
||||
@@ -241,7 +236,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:hide_own")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.rival.add}")
|
||||
public void addRival(Player player, Clan issuerClan, @Conditions("verified|different") @Name("clan") ClanInput rival) {
|
||||
Clan rivalInput = rival.getClan();
|
||||
@@ -286,7 +281,7 @@ public class ClanCommands extends BaseCommand {
|
||||
@Subcommand("%ally %add")
|
||||
@CommandPermission("simpleclans.leader.ally")
|
||||
@Conditions("verified|rank:name=ALLY_ADD|minimum_to_ally")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.ally.add}")
|
||||
public void addAlly(Player player,
|
||||
ClanPlayer cp,
|
||||
@@ -297,7 +292,7 @@ public class ClanCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.allies", player));
|
||||
return;
|
||||
}
|
||||
int maxAlliances = settings.getInt(CLAN_MAX_ALLIANCES);
|
||||
int maxAlliances = settings.getClanMaxAlliances();
|
||||
if (maxAlliances != -1) {
|
||||
if (issuerClan.getAllies().size() >= maxAlliances) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.reached.max.alliances", player));
|
||||
@@ -337,7 +332,7 @@ public class ClanCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%kick")
|
||||
@CommandPermission("simpleclans.leader.kick")
|
||||
@CommandCompletion("@clan_members:hide_own")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Conditions("rank:name=KICK")
|
||||
@Description("{@@command.description.kick}")
|
||||
public void kick(@Conditions("clan_member") Player sender,
|
||||
@@ -359,31 +354,14 @@ 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 SCConversation(plugin, player, new ResignPrompt()).begin();
|
||||
new ConversationFactory(plugin)
|
||||
.withFirstPrompt(new ResignPrompt())
|
||||
.withLocalEcho(true)
|
||||
.withTimeout(10)
|
||||
.buildConversation(player).begin();
|
||||
}
|
||||
}
|
||||
+20
-19
@@ -4,19 +4,16 @@ import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.HomeRegroupEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeClearEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@@ -38,7 +35,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.is(ALLOW_REGROUP)) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
@@ -61,12 +58,17 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.regroup.home")
|
||||
@Conditions("rank:name=REGROUP_HOME")
|
||||
@Description("{@@command.description.regroup.home}")
|
||||
public void regroupHome(Player player, ClanPlayer cp, @Conditions("can_teleport") Clan clan) {
|
||||
if (!settings.is(ALLOW_REGROUP)) {
|
||||
public void regroupHome(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
Location location = clan.getHomeLocation();
|
||||
if (location == null) {
|
||||
ChatBlock.sendMessage(player, RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
processRegroup(player, cp, clan, location);
|
||||
}
|
||||
|
||||
@@ -74,11 +76,16 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.member.home")
|
||||
@Conditions("rank:name=HOME_TP")
|
||||
@Description("{@@command.description.home.tp}")
|
||||
public void teleport(Player player, @Conditions("can_teleport") Clan clan, ClanPlayer cp) {
|
||||
Location homeLocation = clan.getHomeLocation();
|
||||
public void teleport(Player player, Clan clan, ClanPlayer cp) {
|
||||
Location loc = clan.getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.purchaseHomeTeleport(player)) {
|
||||
plugin.getTeleportManager().addPlayer(player, homeLocation, clan.getName());
|
||||
plugin.getTeleportManager().addPlayer(player, clan.getHomeLocation(), clan.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,19 +93,13 @@ public class HomeCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.home-set")
|
||||
@Conditions("rank:name=HOME_SET")
|
||||
@Description("{@@command.description.home.clear}")
|
||||
public void clear(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (settings.is(CLAN_HOMEBASE_CAN_BE_SET_ONLY_ONCE) && clan.getHomeLocation() != null &&
|
||||
public void clear(Player player, Clan clan) {
|
||||
if (settings.isHomebaseSetOnce() && clan.getHomeLocation() != null &&
|
||||
!permissions.has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("home.base.only.once", player));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHomeClearEvent event = new PlayerHomeClearEvent(clan, cp);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(null);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.cleared", player));
|
||||
}
|
||||
@@ -108,12 +109,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.is(CLAN_HOMEBASE_CAN_BE_SET_ONLY_ONCE) && clan.getHomeLocation() != null &&
|
||||
if (settings.isHomebaseSetOnce() && clan.getHomeLocation() != null &&
|
||||
!permissions.has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("home.base.only.once", player));
|
||||
return;
|
||||
}
|
||||
if (settings.is(LAND_SET_BASE_ONLY_IN_LAND)) {
|
||||
if (settings.isSetBaseOnlyInLand()) {
|
||||
if (!protection.isOwner(player, player.getLocation())) {
|
||||
ChatBlock.sendMessageKey(player, "you.can.only.set.base.in.your.land");
|
||||
return;
|
||||
|
||||
@@ -14,11 +14,9 @@ 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|clan_member|land_sharing|own_land")
|
||||
@Conditions("%basic_conditions|land_sharing|own_land")
|
||||
@CommandPermission("simpleclans.member.land")
|
||||
public class LandCommand extends BaseCommand {
|
||||
|
||||
@@ -29,7 +27,7 @@ public class LandCommand extends BaseCommand {
|
||||
|
||||
private Set<Land> getLands(ClanPlayer cp, Location location) {
|
||||
Player player = Objects.requireNonNull(cp.toPlayer());
|
||||
if (settings.is(LAND_EDIT_ALL_LANDS)) {
|
||||
if (settings.isEditAllLands()) {
|
||||
return protection.getLands(player, location);
|
||||
} else {
|
||||
return protection.getLandsAt(location).stream().filter(l -> l.getOwners().contains(player.getUniqueId()))
|
||||
|
||||
+8
-55
@@ -5,12 +5,7 @@ import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.DisbandPrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.SCConversation;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions.DiscordHookException;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,15 +13,13 @@ import org.bukkit.entity.Player;
|
||||
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.*;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|leader")
|
||||
public class LeaderCommands extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private SimpleClans plugin;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
@@ -37,8 +30,6 @@ public class LeaderCommands extends BaseCommand {
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private ChatManager chatManager;
|
||||
|
||||
@Subcommand("%demote")
|
||||
@CommandCompletion("@clan_leaders")
|
||||
@@ -57,7 +48,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.is(CLAN_CONFIRMATION_FOR_DEMOTE)) {
|
||||
if (clan.getLeaders().size() > 2 && settings.isConfirmationForDemote()) {
|
||||
requestManager.addDemoteRequest(cp, otherCp.getName(), clan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("demotion.vote.has.been.requested.from.all.leaders",
|
||||
player));
|
||||
@@ -89,7 +80,7 @@ public class LeaderCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + lang("the.player.is.already.a.leader", player));
|
||||
return;
|
||||
}
|
||||
if (settings.is(CLAN_CONFIRMATION_FOR_PROMOTE) && clan.getLeaders().size() > 1) {
|
||||
if (settings.isConfirmationForPromote() && clan.getLeaders().size() > 1) {
|
||||
requestManager.addPromoteRequest(cp, otherPl.getName(), clan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("promotion.vote.has.been.requested.from.all.leaders",
|
||||
player));
|
||||
@@ -111,7 +102,7 @@ public class LeaderCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
new SCConversation(plugin, player, new DisbandPrompt()).begin();
|
||||
clan.disband(player, true, false);
|
||||
}
|
||||
|
||||
@Subcommand("%verify")
|
||||
@@ -122,12 +113,12 @@ public class LeaderCommands extends BaseCommand {
|
||||
ChatBlock.sendMessageKey(player, "your.clan.already.verified");
|
||||
return;
|
||||
}
|
||||
if (!settings.is(ECONOMY_PURCHASE_CLAN_VERIFY)) {
|
||||
if (!settings.isePurchaseVerification()) {
|
||||
ChatBlock.sendMessageKey(player, "staff.member.verify.clan");
|
||||
return;
|
||||
}
|
||||
int minToVerify = settings.getInt(CLAN_MIN_TO_VERIFY);
|
||||
if (minToVerify > clan.getMembers().size()) {
|
||||
int minToVerify = settings.getMinToVerify();
|
||||
if (minToVerify > clan.getAllMembers().size()) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.must.have.members.to.verify", player, minToVerify));
|
||||
return;
|
||||
}
|
||||
@@ -186,42 +177,4 @@ 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;
|
||||
}
|
||||
|
||||
double amount = settings.getDouble(ECONOMY_DISCORD_CREATION_PRICE);
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!permissions.playerChargeMoney(player, amount)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
discordHook.createChannel(clan.getTag());
|
||||
ChatBlock.sendMessageKey(player, "discord.created.successfully");
|
||||
} catch (DiscordHookException ex) {
|
||||
// Return player's money if clan creation went wrong
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
permissions.playerGrantMoney(player, amount);
|
||||
}
|
||||
String messageKey = ex.getMessageKey();
|
||||
if (messageKey != null) {
|
||||
ChatBlock.sendMessage(player, RED + lang(messageKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ 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;
|
||||
@@ -14,6 +12,8 @@ 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) {
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateRankNamePrompt(), 60);
|
||||
conversation.addConversationCanceller(new RequestCanceller(player, RED + lang("rank.create.request.cancelled", player)));
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateRankNamePrompt())
|
||||
.withLocalEcho(true).withTimeout(60).buildConversation(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 = String.join(",", Helper.fromPermissionArray());
|
||||
private final String validPermissionsToMessage = Helper.toMessage(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 + String.join(",", permissions));
|
||||
ChatBlock.sendMessage(player, AQUA + Helper.toMessage(permissions.toArray(new String[0]), ","));
|
||||
}
|
||||
|
||||
@Subcommand("%add")
|
||||
|
||||
+47
-54
@@ -16,68 +16,61 @@ import static org.bukkit.ChatColor.AQUA;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%toggle")
|
||||
@Conditions("%basic_conditions")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
public class ToggleCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
|
||||
@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);
|
||||
}
|
||||
@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);
|
||||
|
||||
@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);
|
||||
}
|
||||
storage.updateClanPlayer(cp);
|
||||
}
|
||||
|
||||
@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);
|
||||
@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);
|
||||
}
|
||||
|
||||
private void toggle(CommandSender sender, String onMessageKey, String offMessageKey, boolean status,
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
+1
-7
@@ -10,10 +10,8 @@ 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);
|
||||
@@ -25,11 +23,7 @@ public class ClanMembersCompletion extends AbstractSyncCompletion {
|
||||
if (player != null) {
|
||||
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
List<String> list = clan.getMembers().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
if (c.hasConfig("hide_own")) {
|
||||
list.remove(player.getName());
|
||||
}
|
||||
return list;
|
||||
return clan.getAllMembers().stream().map(ClanPlayer::getName).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
+5
-17
@@ -1,16 +1,14 @@
|
||||
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) {
|
||||
@@ -19,28 +17,18 @@ public class ClansCompletion extends AbstractSyncCompletion {
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext c) throws InvalidCommandArgument {
|
||||
List<Clan> clans = clanManager.getClans();
|
||||
Stream<Clan> clans = clanManager.getClans().stream();
|
||||
if (c.hasConfig("has_home")) {
|
||||
clans.removeIf(clan -> clan.getHomeLocation() == null);
|
||||
clans = clans.filter(clan -> clan.getHomeLocation() != null);
|
||||
}
|
||||
if (c.hasConfig("unverified")) {
|
||||
clans.removeIf(Clan::isVerified);
|
||||
clans = clans.filter(clan -> !clan.isVerified());
|
||||
}
|
||||
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());
|
||||
return clans.map(Clan::getTag).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "clans";
|
||||
}
|
||||
|
||||
private @Nullable Clan getClan(CommandIssuer issuer) {
|
||||
return clanManager.getClanByPlayerUniqueId(issuer.getUniqueId());
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -11,7 +11,6 @@ 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 {
|
||||
@@ -27,7 +26,7 @@ public class CanChangeFeeCondition extends AbstractCommandCondition {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime collectTime = getCollectTime();
|
||||
long interval = now.until(collectTime, MINUTES);
|
||||
if (interval <= settingsManager.getInt(ECONOMY_MEMBER_FEE_LAST_MINUTE_CHANGE_INTERVAL) * HOUR_IN_MINUTES) {
|
||||
if (interval <= settingsManager.geteMemberFeeLastMinuteChangeInterval() * HOUR_IN_MINUTES) {
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
String error = lang("cannot.change.member.fee.now", issuer);
|
||||
if (interval <= 60) {
|
||||
@@ -41,8 +40,8 @@ public class CanChangeFeeCondition extends AbstractCommandCondition {
|
||||
|
||||
private LocalDateTime getCollectTime() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime collectTime = now.withHour(settingsManager.getInt(TASKS_COLLECT_FEE_HOUR))
|
||||
.withMinute(settingsManager.getInt(TASKS_COLLECT_FEE_MINUTE));
|
||||
LocalDateTime collectTime = now.withHour(settingsManager.getTasksCollectFeeHour())
|
||||
.withMinute(settingsManager.getTasksCollectFeeMinute());
|
||||
if (collectTime.isBefore(now)) {
|
||||
collectTime = collectTime.plusDays(1);
|
||||
}
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -7,8 +7,6 @@ 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) {
|
||||
@@ -34,8 +32,8 @@ public class CanWarTargetCondition extends AbstractParameterCondition<ClanInput>
|
||||
throw new ConditionFailedException(lang("clans.already.at.war", issuer));
|
||||
}
|
||||
|
||||
boolean isWarRequestEnabled = settingsManager.is(WAR_START_REQUEST_ENABLED);
|
||||
int maxDifference = settingsManager.getInt(WAR_MAX_MEMBERS_DIFFERENCE);
|
||||
boolean isWarRequestEnabled = settingsManager.isWarRequestEnabled();
|
||||
int maxDifference = settingsManager.getMembersOnlineMaxDifference();
|
||||
|
||||
if (!isWarRequestEnabled && maxDifference >= 0) {
|
||||
int difference = Math.abs(issuerClan.getOnlineMembers().size() - targetClan.getOnlineMembers().size());
|
||||
|
||||
+2
-6
@@ -1,14 +1,10 @@
|
||||
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 co.aikar.commands.*;
|
||||
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 {
|
||||
@@ -19,7 +15,7 @@ public class LandSharingCondition extends AbstractCommandCondition {
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
if (!settingsManager.is(LAND_SHARING)) {
|
||||
if (!settingsManager.isLandSharing()) {
|
||||
throw new ConditionFailedException(lang("land.sharing.disabled", context.getIssuer()));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -9,7 +9,6 @@ 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) {
|
||||
@@ -18,7 +17,7 @@ public class MemberFeeEnabledCondition extends AbstractCommandCondition {
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
if (!settingsManager.is(ECONOMY_MEMBER_FEE_ENABLED)) {
|
||||
if (!settingsManager.isMemberFee()) {
|
||||
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.getInt(CLAN_MIN_SIZE_TO_SET_ALLY)) {
|
||||
if (clan.getSize() < settingsManager.getClanMinSizeToAlly()) {
|
||||
throw new ConditionFailedException(RED +
|
||||
lang("minimum.to.make.alliance", context.getIssuer(), settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_ALLY)));
|
||||
lang("minimum.to.make.alliance", context.getIssuer(), settingsManager.getClanMinSizeToAlly()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -9,7 +9,6 @@ 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")
|
||||
@@ -22,9 +21,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.getInt(CLAN_MIN_SIZE_TO_SET_RIVAL)) {
|
||||
if (clan.getSize() < settingsManager.getClanMinSizeToRival()) {
|
||||
throw new ConditionFailedException(RED + lang("min.players.rivalries", issuer,
|
||||
settingsManager.getInt(CLAN_MIN_SIZE_TO_SET_RIVAL)));
|
||||
settingsManager.getClanMinSizeToRival()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -9,8 +9,6 @@ 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 {
|
||||
|
||||
@@ -24,7 +22,7 @@ public class NotBlacklistedCondition extends AbstractCommandCondition {
|
||||
if (player != null) {
|
||||
World world = player.getLocation().getWorld();
|
||||
if (world != null) {
|
||||
if (settingsManager.getStringList(BLACKLISTED_WORLDS).contains(world.getName())) {
|
||||
if (settingsManager.isBlacklistedWorld(world.getName())) {
|
||||
throw new ConditionFailedException();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -1,12 +1,10 @@
|
||||
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;
|
||||
|
||||
@@ -26,9 +24,7 @@ public class NotInClanCondition extends AbstractParameterCondition<ClanPlayerInp
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext, ClanPlayerInput value)
|
||||
throws InvalidCommandArgument {
|
||||
ClanPlayer clanPlayer = value.getClanPlayer();
|
||||
debug(String.format("NotInClanCondition -> %s %s", clanPlayer.getName(), clanPlayer.getUniqueId()));
|
||||
if (clanPlayer.getClan() != null) {
|
||||
if (value.getClanPlayer().getClan() != null) {
|
||||
throw new ConditionFailedException(RED + lang("the.player.is.already.member.of.another.clan",
|
||||
execContext.getSender()));
|
||||
}
|
||||
|
||||
+1
-5
@@ -1,14 +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 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")
|
||||
@@ -25,9 +23,7 @@ public class OnlineCondition extends AbstractParameterCondition<ClanPlayerInput>
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context, BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument {
|
||||
ClanPlayer clanPlayer = value.getClanPlayer();
|
||||
debug(String.format("OnlineCondition -> %s %s", clanPlayer.getName(), clanPlayer.getUniqueId()));
|
||||
Player player = clanPlayer.toPlayer();
|
||||
Player player = value.getClanPlayer().toPlayer();
|
||||
|
||||
if (player != null) {
|
||||
boolean isVanished = VanishUtils.isVanished(execContext.getSender(), player);
|
||||
|
||||
-3
@@ -8,8 +8,6 @@ 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) {
|
||||
@@ -25,7 +23,6 @@ public class PlayerClanMemberCondition extends AbstractParameterCondition<Player
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext,
|
||||
Player value) throws InvalidCommandArgument {
|
||||
debug(String.format("PlayerClanMemberCondition -> %s %s", value.getName(), value.getUniqueId()));
|
||||
Conditions.assertClanMember(clanManager, context.getIssuer());
|
||||
}
|
||||
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Flags;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class TeleportCondition extends AbstractParameterCondition<Clan> {
|
||||
|
||||
public TeleportCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Clan> getType() {
|
||||
return Clan.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context,
|
||||
BukkitCommandExecutionContext execContext,
|
||||
Clan value) throws InvalidCommandArgument {
|
||||
Player player = execContext.getPlayer();
|
||||
if (value.getHomeLocation() == null) {
|
||||
throw new ConditionFailedException(lang("hombase.not.set", player));
|
||||
}
|
||||
Flags flags = new Flags(value.getFlags());
|
||||
String homeServer = flags.getString("homeServer", "");
|
||||
if (!homeServer.isEmpty() && !plugin.getProxyManager().getServerName().equals(homeServer)) {
|
||||
throw new ConditionFailedException(lang("home.set.in.different.server"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "can_teleport";
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.ConditionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TeleportInputCondition extends AbstractParameterCondition<ClanInput> {
|
||||
|
||||
public TeleportInputCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
return ClanInput.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context, BukkitCommandExecutionContext execContext, ClanInput value) throws InvalidCommandArgument {
|
||||
new TeleportCondition(plugin).validateCondition(context, execContext, value.getClan());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "can_teleport";
|
||||
}
|
||||
}
|
||||
+4
-21
@@ -2,43 +2,27 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.contexts;
|
||||
|
||||
import co.aikar.commands.BukkitCommandExecutionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.MinecraftMessageKeys;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.USERNAME_REGEX;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextResolver<ClanPlayerInput> {
|
||||
|
||||
private final Pattern validUsername;
|
||||
|
||||
public ClanPlayerInputContextResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
validUsername = Pattern.compile(plugin.getSettingsManager().getString(USERNAME_REGEX));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClanPlayerInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
String arg = context.popFirstArg();
|
||||
if (!validUsername.matcher(arg).matches()) {
|
||||
throw new InvalidCommandArgument(MinecraftMessageKeys.IS_NOT_A_VALID_NAME, "{name}", arg);
|
||||
}
|
||||
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(arg);
|
||||
if (cp == null) {
|
||||
Player player = Bukkit.getPlayer(arg);
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument(lang("user.hasnt.played.before", context.getSender()));
|
||||
}
|
||||
cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(arg);
|
||||
cp = clanManager.getCreateClanPlayer(offlinePlayer.getUniqueId());
|
||||
}
|
||||
|
||||
return new ClanPlayerInput(cp);
|
||||
@@ -48,5 +32,4 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
public Class<ClanPlayerInput> getType() {
|
||||
return ClanPlayerInput.class;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-11
@@ -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,17 +30,8 @@ public class Contexts {
|
||||
public static Player assertPlayer(@NotNull BukkitCommandIssuer issuer) {
|
||||
Player player = issuer.getPlayer();
|
||||
if (player == null) {
|
||||
throw new InvalidCommandArgument(NOT_ALLOWED_ON_CONSOLE, false);
|
||||
throw new InvalidCommandArgument(MessageKeys.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
@@ -1,16 +0,0 @@
|
||||
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
@@ -1,39 +0,0 @@
|
||||
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
@@ -1,16 +0,0 @@
|
||||
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
@@ -1,36 +0,0 @@
|
||||
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,8 +10,6 @@ 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;
|
||||
|
||||
@@ -32,7 +30,7 @@ public class Alliances extends Sendable {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getAllyString(DARK_GRAY + ", ", sender));
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getAllyString(DARK_GRAY + ", "));
|
||||
}
|
||||
|
||||
sendBlock();
|
||||
@@ -40,9 +38,9 @@ public class Alliances extends Sendable {
|
||||
|
||||
private void sendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " +
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " +
|
||||
lang("alliances", sender) + " " + headColor +
|
||||
Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setAlignment("l", "l");
|
||||
|
||||
@@ -12,7 +12,6 @@ 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;
|
||||
|
||||
@@ -33,8 +32,8 @@ public class ClanCoords extends Sendable {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cpm.isTrusted() ?
|
||||
sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR))) + cpm.getName();
|
||||
String name = (cpm.isLeader() ? sm.getPageLeaderColor() : (cpm.isTrusted() ?
|
||||
sm.getPageTrustedColor() : sm.getPageUnTrustedColor())) + 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();
|
||||
@@ -58,8 +57,8 @@ public class ClanCoords extends Sendable {
|
||||
chatBlock.setAlignment("l", "c", "c", "c");
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("coords", player) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(player, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("coords", player) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.addRow(" " + headColor + lang("name", player), lang("distance", player),
|
||||
|
||||
@@ -14,7 +14,6 @@ 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.*;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class ClanList extends Sendable {
|
||||
@Nullable String order) {
|
||||
boolean ascending = order == null || lang("list.order.asc").equalsIgnoreCase(order);
|
||||
if (type == null) {
|
||||
type = sm.getString(LIST_DEFAULT_ORDER_BY);
|
||||
type = sm.getListDefaultOrderBy();
|
||||
}
|
||||
if (type.equalsIgnoreCase(lang("list.type.size"))) {
|
||||
return new RankingNumberResolver<>(clans, Clan::getSize, order != null && ascending, ORDINAL);
|
||||
@@ -74,15 +73,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.is(SHOW_UNVERIFIED_ON_LIST))
|
||||
clans = clans.stream().filter(clan -> clan.isVerified() || sm.isShowUnverifiedOnList())
|
||||
.collect(Collectors.toList());
|
||||
return clans;
|
||||
}
|
||||
|
||||
private void sendHeader(List<Clan> clans) {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("clans.lower", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " + lang("clans.lower", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.clans", sender) + " " + subColor + clans.size());
|
||||
ChatBlock.sendBlank(sender);
|
||||
@@ -92,11 +91,12 @@ 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.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 tag = sm.getClanChatBracketColor() + sm.getClanChatTagBracketLeft()
|
||||
+ sm.getTagDefaultColor() + clan.getColorTag() + sm.getClanChatBracketColor()
|
||||
+ sm.getClanChatTagBracketRight();
|
||||
String name = (clan.isVerified() ? sm.getPageClanNameColor() : GRAY) + clan.getName();
|
||||
String fullname = tag + " " + name;
|
||||
String size = WHITE + "" + clan.getSize();
|
||||
String kdr = clan.isVerified() ? YELLOW + "" + KDRFormat.format(clan.getTotalKDR()) : "";
|
||||
|
||||
@@ -9,7 +9,6 @@ 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 {
|
||||
|
||||
@@ -26,7 +25,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.getColored(PAGE_LEADER_COLOR), subColor + ", "))
|
||||
.replace("%clan_leaders%", clan.getLeadersString(sm.getPageLeaderColor(), 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()))
|
||||
@@ -37,8 +36,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 + ", ", sender))
|
||||
.replace("%clan_rivals%", clan.getRivalString(subColor + ", ", sender))
|
||||
.replace("%clan_allies%", clan.getAllyString(subColor + ", "))
|
||||
.replace("%clan_rivals%", clan.getRivalString(subColor + ", "))
|
||||
.replace("%clan_founded%", clan.getFoundedString())
|
||||
.replace("%clan_inactive_days%", String.valueOf(clan.getInactiveDays()))
|
||||
.replace("%clan_max_inactive_days%", Helper.formatMaxInactiveDays(clan.getMaxInactiveDays()));
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.data;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
public class ClanRoster extends Sendable {
|
||||
@@ -34,10 +33,12 @@ public class ClanRoster extends Sendable {
|
||||
List<ClanPlayer> members = clan.getNonLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(members);
|
||||
for (ClanPlayer cp : members) {
|
||||
String name = (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) : sm.getColored(PAGE_UNTRUSTED_COLOR)) + cp.getName();
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender) : GREEN + lang("online", sender);
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
String name = (cp.isTrusted() ? sm.getPageTrustedColor() : sm.getPageUnTrustedColor()) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,22 +46,24 @@ public class ClanRoster extends Sendable {
|
||||
List<ClanPlayer> leaders = clan.getLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(leaders);
|
||||
for (ClanPlayer cp : leaders) {
|
||||
String name = sm.getColored(PAGE_LEADER_COLOR) + cp.getName();
|
||||
String lastSeen = VanishUtils.isVanished(sender, cp) ? WHITE + cp.getLastSeenDaysString(sender) :
|
||||
GREEN + lang("online", sender);
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + ChatUtils.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
String name = sm.getPageLeaderColor() + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender)
|
||||
: WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("roster", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(sender, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("roster", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(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.sendMessage(sender, headColor + lang("legend", sender) + " " + sm.getPageLeaderColor() +
|
||||
lang("leader", sender) + headColor + ", " + sm.getPageTrustedColor() + lang("trusted", sender) +
|
||||
headColor + ", " + sm.getPageUnTrustedColor() + lang("untrusted", sender));
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setFlexibility(false, true, false, true);
|
||||
|
||||
@@ -9,7 +9,6 @@ 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 {
|
||||
@@ -37,15 +36,15 @@ public class ClanStats extends Sendable {
|
||||
}
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("stats", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(sender, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("stats", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
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.getDouble(KILL_WEIGHTS_RIVAL) + headColor + " " + lang("neutral", sender) + ": " + subColor +
|
||||
sm.getDouble(KILL_WEIGHTS_NEUTRAL) + headColor + " " + lang("civilian", sender) + ": " + subColor +
|
||||
sm.getDouble(KILL_WEIGHTS_CIVILIAN));
|
||||
+ ": " + subColor + sm.getKwRival() + headColor + " " + lang("neutral", sender) + ": " + subColor +
|
||||
sm.getKwNeutral() + headColor + " " + lang("civilian", sender) + ": " + subColor +
|
||||
sm.getKwCivilian());
|
||||
ChatBlock.sendBlank(sender);
|
||||
|
||||
chatBlock.setFlexibility(true, false, false, false, false, false, false);
|
||||
@@ -57,8 +56,8 @@ public class ClanStats extends Sendable {
|
||||
|
||||
private void addRows(List<ClanPlayer> clanPlayers) {
|
||||
for (ClanPlayer cpm : clanPlayers) {
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) :
|
||||
sm.getColored(PAGE_UNTRUSTED_COLOR)) + cpm.getName());
|
||||
String name = (cpm.isLeader() ? sm.getPageLeaderColor() : (cpm.isTrusted() ? sm.getPageTrustedColor() :
|
||||
sm.getPageUnTrustedColor())) + cpm.getName();
|
||||
String rival = NumberFormat.getInstance().format(cpm.getRivalKills());
|
||||
String neutral = NumberFormat.getInstance().format(cpm.getNeutralKills());
|
||||
String civilian = NumberFormat.getInstance().format(cpm.getCivilianKills());
|
||||
|
||||
@@ -11,8 +11,6 @@ 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 {
|
||||
|
||||
@@ -55,9 +53,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.getColored(PAGE_CLAN_NAME_COLOR) + polled + subColor
|
||||
ChatBlock.saySingle(player, sm.getPageClanNameColor() + polled + subColor
|
||||
+ " " + lang("kills", player) + " " + headColor +
|
||||
Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.RankingNumberResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -14,7 +13,6 @@ 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,10 +36,10 @@ public class Leaderboard extends Sendable {
|
||||
|
||||
private void addLines() {
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
boolean online = !VanishUtils.isVanished(cp);
|
||||
boolean online = cp.toPlayer() != null;
|
||||
|
||||
String name = (cp.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cp.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR) :
|
||||
sm.getColored(PAGE_UNTRUSTED_COLOR))) + cp.getName();
|
||||
String name = (cp.isLeader() ? sm.getPageLeaderColor() : (cp.isTrusted() ? sm.getPageTrustedColor() :
|
||||
sm.getPageUnTrustedColor())) + cp.getName();
|
||||
String lastSeen = online ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
String clanTag = WHITE + lang("free.agent", sender);
|
||||
@@ -57,8 +55,8 @@ public class Leaderboard extends Sendable {
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " + lang("leaderboard.command", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " + lang("leaderboard.command", sender)
|
||||
+ " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("total.clan.players.0", sender, subColor +
|
||||
clanPlayers.size()));
|
||||
|
||||
@@ -11,7 +11,6 @@ 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 {
|
||||
@@ -52,7 +51,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.getInt(PURGE_INACTIVE_PLAYER_DAYS)))
|
||||
.replace("%player_max_inactive_days%", Helper.formatMaxInactiveDays(sm.getPurgePlayers()))
|
||||
.replace("%kill_type_line%", getKillTypeLine());
|
||||
sender.sendMessage(lookup);
|
||||
} else {
|
||||
@@ -82,15 +81,15 @@ public class Lookup extends Sendable {
|
||||
return lang("free.agent", sender);
|
||||
}
|
||||
if (target.isLeader()) {
|
||||
return sm.getColored(PAGE_LEADER_COLOR) + lang("leader", sender);
|
||||
return sm.getPageLeaderColor() + lang("leader", sender);
|
||||
}
|
||||
if (target.isTrusted()) {
|
||||
return sm.getColored(PAGE_TRUSTED_COLOR) + lang("trusted", sender);
|
||||
return sm.getPageTrustedColor() + lang("trusted", sender);
|
||||
}
|
||||
if (!target.getRankId().isEmpty()) {
|
||||
return sm.getColored(PAGE_TRUSTED_COLOR) + lang("in.rank", sender);
|
||||
return sm.getPageTrustedColor() + lang("in.rank", sender);
|
||||
}
|
||||
return sm.getColored(PAGE_UNTRUSTED_COLOR) + lang("untrusted", sender);
|
||||
return sm.getPageUnTrustedColor() + lang("untrusted", sender);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -10,8 +10,6 @@ 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 {
|
||||
@@ -66,8 +64,8 @@ public class MostKilled extends Sendable {
|
||||
chatBlock.addRow(" " + headColor + lang("victim", player), headColor +
|
||||
lang("killcount", player), headColor + lang("attacker", player));
|
||||
|
||||
ChatBlock.saySingle(player, sm.getColored(SERVER_NAME) + subColor + " " + lang("mostkilled",
|
||||
player) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(player, sm.getServerName() + subColor + " " + lang("mostkilled",
|
||||
player) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,6 @@ 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 {
|
||||
@@ -31,7 +29,7 @@ public class Rivalries extends Sendable {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getRivalString(DARK_GRAY + ", ", sender));
|
||||
chatBlock.addRow(" " + AQUA + clan.getName(), clan.getRivalString(DARK_GRAY + ", "));
|
||||
}
|
||||
|
||||
sendBlock();
|
||||
@@ -39,8 +37,8 @@ public class Rivalries extends Sendable {
|
||||
|
||||
private void sendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(SERVER_NAME) + subColor + " " +
|
||||
lang("rivalries", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(sender, sm.getServerName() + subColor + " " +
|
||||
lang("rivalries", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, headColor + lang("legend", sender) + DARK_RED + " [" +
|
||||
lang("war", sender) + "]");
|
||||
|
||||
@@ -8,7 +8,6 @@ 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 {
|
||||
|
||||
@@ -26,19 +25,19 @@ public abstract class Sendable {
|
||||
sm = plugin.getSettingsManager();
|
||||
cm = plugin.getClanManager();
|
||||
this.sender = sender;
|
||||
headColor = sm.getColored(PAGE_HEADINGS_COLOR);
|
||||
subColor = sm.getColored(PAGE_SUBTITLE_COLOR);
|
||||
headColor = sm.getPageHeadingsColor();
|
||||
subColor = sm.getPageSubTitleColor();
|
||||
}
|
||||
|
||||
protected void sendBlock() {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
boolean more = chatBlock.sendBlock(sender, sm.getInt(PAGE_SIZE));
|
||||
boolean more = chatBlock.sendBlock(sender, sm.getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(sender, chatBlock);
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.sendMessage(sender, sm.getColored(PAGE_HEADINGS_COLOR) + lang("view.next.page", sender,
|
||||
sm.getString(COMMANDS_MORE)));
|
||||
ChatBlock.sendMessage(sender, sm.getPageHeadingsColor() + lang("view.next.page", sender,
|
||||
sm.getCommandMore()));
|
||||
}
|
||||
ChatBlock.sendBlank(sender);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ 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 {
|
||||
@@ -39,8 +38,8 @@ public class Vitals extends Sendable {
|
||||
|
||||
private void configureAndSendHeader() {
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, sm.getColored(PAGE_CLAN_NAME_COLOR) + clan.getName() + subColor + " " +
|
||||
lang("vitals", sender) + " " + headColor + Helper.generatePageSeparator(sm.getString(PAGE_SEPARATOR)));
|
||||
ChatBlock.saySingle(sender, sm.getPageClanNameColor() + clan.getName() + subColor + " " +
|
||||
lang("vitals", sender) + " " + headColor + Helper.generatePageSeparator(sm.getPageSep()));
|
||||
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));
|
||||
@@ -64,10 +63,10 @@ public class Vitals extends Sendable {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? sm.getColored(PAGE_LEADER_COLOR) : (cpm.isTrusted() ? sm.getColored(PAGE_TRUSTED_COLOR)
|
||||
: sm.getColored(PAGE_UNTRUSTED_COLOR))) + cpm.getName();
|
||||
String health = cm.getBar(p.getHealth());
|
||||
String hunger = cm.getBar(p.getFoodLevel());
|
||||
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 armor = cm.getArmorString(p.getInventory());
|
||||
String weapons = cm.getWeaponString(p.getInventory());
|
||||
String food = cm.getFoodString(p.getInventory());
|
||||
|
||||
+15
-42
@@ -13,26 +13,23 @@ 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,9 +49,10 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Default
|
||||
@Description("{@@command.description.clan}")
|
||||
@CommandAlias("%clan")
|
||||
@HelpSearchTags("menu gui interface ui")
|
||||
public void main(CommandSender sender) {
|
||||
if (sender instanceof Player && settings.is(ENABLE_GUI)) {
|
||||
if (sender instanceof Player && settings.isEnableGUI()) {
|
||||
InventoryDrawer.open(new MainFrame((Player) sender));
|
||||
} else {
|
||||
help(sender, new CommandHelp(getCurrentCommandManager(),
|
||||
@@ -76,8 +74,8 @@ public class GeneralCommands extends BaseCommand {
|
||||
HashMap<Object, Object> initialData = new HashMap<>();
|
||||
initialData.put(TAG_KEY, tag);
|
||||
initialData.put(NAME_KEY, name);
|
||||
SCConversation conversation = new SCConversation(plugin, player, new CreateClanTagPrompt(), initialData);
|
||||
conversation.addConversationCanceller(new RequestCanceller(player, RED + lang("clan.create.request.cancelled", player)));
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateClanTagPrompt())
|
||||
.withLocalEcho(true).withTimeout(60).withInitialSessionData(initialData).buildConversation(player);
|
||||
conversation.begin();
|
||||
}
|
||||
|
||||
@@ -93,8 +91,8 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandCompletion("@players")
|
||||
@CommandPermission("simpleclans.anyone.lookup")
|
||||
@Description("{@@command.description.lookup.other}")
|
||||
public void lookup(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
Lookup l = new Lookup(plugin, sender, player.getClanPlayer().getUniqueId());
|
||||
public void lookup(CommandSender sender, @Name("player") OfflinePlayer player) {
|
||||
Lookup l = new Lookup(plugin, sender, player.getUniqueId());
|
||||
l.send();
|
||||
}
|
||||
|
||||
@@ -122,7 +120,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%profile")
|
||||
@CommandPermission("simpleclans.anyone.profile")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.profile.other}")
|
||||
public void profile(CommandSender sender, @Conditions("verified") @Name("clan") ClanInput clan) {
|
||||
ClanProfile p = new ClanProfile(plugin, sender, clan.getClan());
|
||||
@@ -130,7 +128,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
}
|
||||
|
||||
@Subcommand("%roster")
|
||||
@CommandCompletion("@clans:hide_own")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandPermission("simpleclans.anyone.roster")
|
||||
@Description("{@@command.description.roster.other}")
|
||||
public void roster(CommandSender sender, @Conditions("verified") @Name("clan") ClanInput clan) {
|
||||
@@ -160,7 +158,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.vip.resetkdr")
|
||||
@Description("{@@command.description.resetkdr}")
|
||||
public void resetKdr(Player player, ClanPlayer cp) {
|
||||
if (!settings.is(ALLOW_RESET_KDR)) {
|
||||
if (!settings.isAllowResetKdr()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("disabled.command", player));
|
||||
return;
|
||||
}
|
||||
@@ -202,12 +200,12 @@ public class GeneralCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
chatBlock.sendBlock(player, settings.getInt(PAGE_SIZE));
|
||||
chatBlock.sendBlock(player, settings.getPageSize());
|
||||
|
||||
if (chatBlock.size() > 0) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, settings.getColored(PAGE_HEADINGS_COLOR) + lang("view.next.page", player,
|
||||
settings.getString(COMMANDS_MORE)));
|
||||
ChatBlock.sendMessage(player, settings.getPageHeadingsColor() + lang("view.next.page", player,
|
||||
settings.getCommandMore()));
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
@@ -236,31 +234,6 @@ 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}")
|
||||
|
||||
+6
-16
@@ -7,11 +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 net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.RED;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -22,9 +18,6 @@ import static org.bukkit.ChatColor.AQUA;
|
||||
@Subcommand("%admin %bank")
|
||||
public class BankCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
|
||||
@Subcommand("%status")
|
||||
@CommandPermission("simpleclans.admin.bank.status")
|
||||
@CommandCompletion("@clans")
|
||||
@@ -41,13 +34,12 @@ public class BankCommand extends BaseCommand {
|
||||
public void take(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
BankOperator operator = new BankOperator(sender, sender instanceof Player ? permissions.playerGetMoney((Player) sender) : 0);
|
||||
|
||||
EconomyResponse economyResponse = clan.withdraw(operator, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
EconomyResponse economyResponse = clan.withdraw(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
switch (economyResponse) {
|
||||
case SUCCESS:
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.take", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.take", sender, amount, sender.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.take", sender, amount));
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
sender.sendMessage(RED + lang("clan.admin.bank.not.enough.money", sender, clan.getName()));
|
||||
@@ -62,12 +54,11 @@ public class BankCommand extends BaseCommand {
|
||||
public void give(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
BankOperator operator = new BankOperator(sender, sender instanceof Player ? permissions.playerGetMoney((Player) sender) : 0);
|
||||
|
||||
EconomyResponse economyResponse = clan.deposit(operator, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
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, sender.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.give", sender, amount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,12 +69,11 @@ public class BankCommand extends BaseCommand {
|
||||
public void set(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
BankOperator operator = new BankOperator(sender, sender instanceof Player ? permissions.playerGetMoney((Player) sender) : 0);
|
||||
|
||||
EconomyResponse response = clan.setBalance(operator, ClanBalanceUpdateEvent.Cause.COMMAND, BankLogger.Operation.SET, amount);
|
||||
EconomyResponse response = clan.setBalance(sender, ClanBalanceUpdateEvent.Cause.COMMAND, 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, sender.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.set", sender, amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
+39
-46
@@ -2,10 +2,10 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.staff;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import co.aikar.commands.bukkit.contexts.OnlinePlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
@@ -18,6 +18,7 @@ import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -25,7 +26,6 @@ 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,32 +49,31 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandCompletion("@players @clans")
|
||||
@HelpSearchTags("move put")
|
||||
@Description("{@@command.description.place}")
|
||||
public void place(CommandSender sender, @Name("player") ClanPlayerInput cpInput, @Name("clan") ClanInput clanInput) {
|
||||
UUID uuid = cpInput.getClanPlayer().getUniqueId();
|
||||
ClanPlayer oldCp = cm.getClanPlayer(uuid);
|
||||
Clan newClan = clanInput.getClan();
|
||||
|
||||
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();
|
||||
if (oldCp != null) {
|
||||
Clan oldClan = Objects.requireNonNull(oldCp.getClan());
|
||||
|
||||
if (oldClan.equals(newClan)) {
|
||||
if (oldClan.equals(newClanInput)) {
|
||||
ChatBlock.sendMessage(sender, lang("player.already.in.this.clan", sender));
|
||||
return;
|
||||
}
|
||||
if (!oldClan.isPermanent() && oldClan.isLeader(uuid) && oldClan.getLeaders().size() <= 1) {
|
||||
if (!oldClan.isPermanent() && oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.move.the.last.leader", sender));
|
||||
return;
|
||||
} else {
|
||||
oldClan.addBb(oldCp.getName(), AQUA + lang("0.has.resigned", oldCp.getName()));
|
||||
oldClan.removePlayerFromClan(uuid);
|
||||
oldClan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(uuid);
|
||||
ClanPlayer cp = Objects.requireNonNull(cm.getCreateClanPlayerUUID(player.getName()));
|
||||
|
||||
newClan.addBb(AQUA + lang("joined.the.clan", cp.getName()));
|
||||
cm.serverAnnounce(lang("has.joined", cp.getName(), newClan.getName()));
|
||||
newClan.addPlayerToClan(cp);
|
||||
newClanInput.addBb(AQUA + lang("joined.the.clan", player.getName()));
|
||||
cm.serverAnnounce(lang("has.joined", player.getName(), newClanInput.getName()));
|
||||
newClanInput.addPlayerToClan(cp);
|
||||
}
|
||||
|
||||
@Subcommand("%mod %modtag")
|
||||
@@ -114,7 +113,7 @@ public class StaffCommands extends BaseCommand {
|
||||
storage.saveModified();
|
||||
plugin.reloadConfig();
|
||||
LanguageResource.clearCache();
|
||||
settings.loadAndSave();
|
||||
settings.load();
|
||||
storage.importFromDatabase();
|
||||
permissions.loadPermissions();
|
||||
|
||||
@@ -128,18 +127,11 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.home")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.mod.home.set}")
|
||||
public void homeSet(Player player, ClanPlayer cp, @Name("clan") ClanInput clanInput) {
|
||||
public void homeSet(Player player, @Name("clan") ClanInput clan) {
|
||||
Location loc = player.getLocation();
|
||||
Clan clan = clanInput.getClan();
|
||||
|
||||
PlayerHomeSetEvent event = new PlayerHomeSetEvent(clan, cp, loc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(loc);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.mod.set", player, clan.getName()) + " " +
|
||||
clan.getClan().setHomeLocation(loc);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.mod.set", player, clan.getClan().getName()) + " " +
|
||||
ChatColor.YELLOW + Helper.toLocationString(loc));
|
||||
}
|
||||
|
||||
@@ -147,7 +139,14 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandCompletion("@clans:has_home")
|
||||
@CommandPermission("simpleclans.mod.hometp")
|
||||
@Description("{@@command.description.mod.home.tp}")
|
||||
public void homeTp(Player player, @Name("clan") @Conditions("can_teleport") ClanInput clan) {
|
||||
public void homeTp(Player player, @Name("clan") ClanInput clan) {
|
||||
Location loc = clan.getClan().getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getTeleportManager().teleportToHome(player, clan.getClan());
|
||||
}
|
||||
|
||||
@@ -155,8 +154,8 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.ban}")
|
||||
public void ban(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
UUID uuid = player.getClanPlayer().getUniqueId();
|
||||
public void ban(CommandSender sender, @Name("player") OfflinePlayer player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (settings.isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("this.player.is.already.banned", sender));
|
||||
return;
|
||||
@@ -175,8 +174,8 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.unban}")
|
||||
public void unban(CommandSender sender, @Name("player") ClanPlayerInput player) {
|
||||
UUID uuid = player.getClanPlayer().getUniqueId();
|
||||
public void unban(CommandSender sender, @Name("player") OfflinePlayer player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (!settings.isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("this.player.is.not.banned", sender));
|
||||
return;
|
||||
@@ -195,10 +194,10 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.globalff")
|
||||
@Description("{@@command.description.globalff.allow}")
|
||||
public void allowGlobalFf(CommandSender sender) {
|
||||
if (settings.is(GLOBAL_FRIENDLY_FIRE)) {
|
||||
if (settings.isGlobalff()) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("global.friendly.fire.is.already.being.allowed", sender));
|
||||
} else {
|
||||
settings.set(GLOBAL_FRIENDLY_FIRE, true);
|
||||
settings.setGlobalff(true);
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("global.friendly.fire.is.set.to.allowed", sender));
|
||||
}
|
||||
}
|
||||
@@ -207,11 +206,11 @@ public class StaffCommands extends BaseCommand {
|
||||
@CommandPermission("simpleclans.mod.globalff")
|
||||
@Description("{@@command.description.globalff.auto}")
|
||||
public void autoGlobalFf(CommandSender sender) {
|
||||
if (!settings.is(GLOBAL_FRIENDLY_FIRE)) {
|
||||
if (!settings.isGlobalff()) {
|
||||
ChatBlock.sendMessage(sender, AQUA +
|
||||
lang("global.friendy.fire.is.already.being.managed.by.each.clan", sender));
|
||||
} else {
|
||||
settings.set(GLOBAL_FRIENDLY_FIRE, false);
|
||||
settings.setGlobalff(false);
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("global.friendy.fire.is.now.managed.by.each.clan",
|
||||
sender));
|
||||
}
|
||||
@@ -258,7 +257,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 (clanPlayer.isLeader() && clan.getLeaders().size() == 1) {
|
||||
if (clan.getLeaders().size() == 1) {
|
||||
ChatBlock.sendMessageKey(sender, "cannot.kick.last.leader");
|
||||
return;
|
||||
}
|
||||
@@ -281,14 +280,13 @@ 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) {
|
||||
ClanPlayer clanPlayer = promote.getClanPlayer();
|
||||
Player promotePl = Objects.requireNonNull(clanPlayer.toPlayer());
|
||||
Player promotePl = Objects.requireNonNull(promote.getClanPlayer().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(clanPlayer.getClan());
|
||||
Clan clan = Objects.requireNonNull(promote.getClanPlayer().getClan());
|
||||
if (clan.isLeader(promotePl)) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.player.is.already.a.leader", sender));
|
||||
return;
|
||||
@@ -306,17 +304,12 @@ 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 (!otherCp.isLeader()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("player.is.not.a.leader", sender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getLeaders().size() == 1 && !clan.isPermanent()) {
|
||||
if (clan.getLeaders().size() == 1) {
|
||||
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));
|
||||
}
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
abstract public class ConfirmationPrompt extends StringPrompt {
|
||||
|
||||
protected abstract Prompt confirm(ClanPlayer sender, Clan clan);
|
||||
|
||||
protected Prompt decline(ClanPlayer sender) {
|
||||
return new MessagePromptImpl(RED + lang(getDeclineTextKey(), sender));
|
||||
}
|
||||
|
||||
protected abstract String getPromptTextKey();
|
||||
|
||||
protected abstract String getDeclineTextKey();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPromptText(@NotNull ConversationContext context) {
|
||||
Player player = (Player) context.getForWhom();
|
||||
List<String> options = Arrays.asList(lang("yes", player), lang("cancel", player));
|
||||
|
||||
return RED + lang(getPromptTextKey(), player, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(@NotNull ConversationContext cc, @Nullable String input) {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
|
||||
Player player = (Player) cc.getForWhom();
|
||||
String yes = lang("yes", player);
|
||||
ClanManager cm = Objects.requireNonNull(plugin).getClanManager();
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan == null) {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
return yes.equalsIgnoreCase(input) ? confirm(cp, clan) : decline(cp);
|
||||
}
|
||||
}
|
||||
+13
-14
@@ -5,7 +5,9 @@ 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;
|
||||
@@ -15,9 +17,6 @@ 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";
|
||||
@@ -66,16 +65,16 @@ public class CreateClanNamePrompt extends StringPrompt {
|
||||
plugin.getClanManager().createClan(player, tag, name);
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(tag);
|
||||
clan.addBb(player.getName(), AQUA +
|
||||
clan.addBb(player.getName(), ChatColor.AQUA +
|
||||
lang("clan.created", name));
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
|
||||
if (plugin.getSettingsManager().is(REQUIRE_VERIFICATION)) {
|
||||
boolean verified = !plugin.getSettingsManager().is(REQUIRE_VERIFICATION)
|
||||
if (plugin.getSettingsManager().isRequireVerification()) {
|
||||
boolean verified = !plugin.getSettingsManager().isRequireVerification()
|
||||
|| plugin.getPermissionsManager().has(player, "simpleclans.mod.verify");
|
||||
|
||||
if (!verified) {
|
||||
ChatBlock.sendMessage(player, AQUA +
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA +
|
||||
lang("get.your.clan.verified.to.access.advanced.features", player));
|
||||
}
|
||||
}
|
||||
@@ -86,19 +85,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().getInt(CLAN_MAX_LENGTH)) {
|
||||
return new MessagePromptImpl(RED +
|
||||
if (ChatUtils.stripColors(input).length() > plugin.getSettingsManager().getClanMaxLength()) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
lang("your.clan.name.cannot.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getInt(CLAN_MAX_LENGTH)), this);
|
||||
plugin.getSettingsManager().getClanMaxLength()), this);
|
||||
}
|
||||
if (ChatUtils.stripColors(input).length() <= plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)) {
|
||||
return new MessagePromptImpl(RED +
|
||||
if (ChatUtils.stripColors(input).length() <= plugin.getSettingsManager().getClanMinLength()) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
lang("your.clan.name.must.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getInt(CLAN_MIN_LENGTH)), this);
|
||||
plugin.getSettingsManager().getClanMinLength()), this);
|
||||
}
|
||||
}
|
||||
if (input.contains("&")) {
|
||||
return new MessagePromptImpl(RED +
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
lang("your.clan.name.cannot.contain.color.codes", player), this);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,11 +18,10 @@ 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", forWhom, lang("cancel", forWhom));
|
||||
return lang("insert.clan.tag", (Player) context.getForWhom());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +39,7 @@ public class CreateClanTagPrompt extends StringPrompt {
|
||||
|
||||
Prompt errorPrompt = validateTag(plugin, player, input);
|
||||
if (errorPrompt != null) return errorPrompt;
|
||||
|
||||
context.setSessionData(TAG_KEY, input);
|
||||
return new CreateClanNamePrompt();
|
||||
}
|
||||
|
||||
+6
-9
@@ -5,6 +5,7 @@ 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;
|
||||
@@ -13,14 +14,11 @@ 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) {
|
||||
Player forWhom = (Player) context.getForWhom();
|
||||
return lang("insert.rank.name", forWhom, lang("cancel", forWhom));
|
||||
return lang("insert.rank.name", (Player) context.getForWhom());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,18 +33,17 @@ 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(RED + lang("rank.already.exists", player), this);
|
||||
return new MessagePromptImpl(ChatColor.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(AQUA + lang("rank.created", player));
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("rank.created", player));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
public class DisbandPrompt extends ConfirmationPrompt {
|
||||
|
||||
@Override
|
||||
protected Prompt confirm(ClanPlayer sender, Clan clan) {
|
||||
clan.disband(sender.toPlayer(), true, false);
|
||||
return new MessagePromptImpl(RED + lang("clan.has.been.disbanded", sender, clan.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPromptTextKey() {
|
||||
return "disband.confirmation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeclineTextKey() {
|
||||
return "disband.request.cancelled";
|
||||
}
|
||||
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
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)));
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -1,16 +1,18 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.MessagePrompt;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class MessagePromptImpl extends MessagePrompt {
|
||||
public class MessagePromptImpl extends org.bukkit.conversations.MessagePrompt {
|
||||
|
||||
private final String message;
|
||||
private Prompt nextPrompt;
|
||||
|
||||
public MessagePromptImpl(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
@@ -29,4 +31,5 @@ public class MessagePromptImpl extends MessagePrompt {
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext cc) {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
+42
-19
@@ -2,40 +2,63 @@ package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
/**
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class ResignPrompt extends ConfirmationPrompt {
|
||||
public class ResignPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
protected Prompt confirm(ClanPlayer sender, Clan clan) {
|
||||
if (clan.isPermanent() || !sender.isLeader() || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(sender.getName(), AQUA + lang("0.has.resigned", sender.getName()));
|
||||
sender.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(sender.getUniqueId());
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
|
||||
return new MessagePromptImpl(AQUA + lang("resign.success", sender));
|
||||
} else if (sender.isLeader() && clan.getLeaders().size() == 1) {
|
||||
clan.disband(sender.toPlayer(), true, false);
|
||||
return new MessagePromptImpl(RED + lang("clan.has.been.disbanded", sender, clan.getName()));
|
||||
Player player = (Player) cc.getForWhom();
|
||||
String yes = lang("resign.yes", player);
|
||||
ClanManager cm = Objects.requireNonNull(plugin).getClanManager();
|
||||
ClanPlayer cp = cm.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan == null) {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
if (yes.equalsIgnoreCase(input)) {
|
||||
if (clan.isPermanent() || !clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("resign.success", player));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband(player, true, false);
|
||||
return null;
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
}
|
||||
} else {
|
||||
return new MessagePromptImpl(RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", sender));
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("resign.request.cancelled", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPromptTextKey() {
|
||||
return "resign.confirmation";
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext cc) {
|
||||
Player player = (Player) cc.getForWhom();
|
||||
return ChatColor.RED + MessageFormat.format(
|
||||
lang("resign.confirmation", player), Arrays.asList(
|
||||
lang("resign.yes", player), lang("resign.no", player)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDeclineTextKey() {
|
||||
return "resign.request.cancelled";
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
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,25 +1,21 @@
|
||||
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;
|
||||
@@ -27,7 +23,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");
|
||||
@@ -36,7 +32,7 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
this.sender = sender;
|
||||
this.receivers = receivers;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
@@ -51,10 +47,9 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
public enum Type {
|
||||
ALLY, CLAN
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the chat type
|
||||
*
|
||||
* @return the chat type
|
||||
*/
|
||||
public Type getType() {
|
||||
@@ -74,10 +69,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) {
|
||||
@@ -112,7 +107,6 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Changes the chat message
|
||||
*
|
||||
* @param message the new message
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
|
||||
+6
-9
@@ -1,24 +1,25 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.loggers.BankOperator;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final BankOperator updater;
|
||||
private final CommandSender updater;
|
||||
private final Clan clan;
|
||||
private final Cause cause;
|
||||
private final double balance;
|
||||
private double newBalance;
|
||||
private boolean cancelled;
|
||||
|
||||
public ClanBalanceUpdateEvent(@NotNull BankOperator updater,
|
||||
public ClanBalanceUpdateEvent(@Nullable CommandSender updater,
|
||||
@NotNull Clan clan,
|
||||
double balance,
|
||||
double newBalance,
|
||||
@@ -31,9 +32,9 @@ public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the balance updater
|
||||
* @return the balance updater, may be null
|
||||
*/
|
||||
public @NotNull BankOperator getUpdater() {
|
||||
public @Nullable CommandSender getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
@@ -114,10 +115,6 @@ public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
* When the balance is updated via API methods
|
||||
*/
|
||||
API,
|
||||
/**
|
||||
* WHen the balance is updated via Internal methods
|
||||
*/
|
||||
INTERNAL,
|
||||
/**
|
||||
* When the clan data is being loaded and the balance is set, usually on server start up or plugin reload
|
||||
*/
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClanPlayerTeleportEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ClanPlayer player;
|
||||
private final Location origin;
|
||||
private final Location destination;
|
||||
|
||||
public ClanPlayerTeleportEvent(ClanPlayer player, Location origin, Location destination) {
|
||||
this.player = player;
|
||||
this.origin = origin;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
public ClanPlayer getClanPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Location getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public Location getDestination() {
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -14,14 +11,9 @@ 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(CommandSender sender, Clan clan) {
|
||||
if (sender == null) {
|
||||
sender = Bukkit.getConsoleSender();
|
||||
}
|
||||
this.sender = sender;
|
||||
public DisbandClanEvent(Clan clan) {
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
@@ -29,10 +21,6 @@ public class DisbandClanEvent extends Event {
|
||||
return this.clan;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
|
||||
@@ -50,16 +50,12 @@ public class HomeRegroupEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerHomeClearEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Clan clan;
|
||||
private final ClanPlayer cp;
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerHomeClearEvent(Clan clan, ClanPlayer cp) {
|
||||
this.clan = clan;
|
||||
this.cp = cp;
|
||||
}
|
||||
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
public ClanPlayer getCp() {
|
||||
return cp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,659 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.AccountLinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.AccountUnlinkedEvent;
|
||||
import github.scarsz.discordsrv.api.events.DiscordGuildMessageReceivedEvent;
|
||||
import github.scarsz.discordsrv.dependencies.commons.lang3.StringUtils;
|
||||
import github.scarsz.discordsrv.dependencies.emoji.EmojiParser;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.Permission;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.*;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.exceptions.ErrorResponseException;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.requests.Response;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.requests.RestAction;
|
||||
import github.scarsz.discordsrv.dependencies.kyori.adventure.text.Component;
|
||||
import github.scarsz.discordsrv.objects.managers.AccountLinkManager;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import github.scarsz.discordsrv.util.MessageUtil;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static github.scarsz.discordsrv.dependencies.jda.api.Permission.MANAGE_CHANNEL;
|
||||
import static github.scarsz.discordsrv.dependencies.jda.api.Permission.VIEW_CHANNEL;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.chat.SCMessage.Source.DISCORD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook.DiscordAction.ADD;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.hooks.discord.DiscordHook.DiscordAction.REMOVE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.*;
|
||||
|
||||
/**
|
||||
* Hooks SimpleClans and Discord, using DiscordSRV.
|
||||
* <p>
|
||||
* On server' startup:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Creates categories and channels, respecting discord's limits.</li>
|
||||
* <li>Removes invalid channels, resets permissions and roles.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Manages events:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Clan creation/deletion</li>
|
||||
* <li>ClanPlayer joining/resigning</li>
|
||||
* <li>Player linking/unlinking</li>
|
||||
* <li>ClanPlayer promoting/demoting</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Currently, works with clan chat only.
|
||||
*/
|
||||
public class DiscordHook implements Listener {
|
||||
|
||||
private static final int MAX_CHANNELS_PER_CATEGORY = 50;
|
||||
private static final int MAX_CHANNELS_PER_GUILD = 500;
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final SettingsManager settingsManager;
|
||||
private final ChatManager chatManager;
|
||||
private final ClanManager clanManager;
|
||||
private final AccountLinkManager accountManager = DiscordSRV.getPlugin().getAccountLinkManager();
|
||||
|
||||
private final Guild guild = DiscordSRV.getPlugin().getMainGuild();
|
||||
private final List<String> textCategories;
|
||||
private final List<String> 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 {
|
||||
if (settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
createChannel(event.getClan().getTag());
|
||||
}
|
||||
} catch (DiscordHookException ex) {
|
||||
// Clan is not following the conditions, categories are fulled or discord reaches the limit, nothing to do here.
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanLeave(PlayerKickedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Clan clan = event.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null || clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, REMOVE);
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClanJoin(PlayerJoinedClanEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Clan clan = event.getClan();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null || clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createChannelSilently(clanPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPromote(PlayerPromoteEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLeaderRole(member, clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDemote(PlayerDemoteEvent event) {
|
||||
ClanPlayer clanPlayer = event.getClanPlayer();
|
||||
Member member = getMember(clanPlayer);
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerLinking(AccountLinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
Member member = guild.getMember(event.getUser());
|
||||
if (clanPlayer == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!createChannelSilently(clanPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clan, ADD);
|
||||
updateLeaderRole(member, clanPlayer, ADD);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerUnlinking(AccountUnlinkedEvent event) {
|
||||
ClanPlayer clanPlayer = clanManager.getClanPlayer(event.getPlayer());
|
||||
Member member = guild.getMember(event.getDiscordUser());
|
||||
if (clanPlayer == null || clanPlayer.getClan() == null || member == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateViewPermission(member, clanPlayer.getClan(), REMOVE);
|
||||
updateLeaderRole(member, clanPlayer, REMOVE);
|
||||
}
|
||||
|
||||
protected void setupDiscord() {
|
||||
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)).
|
||||
addMemberPermissionOverride(guild.getSelfMember().getIdLong(),
|
||||
Arrays.asList(VIEW_CHANNEL, MANAGE_CHANNEL),
|
||||
Collections.emptyList()).
|
||||
submit().get();
|
||||
|
||||
textCategories.add(category.getId());
|
||||
settingsManager.set(DISCORDCHAT_TEXT_CATEGORY_IDS, textCategories);
|
||||
settingsManager.save();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error while trying to create {0} category: " +
|
||||
ex.getMessage(), categoryName);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link TextChannel} in available SimpleClans' categories,
|
||||
* otherwise creates one.
|
||||
*
|
||||
* <p>Sets positive {@link Permission#VIEW_CHANNEL} permission to all linked clan members.</p>
|
||||
*
|
||||
* @param clanTag the clan tag
|
||||
*
|
||||
* @throws InvalidChannelException clan is not verified or permanent,
|
||||
* no one member is linked or clan is not in the whitelist.
|
||||
* @throws ChannelExistsException if channel is already exist
|
||||
* @throws CategoriesLimitException if categories reached the limit.
|
||||
* @throws ChannelsLimitException if discord reached the channels limit.
|
||||
*/
|
||||
public void createChannel(@NotNull String clanTag)
|
||||
throws InvalidChannelException, CategoriesLimitException, ChannelsLimitException, ChannelExistsException {
|
||||
validateChannel(clanTag);
|
||||
Map<ClanPlayer, Member> discordClanPlayers = getDiscordPlayers(clanManager.getClan(clanTag));
|
||||
|
||||
if (getChannels().size() >= settingsManager.getInt(DISCORDCHAT_TEXT_LIMIT)) {
|
||||
throw new ChannelsLimitException("Discord reached the channels limit", "discord.reached.channels.limit");
|
||||
}
|
||||
|
||||
Category availableCategory = getCachedCategories().stream().
|
||||
filter(category -> category.getTextChannels().size() < MAX_CHANNELS_PER_CATEGORY).
|
||||
findAny().orElseGet(this::createCategory);
|
||||
|
||||
if (availableCategory == null) {
|
||||
throw new CategoriesLimitException("Discord reached the categories limit", "discord.reached.category.limit");
|
||||
}
|
||||
|
||||
try {
|
||||
availableCategory.createTextChannel(clanTag).complete();
|
||||
} catch (ErrorResponseException ex) {
|
||||
Response response = ex.getResponse();
|
||||
plugin.getLogger().warning(String.format("Could not create a channel for clan %s, error %d - %s",
|
||||
clanTag, response.code, response.message));
|
||||
return;
|
||||
}
|
||||
for (Map.Entry<ClanPlayer, Member> entry : discordClanPlayers.entrySet()) {
|
||||
// The map is formed from clan#getMembers (so the clan exists)
|
||||
//noinspection ConstantConditions
|
||||
updateViewPermission(entry.getValue(), entry.getKey().getClan(), ADD);
|
||||
updateLeaderRole(entry.getValue(), entry.getKey(), ADD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves channel in SimpleClans categories.
|
||||
*
|
||||
* @param channelName the channel name
|
||||
*
|
||||
* @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())).
|
||||
filter(permissionOverride -> !Objects.equals(permissionOverride.getMember(), guild.getSelfMember())).
|
||||
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 ->
|
||||
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 || !settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
createChannel(clan.getTag());
|
||||
} catch (DiscordHookException ex) {
|
||||
// Clan is not following the conditions, categories are fulled or discord reaches the limit, nothing to do here.
|
||||
SimpleClans.debug(ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum DiscordAction {
|
||||
ADD, REMOVE
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class CategoriesLimitException extends DiscordHookException {
|
||||
|
||||
public CategoriesLimitException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.discord.exceptions;
|
||||
|
||||
public class ChannelExistsException extends DiscordHookException {
|
||||
|
||||
public ChannelExistsException(String debugMessage, String messageKey) {
|
||||
super(debugMessage, messageKey);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 246 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user