Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7781156d57 | ||
|
|
274d27265f | ||
|
|
b1bc1b8f21 | ||
|
|
c688bbcd3b | ||
|
|
5dd157f9e2 | ||
|
|
724599b1c9 | ||
|
|
7902935dfb | ||
|
|
b833372604 | ||
|
|
348b24a2d5 | ||
|
|
ddcec39625 | ||
|
|
404e6e611d | ||
|
|
2dc0eced62 | ||
|
|
16ccfd61fd | ||
|
|
bde5c5804c | ||
|
|
14b5f9f6bb | ||
|
|
00c7fe6a71 | ||
|
|
4943dfe141 | ||
|
|
c3baf75bd6 | ||
|
|
c3667f8030 | ||
|
|
4758a61196 | ||
|
|
ac5a6d1a2c | ||
|
|
d7fb4b1505 | ||
|
|
115aa5f65a | ||
|
|
a5cb971071 | ||
|
|
d9476ad0b9 | ||
|
|
26bf3b2e0f | ||
|
|
3da1812fb4 | ||
|
|
07f3bf5a43 | ||
|
|
afa39e1bf7 | ||
|
|
d79c00db88 | ||
|
|
f9e312737e | ||
|
|
5ed8214e7f | ||
|
|
526cd811de | ||
|
|
d163d1cbdb | ||
|
|
4d6bed3a48 | ||
|
|
ea30033d9a | ||
|
|
efe0c2324a | ||
|
|
5e7ccae224 | ||
|
|
c8e5eef453 | ||
|
|
5639531744 | ||
|
|
b2a9a1b1ca | ||
|
|
2481c31b36 | ||
|
|
998cc2bab4 | ||
|
|
73d8bad3fa | ||
|
|
39d043f900 | ||
|
|
ea992f032d | ||
|
|
4294e3c71c | ||
|
|
736e43d572 | ||
|
|
cf75690334 | ||
|
|
fb7f60bdef | ||
|
|
ea5d2d1c34 | ||
|
|
f4298452b3 | ||
|
|
c709322afb | ||
|
|
8925fd4c84 | ||
|
|
b28b3f76e6 | ||
|
|
c4f8604da9 | ||
|
|
1e86f6991b | ||
|
|
53527dc039 | ||
|
|
44dcef1736 | ||
|
|
542207261e | ||
|
|
5c98c1ecda | ||
|
|
61b37d0907 | ||
|
|
e974af3c0e | ||
|
|
182e6e15c8 | ||
|
|
c11a0e326c | ||
|
|
1087235ecb | ||
|
|
cf45e73448 | ||
|
|
6cf8517606 | ||
|
|
f73ac56bde | ||
|
|
be5dc77e24 | ||
|
|
db17074ac0 | ||
|
|
40d506c389 | ||
|
|
d9f87420e1 | ||
|
|
bfa50407a7 | ||
|
|
238ee17de8 | ||
|
|
1b8a3fee6e | ||
|
|
69f75af088 | ||
|
|
895ff3a44c | ||
|
|
22d961b663 | ||
|
|
c006de7c08 | ||
|
|
c0ba056e54 | ||
|
|
2c7a594c56 | ||
|
|
29db5da1dc | ||
|
|
1d3ebafd6c | ||
|
|
07be81b456 | ||
|
|
e7b088d833 | ||
|
|
9ad41ee3d6 | ||
|
|
a053911f00 | ||
|
|
1a2cf1d3b9 | ||
|
|
cc3d7f9502 | ||
|
|
98c69ed9e9 | ||
|
|
f2bc1f12bd | ||
|
|
04a2fd603f | ||
|
|
4e0c123879 | ||
|
|
3bf8e77133 | ||
|
|
11e0344181 | ||
|
|
34d4590d7e | ||
|
|
d1c98f802c | ||
|
|
8f4dbc9f28 | ||
|
|
a5510b98ad | ||
|
|
a7d11f763c | ||
|
|
c50f6dc931 | ||
|
|
2b4e335b14 | ||
|
|
34b0f32f1b | ||
|
|
9ebe483850 | ||
|
|
7757f712cd | ||
|
|
2b562ac466 | ||
|
|
9038f97403 | ||
|
|
0892545252 | ||
|
|
554e5f25bb | ||
|
|
a0114a517d | ||
|
|
960e40b387 | ||
|
|
0ca66fb6a4 | ||
|
|
e2a083f09a | ||
|
|
c825fdd7ab | ||
|
|
7e12fa6d01 | ||
|
|
113ef19966 | ||
|
|
93cb11532a | ||
|
|
7d5699d75e | ||
|
|
ae09353ab4 | ||
|
|
33f9ee7adc | ||
|
|
2ba027f89a | ||
|
|
d2ed8ac366 | ||
|
|
5e03bf53e7 | ||
|
|
01dc9d2304 | ||
|
|
4eafe9afa8 | ||
|
|
f2ba4b8a5c | ||
|
|
7ba439eafc | ||
|
|
5781f64796 | ||
|
|
4d634901b0 | ||
|
|
c1c4a35b82 | ||
|
|
fd0954b510 | ||
|
|
2e1339e08e | ||
|
|
cec163add9 | ||
|
|
43e21924ee | ||
|
|
2bfc37d780 | ||
|
|
3e4a744fc3 | ||
|
|
f203554a64 | ||
|
|
116e99104c | ||
|
|
b5f81ccf79 | ||
|
|
1ee1c288bd | ||
|
|
03b95bbedf | ||
|
|
37ea6fe665 | ||
|
|
23832888e0 | ||
|
|
50666a222a | ||
|
|
0c63974180 | ||
|
|
aa95ce09a4 | ||
|
|
960200a45f | ||
|
|
6c7bfa1752 | ||
|
|
6554a91800 | ||
|
|
73616ddef9 | ||
|
|
ef894a36df | ||
|
|
598e420fa6 | ||
|
|
68065a3b79 | ||
|
|
6e255fc7cb | ||
|
|
36a3d3732a | ||
|
|
934263063e | ||
|
|
af9e9539f9 | ||
|
|
14be85a84c | ||
|
|
3a789adf61 | ||
|
|
2c39603da9 | ||
|
|
6dddc64a95 | ||
|
|
82f94d1149 | ||
|
|
edd19a42d6 | ||
|
|
26d41c2d98 | ||
|
|
d928cf8e39 | ||
|
|
4e1d538ef2 | ||
|
|
b4fbcdd0de | ||
|
|
0ead15ff25 | ||
|
|
3db5a71bbe | ||
|
|
ae86f5b68f | ||
|
|
1ca26319db | ||
|
|
0bb9fd5b53 | ||
|
|
c548f7749e | ||
|
|
888366ce27 | ||
|
|
dc7d414393 | ||
|
|
f5c0920cc9 | ||
|
|
fe866d959a | ||
|
|
6083766a12 | ||
|
|
14b663801d | ||
|
|
b331e2c236 | ||
|
|
b3d5be1ec0 | ||
|
|
b6d9c3a605 | ||
|
|
e2c7b109d9 | ||
|
|
6bb370facd | ||
|
|
b3c8131c96 | ||
|
|
d4c9537296 | ||
|
|
f89d446ac0 | ||
|
|
009564f732 | ||
|
|
a6e10da510 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
root: ./wiki
|
||||
|
||||
structure:
|
||||
readme: README.md
|
||||
summary: SUMMARY.md
|
||||
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 4.5 MiB |
|
After Width: | Height: | Size: 418 KiB |
|
After Width: | Height: | Size: 243 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 1.9 MiB |
@@ -0,0 +1,30 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Run the command '...'
|
||||
2. Click on a mob '....'
|
||||
3. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Software (please complete the following information):**
|
||||
- Server: [e.g. Spigot 1.12]
|
||||
- Plugin version [e.g. 2.12.1]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Publish to Bintray (Spigot 1.13+)
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
server-id: bintray-roinujnosde-bukkit-plugins # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Publish to Bintray
|
||||
run: mvn -B deploy
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.BINTRAY_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.BINTRAY_TOKEN }}
|
||||
@@ -0,0 +1,31 @@
|
||||
# This workflow will build a Java project with Maven
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Java CI Dev Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ dev ]
|
||||
pull_request:
|
||||
branches: [ dev ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Create Staging
|
||||
run: mkdir staging && cp target/SimpleClans.jar staging
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: SimpleClans
|
||||
path: staging
|
||||
@@ -1,6 +1,8 @@
|
||||
/target/
|
||||
/.idea/
|
||||
SimpleClans.iml
|
||||
/bin/
|
||||
/.classpath
|
||||
/.project
|
||||
/dependency-reduced-pom.xml
|
||||
*.jar
|
||||
.settings
|
||||
@@ -10,6 +10,9 @@ jdk: [openjdk8]
|
||||
# if one build failed, exit testing
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
addons:
|
||||
artifacts: true
|
||||
|
||||
# Disable caching in order to get notified if there are some repo/dependency issues
|
||||
## Cache maven dependencies
|
||||
|
||||
@@ -1,15 +1,83 @@
|
||||
[](https://www.spigotmc.org/resources/simpleclans.71242/)
|
||||
|
||||
SimpleClans
|
||||
==========
|
||||
|
||||
Full featured clan system for PVP Minecraft Servers
|
||||
Full featured clan system for PVP Minecraft Servers!
|
||||
|
||||
[](https://travis-ci.org/marcelo-mason/SimpleClans)
|
||||
[](https://github.com/marcelo-mason/SimpleClans/releases)
|
||||
[](https://github.com/marcelo-mason/SimpleClans/issues)
|
||||
[](https://ghit.me/repo/marcelo-mason/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)
|
||||
[](https://discord.gg/CkNwgdE)
|
||||
[](https://bstats.org/plugin/bukkit/SimpleClans/7131)
|
||||
[](https://bstats.org/plugin/bukkit/SimpleClans/7131)
|
||||
|
||||
## Disclaimer:
|
||||
|
||||
Active development for this plugin has stopped. It is in maintenance mode and will continue to be kept up to date as-is with any new Minecraft version indefinitely.
|
||||
#### Download Link
|
||||
|
||||
Pull-requests for bug fixes or new features are welcomed and will be merged in if they do not break existing functionalities.
|
||||
* [Download from Spigot](https://www.spigotmc.org/resources/simpleclans.71242/)
|
||||
|
||||
#### Documentation
|
||||
|
||||
* [Documentation](https://simpleclans.gitbook.io/simpleclans/)
|
||||
* Commands & Permissions
|
||||
* [Permissions](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/permissions)
|
||||
* [Commands](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/commands)
|
||||
* [Clan Alliances and Rivalries](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/aliances-and-rivalries)
|
||||
* [Clan Ranks with Permissions](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/ranks-with-permissions)
|
||||
* How to Setup
|
||||
* [Configuration](https://simpleclans.gitbook.io/simpleclans/how-to-setup/configuration)
|
||||
* [Translation](https://simpleclans.gitbook.io/simpleclans/how-to-setup/translation)
|
||||
* [Clan Member Fee](https://simpleclans.gitbook.io/simpleclans/how-to-setup/member-fee)
|
||||
* [Clan Upkeep](https://simpleclans.gitbook.io/simpleclans/how-to-setup/clan-upkeep)
|
||||
* [Clan name above players head](https://simpleclans.gitbook.io/simpleclans/how-to-setup/clan-below-players-name)
|
||||
* [Clan name on Tablist](https://simpleclans.gitbook.io/simpleclans/how-to-setup/clan-on-tablist)
|
||||
* Plugins & Development
|
||||
* [SimpleClans API Example](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
|
||||
* [PlaceholderAPI Placeholders](https://simpleclans.gitbook.io/simpleclans/other/placeholderapi-support)
|
||||
* [Land Protection Plugins](https://simpleclans.gitbook.io/simpleclans/other/land-claims)
|
||||
|
||||
#### Support & Suggestions
|
||||
|
||||
* [Discord Support](https://discord.gg/CkNwgdE)
|
||||
* [Bugs and Suggestions](https://github.com/RoinujNosde/SimpleClans/issues)
|
||||
|
||||
|
||||
#### Developers
|
||||
|
||||
Including SimpleClans with Maven:
|
||||
```xml
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bintray-roinujnosde-bukkit-plugins</id>
|
||||
<url>https://dl.bintray.com/roinujnosde/bukkit-plugins</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.14.3</version> <!-- You can find the latest version at the bottom -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
Using Gradle:
|
||||
```groovy
|
||||
repositories {
|
||||
maven {
|
||||
url "https://dl.bintray.com/roinujnosde/bukkit-plugins"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.14.3" // You can find the latest version at the bottom
|
||||
}
|
||||
```
|
||||
|
||||
##### Latest version:
|
||||
[](https://bintray.com/roinujnosde/bukkit-plugins/SimpleClans/_latestVersion)
|
||||
|
||||
##### API Examples
|
||||
* [Examples of how to use the API](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
|
||||
@@ -1,28 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.13.2-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.13-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl.vault:VaultAPI:1.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.nijikokun.bukkit:Permissions:2.7.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sacredlabyrinth.Phaed:PreciousStones:9.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.getspout:spoutplugin:dev-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.10.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:16.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.papermc:paperlib:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-paper:0.5.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.cryptomorin:XSeries:7.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.26.0-GA" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.4.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,11 @@
|
||||
<root>
|
||||
<item name='co.aikar.commands.BukkitCommandCompletionContext org.bukkit.entity.Player getPlayer()'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='co.aikar.commands.BukkitCommandExecutionContext org.bukkit.entity.Player getPlayer()'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='co.aikar.commands.BukkitCommandIssuer org.bukkit.entity.Player getPlayer()'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.14.3</version>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://104.236.246.108:8080</url>
|
||||
</ciManagement>
|
||||
<scm>
|
||||
<connection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</connection>
|
||||
<developerConnection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</developerConnection>
|
||||
<tag>SimpleClans</tag>
|
||||
<url>http://github.com/marcelo-mason/SimpleClans.git/tree/master/</url>
|
||||
</scm>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>${project.name}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.acf</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.locales</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.locales</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>org.jetbrains:annotations</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi-repo</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bstats-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<groupId>net.md-5</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.bukkit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>apiguardian-api</artifactId>
|
||||
<groupId>org.apiguardian</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>opentest4j</artifactId>
|
||||
<groupId>org.opentest4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>junit-platform-commons</artifactId>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>bintray-roinujnosde-bukkit-plugins</id>
|
||||
<name>roinujnosde-bukkit-plugins</name>
|
||||
<url>https://api.bintray.com/maven/roinujnosde/bukkit-plugins/SimpleClans/;publish=1</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<root>
|
||||
<item name='org.bukkit.configuration.MemorySection java.lang.String getString(java.lang.String, java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val val=""_, _, -> !null""/>
|
||||
</annotation>
|
||||
</item>
|
||||
</root>
|
||||
@@ -1,8 +1,9 @@
|
||||
<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.9.2</version>
|
||||
<version>2.14.4.1</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
|
||||
@@ -18,9 +19,7 @@
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>language.yml</include>
|
||||
<include>language-pt-br.yml</include>
|
||||
<include>language-zh.yml</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@@ -38,6 +37,9 @@
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -57,38 +59,63 @@
|
||||
|
||||
<!-- Shade plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats.bukkit</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.commands</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.acf</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>co.aikar.locales</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.locales</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>org.jetbrains:annotations</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Dependencies -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
@@ -97,28 +124,79 @@
|
||||
<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>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.aikar</groupId>
|
||||
<artifactId>acf-paper</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
<version>7.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Repositories -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>paper-repo</id>
|
||||
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
|
||||
<id>placeholderapi-repo</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bstats-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>aikar</id>
|
||||
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@@ -144,14 +222,9 @@
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>SacredCoding</id>
|
||||
<name>SacredCoding-releases</name>
|
||||
<url>http://104.236.246.108:8081/artifactory/plugins-release-local</url>
|
||||
<id>bintray-roinujnosde-bukkit-plugins</id>
|
||||
<name>roinujnosde-bukkit-plugins</name>
|
||||
<url>https://api.bintray.com/maven/roinujnosde/bukkit-plugins/SimpleClans/;publish=1</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>SacredCoding</id>
|
||||
<name>SacredCoding-snapshots</name>
|
||||
<url>http://104.236.246.108:8081/artifactory/plugins-release-local</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -2,6 +2,8 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -9,6 +11,8 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -170,6 +174,7 @@ public class ChatBlock {
|
||||
}
|
||||
|
||||
|
||||
List<String> messages = new ArrayList<>();
|
||||
// size up all sections
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
@@ -285,11 +290,12 @@ public class ChatBlock {
|
||||
msg = color + msg;
|
||||
}
|
||||
|
||||
player.sendMessage(msg);
|
||||
messages.add(msg);
|
||||
|
||||
prefix_used = true;
|
||||
}
|
||||
|
||||
player.sendMessage(messages.toArray(new String[0]));
|
||||
return !rows.isEmpty();
|
||||
}
|
||||
|
||||
@@ -620,7 +626,7 @@ public class ChatBlock {
|
||||
* @param receiver
|
||||
* @param msg
|
||||
*/
|
||||
public static void sendMessage(CommandSender receiver, String msg) {
|
||||
public static void sendMessage(@Nullable CommandSender receiver, @NotNull String msg) {
|
||||
if (receiver == null) {
|
||||
return;
|
||||
}
|
||||
@@ -632,6 +638,10 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendMessageKey(@Nullable CommandSender receiver, @NotNull String key, @NotNull Object... args) {
|
||||
sendMessage(receiver, lang(key, receiver, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send blank lie
|
||||
*
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
@@ -41,8 +46,8 @@ 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 List<String> members = new ArrayList<>();
|
||||
private HashMap<String, Clan> warringClans = new HashMap<>();
|
||||
private final List<String> members = new ArrayList<>();
|
||||
private final HashMap<String, Clan> warringClans = new HashMap<>();
|
||||
private int homeX = 0;
|
||||
private int homeY = 0;
|
||||
private int homeZ = 0;
|
||||
@@ -51,6 +56,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private boolean allowDeposit = true;
|
||||
private boolean feeEnabled;
|
||||
private List<Rank> ranks = new ArrayList<>();
|
||||
private @Nullable ItemStack banner;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -85,7 +91,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (!(obj instanceof Clan)) {
|
||||
return false;
|
||||
}
|
||||
@@ -111,17 +117,23 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param player
|
||||
*/
|
||||
public void deposit(double amount, Player player) {
|
||||
BankDepositEvent event = new BankDepositEvent(player, this, amount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
amount = event.getAmount();
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerHasMoney(player, amount)) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerChargeMoney(player, amount)) {
|
||||
player.sendMessage(ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("player.clan.deposit"), amount));
|
||||
addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("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(ChatColor.AQUA + SimpleClans.getInstance().getLang("not.sufficient.money"));
|
||||
player.sendMessage(ChatColor.AQUA + lang("not.sufficient.money",player));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + SimpleClans.getInstance().getLang("not.sufficient.money"));
|
||||
player.sendMessage(ChatColor.AQUA + lang("not.sufficient.money",player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,15 +144,21 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param player
|
||||
*/
|
||||
public void withdraw(double amount, Player player) {
|
||||
BankWithdrawEvent event = new BankWithdrawEvent(player, this, amount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
amount = event.getAmount();
|
||||
if (getBalance() >= amount) {
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerGrantMoney(player, amount)) {
|
||||
player.sendMessage(ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("player.clan.withdraw"), amount));
|
||||
addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("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);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + SimpleClans.getInstance().getLang("clan.bank.not.enough.money"));
|
||||
player.sendMessage(ChatColor.AQUA + lang("clan.bank.not.enough.money",player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +311,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check if the player is a member of this clan
|
||||
*
|
||||
* @param player
|
||||
* @param player the Player
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(Player player) {
|
||||
@@ -303,13 +321,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check if the player is a member of this clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @param playerUniqueId the Player's UUID
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(UUID playerUniqueId) {
|
||||
return this.members.contains(playerUniqueId.toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isMember(String playerName) {
|
||||
return isMember(Bukkit.getOfflinePlayer(playerName).getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with the contents of the bulletin board
|
||||
@@ -713,6 +735,11 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isLeader(String playerName) {
|
||||
return isLeader(Bukkit.getOfflinePlayer(playerName).getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all members that must pay the fee (that excludes leaders and players with the permission to bypass it)
|
||||
*
|
||||
@@ -1051,6 +1078,11 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerJoinedClanEvent(this, cp));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void removePlayerFromClan(String playerName) {
|
||||
removePlayerFromClan(Bukkit.getOfflinePlayer(playerName).getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a clan
|
||||
*
|
||||
@@ -1084,6 +1116,11 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerKickedClanEvent(this, cp));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void promote(String playerName) {
|
||||
promote(Bukkit.getOfflinePlayer(playerName).getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Promote a member to a leader of a clan
|
||||
*
|
||||
@@ -1103,6 +1140,11 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerPromoteEvent(this, cp));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void demote(String playerName) {
|
||||
demote(Bukkit.getOfflinePlayer(playerName).getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Demote a leader back to a member of a clan
|
||||
*
|
||||
@@ -1217,7 +1259,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
online.remove(cp);
|
||||
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercentageOnlineToDemote();
|
||||
double totalLeaders = getLeaders().size();
|
||||
// all leaders minus the one being demoted
|
||||
double totalLeaders = getLeaders().size() - 1;
|
||||
double onlineLeaders = online.size();
|
||||
|
||||
|
||||
@@ -1322,7 +1365,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + SimpleClans.getInstance().getLang("clan.announce") + ChatColor.AQUA + "] " + ChatColor.AQUA + "[" + Helper.getColorName(playerName) + ChatColor.WHITE + "] " + message);
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + lang("clan.announce") + ChatColor.AQUA + "] " + ChatColor.AQUA + "[" + Helper.getColorName(playerName) + ChatColor.WHITE + "] " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1342,7 +1385,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
ChatBlock.sendMessage(pl, message);
|
||||
}
|
||||
}
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + SimpleClans.getInstance().getLang("leader.announce") + ChatColor.AQUA + "] " + ChatColor.WHITE + message);
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "[" + lang("leader.announce") + ChatColor.AQUA + "] " + ChatColor.WHITE + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1380,7 +1423,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void displayBb(Player player) {
|
||||
if (isVerified()) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, MessageFormat.format(SimpleClans.getInstance().getLang("bulletin.board.header"), SimpleClans.getInstance().getSettingsManager().getBbAccentColor(), SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor(), Helper.capitalize(getName())));
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", SimpleClans.getInstance().getSettingsManager().getBbAccentColor(), SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor(), getName()));
|
||||
|
||||
int maxSize = SimpleClans.getInstance().getSettingsManager().getBbSize();
|
||||
|
||||
@@ -1407,7 +1450,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void displayBb(Player player, int maxSize) {
|
||||
if (isVerified()) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, MessageFormat.format(SimpleClans.getInstance().getLang("bulletin.board.header"), SimpleClans.getInstance().getSettingsManager().getBbAccentColor(), SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor(), Helper.capitalize(getName())));
|
||||
ChatBlock.saySingle(player, lang("bulletin.board.header", SimpleClans.getInstance().getSettingsManager().getBbAccentColor(), SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor(), getName()));
|
||||
|
||||
List<String> localBb = new ArrayList<>(bb);
|
||||
while (localBb.size() > maxSize) {
|
||||
@@ -1446,8 +1489,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
textComponent.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(
|
||||
Dates.formatTime(time, 1) + SimpleClans
|
||||
.getInstance().getLang("bb.ago"))));
|
||||
Dates.formatTime(time, 1) + lang("bb.ago"))));
|
||||
player.spigot().sendMessage(textComponent);
|
||||
return true;
|
||||
} catch (Throwable rock) {
|
||||
@@ -1479,18 +1521,18 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
clans.remove(this);
|
||||
|
||||
for (Clan c : clans) {
|
||||
String disbanded = SimpleClans.getInstance().getLang("clan.disbanded");
|
||||
String disbanded = lang("clan.disbanded");
|
||||
|
||||
if (c.removeWarringClan(this)) {
|
||||
c.addBb(disbanded, ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("you.are.no.longer.at.war"), Helper.capitalize(c.getName()), getColorTag()));
|
||||
c.addBb(disbanded, ChatColor.AQUA + MessageFormat.format(lang("you.are.no.longer.at.war"), c.getName(), getColorTag()));
|
||||
}
|
||||
|
||||
if (c.removeRival(getTag())) {
|
||||
c.addBb(disbanded, ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("has.been.disbanded.rivalry.ended"), Helper.capitalize(getName())));
|
||||
c.addBb(disbanded, ChatColor.AQUA + MessageFormat.format(lang("has.been.disbanded.rivalry.ended"), getName()));
|
||||
}
|
||||
|
||||
if (c.removeAlly(getTag())) {
|
||||
c.addBb(disbanded, ChatColor.AQUA + MessageFormat.format(SimpleClans.getInstance().getLang("has.been.disbanded.alliance.ended"), Helper.capitalize(getName())));
|
||||
c.addBb(disbanded, ChatColor.AQUA + MessageFormat.format(lang("has.been.disbanded.alliance.ended"), getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1663,7 +1705,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
|
||||
public void setHomeLocation(Location home) {
|
||||
public void setHomeLocation(@Nullable Location home) {
|
||||
if (home == null) {
|
||||
homeY = 0;
|
||||
homeX = 0;
|
||||
@@ -1680,7 +1722,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
|
||||
public Location getHomeLocation() {
|
||||
public @Nullable Location getHomeLocation() {
|
||||
if (homeWorld == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -1691,7 +1733,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(world.getBlockAt(homeX, homeY, homeZ).getType().equals(Material.AIR)) || !(world.getBlockAt(homeX, homeY + 1, homeZ).getType().equals(Material.AIR)) || homeY == 0) {
|
||||
if (!(world.getBlockAt(homeX, homeY, homeZ).getType().equals(XMaterial.AIR.parseMaterial())) ||
|
||||
!(world.getBlockAt(homeX, homeY + 1, homeZ).getType().equals(XMaterial.AIR.parseMaterial()))
|
||||
|| homeY == 0) {
|
||||
return new Location(world, homeX, world.getHighestBlockYAt(homeX, homeZ), homeZ);
|
||||
} else {
|
||||
return new Location(world, homeX, homeY, homeZ);
|
||||
@@ -1832,7 +1876,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param name the rank name
|
||||
* @return a rank or null
|
||||
*/
|
||||
public Rank getRank(String name) {
|
||||
public @Nullable Rank getRank(String name) {
|
||||
if (name != null) {
|
||||
for (Rank r : ranks) {
|
||||
if (r.getName().equals(name)) {
|
||||
@@ -1842,4 +1886,29 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBanner(@Nullable ItemStack banner) {
|
||||
if (banner == null) {
|
||||
this.banner = null;
|
||||
return;
|
||||
}
|
||||
banner = banner.clone();
|
||||
banner.setAmount(1);
|
||||
ItemMeta itemMeta = banner.getItemMeta();
|
||||
if (itemMeta != null) {
|
||||
// hides the banner patterns from the lore (I don't know why it's called POTION_EFFECTS)
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemMeta.setLore(null);
|
||||
itemMeta.setDisplayName(null);
|
||||
banner.setItemMeta(itemMeta);
|
||||
}
|
||||
this.banner = banner;
|
||||
}
|
||||
|
||||
public @Nullable ItemStack getBanner() {
|
||||
if (banner != null) {
|
||||
return banner.clone();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
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;
|
||||
@@ -14,6 +17,8 @@ import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -34,9 +39,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
private long lastSeen;
|
||||
private long joinDate;
|
||||
private Set<String> pastClans = new HashSet<>();
|
||||
private Map<String, Long> resignTimes = new HashMap<>();
|
||||
private VoteResult vote;
|
||||
private Channel channel;
|
||||
private final Map<String, Long> resignTimes = new HashMap<>();
|
||||
private @Nullable VoteResult vote;
|
||||
private @NotNull Channel channel;
|
||||
|
||||
private boolean useChatShortcut = false;
|
||||
private boolean globalChat = true;
|
||||
@@ -50,6 +55,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
private boolean clanChatMute = false;
|
||||
|
||||
private String rank = "";
|
||||
private @Nullable Locale locale;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -77,19 +83,19 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerUniqueId
|
||||
* @param uuid the Player's UUID
|
||||
*/
|
||||
public ClanPlayer(UUID playerUniqueId)
|
||||
public ClanPlayer(UUID uuid)
|
||||
{
|
||||
this.uniqueId = playerUniqueId;
|
||||
Player OnlinePlayer = SimpleClans.getInstance().getServer().getPlayer(playerUniqueId);
|
||||
if (OnlinePlayer != null)
|
||||
this.uniqueId = uuid;
|
||||
Player onlinePlayer = SimpleClans.getInstance().getServer().getPlayer(uuid);
|
||||
if (onlinePlayer != null)
|
||||
{
|
||||
this.displayName = OnlinePlayer.getName();
|
||||
this.displayName = onlinePlayer.getName();
|
||||
} else
|
||||
{
|
||||
OfflinePlayer OfflinePlayer = SimpleClans.getInstance().getServer().getOfflinePlayer(playerUniqueId);
|
||||
this.displayName = OfflinePlayer.getName();
|
||||
OfflinePlayer offlinePlayer = SimpleClans.getInstance().getServer().getOfflinePlayer(uuid);
|
||||
this.displayName = offlinePlayer.getName() != null ? offlinePlayer.getName() : "null";
|
||||
}
|
||||
this.lastSeen = (new Date()).getTime();
|
||||
this.joinDate = (new Date()).getTime();
|
||||
@@ -270,28 +276,40 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a verbal representation of how many days ago a player was last seen
|
||||
*
|
||||
* @return
|
||||
* @return a verbal representation of how many days ago a player was last seen
|
||||
*/
|
||||
public String getLastSeenDaysString()
|
||||
{
|
||||
return getLastSeenDaysString(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender the Player viewing the last seen days
|
||||
* @return a verbal representation of how many days ago a player was last seen
|
||||
*/
|
||||
public String getLastSeenDaysString(@Nullable CommandSender sender)
|
||||
{
|
||||
double days = Dates.differenceInDays(new Timestamp(lastSeen), new Timestamp((new Date()).getTime()));
|
||||
|
||||
if (days < 1)
|
||||
{
|
||||
return SimpleClans.getInstance().getLang("today");
|
||||
return lang("today", sender);
|
||||
}
|
||||
else if (Math.round(days) == 1)
|
||||
{
|
||||
return MessageFormat.format(SimpleClans.getInstance().getLang("1.color.day"), ChatColor.GRAY);
|
||||
return lang("1.color.day", sender, ChatColor.GRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageFormat.format(SimpleClans.getInstance().getLang("many.color.days"), Math.round(days), ChatColor.GRAY);
|
||||
return lang("many.color.days", sender, Math.round(days), ChatColor.GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastSeenDaysString(@Nullable Player viewer) {
|
||||
return getLastSeenDaysString((CommandSender) viewer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of days since the player was last seen
|
||||
*
|
||||
@@ -430,7 +448,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the vote
|
||||
*/
|
||||
public VoteResult getVote()
|
||||
public @Nullable VoteResult getVote()
|
||||
{
|
||||
return vote;
|
||||
}
|
||||
@@ -440,7 +458,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @param vote the vote to set
|
||||
*/
|
||||
public void setVote(VoteResult vote)
|
||||
public void setVote(@Nullable VoteResult vote)
|
||||
{
|
||||
this.vote = vote;
|
||||
}
|
||||
@@ -537,15 +555,29 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the last seen date
|
||||
*
|
||||
* @return
|
||||
* @return a string representation of the last seen date
|
||||
*/
|
||||
@NotNull
|
||||
public String getLastSeenString()
|
||||
{
|
||||
if (toPlayer() != null) {
|
||||
return SimpleClans.getInstance().getLang("online");
|
||||
}
|
||||
return getLastSeenString(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param viewer the Player viewing the last seen
|
||||
* @return a string representation of the last seen date
|
||||
*/
|
||||
public String getLastSeenString(@Nullable Player viewer) {
|
||||
return getLastSeenString((CommandSender) viewer);
|
||||
}
|
||||
|
||||
public String getLastSeenString(@Nullable CommandSender sender) {
|
||||
Player player = toPlayer();
|
||||
if (player != null && player.isOnline() && !Helper.isVanished(sender, player)) {
|
||||
return lang("online", sender);
|
||||
}
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.lastSeen));
|
||||
}
|
||||
|
||||
@@ -567,16 +599,16 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*/
|
||||
public String getPackedPastClans()
|
||||
{
|
||||
String PackedPastClans = "";
|
||||
String packedPastClans = "";
|
||||
|
||||
Set<String> pt = getPastClans();
|
||||
|
||||
for (String pastClan : pt)
|
||||
{
|
||||
PackedPastClans += pastClan + "|";
|
||||
packedPastClans += pastClan + "|";
|
||||
}
|
||||
|
||||
return Helper.stripTrailing(PackedPastClans, "|");
|
||||
return Helper.stripTrailing(packedPastClans, "|");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -610,28 +642,39 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a separator delimited string with the color tags for all past clans this player has been in
|
||||
*
|
||||
* @param sep
|
||||
* @return
|
||||
* @param sep the separator
|
||||
* @return a separator delimited string with the color tags for all past clans this player has been in
|
||||
*/
|
||||
public String getPastClansString(String sep)
|
||||
@NotNull
|
||||
public String getPastClansString(@NotNull String sep)
|
||||
{
|
||||
String out = "";
|
||||
return getPastClansString(sep, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sep the separator
|
||||
* @param viewer the Player viewing the clan's string
|
||||
* @return a separator delimited string with the color tags for all past clans this player has been in
|
||||
*/
|
||||
@NotNull
|
||||
public String getPastClansString(String sep, @Nullable Player viewer) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String pastClan : getPastClans())
|
||||
{
|
||||
out += pastClan + sep;
|
||||
out.append(pastClan).append(sep);
|
||||
}
|
||||
|
||||
out = Helper.stripTrailing(out, sep);
|
||||
out = new StringBuilder(Helper.stripTrailing(out.toString(), sep));
|
||||
|
||||
if (out.trim().isEmpty())
|
||||
if (out.toString().trim().isEmpty())
|
||||
{
|
||||
return SimpleClans.getInstance().getLang("none");
|
||||
return lang("none", viewer);
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,6 +740,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the clan
|
||||
*/
|
||||
@Nullable
|
||||
public Clan getClan()
|
||||
{
|
||||
return clan;
|
||||
@@ -901,42 +945,48 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
}
|
||||
|
||||
public Channel getChannel()
|
||||
public @NotNull Channel getChannel()
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isGlobalChat()
|
||||
{
|
||||
return globalChat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isAllyChat()
|
||||
{
|
||||
return allyChat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isClanChat()
|
||||
{
|
||||
return clanChat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setGlobalChat(boolean globalChat)
|
||||
{
|
||||
this.globalChat = globalChat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setAllyChat(boolean allyChat)
|
||||
{
|
||||
this.allyChat = allyChat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setClanChat(boolean clanChat)
|
||||
{
|
||||
this.clanChat = clanChat;
|
||||
}
|
||||
|
||||
public void setChannel(Channel channel)
|
||||
public void setChannel(@NotNull Channel channel)
|
||||
{
|
||||
this.channel = channel;
|
||||
}
|
||||
@@ -1015,7 +1065,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @param rank the rank id
|
||||
*/
|
||||
public void setRank(String rank)
|
||||
public void setRank(@Nullable String rank)
|
||||
{
|
||||
if (rank == null) {
|
||||
rank = "";
|
||||
@@ -1023,6 +1073,17 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
public @NotNull Locale getLocale() {
|
||||
if (locale == null) {
|
||||
return SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(@Nullable Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public enum Channel
|
||||
{
|
||||
CLAN,
|
||||
@@ -1030,7 +1091,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
NONE
|
||||
}
|
||||
|
||||
public Player toPlayer()
|
||||
public @Nullable Player toPlayer()
|
||||
{
|
||||
if (this.uniqueId != null)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -143,46 +145,46 @@ public class Dates {
|
||||
{
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
if (seconds == null || seconds < 1) {
|
||||
return plugin.getLang("bb.moments");
|
||||
return lang("bb.moments");
|
||||
}
|
||||
|
||||
if (seconds < 60) {
|
||||
return seconds + plugin.getLang("bb.seconds");
|
||||
return seconds + lang("bb.seconds");
|
||||
}
|
||||
|
||||
if (seconds < 3600) {
|
||||
Long count = (long) Math.ceil(seconds / 60);
|
||||
long count = (long) Math.ceil(seconds / 60f);
|
||||
String res;
|
||||
if (count > 1) {
|
||||
res = count + plugin.getLang("bb.minutes");
|
||||
res = count + lang("bb.minutes");
|
||||
} else {
|
||||
res = plugin.getLang("bb.one.minute");
|
||||
res = lang("bb.one.minute");
|
||||
}
|
||||
Long remaining = seconds % 60;
|
||||
long remaining = seconds % 60;
|
||||
if (depth > 0 && remaining >= 5) {
|
||||
return res + ", " + formatTime(remaining, --depth);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (seconds < 86400) {
|
||||
Long count = (long) Math.ceil(seconds / 3600);
|
||||
long count = (long) Math.ceil(seconds / 3600f);
|
||||
String res;
|
||||
if (count > 1) {
|
||||
res = count + plugin.getLang("bb.hours");
|
||||
res = count + lang("bb.hours");
|
||||
} else {
|
||||
res = plugin.getLang("bb.one.hour");
|
||||
res = lang("bb.one.hour");
|
||||
}
|
||||
if (depth > 0) {
|
||||
return res + ", " + formatTime(seconds % 3600, --depth);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
Long count = (long) Math.ceil(seconds / 86400);
|
||||
long count = (long) Math.ceil(seconds / 86400f);
|
||||
String res;
|
||||
if (count > 1) {
|
||||
res = count + plugin.getLang("bb.days");
|
||||
res = count + lang("bb.days");
|
||||
} else {
|
||||
res = plugin.getLang("bb.one.day");
|
||||
res = lang("bb.one.day");
|
||||
}
|
||||
if (depth > 0) {
|
||||
return res + ", " + formatTime(seconds % 86400, --depth);
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -14,14 +20,13 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -33,19 +38,53 @@ public class Helper {
|
||||
/**
|
||||
* Dumps stacktrace to log
|
||||
*/
|
||||
@Deprecated
|
||||
public static void dumpStackTrace() {
|
||||
for (StackTraceElement el : Thread.currentThread().getStackTrace()) {
|
||||
SimpleClans.debug(el.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link KDRFormat}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String formatKDR(float kdr) {
|
||||
DecimalFormat formatter = new DecimalFormat("#.#");
|
||||
return formatter.format(kdr);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Locale forLanguageTag(@Nullable String languageTag) {
|
||||
Locale defaultLanguage = SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
if (languageTag == null) {
|
||||
return defaultLanguage;
|
||||
}
|
||||
return Locale.forLanguageTag(languageTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Player locale
|
||||
*
|
||||
* @param player the player
|
||||
* @return the locale
|
||||
*/
|
||||
@Nullable
|
||||
public static Locale getLocale(@NotNull Player player) {
|
||||
ClanPlayer clanPlayer = SimpleClans.getInstance().getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
if (clanPlayer != null) {
|
||||
return clanPlayer.getLocale();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JSON String to a list of Ranks
|
||||
*
|
||||
* @param json
|
||||
* @param json the JSON String
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static List<Rank> ranksFromJson(String json) {
|
||||
public static @Nullable List<Rank> ranksFromJson(String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
try {
|
||||
JSONObject jo = (JSONObject) new JSONParser().parse(json);
|
||||
@@ -331,12 +370,17 @@ public class Helper {
|
||||
* @param hexValue
|
||||
* @return
|
||||
*/
|
||||
public static String toColor(String hexValue) {
|
||||
@NotNull
|
||||
public static String toColor(@Nullable String hexValue) {
|
||||
if (hexValue == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return ChatColor.getByChar(hexValue).toString();
|
||||
ChatColor color = ChatColor.getByChar(hexValue);
|
||||
if (color == null) {
|
||||
return "";
|
||||
}
|
||||
return color.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -423,13 +467,13 @@ public class Helper {
|
||||
* @return
|
||||
*/
|
||||
public static String toMessage(String[] args) {
|
||||
String out = "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String arg : args) {
|
||||
out += arg + " ";
|
||||
out.append(arg).append(" ");
|
||||
}
|
||||
|
||||
return out.trim();
|
||||
return out.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,7 +584,7 @@ public class Helper {
|
||||
|
||||
String out = msg;
|
||||
String first = msg.substring(0, sep.length());
|
||||
String last = msg.substring(msg.length() - sep.length(), msg.length());
|
||||
String last = msg.substring(msg.length() - sep.length());
|
||||
|
||||
if (first.equals(sep)) {
|
||||
out = msg.substring(sep.length());
|
||||
@@ -651,7 +695,7 @@ public class Helper {
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String escapeQuotes(String str) {
|
||||
public static String escapeQuotes(@Nullable String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
@@ -692,30 +736,44 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort hashmap by value
|
||||
* Sorts a Map by value
|
||||
*
|
||||
* @param map
|
||||
* @return Map
|
||||
* @param map the Map to sort
|
||||
* @return the Map sorted
|
||||
*/
|
||||
public static Map sortByValue(Map map) {
|
||||
List list = new LinkedList(map.entrySet());
|
||||
Collections.sort(list, new Comparator() {
|
||||
public static <K, V extends Comparable<V>> Map<K, V> sortByValue(Map<K, V> map) {
|
||||
LinkedList<Map.Entry<K, V>> entryList = new LinkedList<>(map.entrySet());
|
||||
entryList.sort(Entry.comparingByValue());
|
||||
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((Comparable) ((Map.Entry) (o2)).getValue()).compareTo(((Map.Entry) (o1)).getValue());
|
||||
}
|
||||
});
|
||||
|
||||
Map result = new LinkedHashMap();
|
||||
for (Iterator it = list.iterator(); it.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
Map<K, V> result = new LinkedHashMap<>();
|
||||
for (Entry<K, V> entry : entryList) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isVanished(Player player) {
|
||||
|
||||
/**
|
||||
* @deprecated use {@link VanishUtils#isVanished(CommandSender, Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("_, null -> false")
|
||||
public static boolean isVanished(@Nullable CommandSender viewer, @Nullable Player player) {
|
||||
if (isVanished(player)) {
|
||||
return true;
|
||||
}
|
||||
if (viewer instanceof Player && player != null) {
|
||||
return !((Player) viewer).canSee(player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link VanishUtils#isVanished(Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("null -> false")
|
||||
public static boolean isVanished(@Nullable Player player) {
|
||||
if (player != null && player.hasMetadata("vanished") && !player.getMetadata("vanished").isEmpty()) {
|
||||
return player.getMetadata("vanished").get(0).asBoolean();
|
||||
}
|
||||
@@ -740,8 +798,10 @@ public class Helper {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public static Player getPlayer(String playerName) {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(UUIDMigration.getForcedPlayerUUID(playerName));
|
||||
return Bukkit.getPlayerExact(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -770,13 +830,12 @@ public class Helper {
|
||||
}
|
||||
|
||||
private static String replacePlaceholders(String messageFormat, ClanPlayer cp, String leaderColor, String memberColor, String rankFormat, String msg) {
|
||||
String message = ChatColor.translateAlternateColorCodes('&', messageFormat)
|
||||
.replace("%clan%", cp.getClan().getColorTag())
|
||||
return ChatColor.translateAlternateColorCodes('&', messageFormat)
|
||||
.replace("%clan%", Objects.requireNonNull(cp.getClan()).getColorTag())
|
||||
.replace("%nick-color%", (cp.isLeader() ? leaderColor : memberColor))
|
||||
.replace("%player%", cp.getName())
|
||||
.replace("%rank%", rankFormat)
|
||||
.replace("%message%", msg);
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerNameTabCompleter implements TabCompleter {
|
||||
private SimpleClans plugin;
|
||||
|
||||
public PlayerNameTabCompleter() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
if (command.getName().equalsIgnoreCase(plugin.getSettingsManager().getCommandClan())) {
|
||||
if (strings.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (strings[0].equalsIgnoreCase(plugin.getLang("lookup.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("ban.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("unban.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("kick.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("trust.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("untrust.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("promote.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("demote.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("setrank.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("place.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("invite.command")) ||
|
||||
strings[0].equalsIgnoreCase(plugin.getLang("kills.command"))) {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
for (OfflinePlayer player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().startsWith(strings[1])) {
|
||||
list.add(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
@@ -7,46 +10,75 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
*/
|
||||
public enum RankPermission {
|
||||
|
||||
ALLY_ADD("simpleclans.leader.ally"), ALLY_CHAT("simpleclans.member.ally"), ALLY_REMOVE("simpleclans.leader.ally"),
|
||||
BANK_BALANCE("simpleclans.member.bank"), BANK_DEPOSIT("simpleclans.member.bank"),
|
||||
BANK_WITHDRAW("simpleclans.member.bank"), BB_ADD("simpleclans.member.bb-add"),
|
||||
BB_CLEAR("simpleclans.leader.bb-clear"), COORDS("simpleclans.member.coords"),
|
||||
FEE_ENABLE("simpleclans.leader.fee"), FEE_SET("simpleclans.leader.fee"),
|
||||
HOME_REGROUP("simpleclans.leader.home-regroup"), HOME_SET("simpleclans.leader.home-set"),
|
||||
HOME_TP("simpleclans.member.home"), INVITE("simpleclans.leader.invite"), KICK("simpleclans.leader.kick"),
|
||||
MODTAG("simpleclans.leader.modtag"), RANK_DISPLAYNAME("simpleclans.leader.rank.setdisplayname"),
|
||||
RANK_LIST("simpleclans.leader.rank.list"), RIVAL_ADD("simpleclans.leader.rival"),
|
||||
RIVAL_REMOVE("simpleclans.leader.rival"), WAR_END("simpleclans.leader.war"), WAR_START("simpleclans.leader.war"),
|
||||
STATS("simpleclans.member.stats"), VITALS("simpleclans.member.vitals"), KILLS("simpleclans.member.kills"),
|
||||
DESCRIPTION("simpleclans.leader.description"), MOSTKILLED("simpleclans.mod.mostkilled");
|
||||
ALLY_ADD("simpleclans.leader.ally", PermissionLevel.LEADER),
|
||||
ALLY_CHAT("simpleclans.member.ally", PermissionLevel.TRUSTED),
|
||||
ALLY_REMOVE("simpleclans.leader.ally", PermissionLevel.LEADER),
|
||||
BANK_BALANCE("simpleclans.member.bank", PermissionLevel.TRUSTED),
|
||||
BANK_DEPOSIT("simpleclans.member.bank", PermissionLevel.LEADER),
|
||||
BANK_WITHDRAW("simpleclans.member.bank", PermissionLevel.LEADER),
|
||||
BB_ADD("simpleclans.member.bb-add", PermissionLevel.TRUSTED),
|
||||
BB_CLEAR("simpleclans.leader.bb-clear", PermissionLevel.LEADER),
|
||||
COORDS("simpleclans.member.coords", PermissionLevel.TRUSTED),
|
||||
FEE_ENABLE("simpleclans.leader.fee", PermissionLevel.LEADER),
|
||||
FEE_SET("simpleclans.leader.fee", 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),
|
||||
HOME_TP("simpleclans.member.home", PermissionLevel.TRUSTED),
|
||||
INVITE("simpleclans.leader.invite", PermissionLevel.LEADER),
|
||||
KICK("simpleclans.leader.kick", PermissionLevel.LEADER),
|
||||
MODTAG("simpleclans.leader.modtag", PermissionLevel.LEADER),
|
||||
RANK_DISPLAYNAME("simpleclans.leader.rank.setdisplayname", PermissionLevel.LEADER),
|
||||
RANK_LIST("simpleclans.leader.rank.list", PermissionLevel.LEADER),
|
||||
RIVAL_ADD("simpleclans.leader.rival", PermissionLevel.LEADER),
|
||||
RIVAL_REMOVE("simpleclans.leader.rival", PermissionLevel.LEADER),
|
||||
WAR_END("simpleclans.leader.war", PermissionLevel.LEADER),
|
||||
WAR_START("simpleclans.leader.war", PermissionLevel.LEADER),
|
||||
STATS("simpleclans.member.stats", PermissionLevel.TRUSTED),
|
||||
VITALS("simpleclans.member.vitals", PermissionLevel.TRUSTED),
|
||||
KILLS("simpleclans.member.kills", PermissionLevel.TRUSTED),
|
||||
DESCRIPTION("simpleclans.leader.description", PermissionLevel.LEADER),
|
||||
MOSTKILLED("simpleclans.mod.mostkilled", PermissionLevel.TRUSTED),
|
||||
FRIENDLYFIRE("simpleclans.leader.ff", PermissionLevel.LEADER),
|
||||
SETBANNER("simpleclans.leader.setbanner", PermissionLevel.LEADER);
|
||||
|
||||
private String bukkitPermission;
|
||||
private final String bukkitPermission;
|
||||
private final PermissionLevel permissionLevel;
|
||||
|
||||
private RankPermission(String bukkitPermission) {
|
||||
RankPermission(String bukkitPermission, PermissionLevel permissionLevel) {
|
||||
this.bukkitPermission = bukkitPermission;
|
||||
this.permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Bukkit equivalent to this rank permission
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return the Bukkit equivalent to this rank permission
|
||||
*/
|
||||
public String getBukkitPermission() {
|
||||
return bukkitPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the PermissionLevel
|
||||
*
|
||||
*/
|
||||
public PermissionLevel getPermissionLevel() {
|
||||
return permissionLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().replace("_", ".").toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a valid rank permission.
|
||||
*
|
||||
* @param permission
|
||||
* @return
|
||||
* @param permission the permission
|
||||
* @return true if this is a valid rank permission
|
||||
*/
|
||||
public static boolean isValid(String permission) {
|
||||
@Contract("null -> false")
|
||||
public static boolean isValid(@Nullable String permission) {
|
||||
for (RankPermission p : values()) {
|
||||
if (p.toString().equalsIgnoreCase(permission)) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -16,16 +18,13 @@ public final class Request {
|
||||
private ClanPlayer requester;
|
||||
private int askCount;
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
* @param type
|
||||
* @param acceptors
|
||||
* @param msg
|
||||
* @param requester
|
||||
* @param clan
|
||||
* @param target
|
||||
*/
|
||||
public Request(SimpleClans plugin, ClanRequest type, List<ClanPlayer> acceptors, ClanPlayer requester, String target, Clan clan, String msg) {
|
||||
public Request(SimpleClans plugin,
|
||||
ClanRequest type,
|
||||
@Nullable List<ClanPlayer> acceptors,
|
||||
ClanPlayer requester,
|
||||
String target,
|
||||
Clan clan,
|
||||
String msg) {
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.clan = clan;
|
||||
@@ -108,25 +107,15 @@ public final class Request {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for leader voting
|
||||
*
|
||||
* @param playerNAme
|
||||
* @param vote
|
||||
*/
|
||||
public void vote(String playerNAme, VoteResult vote) {
|
||||
public void vote(String playerName, VoteResult vote) {
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
if (cp.getName().equalsIgnoreCase(playerNAme)) {
|
||||
if (cp.getName().equalsIgnoreCase(playerName)) {
|
||||
cp.setVote(vote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether all leaders have voted
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean votingFinished() {
|
||||
for (ClanPlayer cp : acceptors) {
|
||||
if (cp.getVote() == null) {
|
||||
@@ -137,11 +126,6 @@ public final class Request {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the players who have denied the request
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getDenies() {
|
||||
List<String> out = new ArrayList<>();
|
||||
|
||||
@@ -154,11 +138,6 @@ public final class Request {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the players who have denied the request
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getAccepts() {
|
||||
List<String> out = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -1,230 +1,308 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.AcceptCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.AllyCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.ClanCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.DenyCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.GlobalCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.MoreCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCEntityListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCPlayerListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.LanguageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
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.managers.TeleportManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.CollectFeeTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.CollectUpkeepTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.UpkeepWarningTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author Phaed
|
||||
*/
|
||||
public class SimpleClans extends JavaPlugin {
|
||||
|
||||
private ArrayList<String> messages = new ArrayList<>();
|
||||
private static SimpleClans instance;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private ClanManager clanManager;
|
||||
private RequestManager requestManager;
|
||||
private StorageManager storageManager;
|
||||
private SettingsManager settingsManager;
|
||||
private PermissionsManager permissionsManager;
|
||||
private TeleportManager teleportManager;
|
||||
private LanguageManager languageManager;
|
||||
private ChatFormatMigration chatFormatMigration;
|
||||
private boolean hasUUID;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
*/
|
||||
public static Logger getLog() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
*/
|
||||
public static void debug(String msg) {
|
||||
if (getInstance().getSettingsManager().isDebugging()) {
|
||||
logger.log(Level.INFO, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static SimpleClans getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void log(String msg, Object... arg) {
|
||||
if (arg == null || arg.length == 0) {
|
||||
logger.log(Level.INFO, msg);
|
||||
} else {
|
||||
logger.log(Level.INFO, MessageFormat.format(msg, arg));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
settingsManager = new SettingsManager();
|
||||
this.hasUUID = UUIDMigration.canReturnUUID();
|
||||
languageManager = new LanguageManager();
|
||||
|
||||
permissionsManager = new PermissionsManager();
|
||||
requestManager = new RequestManager();
|
||||
clanManager = new ClanManager();
|
||||
storageManager = new StorageManager();
|
||||
teleportManager = new TeleportManager();
|
||||
chatFormatMigration = new ChatFormatMigration();
|
||||
|
||||
chatFormatMigration.migrateAllyChat();
|
||||
chatFormatMigration.migrateClanChat();
|
||||
|
||||
logger.info(MessageFormat.format(getLang("version.loaded"), getDescription().getName(), getDescription().getVersion()));
|
||||
|
||||
getServer().getPluginManager().registerEvents(new SCEntityListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new SCPlayerListener(), this);
|
||||
|
||||
permissionsManager.loadPermissions();
|
||||
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandClan());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandAccept());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandDeny());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandMore());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandAlly());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandGlobal());
|
||||
|
||||
getCommand(getSettingsManager().getCommandClan()).setExecutor(new ClanCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandAccept()).setExecutor(new AcceptCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandDeny()).setExecutor(new DenyCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandMore()).setExecutor(new MoreCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandAlly()).setExecutor(new AllyCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandGlobal()).setExecutor(new GlobalCommandExecutor());
|
||||
|
||||
getCommand(getSettingsManager().getCommandClan()).setTabCompleter(new PlayerNameTabCompleter());
|
||||
logger.info("[SimpleClans] Modo Multithreading: " + SimpleClans.getInstance().getSettingsManager().getUseThreads());
|
||||
logger.info("[SimpleClans] Modo BungeeCord: " + SimpleClans.getInstance().getSettingsManager().getUseBungeeCord());
|
||||
|
||||
startTasks();
|
||||
startMetrics();
|
||||
}
|
||||
|
||||
private void startMetrics() {
|
||||
Metrics metrics = new Metrics(this, 7131);
|
||||
SettingsManager sm = getSettingsManager();
|
||||
ClanManager cm = getClanManager();
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("clans", () -> cm.getClans().size()));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("clan_players", () -> cm.getAllClanPlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("database", () -> sm.isUseMysql() ? "MySQL" : "SQLite"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("upkeep", () -> sm.isClanUpkeep() ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("member_fee", () -> sm.isMemberFee() ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("rejoin_cooldown", () -> sm.isRejoinCooldown() ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("clan_verification", () -> sm.isRequireVerification() ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("money_per_kill", () -> sm.isMoneyPerKill() ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("threads", () -> sm.getUseThreads() ? "enabled" : "disabled"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("bungeecord", () -> sm.getUseBungeeCord() ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
private void startTasks() {
|
||||
if (getSettingsManager().isMemberFee()) {
|
||||
new CollectFeeTask().start();
|
||||
}
|
||||
if (getSettingsManager().isClanUpkeep()) {
|
||||
new CollectUpkeepTask().start();
|
||||
new UpkeepWarningTask().start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
getStorageManager().closeConnection();
|
||||
getPermissionsManager().savePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clanManager
|
||||
*/
|
||||
public ClanManager getClanManager() {
|
||||
return clanManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requestManager
|
||||
*/
|
||||
public RequestManager getRequestManager() {
|
||||
return requestManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storageManager
|
||||
*/
|
||||
public StorageManager getStorageManager() {
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the settingsManager
|
||||
*/
|
||||
public SettingsManager getSettingsManager() {
|
||||
return settingsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the permissionsManager
|
||||
*/
|
||||
public PermissionsManager getPermissionsManager() {
|
||||
return permissionsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg the path within the language file
|
||||
* @return the lang
|
||||
*/
|
||||
public String getLang(String msg) {
|
||||
return languageManager.get(msg);
|
||||
}
|
||||
|
||||
public TeleportManager getTeleportManager() {
|
||||
return teleportManager;
|
||||
}
|
||||
|
||||
public List<String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hasUUID
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasUUID() {
|
||||
return this.hasUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trueOrFalse
|
||||
*/
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
|
||||
public LanguageManager getLanguageManager() {
|
||||
return languageManager;
|
||||
}
|
||||
}
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.SCCommandManager;
|
||||
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.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatFormatMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.UpdateChecker;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @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("Minecraft");
|
||||
private SCCommandManager commandManager;
|
||||
private ClanManager clanManager;
|
||||
private RequestManager requestManager;
|
||||
private StorageManager storageManager;
|
||||
private SettingsManager settingsManager;
|
||||
private PermissionsManager permissionsManager;
|
||||
private TeleportManager teleportManager;
|
||||
private boolean hasUUID;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
*/
|
||||
@Deprecated
|
||||
public static Logger getLog() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static void debug(String msg) {
|
||||
if (getInstance().getSettingsManager().isDebugging()) {
|
||||
logger.log(Level.INFO, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static SimpleClans getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void log(String msg, Object... arg) {
|
||||
if (arg == null || arg.length == 0) {
|
||||
logger.log(Level.INFO, msg);
|
||||
} else {
|
||||
logger.log(Level.INFO, MessageFormat.format(msg, arg));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new LanguageMigration(this).migrate();
|
||||
settingsManager = new SettingsManager();
|
||||
languageResource = new LanguageResource();
|
||||
this.hasUUID = UUIDMigration.canReturnUUID();
|
||||
|
||||
permissionsManager = new PermissionsManager();
|
||||
requestManager = new RequestManager();
|
||||
clanManager = new ClanManager();
|
||||
storageManager = new StorageManager();
|
||||
teleportManager = new TeleportManager();
|
||||
migrateChatFormat();
|
||||
registerEvents();
|
||||
permissionsManager.loadPermissions();
|
||||
commandManager = new SCCommandManager(this);
|
||||
|
||||
logStatus();
|
||||
startTasks();
|
||||
startMetrics();
|
||||
hookIntoPAPI();
|
||||
new UpdateChecker(this).check();
|
||||
}
|
||||
|
||||
private void logStatus() {
|
||||
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);
|
||||
pm.registerEvents(new SCPlayerListener(), this);
|
||||
pm.registerEvents(new InventoryController(), this);
|
||||
pm.registerEvents(new TamableMobsSharing(this), this);
|
||||
pm.registerEvents(new PvPOnlyInWar(this), this);
|
||||
pm.registerEvents(new FriendlyFire(this), this);
|
||||
}
|
||||
|
||||
private void migrateChatFormat() {
|
||||
ChatFormatMigration chatFormatMigration = new ChatFormatMigration();
|
||||
chatFormatMigration.migrateAllyChat();
|
||||
chatFormatMigration.migrateClanChat();
|
||||
}
|
||||
|
||||
private void hookIntoPAPI() {
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
getLogger().info("PlaceholderAPI found. Registering hook...");
|
||||
new PlaceholdersManager(this).register();
|
||||
}
|
||||
}
|
||||
|
||||
private void startMetrics() {
|
||||
Metrics metrics = new Metrics(this, 7131);
|
||||
SettingsManager sm = getSettingsManager();
|
||||
ClanManager cm = getClanManager();
|
||||
String on = "enabled";
|
||||
String off = "disabled";
|
||||
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("clans", () -> cm.getClans().size()));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("clan_players", () -> cm.getAllClanPlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("language", () -> sm.getLanguage().toString()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("machine_language", () -> Locale.getDefault().toString()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("language_chooser", () -> sm.isLanguagePerPlayer() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("database", () -> sm.isUseMysql() ? "MySQL" : "SQLite"));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("save_periodically", () -> sm.isSavePeriodically() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("save_interval", () -> String.valueOf(sm.getSaveInterval())));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("upkeep", () -> sm.isClanUpkeep() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("member_fee", () -> sm.isMemberFee() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("rejoin_cooldown", () -> sm.isRejoinCooldown() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("clan_verification", () -> sm.isRequireVerification() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("money_per_kill", () -> sm.isMoneyPerKill() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("threads", () -> sm.getUseThreads() ? on : off));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("bungeecord", () -> sm.getUseBungeeCord() ? on : off));
|
||||
}
|
||||
|
||||
private void startTasks() {
|
||||
if (getSettingsManager().isSavePeriodically()) {
|
||||
new SaveDataTask().start();
|
||||
}
|
||||
if (getSettingsManager().isMemberFee()) {
|
||||
new CollectFeeTask().start();
|
||||
}
|
||||
if (getSettingsManager().isClanUpkeep()) {
|
||||
new CollectUpkeepTask().start();
|
||||
new UpkeepWarningTask().start();
|
||||
}
|
||||
if (getSettingsManager().isCachePlayerHeads()) {
|
||||
new PlayerHeadCacheTask(this).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
if (getSettingsManager().isSavePeriodically()) {
|
||||
getStorageManager().saveModified();
|
||||
}
|
||||
getStorageManager().closeConnection();
|
||||
getPermissionsManager().savePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clanManager
|
||||
*/
|
||||
public ClanManager getClanManager() {
|
||||
return clanManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requestManager
|
||||
*/
|
||||
public RequestManager getRequestManager() {
|
||||
return requestManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storageManager
|
||||
*/
|
||||
public StorageManager getStorageManager() {
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the settingsManager
|
||||
*/
|
||||
public SettingsManager getSettingsManager() {
|
||||
return settingsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the permissionsManager
|
||||
*/
|
||||
@NotNull
|
||||
public PermissionsManager getPermissionsManager() {
|
||||
return permissionsManager;
|
||||
}
|
||||
|
||||
public SCCommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the path within the language file
|
||||
* @return the lang
|
||||
*/
|
||||
@Deprecated
|
||||
public String getLang(@NotNull String key) {
|
||||
return getLang(key, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getLang(@NotNull String key, @Nullable Player player) {
|
||||
return lang(key, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String optionalLang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
Locale locale = getInstance().getSettingsManager().getLanguage();
|
||||
if (player != null && instance.getSettingsManager().isLanguagePerPlayer()) {
|
||||
Locale playerLocale = Helper.getLocale(player);
|
||||
if (playerLocale != null) {
|
||||
locale = playerLocale;
|
||||
}
|
||||
}
|
||||
|
||||
String lang = languageResource.getLang(key, locale);
|
||||
if (lang == null) {
|
||||
return null;
|
||||
}
|
||||
String message = ChatColor.translateAlternateColorCodes('&', lang);
|
||||
// contains acf placeholders like {commandprefix}
|
||||
if (Pattern.compile("\\{(?<key>[a-zA-Z]+?)}").matcher(message).find()) {
|
||||
return message;
|
||||
}
|
||||
return MessageFormat.format(message, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
String lang = optionalLang(key, player, arguments);
|
||||
if (lang == null) {
|
||||
return key;
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable CommandSender sender, Object... arguments) {
|
||||
if (sender instanceof Player) {
|
||||
return lang(key, (Player) sender, arguments);
|
||||
} else {
|
||||
return lang(key, (Player) null, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable BukkitCommandIssuer issuer, Object... arguments) {
|
||||
if (issuer != null) {
|
||||
return lang(key, issuer.getIssuer(), arguments);
|
||||
}
|
||||
return lang(key, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, Object... arguments) {
|
||||
return lang(key, (Player) null, arguments);
|
||||
}
|
||||
|
||||
public TeleportManager getTeleportManager() {
|
||||
return teleportManager;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasUUID() {
|
||||
return this.hasUUID;
|
||||
}
|
||||
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,31 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TeleportState {
|
||||
private UUID playerUniqueId;
|
||||
private Location playerLocation;
|
||||
private Location destination;
|
||||
private final UUID playerUniqueId;
|
||||
private final Location playerLocation;
|
||||
private final Location destination;
|
||||
private int counter;
|
||||
private String clanName;
|
||||
private final String clanName;
|
||||
private boolean processing;
|
||||
|
||||
public TeleportState(Player player, Location dest, String clanName) {
|
||||
this.destination = dest;
|
||||
public TeleportState(Player player, Location destination, String clanName) {
|
||||
this.destination = destination;
|
||||
this.playerLocation = player.getLocation();
|
||||
this.clanName = clanName;
|
||||
this.counter = SimpleClans.getInstance().getSettingsManager().getWaitSecs();
|
||||
this.playerUniqueId = player.getUniqueId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Location getLocation() {
|
||||
return this.playerLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether its time for teleport
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isTeleportTime() {
|
||||
if (this.counter > 1) {
|
||||
this.counter--;
|
||||
@@ -45,16 +39,16 @@ public class TeleportState {
|
||||
/**
|
||||
* The player that is waiting for teleport
|
||||
*
|
||||
* @return
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
public @Nullable Player getPlayer() {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerUniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get seconds left before teleport
|
||||
*
|
||||
* @return
|
||||
* @return the counter
|
||||
*/
|
||||
public int getCounter() {
|
||||
return this.counter;
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class AlliancesCommand {
|
||||
public AlliancesCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.clan.alliances"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.anyone.alliances")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
plugin.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("alliances") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.setAlignment("l", "l");
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("clan"), plugin.getLang("allies"));
|
||||
|
||||
for (Clan clan : clans) {
|
||||
if (!clan.isVerified()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + ChatColor.AQUA + clan.getName(), clan.getAllyString(ChatColor.DARK_GRAY + ", "));
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class AllyCommand {
|
||||
public AllyCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.ally")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.ally"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getSize() < plugin.getSettingsManager().getClanMinSizeToAlly()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("minimum.to.make.alliance"), plugin.getSettingsManager().getClanMinSizeToAlly()));
|
||||
return;
|
||||
}
|
||||
|
||||
String action = arg[0];
|
||||
Clan ally = plugin.getClanManager().getClan(arg[1]);
|
||||
|
||||
if (ally == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clan.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ally.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("cannot.ally.with.an.unverified.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equals(plugin.getLang("add"))) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.ALLY_ADD, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.isAlly(ally.getTag())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clans.are.already.allies"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
|
||||
if (onlineLeaders.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("at.least.one.leader.accept.the.alliance"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getRequestManager().addAllyRequest(cp, ally, clan);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.have.been.asked.for.an.alliance"), Helper.capitalize(ally.getName())));
|
||||
} else if (action.equals(plugin.getLang("remove"))) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.ALLY_REMOVE, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clan.isAlly(ally.getTag())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clans.are.not.allies"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.removeAlly(ally);
|
||||
ally.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.broken.the.alliance"), Helper.capitalize(clan.getName()), ally.getName()), false);
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.broken.the.alliance"), Helper.capitalize(cp.getName()), Helper.capitalize(ally.getName())));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.ally"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class BanCommand {
|
||||
public BanCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.ban")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, MessageFormat.format(plugin.getLang("usage.ban.unban"), ChatColor.RED, plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (uuid == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.already.banned"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getClanManager().ban(uuid);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.added.to.banned.list"));
|
||||
|
||||
Player pl = SimpleClans.getInstance().getServer().getPlayer(uuid);
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, ChatColor.AQUA + plugin.getLang("you.banned"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class BankCommand {
|
||||
|
||||
public BankCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.bank")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
double plmoney = plugin.getPermissionsManager().playerGetMoney(player);
|
||||
double money = 0;
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
double clanbalance = clan.getBalance();
|
||||
|
||||
if (clan.isMember(player)) {
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length == 1) {
|
||||
if (arg[0].equalsIgnoreCase("status")) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BANK_BALANCE, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
player.sendMessage(ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.balance"), clanbalance));
|
||||
}
|
||||
} else if (arg.length == 2) {
|
||||
if (arg[1].matches("[0-9]+")) {
|
||||
money = Double.parseDouble(arg[1]);
|
||||
}
|
||||
if (arg[0].equalsIgnoreCase("deposit")) {
|
||||
if (!clan.isAllowDeposit()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("deposit.not.allowed"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BANK_DEPOSIT, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (arg[1].equalsIgnoreCase("all")) {
|
||||
clan.deposit(plmoney, player);
|
||||
} else {
|
||||
clan.deposit(money, player);
|
||||
}
|
||||
} else if (arg[0].equalsIgnoreCase("withdraw")) {
|
||||
if (!clan.isAllowWithdraw()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("withdraw.not.allowed"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BANK_WITHDRAW, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (arg[1].equalsIgnoreCase("all")) {
|
||||
clan.withdraw(clanbalance, player);
|
||||
} else {
|
||||
clan.withdraw(money, player);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.bank"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.bank"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class BbCommand {
|
||||
|
||||
public BbCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.bb")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
clan.displayBb(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length == 1 && arg[0].equalsIgnoreCase("clear")) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BB_CLEAR, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
cp.getClan().clearBb();
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("cleared.bb"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BB_ADD, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = Helper.toMessage(arg);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + player.getName() + ": " + ChatColor.WHITE + msg);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ClanInput {
|
||||
|
||||
private final Clan clan;
|
||||
|
||||
public ClanInput(@NotNull Clan clan) {
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ClanInput clanInput = (ClanInput) o;
|
||||
return clan.equals(clanInput.clan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(clan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ClanPlayerInput {
|
||||
|
||||
private final ClanPlayer clanPlayer;
|
||||
|
||||
public ClanPlayerInput(@NotNull ClanPlayer clanPlayer) {
|
||||
this.clanPlayer = clanPlayer;
|
||||
}
|
||||
|
||||
public ClanPlayer getClanPlayer() {
|
||||
return clanPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ClanPlayerInput that = (ClanPlayerInput) o;
|
||||
return clanPlayer.equals(that.clanPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(clanPlayer);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ClanffCommand {
|
||||
public ClanffCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.ff")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.clanff"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String action = arg[0];
|
||||
|
||||
if (action.equalsIgnoreCase(plugin.getLang("allow"))) {
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + plugin.getLang("clan.wide.friendly.fire.is.allowed"));
|
||||
clan.setFriendlyFire(true);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!action.equalsIgnoreCase(plugin.getLang("block"))) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.clanff"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + plugin.getLang("clan.wide.friendly.fire.blocked"));
|
||||
clan.setFriendlyFire(false);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class CoordsCommand {
|
||||
public CoordsCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.coords")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.COORDS, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.coords"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
|
||||
chatBlock.setFlexibility(true, false, false, false);
|
||||
chatBlock.setAlignment("l", "c", "c", "c");
|
||||
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("name"), plugin.getLang("distance"), plugin.getLang("coords.upper"), plugin.getLang("world"));
|
||||
|
||||
List<ClanPlayer> members = Helper.stripOffLinePlayers(clan.getMembers());
|
||||
|
||||
Map<Integer, List<String>> rows = new TreeMap<>();
|
||||
|
||||
for (ClanPlayer cpm : members) {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? plugin.getSettingsManager().getPageLeaderColor() : (cpm.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() : plugin.getSettingsManager().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();
|
||||
String world = loc.getWorld().getName();
|
||||
|
||||
List<String> cols = new ArrayList<>();
|
||||
cols.add(" " + name);
|
||||
cols.add(ChatColor.AQUA + "" + distance);
|
||||
cols.add(ChatColor.WHITE + "" + coords);
|
||||
cols.add(world);
|
||||
rows.put(distance, cols);
|
||||
}
|
||||
}
|
||||
|
||||
if (rows.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.are.the.only.member.online"));
|
||||
return;
|
||||
}
|
||||
|
||||
for (List<String> col : rows.values()) {
|
||||
chatBlock.addRow(col.get(0), col.get(1), col.get(2), col.get(3));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(clan.getName()) + subColor + " " + plugin.getLang("coords") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class CreateCommand {
|
||||
public CreateCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.create")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length < 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.create.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("example.clan.create"));
|
||||
return;
|
||||
}
|
||||
|
||||
String tag = arg[0];
|
||||
String cleanTag = Helper.cleanTag(arg[0]);
|
||||
|
||||
String name = Helper.toMessage(Helper.removeFirst(arg));
|
||||
|
||||
boolean bypass = plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass");
|
||||
|
||||
if (!bypass) {
|
||||
if (cleanTag.length() > plugin.getSettingsManager().getTagMaxLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.tag.cannot.be.longer.than.characters"), plugin.getSettingsManager().getTagMaxLength()));
|
||||
return;
|
||||
}
|
||||
if (cleanTag.length() <= plugin.getSettingsManager().getTagMinLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.tag.must.be.longer.than.characters"), plugin.getSettingsManager().getTagMinLength()));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.coloredtag") && tag.contains("&")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.tag.cannot.contain.color.codes"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().hasDisallowedColor(tag)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.tag.cannot.contain.the.following.colors"), plugin.getSettingsManager().getDisallowedColorString()));
|
||||
return;
|
||||
}
|
||||
if (Helper.stripColors(name).length() > plugin.getSettingsManager().getClanMaxLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.name.cannot.be.longer.than.characters"), plugin.getSettingsManager().getClanMaxLength()));
|
||||
return;
|
||||
}
|
||||
if (Helper.stripColors(name).length() <= plugin.getSettingsManager().getClanMinLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.name.must.be.longer.than.characters"), plugin.getSettingsManager().getClanMinLength()));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().isDisallowedWord(cleanTag.toLowerCase())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("that.tag.name.is.disallowed"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cleanTag.matches("[0-9a-zA-Z]*")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clan.tag.can.only.contain.letters.numbers.and.color.codes"));
|
||||
return;
|
||||
}
|
||||
if (name.contains("&")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clan.name.cannot.contain.color.codes"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("you.must.first.resign"), cp.getClan().getName()));
|
||||
return;
|
||||
}
|
||||
if (plugin.getClanManager().isClan(cleanTag)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.with.this.tag.already.exists"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getClanManager().purchaseCreation(player)) {
|
||||
plugin.getClanManager().createClan(player, tag, name);
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(tag);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.created"), name));
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
|
||||
if (plugin.getSettingsManager().isRequireVerification()) {
|
||||
boolean verified = !plugin.getSettingsManager().isRequireVerification() || plugin.getPermissionsManager().has(player, "simpleclans.mod.verify");
|
||||
|
||||
if (!verified) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("get.your.clan.verified.to.access.advanced.features"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class DemoteCommand {
|
||||
|
||||
public DemoteCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.demote.leader"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String demotedName = arg[0];
|
||||
|
||||
if (demotedName == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer toDemote;
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(demotedName);
|
||||
toDemote = plugin.getClanManager().getAnyClanPlayer(uuid);
|
||||
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.admin.demote")) {
|
||||
if (!toDemote.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("player.is.not.a.leader.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
final Clan clan = toDemote.getClan();
|
||||
|
||||
if (clan.getLeaders().size() == 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.demote.the.last.leader"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.demote(toDemote.getUniqueId());
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("demoted.back.to.member"), Helper.capitalize(demotedName)));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.successfully.demoted"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.demote")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clan.enoughLeadersOnlineToDemote(toDemote)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.enough.leaders.online.to.vote.on.demotion"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clan.isLeader(uuid)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("player.is.not.a.leader.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.getLeaders().size() != 1 && plugin.getSettingsManager().isConfirmationForDemote()) {
|
||||
plugin.getRequestManager().addDemoteRequest(cp, demotedName, clan);
|
||||
ChatBlock.sendMessage(player,
|
||||
ChatColor.AQUA + plugin.getLang("demotion.vote.has.been.requested.from.all.leaders"));
|
||||
return;
|
||||
}
|
||||
clan.addBb(player.getName(), ChatColor.AQUA
|
||||
+ MessageFormat.format(plugin.getLang("demoted.back.to.member"), Helper.capitalize(demotedName)));
|
||||
clan.demote(uuid);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
public class DescriptionCommand {
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param args
|
||||
*/
|
||||
public void execute(Player player, String[] args) {
|
||||
final SimpleClans plugin = SimpleClans.getInstance();
|
||||
final SettingsManager sm = plugin.getSettingsManager();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.description")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.DESCRIPTION, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.description"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String description = Helper.toMessage(args);
|
||||
if (description.length() < sm.getClanMinDescriptionLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.description.must.be.longer.than"), sm.getClanMinDescriptionLength()));
|
||||
return;
|
||||
}
|
||||
if (description.length() > sm.getClanMaxDescriptionLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.description.cannot.be.longer.than"), sm.getClanMaxDescriptionLength()));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setDescription(description);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("description.changed"));
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class DisbandCommand {
|
||||
public DisbandCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.disband")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
plugin.getRequestManager().addDisbandRequest(cp, clan);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("clan.disband.vote.has.been.requested.from.all.leaders"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.clanAnnounce(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.has.been.disbanded"), clan.getName()));
|
||||
clan.disband();
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length > 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.disband"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.disband")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(arg[0]);
|
||||
|
||||
if (clan == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clan.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getClanManager().serverAnnounce(ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.has.been.disbanded"), clan.getName()));
|
||||
clan.disband();
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class FeeCommand {
|
||||
|
||||
/**
|
||||
* Executes the command
|
||||
*
|
||||
* @param player
|
||||
* @param args
|
||||
*/
|
||||
public void execute(Player player, String[] args) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
if (!plugin.getSettingsManager().isMemberFee()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("disabled.command"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length >= 1) {
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("check")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.fee-check")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA
|
||||
+ MessageFormat.format(
|
||||
plugin.getLang("the.fee.is.0.and.its.current.value.is.1"),
|
||||
clan.isMemberFeeEnabled() ? plugin.getLang("fee.enabled") : plugin.getLang("fee.disabled"),
|
||||
clan.getMemberFee()
|
||||
));
|
||||
return;
|
||||
}
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("set")) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.FEE_SET, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (!cp.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
double newFee = 0;
|
||||
try {
|
||||
newFee = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLang("invalid.fee"));
|
||||
return;
|
||||
}
|
||||
double maxFee = plugin.getSettingsManager().getMaxMemberFee();
|
||||
if (newFee > maxFee) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED
|
||||
+ MessageFormat.format(plugin.getLang("max.fee.allowed.is.0"), maxFee));
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getClanManager().purchaseMemberFeeSet(player)) {
|
||||
clan.setMemberFee(newFee);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("bb.fee.set"), newFee));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("fee.set"));
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.RED
|
||||
+ MessageFormat.format(plugin.getLang("usage.fee"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class FfCommand {
|
||||
public FfCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.ff")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.ff.allow.auto"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String action = arg[0];
|
||||
|
||||
if (action.equalsIgnoreCase(plugin.getLang("allow"))) {
|
||||
cp.setFriendlyFire(true);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("personal.friendly.fire.is.set.to.allowed"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase(plugin.getLang("auto"))) {
|
||||
cp.setFriendlyFire(false);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("friendy.fire.is.now.managed.by.your.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.ff.allow.auto"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class GlobalffCommand {
|
||||
public GlobalffCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(CommandSender player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.ff.allow.auto"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String action = arg[0];
|
||||
|
||||
if (action.equalsIgnoreCase(plugin.getLang("allow"))) {
|
||||
if (plugin.getSettingsManager().isGlobalff()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("global.friendly.fire.is.already.being.allowed"));
|
||||
} else {
|
||||
plugin.getSettingsManager().setGlobalff(true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("global.friendly.fire.is.set.to.allowed"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase(plugin.getLang("auto"))) {
|
||||
if (!plugin.getSettingsManager().isGlobalff()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("global.friendy.fire.is.already.being.managed.by.each.clan"));
|
||||
} else {
|
||||
plugin.getSettingsManager().setGlobalff(false);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("global.friendy.fire.is.now.managed.by.each.clan"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.globalff.allow.auto"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.HomeRegroupEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class HomeCommand {
|
||||
|
||||
public HomeCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (arg.length == 2) {
|
||||
if (arg[0].equalsIgnoreCase("set") && plugin.getPermissionsManager().has(player, "simpleclans.mod.home")) {
|
||||
if (!plugin.getClanManager().purchaseHomeTeleportSet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Clan clan = plugin.getClanManager().getClan(arg[1]);
|
||||
|
||||
if (clan == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(loc);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("hombase.mod.set"), clan.getName()) + " " + ChatColor.YELLOW + Helper.toLocationString(loc));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg[0].equalsIgnoreCase("tp") && plugin.getPermissionsManager().has(player, "simpleclans.mod.hometp")) {
|
||||
Clan clan = plugin.getClanManager().getClan(arg[1]);
|
||||
|
||||
if (clan == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = clan.getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("hombase.not.set"));
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(loc);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("now.at.homebase"), clan.getName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.HOME_TP, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = clan.getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("hombase.not.set"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getClanManager().purchaseHomeTeleport(player)) {
|
||||
plugin.getTeleportManager().addPlayer(player, clan.getHomeLocation(), clan.getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg[0].equalsIgnoreCase("set")) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.HOME_SET, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().isHomebaseSetOnce() && clan.getHomeLocation() != null && !plugin.getPermissionsManager().has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("home.base.only.once"));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHomeSetEvent homeSetEvent = new PlayerHomeSetEvent(clan, cp, player.getLocation());
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(homeSetEvent);
|
||||
|
||||
if (homeSetEvent.isCancelled() || !plugin.getClanManager().purchaseHomeTeleportSet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(player.getLocation());
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("hombase.set"), ChatColor.YELLOW + Helper.toLocationString(player.getLocation())));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg[0].equalsIgnoreCase("clear")) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.HOME_SET, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().isHomebaseSetOnce() && clan.getHomeLocation() != null && !plugin.getPermissionsManager().has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("home.base.only.once"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(null);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("hombase.cleared"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg[0].equalsIgnoreCase("regroup")) {
|
||||
if (!SimpleClans.getInstance().getSettingsManager().getAllowReGroupCommand()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.HOME_REGROUP, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc;
|
||||
if (arg.length >= 2 && arg[1].equalsIgnoreCase("me")) {
|
||||
loc = player.getLocation();
|
||||
} else {
|
||||
loc = cp.getClan().getHomeLocation();
|
||||
}
|
||||
|
||||
HomeRegroupEvent homeRegroupEvent = new HomeRegroupEvent(clan, cp, clan.getOnlineMembers(), loc);
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(homeRegroupEvent);
|
||||
|
||||
if (homeRegroupEvent.isCancelled() || !plugin.getClanManager().purchaseHomeRegroup(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ClanPlayer> members = clan.getOnlineMembers();
|
||||
for (ClanPlayer ccp : members) {
|
||||
Player pl = ccp.toPlayer();
|
||||
if (pl == null) {
|
||||
continue;
|
||||
}
|
||||
int x = loc.getBlockX();
|
||||
int z = loc.getBlockZ();
|
||||
player.sendBlockChange(new Location(loc.getWorld(), x + 1, loc.getBlockY(), z + 1), Material.GLASS, (byte) 0);
|
||||
player.sendBlockChange(new Location(loc.getWorld(), x - 1, loc.getBlockY(), z - 1), Material.GLASS, (byte) 0);
|
||||
player.sendBlockChange(new Location(loc.getWorld(), x + 1, loc.getBlockY(), z - 1), Material.GLASS, (byte) 0);
|
||||
player.sendBlockChange(new Location(loc.getWorld(), x - 1, loc.getBlockY(), z + 1), Material.GLASS, (byte) 0);
|
||||
Random r = new Random();
|
||||
int xx = r.nextInt(2) - 1;
|
||||
int zz = r.nextInt(2) - 1;
|
||||
if (xx == 0 && zz == 0) {
|
||||
xx = 1;
|
||||
}
|
||||
x = x + xx;
|
||||
z = z + zz;
|
||||
|
||||
plugin.getTeleportManager().addPlayer(player, new Location(loc.getWorld(), x + .5, loc.getBlockY(), z + .5), clan.getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class InviteCommand {
|
||||
public InviteCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.invite")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.INVITE, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.invite.player"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
Player invited = Helper.getPlayer(arg[0]);
|
||||
|
||||
if (invited == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(invited, "simpleclans.member.can-join")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.doesn.t.not.have.the.permissions.to.join.clans"));
|
||||
return;
|
||||
}
|
||||
if (invited.getName().equals(player.getName())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.invite.yourself"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().isBanned(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.banned.from.using.clan.commands"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpInv = plugin.getClanManager().getAnyClanPlayer(invited.getUniqueId());
|
||||
|
||||
if (cpInv != null) {
|
||||
if (cpInv.getClan() != null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.already.member.of.another.clan"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().isRejoinCooldown()) {
|
||||
Long resign = cpInv.getResignTime(clan.getTag());
|
||||
if (resign != null) {
|
||||
long timePassed = Instant.ofEpochMilli(resign).until(Instant.now(), ChronoUnit.MINUTES);
|
||||
int cooldown = plugin.getSettingsManager().getRejoinCooldown();
|
||||
if (timePassed < cooldown) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("the.player.must.wait.0.before.joining.your.clan.again"), cooldown - timePassed));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.getClanManager().purchaseInvite(player)) {
|
||||
return;
|
||||
}
|
||||
if (clan.getSize() >= plugin.getSettingsManager().getMaxMembers()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.members.reached.limit"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getRequestManager().addInviteRequest(cp, invited.getName(), clan);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.asked.to.join"), Helper.capitalize(invited.getName()), clan.getName()));
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class KickCommand {
|
||||
public KickCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.kick")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.KICK, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.kick.player"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID kicked = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (kicked == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (kicked.equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.kick.yourself"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isMember(kicked)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(kicked)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.kick.another.leader"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.kicked.by"), Helper.capitalize(arg[0]), player.getName()));
|
||||
clan.removePlayerFromClan(kicked);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager.DataCallback;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class KillsCommand {
|
||||
public KillsCommand() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.kills")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.KILLS, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String polledPlayerName = player.getName();
|
||||
|
||||
if (arg.length == 1) {
|
||||
polledPlayerName = arg[0];
|
||||
}
|
||||
|
||||
final String name = polledPlayerName;
|
||||
|
||||
plugin.getStorageManager().getKillsPerPlayer(polledPlayerName, new DataCallback<Map<String, Integer>>() {
|
||||
@Override
|
||||
public void onResultReady(Map<String, Integer> data) {
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
chatBlock.setFlexibility(true, false);
|
||||
chatBlock.setAlignment("l", "c");
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("victim"), plugin.getLang("killcount"));
|
||||
|
||||
if (data.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("nokillsfound"));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Integer> killsPerPlayer = Helper.sortByValue(data);
|
||||
|
||||
for (Entry<String, Integer> playerKills : killsPerPlayer.entrySet()) {
|
||||
int count = playerKills.getValue();
|
||||
chatBlock.addRow(" " + playerKills.getKey(), ChatColor.AQUA + "" + count);
|
||||
}
|
||||
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(name) + subColor + " " + plugin.getLang("kills") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class LeaderboardCommand {
|
||||
public LeaderboardCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
NumberFormat formatter = new DecimalFormat("#.#");
|
||||
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.leaderboard"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.anyone.leaderboard")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ClanPlayer> clanPlayers = plugin.getClanManager().getAllClanPlayers();
|
||||
plugin.getClanManager().sortClanPlayersByKDR(clanPlayers);
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("leaderboard.command") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("total.clan.players.0"), subColor + clanPlayers.size()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.setAlignment("c", "l", "c", "c", "c", "c");
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("rank"), plugin.getLang("player"), plugin.getLang("kdr"), plugin.getLang("clan"), plugin.getLang("seen"));
|
||||
|
||||
int rank = 1;
|
||||
|
||||
for (ClanPlayer cp : clanPlayers) {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
boolean isOnline = false;
|
||||
|
||||
if (p != null) {
|
||||
isOnline = true;
|
||||
}
|
||||
|
||||
String name = (cp.isLeader() ? plugin.getSettingsManager().getPageLeaderColor() : (cp.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() : plugin.getSettingsManager().getPageUnTrustedColor())) + cp.getName();
|
||||
String lastSeen = isOnline ? ChatColor.GREEN + plugin.getLang("online") : ChatColor.WHITE + cp.getLastSeenDaysString();
|
||||
|
||||
String clanTag = ChatColor.WHITE + plugin.getLang("free.agent");
|
||||
|
||||
if (cp.getClan() != null) {
|
||||
clanTag = cp.getClan().getColorTag();
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + rank, name, ChatColor.YELLOW + "" + formatter.format(cp.getKDR()), ChatColor.WHITE + clanTag, lastSeen);
|
||||
rank++;
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ListCommand {
|
||||
public ListCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param args
|
||||
*/
|
||||
public void execute(Player player, String[] args) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
NumberFormat formatter = new DecimalFormat("#.#");
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.anyone.list")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length > 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.list"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
|
||||
sort(plugin, clans, args);
|
||||
|
||||
if (clans.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clans.have.been.created"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("clans.lower") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("total.clans") + " " + subColor + clans.size());
|
||||
ChatBlock.sendBlank(player);
|
||||
chatBlock.setAlignment("c", "l", "c", "c");
|
||||
chatBlock.setFlexibility(false, true, false, false);
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("rank"), plugin.getLang("name"), plugin.getLang("kdr"), plugin.getLang("members"));
|
||||
|
||||
int rank = 1;
|
||||
|
||||
for (Clan clan : clans) {
|
||||
if (!plugin.getSettingsManager().isShowUnverifiedOnList() && !clan.isVerified()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String tag = plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketLeft() + plugin.getSettingsManager().getTagDefaultColor() + clan.getColorTag() + plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketRight();
|
||||
String name = (clan.isVerified() ? plugin.getSettingsManager().getPageClanNameColor() : ChatColor.GRAY) + clan.getName();
|
||||
String fullname = tag + " " + name;
|
||||
String size = ChatColor.WHITE + "" + clan.getSize();
|
||||
String kdr = clan.isVerified() ? ChatColor.YELLOW + "" + formatter.format(clan.getTotalKDR()) : "";
|
||||
|
||||
chatBlock.addRow(" " + rank, fullname, kdr, size);
|
||||
rank++;
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
|
||||
private void sort(SimpleClans plugin, List<Clan> clans, String[] args) {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
String type = sm.getListDefault();
|
||||
String order = null;
|
||||
if (args.length > 0) {
|
||||
type = args[0];
|
||||
}
|
||||
String asc = sm.getListAsc();
|
||||
String desc = sm.getListDesc();
|
||||
if (args.length == 2) {
|
||||
order = args[1];
|
||||
if (!order.equalsIgnoreCase(asc) && !order.equalsIgnoreCase(desc)) {
|
||||
order = null;
|
||||
}
|
||||
}
|
||||
ClanManager cm = plugin.getClanManager();
|
||||
//in case the default type is invalid
|
||||
cm.sortClansByKDR(clans);
|
||||
|
||||
if (type.equalsIgnoreCase(sm.getListActive())) {
|
||||
cm.sortClansByActive(clans, asc.equalsIgnoreCase(order));
|
||||
}
|
||||
if (type.equalsIgnoreCase(sm.getListFounded())) {
|
||||
if (order == null) {
|
||||
order = asc;
|
||||
}
|
||||
cm.sortClansByFounded(clans, asc.equalsIgnoreCase(order));
|
||||
}
|
||||
if (type.equalsIgnoreCase(sm.getListKdr())) {
|
||||
cm.sortClansByKDR(clans, asc.equalsIgnoreCase(order));
|
||||
}
|
||||
if (type.equalsIgnoreCase(sm.getListName())) {
|
||||
if (order == null) {
|
||||
order = asc;
|
||||
}
|
||||
cm.sortClansByName(clans, asc.equalsIgnoreCase(order));
|
||||
}
|
||||
if (type.equalsIgnoreCase(sm.getListSize())) {
|
||||
cm.sortClansBySize(clans, asc.equalsIgnoreCase(order));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class LookupCommand {
|
||||
public LookupCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
NumberFormat formatter = new DecimalFormat("#.#");
|
||||
|
||||
String playerName = null;
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.lookup")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
playerName = player.getName();
|
||||
} else if (arg.length == 1) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.anyone.lookup")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
playerName = arg[0];
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.lookup.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID targetUuid = UUIDMigration.getForcedPlayerUUID(playerName);
|
||||
if (targetUuid == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer targetCp = plugin.getClanManager().getAnyClanPlayer(targetUuid);
|
||||
ClanPlayer myCp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
|
||||
Clan myClan = myCp == null ? null : myCp.getClan();
|
||||
|
||||
if (targetCp != null) {
|
||||
Clan targetClan = targetCp.getClan();
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, MessageFormat.format(plugin.getLang("s.player.info"), plugin.getSettingsManager().getPageClanNameColor() + targetCp.getName() + subColor) + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
String clanName = ChatColor.WHITE + plugin.getLang("none");
|
||||
|
||||
if (targetClan != null) {
|
||||
clanName = plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketLeft() + plugin.getSettingsManager().getTagDefaultColor() + targetClan.getColorTag() + plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketRight() + " " + plugin.getSettingsManager().getPageClanNameColor() + targetClan.getName();
|
||||
}
|
||||
|
||||
String status = targetClan == null ? ChatColor.WHITE + plugin.getLang("free.agent") : (targetCp.isLeader() ? plugin.getSettingsManager().getPageLeaderColor() + plugin.getLang("leader") : (targetCp.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() + plugin.getLang("trusted") : plugin.getSettingsManager().getPageUnTrustedColor() + plugin.getLang("untrusted")));
|
||||
String rank = ChatColor.WHITE + "" + Helper.parseColors(targetCp.getRankDisplayName());
|
||||
String joinDate = ChatColor.WHITE + "" + targetCp.getJoinDateString();
|
||||
String lastSeen = ChatColor.WHITE + "" + targetCp.getLastSeenString();
|
||||
String inactive = ChatColor.WHITE + "" + targetCp.getInactiveDays() + subColor + "/" + ChatColor.WHITE + plugin.getSettingsManager().getPurgePlayers() + " days";
|
||||
String rival = ChatColor.WHITE + "" + targetCp.getRivalKills();
|
||||
String neutral = ChatColor.WHITE + "" + targetCp.getNeutralKills();
|
||||
String civilian = ChatColor.WHITE + "" + targetCp.getCivilianKills();
|
||||
String deaths = ChatColor.WHITE + "" + targetCp.getDeaths();
|
||||
String kdr = ChatColor.YELLOW + "" + formatter.format(targetCp.getKDR());
|
||||
String pastClans = ChatColor.WHITE + "" + targetCp.getPastClansString(headColor + ", ");
|
||||
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("clan.0"), clanName));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("rank.0"), rank));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("status.0"), status));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("kdr.0"), kdr));
|
||||
ChatBlock.sendMessage(player, " " + subColor + plugin.getLang("kill.totals") + " " + headColor + "[" + plugin.getLang("rival") + ":" + rival + " " + headColor + "" + plugin.getLang("neutral") + ":" + neutral + " " + headColor + "" + plugin.getLang("civilian") + ":" + civilian + headColor + "]");
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("deaths.0"), deaths));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("join.date.0"), joinDate));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("last.seen.0"), lastSeen));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("past.clans.0"), pastClans));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("inactive.0"), inactive));
|
||||
|
||||
if (arg.length == 1 && !targetCp.equals(myCp)) {
|
||||
String killType = ChatColor.GRAY + plugin.getLang("neutral");
|
||||
|
||||
if (targetClan == null) {
|
||||
killType = ChatColor.DARK_GRAY + plugin.getLang("civilian");
|
||||
} else if (myClan != null && myClan.isRival(targetClan.getTag())) {
|
||||
killType = ChatColor.WHITE + plugin.getLang("rival");
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("kill.type.0"), killType));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.data.found"));
|
||||
|
||||
if (arg.length == 1 && myClan != null) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, MessageFormat.format(plugin.getLang("kill.type.civilian"), ChatColor.DARK_GRAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class MenuCommand {
|
||||
private List<String> menuItems = new LinkedList<>();
|
||||
|
||||
public MenuCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void execute(Player player) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
Clan clan = cp == null ? null : cp.getClan();
|
||||
|
||||
boolean isLeader = cp != null && cp.isLeader();
|
||||
boolean isVerified = clan != null && clan.isVerified();
|
||||
boolean isNonVerified = clan != null && !clan.isVerified();
|
||||
|
||||
String clanCommand = plugin.getSettingsManager().getCommandClan();
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
chatBlock.setCropRight(false);
|
||||
chatBlock.setPadRight(false);
|
||||
|
||||
if (clan == null && plugin.getPermissionsManager().has(player, "simpleclans.leader.create")) {
|
||||
if (plugin.getSettingsManager().isePurchaseCreation()) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.create.tag.name.1.purchase.a.new.clan"), clanCommand, ChatColor.WHITE));
|
||||
} else {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.create.tag.name.1.create.a.new.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
if (isNonVerified && plugin.getSettingsManager().isRequireVerification() && plugin.getSettingsManager().isePurchaseVerification()) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.verify.1.purchase.verification.of.your.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.list")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.list.1.lists.all.clans"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.profile")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.profile.1.view.your.clan.s.profile"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.profile")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.profile.tag.1.view.a.clan.s.profile"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.lookup")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.lookup.1.lookup.your.info"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.lookup")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.lookup.player.1.lookup.a.player.s.info"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.leaderboard")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.leaderboard.1.view.leaderboard"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.alliances")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.alliances.1.view.all.clan.alliances"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.rivalries")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rivalries.1.view.all.clan.rivalries"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.roster")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.roster.1.view.your.clan.s.member.list"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.roster")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.roster.tag.1.view.a.clan.s.member.list"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.VITALS, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.vitals.1.view.your.clan.member.s.vitals"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.COORDS, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.coords.1.view.your.clan.member.s.coordinates"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.STATS, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.stats.1.view.your.clan.member.s.stats"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.KILLS, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.kills"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.KILLS, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.killsplayer"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getSettingsManager().isMemberFee() && isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.fee-check")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.fee.check"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getSettingsManager().isMemberFee() && isVerified && plugin.getPermissionsManager().has(player, RankPermission.FEE_SET, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.fee.set"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && (plugin.getPermissionsManager().has(player, RankPermission.ALLY_ADD, PermissionLevel.LEADER, false)
|
||||
|| plugin.getPermissionsManager().has(player, RankPermission.ALLY_REMOVE, PermissionLevel.LEADER, false))) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.ally.add.remove.tag.1.add.remove.an.ally.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && (plugin.getPermissionsManager().has(player, RankPermission.RIVAL_ADD, PermissionLevel.LEADER, false)
|
||||
|| plugin.getPermissionsManager().has(player, RankPermission.RIVAL_REMOVE, PermissionLevel.LEADER, false))) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rival.add.remove.tag.1.add.remove.a.rival.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.HOME_TP, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("home-menu"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.HOME_SET, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("home-set-menu"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.HOME_SET, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("home-clear-menu"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.HOME_REGROUP, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("home-regroup-menu"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && (plugin.getPermissionsManager().has(player, RankPermission.WAR_END, PermissionLevel.LEADER, false)
|
||||
|| plugin.getPermissionsManager().has(player, RankPermission.WAR_START, PermissionLevel.LEADER, false))) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.war"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.resetkdr")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.resetkdr.1.resets.your.kdr"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.bb")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.bb.1.display.bulletin.board"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.BB_ADD, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.bb.msg.1.add.a.message.to.the.bulletin.board"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.MODTAG, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.modtag.tag.1.modify.the.clan.s.tag"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.DESCRIPTION, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.description.description.1.modify.the.clan.s.description"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
|
||||
String toggles = "";
|
||||
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.bb-toggle")) {
|
||||
toggles += "bb/";
|
||||
}
|
||||
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.tag-toggle")) {
|
||||
toggles += "tag/";
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isMemberFee() && isVerified && plugin.getPermissionsManager().has(player, RankPermission.FEE_ENABLE, PermissionLevel.LEADER, false)) {
|
||||
toggles += "fee/";
|
||||
}
|
||||
|
||||
if (!toggles.isEmpty()) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.toggle.command"), clanCommand, ChatColor.WHITE, Helper.stripTrailing(toggles, "/")));
|
||||
}
|
||||
|
||||
if (plugin.getPermissionsManager().has(player, RankPermission.INVITE, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.invite.player.1.invite.a.player"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, RankPermission.KICK, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.kick.player.1.kick.a.player.from.the.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.settrust")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.trust.untrust.player.1.set.trust.level1"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.settrust")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.trust.untrust.player.1.set.trust.level2"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.create")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.create.rank.1.create.rank"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.assign")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.assign.rank.player.1.assign.rank.to.player"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.unassign")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.unassign.player.1.unassign.player.from.rank"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.delete")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.delete.rank.1.delete.rank"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.RANK_LIST, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.list.1.list.ranks"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.RANK_DISPLAYNAME, PermissionLevel.LEADER, false)) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.setdisplayname.rank.displayname.1.set.rank.displayname"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.available")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.permissions.1.list.available.permissions"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.list")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.permissions.rank.1.list.rank.permissions"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.add")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.permissions.rank.add.permission.1.add.a.permission.to.rank"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.remove")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.rank.permissions.rank.remove.permission.1.remove.a.permission.from.rank"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.promote")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.promote.member.1.promote.a.member.to.leader"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.demote")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.demote.leader.1.demote.a.leader.to.member"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.ff")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.clanff.allow.block.1.toggle.clan.s.friendly.fire"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.disband")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.disband.1.disband.your.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.ff")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.ff.allow.auto.1.toggle.personal.friendly.fire"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.resign")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.resign.1.resign.from.the.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
|
||||
for (String item : menuItems) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + item);
|
||||
}
|
||||
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.verify") && plugin.getSettingsManager().isRequireVerification()) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.verify.tag.1.verify.an.unverified.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.place")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.place"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, RankPermission.MOSTKILLED, PermissionLevel.TRUSTED, false)) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.mostkilled"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.disband")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.disband.tag.1.disband.a.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.ban")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.ban.unban.player.1.ban.unban.a.player"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.hometp")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.hometp.clan.1.tp.home.a.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.globalff")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.globalff.allow.auto.1.set.global.friendly.fire"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.admin.demote")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.demote.leader.1.demote.a.leader.to.member"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.admin.purge")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.purge.player.1.purge.a.player"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.admin.resetkdr")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.resetkdr.1.resets.kdr"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.admin.reload")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.reload.1.reload.configuration"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (chatBlock.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("clan.commands") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param sender
|
||||
*/
|
||||
public void executeSender(CommandSender sender) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
String clanCommand = plugin.getSettingsManager().getCommandClan();
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.purge.player.1.purge.a.player"), clanCommand, ChatColor.WHITE));
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.verify.tag.1.verify.an.unverified.clan"), clanCommand, ChatColor.WHITE));
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.reload.1.reload.configuration"), clanCommand, ChatColor.WHITE));
|
||||
|
||||
ChatBlock.sendBlank(sender);
|
||||
ChatBlock.saySingle(sender, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("clan.commands") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(sender);
|
||||
chatBlock.sendBlock(sender, plugin.getSettingsManager().getPageSize());
|
||||
ChatBlock.sendBlank(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a menu item to the /clan menu
|
||||
*
|
||||
* @param syntax
|
||||
* @param description
|
||||
*/
|
||||
public void addMenuItem(String syntax, String description) {
|
||||
addMenuItem(syntax, description, ChatColor.AQUA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a menu item to the /clan menu, specifying syntax color
|
||||
* [color] /[syntax] - [description]
|
||||
*
|
||||
* @param syntax
|
||||
* @param description
|
||||
* @param color
|
||||
*/
|
||||
public void addMenuItem(String syntax, String description, ChatColor color) {
|
||||
menuItems.add(color + "/" + syntax + ChatColor.WHITE + " - " + description);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ModtagCommand {
|
||||
public ModtagCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.modtag")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.MODTAG, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.modtag.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("example.clan.modtag.4kfo.4l"));
|
||||
return;
|
||||
}
|
||||
|
||||
String newtag = arg[0];
|
||||
String cleantag = Helper.cleanTag(newtag);
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.coloredtag") && newtag.contains("&")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.tag.cannot.contain.color.codes"));
|
||||
return;
|
||||
}
|
||||
if (Helper.stripColors(newtag).length() > plugin.getSettingsManager().getTagMaxLength()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.clan.tag.cannot.be.longer.than.characters"), plugin.getSettingsManager().getTagMaxLength()));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().hasDisallowedColor(newtag)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("your.tag.cannot.contain.the.following.colors"), plugin.getSettingsManager().getDisallowedColorString()));
|
||||
return;
|
||||
}
|
||||
if (!Helper.stripColors(newtag).matches("[0-9a-zA-Z]*")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clan.tag.can.only.contain.letters.numbers.and.color.codes"));
|
||||
return;
|
||||
}
|
||||
if (!cleantag.equals(clan.getTag())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.can.only.modify.the.color.and.case.of.the.tag"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("tag.changed.to.0"), Helper.parseColors(newtag)));
|
||||
clan.changeClanTag(newtag);
|
||||
plugin.getClanManager().updateDisplayName(player.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager.DataCallback;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class MostKilledCommand {
|
||||
public MostKilledCommand() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.mostkilled")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.MOSTKILLED, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getStorageManager().getMostKilled(new DataCallback<Map<String, Integer>>() {
|
||||
|
||||
@Override
|
||||
public void onResultReady(Map<String, Integer> data) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
chatBlock.setFlexibility(true, false, false);
|
||||
chatBlock.setAlignment("l", "c", "l");
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("victim"), headColor + plugin.getLang("killcount"), headColor + plugin.getLang("attacker"));
|
||||
|
||||
if (data.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("nokillsfound"));
|
||||
return;
|
||||
}
|
||||
Map<String, Integer> killsPerPlayer = Helper.sortByValue(data);
|
||||
|
||||
for (Entry<String, Integer> attackerVictim : killsPerPlayer.entrySet()) {
|
||||
String[] split = attackerVictim.getKey().split(" ");
|
||||
|
||||
if (split.length < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int count = attackerVictim.getValue();
|
||||
String attacker = split[0];
|
||||
String victim = split[1];
|
||||
|
||||
chatBlock.addRow(" " + ChatColor.WHITE + victim, ChatColor.AQUA + "" + count, ChatColor.YELLOW + attacker);
|
||||
}
|
||||
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("mostkilled") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
public class PlaceCommand {
|
||||
public PlaceCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param sender
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(CommandSender sender, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.place")) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.place"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Helper.getPlayer(arg[0]);
|
||||
|
||||
if (player == null) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan newClan = plugin.getClanManager().getClan(arg[1]);
|
||||
|
||||
if (newClan == null) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("the.clan.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer oldCp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (oldCp != null) {
|
||||
Clan oldClan = oldCp.getClan();
|
||||
|
||||
if (oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
|
||||
oldClan.clanAnnounce(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.has.been.disbanded"), oldClan.getName()));
|
||||
oldClan.disband();
|
||||
} else {
|
||||
oldClan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("0.has.resigned"), Helper.capitalize(player.getName())));
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getCreateClanPlayerUUID(player.getName());
|
||||
|
||||
if (cp == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
newClan.addBb(ChatColor.AQUA + MessageFormat.format(plugin.getLang("joined.the.clan"), player.getName()));
|
||||
plugin.getClanManager().serverAnnounce(MessageFormat.format(plugin.getLang("has.joined"), player.getName(), newClan.getName()));
|
||||
newClan.addPlayerToClan(cp);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ProfileCommand {
|
||||
public ProfileCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
NumberFormat formatter = new DecimalFormat("#.#");
|
||||
|
||||
Clan clan = null;
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.profile")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
} else {
|
||||
if (cp.getClan().isVerified()) {
|
||||
clan = cp.getClan();
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
} else if (arg.length == 1) {
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.profile")) {
|
||||
clan = plugin.getClanManager().getClan(arg[0]);
|
||||
|
||||
if (clan == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clan.matched"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.profile.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
|
||||
if (clan != null) {
|
||||
if (clan.isVerified()) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(clan.getName()) + subColor + " " + plugin.getLang("profile") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
String name = plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketLeft() + plugin.getSettingsManager().getTagDefaultColor() + clan.getColorTag() + plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketRight() + " " + plugin.getSettingsManager().getPageClanNameColor() + clan.getName();
|
||||
String description = ChatColor.WHITE + (clan.getDescription() != null && !clan.getDescription().isEmpty() ? clan.getDescription() : plugin.getLang("no.description"));
|
||||
String leaders = clan.getLeadersString(plugin.getSettingsManager().getPageLeaderColor(), subColor + ", ");
|
||||
String onlineCount = ChatColor.WHITE + "" + Helper.stripOffLinePlayers(clan.getMembers()).size();
|
||||
String membersOnline = onlineCount + subColor + "/" + ChatColor.WHITE + clan.getSize();
|
||||
String inactive = ChatColor.WHITE + "" + clan.getInactiveDays() + subColor + "/" + ChatColor.WHITE + (clan.isVerified() ? plugin.getSettingsManager().getPurgeClan() : plugin.getSettingsManager().getPurgeUnverified()) + " " + plugin.getLang("days");
|
||||
String founded = ChatColor.WHITE + "" + clan.getFoundedString();
|
||||
String allies = ChatColor.WHITE + "" + clan.getAllyString(subColor + ", ");
|
||||
String rivals = ChatColor.WHITE + "" + clan.getRivalString(subColor + ", ");
|
||||
String kdr = ChatColor.YELLOW + "" + formatter.format(clan.getTotalKDR());
|
||||
String deaths = ChatColor.WHITE + "" + clan.getTotalDeaths();
|
||||
String rival = ChatColor.WHITE + "" + clan.getTotalRival();
|
||||
String neutral = ChatColor.WHITE + "" + clan.getTotalNeutral();
|
||||
String civ = ChatColor.WHITE + "" + clan.getTotalCivilian();
|
||||
String status = ChatColor.WHITE + "" + (clan.isVerified() ? plugin.getSettingsManager().getPageTrustedColor() + plugin.getLang("verified") : plugin.getSettingsManager().getPageUnTrustedColor() + plugin.getLang("unverified"));
|
||||
String feeEnabled = ChatColor.WHITE + (clan.isMemberFeeEnabled() ? plugin.getLang("fee.enabled") : plugin.getLang("fee.disabled"));
|
||||
String feeValue = ChatColor.WHITE + "" + clan.getMemberFee();
|
||||
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("name.0"), name));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("description.0"), description));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("status.0"), status));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("leaders.0"), leaders));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("members.online.0"), membersOnline));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("kdr.0"), kdr));
|
||||
ChatBlock.sendMessage(player, " " + subColor + plugin.getLang("kill.totals") + " " + headColor + "[" + plugin.getLang("rival") + ":" + rival + " " + headColor + "" + plugin.getLang("neutral") + ":" + neutral + " " + headColor + "" + plugin.getLang("civilian") + ":" + civ + headColor + "]");
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("deaths.0"), deaths));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("fee.0.value.1"), feeEnabled, feeValue));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("allies.0"), allies));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("rivals.0"), rivals));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("founded.0"), founded));
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("inactive.0"), inactive));
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class PromoteCommand {
|
||||
public PromoteCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.promote")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.promote.member"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
Player promoted = Helper.getPlayer(arg[0]);
|
||||
|
||||
if (promoted == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.member.to.be.promoted.must.be.online"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(promoted, "simpleclans.leader.promotable")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.does.not.have.the.permissions.to.lead.a.clan"));
|
||||
return;
|
||||
}
|
||||
if (promoted.getName().equals(player.getName())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.promote.yourself"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isMember(promoted)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(promoted) && plugin.getSettingsManager().isConfirmationForPromote()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.already.a.leader"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("promoted.to.leader"), Helper.capitalize(promoted.getName())));
|
||||
clan.promote(promoted.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class PurgeCommand {
|
||||
|
||||
/**
|
||||
* Executes the command
|
||||
*
|
||||
* @param sender
|
||||
* @param args
|
||||
*/
|
||||
public void execute(CommandSender sender, String args[]) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
if (sender instanceof Player) {
|
||||
if (!plugin.getPermissionsManager().has((Player) sender, "simpleclans.admin.purge")) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(args[0]);
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(uuid);
|
||||
if (uuid == null || cp == null) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getClanManager().deleteClanPlayer(cp);
|
||||
ChatBlock.sendMessage(sender, ChatColor.AQUA + plugin.getLang("player.purged"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED
|
||||
+ MessageFormat.format(plugin.getLang("usage.purge"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -1,308 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Rank;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public class RankCommand {
|
||||
private SimpleClans plugin;
|
||||
private Player player;
|
||||
private ClanPlayer clanPlayer;
|
||||
private Clan clan;
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] args) {
|
||||
this.player = player;
|
||||
plugin = SimpleClans.getInstance();
|
||||
ClanManager clanManager = plugin.getClanManager();
|
||||
|
||||
clanPlayer = clanManager.getClanPlayer(player);
|
||||
if (clanPlayer == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan = clanPlayer.getClan();
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clanPlayer.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length > 0) {
|
||||
String subCommand = args[0].toLowerCase();
|
||||
args = Helper.removeFirst(args);
|
||||
|
||||
switch (subCommand) {
|
||||
case "assign":
|
||||
assignRank(args);
|
||||
return;
|
||||
case "unassign":
|
||||
unassign(args);
|
||||
return;
|
||||
case "create":
|
||||
createRank(args);
|
||||
return;
|
||||
case "list":
|
||||
listRanks();
|
||||
return;
|
||||
case "delete":
|
||||
deleteRank(args);
|
||||
return;
|
||||
case "permissions":
|
||||
permissions(args);
|
||||
return;
|
||||
case "setdisplayname":
|
||||
setDisplayName(args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
private void assignRank(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.assign")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.assign"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(args[0]);
|
||||
if (uuid == null || (!clan.isMember(uuid) && !clan.isLeader(uuid))) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
String rank = args[1].toLowerCase();
|
||||
if (!clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("rank.0.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpTarget = plugin.getClanManager().getClanPlayer(uuid);
|
||||
cpTarget.setRank(rank);
|
||||
plugin.getStorageManager().updateClanPlayer(cpTarget);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.rank.changed"));
|
||||
}
|
||||
|
||||
private void unassign(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.unassign")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.unassign"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(args[0]);
|
||||
if (uuid == null || (!clan.isMember(uuid) && !clan.isLeader(uuid))) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpTarget = plugin.getClanManager().getClanPlayer(uuid);
|
||||
cpTarget.setRank(null);
|
||||
plugin.getStorageManager().updateClanPlayer(cpTarget);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.unassigned.from.rank"));
|
||||
}
|
||||
|
||||
private void createRank(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.create")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.create"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String rank = args[0].toLowerCase();
|
||||
if (clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("rank.already.exists"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.createRank(rank);
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("rank.created"));
|
||||
}
|
||||
|
||||
private void listRanks() {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.list")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
List<Rank> ranks = clan.getRanks();
|
||||
|
||||
if (ranks.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.ranks"));
|
||||
return;
|
||||
}
|
||||
|
||||
ranks.sort(Comparator.reverseOrder());
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("clans.ranks"));
|
||||
int count = 1;
|
||||
for (Rank rank : ranks) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("ranks.list.item"), count, Helper.parseColors(rank.getDisplayName()) + ChatColor.AQUA, rank.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRank(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.delete")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.delete"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
String rank = args[0].toLowerCase();
|
||||
if (!clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("rank.0.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
clan.deleteRank(rank);
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("rank.0.deleted"), rank));
|
||||
}
|
||||
|
||||
private void setDisplayName(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.setdisplayname")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.setdisplayname"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String rankName = args[0].toLowerCase();
|
||||
if (!clan.hasRank(rankName)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("rank.0.does.not.exist"), rankName));
|
||||
return;
|
||||
}
|
||||
Rank rank = clan.getRank(rankName);
|
||||
String dn = Helper.toMessage(Helper.removeFirst(args));
|
||||
if (dn.contains("&") && !plugin.getPermissionsManager().has(player, "simpleclans.leader.coloredrank")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.set.colored.ranks"));
|
||||
return;
|
||||
}
|
||||
rank.setDisplayName(dn);
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("rank.displayname.updated"));
|
||||
}
|
||||
|
||||
private void permissions(String[] args) {
|
||||
String validPermissionsToMessage = Helper.toMessage(Helper.fromPermissionArray(), ",");
|
||||
if (args.length == 0) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.available")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("available.rank.permissions"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + validPermissionsToMessage);
|
||||
return;
|
||||
}
|
||||
if (args.length > 0) {
|
||||
String rank = args[0].toLowerCase();
|
||||
if (!clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("rank.0.does.not.exist"), rank));
|
||||
return;
|
||||
}
|
||||
Set<String> permissions = clan.getRank(rank).getPermissions();
|
||||
|
||||
if (args.length == 1) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.list")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (permissions.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("rank.no.permissions"));
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("rank.0.permissions"), rank));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + Helper.toMessage(permissions.toArray(new String[0]), ","));
|
||||
return;
|
||||
}
|
||||
if (args.length == 3) {
|
||||
String subCommand = args[1].toLowerCase();
|
||||
String permission = args[2].toLowerCase();
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
switch (subCommand) {
|
||||
case "add":
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.add")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (!RankPermission.isValid(permission)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("invalid.permission"), permission, validPermissionsToMessage));
|
||||
return;
|
||||
}
|
||||
permissions.add(permission);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("permission.0.added.to.rank.1"), permission, rank));
|
||||
changed = true;
|
||||
break;
|
||||
case "remove":
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.permissions.remove")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
permissions.remove(permission);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("permission.0.removed.from.rank.1"), permission, rank));
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.permissions"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ReloadCommand
|
||||
{
|
||||
public ReloadCommand()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param sender
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(CommandSender sender, String[] arg)
|
||||
{
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (sender instanceof Player && !plugin.getPermissionsManager().has((Player)sender, "simpleclans.admin.reload"))
|
||||
{
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + "Does not match a clan command");
|
||||
return;
|
||||
}
|
||||
plugin.reloadConfig();
|
||||
plugin.getSettingsManager().load();
|
||||
plugin.getLanguageManager().load();
|
||||
plugin.getStorageManager().importFromDatabase();
|
||||
SimpleClans.getInstance().getPermissionsManager().loadPermissions();
|
||||
|
||||
for (Clan clan : plugin.getClanManager().getClans())
|
||||
{
|
||||
SimpleClans.getInstance().getPermissionsManager().updateClanPermissions(clan);
|
||||
}
|
||||
ChatBlock.sendMessage(sender, ChatColor.AQUA + plugin.getLang("configuration.reloaded"));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ResetKDRCommand {
|
||||
|
||||
public ResetKDRCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
if (arg == null || arg.length == 0) {
|
||||
if (!plugin.getSettingsManager().isAllowResetKdr()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED
|
||||
+ MessageFormat.format(plugin.getLang("usage.resetkdr"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.resetkdr")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getClanManager().purchaseResetKdr(player)) {
|
||||
plugin.getClanManager().resetKdr(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.have.reseted.your.kdr"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (arg.length == 1 && plugin.getPermissionsManager().has(player, "simpleclans.admin.resetkdr")) {
|
||||
if (arg[0].equalsIgnoreCase("all")) {
|
||||
for (ClanPlayer cp : SimpleClans.getInstance().getClanManager().getAllClanPlayers()) {
|
||||
plugin.getClanManager().resetKdr(cp);
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.have.reseted.kdr.of.all.players"));
|
||||
} else {
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (uuid == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer trcp = plugin.getClanManager().getClanPlayer(uuid);
|
||||
if (trcp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.data.found"));
|
||||
return;
|
||||
}
|
||||
plugin.getClanManager().resetKdr(trcp);
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("you.have.reseted.0.kdr"), trcp.getName()));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.ResignPrompt;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ResignCommand {
|
||||
public ResignCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.resign")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
new ConversationFactory(plugin)
|
||||
.withFirstPrompt(new ResignPrompt())
|
||||
.withLocalEcho(true)
|
||||
.withTimeout(10)
|
||||
.buildConversation(player).begin();
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class RivalCommand {
|
||||
public RivalCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rival")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (clan.isUnrivable()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clan.cannot.create.rivals"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.rival"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getSize() < plugin.getSettingsManager().getClanMinSizeToRival()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("min.players.rivalries"), plugin.getSettingsManager().getClanMinSizeToRival()));
|
||||
return;
|
||||
}
|
||||
|
||||
String action = arg[0];
|
||||
Clan rival = plugin.getClanManager().getClan(arg[1]);
|
||||
|
||||
if (rival == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clan.matched"));
|
||||
return;
|
||||
}
|
||||
if (clan.getTag().equals(rival.getTag()))
|
||||
{
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.rival.your.own.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isUnrivable(rival.getTag())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.cannot.be.rivaled"));
|
||||
return;
|
||||
}
|
||||
if (!rival.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("cannot.rival.an.unverified.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equals(plugin.getLang("add"))) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.RIVAL_ADD, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (!clan.reachedRivalLimit()) {
|
||||
if (!clan.isRival(rival.getTag())) {
|
||||
clan.addRival(rival);
|
||||
rival.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.initiated.a.rivalry"), Helper.capitalize(clan.getName()), rival.getName()), false);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.initiated.a.rivalry"), Helper.capitalize(player.getName()), Helper.capitalize(rival.getName())));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clans.are.already.rivals"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("rival.limit.reached"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equals(plugin.getLang("remove"))) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.RIVAL_REMOVE, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (clan.isRival(rival.getTag())) {
|
||||
plugin.getRequestManager().addRivalryBreakRequest(cp, rival, clan);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.asked.to.end.rivalry"), Helper.capitalize(rival.getName())));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clans.are.not.rivals"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.rival"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class RivalriesCommand {
|
||||
public RivalriesCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rivalries"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.anyone.rivalries")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
plugin.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getServerName() + subColor + " " + plugin.getLang("rivalries") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("legend") + ChatColor.DARK_RED + " [" + plugin.getLang("war") + "]");
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.setAlignment("l", "l");
|
||||
chatBlock.addRow(plugin.getLang("clan"), plugin.getLang("rivals"));
|
||||
|
||||
for (Clan clan : clans) {
|
||||
if (!clan.isVerified()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chatBlock.addRow(" " + ChatColor.AQUA + clan.getName(), clan.getRivalString(ChatColor.DARK_GRAY + ", "));
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class RosterCommand {
|
||||
|
||||
public RosterCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
Clan clan = null;
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.roster")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
} else {
|
||||
clan = cp.getClan();
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
} else if (arg.length == 1) {
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.anyone.roster")) {
|
||||
clan = plugin.getClanManager().getClan(arg[0]);
|
||||
|
||||
if (clan == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clan.matched"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.roster.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
|
||||
if (clan != null) {
|
||||
if (clan.isVerified()) {
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(clan.getName()) + subColor + " " + plugin.getLang("roster") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("legend") + " " + plugin.getSettingsManager().getPageLeaderColor() + plugin.getLang("leader") + headColor + ", " + plugin.getSettingsManager().getPageTrustedColor() + plugin.getLang("trusted") + headColor + ", " + plugin.getSettingsManager().getPageUnTrustedColor() + plugin.getLang("untrusted"));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.setFlexibility(false, true, false, true);
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("player"), plugin.getLang("rank"), plugin.getLang("seen"));
|
||||
|
||||
List<ClanPlayer> leaders = clan.getLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(leaders);
|
||||
|
||||
List<ClanPlayer> members = clan.getNonLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByLastSeen(members);
|
||||
|
||||
for (ClanPlayer cp : leaders) {
|
||||
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = plugin.getSettingsManager().getPageLeaderColor() + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !Helper.isVanished(p) ? ChatColor.GREEN + plugin.getLang("online") : ChatColor.WHITE + cp.getLastSeenDaysString();
|
||||
|
||||
chatBlock.addRow(" " + name, ChatColor.YELLOW + Helper.parseColors(cp.getRankDisplayName()) + ChatColor.RESET, lastSeen);
|
||||
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : members) {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = (cp.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() : plugin.getSettingsManager().getPageUnTrustedColor()) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !Helper.isVanished(p) ? ChatColor.GREEN + plugin.getLang("online") : ChatColor.WHITE + cp.getLastSeenDaysString();
|
||||
|
||||
chatBlock.addRow(" " + name, ChatColor.YELLOW + Helper.parseColors(cp.getRankDisplayName()) + ChatColor.RESET, lastSeen);
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.roster.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.BukkitLocales;
|
||||
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.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.completions.AbstractAsyncCompletion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.completions.AbstractCompletion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.completions.AbstractStaticCompletion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.completions.AbstractSyncCompletion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.conditions.AbstractCommandCondition;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.conditions.AbstractCondition;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.conditions.AbstractParameterCondition;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.contexts.AbstractContextResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.contexts.AbstractInputOnlyContextResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.contexts.AbstractIssuerOnlyContextResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.optionalLang;
|
||||
|
||||
public class SCCommandManager extends PaperCommandManager {
|
||||
private final SimpleClans plugin;
|
||||
private static final List<String> SUBCOMMANDS;
|
||||
|
||||
public SCCommandManager(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
configure();
|
||||
}
|
||||
|
||||
private void configure() {
|
||||
registerDependencies();
|
||||
enableUnstableAPI("help");
|
||||
addCommandReplacements();
|
||||
registerContexts();
|
||||
registerCommands();
|
||||
registerConditions();
|
||||
registerCompletions();
|
||||
}
|
||||
|
||||
private void registerDependencies() {
|
||||
registerDependency(ClanManager.class, plugin.getClanManager());
|
||||
registerDependency(SettingsManager.class, plugin.getSettingsManager());
|
||||
registerDependency(StorageManager.class, plugin.getStorageManager());
|
||||
registerDependency(PermissionsManager.class, plugin.getPermissionsManager());
|
||||
registerDependency(RequestManager.class, plugin.getRequestManager());
|
||||
}
|
||||
|
||||
private void registerCompletions() {
|
||||
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())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
AbstractCompletion obj = c.getConstructor(SimpleClans.class).newInstance(plugin);
|
||||
if (obj instanceof AbstractStaticCompletion) {
|
||||
getCommandCompletions().registerStaticCompletion(obj.getId(),
|
||||
((AbstractStaticCompletion) obj).getCompletions());
|
||||
}
|
||||
if (obj instanceof AbstractAsyncCompletion) {
|
||||
getCommandCompletions().registerAsyncCompletion(obj.getId(), (AbstractAsyncCompletion) obj);
|
||||
}
|
||||
if (obj instanceof AbstractSyncCompletion) {
|
||||
getCommandCompletions().registerCompletion(obj.getId(), ((AbstractSyncCompletion) obj));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error registering completion", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void registerConditions() {
|
||||
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())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
AbstractCondition obj = c.getConstructor(SimpleClans.class).newInstance(plugin);
|
||||
if (obj instanceof AbstractParameterCondition) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
AbstractParameterCondition condition = (AbstractParameterCondition) obj;
|
||||
getCommandConditions().addCondition(condition.getType(), condition.getId(), condition);
|
||||
}
|
||||
if (obj instanceof AbstractCommandCondition) {
|
||||
AbstractCommandCondition condition = (AbstractCommandCondition) obj;
|
||||
getCommandConditions().addCondition(condition.getId(), condition);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error registering condition", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private void registerContexts() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.contexts");
|
||||
Set<Class<? extends AbstractContextResolver>> resolvers = reflections.getSubTypesOf(AbstractContextResolver.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command contexts...", resolvers.size()));
|
||||
for (Class<? extends AbstractContextResolver> cr : resolvers) {
|
||||
if (Modifier.isAbstract(cr.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
AbstractContextResolver obj = cr.getConstructor(SimpleClans.class).newInstance(plugin);
|
||||
if (obj instanceof AbstractIssuerOnlyContextResolver) {
|
||||
getCommandContexts().registerIssuerOnlyContext(obj.getType(), ((AbstractIssuerOnlyContextResolver) obj));
|
||||
}
|
||||
if (obj instanceof AbstractInputOnlyContextResolver) {
|
||||
getCommandContexts().registerContext(obj.getType(), ((AbstractInputOnlyContextResolver<?>) obj));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error registering context", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
boolean forceCommandPriority = plugin.getSettingsManager().isForceCommandPriority();
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands");
|
||||
Set<Class<? extends BaseCommand>> commands = reflections.getSubTypesOf(BaseCommand.class);
|
||||
plugin.getLogger().info(String.format("Registering %d base commands...", commands.size()));
|
||||
for (Class<? extends BaseCommand> c : commands) {
|
||||
//ACF already registers nested classes
|
||||
if (c.isMemberClass() || Modifier.isStatic(c.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
BaseCommand baseCommand = c.getConstructor().newInstance();
|
||||
registerCommand(baseCommand, forceCommandPriority);
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error registering command", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addCommandReplacements() {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
getCommandReplacements().addReplacements(
|
||||
"basic_conditions", "not_blacklisted|not_banned",
|
||||
"clan", sm.getCommandClan(),
|
||||
"deny", sm.getCommandDeny(),
|
||||
"more", sm.getCommandMore(),
|
||||
"ally_chat", sm.getCommandAlly(),
|
||||
"accept", sm.getCommandAccept(),
|
||||
"clan_chat", sm.getCommandClanChat()
|
||||
);
|
||||
|
||||
SUBCOMMANDS.forEach(s -> {
|
||||
String command = optionalLang(s + ".command", null);
|
||||
if (command == null) {
|
||||
command = s;
|
||||
}
|
||||
command = command.replace(" ", "");
|
||||
String replacement = command.equals(s) ? s : command + "|" + s;
|
||||
getCommandReplacements().addReplacement(s, replacement);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitLocales getLocales() {
|
||||
if (this.locales == null) {
|
||||
this.locales = new BukkitLocales(this) {
|
||||
|
||||
@Nullable
|
||||
private Player getPlayer(CommandIssuer issuer) {
|
||||
if (issuer != null) {
|
||||
return Bukkit.getPlayer(issuer.getUniqueId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getOptionalMessage(CommandIssuer issuer, MessageKey key) {
|
||||
return optionalLang(key.getKey(), getPlayer(issuer));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getMessage(CommandIssuer issuer, MessageKeyProvider key) {
|
||||
return lang(key.getMessageKey().getKey(), getPlayer(issuer));
|
||||
}
|
||||
};
|
||||
//this.locales.loadLanguages();
|
||||
}
|
||||
|
||||
return this.locales;
|
||||
}
|
||||
|
||||
static {
|
||||
SUBCOMMANDS = Arrays.asList("setbanner", "resetkdr", "place", "rank", "home", "war", "regroup",
|
||||
"mostkilled", "kills", "globalff", "reload", "unban", "ban", "verify", "disband", "resign", "ff",
|
||||
"clanff", "demote", "promote", "untrust", "trust", "purge", "fee", "bank", "kick", "invite", "toggle",
|
||||
"modtag", "bb", "clear", "rival", "ally", "add", "remove", "stats", "coords", "vitals", "rivalries",
|
||||
"alliances", "leaderboard", "allow", "block", "auto", "check", "assign", "unassign", "delete", "me",
|
||||
"setdisplayname", "permissions", "tag", "deposit", "withdraw", "set", "status", "tp", "all", "everyone",
|
||||
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help");
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
public class SetRankCommand {
|
||||
public SetRankCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.create"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.assign"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.rank.setdisplayname"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class StatsCommand {
|
||||
public StatsCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.stats")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.STATS, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.stats"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(clan.getName()) + subColor + " " + plugin.getLang("stats") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("kdr") + " = " + subColor + plugin.getLang("kill.death.ratio"));
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("weights") + " = " + plugin.getLang("rival") + ": " + subColor + plugin.getSettingsManager().getKwRival() + headColor + " " + plugin.getLang("neutral") + ": " + subColor + plugin.getSettingsManager().getKwNeutral() + headColor + " " + plugin.getLang("civilian") + ": " + subColor + plugin.getSettingsManager().getKwCivilian());
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.setFlexibility(true, false, false, false, false, false, false);
|
||||
chatBlock.setAlignment("l", "c", "c", "c", "c", "c", "c");
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("name"), plugin.getLang("kdr"), plugin.getLang("rival"), plugin.getLang("neutral"), plugin.getLang("civilian.abbreviation"), plugin.getLang("deaths"));
|
||||
|
||||
List<ClanPlayer> leaders = clan.getLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByKDR(leaders);
|
||||
|
||||
List<ClanPlayer> members = clan.getNonLeaders();
|
||||
plugin.getClanManager().sortClanPlayersByKDR(members);
|
||||
|
||||
addRows(leaders, chatBlock);
|
||||
addRows(members, chatBlock);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
|
||||
private void addRows(List<ClanPlayer> leaders, ChatBlock chatBlock) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
NumberFormat formatter = new DecimalFormat("#.#");
|
||||
|
||||
for (ClanPlayer cpm : leaders) {
|
||||
String name = (cpm.isLeader() ? plugin.getSettingsManager().getPageLeaderColor() : (cpm.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() : plugin.getSettingsManager().getPageUnTrustedColor())) + cpm.getName();
|
||||
String rival = NumberFormat.getInstance().format(cpm.getRivalKills());
|
||||
String neutral = NumberFormat.getInstance().format(cpm.getNeutralKills());
|
||||
String civilian = NumberFormat.getInstance().format(cpm.getCivilianKills());
|
||||
String deaths = NumberFormat.getInstance().format(cpm.getDeaths());
|
||||
String kdr = formatter.format(cpm.getKDR());
|
||||
|
||||
chatBlock.addRow(" " + name, ChatColor.YELLOW + kdr, ChatColor.WHITE + rival, ChatColor.GRAY + neutral, ChatColor.DARK_GRAY + civilian, ChatColor.DARK_RED + deaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class ToggleCommand {
|
||||
|
||||
public ToggleCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (arg.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = arg[0];
|
||||
|
||||
if (cmd.equalsIgnoreCase("cape")) {
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.member.cape-toggle")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isCapeEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("capeoff"));
|
||||
cp.setCapeEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("capeon"));
|
||||
cp.setCapeEnabled(true);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("bb") && plugin.getPermissionsManager().has(player, "simpleclans.member.bb-toggle")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isBbEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("bboff"));
|
||||
cp.setBbEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("bbon"));
|
||||
cp.setBbEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("tag") && plugin.getPermissionsManager().has(player, "simpleclans.member.tag-toggle")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isTagEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("tagoff"));
|
||||
cp.setTagEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("tagon"));
|
||||
cp.setTagEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("deposit") && plugin.getPermissionsManager().has(player, "simpleclans.leader.deposit-toggle")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
if (clan.isLeader(player)) {
|
||||
if (clan.isVerified()) {
|
||||
if (clan.isAllowDeposit()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("depositoff"));
|
||||
clan.setAllowDeposit(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("depositon"));
|
||||
clan.setAllowDeposit(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("fee") && plugin.getPermissionsManager().has(player, RankPermission.FEE_ENABLE, PermissionLevel.LEADER, true)) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
if (clan.isVerified()) {
|
||||
if (clan.isMemberFeeEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("feeoff"));
|
||||
clan.setMemberFeeEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("feeon"));
|
||||
clan.setMemberFeeEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("withdraw") && plugin.getPermissionsManager().has(player, "simpleclans.leader.withdraw-toggle")) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
if (clan.isVerified()) {
|
||||
if (clan.isLeader(player)) {
|
||||
if (clan.isAllowWithdraw()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("withdrawoff"));
|
||||
clan.setAllowWithdraw(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("withdrawon"));
|
||||
clan.setAllowWithdraw(true);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class TrustCommand {
|
||||
public TrustCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.settrust")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.trust.player"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID trusted = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (trusted == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (trusted.equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.trust.yourself"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isMember(trusted)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(trusted)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("leaders.are.already.trusted"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer tcp = plugin.getClanManager().getClanPlayer(trusted);
|
||||
|
||||
if (tcp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (tcp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.already.trusted"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.given.trusted.status.by"), Helper.capitalize(arg[0]), player.getName()));
|
||||
tcp.setTrusted(true);
|
||||
plugin.getStorageManager().updateClanPlayer(tcp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class UnbanCommand {
|
||||
public UnbanCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.ban")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.ban.unban"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (uuid == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getSettingsManager().isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.not.banned"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player pl = Bukkit.getPlayer(uuid);
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, ChatColor.AQUA + plugin.getLang("you.have.been.unbanned.from.clan.commands"));
|
||||
}
|
||||
|
||||
plugin.getSettingsManager().removeBanned(uuid);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.removed.from.the.banned.list"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class UntrustCommand {
|
||||
public UntrustCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.settrust")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.untrust.player"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
UUID trustedId = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (trustedId == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (trustedId.equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.untrust.yourself"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isMember(trustedId)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(trustedId)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("leaders.cannot.be.untrusted"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer tcp = plugin.getClanManager().getClanPlayer(trustedId);
|
||||
|
||||
if (tcp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (!tcp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.already.untrusted"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.given.untrusted.status.by"), Helper.capitalize(arg[0]), player.getName()));
|
||||
tcp.setTrusted(false);
|
||||
plugin.getStorageManager().updateClanPlayer(tcp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class VerifyCommand {
|
||||
|
||||
public VerifyCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param sender
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(CommandSender sender, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
Clan clan = cp == null ? null : cp.getClan();
|
||||
|
||||
boolean isNonVerified = clan != null && !clan.isVerified();
|
||||
boolean isBuyer = isNonVerified && plugin.getSettingsManager().isRequireVerification() && plugin.getSettingsManager().isePurchaseVerification();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.verify")) {
|
||||
//if the player does specify a tag, but does not have mod permission to verify
|
||||
//if the player does not specify a tag, but does not have leader permission to verify
|
||||
if (arg.length != 0 || !plugin.getPermissionsManager().has(player, "simpleclans.leader.verify")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (isBuyer) {
|
||||
if (arg.length == 0 && plugin.getClanManager().purchaseVerification(player)) {
|
||||
clan.verifyClan();
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.0.has.been.verified"), clan.getName()));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("the.clan.has.been.verified"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.verify.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
verify(player, arg[0]);
|
||||
}
|
||||
} else {
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.verify.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
verify(sender, arg[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void verify(CommandSender player, String clanName) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
Clan clan = plugin.getClanManager().getClan(clanName);
|
||||
|
||||
if (clan != null) {
|
||||
if (!clan.isVerified()) {
|
||||
clan.verifyClan();
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.0.has.been.verified"), clan.getName()));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("the.clan.has.been.verified"));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.is.already.verified"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.does.not.exist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class VitalsCommand {
|
||||
public VitalsCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.vitals")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.VITALS, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.vitals"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(clan.getName()) + subColor + " " + plugin.getLang("vitals") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("weapons") + ": " + MessageFormat.format(plugin.getLang("0.s.sword.1.2.b.bow.3.4.a.arrow"), ChatColor.WHITE, ChatColor.DARK_GRAY, ChatColor.WHITE, ChatColor.DARK_GRAY, ChatColor.WHITE));
|
||||
ChatBlock.sendMessage(player, headColor + plugin.getLang("materials") + ": " + ChatColor.AQUA + plugin.getLang("diamond") + ChatColor.DARK_GRAY + ", " + ChatColor.YELLOW + plugin.getLang("gold") + ChatColor.DARK_GRAY + ", " + ChatColor.GRAY + plugin.getLang("stone") + ChatColor.DARK_GRAY + ", " + ChatColor.WHITE + plugin.getLang("iron") + ChatColor.DARK_GRAY + ", " + ChatColor.GOLD + plugin.getLang("wood"));
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
chatBlock.setFlexibility(true, false, false, false, false, false);
|
||||
chatBlock.setAlignment("l", "l", "l", "c", "c", "c");
|
||||
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("name"), plugin.getLang("health"), plugin.getLang("hunger"), plugin.getLang("food"), plugin.getLang("armor"), plugin.getLang("weapons"));
|
||||
|
||||
List<ClanPlayer> members = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
members.addAll(Helper.stripOffLinePlayers(clan.getNonLeaders()));
|
||||
|
||||
addRows(members, chatBlock);
|
||||
|
||||
chatBlock.addRow(" -- Allies -- ", "", "", "", "", "");
|
||||
|
||||
addRows(clan.getAllAllyMembers(), chatBlock);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
if (more) {
|
||||
plugin.getStorageManager().addChatBlock(player, chatBlock);
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, headColor + MessageFormat.format(plugin.getLang("view.next.page"), plugin.getSettingsManager().getCommandMore()));
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
|
||||
private void addRows(Collection<ClanPlayer> players, ChatBlock chatBlock){
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
for (ClanPlayer cpm : players) {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
String name = (cpm.isLeader() ? plugin.getSettingsManager().getPageLeaderColor() : (cpm.isTrusted() ? plugin.getSettingsManager().getPageTrustedColor() : plugin.getSettingsManager().getPageUnTrustedColor())) + cpm.getName();
|
||||
String health = plugin.getClanManager().getHealthString(p.getHealth());
|
||||
String hunger = plugin.getClanManager().getHungerString(p.getFoodLevel());
|
||||
String armor = plugin.getClanManager().getArmorString(p.getInventory());
|
||||
String weapons = plugin.getClanManager().getWeaponString(p.getInventory());
|
||||
String food = plugin.getClanManager().getFoodString(p.getInventory());
|
||||
|
||||
chatBlock.addRow(" " + name, ChatColor.RED + health, hunger, ChatColor.WHITE + food, armor, weapons);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class WarCommand {
|
||||
public WarCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param arg
|
||||
*/
|
||||
public void execute(Player player, String[] arg) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.war")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.war"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String action = arg[0];
|
||||
Clan war = plugin.getClanManager().getClan(arg[1]);
|
||||
|
||||
if (war == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.clan.matched"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isRival(war.getTag())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.can.only.start.war.with.rivals"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equals(plugin.getLang("start"))) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.WAR_START, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (!clan.isWarring(war.getTag())) {
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
|
||||
if (!onlineLeaders.isEmpty()) {
|
||||
plugin.getRequestManager().addWarStartRequest(cp, war, clan);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.have.been.asked.to.accept.the.war.request"), Helper.capitalize(war.getName())));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("at.least.one.leader.accept.the.alliance"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clans.already.at.war"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.equals(plugin.getLang("end"))) {
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.WAR_END, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (clan.isWarring(war.getTag())) {
|
||||
plugin.getRequestManager().addWarEndRequest(cp, war, clan);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.asked.to.end.rivalry"), Helper.capitalize(war.getName())));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clans.not.at.war"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.war"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%ally_chat")
|
||||
@Description("{@@command.description.ally}")
|
||||
@CommandPermission("simpleclans.member.ally")
|
||||
@Conditions("%basic_conditions|clan_member|rank:name=ALLY_CHAT")
|
||||
public class AllyChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ClanManager clanManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, @Name("message") String message) {
|
||||
if (!settingsManager.isAllyChatEnable()) {
|
||||
return;
|
||||
}
|
||||
clanManager.processAllyChat(player, message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%bank")
|
||||
@Conditions("%basic_conditions|economy|verified")
|
||||
public class BankCommand extends BaseCommand {
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
|
||||
@Subcommand("%status")
|
||||
@CommandPermission("simpleclans.member.bank")
|
||||
@Conditions("rank:name=BANK_BALANCE")
|
||||
@Description("{@@command.description.bank.status}")
|
||||
public void bankStatus(Player player, Clan clan) {
|
||||
player.sendMessage(AQUA + lang("clan.balance", player, clan.getBalance()));
|
||||
}
|
||||
|
||||
@Subcommand("%withdraw %all")
|
||||
@CommandPermission("simpleclans.member.bank")
|
||||
@Conditions("rank:name=BANK_WITHDRAW")
|
||||
@Description("{@@command.description.bank.withdraw.all}")
|
||||
public void bankWithdraw(Player player, Clan clan) {
|
||||
processWithdraw(player, clan, clan.getBalance());
|
||||
}
|
||||
|
||||
@Subcommand("%withdraw")
|
||||
@CommandPermission("simpleclans.member.bank")
|
||||
@Conditions("rank:name=BANK_WITHDRAW")
|
||||
@Description("{@@command.description.bank.withdraw.amount}")
|
||||
public void bankWithdraw(Player player, Clan clan, double amount) {
|
||||
processWithdraw(player, clan, amount);
|
||||
}
|
||||
|
||||
private void processWithdraw(Player player, Clan clan, double amount) {
|
||||
if (!clan.isAllowWithdraw()) {
|
||||
String message = getCurrentCommandManager().getCommandReplacements()
|
||||
.replace(lang("withdraw.not.allowed", player));
|
||||
ChatBlock.sendMessage(player, RED + message);
|
||||
return;
|
||||
}
|
||||
amount = Math.abs(amount);
|
||||
clan.withdraw(amount, player);
|
||||
}
|
||||
|
||||
@Subcommand("%deposit %all")
|
||||
@CommandPermission("simpleclans.member.bank")
|
||||
@Conditions("rank:name=BANK_DEPOSIT")
|
||||
@Description("{@@command.description.bank.deposit.all}")
|
||||
public void bankDeposit(Player player, Clan clan) {
|
||||
processDeposit(player, clan, permissions.playerGetMoney(player));
|
||||
}
|
||||
|
||||
@Subcommand("%deposit")
|
||||
@CommandPermission("simpleclans.member.bank")
|
||||
@Conditions("rank:name=BANK_DEPOSIT")
|
||||
@Description("{@@command.description.bank.deposit.amount}")
|
||||
public void bankDeposit(Player player, Clan clan, double amount) {
|
||||
processDeposit(player, clan, amount);
|
||||
}
|
||||
|
||||
private void processDeposit(Player player, Clan clan, double amount) {
|
||||
if (!clan.isAllowDeposit()) {
|
||||
String message = getCurrentCommandManager().getCommandReplacements()
|
||||
.replace(lang("deposit.not.allowed", player));
|
||||
ChatBlock.sendMessage(player, RED + message);
|
||||
return;
|
||||
}
|
||||
amount = Math.abs(amount);
|
||||
clan.deposit(amount, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
public class BbCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
|
||||
@Subcommand("%bb")
|
||||
@CommandPermission("simpleclans.member.bb")
|
||||
@Description("{@@command.description.bb.display}")
|
||||
public void display(Player sender) {
|
||||
Clan clan = Objects.requireNonNull(cm.getClanByPlayerUniqueId(sender.getUniqueId()));
|
||||
clan.displayBb(sender);
|
||||
}
|
||||
|
||||
@Subcommand("%bb %clear")
|
||||
@CommandPermission("simpleclans.leader.bb-clear")
|
||||
@Conditions("rank:name=BB_CLEAR")
|
||||
@Description("{@@command.description.bb.clear}")
|
||||
public void clear(Player player) {
|
||||
Clan clan = Objects.requireNonNull(cm.getClanByPlayerUniqueId(player.getUniqueId()));
|
||||
clan.clearBb();
|
||||
ChatBlock.sendMessage(player, RED + lang("cleared.bb", player));
|
||||
}
|
||||
|
||||
@Subcommand("%bb %add")
|
||||
@CommandPermission("simpleclans.member.bb-add")
|
||||
@Conditions("rank:name=BB_ADD")
|
||||
@Description("{@@command.description.bb.post}")
|
||||
public void postMessage(Player player, @Name("message") String msg) {
|
||||
Clan clan = Objects.requireNonNull(cm.getClanByPlayerUniqueId(player.getUniqueId()));
|
||||
clan.addBb(player.getName(), AQUA + player.getName() + ": " + WHITE + msg);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("%clan_chat")
|
||||
@Conditions("%basic_conditions|clan_member")
|
||||
@CommandPermission("simpleclans.member.chat")
|
||||
@Description("{@@command.description.chat}")
|
||||
public class ChatCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ClanManager clanManager;
|
||||
@Dependency
|
||||
private SettingsManager settingsManager;
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, ClanPlayer cp, @Name("message") String message) {
|
||||
if (!settingsManager.getClanChatEnable()) {
|
||||
return;
|
||||
}
|
||||
clanManager.processClanChat(player, cp.getTag(), message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
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.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions")
|
||||
public class ClanCommands extends BaseCommand {
|
||||
@Dependency
|
||||
private SimpleClans plugin;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
@Dependency
|
||||
private RequestManager requestManager;
|
||||
|
||||
@Subcommand("%war %start")
|
||||
@CommandPermission("simpleclans.leader.war")
|
||||
@Conditions("verified|rank:name=WAR_START")
|
||||
@Description("{@@command.description.war.start}")
|
||||
@CommandCompletion("@rivals")
|
||||
public void startWar(Player player, ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
Clan war = other.getClan();
|
||||
if (!issuerClan.isRival(war.getTag())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.can.only.start.war.with.rivals", player));
|
||||
return;
|
||||
}
|
||||
if (!issuerClan.isWarring(war.getTag())) {
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(issuerClan.getLeaders());
|
||||
|
||||
if (!onlineLeaders.isEmpty()) {
|
||||
requestManager.addWarStartRequest(cp, war, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.have.been.asked.to.accept.the.war.request",
|
||||
player, war.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("at.least.one.leader.accept.the.alliance", player));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("clans.already.at.war", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%war %end")
|
||||
@CommandPermission("simpleclans.leader.war")
|
||||
@Conditions("verified|rank:name=WAR_END")
|
||||
@Description("{@@command.description.war.end}")
|
||||
@CommandCompletion("@warring_clans")
|
||||
public void endWar(Player player, ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
Clan war = other.getClan();
|
||||
if (issuerClan.isWarring(war.getTag())) {
|
||||
requestManager.addWarEndRequest(cp, war, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.asked.to.end.rivalry", player, war.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("clans.not.at.war", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%modtag")
|
||||
@CommandPermission("simpleclans.leader.modtag")
|
||||
@Conditions("verified|rank:name=MODTAG")
|
||||
@Description("{@@command.description.modtag}")
|
||||
public void modtag(Player player, Clan clan, @Single @Name("tag") String tag) {
|
||||
TagChangeEvent event = new TagChangeEvent(player, clan, tag);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
tag = event.getNewTag();
|
||||
String cleanTag = Helper.cleanTag(tag);
|
||||
|
||||
TagValidator validator = new TagValidator(plugin, player, tag);
|
||||
if (validator.getErrorMessage() != null) {
|
||||
ChatBlock.sendMessage(player, validator.getErrorMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cleanTag.equals(clan.getTag())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.can.only.modify.the.color.and.case.of.the.tag",
|
||||
player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", Helper.parseColors(tag)));
|
||||
clan.changeClanTag(tag);
|
||||
cm.updateDisplayName(player);
|
||||
}
|
||||
|
||||
@Subcommand("%setbanner")
|
||||
@CommandPermission("simpleclans.leader.setbanner")
|
||||
@Conditions("verified|rank:name=SETBANNER")
|
||||
@Description("{@@command.description.setbanner}")
|
||||
public void setbanner(Player player, Clan clan) {
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (!hand.getType().toString().contains("BANNER")) {
|
||||
ChatBlock.sendMessageKey(player, "you.must.hold.a.banner");
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setBanner(hand);
|
||||
storage.updateClan(clan);
|
||||
ChatBlock.sendMessageKey(player, "you.changed.clan.banner");
|
||||
}
|
||||
|
||||
@Subcommand("%invite")
|
||||
@CommandPermission("simpleclans.leader.invite")
|
||||
@CommandCompletion("@non_members")
|
||||
@Conditions("rank:name=INVITE")
|
||||
@Description("{@@command.description.invite}")
|
||||
public void invite(Player sender, ClanPlayer cp, Clan clan,
|
||||
@Conditions("not_banned|not_in_clan|online") @Name("player") ClanPlayerInput invited) {
|
||||
Player invitedPlayer = invited.getClanPlayer().toPlayer();
|
||||
if (invitedPlayer == null) return;
|
||||
if (!permissions.has(invitedPlayer, "simpleclans.member.can-join")) {
|
||||
ChatBlock.sendMessage(sender, RED +
|
||||
lang("the.player.doesn.t.not.have.the.permissions.to.join.clans", sender));
|
||||
return;
|
||||
}
|
||||
if (invitedPlayer.getUniqueId().equals(sender.getUniqueId())) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.invite.yourself", sender));
|
||||
return;
|
||||
}
|
||||
long minutesBeforeRejoin = cm.getMinutesBeforeRejoin(invited.getClanPlayer(), clan);
|
||||
if (minutesBeforeRejoin != 0) {
|
||||
ChatBlock.sendMessage(sender, RED +
|
||||
lang("the.player.must.wait.0.before.joining.your.clan.again", sender, minutesBeforeRejoin));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getSize() >= settings.getMaxMembers()) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("the.clan.members.reached.limit", sender));
|
||||
return;
|
||||
}
|
||||
if (!cm.purchaseInvite(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
requestManager.addInviteRequest(cp, invitedPlayer.getName(), clan);
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("has.been.asked.to.join",
|
||||
sender, invitedPlayer.getName(), clan.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("%fee %check")
|
||||
@Conditions("member_fee_enabled|verified")
|
||||
@CommandPermission("simpleclans.member.fee-check")
|
||||
@Description("{@@command.description.fee.check}")
|
||||
public void checkFee(Player player, Clan clan) {
|
||||
ChatBlock.sendMessage(player, AQUA
|
||||
+ lang("the.fee.is.0.and.its.current.value.is.1", player, clan.isMemberFeeEnabled() ?
|
||||
lang("fee.enabled", player) : lang("fee.disabled", player),
|
||||
clan.getMemberFee()
|
||||
));
|
||||
}
|
||||
|
||||
@Subcommand("%fee %set")
|
||||
@CommandPermission("simpleclans.leader.fee")
|
||||
@Conditions("rank:name=FEE_SET|change_fee")
|
||||
@Description("{@@command.description.fee.set}")
|
||||
public void setFee(Player player, Clan clan, @Name("fee") double fee) {
|
||||
fee = Math.abs(fee);
|
||||
double maxFee = settings.getMaxMemberFee();
|
||||
if (fee > maxFee) {
|
||||
ChatBlock.sendMessage(player, RED
|
||||
+ lang("max.fee.allowed.is.0", player, maxFee));
|
||||
return;
|
||||
}
|
||||
if (cm.purchaseMemberFeeSet(player)) {
|
||||
clan.setMemberFee(fee);
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.fee.set", fee));
|
||||
ChatBlock.sendMessage(player, AQUA + lang("fee.set", player));
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%clanff %allow")
|
||||
@CommandPermission("simpleclans.leader.ff")
|
||||
@Conditions("rank:name=FRIENDLYFIRE")
|
||||
@Description("{@@command.description.clanff.allow}")
|
||||
public void allowClanFf(Player player, Clan clan) {
|
||||
clan.addBb(player.getName(), AQUA + lang("clan.wide.friendly.fire.is.allowed"));
|
||||
clan.setFriendlyFire(true);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%clanff %block")
|
||||
@CommandPermission("simpleclans.leader.ff")
|
||||
@Description("{@@command.description.clanff.block}")
|
||||
public void blockClanFf(Player player, Clan clan) {
|
||||
clan.addBb(player.getName(), AQUA + lang("clan.wide.friendly.fire.blocked"));
|
||||
clan.setFriendlyFire(false);
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%description")
|
||||
@CommandPermission("simpleclans.leader.description")
|
||||
@Conditions("verified|rank:name=DESCRIPTION")
|
||||
@Description("{@@command.description.description}")
|
||||
public void setDescription(Player player, Clan clan, @Name("description") String description) {
|
||||
if (description.length() < settings.getClanMinDescriptionLength()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.must.be.longer.than",
|
||||
player, settings.getClanMinDescriptionLength()));
|
||||
return;
|
||||
}
|
||||
if (description.length() > settings.getClanMaxDescriptionLength()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clan.description.cannot.be.longer.than",
|
||||
player, settings.getClanMaxDescriptionLength()));
|
||||
return;
|
||||
}
|
||||
clan.setDescription(description);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("description.changed", player));
|
||||
storage.updateClan(clan);
|
||||
}
|
||||
|
||||
@Subcommand("%rival %add")
|
||||
@CommandPermission("simpleclans.leader.rival")
|
||||
@Conditions("verified|rivable|minimum_to_rival|rank:name=RIVAL_ADD")
|
||||
@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();
|
||||
if (settings.isUnrivable(rivalInput.getTag())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("the.clan.cannot.be.rivaled", player));
|
||||
return;
|
||||
}
|
||||
if (!issuerClan.reachedRivalLimit()) {
|
||||
if (!issuerClan.isRival(rivalInput.getTag())) {
|
||||
issuerClan.addRival(rivalInput);
|
||||
rivalInput.addBb(player.getName(), AQUA + lang("has.initiated.a.rivalry", issuerClan.getName(),
|
||||
rivalInput.getName()), false);
|
||||
issuerClan.addBb(player.getName(), AQUA + lang("has.initiated.a.rivalry", player.getName(),
|
||||
rivalInput.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.rivals", player));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("rival.limit.reached", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%rival %remove")
|
||||
@CommandPermission("simpleclans.leader.rival")
|
||||
@Conditions("verified|rank:name=RIVAL_REMOVE")
|
||||
@CommandCompletion("@rivals")
|
||||
@Description("{@@command.description.rival.remove}")
|
||||
public void removeRival(Player player,
|
||||
ClanPlayer cp,
|
||||
Clan issuerClan,
|
||||
@Conditions("different") @Name("clan") ClanInput rival) {
|
||||
Clan rivalInput = rival.getClan();
|
||||
if (issuerClan.isRival(rivalInput.getTag())) {
|
||||
requestManager.addRivalryBreakRequest(cp, rivalInput, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.asked.to.end.rivalry", player,
|
||||
rivalInput.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.not.rivals", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%ally %add")
|
||||
@CommandPermission("simpleclans.leader.ally")
|
||||
@Conditions("verified|rank:name=ALLY_ADD|minimum_to_ally")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.ally.add}")
|
||||
public void addAlly(Player player,
|
||||
ClanPlayer cp,
|
||||
Clan issuerClan,
|
||||
@Conditions("verified|different") @Name("clan") ClanInput other) {
|
||||
Clan input = other.getClan();
|
||||
if (issuerClan.isAlly(input.getTag())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("your.clans.are.already.allies", player));
|
||||
return;
|
||||
}
|
||||
int maxAlliances = settings.getClanMaxAlliances();
|
||||
if (maxAlliances != -1) {
|
||||
if (issuerClan.getAllies().size() >= maxAlliances) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.reached.max.alliances", player));
|
||||
return;
|
||||
}
|
||||
if (input.getAllies().size() >= maxAlliances) {
|
||||
ChatBlock.sendMessage(player, lang("other.clan.reached.max.alliances", player));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(issuerClan.getLeaders());
|
||||
if (onlineLeaders.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("at.least.one.leader.accept.the.alliance",
|
||||
player));
|
||||
return;
|
||||
}
|
||||
|
||||
requestManager.addAllyRequest(cp, input, issuerClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.have.been.asked.for.an.alliance",
|
||||
player, input.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("%ally %remove")
|
||||
@Conditions("verified|rank:name=ALLY_REMOVE")
|
||||
@CommandPermission("simpleclans.leader.ally")
|
||||
@Description("{@@command.description.ally.remove}")
|
||||
@CommandCompletion("@allied_clans")
|
||||
public void removeAlly(Player player, Clan issuerClan, @Conditions("different|allied_clan") @Name("clan") ClanInput ally) {
|
||||
Clan allyInput = ally.getClan();
|
||||
issuerClan.removeAlly(allyInput);
|
||||
allyInput.addBb(player.getName(), AQUA + lang("has.broken.the.alliance", issuerClan.getName(),
|
||||
allyInput.getName()), false);
|
||||
issuerClan.addBb(player.getName(), AQUA + lang("has.broken.the.alliance", player.getName(),
|
||||
allyInput.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("%kick")
|
||||
@CommandPermission("simpleclans.leader.kick")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Conditions("rank:name=KICK")
|
||||
@Description("{@@command.description.kick}")
|
||||
public void kick(@Conditions("clan_member") Player sender,
|
||||
@Conditions("same_clan") @Name("member") ClanPlayerInput other) {
|
||||
ClanPlayer clanPlayer = other.getClanPlayer();
|
||||
if (sender.getUniqueId().equals(clanPlayer.getUniqueId())) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.kick.yourself", sender));
|
||||
return;
|
||||
}
|
||||
|
||||
Clan clan = cm.getClanByPlayerUniqueId(sender.getUniqueId());
|
||||
if (Objects.requireNonNull(clan).isLeader(clanPlayer.getUniqueId())) {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.kick.another.leader", sender));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(sender.getName(), AQUA + lang("has.been.kicked.by", clanPlayer.getName(),
|
||||
sender.getName(), sender));
|
||||
clan.removePlayerFromClan(clanPlayer.getUniqueId());
|
||||
}
|
||||
|
||||
@Subcommand("%resign")
|
||||
@CommandPermission("simpleclans.member.resign")
|
||||
@Description("{@@command.description.resign}")
|
||||
public void resign(@Conditions("clan_member") Player player) {
|
||||
new ConversationFactory(plugin)
|
||||
.withFirstPrompt(new ResignPrompt())
|
||||
.withLocalEcho(true)
|
||||
.withTimeout(10)
|
||||
.buildConversation(player).begin();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.data.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
public class DataCommands extends BaseCommand {
|
||||
@Dependency
|
||||
private SimpleClans plugin;
|
||||
|
||||
@Subcommand("%vitals")
|
||||
@CommandPermission("simpleclans.member.vitals")
|
||||
@Conditions("rank:name=VITALS")
|
||||
@Description("{@@command.description.vitals}")
|
||||
public void vitals(CommandSender sender, Clan clan) {
|
||||
Vitals vitals = new Vitals(plugin, sender, clan);
|
||||
vitals.send();
|
||||
}
|
||||
|
||||
@Subcommand("%stats")
|
||||
@CommandPermission("simpleclans.member.stats")
|
||||
@Conditions("rank:name=STATS")
|
||||
@Description("{@@command.description.stats}")
|
||||
public void stats(Player player, Clan clan) {
|
||||
ClanStats stats = new ClanStats(plugin, player, clan);
|
||||
stats.send();
|
||||
}
|
||||
|
||||
@Subcommand("%profile")
|
||||
@CommandPermission("simpleclans.member.profile")
|
||||
@Description("{@@command.description.profile}")
|
||||
public void profile(CommandSender sender, Clan clan) {
|
||||
ClanProfile p = new ClanProfile(plugin, sender, clan);
|
||||
p.send();
|
||||
}
|
||||
|
||||
@Subcommand("%roster")
|
||||
@CommandPermission("simpleclans.member.roster")
|
||||
@Description("{@@command.description.roster}")
|
||||
public void roster(Player player, Clan clan) {
|
||||
ClanRoster r = new ClanRoster(plugin, player, clan);
|
||||
r.send();
|
||||
}
|
||||
|
||||
@Subcommand("%coords")
|
||||
@CommandPermission("simpleclans.member.coords")
|
||||
@Conditions("rank:name=COORDS")
|
||||
@HelpSearchTags("local location")
|
||||
@Description("{@@command.description.coords}")
|
||||
public void coords(Player player, Clan clan) {
|
||||
if (VanishUtils.getNonVanished(player, clan).size() == 1) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.are.the.only.member.online", player));
|
||||
return;
|
||||
}
|
||||
ClanCoords c = new ClanCoords(plugin, player, clan);
|
||||
c.send();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
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.PlayerHomeSetEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
public class HomeCommands extends BaseCommand {
|
||||
@Dependency
|
||||
private SimpleClans plugin;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
|
||||
@Subcommand("%regroup %me")
|
||||
@CommandPermission("simpleclans.leader.regroup.me")
|
||||
@Conditions("rank:name=REGROUP_ME")
|
||||
@Description("{@@command.description.regroup.me}")
|
||||
public void regroupMe(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
|
||||
processTeleport(player, cp, clan, player.getLocation());
|
||||
}
|
||||
|
||||
private void processTeleport(Player player, ClanPlayer cp, Clan clan, Location location) {
|
||||
HomeRegroupEvent homeRegroupEvent = new HomeRegroupEvent(clan, cp, VanishUtils.getNonVanished(player, clan), location);
|
||||
plugin.getServer().getPluginManager().callEvent(homeRegroupEvent);
|
||||
|
||||
if (homeRegroupEvent.isCancelled() || !cm.purchaseHomeRegroup(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getTeleportManager().teleport(player, clan, location);
|
||||
}
|
||||
|
||||
@Subcommand("%regroup %home")
|
||||
@CommandPermission("simpleclans.leader.regroup.home")
|
||||
@Conditions("rank:name=REGROUP_HOME")
|
||||
@Description("{@@command.description.regroup.home}")
|
||||
public void regroupHome(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (!settings.getAllowReGroupCommand()) {
|
||||
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;
|
||||
}
|
||||
|
||||
processTeleport(player, cp, clan, location);
|
||||
}
|
||||
|
||||
@Subcommand("%home")
|
||||
@CommandPermission("simpleclans.member.home")
|
||||
@Conditions("rank:name=HOME_TP")
|
||||
@Description("{@@command.description.home.tp}")
|
||||
public void teleport(Player player, Clan clan, ClanPlayer cp) {
|
||||
Location loc = clan.getHomeLocation();
|
||||
|
||||
if (loc == null) {
|
||||
ChatBlock.sendMessage(player, RED + lang("hombase.not.set", player));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.purchaseHomeTeleport(player)) {
|
||||
plugin.getTeleportManager().addPlayer(player, clan.getHomeLocation(), clan.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%home %clear")
|
||||
@CommandPermission("simpleclans.leader.home-set")
|
||||
@Conditions("rank:name=HOME_SET")
|
||||
@Description("{@@command.description.home.clear}")
|
||||
public void clear(Player player, Clan clan) {
|
||||
if (settings.isHomebaseSetOnce() && clan.getHomeLocation() != null &&
|
||||
!permissions.has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("home.base.only.once", player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(null);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.cleared", player));
|
||||
}
|
||||
|
||||
@Subcommand("%home %set")
|
||||
@Conditions("rank:name=HOME_SET")
|
||||
@CommandPermission("simpleclans.leader.home-set")
|
||||
@Description("{@@command.description.home.set}")
|
||||
public void set(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (settings.isHomebaseSetOnce() && clan.getHomeLocation() != null &&
|
||||
!permissions.has(player, "simpleclans.mod.home")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("home.base.only.once", player));
|
||||
return;
|
||||
}
|
||||
PlayerHomeSetEvent homeSetEvent = new PlayerHomeSetEvent(clan, cp, player.getLocation());
|
||||
plugin.getServer().getPluginManager().callEvent(homeSetEvent);
|
||||
|
||||
if (homeSetEvent.isCancelled() || !cm.purchaseHomeTeleportSet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.setHomeLocation(player.getLocation());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("hombase.set", player, YELLOW +
|
||||
Helper.toLocationString(player.getLocation())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions|leader")
|
||||
public class LeaderCommands extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
|
||||
@Subcommand("%demote")
|
||||
@CommandCompletion("@clan_leaders")
|
||||
@CommandPermission("simpleclans.leader.demote")
|
||||
@Description("{@@command.description.demote}")
|
||||
public void demote(Player player,
|
||||
ClanPlayer cp,
|
||||
Clan clan,
|
||||
@Conditions("same_clan") @Name("leader") ClanPlayerInput other) {
|
||||
ClanPlayer otherCp = other.getClanPlayer();
|
||||
if (!clan.enoughLeadersOnlineToDemote(otherCp)) {
|
||||
ChatBlock.sendMessage(player, RED + lang("not.enough.leaders.online.to.vote.on.demotion", player));
|
||||
return;
|
||||
}
|
||||
if (!clan.isLeader(otherCp.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("player.is.not.a.leader.of.your.clan", player));
|
||||
return;
|
||||
}
|
||||
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));
|
||||
return;
|
||||
}
|
||||
clan.addBb(player.getName(), AQUA + lang("demoted.back.to.member", otherCp.getName()));
|
||||
clan.demote(otherCp.getUniqueId());
|
||||
}
|
||||
|
||||
@Subcommand("%promote")
|
||||
@CommandPermission("simpleclans.leader.promote")
|
||||
@CommandCompletion("@clan_non_leaders")
|
||||
@Description("{@@command.description.promote}")
|
||||
public void promote(Player player,
|
||||
Clan clan,
|
||||
ClanPlayer cp,
|
||||
@Conditions("online|same_clan") @Name("member") ClanPlayerInput other) {
|
||||
Player otherPl = Objects.requireNonNull(other.getClanPlayer().toPlayer());
|
||||
if (!permissions.has(otherPl, "simpleclans.leader.promotable")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("the.player.does.not.have.the.permissions.to.lead.a.clan",
|
||||
player));
|
||||
return;
|
||||
}
|
||||
if (otherPl.getUniqueId().equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.cannot.promote.yourself", player));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(otherPl.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("the.player.is.already.a.leader", player));
|
||||
return;
|
||||
}
|
||||
if (settings.isConfirmationForPromote() && clan.getLeaders().size() > 1) {
|
||||
requestManager.addPromoteRequest(cp, otherPl.getName(), clan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("promotion.vote.has.been.requested.from.all.leaders",
|
||||
player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("promoted.to.leader", otherPl.getName()));
|
||||
clan.promote(otherPl.getUniqueId());
|
||||
}
|
||||
|
||||
@Subcommand("%disband")
|
||||
@CommandPermission("simpleclans.leader.disband")
|
||||
@Description("{@@command.description.disband}")
|
||||
public void disband(Player player, ClanPlayer cp, Clan clan) {
|
||||
if (clan.getLeaders().size() != 1) {
|
||||
requestManager.addDisbandRequest(cp, clan);
|
||||
ChatBlock.sendMessage(player, AQUA +
|
||||
lang("clan.disband.vote.has.been.requested.from.all.leaders", player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.clanAnnounce(player.getName(), AQUA + lang("clan.has.been.disbanded", clan.getName()));
|
||||
clan.disband();
|
||||
}
|
||||
|
||||
@Subcommand("%verify")
|
||||
@CommandPermission("simpleclans.leader.verify")
|
||||
@Description("{@@command.description.verify}")
|
||||
public void verify(Player player, Clan clan) {
|
||||
if (clan.isVerified()) {
|
||||
ChatBlock.sendMessageKey(player, "your.clan.already.verified");
|
||||
return;
|
||||
}
|
||||
if (!settings.isePurchaseVerification()) {
|
||||
ChatBlock.sendMessageKey(player, "staff.member.verify.clan");
|
||||
return;
|
||||
}
|
||||
int minToVerify = settings.getMinToVerify();
|
||||
if (minToVerify > clan.getAllMembers().size()) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.must.have.members.to.verify", player, minToVerify));
|
||||
return;
|
||||
}
|
||||
if (cm.purchaseVerification(player)) {
|
||||
clan.verifyClan();
|
||||
clan.addBb(player.getName(), AQUA + lang("clan.0.has.been.verified", clan.getName()));
|
||||
ChatBlock.sendMessage(player, AQUA + lang("the.clan.has.been.verified", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%trust")
|
||||
@CommandPermission("simpleclans.leader.settrust")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Description("{@@command.description.trust}")
|
||||
public void trust(Player player, Clan clan, @Conditions("same_clan") @Name("member") ClanPlayerInput trusted) {
|
||||
ClanPlayer trustedInput = trusted.getClanPlayer();
|
||||
if (player.getUniqueId().equals(trustedInput.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.cannot.trust.yourself", player));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(trustedInput.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("leaders.are.already.trusted", player));
|
||||
return;
|
||||
}
|
||||
if (trustedInput.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("this.player.is.already.trusted", player));
|
||||
return;
|
||||
}
|
||||
clan.addBb(player.getName(), AQUA + lang("has.been.given.trusted.status.by", trustedInput.getName(),
|
||||
player.getName()));
|
||||
trustedInput.setTrusted(true);
|
||||
storage.updateClanPlayer(trustedInput);
|
||||
}
|
||||
|
||||
@Subcommand("%untrust")
|
||||
@CommandPermission("simpleclans.leader.settrust")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Description("{@@command.description.untrust}")
|
||||
public void untrust(Player player, Clan clan, @Conditions("same_clan") @Name("member") ClanPlayerInput trusted) {
|
||||
ClanPlayer trustedInput = trusted.getClanPlayer();
|
||||
if (trustedInput.getUniqueId().equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.cannot.untrust.yourself", player));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(trustedInput.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("leaders.cannot.be.untrusted", player));
|
||||
return;
|
||||
}
|
||||
if (!trustedInput.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("this.player.is.already.untrusted", player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("has.been.given.untrusted.status.by", trustedInput.getName(),
|
||||
player.getName()));
|
||||
trustedInput.setTrusted(false);
|
||||
storage.updateClanPlayer(trustedInput);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
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.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
import static org.bukkit.ChatColor.RED;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%rank")
|
||||
@Conditions("%basic_conditions|verified|leader")
|
||||
public class RankCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private SimpleClans plugin;
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
@Dependency
|
||||
private PermissionsManager permissions;
|
||||
|
||||
@Subcommand("%assign")
|
||||
@CommandPermission("simpleclans.leader.rank.assign")
|
||||
@CommandCompletion("@clan_members @ranks")
|
||||
@Description("{@@command.description.rank.assign}")
|
||||
public void assign(Player player,
|
||||
Clan clan,
|
||||
@Name("member") @Conditions("same_clan") ClanPlayerInput member,
|
||||
@Name("rank") Rank rank) {
|
||||
ClanPlayer memberInput = member.getClanPlayer();
|
||||
if (memberInput.getRankId().equals(rank.getName())) {
|
||||
ChatBlock.sendMessage(player, lang("player.already.has.that.rank", player));
|
||||
return;
|
||||
}
|
||||
|
||||
memberInput.setRank(rank.getName());
|
||||
storage.updateClanPlayer(memberInput);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("player.rank.changed", player));
|
||||
}
|
||||
|
||||
@Subcommand("%unassign")
|
||||
@CommandPermission("simpleclans.leader.rank.unassign")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Description("{@@command.description.rank.unassign}")
|
||||
public void unassign(Player player, @Conditions("same_clan") @Name("member") ClanPlayerInput cp) {
|
||||
ClanPlayer cpInput = cp.getClanPlayer();
|
||||
cpInput.setRank(null);
|
||||
storage.updateClanPlayer(cpInput);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("player.unassigned.from.rank", player));
|
||||
}
|
||||
|
||||
@Subcommand("%create")
|
||||
@CommandPermission("simpleclans.leader.rank.create")
|
||||
@Description("{@@command.description.rank.create}")
|
||||
public void create(Player player, Clan clan) {
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateRankNamePrompt())
|
||||
.withLocalEcho(true).buildConversation(player);
|
||||
conversation.getContext().setSessionData("clan", clan);
|
||||
conversation.begin();
|
||||
}
|
||||
|
||||
@Subcommand("%delete")
|
||||
@CommandPermission("simpleclans.leader.rank.delete")
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.delete}")
|
||||
public void delete(Player player, Clan clan, @Name("rank") Rank rank) {
|
||||
clan.deleteRank(rank.getName());
|
||||
storage.updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.deleted", player, rank.getDisplayName()));
|
||||
}
|
||||
|
||||
@Subcommand("%list")
|
||||
@CommandPermission("simpleclans.leader.rank.list")
|
||||
@Description("{@@command.description.rank.list}")
|
||||
public void list(Player player, Clan clan) {
|
||||
List<Rank> ranks = clan.getRanks();
|
||||
|
||||
if (ranks.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("no.ranks", player));
|
||||
return;
|
||||
}
|
||||
|
||||
ranks.sort(Comparator.reverseOrder());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("clans.ranks", player));
|
||||
int count = 1;
|
||||
for (Rank rank : ranks) {
|
||||
ChatBlock.sendMessage(player, AQUA + lang("ranks.list.item", player, count,
|
||||
Helper.parseColors(rank.getDisplayName()) + AQUA, rank.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%setdisplayname")
|
||||
@CommandPermission("simpleclans.leader.rank.setdisplayname")
|
||||
@CommandCompletion("@ranks @nothing")
|
||||
@Description("{@@command.description.rank.setdisplayname}")
|
||||
public void setDisplayName(Player player, Clan clan, @Name("rank") Rank rank, @Name("displayname") String displayName) {
|
||||
if (displayName.contains("&") && !permissions.has(player, "simpleclans.leader.coloredrank")) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.cannot.set.colored.ranks", player));
|
||||
return;
|
||||
}
|
||||
rank.setDisplayName(displayName);
|
||||
storage.updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("rank.displayname.updated", player));
|
||||
}
|
||||
|
||||
@Subcommand("%permissions")
|
||||
public class PermissionsCommand extends BaseCommand {
|
||||
private final String validPermissionsToMessage = Helper.toMessage(Helper.fromPermissionArray(), ",");
|
||||
|
||||
@Default
|
||||
@CommandPermission("simpleclans.leader.rank.permissions.available")
|
||||
@Description("{@@command.description.rank.permissions.available}")
|
||||
public void availablePermissions(Player player) {
|
||||
ChatBlock.sendMessage(player, AQUA + lang("available.rank.permissions", player));
|
||||
ChatBlock.sendMessage(player, AQUA + validPermissionsToMessage);
|
||||
}
|
||||
|
||||
@Default
|
||||
@CommandPermission("simpleclans.leader.rank.permissions.list")
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.permissions.rank}")
|
||||
public void list(Player player, @Name("rank") Rank rank) {
|
||||
Set<String> permissions = rank.getPermissions();
|
||||
if (permissions.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("rank.no.permissions", player));
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.permissions", player, rank.getDisplayName()));
|
||||
ChatBlock.sendMessage(player, AQUA + Helper.toMessage(permissions.toArray(new String[0]), ","));
|
||||
}
|
||||
|
||||
@Subcommand("%add")
|
||||
@CommandPermission("simpleclans.leader.rank.permissions.add")
|
||||
@CommandCompletion("@ranks @rank_permissions")
|
||||
@Description("{@@command.description.rank.permissions.add}")
|
||||
public void add(Player player,
|
||||
Clan clan,
|
||||
@Name("rank") Rank rank,
|
||||
@Values("@rank_permissions") @Name("permission") String permission) {
|
||||
Set<String> permissions = rank.getPermissions();
|
||||
permissions.add(permission);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("permission.0.added.to.rank.1", player, permission,
|
||||
rank.getDisplayName()));
|
||||
storage.updateClan(clan, true);
|
||||
}
|
||||
|
||||
@Subcommand("%remove")
|
||||
@CommandCompletion("@ranks @rank_permissions")
|
||||
@CommandPermission("simpleclans.leader.rank.permissions.remove")
|
||||
@Description("{@@command.description.rank.permissions.remove}")
|
||||
public void remove(Player player,
|
||||
Clan clan,
|
||||
@Name("rank") Rank rank,
|
||||
@Values("@rank_permissions") @Name("permission") String permission) {
|
||||
Set<String> permissions = rank.getPermissions();
|
||||
permissions.remove(permission);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("permission.0.removed.from.rank.1", player,
|
||||
permission, rank.getDisplayName()));
|
||||
storage.updateClan(clan, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%toggle")
|
||||
@Conditions("%basic_conditions|verified")
|
||||
public class ToggleCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
|
||||
@Subcommand("%bb")
|
||||
@CommandPermission("simpleclans.member.bb-toggle")
|
||||
@Description("{@@command.description.toggle.bb}")
|
||||
public void bb(Player player, ClanPlayer cp) {
|
||||
toggle(player, "bbon", "bboff", cp.isBbEnabled(), cp::setBbEnabled);
|
||||
|
||||
storage.updateClanPlayer(cp);
|
||||
}
|
||||
|
||||
@Subcommand("%tag")
|
||||
@CommandPermission("simpleclans.member.tag-toggle")
|
||||
@Description("{@@command.description.toggle.tag}")
|
||||
public void tag(Player player, ClanPlayer cp) {
|
||||
toggle(player, "tagon", "tagoff", cp.isTagEnabled(), cp::setTagEnabled);
|
||||
|
||||
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,
|
||||
Consumer<Boolean> consumer) {
|
||||
String messageOn = AQUA + lang(onMessageKey, sender);
|
||||
String messageOff = AQUA + lang(offMessageKey, sender);
|
||||
|
||||
ChatBlock.sendMessage(sender, status ? messageOff : messageOn);
|
||||
consumer.accept(!status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.CommandCompletions.AsyncCommandCompletionHandler;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractAsyncCompletion extends AbstractCompletion
|
||||
implements AsyncCommandCompletionHandler<BukkitCommandCompletionContext> {
|
||||
public AbstractAsyncCompletion(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractCompletion implements IdentifiableCompletion {
|
||||
|
||||
protected final SimpleClans plugin;
|
||||
protected final ClanManager clanManager;
|
||||
|
||||
public AbstractCompletion(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
this.clanManager = plugin.getClanManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class AbstractStaticCompletion extends AbstractCompletion {
|
||||
|
||||
public AbstractStaticCompletion(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract Collection<String> getCompletions();
|
||||
|
||||
}
|
||||