mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-05 01:10:04 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae09353ab4 | ||
|
|
2ba027f89a | ||
|
|
d2ed8ac366 | ||
|
|
f2ba4b8a5c | ||
|
|
2bfc37d780 | ||
|
|
3e4a744fc3 | ||
|
|
f203554a64 | ||
|
|
b5f81ccf79 | ||
|
|
1ee1c288bd | ||
|
|
03b95bbedf | ||
|
|
37ea6fe665 | ||
|
|
598e420fa6 | ||
|
|
68065a3b79 | ||
|
|
6e255fc7cb | ||
|
|
36a3d3732a | ||
|
|
934263063e | ||
|
|
2c39603da9 | ||
|
|
6dddc64a95 | ||
|
|
82f94d1149 | ||
|
|
b4fbcdd0de | ||
|
|
3db5a71bbe | ||
|
|
ae86f5b68f | ||
|
|
1ca26319db | ||
|
|
0bb9fd5b53 | ||
|
|
c548f7749e | ||
|
|
888366ce27 | ||
|
|
dc7d414393 | ||
|
|
f5c0920cc9 | ||
|
|
fe866d959a | ||
|
|
6083766a12 | ||
|
|
14b663801d | ||
|
|
b331e2c236 | ||
|
|
b3d5be1ec0 | ||
|
|
b6d9c3a605 | ||
|
|
e2c7b109d9 | ||
|
|
6bb370facd | ||
|
|
b3c8131c96 | ||
|
|
d4c9537296 | ||
|
|
f89d446ac0 | ||
|
|
009564f732 | ||
|
|
a6e10da510 | ||
|
|
a9fe589794 | ||
|
|
2d0b524557 | ||
|
|
ba66f16f54 | ||
|
|
4d6a489b43 | ||
|
|
92da40ca76 | ||
|
|
f1d0741ac8 | ||
|
|
03b2f73e74 | ||
|
|
2a65295e8b | ||
|
|
a7cb9ed171 | ||
|
|
ac0a387198 | ||
|
|
e3cd7d37a8 | ||
|
|
63595258f4 | ||
|
|
0c866044df | ||
|
|
2217efa8a7 | ||
|
|
df97e43c4d | ||
|
|
169b44e793 | ||
|
|
f2303c5336 | ||
|
|
af8cd133c2 | ||
|
|
fa66424402 | ||
|
|
2727203bed | ||
|
|
eedc743d5b | ||
|
|
4e12e4d6f5 | ||
|
|
32855c2611 | ||
|
|
d7118aea82 | ||
|
|
f472432eb6 | ||
|
|
e07c8a9343 | ||
|
|
b84e46d156 | ||
|
|
daba767a5a | ||
|
|
e59a760776 | ||
|
|
6aa30a5d2d | ||
|
|
9fe944fe5b | ||
|
|
178382e685 | ||
|
|
2fcc765447 | ||
|
|
6d5dc79568 | ||
|
|
29c8955f9d | ||
|
|
62f69e0a1e | ||
|
|
3518024428 | ||
|
|
ad7f6fd402 | ||
|
|
732932763d | ||
|
|
6440e937bc | ||
|
|
72ffaaa7fe | ||
|
|
9b69020677 | ||
|
|
50d25bb881 | ||
|
|
5fc0477e9f | ||
|
|
10482ecf23 | ||
|
|
00158a3e3c | ||
|
|
96d65c2d8f | ||
|
|
4036b13bad | ||
|
|
2abe64284b | ||
|
|
1b62ecf296 | ||
|
|
c59afd27b3 | ||
|
|
fecc50c083 | ||
|
|
230a0e9ba5 | ||
|
|
9f96f8c19f | ||
|
|
1b16fd3b2b | ||
|
|
4e5461b533 | ||
|
|
70f4a4a109 | ||
|
|
ae3ebee649 | ||
|
|
235a69cf15 | ||
|
|
2c18498f08 | ||
|
|
2ac4085915 | ||
|
|
9b5e727fed | ||
|
|
dcf1659e6b | ||
|
|
d64190cc8f | ||
|
|
dc1c417222 | ||
|
|
3872790c25 | ||
|
|
da1894e55d | ||
|
|
63763e9afd | ||
|
|
756a30303e |
No files matched your search
@@ -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.
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
/target/
|
||||
/.idea/
|
||||
SimpleClans.iml
|
||||
SimpleClans.iml
|
||||
/bin/
|
||||
/.classpath
|
||||
/.project
|
||||
/dependency-reduced-pom.xml
|
||||
/simpleclans-mc1.8.iml
|
||||
+1
-1
@@ -5,7 +5,7 @@ language: java
|
||||
|
||||
script: mvn install
|
||||
|
||||
jdk: [openjdk7]
|
||||
jdk: [openjdk8]
|
||||
|
||||
# if one build failed, exit testing
|
||||
matrix:
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
SimpleClans
|
||||
==========
|
||||
|
||||
Full featured clan system for PVP Minecraft Servers
|
||||
|
||||
[](https://travis-ci.org/marcelo-mason/SimpleClans)
|
||||
[](http://104.236.246.108:8080/job/SimpleClans/)
|
||||
[](https://github.com/marcelo-mason/SimpleClans/issues)
|
||||
[](https://ghit.me/repo/marcelo-mason/SimpleClans)
|
||||
|
||||
## 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.
|
||||
|
||||
Pull-requests for bug fixes or new features are welcomed and will be merged in if they do not break existing functionalities.
|
||||
SimpleClans
|
||||
==========
|
||||
|
||||
Full featured clan system for PVP Minecraft Servers
|
||||
|
||||
[](https://github.com/marcelo-mason/SimpleClans/actions?query=workflow%3A%22Maven+Package%22)
|
||||
[](https://github.com/marcelo-mason/SimpleClans/packages)
|
||||
[](https://github.com/RoinujNosde/SimpleClans/issues)
|
||||
[](https://crowdin.com/project/simpleclans)
|
||||
|
||||
Spigot resource page: https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
|
||||
Discord support server: https://discord.gg/CkNwgdE
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<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" />
|
||||
<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: commons-lang:commons-lang:2.6" 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" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.7.12</version>
|
||||
<version>2.12.2</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>language.yml</include>
|
||||
<include>language-br.yml</include>
|
||||
<include>language-zh.yml</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@@ -33,8 +31,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
@@ -54,39 +52,88 @@
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
|
||||
<!-- 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>
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- Dependencies -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<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.6</version>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Repositories -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<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>
|
||||
</repositories>
|
||||
|
||||
<!-- GitHub/Jenkins -->
|
||||
@@ -111,14 +158,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>
|
||||
@@ -19,11 +19,23 @@ public class ChatBlock {
|
||||
private final ArrayList<String> columnAlignments = new ArrayList<>();
|
||||
private final LinkedList<String[]> rows = new LinkedList<>();
|
||||
private String color = "";
|
||||
private boolean cropRight = true;
|
||||
private boolean padRight = true;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final Logger LOG = Logger.getLogger("Minecraft");
|
||||
|
||||
|
||||
public void setCropRight(boolean cropRight) {
|
||||
this.cropRight = cropRight;
|
||||
}
|
||||
|
||||
public void setPadRight(boolean padRight) {
|
||||
this.padRight = padRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columnAlignment
|
||||
*/
|
||||
@@ -182,15 +194,27 @@ public class ChatBlock {
|
||||
}
|
||||
} else if (align.equalsIgnoreCase("l")) {
|
||||
if (msgLength(section) > colsize) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
if (cropRight) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
} else if (msgLength(section) < colsize) {
|
||||
col = paddRightToFit(section, colsize);
|
||||
if (padRight) {
|
||||
col = paddRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
}
|
||||
} else if (align.equalsIgnoreCase("c")) {
|
||||
if (msgLength(section) > colsize) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
if (cropRight) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
} else if (msgLength(section) < colsize) {
|
||||
col = centerInLineOf(section, colsize);
|
||||
col = centerInLineOf(section, colsize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,9 +277,10 @@ public class ChatBlock {
|
||||
}
|
||||
|
||||
// crop and print out
|
||||
|
||||
String msg = cropRightToFit((prefix_used ? empty_prefix : prefix + " ") + finalString, LINE_LENGTH);
|
||||
|
||||
String msg = (prefix_used ? empty_prefix : prefix + " ") + finalString;
|
||||
if (cropRight) {
|
||||
msg = cropRightToFit(msg, LINE_LENGTH);
|
||||
}
|
||||
if (color.length() > 0) {
|
||||
msg = color + msg;
|
||||
}
|
||||
@@ -638,6 +663,10 @@ public class ChatBlock {
|
||||
public static String[] say(String message) {
|
||||
return colorize(wordWrap(message));
|
||||
}
|
||||
|
||||
public static String[] getColorizedMessage(String msg) {
|
||||
return colorize(wordWrap(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
@@ -697,4 +726,4 @@ public class ChatBlock {
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
|
||||
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.json.simple.JSONArray;
|
||||
@@ -15,6 +19,7 @@ import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -26,7 +31,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private String tag;
|
||||
private String colorTag;
|
||||
private String name;
|
||||
private String description;
|
||||
private double balance;
|
||||
private double fee;
|
||||
private boolean friendlyFire;
|
||||
private long founded;
|
||||
private long lastUsed;
|
||||
@@ -42,6 +49,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private String homeWorld = "";
|
||||
private boolean allowWithdraw = false;
|
||||
private boolean allowDeposit = true;
|
||||
private boolean feeEnabled;
|
||||
private List<Rank> ranks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -152,7 +161,46 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clan's description
|
||||
*
|
||||
* @return the description or null if it doesn't have one
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the clan's fee
|
||||
*
|
||||
* @param fee
|
||||
*/
|
||||
public void setMemberFee(double fee) {
|
||||
if (fee < 0) {
|
||||
fee = 0;
|
||||
}
|
||||
this.fee = fee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clan's fee
|
||||
*
|
||||
* @return the fee
|
||||
*/
|
||||
public double getMemberFee() {
|
||||
return fee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clan's balance
|
||||
*
|
||||
@@ -249,31 +297,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return confirmation
|
||||
*/
|
||||
public boolean isMember(Player player) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return this.members.contains(player.getUniqueId().toString());
|
||||
} else {
|
||||
return this.members.contains(player.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player is a member of this clan
|
||||
*
|
||||
* @param playerName
|
||||
* @return confirmation
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isMember(String playerName) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID PlayerUniqueId = UUIDMigration.getForcedPlayerUUID(playerName);
|
||||
if (PlayerUniqueId != null) {
|
||||
return this.members.contains(PlayerUniqueId.toString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return this.members.contains(playerName.toLowerCase());
|
||||
}
|
||||
return this.members.contains(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,27 +393,33 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param msg
|
||||
*/
|
||||
public void addBb(String msg) {
|
||||
addBbWithoutSaving(msg);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a bulletin board message without saving it to the database
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void addBbWithoutSaving(String msg) {
|
||||
while (bb.size() > SimpleClans.getInstance().getSettingsManager().getBbSize()) {
|
||||
bb.remove(0);
|
||||
}
|
||||
|
||||
bb.add(msg);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
bb.add(System.currentTimeMillis() + "_" + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bulletin board message without announcer
|
||||
* Adds a bulletin board message without announcer and saves it to the database
|
||||
*
|
||||
* @param msg
|
||||
*
|
||||
* @param updateLastUsed should the clan's last used time be updated as well?
|
||||
*/
|
||||
public void addBb(String msg, boolean updateLastUsed) {
|
||||
while (bb.size() > SimpleClans.getInstance().getSettingsManager().getBbSize()) {
|
||||
bb.remove(0);
|
||||
}
|
||||
|
||||
bb.add(msg);
|
||||
addBbWithoutSaving(msg);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this, updateLastUsed);
|
||||
}
|
||||
|
||||
@@ -407,35 +437,15 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param cp
|
||||
*/
|
||||
public void importMember(ClanPlayer cp) {
|
||||
String NameOrUUID;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
if (cp.getUniqueId() != null) {
|
||||
NameOrUUID = cp.getUniqueId().toString();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
NameOrUUID = cp.getCleanName();
|
||||
}
|
||||
if (!this.members.contains(NameOrUUID)) {
|
||||
this.members.add(NameOrUUID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param playerName
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeMember(String playerName) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID PlayerUniqueId = UUIDMigration.getForcedPlayerUUID(playerName);
|
||||
if (PlayerUniqueId != null) {
|
||||
this.members.remove(PlayerUniqueId.toString());
|
||||
}
|
||||
} else {
|
||||
this.members.remove(playerName.toLowerCase());
|
||||
String uuid;
|
||||
if (cp.getUniqueId() != null) {
|
||||
uuid = cp.getUniqueId().toString();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.members.contains(uuid)) {
|
||||
this.members.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,12 +671,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
String out = "";
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -686,31 +691,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return the leaders
|
||||
*/
|
||||
public boolean isLeader(Player player) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return isLeader(player.getUniqueId());
|
||||
} else {
|
||||
return isLeader(player.getName());
|
||||
}
|
||||
return isLeader(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is a leader of a clan
|
||||
*
|
||||
* @param playerName
|
||||
* @return the leaders
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isLeader(String playerName) {
|
||||
if (isMember(playerName)) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerName.toLowerCase());
|
||||
|
||||
if (cp != null && cp.isLeader()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is a leader of a clan
|
||||
@@ -730,6 +713,24 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all members that must pay the fee (that excludes leaders and players with the permission to bypass it)
|
||||
*
|
||||
* @return the fee payers
|
||||
*/
|
||||
public Set<ClanPlayer> getFeePayers() {
|
||||
Set<ClanPlayer> feePayers = new HashSet<>();
|
||||
|
||||
getNonLeaders().forEach(cp -> {
|
||||
OfflinePlayer op= Bukkit.getOfflinePlayer(cp.getUniqueId());
|
||||
if (!SimpleClans.getInstance().getPermissionsManager().has(null, op, "simpleclans.member.bypass-fee")) {
|
||||
feePayers.add(cp);
|
||||
}
|
||||
});
|
||||
|
||||
return feePayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all members (leaders, and non-leaders) in the clan
|
||||
*
|
||||
@@ -739,12 +740,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -763,12 +759,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -789,12 +780,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -816,12 +802,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -845,12 +826,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -896,12 +872,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
int totalDeaths = 0;
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -930,12 +901,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -959,12 +925,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -988,12 +949,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -1017,12 +973,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -1046,12 +997,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
} else {
|
||||
cp = SimpleClans.getInstance().getClanManager().getClanPlayer(member.toLowerCase());
|
||||
}
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -1095,13 +1041,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
// add clan permission
|
||||
SimpleClans.getInstance().getPermissionsManager().addClanPermissions(cp);
|
||||
SimpleClans.getInstance().getPermissionsManager().addPlayerPermissions(cp);
|
||||
|
||||
Player player;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
player = SimpleClans.getInstance().getServer().getPlayer(cp.getUniqueId());
|
||||
} else {
|
||||
player = SimpleClans.getInstance().getServer().getPlayerExact(cp.getName());
|
||||
}
|
||||
Player player = SimpleClans.getInstance().getServer().getPlayer(cp.getUniqueId());
|
||||
|
||||
if (player != null) {
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(player);
|
||||
@@ -1109,39 +1051,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerJoinedClanEvent(this, cp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a clan
|
||||
*
|
||||
* @param playerName
|
||||
*/
|
||||
@Deprecated
|
||||
public void removePlayerFromClan(String playerName) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerName);
|
||||
|
||||
// remove clan group-permission
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPermissions(cp);
|
||||
|
||||
// remove permissions
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPlayerPermissions(cp);
|
||||
|
||||
cp.setClan(null);
|
||||
cp.addPastClan(getColorTag() + (cp.isLeader() ? ChatColor.DARK_RED + "*" : ""));
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(false);
|
||||
cp.setJoinDate(0);
|
||||
removeMember(playerName);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(cp);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
|
||||
Player matched = cp.toPlayer();
|
||||
|
||||
if (matched != null) {
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(matched);
|
||||
}
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerKickedClanEvent(this, cp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a clan
|
||||
*
|
||||
@@ -1161,6 +1070,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(false);
|
||||
cp.setJoinDate(0);
|
||||
cp.setRank(null);
|
||||
removeMember(playerUniqueId);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(cp);
|
||||
@@ -1174,27 +1084,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerKickedClanEvent(this, cp));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Promote a member to a leader of a clan
|
||||
*
|
||||
* @param playerName
|
||||
*/
|
||||
@Deprecated
|
||||
public void promote(String playerName) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerName);
|
||||
|
||||
cp.setLeader(true);
|
||||
cp.setTrusted(true);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(cp);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
|
||||
// add clan permission
|
||||
SimpleClans.getInstance().getPermissionsManager().addClanPermissions(cp);
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerPromoteEvent(this, cp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Promote a member to a leader of a clan
|
||||
*
|
||||
@@ -1214,25 +1103,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerPromoteEvent(this, cp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Demote a leader back to a member of a clan
|
||||
*
|
||||
* @param playerName
|
||||
*/
|
||||
@Deprecated
|
||||
public void demote(String playerName) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerName);
|
||||
|
||||
cp.setLeader(false);
|
||||
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(cp);
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
|
||||
// add clan permission
|
||||
SimpleClans.getInstance().getPermissionsManager().addClanPermissions(cp);
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new PlayerDemoteEvent(this, cp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Demote a leader back to a member of a clan
|
||||
*
|
||||
@@ -1327,21 +1197,43 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @return
|
||||
*/
|
||||
public boolean isAnyOnline() {
|
||||
for (String member : members) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
if (Helper.isOnline(UUID.fromString(member))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Helper.isOnline(member)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String member : members) {
|
||||
if (Helper.isOnline(UUID.fromString(member))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough leaders online to vote
|
||||
*
|
||||
* @param cp the one to demote
|
||||
* @return true if there are
|
||||
*/
|
||||
public boolean enoughLeadersOnlineToDemote(ClanPlayer cp) {
|
||||
List<ClanPlayer> online = getOnlineLeaders();
|
||||
online.remove(cp);
|
||||
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercentageOnlineToDemote();
|
||||
// all leaders minus the one being demoted
|
||||
double totalLeaders = getLeaders().size() - 1;
|
||||
double onlineLeaders = online.size();
|
||||
|
||||
|
||||
return ((onlineLeaders / totalLeaders) * 100) >= minimum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the online leaders
|
||||
*
|
||||
* @return the online leaders
|
||||
*/
|
||||
public List<ClanPlayer> getOnlineLeaders() {
|
||||
return getOnlineMembers().stream().filter(ClanPlayer::isLeader).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether all leaders of a clan are online
|
||||
*
|
||||
@@ -1350,17 +1242,11 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public boolean allLeadersOnline() {
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
|
||||
for (ClanPlayer leader : leaders) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Helper.isOnline(leader.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ClanPlayer leader : leaders) {
|
||||
if (!Helper.isOnline(leader.getUniqueId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1495,7 +1381,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, MessageFormat.format(SimpleClans.getInstance().getLang("bulletin.board.header"), SimpleClans.getInstance().getSettingsManager().getBbAccentColor(), SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor(), getName()));
|
||||
|
||||
int maxSize = SimpleClans.getInstance().getSettingsManager().getBbSize();
|
||||
|
||||
@@ -1504,12 +1390,72 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
for (String msg : bb) {
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
if (!sendBbTime(player, msg)) {
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
}
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays bb to a player
|
||||
* @implNote may want to refactor displaybb(Player) to use this?
|
||||
*
|
||||
* @param player
|
||||
* @param maxSize amount of lines to display
|
||||
*/
|
||||
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(), getName()));
|
||||
|
||||
List<String> localBb = new ArrayList<>(bb);
|
||||
while (localBb.size() > maxSize) {
|
||||
localBb.remove(0);
|
||||
}
|
||||
|
||||
for (String msg : localBb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
}
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a bb message with the timestamp in a hover message, if the bb message is timestamped
|
||||
* @param msg the bb message
|
||||
* @return true if sent
|
||||
*/
|
||||
private boolean sendBbTime(Player player, String msg) {
|
||||
try {
|
||||
int index = msg.indexOf("_");
|
||||
if (index < 1)
|
||||
return false;
|
||||
long time;
|
||||
time = (System.currentTimeMillis()
|
||||
- Long.parseLong(msg.substring(0, index))) / 1000L;
|
||||
msg = String.join("", ChatBlock
|
||||
.getColorizedMessage(SimpleClans.getInstance()
|
||||
.getSettingsManager().getBbAccentColor() + "* " +
|
||||
SimpleClans.getInstance().getSettingsManager()
|
||||
.getBbColor() + Helper.parseColors(
|
||||
msg.substring(++index, msg.length()))));
|
||||
TextComponent textComponent = new TextComponent(msg);
|
||||
textComponent.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(
|
||||
Dates.formatTime(time, 1) + SimpleClans
|
||||
.getInstance().getLang("bb.ago"))));
|
||||
player.spigot().sendMessage(textComponent);
|
||||
return true;
|
||||
} catch (Throwable rock) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband a clan
|
||||
*/
|
||||
@@ -1537,15 +1483,15 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
String disbanded = SimpleClans.getInstance().getLang("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(SimpleClans.getInstance().getLang("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(SimpleClans.getInstance().getLang("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(SimpleClans.getInstance().getLang("has.been.disbanded.alliance.ended"), getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1633,7 +1579,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the flags
|
||||
*/
|
||||
public String getFlags() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public String getFlags() {
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
// writing the list of flags to json
|
||||
@@ -1703,8 +1650,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
public void validateWarring() {
|
||||
for (Iterator iter = warringClans.keySet().iterator(); iter.hasNext(); ) {
|
||||
String clanName = (String) iter.next();
|
||||
for (Iterator<String> iter = warringClans.keySet().iterator(); iter.hasNext(); ) {
|
||||
String clanName = iter.next();
|
||||
|
||||
Clan clan = SimpleClans.getInstance().getClanManager().getClan(clanName);
|
||||
|
||||
@@ -1776,6 +1723,24 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the fee is enabled
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isMemberFeeEnabled() {
|
||||
return feeEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the fee
|
||||
*
|
||||
* @param enable
|
||||
*/
|
||||
public void setMemberFeeEnabled(boolean enable) {
|
||||
feeEnabled = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the allowWithdraw
|
||||
*/
|
||||
@@ -1803,4 +1768,79 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void setAllowDeposit(boolean allowDeposit) {
|
||||
this.allowDeposit = allowDeposit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the clan has the specified rank
|
||||
*
|
||||
* @param name the rank
|
||||
* @return
|
||||
*/
|
||||
public boolean hasRank(String name) {
|
||||
return getRank(name) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a rank
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void createRank(String name) {
|
||||
ranks.add(new Rank(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clan's ranks
|
||||
*
|
||||
* @return the ranks
|
||||
*/
|
||||
public List<Rank> getRanks() {
|
||||
return ranks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the clan's ranks
|
||||
*
|
||||
* @param ranks
|
||||
*/
|
||||
public void setRanks(List<Rank> ranks) {
|
||||
if (ranks == null) {
|
||||
ranks = new ArrayList<>();
|
||||
}
|
||||
this.ranks = ranks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a rank with the specified name
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void deleteRank(String name) {
|
||||
Rank r = getRank(name);
|
||||
if (r != null) {
|
||||
ranks.remove(r);
|
||||
getMembers().forEach(cp -> {
|
||||
if (cp.getRankId().equals(r.getName())) {
|
||||
cp.setRank("");
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a rank with the specified name or null if not found
|
||||
*
|
||||
* @param name the rank name
|
||||
* @return a rank or null
|
||||
*/
|
||||
public Rank getRank(String name) {
|
||||
if (name != null) {
|
||||
for (Rank r : ranks) {
|
||||
if (r.getName().equals(name)) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import org.json.simple.JSONValue;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -32,6 +34,7 @@ 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;
|
||||
|
||||
@@ -116,15 +119,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClanPlayer other)
|
||||
{
|
||||
if (SimpleClans.getInstance().hasUUID())
|
||||
{
|
||||
return this.getUniqueId().compareTo(other.getUniqueId());
|
||||
} else
|
||||
{
|
||||
return this.getName().compareToIgnoreCase(other.getName());
|
||||
}
|
||||
public int compareTo(ClanPlayer other) {
|
||||
return this.getUniqueId().compareTo(other.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -329,6 +325,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Adds one rival kill to this player (does not update clanplayer to db)
|
||||
*/
|
||||
@Deprecated
|
||||
public void addRivalKill()
|
||||
{
|
||||
setRivalKills(getRivalKills() + 1);
|
||||
@@ -357,6 +354,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Adds one civilian kill to this player (does not update clanplayer to db)
|
||||
*/
|
||||
@Deprecated
|
||||
public void addCivilianKill()
|
||||
{
|
||||
setCivilianKills(getCivilianKills() + 1);
|
||||
@@ -385,10 +383,27 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Adds one civilian kill to this player (does not update clanplayer to db)
|
||||
*/
|
||||
@Deprecated
|
||||
public void addNeutralKill()
|
||||
{
|
||||
setNeutralKills(getNeutralKills() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one kill to this player (does not update to db)
|
||||
*/
|
||||
public void addKill(Kill.Type type) {
|
||||
switch (type) {
|
||||
case CIVILIAN:
|
||||
civilianKills++;
|
||||
break;
|
||||
case NEUTRAL:
|
||||
neutralKills++;
|
||||
break;
|
||||
case RIVAL:
|
||||
rivalKills++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this player is allowing friendly fire
|
||||
@@ -528,6 +543,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*/
|
||||
public String getLastSeenString()
|
||||
{
|
||||
if (toPlayer() != null) {
|
||||
return SimpleClans.getInstance().getLang("online");
|
||||
}
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.lastSeen));
|
||||
}
|
||||
|
||||
@@ -628,6 +646,51 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
// return pc;
|
||||
return pastClans;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map containing the time the player resigned from certain clans
|
||||
*
|
||||
* @return the resign times
|
||||
*/
|
||||
public Map<String, Long> getResignTimes() {
|
||||
return resignTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time in millis when the player resigned from the clan
|
||||
*
|
||||
* @param tag
|
||||
* @return the time in millis
|
||||
*/
|
||||
public Long getResignTime(String tag) {
|
||||
return resignTimes.get(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resign times (does not update to db)
|
||||
*
|
||||
* @param resignTimes
|
||||
*/
|
||||
public void setResignTimes(Map<String, Long> resignTimes) {
|
||||
if (resignTimes != null) {
|
||||
final int cooldown = SimpleClans.getInstance().getSettingsManager().getRejoinCooldown();
|
||||
resignTimes.forEach((k, v) -> {
|
||||
long timePassed = Instant.ofEpochMilli(v).until(Instant.now(), ChronoUnit.MINUTES);
|
||||
if (timePassed < cooldown) {
|
||||
this.resignTimes.put(k, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the clan to the resign times map
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
public void addResignTime(String tag) {
|
||||
if (tag != null) resignTimes.put(tag, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this player's clan
|
||||
@@ -708,7 +771,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the flags
|
||||
*/
|
||||
public String getFlags()
|
||||
@SuppressWarnings("unchecked")
|
||||
public String getFlags()
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
@@ -916,13 +980,46 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
return useChatShortcut;
|
||||
}
|
||||
|
||||
public String getRankDisplayName() {
|
||||
if (clan != null) {
|
||||
Rank r = clan.getRank(rank);
|
||||
if (r != null) {
|
||||
return r.getDisplayName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rank id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRankId() {
|
||||
return rank;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rank displayname
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public String getRank()
|
||||
{
|
||||
return rank;
|
||||
return getRankDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rank id
|
||||
*
|
||||
* @param rank the rank id
|
||||
*/
|
||||
public void setRank(String rank)
|
||||
{
|
||||
if (rank == null) {
|
||||
rank = "";
|
||||
}
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,138 +1,192 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
|
||||
public class Dates {
|
||||
|
||||
private Dates() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMonths(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMonths(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInYears(Timestamp date1, Timestamp date2) {
|
||||
return differenceInYears(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInDays(Timestamp date1, Timestamp date2) {
|
||||
return differenceInDays(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInHours(Timestamp date1, Timestamp date2) {
|
||||
return differenceInHours(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMinutes(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMinutes(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInSeconds(Timestamp date1, Timestamp date2) {
|
||||
return differenceInSeconds(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
private static double differenceInMilliseconds(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMilliseconds(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMonths(Date date1, Date date2) {
|
||||
return differenceInYears(date1, date2) * 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInYears(Date date1, Date date2) {
|
||||
double days = differenceInDays(date1, date2);
|
||||
return days / 365.2425;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInDays(Date date1, Date date2) {
|
||||
return differenceInHours(date1, date2) / 24.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInHours(Date date1, Date date2) {
|
||||
return differenceInMinutes(date1, date2) / 60.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMinutes(Date date1, Date date2) {
|
||||
return differenceInSeconds(date1, date2) / 60.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInSeconds(Date date1, Date date2) {
|
||||
return differenceInMilliseconds(date1, date2) / 1000.0;
|
||||
}
|
||||
|
||||
private static double differenceInMilliseconds(Date date1, Date date2) {
|
||||
return Math.abs(getTimeInMilliseconds(date1) - getTimeInMilliseconds(date2));
|
||||
}
|
||||
|
||||
private static long getTimeInMilliseconds(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
return cal.getTimeInMillis() + cal.getTimeZone().getOffset(cal.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
|
||||
public class Dates {
|
||||
|
||||
private Dates() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMonths(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMonths(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInYears(Timestamp date1, Timestamp date2) {
|
||||
return differenceInYears(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInDays(Timestamp date1, Timestamp date2) {
|
||||
return differenceInDays(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInHours(Timestamp date1, Timestamp date2) {
|
||||
return differenceInHours(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMinutes(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMinutes(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInSeconds(Timestamp date1, Timestamp date2) {
|
||||
return differenceInSeconds(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMonths(Date date1, Date date2) {
|
||||
return differenceInYears(date1, date2) * 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInYears(Date date1, Date date2) {
|
||||
double days = differenceInDays(date1, date2);
|
||||
return days / 365.2425;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInDays(Date date1, Date date2) {
|
||||
return differenceInHours(date1, date2) / 24.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInHours(Date date1, Date date2) {
|
||||
return differenceInMinutes(date1, date2) / 60.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMinutes(Date date1, Date date2) {
|
||||
return differenceInSeconds(date1, date2) / 60.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInSeconds(Date date1, Date date2) {
|
||||
return differenceInMilliseconds(date1, date2) / 1000.0;
|
||||
}
|
||||
|
||||
private static double differenceInMilliseconds(Date date1, Date date2) {
|
||||
return Math.abs(getTimeInMilliseconds(date1) - getTimeInMilliseconds(date2));
|
||||
}
|
||||
|
||||
private static long getTimeInMilliseconds(Date date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
return cal.getTimeInMillis() + cal.getTimeZone().getOffset(cal.getTimeInMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of the amount of time labeled as days, hours, minutes, seconds
|
||||
* @author RoboMWM, LaxWasHere
|
||||
* @param seconds the time in seconds
|
||||
* @param depth Max amount of detail (e.g. only display days and hours if set to 1 and seconds > 1 day)
|
||||
* @return
|
||||
*/
|
||||
public static String formatTime(Long seconds, int depth)
|
||||
{
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
if (seconds == null || seconds < 1) {
|
||||
return plugin.getLang("bb.moments");
|
||||
}
|
||||
|
||||
if (seconds < 60) {
|
||||
return seconds + plugin.getLang("bb.seconds");
|
||||
}
|
||||
|
||||
if (seconds < 3600) {
|
||||
Long count = (long) Math.ceil(seconds / 60);
|
||||
String res;
|
||||
if (count > 1) {
|
||||
res = count + plugin.getLang("bb.minutes");
|
||||
} else {
|
||||
res = plugin.getLang("bb.one.minute");
|
||||
}
|
||||
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);
|
||||
String res;
|
||||
if (count > 1) {
|
||||
res = count + plugin.getLang("bb.hours");
|
||||
} else {
|
||||
res = plugin.getLang("bb.one.hour");
|
||||
}
|
||||
if (depth > 0) {
|
||||
return res + ", " + formatTime(seconds % 3600, --depth);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
Long count = (long) Math.ceil(seconds / 86400);
|
||||
String res;
|
||||
if (count > 1) {
|
||||
res = count + plugin.getLang("bb.days");
|
||||
} else {
|
||||
res = plugin.getLang("bb.one.day");
|
||||
}
|
||||
if (depth > 0) {
|
||||
return res + ", " + formatTime(seconds % 86400, --depth);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,22 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.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 java.util.regex.Matcher;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
/**
|
||||
@@ -31,6 +39,142 @@ public class Helper {
|
||||
SimpleClans.debug(el.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatKDR(float kdr) {
|
||||
DecimalFormat formatter = new DecimalFormat("#.#");
|
||||
return formatter.format(kdr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Player locale
|
||||
*
|
||||
* @param player the player
|
||||
* @return the locale
|
||||
*/
|
||||
public static Locale getLocale(Player player) {
|
||||
String lang = player.getLocale();
|
||||
String[] split = lang.split("_");
|
||||
|
||||
if (split.length == 2) {
|
||||
return new Locale(split[0], split[1]);
|
||||
}
|
||||
|
||||
return new Locale(lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JSON String to a list of Ranks
|
||||
*
|
||||
* @param json
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static List<Rank> ranksFromJson(String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
try {
|
||||
JSONObject jo = (JSONObject) new JSONParser().parse(json);
|
||||
Object ranks = jo.get("ranks");
|
||||
if (ranks != null) {
|
||||
JSONArray array = (JSONArray) ranks;
|
||||
List<Rank> rankList = new ArrayList<>();
|
||||
for (Object o : array) {
|
||||
JSONObject r = (JSONObject) o;
|
||||
String name = (String) r.get("name");
|
||||
String displayName = (String) r.get("displayName");
|
||||
Set<String> permissions = new HashSet<>();
|
||||
for (Object p : (JSONArray) r.get("permissions")) {
|
||||
permissions.add((String) p);
|
||||
}
|
||||
Rank rank = new Rank(name, displayName, permissions);
|
||||
rankList.add(rank);
|
||||
}
|
||||
|
||||
return rankList;
|
||||
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of Ranks to a JSON String
|
||||
*
|
||||
* @param ranks
|
||||
* @return a JSON String
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String ranksToJson(List<Rank> ranks) {
|
||||
if (ranks == null)
|
||||
ranks = new ArrayList<Rank>();
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
for (Rank rank : ranks) {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("name", rank.getName());
|
||||
o.put("displayName", rank.getDisplayName());
|
||||
JSONArray permArray = new JSONArray();
|
||||
for (String p : rank.getPermissions()) {
|
||||
permArray.add(p);
|
||||
}
|
||||
o.put("permissions", permArray);
|
||||
array.add(o);
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("ranks", array);
|
||||
return object.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a resign times map to a JSON String
|
||||
*
|
||||
* @param resignTimes
|
||||
* @return a JSON String
|
||||
*/
|
||||
public static String resignTimesToJson(Map<String, Long> resignTimes) {
|
||||
return JSONObject.toJSONString(resignTimes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JSON String to a resign times map
|
||||
*
|
||||
* @param json JSON String
|
||||
* @return a map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Long> resignTimesFromJson(String json) {
|
||||
if (json != null) {
|
||||
try {
|
||||
return (Map<String, Long>) new JSONParser().parse(json);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the delay in seconds to the specified hour and minute.
|
||||
*
|
||||
* @param hour hour
|
||||
* @param minute minute
|
||||
* @return the delay in seconds
|
||||
*/
|
||||
public static long getDelayTo(int hour, int minute) {
|
||||
if (hour < 0 || hour > 23) hour = 1;
|
||||
if (minute < 0 || minute > 59) minute = 0;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime d = LocalDateTime.of(now.toLocalDate(), LocalTime.of(hour, minute));
|
||||
long delay;
|
||||
if (now.isAfter(d)) {
|
||||
delay = now.until(d.plusDays(1), ChronoUnit.SECONDS);
|
||||
} else {
|
||||
delay = now.until(d, ChronoUnit.SECONDS);
|
||||
}
|
||||
return delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a players full color name if he is online
|
||||
@@ -265,6 +409,20 @@ public class Helper {
|
||||
public static String[] toArray(List<String> list) {
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the Permission values array to a String array
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String[] fromPermissionArray() {
|
||||
RankPermission[] permissions = RankPermission.values();
|
||||
String[] sa = new String[permissions.length];
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
sa[i] = permissions[i].toString();
|
||||
}
|
||||
return sa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes first item from a string array
|
||||
@@ -348,9 +506,9 @@ public class Helper {
|
||||
* @return
|
||||
*/
|
||||
public static String stripColors(String msg) {
|
||||
String out = msg.replaceAll("[&][0-9a-f]", "");
|
||||
String out = msg.replaceAll("[&][0-9a-fk-or]", "");
|
||||
out = out.replaceAll(String.valueOf((char) 194), "");
|
||||
return out.replaceAll("[\u00a7][0-9a-f]", "");
|
||||
return out.replaceAll("[\u00a7][0-9a-fk-or]", "");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -405,7 +563,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());
|
||||
@@ -579,7 +737,7 @@ public class Helper {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isVanished(Player player) {
|
||||
if (player != null && player.hasMetadata("vanished") && !player.getMetadata("vanished").isEmpty()) {
|
||||
return player.getMetadata("vanished").get(0).asBoolean();
|
||||
@@ -587,7 +745,8 @@ public class Helper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Collection<Player> getOnlinePlayers() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<Player> getOnlinePlayers() {
|
||||
try {
|
||||
Method method = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
|
||||
Object players = method.invoke(null);
|
||||
@@ -605,11 +764,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
public static Player getPlayer(String playerName) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(UUIDMigration.getForcedPlayerUUID(playerName));
|
||||
}
|
||||
|
||||
return SimpleClans.getInstance().getServer().getPlayer(playerName);
|
||||
return SimpleClans.getInstance().getServer().getPlayer(UUIDMigration.getForcedPlayerUUID(playerName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,25 +780,25 @@ public class Helper {
|
||||
|
||||
String leaderColor = sm.getAllyChatLeaderColor();
|
||||
String memberColor = sm.getAllyChatMemberColor();
|
||||
String rank = cp.getRank().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRank());
|
||||
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getAllyChatRank()).replaceAll("%rank%", rank) : "";
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getAllyChatRank()).replace("%rank%", rank) : "";
|
||||
|
||||
String message = replacePlaceholders(sm, cp, leaderColor, memberColor, rankFormat, msg);
|
||||
String message = replacePlaceholders(sm.getAllyChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
if (placeholders != null) {
|
||||
for (Entry<String, String> e : placeholders.entrySet()) {
|
||||
message = message.replaceAll("%"+e.getKey()+"%", e.getValue());
|
||||
message = message.replace("%"+e.getKey()+"%", e.getValue());
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String replacePlaceholders(SettingsManager sm, ClanPlayer cp, String leaderColor, String memberColor, String rankFormat, String msg) {
|
||||
String message = ChatColor.translateAlternateColorCodes('&', sm.getAllyChatFormat())
|
||||
.replaceAll("%clan%", cp.getClan().getColorTag())
|
||||
.replaceAll("%nick-color%", (cp.isLeader() ? leaderColor : memberColor))
|
||||
.replaceAll("%player%", cp.getName())
|
||||
.replaceAll("%rank%", rankFormat)
|
||||
.replaceAll("%message%", Matcher.quoteReplacement(msg));
|
||||
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())
|
||||
.replace("%nick-color%", (cp.isLeader() ? leaderColor : memberColor))
|
||||
.replace("%player%", cp.getName())
|
||||
.replace("%rank%", rankFormat)
|
||||
.replace("%message%", msg);
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -660,14 +815,14 @@ public class Helper {
|
||||
|
||||
String leaderColor = sm.getClanChatLeaderColor();
|
||||
String memberColor = sm.getClanChatMemberColor();
|
||||
String rank = cp.getRank().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRank());
|
||||
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getClanChatRank()).replaceAll("%rank%", rank) : "";
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getClanChatRank()).replace("%rank%", rank) : "";
|
||||
|
||||
String message = replacePlaceholders(sm, cp, leaderColor, memberColor, rankFormat, msg);
|
||||
String message = replacePlaceholders(sm.getClanChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
|
||||
if (placeholders != null) {
|
||||
for (Entry<String, String> e : placeholders.entrySet()) {
|
||||
message = message.replaceAll("%"+e.getKey()+"%", e.getValue());
|
||||
message = message.replace("%"+e.getKey()+"%", e.getValue());
|
||||
}
|
||||
}
|
||||
return message;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Kill {
|
||||
|
||||
private final ClanPlayer killer;
|
||||
private final ClanPlayer victim;
|
||||
private final LocalDateTime time;
|
||||
|
||||
public Kill(ClanPlayer killer, ClanPlayer victim, LocalDateTime time) {
|
||||
this.killer = killer;
|
||||
this.victim = victim;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public ClanPlayer getKiller() {
|
||||
return killer;
|
||||
}
|
||||
|
||||
public ClanPlayer getVictim() {
|
||||
return victim;
|
||||
}
|
||||
|
||||
public LocalDateTime getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
CIVILIAN("c"), RIVAL("r"), NEUTRAL("n");
|
||||
|
||||
Type(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
private final String shortName;
|
||||
|
||||
public String getShortname() {
|
||||
return shortName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
public enum PermissionLevel {
|
||||
LEADER, TRUSTED
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public class Rank implements Comparable<Rank> {
|
||||
|
||||
private String name;
|
||||
private String displayName;
|
||||
private Set<String> permissions;
|
||||
|
||||
public Rank(String name) {
|
||||
setName(name);
|
||||
permissions = new HashSet<String>();
|
||||
setDisplayName(displayName);
|
||||
}
|
||||
|
||||
public Rank(String name, String displayName, Set<String> permissions) {
|
||||
setName(name);
|
||||
setDisplayName(displayName);
|
||||
setPermissions(permissions);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
throw new IllegalArgumentException("name cannot be null or empty");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
if (displayName == null || displayName.isEmpty()) {
|
||||
displayName = name;
|
||||
}
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public void setPermissions(Set<String> permissions) {
|
||||
if (permissions == null) {
|
||||
permissions = new HashSet<String>();
|
||||
}
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Rank other = (Rank) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rank's permissions
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rank's display name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rank's name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Rank other) {
|
||||
return Integer.compare(permissions.size(), other.permissions.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public enum RankPermission {
|
||||
|
||||
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),
|
||||
HOME_REGROUP("simpleclans.leader.home-regroup", 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);
|
||||
|
||||
private final String bukkitPermission;
|
||||
private final PermissionLevel permissionLevel;
|
||||
|
||||
RankPermission(String bukkitPermission, PermissionLevel permissionLevel) {
|
||||
this.bukkitPermission = bukkitPermission;
|
||||
this.permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Bukkit equivalent to this rank permission
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public static boolean isValid(String permission) {
|
||||
for (RankPermission p : values()) {
|
||||
if (p.toString().equalsIgnoreCase(permission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,186 +1,293 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCEntityListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCPlayerListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @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] Online Mode: " + hasUUID); //TODO: Is this necessary?
|
||||
logger.info("[SimpleClans] Modo Multithreading: " + SimpleClans.getInstance().getSettingsManager().getUseThreads());
|
||||
logger.info("[SimpleClans] Modo BungeeCord: " + SimpleClans.getInstance().getSettingsManager().getUseBungeeCord());
|
||||
}
|
||||
|
||||
@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
|
||||
*/
|
||||
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 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 org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
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.language.LanguageMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
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.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PlaceholdersManager;
|
||||
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.SaveDataTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.UpkeepWarningTask;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
ChatFormatMigration chatFormatMigration = new ChatFormatMigration();
|
||||
chatFormatMigration.migrateAllyChat();
|
||||
chatFormatMigration.migrateClanChat();
|
||||
|
||||
getServer().getPluginManager().registerEvents(new SCEntityListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new SCPlayerListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryController(), 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());
|
||||
getLogger().info("Multithreading: " + SimpleClans.getInstance().getSettingsManager().getUseThreads());
|
||||
getLogger().info("BungeeCord: " + SimpleClans.getInstance().getSettingsManager().getUseBungeeCord());
|
||||
if (!Locale.getDefault().getLanguage().equals("en")) {
|
||||
getLogger().info("Help us translate SimpleClans to your language! Access https://crowdin.com/project/simpleclans/");
|
||||
}
|
||||
|
||||
startTasks();
|
||||
startMetrics();
|
||||
hookIntoPAPI();
|
||||
new UpdateChecker(this).check();
|
||||
}
|
||||
|
||||
private void hookIntoPAPI() {
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
getLogger().info("PlaceholderAPI found. Registering hook...");
|
||||
new PlaceholdersManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
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("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();
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
*/
|
||||
public PermissionsManager getPermissionsManager() {
|
||||
return permissionsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the path within the language file
|
||||
* @return the lang
|
||||
*/
|
||||
@Deprecated
|
||||
public String getLang(String key) {
|
||||
return getLang(key, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getLang(String key, Player player) {
|
||||
Locale locale;
|
||||
if (player == null) {
|
||||
locale = getSettingsManager().getLanguage();
|
||||
} else {
|
||||
locale = Helper.getLocale(player);
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', languageResource.getLang(key, locale));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, @Nullable Player player, Object... arguments) {
|
||||
Locale locale;
|
||||
if (player != null && instance.getSettingsManager().isLanguagePerPlayer()) {
|
||||
locale = Helper.getLocale(player);
|
||||
} else {
|
||||
locale = getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
|
||||
return MessageFormat.format(
|
||||
ChatColor.translateAlternateColorCodes(
|
||||
'&', languageResource.getLang(key, locale)), arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lang(@NotNull String key, Object... arguments) {
|
||||
return lang(key, null, arguments);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import java.util.UUID;
|
||||
|
||||
public class TeleportState {
|
||||
private UUID playerUniqueId;
|
||||
private String playerName;
|
||||
private Location playerLocation;
|
||||
private Location destination;
|
||||
private int counter;
|
||||
@@ -17,7 +16,6 @@ public class TeleportState {
|
||||
public TeleportState(Player player, Location dest, String clanName) {
|
||||
this.destination = dest;
|
||||
this.playerLocation = player.getLocation();
|
||||
this.playerName = player.getName();
|
||||
this.clanName = clanName;
|
||||
this.counter = SimpleClans.getInstance().getSettingsManager().getWaitSecs();
|
||||
this.playerUniqueId = player.getUniqueId();
|
||||
@@ -50,11 +48,7 @@ public class TeleportState {
|
||||
* @return
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerUniqueId);
|
||||
} else {
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerName);
|
||||
}
|
||||
return SimpleClans.getInstance().getServer().getPlayer(this.playerUniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,12 +40,7 @@ public class AllyCommand {
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.ally"), plugin.getSettingsManager().getCommandClan()));
|
||||
@@ -67,9 +62,14 @@ public class AllyCommand {
|
||||
|
||||
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;
|
||||
@@ -83,16 +83,20 @@ public class AllyCommand {
|
||||
}
|
||||
|
||||
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())));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.have.been.asked.for.an.alliance"), 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())));
|
||||
ally.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.broken.the.alliance"), clan.getName(), ally.getName()), false);
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.broken.the.alliance"), cp.getName(), ally.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.ally"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
|
||||
@@ -36,38 +36,23 @@ public class BanCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String banned = arg[0];
|
||||
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;
|
||||
}
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID PlayerUniqueId = UUIDMigration.getForcedPlayerUUID(banned);
|
||||
if (plugin.getSettingsManager().isBanned(PlayerUniqueId)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.already.banned"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player pl = SimpleClans.getInstance().getServer().getPlayer(PlayerUniqueId);
|
||||
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, ChatColor.AQUA + plugin.getLang("you.banned"));
|
||||
}
|
||||
|
||||
plugin.getClanManager().ban(banned);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.added.to.banned.list"));
|
||||
} else {
|
||||
if (plugin.getSettingsManager().isBanned(banned)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.already.banned"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player pl = SimpleClans.getInstance().getServer().getPlayerExact(banned);
|
||||
|
||||
if (pl != null) {
|
||||
ChatBlock.sendMessage(pl, ChatColor.AQUA + plugin.getLang("you.banned"));
|
||||
}
|
||||
|
||||
plugin.getClanManager().ban(banned);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.added.to.banned.list"));
|
||||
}
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ 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;
|
||||
@@ -47,34 +49,39 @@ public class BankCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.stats"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length == 1) {
|
||||
if (arg[0].equalsIgnoreCase("status")) {
|
||||
player.sendMessage(ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.balance"), clanbalance));
|
||||
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 (!cp.getClan().isLeader(player) && !clan.isAllowDeposit()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
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 (!cp.getClan().isLeader(player) && !clan.isAllowWithdraw()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
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 {
|
||||
|
||||
@@ -45,12 +45,7 @@ public class BbCommand {
|
||||
}
|
||||
|
||||
if (arg.length == 1 && arg[0].equalsIgnoreCase("clear")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.bb-clear")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (!cp.isTrusted() || !cp.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BB_CLEAR, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
cp.getClan().clearBb();
|
||||
@@ -58,13 +53,7 @@ public class BbCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.bb-add")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.BB_ADD, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ public class CoordsCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.coords"));
|
||||
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;
|
||||
@@ -96,7 +96,7 @@ public class CoordsCommand {
|
||||
}
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(clan.getName()) + subColor + " " + plugin.getLang("coords") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + clan.getName() + subColor + " " + plugin.getLang("coords") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.sendBlank(player);
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -43,12 +45,17 @@ public class CreateCommand {
|
||||
|
||||
boolean bypass = plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass");
|
||||
|
||||
if (tag.length() > 25) {
|
||||
ChatBlock.sendMessage(player, lang("your.clan.color.tag.cannot.be.longer.than.characters", player, 25));
|
||||
return;
|
||||
}
|
||||
|
||||
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()) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
* @author phaed
|
||||
*/
|
||||
public class DemoteCommand {
|
||||
|
||||
public DemoteCommand() {
|
||||
}
|
||||
|
||||
@@ -29,6 +30,40 @@ public class DemoteCommand {
|
||||
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"), 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;
|
||||
@@ -46,61 +81,25 @@ public class DemoteCommand {
|
||||
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.demote.leader"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
|
||||
if (!clan.enoughLeadersOnlineToDemote(toDemote)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.enough.leaders.online.to.vote.on.demotion"));
|
||||
return;
|
||||
}
|
||||
|
||||
String demotedName = arg[0];
|
||||
boolean allOtherLeadersOnline;
|
||||
|
||||
if (demotedName == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID PlayerUniqueId = UUIDMigration.getForcedPlayerUUID(demotedName);
|
||||
if (PlayerUniqueId == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
allOtherLeadersOnline = clan.allOtherLeadersOnline(PlayerUniqueId);
|
||||
} else {
|
||||
allOtherLeadersOnline = clan.allOtherLeadersOnline(demotedName);
|
||||
}
|
||||
|
||||
if (!allOtherLeadersOnline) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("leaders.must.be.online.to.vote.on.demotion"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID PlayerUniqueId = UUIDMigration.getForcedPlayerUUID(demotedName);
|
||||
if (!clan.isLeader(PlayerUniqueId)) {
|
||||
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(PlayerUniqueId);
|
||||
} else {
|
||||
if (!clan.isLeader(demotedName)) {
|
||||
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(demotedName);
|
||||
}
|
||||
if (!clan.isLeader(uuid)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("player.is.not.a.leader.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.getLeaders().size() > 2 && 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"), demotedName));
|
||||
clan.demote(uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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().updateClan(clan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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().updateClan(clan);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.RED
|
||||
+ MessageFormat.format(plugin.getLang("usage.fee"), plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
@@ -25,7 +24,7 @@ public class GlobalffCommand {
|
||||
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()));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.globalff.allow.auto"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,14 +82,9 @@ public class HomeCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.vitals"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length == 0) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.home")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.HOME_TP, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,12 +102,7 @@ public class HomeCommand {
|
||||
}
|
||||
|
||||
if (arg[0].equalsIgnoreCase("set")) {
|
||||
if (!cp.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.home-set")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
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")) {
|
||||
@@ -133,12 +123,7 @@ public class HomeCommand {
|
||||
}
|
||||
|
||||
if (arg[0].equalsIgnoreCase("clear")) {
|
||||
if (!cp.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.home-set")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
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")) {
|
||||
@@ -156,20 +141,23 @@ public class HomeCommand {
|
||||
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();
|
||||
}
|
||||
|
||||
if (!cp.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
|
||||
if(loc == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("hombase.not.set"));
|
||||
return;
|
||||
}
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.home-regroup")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
|
||||
|
||||
HomeRegroupEvent homeRegroupEvent = new HomeRegroupEvent(clan, cp, clan.getOnlineMembers(), loc);
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(homeRegroupEvent);
|
||||
|
||||
@@ -200,10 +188,7 @@ public class HomeCommand {
|
||||
|
||||
plugin.getTeleportManager().addPlayer(player, new Location(loc.getWorld(), x + .5, loc.getBlockY(), z + .5), clan.getName());
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("hombase.set") + ChatColor.YELLOW + Helper.toLocationString(loc));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -37,15 +45,15 @@ public class InviteCommand {
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
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) {
|
||||
@@ -60,17 +68,31 @@ public class InviteCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.invite.yourself"));
|
||||
return;
|
||||
}
|
||||
if (plugin.getSettingsManager().isBanned(player.getName())) {
|
||||
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().getClanPlayer(invited);
|
||||
ClanPlayer cpInv = plugin.getClanManager().getAnyClanPlayer(invited.getUniqueId());
|
||||
|
||||
if (cpInv != null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.already.member.of.another.clan"));
|
||||
return;
|
||||
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;
|
||||
}
|
||||
@@ -78,8 +100,8 @@ public class InviteCommand {
|
||||
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()));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.asked.to.join"), invited.getName(), clan.getName()));
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,14 @@ 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;
|
||||
|
||||
@@ -42,22 +45,21 @@ public class KickCommand {
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
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;
|
||||
}
|
||||
|
||||
String kicked = arg[0];
|
||||
|
||||
UUID kicked = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (kicked == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (kicked.equalsIgnoreCase(player.getName())) {
|
||||
if (kicked.equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.kick.yourself"));
|
||||
return;
|
||||
}
|
||||
@@ -70,12 +72,7 @@ public class KickCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.kicked.by"), Helper.capitalize(kicked), player.getName()));
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
clan.removePlayerFromClan(UUIDMigration.getForcedPlayerUUID(kicked));
|
||||
} else {
|
||||
clan.removePlayerFromClan(kicked);
|
||||
}
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.kicked.by"), arg[0], player.getName()));
|
||||
clan.removePlayerFromClan(kicked);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,102 @@
|
||||
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.HashMap;
|
||||
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 (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.stats"));
|
||||
return;
|
||||
}
|
||||
|
||||
String polledPlayerName = player.getName();
|
||||
|
||||
if (arg.length == 1) {
|
||||
polledPlayerName = arg[0];
|
||||
}
|
||||
|
||||
ChatBlock chatBlock = new ChatBlock();
|
||||
chatBlock.setFlexibility(true, false);
|
||||
chatBlock.setAlignment("l", "c");
|
||||
chatBlock.addRow(" " + headColor + plugin.getLang("victim"), plugin.getLang("killcount"));
|
||||
|
||||
Map<String, Integer> killsPerPlayerUnordered = plugin.getStorageManager().getKillsPerPlayer(polledPlayerName);
|
||||
|
||||
if (killsPerPlayerUnordered.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("nokillsfound"));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Integer> killsPerPlayer = Helper.sortByValue(killsPerPlayerUnordered);
|
||||
|
||||
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(polledPlayerName) + 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);
|
||||
}
|
||||
}
|
||||
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() + 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,92 +1,137 @@
|
||||
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.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 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 (!plugin.getPermissionsManager().has(player, "simpleclans.anyone.list")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.list"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
plugin.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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,111 +1,119 @@
|
||||
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 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;
|
||||
}
|
||||
|
||||
ClanPlayer targetCp = plugin.getClanManager().getAnyClanPlayer(playerName);
|
||||
ClanPlayer myCp = plugin.getClanManager().getClanPlayer(player.getName());
|
||||
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.getRank());
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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,6 +1,7 @@
|
||||
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;
|
||||
@@ -25,7 +26,7 @@ public class MenuCommand {
|
||||
*/
|
||||
public void execute(Player player) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
String subColor = plugin.getSettingsManager().getPageSubTitleColor();
|
||||
|
||||
@@ -33,13 +34,14 @@ public class MenuCommand {
|
||||
Clan clan = cp == null ? null : cp.getClan();
|
||||
|
||||
boolean isLeader = cp != null && cp.isLeader();
|
||||
boolean isTrusted = cp != null && cp.isTrusted();
|
||||
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()) {
|
||||
@@ -48,6 +50,10 @@ public class MenuCommand {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.create.tag.name.1.create.a.new.clan"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
if (clan != null && plugin.getPermissionsManager().has(player, "simpleclans.member.chat")) {
|
||||
String chatCommand = plugin.getSettingsManager().isTagBasedClanChat() ? clan.getTag() : plugin.getSettingsManager().getCommandClanChat();
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.message.1.send.a.message.to.clan.chat"), chatCommand, 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));
|
||||
}
|
||||
@@ -81,40 +87,49 @@ public class MenuCommand {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.vitals")) {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.coords")) {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.stats")) {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.kills")) {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.kills")) {
|
||||
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 (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.ally")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.rival")) {
|
||||
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, "simpleclans.member.home")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.home-set")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.home-set")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.home-regroup")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.war")) {
|
||||
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")) {
|
||||
@@ -123,42 +138,76 @@ public class MenuCommand {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.bb-add")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.modtag")) {
|
||||
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 && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.bb-toggle")) {
|
||||
if (isVerified && plugin.getPermissionsManager().has(player, "simpleclans.member.bb-toggle")) {
|
||||
toggles += "bb/";
|
||||
}
|
||||
|
||||
if (isVerified && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.member.tag-toggle")) {
|
||||
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 (isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.invite")) {
|
||||
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 (isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.kick")) {
|
||||
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.setrank")) {
|
||||
chatBlock.addRow(ChatColor.AQUA + " " + MessageFormat.format(plugin.getLang("0.trust.setrank"), 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.player.rank.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));
|
||||
}
|
||||
@@ -188,7 +237,7 @@ public class MenuCommand {
|
||||
if (plugin.getPermissionsManager().has(player, "simpleclans.mod.place")) {
|
||||
chatBlock.addRow(ChatColor.DARK_RED + " " + MessageFormat.format(plugin.getLang("0.place"), clanCommand, ChatColor.WHITE));
|
||||
}
|
||||
if (isVerified && isTrusted && plugin.getPermissionsManager().has(player, "simpleclans.mod.mostkilled")) {
|
||||
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")) {
|
||||
@@ -203,6 +252,12 @@ public class MenuCommand {
|
||||
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));
|
||||
}
|
||||
@@ -244,6 +299,7 @@ public class MenuCommand {
|
||||
|
||||
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));
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ 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;
|
||||
@@ -44,10 +46,10 @@ public class ModtagCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
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"));
|
||||
|
||||
+105
-93
@@ -1,93 +1,105 @@
|
||||
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.HashMap;
|
||||
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 (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.stats"));
|
||||
return;
|
||||
}
|
||||
|
||||
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"));
|
||||
|
||||
Map<String, Integer> killsPerPlayerUnordered = plugin.getStorageManager().getMostKilled();
|
||||
|
||||
if (killsPerPlayerUnordered.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("nokillsfound"));
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Integer> killsPerPlayer = Helper.sortByValue(killsPerPlayerUnordered);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -58,13 +58,8 @@ public class PlaceCommand {
|
||||
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())));
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
} else {
|
||||
oldClan.removePlayerFromClan(player.getName());
|
||||
}
|
||||
oldClan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("0.has.resigned"), player.getName()));
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+106
-101
@@ -1,101 +1,106 @@
|
||||
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 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"));
|
||||
|
||||
ChatBlock.sendMessage(player, " " + subColor + MessageFormat.format(plugin.getLang("name.0"), name));
|
||||
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("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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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() + 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,7 +1,6 @@
|
||||
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;
|
||||
|
||||
@@ -64,17 +63,20 @@ public class PromoteCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(promoted) && plugin.getSettingsManager().isConfirmationForPromote()) {
|
||||
if (clan.isLeader(promoted)) {
|
||||
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())));
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
clan.promote(promoted.getUniqueId());
|
||||
} else {
|
||||
clan.promote(promoted.getName());
|
||||
|
||||
if (plugin.getSettingsManager().isConfirmationForPromote() && clan.getLeaders().size() > 1) {
|
||||
plugin.getRequestManager().addPromoteRequest(cp, promoted.getName(), clan);
|
||||
ChatBlock.sendMessage(player,
|
||||
ChatColor.AQUA + plugin.getLang("promotion.vote.has.been.requested.from.all.leaders"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("promoted.to.leader"), promoted.getName()));
|
||||
clan.promote(promoted.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
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]);
|
||||
if (uuid == null || plugin.getClanManager().getAnyClanPlayer(uuid) == null) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
Player player = plugin.getServer().getPlayer(uuid);
|
||||
if (player != null && InventoryController.isRegistered(player)) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(uuid);
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
if (clan != null && clan.getMembers().size() == 1) {
|
||||
clan.disband();
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
|
||||
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;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public class RankCommand {
|
||||
private SimpleClans plugin;
|
||||
private Player player;
|
||||
private ClanPlayer clanPlayer;
|
||||
private Clan clan;
|
||||
|
||||
/**
|
||||
* Execute the command
|
||||
*
|
||||
* @param player
|
||||
* @param args
|
||||
*/
|
||||
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 + lang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan = clanPlayer.getClan();
|
||||
if (!clan.isVerified()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clanPlayer.isLeader()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("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(lang("usage.0.rank"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
|
||||
private void assignRank(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.assign")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("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 + lang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
String rank = args[1].toLowerCase();
|
||||
if (!clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("rank.0.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpTarget = Objects.requireNonNull(plugin.getClanManager().getClanPlayer(uuid));
|
||||
if (cpTarget.getRankId().equals(rank)) {
|
||||
ChatBlock.sendMessage(player, lang("player.already.has.that.rank"));
|
||||
return;
|
||||
}
|
||||
cpTarget.setRank(rank);
|
||||
plugin.getStorageManager().updateClanPlayer(cpTarget);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("player.rank.changed"));
|
||||
}
|
||||
|
||||
private void unassign(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.unassign")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("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 + lang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpTarget = plugin.getClanManager().getClanPlayer(uuid);
|
||||
Objects.requireNonNull(cpTarget).setRank(null);
|
||||
plugin.getStorageManager().updateClanPlayer(cpTarget);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("player.unassigned.from.rank"));
|
||||
}
|
||||
|
||||
private void createRank(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.create")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("usage.0.rank.create"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String rank = args[0].toLowerCase();
|
||||
if (clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("rank.already.exists"));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.createRank(rank);
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("rank.created"));
|
||||
}
|
||||
|
||||
private void listRanks() {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.list")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
List<Rank> ranks = clan.getRanks();
|
||||
|
||||
if (ranks.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("no.ranks"));
|
||||
return;
|
||||
}
|
||||
|
||||
ranks.sort(Comparator.reverseOrder());
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("clans.ranks"));
|
||||
int count = 1;
|
||||
for (Rank rank : ranks) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(lang("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 + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("usage.0.rank.delete"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
String rank = args[0].toLowerCase();
|
||||
if (!clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("rank.0.does.not.exist"));
|
||||
return;
|
||||
}
|
||||
clan.deleteRank(rank);
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(lang("rank.0.deleted"), rank));
|
||||
}
|
||||
|
||||
private void setDisplayName(String[] args) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.rank.setdisplayname")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("usage.0.rank.setdisplayname"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String rankName = args[0].toLowerCase();
|
||||
if (!clan.hasRank(rankName)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("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 + lang("you.cannot.set.colored.ranks"));
|
||||
return;
|
||||
}
|
||||
rank.setDisplayName(dn);
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("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 + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("available.rank.permissions"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + validPermissionsToMessage);
|
||||
return;
|
||||
}
|
||||
String rank = args[0].toLowerCase();
|
||||
if (!clan.hasRank(rank)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("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 + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (permissions.isEmpty()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("rank.no.permissions"));
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(lang("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 + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (!RankPermission.isValid(permission)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("invalid.permission"), permission, validPermissionsToMessage));
|
||||
return;
|
||||
}
|
||||
permissions.add(permission);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(lang("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 + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
permissions.remove(permission);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(lang("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(lang("usage.0.rank.permissions"),
|
||||
plugin.getSettingsManager().getCommandClan()));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ 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 net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -31,9 +33,11 @@ public class ReloadCommand
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + "Does not match a clan command");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getStorageManager().saveModified();
|
||||
plugin.reloadConfig();
|
||||
LanguageResource.clearCache();
|
||||
plugin.getSettingsManager().load();
|
||||
plugin.getLanguageManager().load();
|
||||
plugin.getStorageManager().importFromDatabase();
|
||||
SimpleClans.getInstance().getPermissionsManager().loadPermissions();
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@@ -52,18 +54,18 @@ public class ResetKDRCommand {
|
||||
}
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.have.reseted.kdr.of.all.players"));
|
||||
} else {
|
||||
OfflinePlayer toReset = Bukkit.getOfflinePlayer(arg[0]);
|
||||
if (toReset == null) {
|
||||
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(toReset);
|
||||
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"), toReset.getName()));
|
||||
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,14 +1,13 @@
|
||||
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 net.sacredlabyrinth.phaed.simpleclans.conversation.ResignPrompt;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -36,20 +35,11 @@ public class ResignCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
return;
|
||||
}
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (!clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("0.has.resigned"), Helper.capitalize(player.getName())));
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
} else {
|
||||
clan.removePlayerFromClan(player.getName());
|
||||
}
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
plugin.getClanManager().serverAnnounce(ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.has.been.disbanded"), clan.getName()));
|
||||
clan.disband();
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan"));
|
||||
}
|
||||
|
||||
new ConversationFactory(plugin)
|
||||
.withFirstPrompt(new ResignPrompt())
|
||||
.withLocalEcho(true)
|
||||
.withTimeout(10)
|
||||
.buildConversation(player).begin();
|
||||
}
|
||||
}
|
||||
@@ -44,10 +44,6 @@ public class RivalCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clan.cannot.create.rivals"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.rival"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
@@ -81,11 +77,14 @@ public class RivalCommand {
|
||||
}
|
||||
|
||||
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())));
|
||||
rival.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.initiated.a.rivalry"), clan.getName(), rival.getName()), false);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.initiated.a.rivalry"), player.getName(), rival.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clans.are.already.rivals"));
|
||||
}
|
||||
@@ -96,9 +95,12 @@ public class RivalCommand {
|
||||
}
|
||||
|
||||
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())));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.asked.to.end.rivalry"), rival.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("your.clans.are.not.rivals"));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RosterCommand {
|
||||
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.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + 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);
|
||||
@@ -80,7 +80,7 @@ public class RosterCommand {
|
||||
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.getRank()), lastSeen);
|
||||
chatBlock.addRow(" " + name, ChatColor.YELLOW + Helper.parseColors(cp.getRankDisplayName()) + ChatColor.RESET, lastSeen);
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class RosterCommand {
|
||||
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.getRank()), lastSeen);
|
||||
chatBlock.addRow(" " + name, ChatColor.YELLOW + Helper.parseColors(cp.getRankDisplayName()) + ChatColor.RESET, lastSeen);
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
@@ -1,68 +1,35 @@
|
||||
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();
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.setrank")) {
|
||||
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.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.setrank"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = arg[0];
|
||||
String rank = Helper.toMessage(Helper.removeFirst(arg));
|
||||
|
||||
if (!clan.isMember(playerName) && !clan.isLeader(playerName)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpm = plugin.getClanManager().getClanPlayer(playerName);
|
||||
cpm.setRank(rank);
|
||||
plugin.getStorageManager().updateClanPlayer(cpm);
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.rank.changed"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,9 +46,8 @@ public class StatsCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.stats"));
|
||||
return;
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.STATS, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg.length != 0) {
|
||||
@@ -57,7 +56,7 @@ public class StatsCommand {
|
||||
}
|
||||
|
||||
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.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + 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());
|
||||
|
||||
@@ -1,138 +1,175 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @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("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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @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 + lang("capeoff"));
|
||||
cp.setCapeEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("capeon"));
|
||||
cp.setCapeEnabled(true);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("clan.is.not.verified"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("not.a.member.of.any.clan"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("bb")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.bb-toggle")) {
|
||||
lang(ChatColor.RED + "insufficient.permissions");
|
||||
return;
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isBbEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("bboff"));
|
||||
cp.setBbEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("bbon"));
|
||||
cp.setBbEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("tag")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.tag-toggle")) {
|
||||
lang(ChatColor.RED + "insufficient.permissions");
|
||||
return;
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isTagEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("tagoff"));
|
||||
cp.setTagEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("tagon"));
|
||||
cp.setTagEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("deposit")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.deposit-toggle")) {
|
||||
lang(ChatColor.RED + "insufficient.permissions");
|
||||
return;
|
||||
}
|
||||
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 + lang("depositoff"));
|
||||
clan.setAllowDeposit(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("depositon"));
|
||||
clan.setAllowDeposit(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("no.leader.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("fee") && plugin.getPermissionsManager().has(player, RankPermission.FEE_ENABLE,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 + lang("feeoff"));
|
||||
clan.setMemberFeeEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("feeon"));
|
||||
clan.setMemberFeeEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("withdraw")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.withdraw-toggle")) {
|
||||
lang(ChatColor.RED + "insufficient.permissions");
|
||||
return;
|
||||
}
|
||||
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 + lang("withdrawoff"));
|
||||
clan.setAllowWithdraw(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("withdrawon"));
|
||||
clan.setAllowWithdraw(true);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("no.leader.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,13 @@ 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
|
||||
@@ -49,13 +52,12 @@ public class TrustCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String trusted = arg[0];
|
||||
|
||||
UUID trusted = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (trusted == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (trusted.equals(player.getName())) {
|
||||
if (trusted.equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.trust.yourself"));
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +82,7 @@ public class TrustCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.given.trusted.status.by"), Helper.capitalize(trusted), player.getName()));
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.given.trusted.status.by"), arg[0], player.getName()));
|
||||
tcp.setTrusted(true);
|
||||
plugin.getStorageManager().updateClanPlayer(tcp);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -34,20 +36,23 @@ public class UnbanCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String banned = arg[0];
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (uuid == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getSettingsManager().isBanned(banned)) {
|
||||
if (!plugin.getSettingsManager().isBanned(uuid)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("this.player.is.not.banned"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player pl = Helper.getPlayer(banned);
|
||||
|
||||
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(banned);
|
||||
plugin.getSettingsManager().removeBanned(uuid);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.removed.from.the.banned.list"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ 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
|
||||
@@ -49,26 +52,25 @@ public class UntrustCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
String trusted = arg[0];
|
||||
|
||||
if (trusted == null) {
|
||||
UUID trustedId = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (trustedId == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
if (trusted.equals(player.getName())) {
|
||||
if (trustedId.equals(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.cannot.untrust.yourself"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isMember(trusted)) {
|
||||
if (!clan.isMember(trustedId)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.player.is.not.a.member.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.isLeader(trusted)) {
|
||||
if (clan.isLeader(trustedId)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("leaders.cannot.be.untrusted"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer tcp = plugin.getClanManager().getClanPlayer(trusted);
|
||||
ClanPlayer tcp = plugin.getClanManager().getClanPlayer(trustedId);
|
||||
|
||||
if (tcp == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
@@ -79,7 +81,7 @@ public class UntrustCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.given.untrusted.status.by"), Helper.capitalize(trusted), player.getName()));
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.given.untrusted.status.by"), arg[0], player.getName()));
|
||||
tcp.setTrusted(false);
|
||||
plugin.getStorageManager().updateClanPlayer(tcp);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -40,26 +42,28 @@ public class VerifyCommand {
|
||||
//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"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
return;
|
||||
}
|
||||
if (isBuyer) {
|
||||
if (arg.length == 0 && plugin.getClanManager().purchaseVerification(player)) {
|
||||
if (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"));
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(lang("clan.0.has.been.verified"), clan.getName()));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("the.clan.has.been.verified"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
ChatBlock.sendMessage(player, lang("staff.member.verify.clan"));
|
||||
} else {
|
||||
if (arg.length != 1) {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.0.verify.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + MessageFormat.format(lang("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()));
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + MessageFormat.format(lang("usage.0.verify.tag"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
}
|
||||
verify(sender, arg[0]);
|
||||
@@ -73,13 +77,13 @@ public class VerifyCommand {
|
||||
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"));
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(lang("clan.0.has.been.verified"), clan.getName()));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("the.clan.has.been.verified"));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.is.already.verified"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("the.clan.is.already.verified"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("the.clan.does.not.exist"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("the.clan.does.not.exist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -43,17 +42,18 @@ public class VitalsCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!cp.isTrusted()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("only.trusted.players.can.access.clan.vitals"));
|
||||
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.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + 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"));
|
||||
|
||||
@@ -41,10 +41,6 @@ public class WarCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
return;
|
||||
}
|
||||
if (!clan.isLeader(player)) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
return;
|
||||
}
|
||||
if (arg.length != 2) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(plugin.getLang("usage.war"), plugin.getSettingsManager().getCommandClan()));
|
||||
return;
|
||||
@@ -63,12 +59,15 @@ public class WarCommand {
|
||||
}
|
||||
|
||||
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())));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.have.been.asked.to.accept.the.war.request"), war.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("at.least.one.leader.accept.the.alliance"));
|
||||
}
|
||||
@@ -79,9 +78,12 @@ public class WarCommand {
|
||||
}
|
||||
|
||||
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())));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("leaders.asked.to.end.rivalry"), war.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clans.not.at.war"));
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class MessagePromptImpl extends org.bukkit.conversations.MessagePrompt {
|
||||
|
||||
private final String message;
|
||||
|
||||
public MessagePromptImpl(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt getNextPrompt(ConversationContext cc) {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class ResignPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
|
||||
String yes = plugin.getLang("resign.yes");
|
||||
Player player = (Player) cc.getForWhom();
|
||||
ClanManager cm = plugin.getClanManager();
|
||||
ClanPlayer cp = cm.getClanPlayer(player);
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (yes.equalsIgnoreCase(input)) {
|
||||
if (!clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("0.has.resigned"), player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
return new MessagePromptImpl(ChatColor.AQUA + plugin.getLang("resign.success"));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband();
|
||||
String clanDisbanded = ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.has.been.disbanded"), clan.getName());
|
||||
//message for the server
|
||||
plugin.getClanManager().serverAnnounce(clanDisbanded);
|
||||
//message for the player
|
||||
return new MessagePromptImpl(clanDisbanded);
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + plugin.getLang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan"));
|
||||
}
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + plugin.getLang("resign.request.cancelled"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
final SimpleClans plugin = (SimpleClans) cc.getPlugin();
|
||||
|
||||
return ChatColor.RED + MessageFormat.format(
|
||||
plugin.getLang("resign.confirmation"), Arrays.asList(
|
||||
plugin.getLang("resign.yes"), plugin.getLang("resign.no")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AddKillEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private ClanPlayer victim;
|
||||
private ClanPlayer attacker;
|
||||
public AddKillEvent(ClanPlayer attacker, ClanPlayer victim){
|
||||
this.attacker = attacker;
|
||||
this.victim = victim;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public ClanPlayer getAttacker() {
|
||||
return attacker;
|
||||
}
|
||||
|
||||
public ClanPlayer getVictim() {
|
||||
return victim;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean value) {
|
||||
cancelled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,12 +16,12 @@ import org.bukkit.event.HandlerList;
|
||||
*/
|
||||
public class ChatEvent extends Event implements Cancellable {
|
||||
|
||||
private final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private String message;
|
||||
private ClanPlayer sender;
|
||||
private List<ClanPlayer> receivers;
|
||||
private Map<String, String> placeholders = new HashMap<>();
|
||||
private Type type;
|
||||
private final ClanPlayer sender;
|
||||
private final List<ClanPlayer> receivers;
|
||||
private final Map<String, String> placeholders = new HashMap<>();
|
||||
private final Type type;
|
||||
private boolean cancelled;
|
||||
|
||||
public ChatEvent(String message, ClanPlayer sender, List<ClanPlayer> receivers, Type type) {
|
||||
@@ -134,8 +135,12 @@ public class ChatEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-9
@@ -20,7 +20,7 @@ public class AcceptCommandExecutor implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
if (plugin.getSettingsManager().isBanned(player.getName())) {
|
||||
if (plugin.getSettingsManager().isBanned(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("banned"));
|
||||
return false;
|
||||
}
|
||||
@@ -42,19 +42,16 @@ public class AcceptCommandExecutor implements CommandExecutor {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("you.have.already.voted"));
|
||||
return false;
|
||||
}
|
||||
plugin.getRequestManager().accept(cp);
|
||||
clan.leaderAnnounce(ChatColor.GREEN + MessageFormat.format(plugin.getLang("voted.to.accept"), Helper.capitalize(player.getName())));
|
||||
|
||||
clan.leaderAnnounce(ChatColor.GREEN + MessageFormat.format(plugin.getLang("voted.to.accept"), player.getName()));
|
||||
plugin.getRequestManager().accept(cp);
|
||||
} else {
|
||||
if (!plugin.getRequestManager().hasRequest(player.getName().toLowerCase())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("nothing.to.accept"));
|
||||
return false;
|
||||
}
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = plugin.getClanManager().getCreateClanPlayer(player.getUniqueId());
|
||||
cp.setName(player.getName());
|
||||
} else {
|
||||
cp = plugin.getClanManager().getCreateClanPlayer(player.getName());
|
||||
}
|
||||
cp = plugin.getClanManager().getCreateClanPlayer(player.getUniqueId());
|
||||
cp.setName(player.getName());
|
||||
plugin.getRequestManager().accept(cp);
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -1,9 +1,9 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.executors;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
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.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -25,8 +25,7 @@ public class AllyCommandExecutor implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.member.ally")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.ALLY_CHAT, PermissionLevel.TRUSTED, true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+175
-99
@@ -1,58 +1,115 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.executors;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.*;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.AlliancesCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.AllyCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.BanCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.BankCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.BbCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanffCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.CoordsCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.CreateCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.DemoteCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.DescriptionCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.DisbandCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.FeeCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.FfCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.GlobalffCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.HomeCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.InviteCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.KickCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.KillsCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.LeaderboardCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ListCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.LookupCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.MenuCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ModtagCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.MostKilledCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.PlaceCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ProfileCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.PromoteCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.PurgeCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.RankCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ReloadCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ResetKDRCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ResignCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.RivalCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.RivalriesCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.RosterCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.SetRankCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.StatsCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ToggleCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.TrustCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.UnbanCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.UntrustCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.VerifyCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.VitalsCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.WarCommand;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.MainFrame;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public final class ClanCommandExecutor implements CommandExecutor {
|
||||
private SimpleClans plugin;
|
||||
private CreateCommand createCommand;
|
||||
private ListCommand listCommand;
|
||||
private ProfileCommand profileCommand;
|
||||
private RosterCommand rosterCommand;
|
||||
private LookupCommand lookupCommand;
|
||||
private LeaderboardCommand leaderboardCommand;
|
||||
private AlliancesCommand alliancesCommand;
|
||||
private RivalriesCommand rivalriesCommand;
|
||||
private VitalsCommand vitalsCommand;
|
||||
private CoordsCommand coordsCommand;
|
||||
private StatsCommand statsCommand;
|
||||
private AllyCommand allyCommand;
|
||||
private RivalCommand rivalCommand;
|
||||
private BbCommand bbCommand;
|
||||
private ModtagCommand modtagCommand;
|
||||
private ToggleCommand toggleCommand;
|
||||
private InviteCommand inviteCommand;
|
||||
private KickCommand kickCommand;
|
||||
private TrustCommand trustCommand;
|
||||
private UntrustCommand untrustCommand;
|
||||
private PromoteCommand promoteCommand;
|
||||
private DemoteCommand demoteCommand;
|
||||
private ClanffCommand clanffCommand;
|
||||
private FfCommand ffCommand;
|
||||
private ResignCommand resignCommand;
|
||||
private DisbandCommand disbandCommand;
|
||||
private VerifyCommand verifyCommand;
|
||||
private BanCommand banCommand;
|
||||
private UnbanCommand unbanCommand;
|
||||
private ReloadCommand reloadCommand;
|
||||
private GlobalffCommand globalffCommand;
|
||||
private MenuCommand menuCommand;
|
||||
private WarCommand warCommand;
|
||||
private HomeCommand homeCommand;
|
||||
private KillsCommand killsCommand;
|
||||
private MostKilledCommand mostKilledCommand;
|
||||
private SetRankCommand setRankCommand;
|
||||
private BankCommand bankCommand;
|
||||
private PlaceCommand placeCommand;
|
||||
private ResetKDRCommand resetKDRCommand;
|
||||
private final SimpleClans plugin;
|
||||
private final CreateCommand createCommand;
|
||||
private final ListCommand listCommand;
|
||||
private final ProfileCommand profileCommand;
|
||||
private final RosterCommand rosterCommand;
|
||||
private final LookupCommand lookupCommand;
|
||||
private final LeaderboardCommand leaderboardCommand;
|
||||
private final AlliancesCommand alliancesCommand;
|
||||
private final RivalriesCommand rivalriesCommand;
|
||||
private final VitalsCommand vitalsCommand;
|
||||
private final CoordsCommand coordsCommand;
|
||||
private final StatsCommand statsCommand;
|
||||
private final AllyCommand allyCommand;
|
||||
private final RivalCommand rivalCommand;
|
||||
private final BbCommand bbCommand;
|
||||
private final ModtagCommand modtagCommand;
|
||||
private final ToggleCommand toggleCommand;
|
||||
private final InviteCommand inviteCommand;
|
||||
private final KickCommand kickCommand;
|
||||
private final TrustCommand trustCommand;
|
||||
private final UntrustCommand untrustCommand;
|
||||
private final PromoteCommand promoteCommand;
|
||||
private final DemoteCommand demoteCommand;
|
||||
private final ClanffCommand clanffCommand;
|
||||
private final FfCommand ffCommand;
|
||||
private final ResignCommand resignCommand;
|
||||
private final DisbandCommand disbandCommand;
|
||||
private final VerifyCommand verifyCommand;
|
||||
private final BanCommand banCommand;
|
||||
private final FeeCommand feeCommand;
|
||||
private final UnbanCommand unbanCommand;
|
||||
private final ReloadCommand reloadCommand;
|
||||
private final GlobalffCommand globalffCommand;
|
||||
private final MenuCommand menuCommand;
|
||||
private final WarCommand warCommand;
|
||||
private final HomeCommand homeCommand;
|
||||
private final KillsCommand killsCommand;
|
||||
private final MostKilledCommand mostKilledCommand;
|
||||
private final SetRankCommand setRankCommand;
|
||||
private final BankCommand bankCommand;
|
||||
private final PlaceCommand placeCommand;
|
||||
private final ResetKDRCommand resetKDRCommand;
|
||||
private final PurgeCommand purgeCommand;
|
||||
private final DescriptionCommand descriptionCommand;
|
||||
private final RankCommand rankCommand;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -99,10 +156,14 @@ public final class ClanCommandExecutor implements CommandExecutor {
|
||||
bankCommand = new BankCommand();
|
||||
placeCommand = new PlaceCommand();
|
||||
resetKDRCommand = new ResetKDRCommand();
|
||||
feeCommand = new FeeCommand();
|
||||
purgeCommand = new PurgeCommand();
|
||||
descriptionCommand = new DescriptionCommand();
|
||||
rankCommand = new RankCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, Command command, String s, String[] args) {
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
@@ -111,97 +172,111 @@ public final class ClanCommandExecutor implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isBanned(player.getName())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("banned"));
|
||||
if (plugin.getSettingsManager().isBanned(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("banned",player));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
menuCommand.execute(player);
|
||||
if (plugin.getSettingsManager().isEnableGUI()) {
|
||||
InventoryDrawer.open(new MainFrame(player));
|
||||
} else {
|
||||
menuCommand.execute(player);
|
||||
}
|
||||
} else {
|
||||
String subcommand = args[0];
|
||||
String[] subargs = Helper.removeFirst(args);
|
||||
|
||||
if (subcommand.equalsIgnoreCase(plugin.getLang("create.command"))) {
|
||||
|
||||
if (subcommand.equalsIgnoreCase(lang("create.command",player)) || subcommand.equalsIgnoreCase("create")) {
|
||||
createCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("list.command")) || subcommand.equalsIgnoreCase("list")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("list.command",player)) || subcommand.equalsIgnoreCase("list")) {
|
||||
listCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("bank.command")) || subcommand.equalsIgnoreCase("bank")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("bank.command",player)) || subcommand.equalsIgnoreCase("bank")) {
|
||||
bankCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("profile.command")) || subcommand.equalsIgnoreCase("profile")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("profile.command",player)) || subcommand.equalsIgnoreCase("profile")) {
|
||||
profileCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("roster.command")) || subcommand.equalsIgnoreCase("roster")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("roster.command",player)) || subcommand.equalsIgnoreCase("roster")) {
|
||||
rosterCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("lookup.command")) || subcommand.equalsIgnoreCase("lookup")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("lookup.command",player)) || subcommand.equalsIgnoreCase("lookup")) {
|
||||
lookupCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("home.command")) || subcommand.equalsIgnoreCase("home")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("home.command",player)) || subcommand.equalsIgnoreCase("home")) {
|
||||
homeCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("leaderboard.command")) || subcommand.equalsIgnoreCase("leaderboard")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("leaderboard.command",player)) || subcommand.equalsIgnoreCase("leaderboard")) {
|
||||
leaderboardCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("alliances.command")) || subcommand.equalsIgnoreCase("alliances")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("alliances.command",player)) || subcommand.equalsIgnoreCase("alliances")) {
|
||||
alliancesCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("rivalries.command")) || subcommand.equalsIgnoreCase("rivalries")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("rivalries.command",player)) || subcommand.equalsIgnoreCase("rivalries")) {
|
||||
rivalriesCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("vitals.command")) || subcommand.equalsIgnoreCase("vitals")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("vitals.command",player)) || subcommand.equalsIgnoreCase("vitals")) {
|
||||
vitalsCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("coords.command")) || subcommand.equalsIgnoreCase("coords")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("coords.command",player)) || subcommand.equalsIgnoreCase("coords")) {
|
||||
coordsCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("stats.command")) || subcommand.equalsIgnoreCase("stats")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("stats.command",player)) || subcommand.equalsIgnoreCase("stats")) {
|
||||
statsCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("ally.command")) || subcommand.equalsIgnoreCase("ally")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("ally.command",player)) || subcommand.equalsIgnoreCase("ally")) {
|
||||
allyCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("rival.command")) || subcommand.equalsIgnoreCase("rival")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("rival.command",player)) || subcommand.equalsIgnoreCase("rival")) {
|
||||
rivalCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("bb.command")) || subcommand.equalsIgnoreCase("bb")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("bb.command",player)) || subcommand.equalsIgnoreCase("bb")) {
|
||||
bbCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("modtag.command")) || subcommand.equalsIgnoreCase("modtag")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("modtag.command",player)) || subcommand.equalsIgnoreCase("modtag")) {
|
||||
modtagCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("toggle.command")) || subcommand.equalsIgnoreCase("toggle")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("toggle.command",player)) || subcommand.equalsIgnoreCase("toggle")) {
|
||||
toggleCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("invite.command")) || subcommand.equalsIgnoreCase("invite")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("invite.command",player)) || subcommand.equalsIgnoreCase("invite")) {
|
||||
inviteCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("kick.command")) || subcommand.equalsIgnoreCase("kick")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("kick.command",player)) || subcommand.equalsIgnoreCase("kick")) {
|
||||
kickCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("trust.command")) || subcommand.equalsIgnoreCase("trust")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("trust.command",player)) || subcommand.equalsIgnoreCase("trust")) {
|
||||
trustCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("untrust.command")) || subcommand.equalsIgnoreCase("unstrust")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("untrust.command",player)) || subcommand.equalsIgnoreCase("unstrust")) {
|
||||
untrustCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("promote.command")) || subcommand.equalsIgnoreCase("promote")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("promote.command",player)) || subcommand.equalsIgnoreCase("promote")) {
|
||||
promoteCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("demote.command")) || subcommand.equalsIgnoreCase("demote")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("demote.command",player)) || subcommand.equalsIgnoreCase("demote")) {
|
||||
demoteCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("clanff.command")) || subcommand.equalsIgnoreCase("canff")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("clanff.command",player)) || subcommand.equalsIgnoreCase("canff")) {
|
||||
clanffCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("ff.command")) || subcommand.equalsIgnoreCase("ff")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("ff.command",player)) || subcommand.equalsIgnoreCase("ff")) {
|
||||
ffCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("resign.command")) || subcommand.equalsIgnoreCase("resign")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("resign.command",player)) || subcommand.equalsIgnoreCase("resign")) {
|
||||
resignCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("disband.command")) || subcommand.equalsIgnoreCase("disband")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("disband.command",player)) || subcommand.equalsIgnoreCase("disband")) {
|
||||
disbandCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("verify.command")) || subcommand.equalsIgnoreCase("verify")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("verify.command",player)) || subcommand.equalsIgnoreCase("verify")) {
|
||||
verifyCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("ban.command")) || subcommand.equalsIgnoreCase("ban")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("ban.command",player)) || subcommand.equalsIgnoreCase("ban")) {
|
||||
banCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("unban.command")) || subcommand.equalsIgnoreCase("unban")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("unban.command",player)) || subcommand.equalsIgnoreCase("unban")) {
|
||||
unbanCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("reload.command")) || subcommand.equalsIgnoreCase("reload")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("reload.command",player)) || subcommand.equalsIgnoreCase("reload")) {
|
||||
reloadCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("globalff.command")) || subcommand.equalsIgnoreCase("globalff")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("globalff.command",player)) || subcommand.equalsIgnoreCase("globalff")) {
|
||||
globalffCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("war.command")) || subcommand.equalsIgnoreCase("war")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("war.command",player)) || subcommand.equalsIgnoreCase("war")) {
|
||||
warCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("kills.command")) || subcommand.equalsIgnoreCase("kills")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("kills.command",player)) || subcommand.equalsIgnoreCase("kills")) {
|
||||
killsCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("mostkilled.command")) || subcommand.equalsIgnoreCase("mostkilled")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("mostkilled.command",player)) || subcommand.equalsIgnoreCase("mostkilled")) {
|
||||
mostKilledCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("setrank.command")) || subcommand.equalsIgnoreCase("setrank")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("setrank.command",player)) || subcommand.equalsIgnoreCase("setrank")) {
|
||||
setRankCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("place.command")) || subcommand.equalsIgnoreCase("place")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("place.command",player)) || subcommand.equalsIgnoreCase("place")) {
|
||||
placeCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("resetkdr.command")) || subcommand.equalsIgnoreCase("resetkdr")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("resetkdr.command",player)) || subcommand.equalsIgnoreCase("resetkdr")) {
|
||||
resetKDRCommand.execute(player, subargs);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("does.not.match"));
|
||||
} else if (subcommand.equalsIgnoreCase(lang("fee.command",player)) || subcommand.equalsIgnoreCase("fee")) {
|
||||
feeCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(lang("purge.command",player)) || subcommand.equalsIgnoreCase("purge")){
|
||||
purgeCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(lang("description.command",player)) || subcommand.equalsIgnoreCase("description")) {
|
||||
descriptionCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(lang("rank.command",player)) || subcommand.equalsIgnoreCase("rank")) {
|
||||
rankCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(lang("help.command",player)) || subcommand.equalsIgnoreCase("help")) {
|
||||
menuCommand.execute(player);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("does.not.match",player));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -211,22 +286,23 @@ public final class ClanCommandExecutor implements CommandExecutor {
|
||||
String subcommand = args[0];
|
||||
String[] subargs = Helper.removeFirst(args);
|
||||
|
||||
if (subcommand.equalsIgnoreCase(plugin.getLang("verify.command")) || subcommand.equalsIgnoreCase("verify")) {
|
||||
if (subcommand.equalsIgnoreCase(lang("verify.command")) || subcommand.equalsIgnoreCase("verify")) {
|
||||
verifyCommand.execute(sender, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("reload.command")) || subcommand.equalsIgnoreCase("reload")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("reload.command")) || subcommand.equalsIgnoreCase("reload")) {
|
||||
reloadCommand.execute(sender, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("place.command")) || subcommand.equalsIgnoreCase("place")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("place.command")) || subcommand.equalsIgnoreCase("place")) {
|
||||
placeCommand.execute(sender, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("globalff.command")) || subcommand.equalsIgnoreCase("globalff")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("globalff.command")) || subcommand.equalsIgnoreCase("globalff")) {
|
||||
globalffCommand.execute(sender, subargs);
|
||||
}
|
||||
else {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("does.not.match"));
|
||||
} else if (subcommand.equalsIgnoreCase(lang("purge.command")) || subcommand.equalsIgnoreCase("purge")) {
|
||||
purgeCommand.execute(sender, subargs);
|
||||
} else {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + lang("does.not.match"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.RED + MessageFormat.format(plugin.getLang("simpleclans.command.failure"), ex.getMessage()));
|
||||
SimpleClans.getInstance().getServer().getConsoleSender().sendMessage(ChatColor.RED + MessageFormat.format(lang("simpleclans.command.failure"), ex.getMessage()));
|
||||
for (StackTraceElement el : ex.getStackTrace()) {
|
||||
System.out.print(el.toString());
|
||||
}
|
||||
|
||||
+5
-8
@@ -20,7 +20,7 @@ public class DenyCommandExecutor implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
if (plugin.getSettingsManager().isBanned(player.getName())) {
|
||||
if (plugin.getSettingsManager().isBanned(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("banned"));
|
||||
return false;
|
||||
}
|
||||
@@ -43,18 +43,15 @@ public class DenyCommandExecutor implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
plugin.getRequestManager().deny(cp);
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("has.voted.to.deny"), Helper.capitalize(player.getName())));
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("has.voted.to.deny"), player.getName()));
|
||||
plugin.getRequestManager().deny(cp);
|
||||
} else {
|
||||
if (!plugin.getRequestManager().hasRequest(player.getName().toLowerCase())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("nothing.to.deny"));
|
||||
return false;
|
||||
}
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = plugin.getClanManager().getCreateClanPlayer(player.getUniqueId());
|
||||
} else {
|
||||
cp = plugin.getClanManager().getCreateClanPlayer(player.getName());
|
||||
}
|
||||
cp = plugin.getClanManager().getCreateClanPlayer(player.getUniqueId());
|
||||
|
||||
plugin.getRequestManager().deny(cp);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class MoreCommandExecutor implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
if (plugin.getSettingsManager().isBanned(player.getName())) {
|
||||
if (plugin.getSettingsManager().isBanned(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("banned"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.language;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
* Utility class that migrates old language files (yaml) to the new format (properties)
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public class LanguageMigration {
|
||||
|
||||
private SimpleClans plugin;
|
||||
|
||||
public LanguageMigration(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates all language files in the plugin's data folder
|
||||
*/
|
||||
public void migrate() {
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
if (!dataFolder.exists()) {
|
||||
return;
|
||||
}
|
||||
File[] languageFiles = dataFolder.listFiles(f -> {
|
||||
return f.getName().startsWith("language") && f.getName().endsWith(".yml");
|
||||
});
|
||||
|
||||
for (File file : languageFiles) {
|
||||
convert(file);
|
||||
backup(file);
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the file to the backup folder
|
||||
*
|
||||
* @param file the file to backup
|
||||
*/
|
||||
private void backup(File file) {
|
||||
File backupFolder = new File(plugin.getDataFolder(), "language_backup");
|
||||
if (!backupFolder.exists()) {
|
||||
backupFolder.mkdir();
|
||||
}
|
||||
|
||||
file.renameTo(new File(backupFolder, file.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the yaml file to properties
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
private void convert(File file) {
|
||||
List<String> lines = null;
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
||||
lines = reader.lines().collect(Collectors.toList());
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Error converting language file " + file.getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (lines == null || lines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> convertedLines = new ArrayList<>();
|
||||
for (String line : lines) {
|
||||
line = line.replaceFirst(":", "=")
|
||||
.replaceAll("''''", "''")
|
||||
.replaceAll("^'", "")
|
||||
.replaceAll("= \'", "=")
|
||||
.replaceAll("'$", "")
|
||||
.replaceAll("^\"", "")
|
||||
.replaceAll("\"$", "")
|
||||
.replaceAll("= \"", "=");
|
||||
convertedLines.add(line);
|
||||
}
|
||||
|
||||
File converted = new File(file.getParentFile(), file.getName().replace("language", "messages").replace("yml", "properties").replace("-", "_"));
|
||||
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(converted), StandardCharsets.UTF_8))) {
|
||||
for (String line : convertedLines) {
|
||||
writer.append(line);
|
||||
writer.append(System.lineSeparator());
|
||||
}
|
||||
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Error converting language file " + file.getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.language;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public class LanguageResource {
|
||||
|
||||
private static ResourceLoader loader = new ResourceLoader(SimpleClans.getInstance().getDataFolder());
|
||||
private Locale defaultLocale;
|
||||
|
||||
public LanguageResource() {
|
||||
this.defaultLocale = SimpleClans.getInstance().getSettingsManager().getLanguage();
|
||||
}
|
||||
|
||||
public String getLang(String key, Locale locale) {
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("messages", locale, loader,
|
||||
new ResourceControl(defaultLocale));
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
|
||||
try {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("messages", locale,
|
||||
SimpleClans.getInstance().getClass().getClassLoader(), new ResourceControl(defaultLocale));
|
||||
|
||||
return bundle.getString(key);
|
||||
} catch (MissingResourceException ignored) {}
|
||||
|
||||
return "Missing language key: " + key;
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
ResourceBundle.clearCache(loader);
|
||||
}
|
||||
|
||||
static class ResourceLoader extends ClassLoader {
|
||||
|
||||
private final File dataFolder;
|
||||
|
||||
public ResourceLoader(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
File file = new File(dataFolder, name);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return file.toURI().toURL();
|
||||
} catch (MalformedURLException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static class ResourceControl extends ResourceBundle.Control {
|
||||
|
||||
private Locale defaultLocale;
|
||||
|
||||
public ResourceControl(Locale defaultLocale) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFormats(String baseName) {
|
||||
if (baseName == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
return Arrays.asList("java.properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader,
|
||||
boolean reload) throws IllegalAccessException, InstantiationException, IOException {
|
||||
String bundleName = toBundleName(baseName, locale);
|
||||
|
||||
ResourceBundle bundle = null;
|
||||
if (format.equals("java.properties")) {
|
||||
|
||||
String resourceName = toResourceName(bundleName, "properties");
|
||||
|
||||
if (resourceName == null) {
|
||||
return bundle;
|
||||
}
|
||||
URL url = loader.getResource(resourceName);
|
||||
if (url == null) {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
URLConnection connection = url.openConnection();
|
||||
if (reload) {
|
||||
|
||||
connection.setUseCaches(false);
|
||||
}
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
bundle = new PropertyResourceBundle(reader);
|
||||
reader.close();
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown format: " + format);
|
||||
}
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Locale getFallbackLocale(String baseName, Locale locale) {
|
||||
if (!locale.equals(defaultLocale) && !locale.equals(Locale.ROOT)) {
|
||||
return defaultLocale;
|
||||
}
|
||||
if (locale.equals(defaultLocale) && !defaultLocale.equals(Locale.ROOT)) {
|
||||
return Locale.ROOT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
-29
@@ -2,7 +2,12 @@ package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Kill;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.AddKillEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager.DataCallback;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,6 +20,9 @@ import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -78,64 +86,104 @@ public class SCEntityListener implements Listener
|
||||
|
||||
if (attacker != null && victim != null)
|
||||
{
|
||||
ClanPlayer acp;
|
||||
ClanPlayer vcp;
|
||||
if (SimpleClans.getInstance().hasUUID())
|
||||
{
|
||||
acp = plugin.getClanManager().getCreateClanPlayer(attacker.getUniqueId());
|
||||
vcp = plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId());
|
||||
} else
|
||||
{
|
||||
acp = plugin.getClanManager().getCreateClanPlayer(attacker.getName());
|
||||
vcp = plugin.getClanManager().getCreateClanPlayer(victim.getName());
|
||||
}
|
||||
|
||||
if (SimpleClans.getInstance().getSettingsManager().isDenySameIPKills())
|
||||
{
|
||||
if (attacker.getAddress().getHostString().equals(victim.getAddress().getHostString()))
|
||||
{
|
||||
plugin.getLogger().log(Level.INFO, "Blocked same IP kill calculating: {0} killed {1}. IP: {2}", new Object[]{
|
||||
attacker.getDisplayName(), victim.getDisplayName(), attacker.getAddress().getHostString()
|
||||
});
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
String kdrExempt = "simpleclans.other.kdr-exempt";
|
||||
PermissionsManager pm = plugin.getPermissionsManager();
|
||||
if (pm.has(attacker, kdrExempt) || pm.has(victim, kdrExempt)) {
|
||||
return;
|
||||
}
|
||||
AddKillEvent addKillEvent = new AddKillEvent(plugin.getClanManager().getCreateClanPlayer(attacker.getUniqueId()),plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(addKillEvent);
|
||||
if(addKillEvent.isCancelled()) return;
|
||||
ClanPlayer victimCp = addKillEvent.getVictim();
|
||||
ClanPlayer attackerCp = addKillEvent.getAttacker();
|
||||
double reward = 0;
|
||||
double multipier = plugin.getSettingsManager().getKDRMultipliesPerKill();
|
||||
float kdr = acp.getKDR();
|
||||
|
||||
if (vcp.getClan() == null || acp.getClan() == null || !vcp.getClan().isVerified() || !acp.getClan().isVerified())
|
||||
float kdr = attackerCp.getKDR();
|
||||
if (victimCp.getClan() == null || attackerCp.getClan() == null || !victimCp.getClan().isVerified() || !attackerCp.getClan().isVerified())
|
||||
{
|
||||
acp.addCivilianKill();
|
||||
plugin.getStorageManager().insertKill(attacker, acp.getTag(), victim, "", "c");
|
||||
} else if (acp.getClan().isRival(vcp.getTag()))
|
||||
addKill(Kill.Type.CIVILIAN, attackerCp, victimCp);
|
||||
} else if (attackerCp.getClan().isRival(victimCp.getTag()))
|
||||
{
|
||||
if (acp.getClan().isWarring(vcp.getClan()))
|
||||
if (attackerCp.getClan().isWarring(victimCp.getClan()))
|
||||
{
|
||||
reward = (double) kdr * multipier * 4;
|
||||
} else
|
||||
{
|
||||
reward = (double) kdr * multipier * 2;
|
||||
}
|
||||
acp.addRivalKill();
|
||||
plugin.getStorageManager().insertKill(attacker, acp.getTag(), victim, vcp.getTag(), "r");
|
||||
} else if (acp.getClan().isAlly(vcp.getTag()))
|
||||
addKill(Kill.Type.RIVAL, attackerCp, victimCp);
|
||||
} else if (attackerCp.getClan().isAlly(victimCp.getTag()))
|
||||
{
|
||||
reward = (double) kdr * multipier * -1;
|
||||
} else
|
||||
{
|
||||
reward = (double) kdr * multipier;
|
||||
acp.addNeutralKill();
|
||||
plugin.getStorageManager().insertKill(attacker, acp.getTag(), victim, vcp.getTag(), "n");
|
||||
addKill(Kill.Type.NEUTRAL, attackerCp, victimCp);
|
||||
}
|
||||
|
||||
if (reward != 0 && plugin.getSettingsManager().isMoneyPerKill())
|
||||
{
|
||||
for (ClanPlayer cp : acp.getClan().getOnlineMembers())
|
||||
for (ClanPlayer cp : attackerCp.getClan().getOnlineMembers())
|
||||
{
|
||||
double money = Math.round((reward / acp.getClan().getOnlineMembers().size()) * 100D) / 100D;
|
||||
double money = Math.round((reward / attackerCp.getClan().getOnlineMembers().size()) * 100D) / 100D;
|
||||
cp.toPlayer().sendMessage(ChatColor.AQUA + MessageFormat.format(plugin.getLang("player.got.money"), money, victim.getName(), kdr));
|
||||
plugin.getPermissionsManager().playerGrantMoney(cp.getName(), money);
|
||||
plugin.getPermissionsManager().playerGrantMoney(cp.toPlayer(), money);
|
||||
}
|
||||
}
|
||||
|
||||
// record death for victim
|
||||
vcp.addDeath();
|
||||
plugin.getStorageManager().updateClanPlayerAsync(vcp);
|
||||
victimCp.addDeath();
|
||||
plugin.getStorageManager().updateClanPlayer(victimCp);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void addKill(Kill.Type type, ClanPlayer attacker, ClanPlayer victim) {
|
||||
if (type == null || attacker == null || victim == null) {
|
||||
return;
|
||||
}
|
||||
final Kill kill = new Kill(attacker, victim, LocalDateTime.now());
|
||||
if (plugin.getSettingsManager().isDelayBetweenKills() && plugin.getClanManager().isKillBeforeDelay(kill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isMaxKillsPerVictim()) {
|
||||
plugin.getStorageManager().getKillsPerPlayer(attacker.getName(), new DataCallback<Map<String,Integer>>() {
|
||||
|
||||
@Override
|
||||
public void onResultReady(Map<String, Integer> data) {
|
||||
final int max = plugin.getSettingsManager().getMaxKillsPerVictim();
|
||||
Integer kills = data.get(kill.getVictim().getName());
|
||||
if (kills != null) {
|
||||
if (kills.intValue() < max) {
|
||||
saveKill(kill, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
saveKill(kill, type);
|
||||
}
|
||||
|
||||
private void saveKill(Kill kill, Kill.Type type) {
|
||||
plugin.getClanManager().addKill(kill);
|
||||
ClanPlayer killer = kill.getKiller();
|
||||
ClanPlayer victim = kill.getVictim();
|
||||
killer.addKill(type);
|
||||
plugin.getStorageManager().insertKill(killer.toPlayer(), killer.getTag(), victim.toPlayer(), victim.getTag(), type.getShortname());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
|
||||
@@ -156,10 +156,9 @@ public class SCPlayerListener implements Listener {
|
||||
String message = event.getMessage();
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(event.getPlayer());
|
||||
|
||||
if (cp != null) {
|
||||
if (cp != null && !event.isCancelled()) {
|
||||
if (cp.getChannel().equals(ClanPlayer.Channel.CLAN)) {
|
||||
event.setCancelled(true);
|
||||
//TODO: Document this permission
|
||||
if (!plugin.getPermissionsManager().has(cp.toPlayer(), "simpleclans.member.chat")) {
|
||||
ChatBlock.sendMessage(cp.toPlayer(), ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
return;
|
||||
@@ -181,8 +180,8 @@ public class SCPlayerListener implements Listener {
|
||||
boolean isClanChat = event.getMessage().contains("" + ChatColor.RED + ChatColor.WHITE + ChatColor.RED + ChatColor.BLACK);
|
||||
boolean isAllyChat = event.getMessage().contains("" + ChatColor.AQUA + ChatColor.WHITE + ChatColor.AQUA + ChatColor.BLACK);
|
||||
|
||||
for (Iterator iter = event.getRecipients().iterator(); iter.hasNext();) {
|
||||
Player player = (Player) iter.next();
|
||||
for (Iterator<Player> iter = event.getRecipients().iterator(); iter.hasNext();) {
|
||||
Player player = iter.next();
|
||||
|
||||
ClanPlayer rcp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
@@ -259,7 +258,7 @@ public class SCPlayerListener implements Listener {
|
||||
SimpleClans.getInstance().getPermissionsManager().addPlayerPermissions(cp);
|
||||
|
||||
if (plugin.getSettingsManager().isBbShowOnLogin() && cp.isBbEnabled()) {
|
||||
cp.getClan().displayBb(player);
|
||||
cp.getClan().displayBb(player, plugin.getSettingsManager().getBbLoginSize());
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getPermissionsManager().addClanPermissions(cp);
|
||||
|
||||
@@ -10,19 +10,25 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ChatEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public final class ClanManager {
|
||||
|
||||
private SimpleClans plugin;
|
||||
private HashMap<String, Clan> clans = new HashMap<>();
|
||||
private HashMap<String, ClanPlayer> clanPlayers = new HashMap<>();
|
||||
private final SimpleClans plugin;
|
||||
private final HashMap<String, Clan> clans = new HashMap<>();
|
||||
private final HashMap<String, ClanPlayer> clanPlayers = new HashMap<>();
|
||||
private final HashMap<ClanPlayer, List<Kill>> kills = new HashMap<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -37,8 +43,76 @@ public final class ClanManager {
|
||||
public void cleanData() {
|
||||
clans.clear();
|
||||
clanPlayers.clear();
|
||||
kills.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a kill to the memory
|
||||
*
|
||||
* @param kill
|
||||
*/
|
||||
public void addKill(Kill kill) {
|
||||
if (kill == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Kill> list = kills.get(kill.getKiller());
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
kills.put(kill.getKiller(), list);
|
||||
}
|
||||
|
||||
Iterator<Kill> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Kill oldKill = iterator.next();
|
||||
if (oldKill.getVictim().equals(kill.getKiller())) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
//cleaning
|
||||
final int delay = plugin.getSettingsManager().getDelayBetweenKills();
|
||||
long timePassed = oldKill.getTime().until(LocalDateTime.now(), ChronoUnit.MINUTES);
|
||||
if (timePassed >= delay) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
list.add(kill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this kill respects the delay
|
||||
*
|
||||
* @param kill
|
||||
* @return
|
||||
*/
|
||||
public boolean isKillBeforeDelay(Kill kill) {
|
||||
if (kill == null) {
|
||||
return false;
|
||||
}
|
||||
List<Kill> list = kills.get(kill.getKiller());
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator<Kill> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
Kill oldKill = iterator.next();
|
||||
if (oldKill.getVictim().equals(kill.getVictim())) {
|
||||
|
||||
final int delay = plugin.getSettingsManager().getDelayBetweenKills();
|
||||
long timePassed = oldKill.getTime().until(kill.getTime(), ChronoUnit.MINUTES);
|
||||
if (timePassed < delay) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a clan into the in-memory store
|
||||
*
|
||||
@@ -54,13 +128,9 @@ public final class ClanManager {
|
||||
* @param cp
|
||||
*/
|
||||
public void importClanPlayer(ClanPlayer cp) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
if (cp.getUniqueId() != null) {
|
||||
this.clanPlayers.put(cp.getUniqueId().toString(), cp);
|
||||
}
|
||||
} else {
|
||||
this.clanPlayers.put(cp.getCleanName(), cp);
|
||||
}
|
||||
if (cp.getUniqueId() != null) {
|
||||
this.clanPlayers.put(cp.getUniqueId().toString(), cp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,12 +141,7 @@ public final class ClanManager {
|
||||
* @param name
|
||||
*/
|
||||
public void createClan(Player player, String colorTag, String name) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = getCreateClanPlayer(player.getUniqueId());
|
||||
} else {
|
||||
cp = getCreateClanPlayer(player.getName());
|
||||
}
|
||||
ClanPlayer cp = getCreateClanPlayer(player.getUniqueId());
|
||||
|
||||
boolean verified = !plugin.getSettingsManager().isRequireVerification() || plugin.getPermissionsManager().has(player, "simpleclans.mod.verify");
|
||||
|
||||
@@ -91,17 +156,18 @@ public final class ClanManager {
|
||||
SimpleClans.getInstance().getPermissionsManager().updateClanPermissions(clan);
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new CreateClanEvent(clan));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset a player's kdr
|
||||
* @param cp
|
||||
* Reset a player's KDR
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void resetKdr(ClanPlayer cp) {
|
||||
cp.setCivilianKills(0);
|
||||
cp.setNeutralKills(0);
|
||||
cp.setRivalKills(0);
|
||||
cp.setDeaths(0);
|
||||
plugin.getStorageManager().updateClanPlayerAsync(cp);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +176,11 @@ public final class ClanManager {
|
||||
* @param cp
|
||||
*/
|
||||
public void deleteClanPlayer(ClanPlayer cp) {
|
||||
clanPlayers.remove(cp.getCleanName());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan != null) {
|
||||
clan.removePlayerFromClan(cp.getUniqueId());
|
||||
}
|
||||
clanPlayers.remove(cp.getUniqueId().toString());
|
||||
plugin.getStorageManager().deleteClanPlayer(cp);
|
||||
}
|
||||
|
||||
@@ -153,23 +223,6 @@ public final class ClanManager {
|
||||
return clans.get(Helper.cleanTag(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a player's clan
|
||||
*
|
||||
* @param playerName
|
||||
* @return null if not in a clan
|
||||
*/
|
||||
@Deprecated
|
||||
public Clan getClanByPlayerName(String playerName) {
|
||||
ClanPlayer cp = getClanPlayer(playerName);
|
||||
|
||||
if (cp != null) {
|
||||
return cp.getClan();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a player's clan
|
||||
*
|
||||
@@ -211,11 +264,7 @@ public final class ClanManager {
|
||||
*/
|
||||
public ClanPlayer getClanPlayerJoinEvent(Player player) {
|
||||
SimpleClans.getInstance().getStorageManager().importFromDatabaseOnePlayer(player);
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return getClanPlayer(player.getUniqueId());
|
||||
} else {
|
||||
return getClanPlayer(player.getName());
|
||||
}
|
||||
return getClanPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,14 +275,9 @@ public final class ClanManager {
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getClanPlayer(OfflinePlayer player) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return getClanPlayer(player.getUniqueId());
|
||||
} else {
|
||||
return getClanPlayer(player.getName());
|
||||
}
|
||||
return getClanPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
@@ -245,33 +289,6 @@ public final class ClanManager {
|
||||
return getClanPlayer((OfflinePlayer) player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public ClanPlayer getClanPlayer(String playerName) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = getClanPlayerName(playerName);
|
||||
} else {
|
||||
cp = clanPlayers.get(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
if (cp == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cp.getClan() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
@@ -320,24 +337,6 @@ public final class ClanManager {
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer data object for the player, will retrieve disabled
|
||||
* clan players as well, these are players who used to be in a clan but are
|
||||
* not currently in one, their data file persists and can be accessed. their
|
||||
* clan will be null though.
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public ClanPlayer getAnyClanPlayer(String playerName) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return getClanPlayerName(playerName);
|
||||
} else {
|
||||
return clanPlayers.get(playerName.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer data object for the player, will retrieve disabled
|
||||
* clan players as well, these are players who used to be in a clan but are
|
||||
@@ -351,26 +350,6 @@ public final class ClanManager {
|
||||
return clanPlayers.get(playerUniqueId.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer object for the player, creates one if not found
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public ClanPlayer getCreateClanPlayer(String playerName) {
|
||||
if (clanPlayers.containsKey(playerName.toLowerCase())) {
|
||||
return clanPlayers.get(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
ClanPlayer cp = new ClanPlayer(playerName);
|
||||
|
||||
plugin.getStorageManager().insertClanPlayer(cp);
|
||||
importClanPlayer(cp);
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ClanPlayer object for the player, creates one if not found
|
||||
*
|
||||
@@ -378,16 +357,12 @@ public final class ClanManager {
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getCreateClanPlayerUUID(String playerDisplayName) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID playerUniqueId = UUIDMigration.getForcedPlayerUUID(playerDisplayName);
|
||||
if (playerUniqueId != null) {
|
||||
return getCreateClanPlayer(playerUniqueId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return getCreateClanPlayer(playerDisplayName);
|
||||
}
|
||||
UUID playerUniqueId = UUIDMigration.getForcedPlayerUUID(playerDisplayName);
|
||||
if (playerUniqueId != null) {
|
||||
return getCreateClanPlayer(playerUniqueId);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,11 +417,11 @@ public final class ClanManager {
|
||||
|
||||
if (plugin.getSettingsManager().isChatTags()) {
|
||||
String prefix = plugin.getPermissionsManager().getPrefix(player);
|
||||
String suffix = plugin.getPermissionsManager().getSuffix(player);
|
||||
//String suffix = plugin.getPermissionsManager().getSuffix(player);
|
||||
String lastColor = plugin.getSettingsManager().isUseColorCodeFromPrefix() ? Helper.getLastColorCode(prefix) : ChatColor.WHITE + "";
|
||||
String fullName = player.getName();
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getName());
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
|
||||
if (cp == null) {
|
||||
return;
|
||||
@@ -472,27 +447,32 @@ public final class ClanManager {
|
||||
* @param player
|
||||
*/
|
||||
public void updateLastSeen(Player player) {
|
||||
ClanPlayer cp = getAnyClanPlayer(player.getName());
|
||||
ClanPlayer cp = getAnyClanPlayer(player.getUniqueId());
|
||||
|
||||
if (cp != null) {
|
||||
cp.updateLastSeen();
|
||||
plugin.getStorageManager().updateClanPlayerAsync(cp);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan != null) {
|
||||
clan.updateLastUsed();
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
* Bans a player from clan commands
|
||||
*
|
||||
* @param uuid the player's uuid
|
||||
*/
|
||||
public void ban(String playerName) {
|
||||
ClanPlayer cp = getClanPlayer(playerName);
|
||||
Clan clan = cp.getClan();
|
||||
public void ban(UUID uuid) {
|
||||
ClanPlayer cp = getClanPlayer(uuid);
|
||||
Clan clan = null;
|
||||
if (cp != null) {
|
||||
clan = cp.getClan();
|
||||
}
|
||||
|
||||
if (clan != null) {
|
||||
if (clan.getSize() == 1) {
|
||||
@@ -502,14 +482,14 @@ public final class ClanManager {
|
||||
cp.addPastClan(clan.getColorTag() + (cp.isLeader() ? ChatColor.DARK_RED + "*" : ""));
|
||||
cp.setLeader(false);
|
||||
cp.setJoinDate(0);
|
||||
clan.removeMember(playerName);
|
||||
clan.removeMember(uuid);
|
||||
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getSettingsManager().addBanned(playerName);
|
||||
plugin.getSettingsManager().addBanned(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,7 +525,7 @@ public final class ClanManager {
|
||||
out += ChatColor.WHITE + plugin.getLang("armor.h");
|
||||
} else if (h.getType().equals(Material.DIAMOND_HELMET)) {
|
||||
out += ChatColor.AQUA + plugin.getLang("armor.h");
|
||||
} else if (h.getType().equals(Material.GOLD_HELMET)) {
|
||||
} else if (h.getType().equals(Material.GOLDEN_HELMET)) {
|
||||
out += ChatColor.YELLOW + plugin.getLang("armor.h");
|
||||
} else if (h.getType().equals(Material.IRON_HELMET)) {
|
||||
out += ChatColor.GRAY + plugin.getLang("armor.h");
|
||||
@@ -564,7 +544,7 @@ public final class ClanManager {
|
||||
out += ChatColor.WHITE + plugin.getLang("armor.c");
|
||||
} else if (c.getType().equals(Material.DIAMOND_CHESTPLATE)) {
|
||||
out += ChatColor.AQUA + plugin.getLang("armor.c");
|
||||
} else if (c.getType().equals(Material.GOLD_CHESTPLATE)) {
|
||||
} else if (c.getType().equals(Material.GOLDEN_CHESTPLATE)) {
|
||||
out += ChatColor.YELLOW + plugin.getLang("armor.c");
|
||||
} else if (c.getType().equals(Material.IRON_CHESTPLATE)) {
|
||||
out += ChatColor.GRAY + plugin.getLang("armor.c");
|
||||
@@ -583,7 +563,7 @@ public final class ClanManager {
|
||||
out += ChatColor.WHITE + plugin.getLang("armor.l");
|
||||
} else if (l.getType().equals(Material.DIAMOND_LEGGINGS)) {
|
||||
out += plugin.getLang("armor.l");
|
||||
} else if (l.getType().equals(Material.GOLD_LEGGINGS)) {
|
||||
} else if (l.getType().equals(Material.GOLDEN_LEGGINGS)) {
|
||||
out += plugin.getLang("armor.l");
|
||||
} else if (l.getType().equals(Material.IRON_LEGGINGS)) {
|
||||
out += plugin.getLang("armor.l");
|
||||
@@ -602,7 +582,7 @@ public final class ClanManager {
|
||||
out += ChatColor.WHITE + plugin.getLang("armor.B");
|
||||
} else if (b.getType().equals(Material.DIAMOND_BOOTS)) {
|
||||
out += ChatColor.AQUA + plugin.getLang("armor.B");
|
||||
} else if (b.getType().equals(Material.GOLD_BOOTS)) {
|
||||
} else if (b.getType().equals(Material.GOLDEN_BOOTS)) {
|
||||
out += ChatColor.YELLOW + plugin.getLang("armor.B");
|
||||
} else if (b.getType().equals(Material.IRON_BOOTS)) {
|
||||
out += ChatColor.WHITE + plugin.getLang("armor.B");
|
||||
@@ -640,7 +620,7 @@ public final class ClanManager {
|
||||
out += ChatColor.AQUA + plugin.getLang("weapon.S") + headColor + countString;
|
||||
}
|
||||
|
||||
count = getItemCount(inv.all(Material.GOLD_SWORD));
|
||||
count = getItemCount(inv.all(Material.GOLDEN_SWORD));
|
||||
|
||||
if (count > 0) {
|
||||
String countString = count > 1 ? count + "" : "";
|
||||
@@ -661,7 +641,7 @@ public final class ClanManager {
|
||||
out += ChatColor.GRAY + plugin.getLang("weapon.S") + headColor + countString;
|
||||
}
|
||||
|
||||
count = getItemCount(inv.all(Material.WOOD_SWORD));
|
||||
count = getItemCount(inv.all(Material.WOODEN_SWORD));
|
||||
|
||||
if (count > 0) {
|
||||
String countString = count > 1 ? count + "" : "";
|
||||
@@ -680,7 +660,7 @@ public final class ClanManager {
|
||||
count += getItemCount(inv.all(Material.TIPPED_ARROW));
|
||||
|
||||
if (count > 0) {
|
||||
out += ChatColor.WHITE + headColor + count;
|
||||
out += ChatColor.WHITE + plugin.getLang("weapon.A") + headColor + count;
|
||||
}
|
||||
|
||||
if (out.length() == 0) {
|
||||
@@ -724,30 +704,30 @@ public final class ClanManager {
|
||||
count += getFoodPoints(inv, Material.CAKE, 14, 2.8);
|
||||
count += getFoodPoints(inv, Material.CARROT, 3, 3.6);
|
||||
count += getFoodPoints(inv, Material.CHORUS_FRUIT, 4, 2.4);
|
||||
count += getFoodPoints(inv, Material.RAW_FISH, 2, 5, .2); //clownfish
|
||||
count += getFoodPoints(inv, Material.COOKED_CHICKEN, 6, 7.2);
|
||||
count += getFoodPoints(inv, Material.COOKED_FISH, 5, 6);
|
||||
count += getFoodPoints(inv, Material.COOKED_MUTTON, 6, 9.6);
|
||||
count += getFoodPoints(inv, Material.GRILLED_PORK, 8, 12.8);
|
||||
count += getFoodPoints(inv, Material.COOKED_PORKCHOP, 8, 12.8);
|
||||
count += getFoodPoints(inv, Material.COOKED_RABBIT, 5, 6);
|
||||
count += getFoodPoints(inv, Material.COOKED_FISH, 1, 6, 9.6); //salmon
|
||||
count += getFoodPoints(inv, Material.COOKED_SALMON, 1, 6, 9.6);
|
||||
count += getFoodPoints(inv, Material.COOKIE, 2, .4);
|
||||
count += getFoodPoints(inv, Material.GOLDEN_APPLE, 4, 9.6);
|
||||
count += getFoodPoints(inv, Material.GOLDEN_CARROT, 6, 14.4);
|
||||
count += getFoodPoints(inv, Material.MELON, 2, 1.2);
|
||||
count += getFoodPoints(inv, Material.MUSHROOM_SOUP, 6, 7.2);
|
||||
count += getFoodPoints(inv, Material.MUSHROOM_STEW, 6, 7.2);
|
||||
count += getFoodPoints(inv, Material.POISONOUS_POTATO, 2, 1.2);
|
||||
count += getFoodPoints(inv, Material.POTATO, 1, 0.6);
|
||||
count += getFoodPoints(inv, Material.RAW_FISH, 3, 1, 0.2); //pufferfish
|
||||
count += getFoodPoints(inv, Material.PUFFERFISH, 3, 1, 0.2);
|
||||
count += getFoodPoints(inv, Material.PUMPKIN_PIE, 8, 4.8);
|
||||
count += getFoodPoints(inv, Material.RABBIT_STEW, 10, 12);
|
||||
count += getFoodPoints(inv, Material.RAW_BEEF, 3, 1.8);
|
||||
count += getFoodPoints(inv, Material.RAW_CHICKEN, 2, 1.2);
|
||||
count += getFoodPoints(inv, Material.RAW_FISH, 0, 4, .4); //fish
|
||||
count += getFoodPoints(inv, Material.BEEF, 3, 1.8);
|
||||
count += getFoodPoints(inv, Material.CHICKEN, 2, 1.2);
|
||||
count += getFoodPoints(inv, Material.MUTTON, 2, 1.2);
|
||||
count += getFoodPoints(inv, Material.PORK, 3, 1.8);
|
||||
count += getFoodPoints(inv, Material.PORKCHOP, 3, 1.8);
|
||||
count += getFoodPoints(inv, Material.RABBIT, 3, 1.8);
|
||||
count += getFoodPoints(inv, Material.RAW_FISH, 1, .4); //raw salmon
|
||||
count += getFoodPoints(inv, Material.SALMON, 1, .4);
|
||||
count += getFoodPoints(inv, Material.COD, 2, .4);
|
||||
count += getFoodPoints(inv, Material.COOKED_COD, 5, 6);
|
||||
count += getFoodPoints(inv, Material.TROPICAL_FISH, 1, .2);
|
||||
count += getFoodPoints(inv, Material.ROTTEN_FLESH, 4, .8);
|
||||
count += getFoodPoints(inv, Material.SPIDER_EYE, 2, 3.2);
|
||||
count += getFoodPoints(inv, Material.COOKED_BEEF, 8, 12.8);
|
||||
@@ -806,6 +786,90 @@ public final class ClanManager {
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by active
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*/
|
||||
public void sortClansByActive(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
int o = 1;
|
||||
if (!asc) {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Long) c1.getLastUsed()).compareTo(c2.getLastUsed()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by founded date
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*/
|
||||
public void sortClansByFounded(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
int o = 1;
|
||||
if (!asc) {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Long) c1.getFounded()).compareTo(c2.getFounded()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by kdr
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*/
|
||||
public void sortClansByKDR(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
int o = 1;
|
||||
if (!asc) {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Float) c1.getTotalKDR()).compareTo(c2.getTotalKDR()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by size
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*/
|
||||
public void sortClansBySize(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
int o = 1;
|
||||
if (!asc) {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Integer) c1.getSize()).compareTo(c2.getSize()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by name
|
||||
*
|
||||
* @param clans
|
||||
*/
|
||||
public void sortClansByName(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
int o = 1;
|
||||
if (!asc) {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return c1.getName().compareTo(c2.getName()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by KDR
|
||||
@@ -880,6 +944,32 @@ public final class ClanManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Purchase member fee set
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseMemberFeeSet(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseMemberFeeSet()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
double price = plugin.getSettingsManager().geteMemberFeeSetPrice();
|
||||
|
||||
if (plugin.getPermissionsManager().hasEconomy()) {
|
||||
if (plugin.getPermissionsManager().playerHasMoney(player, price)) {
|
||||
plugin.getPermissionsManager().playerChargeMoney(player, price);
|
||||
player.sendMessage(ChatColor.RED + MessageFormat.format(plugin.getLang("account.has.been.debited"), price));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + plugin.getLang("not.sufficient.money"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purchase clan creation
|
||||
@@ -984,10 +1074,10 @@ public final class ClanManager {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Purchase Reset Kdr
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
@@ -995,9 +1085,9 @@ public final class ClanManager {
|
||||
if (!plugin.getSettingsManager().isePurchaseResetKdr()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
double price = plugin.getSettingsManager().geteResetKdr();
|
||||
|
||||
|
||||
if (plugin.getPermissionsManager().hasEconomy()) {
|
||||
if (plugin.getPermissionsManager().playerHasMoney(player, price)) {
|
||||
plugin.getPermissionsManager().playerChargeMoney(player, price);
|
||||
@@ -1101,8 +1191,8 @@ public final class ClanManager {
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void processClanChat(Player player, String msg) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
public void processClanChat(Player player, final String msg) {
|
||||
final ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
return;
|
||||
@@ -1119,51 +1209,56 @@ public final class ClanManager {
|
||||
if (command.equals(plugin.getLang("on"))) {
|
||||
cp.setClanChat(true);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have enabled clan chat");
|
||||
ChatBlock.sendMessage(player, lang("enabled.clan.chat", player));
|
||||
} else if (command.equals(plugin.getLang("off"))) {
|
||||
cp.setClanChat(false);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have disabled clan chat");
|
||||
ChatBlock.sendMessage(player, lang("disabled.clan.chat", player));
|
||||
} else if (command.equals(plugin.getLang("join"))) {
|
||||
cp.setChannel(ClanPlayer.Channel.CLAN);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have joined clan chat");
|
||||
ChatBlock.sendMessage(player, lang("joined.clan.chat", player));
|
||||
} else if (command.equals(plugin.getLang("leave"))) {
|
||||
cp.setChannel(ClanPlayer.Channel.NONE);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have left clan chat");
|
||||
ChatBlock.sendMessage(player, lang("left.clan.chat", player));
|
||||
} else if (command.equals(plugin.getLang("mute"))) {
|
||||
if (cp.isMuted()) {
|
||||
cp.setMuted(true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have muted clan chat");
|
||||
ChatBlock.sendMessage(player, lang("muted.clan.chat", player));
|
||||
} else {
|
||||
cp.setMuted(false);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have unmuted clan chat");
|
||||
ChatBlock.sendMessage(player, lang("unmuted.clan.chat", player));
|
||||
}
|
||||
} else {
|
||||
List<ClanPlayer> receivers = new LinkedList<>();
|
||||
final List<ClanPlayer> receivers = new LinkedList<>();
|
||||
for (ClanPlayer p : cp.getClan().getOnlineMembers()) {
|
||||
if (!p.isMuted()) {
|
||||
receivers.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
ChatEvent ce = new ChatEvent(msg, cp, receivers, ChatEvent.Type.CLAN);
|
||||
Bukkit.getServer().getPluginManager().callEvent(ce);
|
||||
|
||||
if (ce.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Helper.formatClanChat(cp, ce.getMessage(), ce.getPlaceholders());
|
||||
String eyeMessage = Helper.formatSpyClanChat(cp, message);
|
||||
plugin.getServer().getConsoleSender().sendMessage(eyeMessage);
|
||||
|
||||
for (ClanPlayer p : ce.getReceivers()) {
|
||||
ChatBlock.sendMessage(p.toPlayer(), message);
|
||||
}
|
||||
|
||||
sendToAllSeeing(eyeMessage, ce.getReceivers());
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatEvent ce = new ChatEvent(msg, cp, receivers, ChatEvent.Type.CLAN);
|
||||
Bukkit.getServer().getPluginManager().callEvent(ce);
|
||||
|
||||
if (ce.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Helper.formatClanChat(cp, ce.getMessage(), ce.getPlaceholders());
|
||||
String eyeMessage = Helper.formatSpyClanChat(cp, message);
|
||||
plugin.getServer().getConsoleSender().sendMessage(eyeMessage);
|
||||
|
||||
for (ClanPlayer p : ce.getReceivers()) {
|
||||
ChatBlock.sendMessage(p.toPlayer(), message);
|
||||
}
|
||||
|
||||
sendToAllSeeing(eyeMessage, ce.getReceivers());
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1199,8 +1294,8 @@ public final class ClanManager {
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void processAllyChat(Player player, String msg) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
public void processAllyChat(Player player, final String msg) {
|
||||
final ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp == null) {
|
||||
return;
|
||||
@@ -1217,63 +1312,62 @@ public final class ClanManager {
|
||||
if (command.equals(plugin.getLang("on"))) {
|
||||
cp.setAllyChat(true);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have enabled ally chat");
|
||||
ChatBlock.sendMessage(player, lang("enabled.ally.chat", player));
|
||||
} else if (command.equals(plugin.getLang("off"))) {
|
||||
cp.setAllyChat(false);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have disabled ally chat");
|
||||
ChatBlock.sendMessage(player, lang("disabled.ally.chat", player));
|
||||
} else if (command.equals(plugin.getLang("join"))) {
|
||||
cp.setChannel(ClanPlayer.Channel.ALLY);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have joined ally chat");
|
||||
ChatBlock.sendMessage(player, lang("joined.ally.chat", player));
|
||||
} else if (command.equals(plugin.getLang("leave"))) {
|
||||
cp.setChannel(ClanPlayer.Channel.NONE);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have left ally chat");
|
||||
ChatBlock.sendMessage(player, lang("left.ally.chat", player));
|
||||
} else if (command.equals(plugin.getLang("mute"))) {
|
||||
if (!cp.isMutedAlly()) {
|
||||
cp.setMutedAlly(true);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have muted ally chat");
|
||||
ChatBlock.sendMessage(player, lang("muted.ally.chat", player));
|
||||
} else {
|
||||
cp.setMutedAlly(false);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + "You have unmuted ally chat");
|
||||
ChatBlock.sendMessage(player, lang("unmuted.ally.chat", player));
|
||||
}
|
||||
} else {
|
||||
List<ClanPlayer> receivers = new LinkedList<>();
|
||||
final List<ClanPlayer> receivers = new LinkedList<>();
|
||||
Set<ClanPlayer> allies = cp.getClan().getAllAllyMembers();
|
||||
allies.addAll(cp.getClan().getMembers());
|
||||
for (ClanPlayer ally : allies) {
|
||||
if (ally.isMutedAlly()) {
|
||||
continue;
|
||||
}
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
if (player.getUniqueId().equals(ally.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (player.getName().equalsIgnoreCase(ally.getName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (player.getUniqueId().equals(ally.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
receivers.add(ally);
|
||||
}
|
||||
|
||||
ChatEvent ce = new ChatEvent(msg, cp, receivers, ChatEvent.Type.ALLY);
|
||||
Bukkit.getServer().getPluginManager().callEvent(ce);
|
||||
|
||||
if (ce.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Helper.formatAllyChat(cp, ce.getMessage(), ce.getPlaceholders());
|
||||
SimpleClans.log(message);
|
||||
|
||||
Player self = cp.toPlayer();
|
||||
ChatBlock.sendMessage(self, message);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChatEvent ce = new ChatEvent(msg, cp, receivers, ChatEvent.Type.ALLY);
|
||||
Bukkit.getServer().getPluginManager().callEvent(ce);
|
||||
|
||||
for (ClanPlayer p : ce.getReceivers()) {
|
||||
ChatBlock.sendMessage(p.toPlayer(), message);
|
||||
}
|
||||
if (ce.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Helper.formatAllyChat(cp, ce.getMessage(), ce.getPlaceholders());
|
||||
plugin.getLogger().info(message);
|
||||
|
||||
Player self = cp.toPlayer();
|
||||
ChatBlock.sendMessage(self, message);
|
||||
|
||||
for (ClanPlayer p : ce.getReceivers()) {
|
||||
ChatBlock.sendMessage(p.toPlayer(), message);
|
||||
}
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1285,12 +1379,7 @@ public final class ClanManager {
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean processGlobalChat(Player player, String msg) {
|
||||
ClanPlayer cp;
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
|
||||
} else {
|
||||
cp = plugin.getClanManager().getClanPlayer(player.getName());
|
||||
}
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
|
||||
|
||||
if (cp == null) {
|
||||
return false;
|
||||
|
||||
@@ -7,16 +7,16 @@ import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public class LanguageManager {
|
||||
private File file;
|
||||
private HashMap<String, String> language;
|
||||
private String[] comments = new String[]{};
|
||||
|
||||
public LanguageManager() {
|
||||
load();
|
||||
//load();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -85,6 +85,6 @@ public class LanguageManager {
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
return "Missing language for "+key;
|
||||
}
|
||||
}
|
||||
+166
-8
@@ -3,19 +3,27 @@ package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
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.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -24,14 +32,14 @@ public final class PermissionsManager {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private SimpleClans plugin;
|
||||
private final SimpleClans plugin;
|
||||
|
||||
private static Permission permission = null;
|
||||
private static Economy economy = null;
|
||||
private static Chat chat = null;
|
||||
|
||||
private HashMap<String, List<String>> permissions = new HashMap<>();
|
||||
private HashMap<Player, PermissionAttachment> permAttaches = new HashMap<>();
|
||||
private final HashMap<String, List<String>> permissions = new HashMap<>();
|
||||
private final HashMap<Player, PermissionAttachment> permAttaches = new HashMap<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -46,12 +54,12 @@ public final class PermissionsManager {
|
||||
setupEconomy();
|
||||
setupPermissions();
|
||||
} catch (ClassNotFoundException e) {
|
||||
SimpleClans.log("[SimpleClans] Vault not found. No economy or extended Permissions support.");
|
||||
SimpleClans.getInstance().getLogger().info("Vault not found. No economy or extended Permissions support.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether exonomy plugin exists and is enabled
|
||||
* Whether economy plugin exists and is enabled
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -71,7 +79,7 @@ public final class PermissionsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the permissions for earch clan from the config
|
||||
* Saves the permissions for each clan from the config
|
||||
*/
|
||||
public void savePermissions() {
|
||||
for (Clan clan : plugin.getClanManager().getClans()) {
|
||||
@@ -79,11 +87,12 @@ public final class PermissionsManager {
|
||||
SimpleClans.getInstance().getSettingsManager().getConfig().set("permissions." + clan.getTag(), getPermissions(clan));
|
||||
}
|
||||
}
|
||||
SimpleClans.getInstance().getSettingsManager().load();
|
||||
SimpleClans.getInstance().getSettingsManager().save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all pemrissions for a clan
|
||||
* Adds all permissions for a clan
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
@@ -157,6 +166,29 @@ public final class PermissionsManager {
|
||||
public Map<Player, PermissionAttachment> getPermAttaches() {
|
||||
return permAttaches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean playerChargeMoney(String player, double money) {
|
||||
return economy.withdrawPlayer(player, money).transactionSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
public boolean playerChargeMoney(OfflinePlayer player, double money) {
|
||||
return economy.withdrawPlayer(player, money).transactionSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge a player some money
|
||||
@@ -166,7 +198,7 @@ public final class PermissionsManager {
|
||||
* @return
|
||||
*/
|
||||
public boolean playerChargeMoney(Player player, double money) {
|
||||
return economy.withdrawPlayer(player, money).transactionSuccess();
|
||||
return playerChargeMoney((OfflinePlayer) player, money);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,6 +256,22 @@ public final class PermissionsManager {
|
||||
return economy.getBalance(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permissions
|
||||
*
|
||||
* @param world the world
|
||||
* @param player the player
|
||||
* @param perm the permission
|
||||
* @return whether he has the permission
|
||||
*/
|
||||
public boolean has(String world, OfflinePlayer player, String perm) {
|
||||
if (player != null && permission != null) {
|
||||
return permission.playerHas(world, player, perm);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permissions
|
||||
*
|
||||
@@ -242,6 +290,116 @@ public final class PermissionsManager {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has the rank permission or the permission level, and the equivalent Bukkit permission
|
||||
*
|
||||
* @param player the player
|
||||
* @param permission the rank permission
|
||||
* @param notify notify the player if they don't have permission
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean has(Player player, RankPermission permission, PermissionLevel level, boolean notify) {
|
||||
if (player == null || permission == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ClanPlayer clanPlayer = plugin.getClanManager().getClanPlayer(player);
|
||||
if (clanPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasBukkitPermission = has(player, permission.getBukkitPermission());
|
||||
if (!hasBukkitPermission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasLevel = false;
|
||||
if (level != null) {
|
||||
switch (level) {
|
||||
case LEADER:
|
||||
hasLevel = clanPlayer.isLeader();
|
||||
break;
|
||||
case TRUSTED:
|
||||
hasLevel = clanPlayer.isTrusted();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasRankPermission = false;
|
||||
String rankName = clanPlayer.getRankId();
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan.hasRank(rankName)) {
|
||||
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
|
||||
} else {
|
||||
if (rankName != null && !rankName.isEmpty()) {
|
||||
clanPlayer.setRank(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (notify && !hasLevel && !hasRankPermission) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("you.must.be.0.or.have.the.permission.1.to.use.this"),
|
||||
level == PermissionLevel.LEADER ? lang("leader") : lang("trusted"), permission.toString()));
|
||||
}
|
||||
|
||||
return hasLevel || hasRankPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has the rank permission or the permission level, and the equivalent Bukkit permission
|
||||
*
|
||||
* @param player the player
|
||||
* @param permission the rank permission
|
||||
* @param notify notify the player if they don't have permission
|
||||
* @return
|
||||
*/
|
||||
public boolean has(Player player, RankPermission permission, boolean notify) {
|
||||
if (player == null || permission == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ClanPlayer clanPlayer = plugin.getClanManager().getClanPlayer(player);
|
||||
if (clanPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasBukkitPermission = has(player, permission.getBukkitPermission());
|
||||
if (!hasBukkitPermission) {
|
||||
if (notify) {
|
||||
ChatBlock.sendMessage(player, lang(ChatColor.RED + "insufficient.permissions"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasLevel = false;
|
||||
switch (permission.getPermissionLevel()) {
|
||||
case LEADER:
|
||||
hasLevel = clanPlayer.isLeader();
|
||||
break;
|
||||
case TRUSTED:
|
||||
hasLevel = clanPlayer.isTrusted();
|
||||
break;
|
||||
}
|
||||
|
||||
boolean hasRankPermission = false;
|
||||
String rankName = clanPlayer.getRankId();
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan.hasRank(rankName)) {
|
||||
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
|
||||
} else {
|
||||
if (rankName != null && !rankName.isEmpty()) {
|
||||
clanPlayer.setRank(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (notify && !hasLevel && !hasRankPermission) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + MessageFormat.format(lang("you.must.be.0.or.have.the.permission.1.to.use.this"),
|
||||
permission.getPermissionLevel() == PermissionLevel.LEADER ? lang("leader") : lang("trusted"), permission.toString()));
|
||||
}
|
||||
|
||||
return hasLevel || hasRankPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the player permissions linked to a clan
|
||||
|
||||
+319
@@ -0,0 +1,319 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.PlaceholderHook;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanFalse;
|
||||
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanTrue;
|
||||
|
||||
/**
|
||||
* {@link Class} to manage and hook {@link SimpleClans} into {@link PlaceholderAPI}
|
||||
*
|
||||
* @since 2.10.1
|
||||
*
|
||||
* @author Peng1104
|
||||
*/
|
||||
|
||||
public final class PlaceholdersManager {
|
||||
|
||||
private static final String TOP_CLANS_IDENTIFIER = "topclans_";
|
||||
|
||||
/**
|
||||
* The {@link SimpleClans} {@link Plugin} instance
|
||||
*
|
||||
* @since 2.10.1
|
||||
*/
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
/**
|
||||
* The {@link PlaceholdersManager} constructor
|
||||
*
|
||||
* @since 2.10.1
|
||||
*/
|
||||
|
||||
public PlaceholdersManager(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
setupPlaceholderAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the {@link PlaceholderAPI} hook
|
||||
*
|
||||
* @since 2.10.1
|
||||
*/
|
||||
|
||||
private void setupPlaceholderAPI() {
|
||||
PlaceholderAPI.registerPlaceholderHook(plugin.getName(), new PlaceholderHook() {
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String identifier) {
|
||||
return onRequest(player, identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(OfflinePlayer player, String identifier) {
|
||||
ClanPlayer clanPlayer = null;
|
||||
if (player != null) {
|
||||
clanPlayer = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
}
|
||||
return getPlaceholderValue(clanPlayer, identifier);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value for the requested {@link ClanPlayer} and identifier
|
||||
*
|
||||
* @param player The {@link ClanPlayer} to request the placeholders value for
|
||||
* @param identifier String that determine what value to return
|
||||
*
|
||||
* @return value for the requested {@link ClanPlayer} and params
|
||||
*
|
||||
* @since 2.10.1
|
||||
*/
|
||||
@NotNull
|
||||
public String getPlaceholderValue(@Nullable ClanPlayer player, String identifier) {
|
||||
if (identifier.startsWith(TOP_CLANS_IDENTIFIER)) {
|
||||
return getTopClansPlaceholderValue(identifier);
|
||||
}
|
||||
|
||||
if (player == null) return "";
|
||||
|
||||
Clan clan = player.getClan();
|
||||
|
||||
switch (identifier) {
|
||||
case "neutral_kills": {
|
||||
return String.valueOf(player.getNeutralKills());
|
||||
}
|
||||
case "rival_kills": {
|
||||
return String.valueOf(player.getRivalKills());
|
||||
}
|
||||
case "civilian_kills": {
|
||||
return String.valueOf(player.getCivilianKills());
|
||||
}
|
||||
case "total_kills": {
|
||||
return String.valueOf(player.getNeutralKills() + player.getRivalKills() + player.getCivilianKills());
|
||||
}
|
||||
case "weighted_kills": {
|
||||
return String.valueOf(player.getWeightedKills());
|
||||
}
|
||||
case "deaths": {
|
||||
return String.valueOf(player.getDeaths());
|
||||
}
|
||||
case "kdr": {
|
||||
return String.valueOf(player.getKDR());
|
||||
}
|
||||
case "in_clan": {
|
||||
return (clan != null) ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_leader": {
|
||||
return player.isLeader() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_trusted": {
|
||||
return (!player.isLeader() && player.isTrusted()) ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_member": {
|
||||
return (!player.isTrusted() && !player.isLeader() && clan != null) ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_bb_enabled": {
|
||||
return player.isBbEnabled() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_usechatshortcut": {
|
||||
return player.isUseChatShortcut() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_allychat": {
|
||||
return player.isAllyChat() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_clanchat": {
|
||||
return player.isClanChat() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_globalchat": {
|
||||
return player.isGlobalChat() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_cape_enabled": {
|
||||
return player.isCapeEnabled() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_tag_enabled": {
|
||||
return player.isTagEnabled() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_friendlyfire_on": {
|
||||
return player.isFriendlyFire() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_muted": {
|
||||
return player.isMuted() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "is_mutedally": {
|
||||
return player.isMutedAlly() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "join_date": {
|
||||
return player.getJoinDateString();
|
||||
}
|
||||
case "inactive_days": {
|
||||
return String.valueOf(player.getInactiveDays());
|
||||
}
|
||||
case "lastseen": {
|
||||
return player.getLastSeenString();
|
||||
}
|
||||
case "lastseendays": {
|
||||
return player.getLastSeenDaysString();
|
||||
}
|
||||
case "tag": {
|
||||
return player.getTag();
|
||||
}
|
||||
case "tag_label": {
|
||||
return player.getTagLabel();
|
||||
}
|
||||
case "rank": {
|
||||
return player.getRankId();
|
||||
}
|
||||
case "rank_displayname": {
|
||||
return player.getRankDisplayName();
|
||||
}
|
||||
case "clanchat_player_color": {
|
||||
if (player.isLeader()) return plugin.getSettingsManager().getClanChatLeaderColor();
|
||||
if (player.isTrusted()) return plugin.getSettingsManager().getClanChatTrustedColor();
|
||||
if (clan != null) return plugin.getSettingsManager().getClanChatMemberColor();
|
||||
return "";
|
||||
}
|
||||
case "allychat_player_color": {
|
||||
if (player.isLeader()) return plugin.getSettingsManager().getAllyChatLeaderColor();
|
||||
if (player.isTrusted()) return plugin.getSettingsManager().getAllyChatTrustedColor();
|
||||
if (clan != null) return plugin.getSettingsManager().getAllyChatMemberColor();
|
||||
return "";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (clan == null) return "";
|
||||
|
||||
switch (identifier) {
|
||||
case "clan_total_neutral": {
|
||||
return String.valueOf(clan.getTotalNeutral());
|
||||
}
|
||||
case "clan_total_civilian": {
|
||||
return String.valueOf(clan.getTotalCivilian());
|
||||
}
|
||||
case "clan_total_rival": {
|
||||
return String.valueOf(clan.getTotalRival());
|
||||
}
|
||||
case "clan_total_kills": {
|
||||
return String.valueOf(clan.getTotalRival() + clan.getTotalNeutral() + clan.getTotalCivilian());
|
||||
}
|
||||
case "clan_total_deaths": {
|
||||
return String.valueOf(clan.getTotalDeaths());
|
||||
}
|
||||
case "clan_total_kdr": {
|
||||
return String.valueOf(clan.getTotalKDR());
|
||||
}
|
||||
case "clan_average_wk": {
|
||||
return String.valueOf(clan.getAverageWK());
|
||||
}
|
||||
case "clan_leader_size": {
|
||||
return String.valueOf(clan.getLeaders().size());
|
||||
}
|
||||
case "clan_balance": {
|
||||
return String.valueOf(clan.getBalance());
|
||||
}
|
||||
case "clan_allow_withdraw": {
|
||||
return clan.isAllowWithdraw() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "clan_allow_deposit": {
|
||||
return clan.isAllowDeposit() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "clan_size": {
|
||||
return String.valueOf(clan.getSize());
|
||||
}
|
||||
case "clan_name": {
|
||||
return clan.getName();
|
||||
}
|
||||
case "clan_color_tag": {
|
||||
return clan.getColorTag();
|
||||
}
|
||||
case "clan_tag": {
|
||||
return clan.getTag();
|
||||
}
|
||||
case "clan_founded": {
|
||||
return clan.getFoundedString();
|
||||
}
|
||||
case "clan_friendly_fire": {
|
||||
return clan.isFriendlyFire() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "clan_is_unrivable": {
|
||||
return clan.isUnrivable() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "clan_is_anyonline": {
|
||||
return clan.isAnyOnline() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "clan_is_verified": {
|
||||
return clan.isVerified() ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
case "clan_capeurl": {
|
||||
return clan.getCapeUrl();
|
||||
}
|
||||
case "clan_inactivedays": {
|
||||
return String.valueOf(clan.getInactiveDays());
|
||||
}
|
||||
case "clan_onlinemembers_count": {
|
||||
return String.valueOf(clan.getOnlineMembers().size());
|
||||
}
|
||||
case "clan_allies_count": {
|
||||
return String.valueOf(clan.getAllies().size());
|
||||
}
|
||||
case "clan_rivals_count": {
|
||||
return String.valueOf(clan.getRivals().size());
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param identifier String that determine what value to return
|
||||
* @return value for the requested identifier and params
|
||||
*/
|
||||
private String getTopClansPlaceholderValue(String identifier) {
|
||||
//getting the position
|
||||
int position;
|
||||
try {
|
||||
position = Integer.parseInt(identifier.substring(TOP_CLANS_IDENTIFIER.length(),
|
||||
identifier.indexOf('_', TOP_CLANS_IDENTIFIER.length())));
|
||||
} catch (NumberFormatException ex) {
|
||||
return "";
|
||||
}
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
//validating position
|
||||
if (position < 1 || position > clans.size()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
plugin.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
Clan clan = clans.get(position - 1);
|
||||
if (identifier.endsWith("_color_tag")) {
|
||||
return clan.getColorTag();
|
||||
}
|
||||
if (identifier.endsWith("_kdr")) {
|
||||
return String.valueOf(clan.getTotalKDR());
|
||||
}
|
||||
if (identifier.endsWith("_total_kills")) {
|
||||
int totalKills = clan.getTotalCivilian() + clan.getTotalNeutral() + clan.getTotalRival();
|
||||
return String.valueOf(totalKills);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+209
-167
@@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -43,15 +44,19 @@ public final class RequestManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void addDemoteRequest(ClanPlayer requester, String demotedName, Clan clan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("asking.for.the.demotion"), Helper.capitalize(requester.getName()), demotedName);
|
||||
if (requests.containsKey(clan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("asking.for.the.demotion"), requester.getName(), demotedName);
|
||||
|
||||
ClanPlayer demotedTp = plugin.getClanManager().getClanPlayer(demotedName.toLowerCase());
|
||||
ClanPlayer demotedTp = plugin.getClanManager().getClanPlayer(UUIDMigration.getForcedPlayerUUID(demotedName));
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
acceptors.remove(demotedTp);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.DEMOTE, acceptors, requester, demotedName, clan, msg);
|
||||
requests.put(clan.getTag(), req);
|
||||
req.vote(requester.getName(), VoteResult.ACCEPT);
|
||||
requests.put(req.getClan().getTag(), req);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -63,13 +68,16 @@ public final class RequestManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void addPromoteRequest(ClanPlayer requester, String promotedName, Clan clan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("asking.for.the.promotion"), Helper.capitalize(requester.getName()), promotedName);
|
||||
if (requests.containsKey(clan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("asking.for.the.promotion"), requester.getName(), promotedName);
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
acceptors.remove(requester);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.PROMOTE, acceptors, requester, promotedName, clan, msg);
|
||||
requests.put(clan.getTag(), req);
|
||||
requests.put(req.getClan().getTag(), req);
|
||||
req.vote(requester.getName(), VoteResult.ACCEPT);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -80,13 +88,16 @@ public final class RequestManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void addDisbandRequest(ClanPlayer requester, Clan clan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("asking.for.the.deletion"), Helper.capitalize(requester.getName()));
|
||||
if (requests.containsKey(clan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("asking.for.the.deletion"), requester.getName());
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(clan.getLeaders());
|
||||
acceptors.remove(requester);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.DISBAND, acceptors, requester, clan.getTag(), clan, msg);
|
||||
requests.put(clan.getTag(), req);
|
||||
requests.put(req.getTarget(), req);
|
||||
req.vote(requester.getName(), VoteResult.ACCEPT);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -98,7 +109,10 @@ public final class RequestManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void addInviteRequest(ClanPlayer requester, String invitedName, Clan clan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("inviting.you.to.join"), Helper.capitalize(requester.getName()), clan.getName());
|
||||
if (requests.containsKey(invitedName.toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("inviting.you.to.join"), requester.getName(), clan.getName());
|
||||
Request req = new Request(plugin, ClanRequest.INVITE, null, requester, invitedName, clan, msg);
|
||||
requests.put(invitedName.toLowerCase(), req);
|
||||
ask(req);
|
||||
@@ -112,13 +126,16 @@ public final class RequestManager {
|
||||
* @param requestingClan
|
||||
*/
|
||||
public void addWarStartRequest(ClanPlayer requester, Clan warClan, Clan requestingClan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.war"), Helper.capitalize(requestingClan.getName()), Helper.stripColors(warClan.getColorTag()));
|
||||
if (requests.containsKey(warClan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.war"), requestingClan.getName(), Helper.stripColors(warClan.getColorTag()));
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(warClan.getLeaders());
|
||||
acceptors.remove(requester);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.START_WAR, acceptors, requester, warClan.getTag(), requestingClan, msg);
|
||||
requests.put(warClan.getTag(), req);
|
||||
requests.put(req.getTarget(), req);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -130,13 +147,16 @@ public final class RequestManager {
|
||||
* @param requestingClan
|
||||
*/
|
||||
public void addWarEndRequest(ClanPlayer requester, Clan warClan, Clan requestingClan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.to.end.the.war"), Helper.capitalize(requestingClan.getName()), Helper.stripColors(warClan.getColorTag()));
|
||||
if (requests.containsKey(warClan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.to.end.the.war"), requestingClan.getName(), Helper.stripColors(warClan.getColorTag()));
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(warClan.getLeaders());
|
||||
acceptors.remove(requester);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.END_WAR, acceptors, requester, warClan.getTag(), requestingClan, msg);
|
||||
requests.put(warClan.getTag(), req);
|
||||
requests.put(req.getTarget(), req);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -148,13 +168,16 @@ public final class RequestManager {
|
||||
* @param requestingClan
|
||||
*/
|
||||
public void addAllyRequest(ClanPlayer requester, Clan allyClan, Clan requestingClan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.an.alliance"), Helper.capitalize(requestingClan.getName()), Helper.stripColors(allyClan.getColorTag()));
|
||||
if (requests.containsKey(allyClan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.an.alliance"), requestingClan.getName(), Helper.stripColors(allyClan.getColorTag()));
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(allyClan.getLeaders());
|
||||
acceptors.remove(requester);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.CREATE_ALLY, acceptors, requester, allyClan.getTag(), requestingClan, msg);
|
||||
requests.put(allyClan.getTag(), req);
|
||||
requests.put(req.getTarget(), req);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -166,13 +189,16 @@ public final class RequestManager {
|
||||
* @param requestingClan
|
||||
*/
|
||||
public void addRivalryBreakRequest(ClanPlayer requester, Clan rivalClan, Clan requestingClan) {
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.to.end.the.rivalry"), Helper.capitalize(requestingClan.getName()), Helper.stripColors(rivalClan.getColorTag()));
|
||||
if (requests.containsKey(rivalClan.getTag())) {
|
||||
return;
|
||||
}
|
||||
String msg = MessageFormat.format(plugin.getLang("proposing.to.end.the.rivalry"), requestingClan.getName(), Helper.stripColors(rivalClan.getColorTag()));
|
||||
|
||||
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(rivalClan.getLeaders());
|
||||
acceptors.remove(requester);
|
||||
|
||||
Request req = new Request(plugin, ClanRequest.BREAK_RIVALRY, acceptors, requester, rivalClan.getTag(), requestingClan, msg);
|
||||
requests.put(rivalClan.getTag(), req);
|
||||
requests.put(req.getTarget(), req);
|
||||
ask(req);
|
||||
}
|
||||
|
||||
@@ -232,160 +258,171 @@ public final class RequestManager {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(ChatColor.AQUA + MessageFormat.format(plugin.getLang("joined.the.clan"), Helper.capitalize(invited)));
|
||||
plugin.getClanManager().serverAnnounce(MessageFormat.format(plugin.getLang("has.joined"), Helper.capitalize(invited), clan.getName()));
|
||||
clan.addBb(ChatColor.AQUA + MessageFormat.format(plugin.getLang("joined.the.clan"), invited));
|
||||
plugin.getClanManager().serverAnnounce(MessageFormat.format(plugin.getLang("has.joined"), invited, clan.getName()));
|
||||
clan.addPlayerToClan(cp);
|
||||
} else {
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("membership.invitation"), Helper.capitalize(invited)));
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("membership.invitation"), invited));
|
||||
}
|
||||
|
||||
requests.remove(req.getTarget().toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check to see if votes are complete and process the result
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
public void processResults(Request req) {
|
||||
if (req.getType().equals(ClanRequest.START_WAR)) {
|
||||
Clan clan = req.getClan();
|
||||
Clan war = plugin.getClanManager().getClan(req.getTarget());
|
||||
ClanPlayer cp = req.getRequester();
|
||||
|
||||
if (war != null && clan != null) {
|
||||
List<String> accepts = req.getAccepts();
|
||||
List<String> denies = req.getDenies();
|
||||
|
||||
if (!accepts.isEmpty()) {
|
||||
clan.addWarringClan(war);
|
||||
war.addWarringClan(clan);
|
||||
|
||||
war.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.at.war"), Helper.capitalize(war.getName()), clan.getColorTag()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.at.war"), Helper.capitalize(clan.getName()), war.getColorTag()));
|
||||
} else {
|
||||
war.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.war.req"), Helper.capitalize(denies.get(0)), clan.getName()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("end.war.denied"), Helper.capitalize(war.getName())));
|
||||
}
|
||||
}
|
||||
} else if (req.getType().equals(ClanRequest.END_WAR)) {
|
||||
Clan clan = req.getClan();
|
||||
Clan war = plugin.getClanManager().getClan(req.getTarget());
|
||||
ClanPlayer cp = req.getRequester();
|
||||
|
||||
if (war != null && clan != null) {
|
||||
List<String> accepts = req.getAccepts();
|
||||
List<String> denies = req.getDenies();
|
||||
|
||||
if (!accepts.isEmpty()) {
|
||||
clan.removeWarringClan(war);
|
||||
war.removeWarringClan(clan);
|
||||
|
||||
war.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.no.longer.at.war"), Helper.capitalize(accepts.get(0)), clan.getColorTag()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.no.longer.at.war"), Helper.capitalize(clan.getName()), Helper.capitalize(war.getColorTag())));
|
||||
} else {
|
||||
war.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.war.end"), Helper.capitalize(denies.get(0)), clan.getName()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("end.war.denied"), Helper.capitalize(war.getName())));
|
||||
}
|
||||
}
|
||||
} else if (req.getType().equals(ClanRequest.CREATE_ALLY)) {
|
||||
Clan clan = req.getClan();
|
||||
Clan ally = plugin.getClanManager().getClan(req.getTarget());
|
||||
ClanPlayer cp = req.getRequester();
|
||||
|
||||
if (ally != null && clan != null) {
|
||||
List<String> accepts = req.getAccepts();
|
||||
List<String> denies = req.getDenies();
|
||||
|
||||
if (!accepts.isEmpty()) {
|
||||
clan.addAlly(ally);
|
||||
|
||||
ally.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("accepted.an.alliance"), Helper.capitalize(accepts.get(0)), clan.getName()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("created.an.alliance"), Helper.capitalize(cp.getName()), Helper.capitalize(ally.getName())));
|
||||
} else {
|
||||
ally.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.an.alliance"), Helper.capitalize(denies.get(0)), clan.getName()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("the.alliance.was.denied"), Helper.capitalize(ally.getName())));
|
||||
}
|
||||
}
|
||||
} else if (req.getType().equals(ClanRequest.BREAK_RIVALRY)) {
|
||||
Clan clan = req.getClan();
|
||||
Clan rival = plugin.getClanManager().getClan(req.getTarget());
|
||||
ClanPlayer cp = req.getRequester();
|
||||
|
||||
if (rival != null && clan != null) {
|
||||
List<String> accepts = req.getAccepts();
|
||||
List<String> denies = req.getDenies();
|
||||
|
||||
if (!accepts.isEmpty()) {
|
||||
clan.removeRival(rival);
|
||||
rival.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("broken.the.rivalry"), Helper.capitalize(accepts.get(0)), clan.getName()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("broken.the.rivalry.with"), Helper.capitalize(cp.getName()), Helper.capitalize(rival.getName())));
|
||||
} else {
|
||||
rival.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.to.make.peace"), Helper.capitalize(denies.get(0)), clan.getName()));
|
||||
clan.addBb(cp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("peace.agreement.denied"), Helper.capitalize(rival.getName())));
|
||||
}
|
||||
}
|
||||
} else if (req.votingFinished()) {
|
||||
List<String> denies = req.getDenies();
|
||||
|
||||
if (req.getType().equals(ClanRequest.DEMOTE)) {
|
||||
Clan clan = req.getClan();
|
||||
String demoted = req.getTarget();
|
||||
UUID demotedUniqueId = UUIDMigration.getForcedPlayerUUID(demoted);
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID() && demotedUniqueId != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (denies.isEmpty()) {
|
||||
clan.addBb(plugin.getLang("leaders"), ChatColor.AQUA + MessageFormat.format(plugin.getLang("demoted.back.to.member"), Helper.capitalize(demoted)));
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
clan.demote(demotedUniqueId);
|
||||
} else {
|
||||
clan.demote(demoted);
|
||||
}
|
||||
} else {
|
||||
String deniers = Helper.capitalize(Helper.toMessage(Helper.toArray(denies), ", "));
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("denied.demotion"), deniers, demoted));
|
||||
}
|
||||
} else if (req.getType().equals(ClanRequest.PROMOTE)) {
|
||||
Clan clan = req.getClan();
|
||||
String promoted = req.getTarget();
|
||||
UUID promotedUniqueId = UUIDMigration.getForcedPlayerUUID(promoted);
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID() && promotedUniqueId == null) {
|
||||
return;
|
||||
}
|
||||
if (denies.isEmpty()) {
|
||||
clan.addBb(plugin.getLang("leaders"), ChatColor.AQUA + MessageFormat.format(plugin.getLang("promoted.to.leader"), Helper.capitalize(promoted)));
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
clan.promote(promotedUniqueId);
|
||||
} else {
|
||||
clan.promote(promoted);
|
||||
}
|
||||
} else {
|
||||
String deniers = Helper.capitalize(Helper.toMessage(Helper.toArray(denies), ", "));
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("denied.the.promotion"), deniers, promoted));
|
||||
}
|
||||
} else if (req.getType().equals(ClanRequest.DISBAND)) {
|
||||
Clan clan = req.getClan();
|
||||
|
||||
if (denies.isEmpty()) {
|
||||
clan.addBb(plugin.getLang("leaders"), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.disbanded"), clan.getName()));
|
||||
clan.disband();
|
||||
} else {
|
||||
String deniers = Helper.capitalize(Helper.toMessage(Helper.toArray(denies), ", "));
|
||||
clan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("clan.deletion"), deniers));
|
||||
}
|
||||
}
|
||||
|
||||
req.cleanVotes();
|
||||
}
|
||||
|
||||
requests.remove(req.getTarget());
|
||||
Clan requesterClan = req.getClan();
|
||||
ClanPlayer requesterCp = req.getRequester();
|
||||
|
||||
String target = req.getTarget();
|
||||
//may be null
|
||||
Clan targetClan = plugin.getClanManager().getClan(target);
|
||||
//may be null
|
||||
UUID targetPlayer = UUIDMigration.getForcedPlayerUUID(target);
|
||||
|
||||
List<String> accepts = req.getAccepts();
|
||||
List<String> denies = req.getDenies();
|
||||
|
||||
switch (req.getType()) {
|
||||
case START_WAR:
|
||||
processStartWar(requesterClan, requesterCp, targetClan, accepts, denies);
|
||||
break;
|
||||
case END_WAR:
|
||||
processEndWar(requesterClan, requesterCp, targetClan, accepts, denies);
|
||||
break;
|
||||
case CREATE_ALLY:
|
||||
processCreateAlly(requesterClan, requesterCp, targetClan, accepts, denies);
|
||||
break;
|
||||
case BREAK_RIVALRY:
|
||||
processBreakRivalry(requesterClan, requesterCp, targetClan, accepts, denies);
|
||||
break;
|
||||
case DEMOTE: case PROMOTE:
|
||||
if (!req.votingFinished() || targetPlayer == null) {
|
||||
return;
|
||||
}
|
||||
target = requesterClan.getTag();
|
||||
|
||||
if (req.getType() == ClanRequest.DEMOTE) {
|
||||
processDemote(req, requesterClan, targetPlayer, denies);
|
||||
}
|
||||
if (req.getType() == ClanRequest.PROMOTE) {
|
||||
processPromote(req, requesterClan, targetPlayer, denies);
|
||||
}
|
||||
break;
|
||||
case DISBAND:
|
||||
if (!req.votingFinished()) {
|
||||
return;
|
||||
}
|
||||
processDisband(requesterClan, denies);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
requests.remove(target);
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new RequestFinishedEvent(req));
|
||||
req.cleanVotes();
|
||||
}
|
||||
|
||||
private void processDisband(Clan requesterClan, List<String> denies) {
|
||||
if (denies.isEmpty()) {
|
||||
requesterClan.addBb(plugin.getLang("leaders"), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.disbanded"), requesterClan.getName()));
|
||||
requesterClan.disband();
|
||||
} else {
|
||||
String deniers = Helper.toMessage(Helper.toArray(denies), ", ");
|
||||
requesterClan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("clan.deletion"), deniers));
|
||||
}
|
||||
}
|
||||
|
||||
private void processPromote(Request req, Clan requesterClan, UUID targetPlayer, List<String> denies) {
|
||||
String promotedName = req.getTarget();
|
||||
if (denies.isEmpty()) {
|
||||
requesterClan.addBb(plugin.getLang("leaders"), ChatColor.AQUA + MessageFormat.format(plugin.getLang("promoted.to.leader"), promotedName));
|
||||
requesterClan.promote(targetPlayer);
|
||||
} else {
|
||||
String deniers = Helper.toMessage(Helper.toArray(denies), ", ");
|
||||
requesterClan.leaderAnnounce(ChatColor.RED + MessageFormat.format(plugin.getLang("denied.the.promotion"), deniers, promotedName));
|
||||
}
|
||||
}
|
||||
|
||||
private void processDemote(Request req, Clan requesterClan, UUID targetPlayer, List<String> denies) {
|
||||
String demotedName = req.getTarget();
|
||||
|
||||
if (denies.isEmpty()) {
|
||||
requesterClan.addBb(plugin.getLang("leaders"), ChatColor.AQUA
|
||||
+ MessageFormat.format(plugin.getLang("demoted.back.to.member"), demotedName));
|
||||
requesterClan.demote(targetPlayer);
|
||||
} else {
|
||||
String deniers = Helper.toMessage(Helper.toArray(denies), ", ");
|
||||
requesterClan.leaderAnnounce(
|
||||
ChatColor.RED + MessageFormat.format(plugin.getLang("denied.demotion"), deniers, demotedName));
|
||||
}
|
||||
}
|
||||
|
||||
private void processBreakRivalry(Clan requesterClan, ClanPlayer requesterCp, Clan targetClan, List<String> accepts,
|
||||
List<String> denies) {
|
||||
if (targetClan != null && requesterClan != null) {
|
||||
if (!accepts.isEmpty()) {
|
||||
requesterClan.removeRival(targetClan);
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("broken.the.rivalry"), accepts.get(0), requesterClan.getName()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("broken.the.rivalry.with"), requesterCp.getName(), targetClan.getName()));
|
||||
} else {
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.to.make.peace"), denies.get(0), requesterClan.getName()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("peace.agreement.denied"), targetClan.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processCreateAlly(Clan requesterClan, ClanPlayer requesterCp, Clan targetClan, List<String> accepts,
|
||||
List<String> denies) {
|
||||
if (targetClan != null && requesterClan != null) {
|
||||
if (!accepts.isEmpty()) {
|
||||
requesterClan.addAlly(targetClan);
|
||||
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("accepted.an.alliance"), accepts.get(0), requesterClan.getName()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("created.an.alliance"), requesterCp.getName(), targetClan.getName()));
|
||||
} else {
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.an.alliance"), denies.get(0), requesterClan.getName()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("the.alliance.was.denied"), targetClan.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processEndWar(Clan requesterClan, ClanPlayer requesterCp, Clan targetClan, List<String> accepts,
|
||||
List<String> denies) {
|
||||
if (requesterClan != null && targetClan != null) {
|
||||
if (!accepts.isEmpty()) {
|
||||
requesterClan.removeWarringClan(targetClan);
|
||||
targetClan.removeWarringClan(requesterClan);
|
||||
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.no.longer.at.war"), accepts.get(0), requesterClan.getColorTag()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.no.longer.at.war"), requesterClan.getName(), targetClan.getColorTag()));
|
||||
} else {
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.war.end"), denies.get(0), requesterClan.getName()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("end.war.denied"), targetClan.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processStartWar(Clan requesterClan, ClanPlayer requesterCp, Clan targetClan, List<String> accepts,
|
||||
List<String> denies) {
|
||||
if (requesterClan != null && targetClan != null) {
|
||||
if (!accepts.isEmpty()) {
|
||||
requesterClan.addWarringClan(targetClan);
|
||||
targetClan.addWarringClan(requesterClan);
|
||||
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.at.war"), targetClan.getName(), requesterClan.getColorTag()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("you.are.at.war"), requesterClan.getName(), targetClan.getColorTag()));
|
||||
} else {
|
||||
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("denied.war.req"), denies.get(0), requesterClan.getName()));
|
||||
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("end.war.denied"), targetClan.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End a pending request prematurely
|
||||
*
|
||||
@@ -396,7 +433,7 @@ public final class RequestManager {
|
||||
for (Request req : new LinkedList<Request>(requests.values())) {
|
||||
for (ClanPlayer cp : req.getAcceptors()) {
|
||||
if (cp.getName().equalsIgnoreCase(playerName)) {
|
||||
req.getClan().leaderAnnounce(MessageFormat.format(plugin.getLang("signed.off.request.cancelled"), ChatColor.RED + Helper.capitalize(playerName), req.getType()));
|
||||
req.getClan().leaderAnnounce(MessageFormat.format(plugin.getLang("signed.off.request.cancelled"), ChatColor.RED + playerName, req.getType()));
|
||||
requests.remove(req.getClan().getTag());
|
||||
break;
|
||||
}
|
||||
@@ -410,9 +447,10 @@ public final class RequestManager {
|
||||
* Starts the task that asks for the votes of all requests
|
||||
*/
|
||||
public void askerTask() {
|
||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Iterator<Map.Entry<String, Request>> iter = requests.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Request req = iter.next().getValue();
|
||||
|
||||
@@ -425,10 +463,9 @@ public final class RequestManager {
|
||||
}
|
||||
|
||||
ask(req);
|
||||
req.incrementAskCount();
|
||||
}
|
||||
}
|
||||
}, 0, plugin.getSettingsManager().getRequestFreqencySecs() * 20L);
|
||||
req.incrementAskCount();
|
||||
}
|
||||
}}.runTaskTimerAsynchronously(plugin, 0, plugin.getSettingsManager().getRequestFreqencySecs() * 20L);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,7 +473,7 @@ public final class RequestManager {
|
||||
*
|
||||
* @param req
|
||||
*/
|
||||
public void ask(Request req) {
|
||||
public void ask(final Request req) {
|
||||
final String tag = plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketLeft() + plugin.getSettingsManager().getTagDefaultColor() + req.getClan().getColorTag() + plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketRight();
|
||||
final String message = tag + " " + plugin.getSettingsManager().getRequestMessageColor() + req.getMsg();
|
||||
final String options = MessageFormat.format(plugin.getLang("accept.or.deny"), ChatBlock.makeEmpty(Helper.stripColors(tag)) + " " + ChatColor.DARK_GREEN + "/" + plugin.getSettingsManager().getCommandAccept() + plugin.getSettingsManager().getPageHeadingsColor(), ChatColor.DARK_RED + "/" + plugin.getSettingsManager().getCommandDeny());
|
||||
@@ -465,6 +502,11 @@ public final class RequestManager {
|
||||
}
|
||||
}
|
||||
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new RequestEvent(req));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new RequestEvent(req));
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
}
|
||||
+1679
-1363
File diff suppressed because it is too large.
Load diff
+351
-119
@@ -12,9 +12,11 @@ import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -27,6 +29,8 @@ public final class StorageManager {
|
||||
private SimpleClans plugin;
|
||||
private DBCore core;
|
||||
private HashMap<String, ChatBlock> chatBlocks = new HashMap<>();
|
||||
private Set<Clan> modifiedClans = new HashSet<>();
|
||||
private Set<ClanPlayer> modifiedClanPlayers = new HashSet<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -45,11 +49,7 @@ public final class StorageManager {
|
||||
* @return
|
||||
*/
|
||||
public ChatBlock getChatBlock(Player player) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
return chatBlocks.get(player.getUniqueId().toString());
|
||||
} else {
|
||||
return chatBlocks.get(player.getName());
|
||||
}
|
||||
return chatBlocks.get(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,17 +59,13 @@ public final class StorageManager {
|
||||
* @param cb
|
||||
*/
|
||||
public void addChatBlock(CommandSender player, ChatBlock cb) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(player.getName());
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(player.getName());
|
||||
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
if (uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
chatBlocks.put(uuid.toString(), cb);
|
||||
} else {
|
||||
chatBlocks.put(player.getName(), cb);
|
||||
}
|
||||
chatBlocks.put(uuid.toString(), cb);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,26 +76,70 @@ public final class StorageManager {
|
||||
core = new MySQLCore(plugin.getSettingsManager().getHost(), plugin.getSettingsManager().getDatabase(), plugin.getSettingsManager().getPort(), plugin.getSettingsManager().getUsername(), plugin.getSettingsManager().getPassword());
|
||||
|
||||
if (core.checkConnection()) {
|
||||
SimpleClans.log("[SimpleClans] " + plugin.getLang("mysql.connection.successful"));
|
||||
plugin.getLogger().info(plugin.getLang("mysql.connection.successful"));
|
||||
|
||||
if (!core.existsTable("sc_clans")) {
|
||||
SimpleClans.log("Creating table: sc_clans");
|
||||
plugin.getLogger().info("Creating table: sc_clans");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ( `id` bigint(20) NOT NULL auto_increment, `verified` tinyint(1) default '0', `tag` varchar(25) NOT NULL, `color_tag` varchar(25) NOT NULL, `name` varchar(100) NOT NULL, `friendly_fire` tinyint(1) default '0', `founded` bigint NOT NULL, `last_used` bigint NOT NULL, `packed_allies` text NOT NULL, `packed_rivals` text NOT NULL, `packed_bb` mediumtext NOT NULL, `cape_url` varchar(255) NOT NULL, `flags` text NOT NULL, `balance` double(64,2), PRIMARY KEY (`id`), UNIQUE KEY `uq_simpleclans_1` (`tag`));";
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ("
|
||||
+ " `id` bigint(20) NOT NULL auto_increment,"
|
||||
+ " `verified` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `color_tag` varchar(25) NOT NULL,"
|
||||
+ " `name` varchar(100) NOT NULL,"
|
||||
+ " `description` varchar(255),"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `founded` bigint NOT NULL,"
|
||||
+ " `last_used` bigint NOT NULL,"
|
||||
+ " `packed_allies` text NOT NULL,"
|
||||
+ " `packed_rivals` text NOT NULL,"
|
||||
+ " `packed_bb` mediumtext NOT NULL,"
|
||||
+ " `cape_url` varchar(255) NOT NULL,"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `balance` double(64,2),"
|
||||
+ " `fee_enabled` tinyint(1) default '0',"
|
||||
+ " `fee_value` double(64,2),"
|
||||
+ " `ranks` text NOT NULL,"
|
||||
+ " PRIMARY KEY (`id`),"
|
||||
+ " UNIQUE KEY `uq_simpleclans_1` (`tag`));";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
if (!core.existsTable("sc_players")) {
|
||||
SimpleClans.log("Creating table: sc_players");
|
||||
plugin.getLogger().info("Creating table: sc_players");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_players` ( `id` bigint(20) NOT NULL auto_increment, `name` varchar(16) NOT NULL, `leader` tinyint(1) default '0', `tag` varchar(25) NOT NULL, `friendly_fire` tinyint(1) default '0', `neutral_kills` int(11) default NULL, `rival_kills` int(11) default NULL, `civilian_kills` int(11) default NULL, `deaths` int(11) default NULL, `last_seen` bigint NOT NULL, `join_date` bigint NOT NULL, `trusted` tinyint(1) default '0', `flags` text NOT NULL, `packed_past_clans` text, PRIMARY KEY (`id`), UNIQUE KEY `uq_sc_players_1` (`name`));";
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_players` ("
|
||||
+ " `id` bigint(20) NOT NULL auto_increment,"
|
||||
+ " `name` varchar(16) NOT NULL,"
|
||||
+ " `leader` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `neutral_kills` int(11) default NULL,"
|
||||
+ " `rival_kills` int(11) default NULL,"
|
||||
+ " `civilian_kills` int(11) default NULL,"
|
||||
+ " `deaths` int(11) default NULL,"
|
||||
+ " `last_seen` bigint NOT NULL,"
|
||||
+ " `join_date` bigint NOT NULL,"
|
||||
+ " `trusted` tinyint(1) default '0',"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `packed_past_clans` text,"
|
||||
+ " `resign_times` text,"
|
||||
+ " PRIMARY KEY (`id`),"
|
||||
+ " UNIQUE KEY `uq_sc_players_1` (`name`));";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
if (!core.existsTable("sc_kills")) {
|
||||
SimpleClans.log("Creating table: sc_kills");
|
||||
plugin.getLogger().info("Creating table: sc_kills");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_kills` ( `kill_id` bigint(20) NOT NULL auto_increment, `attacker` varchar(16) NOT NULL, `attacker_tag` varchar(16) NOT NULL, `victim` varchar(16) NOT NULL, `victim_tag` varchar(16) NOT NULL, `kill_type` varchar(1) NOT NULL, PRIMARY KEY (`kill_id`));";
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_kills` ("
|
||||
+ " `kill_id` bigint(20) NOT NULL auto_increment,"
|
||||
+ " `attacker` varchar(16) NOT NULL,"
|
||||
+ " `attacker_tag` varchar(16) NOT NULL,"
|
||||
+ " `victim` varchar(16) NOT NULL,"
|
||||
+ " `victim_tag` varchar(16) NOT NULL,"
|
||||
+ " `kill_type` varchar(1) NOT NULL,"
|
||||
+ " PRIMARY KEY (`kill_id`));";
|
||||
core.execute(query);
|
||||
}
|
||||
} else {
|
||||
@@ -109,26 +149,71 @@ public final class StorageManager {
|
||||
core = new SQLiteCore(plugin.getDataFolder().getPath());
|
||||
|
||||
if (core.checkConnection()) {
|
||||
SimpleClans.log("[SimpleClans] " + plugin.getLang("sqlite.connection.successful"));
|
||||
|
||||
plugin.getLogger().info(plugin.getLang("sqlite.connection.successful"));
|
||||
|
||||
if (!core.existsTable("sc_clans")) {
|
||||
SimpleClans.log("Creating table: sc_clans");
|
||||
plugin.getLogger().info("Creating table: sc_clans");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ( `id` bigint(20), `verified` tinyint(1) default '0', `tag` varchar(25) NOT NULL, `color_tag` varchar(25) NOT NULL, `name` varchar(100) NOT NULL, `friendly_fire` tinyint(1) default '0', `founded` bigint NOT NULL, `last_used` bigint NOT NULL, `packed_allies` text NOT NULL, `packed_rivals` text NOT NULL, `packed_bb` mediumtext NOT NULL, `cape_url` varchar(255) NOT NULL, `flags` text NOT NULL, `balance` double(64,2) default 0.0, PRIMARY KEY (`id`), UNIQUE (`tag`));";
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ("
|
||||
+ " `id` bigint(20),"
|
||||
+ " `verified` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `color_tag` varchar(25) NOT NULL,"
|
||||
+ " `name` varchar(100) NOT NULL,"
|
||||
+ " `description` varchar(255),"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `founded` bigint NOT NULL,"
|
||||
+ " `last_used` bigint NOT NULL,"
|
||||
+ " `packed_allies` text NOT NULL,"
|
||||
+ " `packed_rivals` text NOT NULL,"
|
||||
+ " `packed_bb` mediumtext NOT NULL,"
|
||||
+ " `cape_url` varchar(255) NOT NULL,"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `balance` double(64,2) default 0.0,"
|
||||
+ " `fee_enabled` tinyint(1) default '0',"
|
||||
+ " `fee_value` double(64,2),"
|
||||
+ " `ranks` text NOT NULL,"
|
||||
+ " PRIMARY KEY (`id`),"
|
||||
+ " UNIQUE (`tag`));";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
if (!core.existsTable("sc_players")) {
|
||||
SimpleClans.log("Creating table: sc_players");
|
||||
plugin.getLogger().info("Creating table: sc_players");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_players` ( `id` bigint(20), `name` varchar(16) NOT NULL, `leader` tinyint(1) default '0', `tag` varchar(25) NOT NULL, `friendly_fire` tinyint(1) default '0', `neutral_kills` int(11) default NULL, `rival_kills` int(11) default NULL, `civilian_kills` int(11) default NULL, `deaths` int(11) default NULL, `last_seen` bigint NOT NULL, `join_date` bigint NOT NULL, `trusted` tinyint(1) default '0', `flags` text NOT NULL, `packed_past_clans` text, PRIMARY KEY (`id`), UNIQUE (`name`));";
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_players` ("
|
||||
+ " `id` bigint(20),"
|
||||
+ " `name` varchar(16) NOT NULL,"
|
||||
+ " `leader` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `neutral_kills` int(11) default NULL,"
|
||||
+ " `rival_kills` int(11) default NULL,"
|
||||
+ " `civilian_kills` int(11) default NULL,"
|
||||
+ " `deaths` int(11) default NULL,"
|
||||
+ " `last_seen` bigint NOT NULL,"
|
||||
+ " `join_date` bigint NOT NULL,"
|
||||
+ " `trusted` tinyint(1) default '0',"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `packed_past_clans` text,"
|
||||
+ " `resign_times` text,"
|
||||
+ " PRIMARY KEY (`id`),"
|
||||
+ " UNIQUE (`name`));";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
if (!core.existsTable("sc_kills")) {
|
||||
SimpleClans.log("Creating table: sc_kills");
|
||||
plugin.getLogger().info("Creating table: sc_kills");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_kills` ( `kill_id` bigint(20), `attacker` varchar(16) NOT NULL, `attacker_tag` varchar(16) NOT NULL, `victim` varchar(16) NOT NULL, `victim_tag` varchar(16) NOT NULL, `kill_type` varchar(1) NOT NULL, PRIMARY KEY (`kill_id`));";
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_kills` ("
|
||||
+ " `kill_id` bigint(20),"
|
||||
+ " `attacker` varchar(16) NOT NULL,"
|
||||
+ " `attacker_tag` varchar(16) NOT NULL,"
|
||||
+ " `victim` varchar(16) NOT NULL,"
|
||||
+ " `victim_tag` varchar(16) NOT NULL,"
|
||||
+ " `kill_type` varchar(1) NOT NULL,"
|
||||
+ " PRIMARY KEY (`kill_id`));";
|
||||
core.execute(query);
|
||||
}
|
||||
} else {
|
||||
@@ -162,7 +247,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
if (!clans.isEmpty()) {
|
||||
SimpleClans.log(MessageFormat.format("[SimpleClans] " + plugin.getLang("clans"), clans.size()));
|
||||
plugin.getLogger().info(MessageFormat.format(plugin.getLang("clans"), clans.size()));
|
||||
}
|
||||
|
||||
List<ClanPlayer> cps = retrieveClanPlayers();
|
||||
@@ -178,7 +263,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
if (!cps.isEmpty()) {
|
||||
SimpleClans.log(MessageFormat.format("[SimpleClans] " + plugin.getLang("clan.players"), cps.size()));
|
||||
plugin.getLogger().info(MessageFormat.format(plugin.getLang("clan.players"), cps.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,8 +285,8 @@ public final class StorageManager {
|
||||
tm.importMember(cp);
|
||||
}
|
||||
plugin.getClanManager().importClanPlayer(cp);
|
||||
|
||||
SimpleClans.log("[SimpleClans] ClanPlayer Reloaded: " + player.getName() + ", UUID: " + player.getUniqueId().toString());
|
||||
|
||||
plugin.getLogger().info("ClanPlayer Reloaded: " + player.getName() + ", UUID: " + player.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +306,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
for (Clan clan : purge) {
|
||||
SimpleClans.log("[SimpleClans] " + MessageFormat.format(plugin.getLang("purging.clan"), clan.getName()));
|
||||
plugin.getLogger().info(MessageFormat.format(plugin.getLang("purging.clan"), clan.getName()));
|
||||
deleteClan(clan);
|
||||
clans.remove(clan);
|
||||
}
|
||||
@@ -237,7 +322,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : purge) {
|
||||
SimpleClans.log("[SimpleClans] " + MessageFormat.format(plugin.getLang("purging.player.data"), cp.getName()));
|
||||
plugin.getLogger().info(MessageFormat.format(plugin.getLang("purging.player.data"), cp.getName()));
|
||||
deleteClanPlayer(cp);
|
||||
cps.remove(cp);
|
||||
}
|
||||
@@ -263,14 +348,18 @@ public final class StorageManager {
|
||||
String tag = res.getString("tag");
|
||||
String color_tag = Helper.parseColors(res.getString("color_tag"));
|
||||
String name = res.getString("name");
|
||||
String description = res.getString("description");
|
||||
String packed_allies = res.getString("packed_allies");
|
||||
String packed_rivals = res.getString("packed_rivals");
|
||||
String packed_bb = res.getString("packed_bb");
|
||||
String cape_url = res.getString("cape_url");
|
||||
String flags = res.getString("flags");
|
||||
String ranks = res.getString("ranks");
|
||||
long founded = res.getLong("founded");
|
||||
long last_used = res.getLong("last_used");
|
||||
double balance = res.getDouble("balance");
|
||||
double feeValue = res.getDouble("fee_value");
|
||||
boolean feeEnabled = res.getBoolean("fee_enabled");
|
||||
|
||||
if (founded == 0) {
|
||||
founded = (new Date()).getTime();
|
||||
@@ -287,6 +376,7 @@ public final class StorageManager {
|
||||
clan.setTag(tag);
|
||||
clan.setColorTag(color_tag);
|
||||
clan.setName(name);
|
||||
clan.setDescription(description);
|
||||
clan.setPackedAllies(packed_allies);
|
||||
clan.setPackedRivals(packed_rivals);
|
||||
clan.setPackedBb(packed_bb);
|
||||
@@ -294,6 +384,9 @@ public final class StorageManager {
|
||||
clan.setFounded(founded);
|
||||
clan.setLastUsed(last_used);
|
||||
clan.setBalance(balance);
|
||||
clan.setMemberFee(feeValue);
|
||||
clan.setMemberFeeEnabled(feeEnabled);
|
||||
clan.setRanks(Helper.ranksFromJson(ranks));
|
||||
|
||||
out.add(clan);
|
||||
} catch (Exception ex) {
|
||||
@@ -303,8 +396,8 @@ public final class StorageManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
SimpleClans.getLog().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
SimpleClans.getLog().log(Level.SEVERE, null, ex);
|
||||
plugin.getLogger().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
plugin.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,14 +426,18 @@ public final class StorageManager {
|
||||
String tag = res.getString("tag");
|
||||
String color_tag = Helper.parseColors(res.getString("color_tag"));
|
||||
String name = res.getString("name");
|
||||
String description = res.getString("description");
|
||||
String packed_allies = res.getString("packed_allies");
|
||||
String packed_rivals = res.getString("packed_rivals");
|
||||
String packed_bb = res.getString("packed_bb");
|
||||
String cape_url = res.getString("cape_url");
|
||||
String flags = res.getString("flags");
|
||||
String ranks = res.getString("ranks");
|
||||
long founded = res.getLong("founded");
|
||||
long last_used = res.getLong("last_used");
|
||||
double balance = res.getDouble("balance");
|
||||
double feeValue = res.getDouble("fee_value");
|
||||
boolean feeEnabled = res.getBoolean("fee_enabled");
|
||||
|
||||
if (founded == 0) {
|
||||
founded = (new Date()).getTime();
|
||||
@@ -357,6 +454,7 @@ public final class StorageManager {
|
||||
clan.setTag(tag);
|
||||
clan.setColorTag(color_tag);
|
||||
clan.setName(name);
|
||||
clan.setDescription(description);
|
||||
clan.setPackedAllies(packed_allies);
|
||||
clan.setPackedRivals(packed_rivals);
|
||||
clan.setPackedBb(packed_bb);
|
||||
@@ -364,6 +462,9 @@ public final class StorageManager {
|
||||
clan.setFounded(founded);
|
||||
clan.setLastUsed(last_used);
|
||||
clan.setBalance(balance);
|
||||
clan.setMemberFee(feeValue);
|
||||
clan.setMemberFeeEnabled(feeEnabled);
|
||||
clan.setRanks(Helper.ranksFromJson(ranks));
|
||||
|
||||
out = clan;
|
||||
} catch (Exception ex) {
|
||||
@@ -373,8 +474,8 @@ public final class StorageManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
SimpleClans.getLog().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
SimpleClans.getLog().log(Level.SEVERE, null, ex);
|
||||
plugin.getLogger().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
plugin.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +511,8 @@ public final class StorageManager {
|
||||
long join_date = res.getLong("join_date");
|
||||
String flags = res.getString("flags");
|
||||
String packed_past_clans = Helper.parseColors(res.getString("packed_past_clans"));
|
||||
|
||||
String resign_times = res.getString("resign_times");
|
||||
|
||||
if (last_seen == 0) {
|
||||
last_seen = (new Date()).getTime();
|
||||
}
|
||||
@@ -435,6 +537,7 @@ public final class StorageManager {
|
||||
cp.setJoinDate(join_date);
|
||||
cp.setPackedPastClans(packed_past_clans);
|
||||
cp.setTrusted(leader || trusted);
|
||||
cp.setResignTimes(Helper.resignTimesFromJson(resign_times));
|
||||
|
||||
if (!tag.isEmpty()) {
|
||||
Clan clan = SimpleClans.getInstance().getClanManager().getClan(tag);
|
||||
@@ -452,8 +555,8 @@ public final class StorageManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
SimpleClans.getLog().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
SimpleClans.getLog().log(Level.SEVERE, null, ex);
|
||||
plugin.getLogger().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
plugin.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,7 +594,8 @@ public final class StorageManager {
|
||||
long join_date = res.getLong("join_date");
|
||||
String flags = res.getString("flags");
|
||||
String packed_past_clans = Helper.parseColors(res.getString("packed_past_clans"));
|
||||
|
||||
String resign_times = res.getString("resign_times");
|
||||
|
||||
if (last_seen == 0) {
|
||||
last_seen = (new Date()).getTime();
|
||||
}
|
||||
@@ -516,7 +620,8 @@ public final class StorageManager {
|
||||
cp.setJoinDate(join_date);
|
||||
cp.setPackedPastClans(packed_past_clans);
|
||||
cp.setTrusted(leader || trusted);
|
||||
|
||||
cp.setResignTimes(Helper.resignTimesFromJson(resign_times));
|
||||
|
||||
if (!tag.isEmpty()) {
|
||||
Clan clanDB = retrieveOneClan(tag);
|
||||
Clan clan = SimpleClans.getInstance().getClanManager().getClan(tag);
|
||||
@@ -553,8 +658,8 @@ public final class StorageManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
SimpleClans.getLog().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
SimpleClans.getLog().log(Level.SEVERE, null, ex);
|
||||
plugin.getLogger().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
plugin.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,8 +672,25 @@ public final class StorageManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void insertClan(Clan clan) {
|
||||
String query = "INSERT INTO `sc_clans` ( `verified`, `tag`, `color_tag`, `name`, `friendly_fire`, `founded`, `last_used`, `packed_allies`, `packed_rivals`, `packed_bb`, `cape_url`, `flags`, `balance`) ";
|
||||
String values = "VALUES ( " + (clan.isVerified() ? 1 : 0) + ",'" + Helper.escapeQuotes(clan.getTag()) + "','" + Helper.escapeQuotes(clan.getColorTag()) + "','" + Helper.escapeQuotes(clan.getName()) + "'," + (clan.isFriendlyFire() ? 1 : 0) + ",'" + clan.getFounded() + "','" + clan.getLastUsed() + "','" + Helper.escapeQuotes(clan.getPackedAllies()) + "','" + Helper.escapeQuotes(clan.getPackedRivals()) + "','" + Helper.escapeQuotes(clan.getPackedBb()) + "','" + Helper.escapeQuotes(clan.getCapeUrl()) + "','" + Helper.escapeQuotes(clan.getFlags()) + "','" + Helper.escapeQuotes(String.valueOf(clan.getBalance())) + "');";
|
||||
String query = "INSERT INTO `sc_clans` (`ranks`, `description`, `fee_enabled`, `fee_value`, `verified`, `tag`, `color_tag`, `name`, `friendly_fire`, `founded`, `last_used`, `packed_allies`, `packed_rivals`, `packed_bb`, `cape_url`, `flags`, `balance`) ";
|
||||
String values = "VALUES ( '"
|
||||
+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks())) + "','"
|
||||
+ Helper.escapeQuotes(clan.getDescription())+ "',"
|
||||
+ (clan.isMemberFeeEnabled() ? 1 : 0) +","
|
||||
+ Helper.escapeQuotes(String.valueOf(clan.getMemberFee())) + ","
|
||||
+ (clan.isVerified() ? 1 : 0) + ",'"
|
||||
+ Helper.escapeQuotes(clan.getTag()) + "','"
|
||||
+ Helper.escapeQuotes(clan.getColorTag()) + "','"
|
||||
+ Helper.escapeQuotes(clan.getName()) + "',"
|
||||
+ (clan.isFriendlyFire() ? 1 : 0) + ",'"
|
||||
+ clan.getFounded() + "','"
|
||||
+ clan.getLastUsed() + "','"
|
||||
+ Helper.escapeQuotes(clan.getPackedAllies()) + "','"
|
||||
+ Helper.escapeQuotes(clan.getPackedRivals()) + "','"
|
||||
+ Helper.escapeQuotes(clan.getPackedBb()) + "','"
|
||||
+ Helper.escapeQuotes(clan.getCapeUrl()) + "','"
|
||||
+ Helper.escapeQuotes(clan.getFlags()) + "','"
|
||||
+ Helper.escapeQuotes(String.valueOf(clan.getBalance())) + "');";
|
||||
core.insert(query + values);
|
||||
}
|
||||
|
||||
@@ -577,14 +699,14 @@ public final class StorageManager {
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public void updateClanAsync(final Clan clan) {
|
||||
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateClan(clan);
|
||||
}
|
||||
});
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,18 +714,17 @@ public final class StorageManager {
|
||||
*
|
||||
* @param p to update
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void updatePlayerNameAsync(final Player p) {
|
||||
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updatePlayerName(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the name of a player in the database asynchronously
|
||||
* Change the name of a player in the database
|
||||
*
|
||||
* @param p to update
|
||||
*/
|
||||
@@ -618,9 +739,7 @@ public final class StorageManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void updateClan(Clan clan) {
|
||||
clan.updateLastUsed();
|
||||
String query = "UPDATE `sc_clans` SET verified = " + (clan.isVerified() ? 1 : 0) + ", tag = '" + Helper.escapeQuotes(clan.getTag()) + "', color_tag = '" + Helper.escapeQuotes(clan.getColorTag()) + "', name = '" + Helper.escapeQuotes(clan.getName()) + "', friendly_fire = " + (clan.isFriendlyFire() ? 1 : 0) + ", founded = '" + clan.getFounded() + "', last_used = '" + clan.getLastUsed() + "', packed_allies = '" + Helper.escapeQuotes(clan.getPackedAllies()) + "', packed_rivals = '" + Helper.escapeQuotes(clan.getPackedRivals()) + "', packed_bb = '" + Helper.escapeQuotes(clan.getPackedBb()) + "', cape_url = '" + Helper.escapeQuotes(clan.getCapeUrl()) + "', cape_url = '" + Helper.escapeQuotes(String.valueOf(clan.getCapeUrl())) + "', balance = '" + clan.getBalance() + "', flags = '" + Helper.escapeQuotes(clan.getFlags()) + "' WHERE tag = '" + Helper.escapeQuotes(clan.getTag()) + "';";
|
||||
core.update(query);
|
||||
updateClan(clan, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -633,9 +752,17 @@ public final class StorageManager {
|
||||
public void updateClan(Clan clan, boolean updateLastUsed) {
|
||||
if (updateLastUsed) {
|
||||
clan.updateLastUsed();
|
||||
}
|
||||
String query = "UPDATE `sc_clans` SET verified = " + (clan.isVerified() ? 1 : 0) + ", tag = '" + Helper.escapeQuotes(clan.getTag()) + "', color_tag = '" + Helper.escapeQuotes(clan.getColorTag()) + "', name = '" + Helper.escapeQuotes(clan.getName()) + "', friendly_fire = " + (clan.isFriendlyFire() ? 1 : 0) + ", founded = '" + clan.getFounded() + "', last_used = '" + clan.getLastUsed() + "', packed_allies = '" + Helper.escapeQuotes(clan.getPackedAllies()) + "', packed_rivals = '" + Helper.escapeQuotes(clan.getPackedRivals()) + "', packed_bb = '" + Helper.escapeQuotes(clan.getPackedBb()) + "', cape_url = '" + Helper.escapeQuotes(clan.getCapeUrl()) + "', cape_url = '" + Helper.escapeQuotes(String.valueOf(clan.getCapeUrl())) + "', balance = '" + clan.getBalance() + "', flags = '" + Helper.escapeQuotes(clan.getFlags()) + "' WHERE tag = '" + Helper.escapeQuotes(clan.getTag()) + "';";
|
||||
core.update(query);
|
||||
}
|
||||
if (plugin.getSettingsManager().isSavePeriodically()) {
|
||||
modifiedClans.add(clan);
|
||||
return;
|
||||
}
|
||||
core.update(getUpdateClanQuery(clan));
|
||||
}
|
||||
|
||||
private String getUpdateClanQuery(Clan clan) {
|
||||
String query = "UPDATE `sc_clans` SET ranks = '"+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks())) +"', description = '" + Helper.escapeQuotes(clan.getDescription())+ "', fee_enabled = "+ (clan.isMemberFeeEnabled() ? 1 : 0) +", fee_value = '" + clan.getMemberFee() + "', verified = " + (clan.isVerified() ? 1 : 0) + ", tag = '" + Helper.escapeQuotes(clan.getTag()) + "', color_tag = '" + Helper.escapeQuotes(clan.getColorTag()) + "', name = '" + Helper.escapeQuotes(clan.getName()) + "', friendly_fire = " + (clan.isFriendlyFire() ? 1 : 0) + ", founded = '" + clan.getFounded() + "', last_used = '" + clan.getLastUsed() + "', packed_allies = '" + Helper.escapeQuotes(clan.getPackedAllies()) + "', packed_rivals = '" + Helper.escapeQuotes(clan.getPackedRivals()) + "', packed_bb = '" + Helper.escapeQuotes(clan.getPackedBb()) + "', cape_url = '" + Helper.escapeQuotes(clan.getCapeUrl()) + "', cape_url = '" + Helper.escapeQuotes(String.valueOf(clan.getCapeUrl())) + "', balance = '" + clan.getBalance() + "', flags = '" + Helper.escapeQuotes(clan.getFlags()) + "' WHERE tag = '" + Helper.escapeQuotes(clan.getTag()) + "';";
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -654,15 +781,9 @@ public final class StorageManager {
|
||||
* @param cp
|
||||
*/
|
||||
public void insertClanPlayer(ClanPlayer cp) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
String query = "INSERT INTO `sc_players` ( `uuid`, `name`, `leader`, `tag`, `friendly_fire`, `neutral_kills`, `rival_kills`, `civilian_kills`, `deaths`, `last_seen`, `join_date`, `packed_past_clans`, `flags`) ";
|
||||
String values = "VALUES ( '" + cp.getUniqueId().toString() + "', '" + cp.getName() + "'," + (cp.isLeader() ? 1 : 0) + ",'" + Helper.escapeQuotes(cp.getTag()) + "'," + (cp.isFriendlyFire() ? 1 : 0) + "," + cp.getNeutralKills() + "," + cp.getRivalKills() + "," + cp.getCivilianKills() + "," + cp.getDeaths() + ",'" + cp.getLastSeen() + "',' " + cp.getJoinDate() + "','" + Helper.escapeQuotes(cp.getPackedPastClans()) + "','" + Helper.escapeQuotes(cp.getFlags()) + "');";
|
||||
core.insert(query + values);
|
||||
} else {
|
||||
String query = "INSERT INTO `sc_players` ( `name`, `leader`, `tag`, `friendly_fire`, `neutral_kills`, `rival_kills`, `civilian_kills`, `deaths`, `last_seen`, `join_date`, `packed_past_clans`, `flags`) ";
|
||||
String values = "VALUES ( '" + cp.getName() + "'," + (cp.isLeader() ? 1 : 0) + ",'" + Helper.escapeQuotes(cp.getTag()) + "'," + (cp.isFriendlyFire() ? 1 : 0) + "," + cp.getNeutralKills() + "," + cp.getRivalKills() + "," + cp.getCivilianKills() + "," + cp.getDeaths() + ",'" + cp.getLastSeen() + "',' " + cp.getJoinDate() + "','" + Helper.escapeQuotes(cp.getPackedPastClans()) + "','" + Helper.escapeQuotes(cp.getFlags()) + "');";
|
||||
core.insert(query + values);
|
||||
}
|
||||
String query = "INSERT INTO `sc_players` (`resign_times`, `uuid`, `name`, `leader`, `tag`, `friendly_fire`, `neutral_kills`, `rival_kills`, `civilian_kills`, `deaths`, `last_seen`, `join_date`, `packed_past_clans`, `flags`) ";
|
||||
String values = "VALUES ( '"+ Helper.escapeQuotes(Helper.resignTimesToJson(cp.getResignTimes()))+ "', '" + cp.getUniqueId().toString() + "', '" + cp.getName() + "'," + (cp.isLeader() ? 1 : 0) + ",'" + Helper.escapeQuotes(cp.getTag()) + "'," + (cp.isFriendlyFire() ? 1 : 0) + "," + cp.getNeutralKills() + "," + cp.getRivalKills() + "," + cp.getCivilianKills() + "," + cp.getDeaths() + ",'" + cp.getLastSeen() + "',' " + cp.getJoinDate() + "','" + Helper.escapeQuotes(cp.getPackedPastClans()) + "','" + Helper.escapeQuotes(cp.getFlags()) + "');";
|
||||
core.insert(query + values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -670,14 +791,14 @@ public final class StorageManager {
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public void updateClanPlayerAsync(final ClanPlayer cp) {
|
||||
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateClanPlayer(cp);
|
||||
}
|
||||
});
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -687,13 +808,16 @@ public final class StorageManager {
|
||||
*/
|
||||
public void updateClanPlayer(ClanPlayer cp) {
|
||||
cp.updateLastSeen();
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
String query = "UPDATE `sc_players` SET leader = " + (cp.isLeader() ? 1 : 0) + ", tag = '" + Helper.escapeQuotes(cp.getTag()) + "' , friendly_fire = " + (cp.isFriendlyFire() ? 1 : 0) + ", neutral_kills = " + cp.getNeutralKills() + ", rival_kills = " + cp.getRivalKills() + ", civilian_kills = " + cp.getCivilianKills() + ", deaths = " + cp.getDeaths() + ", last_seen = '" + cp.getLastSeen() + "', packed_past_clans = '" + Helper.escapeQuotes(cp.getPackedPastClans()) + "', trusted = " + (cp.isTrusted() ? 1 : 0) + ", flags = '" + Helper.escapeQuotes(cp.getFlags()) + "', name = '" + cp.getName() + "' WHERE `uuid` = '" + cp.getUniqueId().toString() + "';";
|
||||
core.update(query);
|
||||
} else {
|
||||
String query = "UPDATE `sc_players` SET leader = " + (cp.isLeader() ? 1 : 0) + ", tag = '" + Helper.escapeQuotes(cp.getTag()) + "' , friendly_fire = " + (cp.isFriendlyFire() ? 1 : 0) + ", neutral_kills = " + cp.getNeutralKills() + ", rival_kills = " + cp.getRivalKills() + ", civilian_kills = " + cp.getCivilianKills() + ", deaths = " + cp.getDeaths() + ", last_seen = '" + cp.getLastSeen() + "', packed_past_clans = '" + Helper.escapeQuotes(cp.getPackedPastClans()) + "', trusted = " + (cp.isTrusted() ? 1 : 0) + ", flags = '" + Helper.escapeQuotes(cp.getFlags()) + "' WHERE name = '" + cp.getName() + "';";
|
||||
core.update(query);
|
||||
if (plugin.getSettingsManager().isSavePeriodically()) {
|
||||
modifiedClanPlayers.add(cp);
|
||||
return;
|
||||
}
|
||||
core.update(getUpdateClanPlayerQuery(cp));
|
||||
}
|
||||
|
||||
private String getUpdateClanPlayerQuery(ClanPlayer cp) {
|
||||
String query = "UPDATE `sc_players` SET resign_times = '"+ Helper.escapeQuotes(Helper.resignTimesToJson(cp.getResignTimes())) +"', leader = " + (cp.isLeader() ? 1 : 0) + ", tag = '" + Helper.escapeQuotes(cp.getTag()) + "' , friendly_fire = " + (cp.isFriendlyFire() ? 1 : 0) + ", neutral_kills = " + cp.getNeutralKills() + ", rival_kills = " + cp.getRivalKills() + ", civilian_kills = " + cp.getCivilianKills() + ", deaths = " + cp.getDeaths() + ", last_seen = '" + cp.getLastSeen() + "', packed_past_clans = '" + Helper.escapeQuotes(cp.getPackedPastClans()) + "', trusted = " + (cp.isTrusted() ? 1 : 0) + ", flags = '" + Helper.escapeQuotes(cp.getFlags()) + "', name = '" + cp.getName() + "' WHERE `uuid` = '" + cp.getUniqueId().toString() + "';";
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -702,17 +826,16 @@ public final class StorageManager {
|
||||
* @param cp
|
||||
*/
|
||||
public void deleteClanPlayer(ClanPlayer cp) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
String query = "DELETE FROM `sc_players` WHERE uuid = '" + cp.getUniqueId() + "';";
|
||||
core.delete(query);
|
||||
deleteKills(cp.getUniqueId());
|
||||
} else {
|
||||
String query = "DELETE FROM `sc_players` WHERE name = '" + cp.getName() + "';";
|
||||
core.delete(query);
|
||||
deleteKills(cp.getName());
|
||||
final Clan clan = cp.getClan();
|
||||
if (clan != null) {
|
||||
clan.addBbWithoutSaving(ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.purged"), cp.getName()));
|
||||
updateClan(clan, false);
|
||||
}
|
||||
String query = "DELETE FROM `sc_players` WHERE uuid = '" + cp.getUniqueId() + "';";
|
||||
core.delete(query);
|
||||
deleteKills(cp.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert a kill into the database
|
||||
*
|
||||
@@ -723,15 +846,9 @@ public final class StorageManager {
|
||||
* @param type
|
||||
*/
|
||||
public void insertKill(Player attacker, String attackerTag, Player victim, String victimTag, String type) {
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
String query = "INSERT INTO `sc_kills` ( `attacker_uuid`, `attacker`, `attacker_tag`, `victim_uuid`, `victim`, `victim_tag`, `kill_type`) ";
|
||||
String values = "VALUES ( '" + attacker.getUniqueId() + "','" + attacker.getName() + "','" + attackerTag + "','" + victim.getUniqueId() + "','" + victim.getName() + "','" + victimTag + "','" + type + "');";
|
||||
core.insert(query + values);
|
||||
} else {
|
||||
String query = "INSERT INTO `sc_kills` ( `attacker`, `attacker_tag`, `victim`, `victim_tag`, `kill_type`) ";
|
||||
String values = "VALUES ( '" + attacker.getName() + "','" + attackerTag + "','" + victim.getName() + "','" + victimTag + "','" + type + "');";
|
||||
core.insert(query + values);
|
||||
}
|
||||
String query = "INSERT INTO `sc_kills` ( `attacker_uuid`, `attacker`, `attacker_tag`, `victim_uuid`, `victim`, `victim_tag`, `kill_type`) ";
|
||||
String values = "VALUES ( '" + attacker.getUniqueId() + "','" + attacker.getName() + "','" + attackerTag + "','" + victim.getUniqueId() + "','" + victim.getName() + "','" + victimTag + "','" + type + "');";
|
||||
core.insert(query + values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -775,14 +892,14 @@ public final class StorageManager {
|
||||
int kills = res.getInt("kills");
|
||||
out.put(victim, kills);
|
||||
} catch (Exception ex) {
|
||||
SimpleClans.getLog().info(ex.getMessage());
|
||||
plugin.getLogger().info(ex.getMessage());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
SimpleClans.getLog().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
SimpleClans.getLog().log(Level.SEVERE, null, ex);
|
||||
plugin.getLogger().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
plugin.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,20 +926,65 @@ public final class StorageManager {
|
||||
int kills = res.getInt("kills");
|
||||
out.put(attacker + " " + victim, kills);
|
||||
} catch (Exception ex) {
|
||||
SimpleClans.getLog().info(ex.getMessage());
|
||||
plugin.getLogger().info(ex.getMessage());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
SimpleClans.getLog().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
SimpleClans.getLog().log(Level.SEVERE, null, ex);
|
||||
plugin.getLogger().severe(String.format("An Error occurred: %s", ex.getErrorCode()));
|
||||
plugin.getLogger().log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets, asynchronously, a map of tag->count of all kills and notifies via callback when it's ready
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
public void getMostKilled(DataCallback<Map<String, Integer>> callback) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
callback.onResultReady(getMostKilled());
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets, asynchronously, a map of victim->count of all kills that specific player did and notifies via callback when it's ready
|
||||
*
|
||||
* @param playerName
|
||||
* @param callback
|
||||
*/
|
||||
public void getKillsPerPlayer(final String playerName, final DataCallback<Map<String, Integer>> callback) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
callback.onResultReady(getKillsPerPlayer(playerName));
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback that returns some data
|
||||
*
|
||||
* @author roinujnosde
|
||||
*
|
||||
*/
|
||||
public interface DataCallback<T> {
|
||||
/**
|
||||
* Notifies when the result is ready
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
void onResultReady(T data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the database to the latest version
|
||||
*
|
||||
@@ -838,6 +1000,42 @@ public final class StorageManager {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `balance` double(64,2);";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* From 2.7.16 to 2.7.17
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "fee_enabled")) {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `fee_enabled` tinyint(1) default '0';";
|
||||
core.execute(query);
|
||||
}
|
||||
if (!core.existsColumn("sc_clans", "fee_value")) {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `fee_value` double(64,2);";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* From 2.7.21 to 2.7.22
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "description")) {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `description` varchar(255);";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* From 2.7.22 to 2.7.23
|
||||
*/
|
||||
if (!core.existsColumn("sc_players", "resign_times")) {
|
||||
query = "ALTER TABLE sc_players ADD COLUMN `resign_times` text;";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* From 2.8.2 to 2.9
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "ranks")) {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `ranks` text;";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bukkit 1.7.5+ UUID Migration
|
||||
@@ -876,11 +1074,12 @@ public final class StorageManager {
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
private void updatePlayersToUUID() {
|
||||
SimpleClans.log("[SimpleClans] Starting Migration to UUID Players !");
|
||||
SimpleClans.log("[SimpleClans] ==================== ATTENTION DONT STOP BUKKIT ! ==================== ");
|
||||
SimpleClans.log("[SimpleClans] ==================== ATTENTION DONT STOP BUKKIT ! ==================== ");
|
||||
SimpleClans.log("[SimpleClans] ==================== ATTENTION DONT STOP BUKKIT ! ==================== ");
|
||||
|
||||
private void updatePlayersToUUID() {
|
||||
plugin.getLogger().log(Level.WARNING, "Starting Migration to UUID Players !");
|
||||
plugin.getLogger().log(Level.WARNING, "==================== ATTENTION DONT STOP BUKKIT ! ==================== ");
|
||||
plugin.getLogger().log(Level.WARNING, "==================== ATTENTION DONT STOP BUKKIT ! ==================== ");
|
||||
plugin.getLogger().log(Level.WARNING, "==================== ATTENTION DONT STOP BUKKIT ! ==================== ");
|
||||
SimpleClans.getInstance().setUUID(false);
|
||||
List<ClanPlayer> cps = retrieveClanPlayers();
|
||||
|
||||
@@ -901,20 +1100,53 @@ public final class StorageManager {
|
||||
|
||||
String query3 = "UPDATE `sc_kills` SET victim_uuid = '" + uuidPlayer.toString() + "' WHERE victim = '" + cp.getName() + "';";
|
||||
core.update(query3);
|
||||
SimpleClans.log("[" + i + " / " + cps.size() + "] Success: " + cp.getName() + "; UUID: " + uuidPlayer.toString());
|
||||
plugin.getLogger().info("[" + i + " / " + cps.size() + "] Success: " + cp.getName() + "; UUID: " + uuidPlayer.toString());
|
||||
} catch (Exception ex) {
|
||||
SimpleClans.log("[" + i + " / " + cps.size() + "] Failed [ERRO]: " + cp.getName() + "; UUID: ???");
|
||||
plugin.getLogger().log(Level.WARNING, "[" + i + " / " + cps.size() + "] Failed [ERRO]: " + cp.getName() + "; UUID: ???");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
SimpleClans.log("[SimpleClans] ==================== END OF MIGRATION ====================");
|
||||
SimpleClans.log("[SimpleClans] ==================== END OF MIGRATION ====================");
|
||||
SimpleClans.log("[SimpleClans] ==================== END OF MIGRATION ====================");
|
||||
plugin.getLogger().log(Level.WARNING, "==================== END OF MIGRATION ====================");
|
||||
plugin.getLogger().log(Level.WARNING, "==================== END OF MIGRATION ====================");
|
||||
plugin.getLogger().log(Level.WARNING, "==================== END OF MIGRATION ====================");
|
||||
|
||||
|
||||
if (!cps.isEmpty()) {
|
||||
SimpleClans.log(MessageFormat.format("[SimpleClans] " + plugin.getLang("clan.players"), cps.size()));
|
||||
plugin.getLogger().info(MessageFormat.format(plugin.getLang("clan.players"), cps.size()));
|
||||
}
|
||||
SimpleClans.getInstance().setUUID(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves modified Clans and ClanPlayers to the database
|
||||
*
|
||||
* @author RoinujNosde
|
||||
* @since 2.10.2
|
||||
*/
|
||||
public void saveModified() {
|
||||
try (Statement statement = core.getConnection().createStatement()) {
|
||||
List<Clan> allClans = plugin.getClanManager().getClans();
|
||||
for (Clan clan : modifiedClans) {
|
||||
if (!allClans.contains(clan)) {
|
||||
continue;
|
||||
}
|
||||
statement.addBatch(getUpdateClanQuery(clan));
|
||||
}
|
||||
List<ClanPlayer> allClanPlayers = plugin.getClanManager().getAllClanPlayers();
|
||||
for (ClanPlayer cp : modifiedClanPlayers) {
|
||||
if (!allClanPlayers.contains(cp)) {
|
||||
continue;
|
||||
}
|
||||
statement.addBatch(getUpdateClanPlayerQuery(cp));
|
||||
}
|
||||
statement.executeBatch();
|
||||
|
||||
modifiedClans.clear();
|
||||
modifiedClanPlayers.clear();
|
||||
} catch (SQLException e) {
|
||||
plugin.getLogger().severe("Error saving modified Clans and ClanPlayers:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,17 +36,13 @@ public final class TeleportManager {
|
||||
* @param clanName
|
||||
*/
|
||||
public void addPlayer(Player player, Location dest, String clanName) {
|
||||
int secs = SimpleClans.getInstance().getSettingsManager().getWaitSecs();
|
||||
int secs = SimpleClans.getInstance().getSettingsManager().getWaitSecs();
|
||||
waitingPlayers.put(player.getUniqueId().toString(), new TeleportState(player, dest, clanName));
|
||||
|
||||
if (SimpleClans.getInstance().hasUUID()) {
|
||||
waitingPlayers.put(player.getUniqueId().toString(), new TeleportState(player, dest, clanName));
|
||||
} else {
|
||||
waitingPlayers.put(player.getName(), new TeleportState(player, dest, clanName));
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + MessageFormat.format(plugin.getLang("waiting.for.teleport.stand.still.for.0.seconds"), secs));
|
||||
}
|
||||
if (secs > 0) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA
|
||||
+ MessageFormat.format(plugin.getLang("waiting.for.teleport.stand.still.for.0.seconds"), secs));
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItems(Player player) {
|
||||
@@ -61,7 +57,7 @@ public final class TeleportManager {
|
||||
|
||||
List<Integer> itemsList = plugin.getSettingsManager().getItemsList();
|
||||
|
||||
if (itemsList.contains(item.getTypeId())) {
|
||||
if (itemsList.contains(item.getType().getId())) {
|
||||
player.getWorld().dropItemNaturally(player.getLocation(), item);
|
||||
inv.remove(item);
|
||||
}
|
||||
@@ -78,7 +74,7 @@ public final class TeleportManager {
|
||||
|
||||
List<Integer> itemsList = plugin.getSettingsManager().getItemsList();
|
||||
|
||||
if (!itemsList.contains(item.getTypeId())) {
|
||||
if (!itemsList.contains(item.getType().getId())) {
|
||||
player.getWorld().dropItemNaturally(player.getLocation(), item);
|
||||
inv.remove(item);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MySQLCore implements DBCore {
|
||||
this.host = host;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.log = SimpleClans.getLog();
|
||||
this.log = SimpleClans.getInstance().getLogger();
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
@@ -25,29 +27,33 @@ public class SQLiteCore implements DBCore {
|
||||
public SQLiteCore(String dbLocation) {
|
||||
this.dbName = "SimpleClans";
|
||||
this.dbLocation = dbLocation;
|
||||
this.log = SimpleClans.getLog();
|
||||
|
||||
this.log = SimpleClans.getInstance().getLogger();
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
if (file == null) {
|
||||
|
||||
File dbFolder = new File(dbLocation);
|
||||
|
||||
if (dbName.contains("/") || dbName.contains("\\") || dbName.endsWith(".db")) {
|
||||
log.severe("The database name can not contain: /, \\, or .db");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dbFolder.exists()) {
|
||||
dbFolder.mkdir();
|
||||
}
|
||||
|
||||
file = new File(dbFolder.getAbsolutePath() + File.separator + dbName + ".db");
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
|
||||
connection = DriverManager.getConnection("jdbc:sqlite:" + file.getAbsolutePath());
|
||||
|
||||
} catch (SQLException ex) {
|
||||
log.severe("SQLite exception on initialize " + ex);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
@@ -98,7 +104,6 @@ public class SQLiteCore implements DBCore {
|
||||
@Override
|
||||
public ResultSet select(String query) {
|
||||
try {
|
||||
|
||||
return getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
log.severe("Error at SQL Query: " + ex.getMessage());
|
||||
@@ -114,14 +119,18 @@ public class SQLiteCore implements DBCore {
|
||||
*/
|
||||
@Override
|
||||
public void insert(String query) {
|
||||
try {
|
||||
getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet")) {
|
||||
log.severe("Error at SQL INSERT Query: " + ex);
|
||||
log.severe("Query: " + query);
|
||||
}
|
||||
}
|
||||
if (SimpleClans.getInstance().getSettingsManager().getUseThreads()) {
|
||||
executeAsync(query, "INSERT");
|
||||
} else {
|
||||
try {
|
||||
getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet")) {
|
||||
log.severe("Error at SQL INSERT Query: " + ex);
|
||||
log.severe("Query: " + query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,13 +140,17 @@ public class SQLiteCore implements DBCore {
|
||||
*/
|
||||
@Override
|
||||
public void update(String query) {
|
||||
try {
|
||||
getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet")) {
|
||||
log.severe("Error at SQL UPDATE Query: " + ex);
|
||||
log.severe("Query: " + query);
|
||||
}
|
||||
if (SimpleClans.getInstance().getSettingsManager().getUseThreads()) {
|
||||
executeAsync(query, "UPDATE");
|
||||
} else {
|
||||
try {
|
||||
getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet")) {
|
||||
log.severe("Error at SQL UPDATE Query: " + ex);
|
||||
log.severe("Query: " + query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,13 +161,17 @@ public class SQLiteCore implements DBCore {
|
||||
*/
|
||||
@Override
|
||||
public void delete(String query) {
|
||||
try {
|
||||
getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet")) {
|
||||
log.severe("Error at SQL DELETE Query: " + ex);
|
||||
log.severe("Query: " + query);
|
||||
}
|
||||
if (SimpleClans.getInstance().getSettingsManager().getUseThreads()) {
|
||||
executeAsync(query, "DELETE");
|
||||
} else {
|
||||
try {
|
||||
getConnection().createStatement().executeQuery(query);
|
||||
} catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet")) {
|
||||
log.severe("Error at SQL DELETE Query: " + ex);
|
||||
log.severe("Query: " + query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,4 +225,25 @@ public class SQLiteCore implements DBCore {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void executeAsync(String query, String sqlType) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
connection.createStatement().executeUpdate(query);
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
if (!ex.toString().contains("not return ResultSet"))
|
||||
{
|
||||
log.severe("[Thread] Error at SQL " + sqlType + " Query: " + ex);
|
||||
log.severe("[Thread] Query: " + query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(SimpleClans.getInstance());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.tasks;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
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.managers.SettingsManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class CollectFeeTask extends BukkitRunnable {
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public CollectFeeTask() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the repetitive task
|
||||
*/
|
||||
public void start() {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
|
||||
int hour = sm.getTasksCollectFeeHour();
|
||||
int minute = sm.getTasksCollectFeeMinute();
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimerAsynchronously(SimpleClans.getInstance(), delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
for (Clan clan : plugin.getClanManager().getClans()) {
|
||||
final double memberFee = clan.getMemberFee();
|
||||
|
||||
if (clan.isMemberFeeEnabled() && memberFee > 0) {
|
||||
for (ClanPlayer cp : clan.getFeePayers()) {
|
||||
|
||||
final boolean success = plugin.getPermissionsManager()
|
||||
.playerChargeMoney(Bukkit.getOfflinePlayer(cp.getUniqueId()), memberFee);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (success) {
|
||||
ChatBlock.sendMessage(cp.toPlayer(), ChatColor.AQUA +
|
||||
MessageFormat.format(plugin.getLang("fee.collected"), memberFee));
|
||||
clan.setBalance(clan.getBalance() + memberFee);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
} else {
|
||||
clan.removePlayerFromClan(cp.getUniqueId());
|
||||
clan.addBb(ChatColor.AQUA +
|
||||
MessageFormat.format(plugin.getLang("bb.fee.player.kicked"), cp.getName()));
|
||||
}
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.tasks;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class CollectUpkeepTask extends BukkitRunnable {
|
||||
private final SimpleClans plugin;
|
||||
private final SettingsManager settingsManager;
|
||||
|
||||
public CollectUpkeepTask() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
settingsManager = plugin.getSettingsManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the repetitive task
|
||||
*/
|
||||
public void start() {
|
||||
int hour = settingsManager.getTasksCollectUpkeepHour();
|
||||
int minute = settingsManager.getTasksCollectUpkeepMinute();
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimerAsynchronously(SimpleClans.getInstance(), delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin == null) {
|
||||
throw new IllegalStateException("Use the start() method!");
|
||||
}
|
||||
plugin.getClanManager().getClans().forEach((clan) -> {
|
||||
if (settingsManager.isChargeUpkeepOnlyIfMemberFeeEnabled() && !clan.isMemberFeeEnabled()) {
|
||||
return;
|
||||
}
|
||||
double upkeep = settingsManager.getClanUpkeep();
|
||||
if (settingsManager.isMultiplyUpkeepBySize()) {
|
||||
upkeep = upkeep * clan.getSize();
|
||||
}
|
||||
final double balance = clan.getBalance();
|
||||
if (balance >= upkeep) {
|
||||
clan.setBalance(balance - upkeep);
|
||||
clan.addBb(ChatColor.AQUA + MessageFormat.format(plugin.getLang("upkeep.collected"), upkeep), false);
|
||||
} else {
|
||||
clan.disband();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.tasks;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
* @since 2.10.2
|
||||
*
|
||||
*/
|
||||
public class SaveDataTask extends BukkitRunnable {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
/**
|
||||
* Starts the repetitive task
|
||||
*/
|
||||
public void start() {
|
||||
long interval = plugin.getSettingsManager().getSaveInterval() * 20;
|
||||
runTaskTimerAsynchronously(plugin, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getStorageManager().saveModified();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.tasks;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class UpkeepWarningTask extends BukkitRunnable {
|
||||
private final SimpleClans plugin;
|
||||
private final SettingsManager sm;
|
||||
|
||||
public UpkeepWarningTask() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
sm = plugin.getSettingsManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the repetitive task
|
||||
*
|
||||
*/
|
||||
public void start() {
|
||||
int hour = sm.getTasksCollectUpkeepWarningHour();
|
||||
int minute = sm.getTasksCollectUpkeepWarningMinute();
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimerAsynchronously(plugin, delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin == null) {
|
||||
throw new IllegalStateException("Use the start() method!");
|
||||
}
|
||||
plugin.getClanManager().getClans().forEach((clan) -> {
|
||||
if (sm.isChargeUpkeepOnlyIfMemberFeeEnabled() && !clan.isMemberFeeEnabled()) {
|
||||
return;
|
||||
}
|
||||
final double balance = clan.getBalance();
|
||||
double upkeep = sm.getClanUpkeep();
|
||||
if (sm.isMultiplyUpkeepBySize()) {
|
||||
upkeep = upkeep * clan.getSize();
|
||||
}
|
||||
if (balance < upkeep) {
|
||||
clan.addBb(MessageFormat.format(plugin.getLang("balance.is.not.enough.for.upkeep"), upkeep), false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,15 +10,15 @@ import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
*/
|
||||
public class ThreadUpdateSQL extends Thread {
|
||||
|
||||
Connection Connection;
|
||||
String Query;
|
||||
String TypeSQL;
|
||||
Connection connection;
|
||||
String query;
|
||||
String sqlType;
|
||||
|
||||
public ThreadUpdateSQL(Connection Connection, String Query, String TypeSQL)
|
||||
public ThreadUpdateSQL(Connection connection, String query, String sqlType)
|
||||
{
|
||||
this.Query = Query;
|
||||
this.Connection = Connection;
|
||||
this.TypeSQL = TypeSQL;
|
||||
this.query = query;
|
||||
this.connection = connection;
|
||||
this.sqlType = sqlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -26,14 +26,16 @@ public class ThreadUpdateSQL extends Thread {
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Connection.createStatement().executeUpdate(this.Query);
|
||||
if (!connection.isClosed()) {
|
||||
this.connection.createStatement().executeUpdate(this.query);
|
||||
}
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
if (!ex.toString().contains("not return ResultSet"))
|
||||
{
|
||||
SimpleClans.getLog().severe("[Thread] Error at SQL " + this.TypeSQL + " Query: " + ex);
|
||||
SimpleClans.getLog().severe("[Thread] Query: " + this.Query);
|
||||
SimpleClans.getInstance().getLogger().severe("[Thread] Error at SQL " + this.sqlType + " Query: " + ex);
|
||||
SimpleClans.getInstance().getLogger().severe("[Thread] Query: " + this.query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.WarningFrame;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public class InventoryController implements Listener {
|
||||
private static final Map<UUID, SCFrame> frames = new HashMap<>();
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
HumanEntity entity = event.getPlayer();
|
||||
if (!(entity instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
frames.remove(entity.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInteract(InventoryClickEvent event) {
|
||||
HumanEntity entity = event.getWhoClicked();
|
||||
if (!(entity instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SCFrame frame = frames.get(entity.getUniqueId());
|
||||
if (frame == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getClickedInventory() == null || event.getClickedInventory().getType() == InventoryType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
|
||||
SCComponent component = frame.getComponent(event.getSlot());
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Runnable listener = component.getListener(event.getClick());
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.isVerifiedOnly(event.getClick()) && !isClanVerified((Player) entity)) {
|
||||
InventoryDrawer.open(new WarningFrame(frame, (Player) entity, null));
|
||||
return;
|
||||
}
|
||||
|
||||
Object permission = component.getPermission(event.getClick());
|
||||
if (permission != null) {
|
||||
if (!hasPermission((Player) entity, permission)) {
|
||||
InventoryDrawer.open(new WarningFrame(frame, (Player) entity, permission));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(SimpleClans.getInstance(), () -> {
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
if (currentItem == null) return;
|
||||
|
||||
ItemMeta itemMeta = currentItem.getItemMeta();
|
||||
Objects.requireNonNull(itemMeta).setLore(Collections.singletonList(lang("gui.loading")));
|
||||
currentItem.setItemMeta(itemMeta);
|
||||
|
||||
listener.run();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the Player's Clan is verified
|
||||
* @param player the Player
|
||||
* @return if the Clan is verified
|
||||
*/
|
||||
private boolean isClanVerified(@NotNull Player player) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
|
||||
return cp != null && cp.getClan() != null && cp.getClan().isVerified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has the permission
|
||||
*
|
||||
* @param player the Player
|
||||
* @param permission the permission
|
||||
* @return true if they have permission
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
private boolean hasPermission(@NotNull Player player, @NotNull Object permission) {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
PermissionsManager pm = plugin.getPermissionsManager();
|
||||
if (permission instanceof String) {
|
||||
boolean leaderPerm = ((String) permission).contains("simpleclans.leader");
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
|
||||
return pm.has(player, (String) permission) && (!leaderPerm || cp.isLeader());
|
||||
}
|
||||
return pm.has(player, (RankPermission) permission, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the frame in the InventoryController
|
||||
* @param frame the frame
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public static void register(@NotNull SCFrame frame) {
|
||||
frames.put(frame.getViewer().getUniqueId(), frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the Player is registered
|
||||
*
|
||||
* @param player the Player
|
||||
* @return if they are registered
|
||||
*/
|
||||
public static boolean isRegistered(@NotNull Player player) {
|
||||
return frames.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a subcommand for the Player
|
||||
* @param player the Player
|
||||
* @param subcommand the subcommand
|
||||
* @param update whether to update the inventory instead of closing
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public static void runSubcommand(@NotNull Player player, @NotNull String subcommand, boolean update) {
|
||||
String baseCommand = SimpleClans.getInstance().getSettingsManager().getCommandClan();
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand(String.format("%s %s", baseCommand, subcommand));
|
||||
if (!update) {
|
||||
player.closeInventory();
|
||||
} else {
|
||||
InventoryDrawer.update(frames.get(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
}.runTask(SimpleClans.getInstance());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.MenuCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class InventoryDrawer {
|
||||
private static final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private static final ConcurrentHashMap<UUID, SCFrame> OPENING = new ConcurrentHashMap<>();
|
||||
|
||||
private InventoryDrawer() {
|
||||
}
|
||||
|
||||
public static void open(@Nullable SCFrame frame) {
|
||||
if (frame == null) {
|
||||
return;
|
||||
}
|
||||
UUID uuid = frame.getViewer().getUniqueId();
|
||||
if (frame.equals(OPENING.get(uuid))) {
|
||||
return;
|
||||
}
|
||||
|
||||
OPENING.put(uuid, frame);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
|
||||
Inventory inventory = prepareInventory(frame);
|
||||
|
||||
if (!frame.equals(OPENING.get(uuid))) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
frame.getViewer().openInventory(inventory);
|
||||
InventoryController.register(frame);
|
||||
OPENING.remove(uuid);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Inventory prepareInventory(@NotNull SCFrame frame) {
|
||||
Inventory inventory = Bukkit.createInventory(frame.getViewer(), frame.getSize(), frame.getTitle());
|
||||
long start = System.currentTimeMillis();
|
||||
setComponents(inventory, frame);
|
||||
|
||||
if (plugin.getSettingsManager().isDebugging()) {
|
||||
plugin.getLogger().log(Level.INFO,
|
||||
String.format("It took %s millisecond(s) to load the frame %s for %s",
|
||||
System.currentTimeMillis() - start, frame.getTitle(), frame.getViewer().getName()));
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void update(@NotNull SCFrame frame) {
|
||||
open(frame);
|
||||
}
|
||||
|
||||
private static void setComponents(@NotNull Inventory inventory, @NotNull SCFrame frame) {
|
||||
frame.clear();
|
||||
try {
|
||||
frame.createComponents();
|
||||
} catch (NoSuchFieldError ex) {
|
||||
runHelpCommand(frame.getViewer());
|
||||
return;
|
||||
}
|
||||
|
||||
Set<SCComponent> components = frame.getComponents();
|
||||
if (components.isEmpty()) {
|
||||
plugin.getLogger().warning(String.format("Frame %s has no components", frame.getTitle()));
|
||||
return;
|
||||
}
|
||||
for (SCComponent c : frame.getComponents()) {
|
||||
if (c.getSlot() >= frame.getSize()) {
|
||||
continue;
|
||||
}
|
||||
checkLorePermission(frame, c);
|
||||
inventory.setItem(c.getSlot(), c.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
private static void runHelpCommand(@NotNull Player player) {
|
||||
MenuCommand menuCommand = new MenuCommand();
|
||||
menuCommand.execute(player);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> plugin.getServer().getConsoleSender().sendMessage(lang("gui.not.supported")));
|
||||
plugin.getSettingsManager().setEnableGUI(false);
|
||||
}
|
||||
|
||||
private static void checkLorePermission(@NotNull SCFrame frame, @NotNull SCComponent component) {
|
||||
ItemMeta itemMeta = component.getItemMeta();
|
||||
if (itemMeta != null) {
|
||||
List<String> lore = itemMeta.getLore();
|
||||
if (lore != null) {
|
||||
Object permission = component.getLorePermission();
|
||||
if (permission != null) {
|
||||
if (!hasPermission(frame.getViewer(), permission)) {
|
||||
lore.clear();
|
||||
lore.add(lang("gui.lore.no.permission"));
|
||||
itemMeta.setLore(lore);
|
||||
component.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasPermission(@NotNull Player viewer, @NotNull Object permission) {
|
||||
if (permission instanceof String) {
|
||||
return plugin.getPermissionsManager().has(viewer, (String) permission);
|
||||
}
|
||||
return plugin.getPermissionsManager().has(viewer, (RankPermission) permission, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
|
||||
/**
|
||||
* Class that represents a button
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public abstract class SCComponent {
|
||||
|
||||
private final HashMap<ClickType, Runnable> listeners = new HashMap<>();
|
||||
private final HashMap<ClickType, Object> permissions = new HashMap<>();
|
||||
private final Set<ClickType> verified = new HashSet<>();
|
||||
private Object lorePermission;
|
||||
|
||||
@NotNull
|
||||
public abstract ItemStack getItem();
|
||||
|
||||
public abstract int getSlot();
|
||||
|
||||
@Nullable
|
||||
public ItemMeta getItemMeta() {
|
||||
return getItem().getItemMeta();
|
||||
}
|
||||
|
||||
public void setItemMeta(@NotNull ItemMeta itemMeta) {
|
||||
getItem().setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public void setVerifiedOnly(@NotNull ClickType clickType) {
|
||||
verified.add(clickType);
|
||||
}
|
||||
|
||||
public boolean isVerifiedOnly(@NotNull ClickType clickType) {
|
||||
return verified.contains(clickType);
|
||||
}
|
||||
|
||||
public void setLorePermission(@Nullable RankPermission permission) {
|
||||
lorePermission = permission;
|
||||
}
|
||||
|
||||
public void setLorePermission(@Nullable String permission) {
|
||||
lorePermission = permission;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getLorePermission() {
|
||||
return lorePermission;
|
||||
}
|
||||
|
||||
public void setPermission(@NotNull ClickType click, @Nullable RankPermission permission) {
|
||||
permissions.put(click, permission);
|
||||
}
|
||||
|
||||
public void setPermission(@NotNull ClickType click, @Nullable String permission) {
|
||||
permissions.put(click, permission);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getPermission(@NotNull ClickType click) {
|
||||
return permissions.get(click);
|
||||
}
|
||||
|
||||
public void setListener(@NotNull ClickType click, @Nullable Runnable listener) {
|
||||
listeners.put(click, listener);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Runnable getListener(@NotNull ClickType click) {
|
||||
return listeners.get(click);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SCComponentImpl extends SCComponent {
|
||||
|
||||
private final ItemStack item;
|
||||
private final int slot;
|
||||
|
||||
public SCComponentImpl(String displayName, List<String> lore, Material material, int slot) {
|
||||
item = new ItemStack(material);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setDisplayName(displayName);
|
||||
itemMeta.setLore(lore);
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public abstract class SCFrame {
|
||||
|
||||
private final SCFrame parent;
|
||||
private final Player viewer;
|
||||
private final Set<SCComponent> components = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public SCFrame(@Nullable SCFrame parent, @NotNull Player viewer) {
|
||||
this.parent = parent;
|
||||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract String getTitle();
|
||||
|
||||
@NotNull
|
||||
public Player getViewer() {
|
||||
return viewer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SCFrame getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public abstract int getSize();
|
||||
|
||||
public abstract void createComponents();
|
||||
|
||||
@Nullable
|
||||
public SCComponent getComponent(int slot) {
|
||||
for (SCComponent c : getComponents()) {
|
||||
if (c.getSlot() == slot) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void add(@NotNull SCComponent c) {
|
||||
components.add(c);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
components.clear();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<SCComponent> getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof SCFrame) {
|
||||
SCFrame otherFrame = (SCFrame) other;
|
||||
return getSize() == otherFrame.getSize() && getTitle().equals(otherFrame.getTitle())
|
||||
&& getComponents().equals(otherFrame.getComponents());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getTitle().hashCode() + Integer.hashCode(getSize()) + getComponents().hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class AddAllyFrame extends SCFrame {
|
||||
private final List<Clan> notAllies;
|
||||
private final Paginator paginator;
|
||||
|
||||
public AddAllyFrame(SCFrame parent, Player viewer, Clan subject) {
|
||||
super(parent, viewer);
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
notAllies = plugin.getClanManager().getClans().stream()
|
||||
.filter(c -> !c.equals(subject) && !c.isRival(subject.getTag()) && !c.isAlly(subject.getTag()))
|
||||
.collect(Collectors.toList());
|
||||
paginator = new Paginator(getSize() - 9, notAllies.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
|
||||
Clan notRival = notAllies.get(i);
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.clanlist.clan.title", notRival.getColorTag(), notRival.getName()),
|
||||
Collections.singletonList(lang("gui.add.ally.clan.lore")), Material.CYAN_BANNER, slot);
|
||||
|
||||
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("ally %s %s", lang("add"), notRival.getTag()), false));
|
||||
c.setPermission(ClickType.LEFT, RankPermission.ALLY_ADD);
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.add.ally.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Rank;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class AddPermissionFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private final String[] availablePermissions;
|
||||
private final Paginator paginator;
|
||||
private final Rank rank;
|
||||
|
||||
public AddPermissionFrame(SCFrame parent, Player viewer, Rank rank) {
|
||||
super(parent, viewer);
|
||||
this.rank = rank;
|
||||
Set<String> rankPerms = rank.getPermissions();
|
||||
availablePermissions = Arrays.stream(Helper.fromPermissionArray()).filter(p -> !rankPerms.contains(p))
|
||||
.toArray(String[]::new);
|
||||
paginator = new Paginator(getSize() - 9, availablePermissions.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
|
||||
String permission = availablePermissions[i];
|
||||
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.add.permission.permission.title", permission),
|
||||
Collections.singletonList(lang("gui.add.permission.permission.lore")), Material.PAPER, slot);
|
||||
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("rank permissions %s add %s", rank.getName(), permission), true));
|
||||
c.setPermission(ClickType.LEFT, "simpleclans.leader.rank.permissions.add");
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.add.permission.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 4 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class AddRivalFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
private final List<Clan> notRivals;
|
||||
private final Paginator paginator;
|
||||
|
||||
public AddRivalFrame(SCFrame parent, Player viewer, Clan subject) {
|
||||
super(parent, viewer);
|
||||
notRivals = plugin.getClanManager().getClans().stream()
|
||||
.filter(c -> !c.equals(subject) && !c.isRival(subject.getTag()) && !c.isAlly(subject.getTag()))
|
||||
.collect(Collectors.toList());
|
||||
paginator = new Paginator(getSize() - 9, notRivals.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
|
||||
Clan notRival = notRivals.get(i);
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.clanlist.clan.title", notRival.getColorTag(), notRival.getName()),
|
||||
Arrays.asList(lang("gui.add.rival.clan.lore")), Material.RED_BANNER, slot);
|
||||
|
||||
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("rival %s %s", lang("add"), notRival.getTag()), false));
|
||||
c.setPermission(ClickType.LEFT, RankPermission.RIVAL_ADD);
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.add.rival.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class AlliesFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private final Paginator paginator;
|
||||
private final List<String> allies;
|
||||
private final Clan subject;
|
||||
|
||||
public AlliesFrame(Player viewer, SCFrame parent, Clan subject) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
allies = subject.getAllies();
|
||||
paginator = new Paginator(getSize() - 9, allies.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 4 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
SCComponent add = new SCComponentImpl(lang("gui.allies.add.title"), null, Material.CYAN_WOOL, 4);
|
||||
add.setVerifiedOnly(ClickType.LEFT);
|
||||
add.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new AddAllyFrame(this, getViewer(), subject)));
|
||||
add.setPermission(ClickType.LEFT, RankPermission.ALLY_ADD);
|
||||
add(add);
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
|
||||
Clan clan = plugin.getClanManager().getClan(allies.get(i));
|
||||
if (clan == null)
|
||||
continue;
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.clanlist.clan.title", clan.getColorTag(), clan.getName()),
|
||||
Collections.singletonList(lang("gui.allies.clan.lore")), Material.CYAN_BANNER, slot);
|
||||
c.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("ally %s %s", lang("remove"), clan.getTag()), false));
|
||||
c.setPermission(ClickType.RIGHT, RankPermission.ALLY_REMOVE);
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.allies.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class ClanDetailsFrame extends SCFrame {
|
||||
private final Clan clan;
|
||||
private final ClanPlayer cp;
|
||||
|
||||
public ClanDetailsFrame(@Nullable SCFrame parent, @NotNull Player viewer, @NotNull Clan clan) {
|
||||
super(parent, viewer);
|
||||
this.clan = clan;
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
cp = plugin.getClanManager().getClanPlayer(getViewer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 4)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
|
||||
add(Components.getBackComponent(getParent(), 4));
|
||||
add(Components.getClanComponent(this, getViewer(), clan, 13, false));
|
||||
|
||||
addRoster();
|
||||
addCoords();
|
||||
addAllies();
|
||||
addRivals();
|
||||
addHome();
|
||||
addRegroup();
|
||||
addFf();
|
||||
addBank();
|
||||
addFee();
|
||||
addRank();
|
||||
addVerify();
|
||||
addResign();
|
||||
addDisband();
|
||||
addChat();
|
||||
}
|
||||
|
||||
private void addChat() {
|
||||
String joined = lang("chat.joined");
|
||||
String notJoined = lang("chat.not.joined");
|
||||
|
||||
Channel cpChannel = cp.getChannel();
|
||||
boolean clan = Channel.CLAN.equals(cpChannel);
|
||||
boolean ally = Channel.ALLY.equals(cpChannel);
|
||||
|
||||
String clanStatus = clan ? joined : notJoined;
|
||||
String allyStatus = ally ? joined : notJoined;
|
||||
|
||||
SCComponent chat = new SCComponentImpl(lang("gui.clandetails.chat.title"),
|
||||
Arrays.asList(lang("gui.clandetails.chat.clan.status.lore", clanStatus),
|
||||
lang("gui.clandetails.chat.ally.status.lore", allyStatus),
|
||||
lang("gui.clandetails.chat.clan.toggle.lore"),
|
||||
lang("gui.clandetails.chat.ally.toggle.lore")),
|
||||
Material.KNOWLEDGE_BOOK, 43);
|
||||
chat.setListener(ClickType.LEFT, () -> {
|
||||
if (clan) {
|
||||
cp.setChannel(Channel.NONE);
|
||||
} else {
|
||||
cp.setChannel(Channel.CLAN);
|
||||
}
|
||||
updateFrame();
|
||||
});
|
||||
chat.setPermission(ClickType.LEFT, "simpleclans.member.chat");
|
||||
chat.setListener(ClickType.RIGHT, () -> {
|
||||
if (ally) {
|
||||
cp.setChannel(Channel.NONE);
|
||||
} else {
|
||||
cp.setChannel(Channel.ALLY);
|
||||
}
|
||||
updateFrame();
|
||||
});
|
||||
chat.setPermission(ClickType.RIGHT, RankPermission.ALLY_CHAT);
|
||||
add(chat);
|
||||
}
|
||||
|
||||
private void addRank() {
|
||||
SCComponent rank = new SCComponentImpl(lang("gui.clandetails.rank.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.rank.lore")), Material.IRON_HELMET, 37);
|
||||
rank.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new RanksFrame(this, getViewer(), clan, null)));
|
||||
rank.setPermission(ClickType.LEFT, "simpleclans.leader.rank.list");
|
||||
add(rank);
|
||||
}
|
||||
|
||||
private void addFee() {
|
||||
String status = clan.isMemberFeeEnabled() ? lang("fee.enabled") : lang("fee.disabled");
|
||||
SCComponent fee = new SCComponentImpl(lang("gui.clandetails.fee.title"),
|
||||
Arrays.asList(lang("gui.clandetails.fee.value.lore", clan.getMemberFee()),
|
||||
lang("gui.clandetails.fee.status.lore", status),
|
||||
lang("gui.clandetails.fee.toggle.lore")),
|
||||
Material.GOLD_NUGGET, 41);
|
||||
fee.setVerifiedOnly(ClickType.LEFT);
|
||||
fee.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "toggle fee", true));
|
||||
fee.setPermission(ClickType.LEFT, RankPermission.FEE_ENABLE);
|
||||
add(fee);
|
||||
}
|
||||
|
||||
private void addDisband() {
|
||||
SCComponent disband = new SCComponentImpl(lang("gui.clandetails.disband.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.disband.lore")), Material.BARRIER, 50);
|
||||
disband.setListener(ClickType.MIDDLE, () -> InventoryController.runSubcommand(getViewer(), "disband", false));
|
||||
disband.setPermission(ClickType.MIDDLE, "simpleclans.leader.disband");
|
||||
add(disband);
|
||||
}
|
||||
|
||||
private void addResign() {
|
||||
SCComponent resign = new SCComponentImpl(lang("gui.clandetails.resign.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.resign.lore")), Material.IRON_DOOR, 48);
|
||||
resign.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "resign", false));
|
||||
resign.setPermission(ClickType.LEFT, "simpleclans.member.resign");
|
||||
add(resign);
|
||||
}
|
||||
|
||||
private void addVerify() {
|
||||
boolean verified = clan.isVerified();
|
||||
Material material = verified ? Material.REDSTONE_TORCH : Material.LEVER;
|
||||
String title = verified ? lang("gui.clandetails.verified.title")
|
||||
: lang("gui.clandetails.not.verified.title");
|
||||
List<String> lore = verified ? null : Collections.singletonList(lang("gui.clandetails.not.verified.lore"));
|
||||
SCComponent verify = new SCComponentImpl(title, lore, material, 39);
|
||||
if (!verified) {
|
||||
verify.setPermission(ClickType.LEFT, "simpleclans.leader.verify");
|
||||
verify.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "verify", false));
|
||||
}
|
||||
add(verify);
|
||||
}
|
||||
|
||||
private void addBank() {
|
||||
String withdrawStatus = clan.isAllowWithdraw() ? lang("allowed") : lang("blocked");
|
||||
String depositStatus = clan.isAllowDeposit() ? lang("allowed") : lang("blocked");
|
||||
SCComponent bank = new SCComponentImpl(lang("gui.clandetails.bank.title"),
|
||||
Arrays.asList(lang("gui.clandetails.bank.balance.lore", clan.getBalance()),
|
||||
lang("gui.clandetails.bank.withdraw.status.lore", withdrawStatus),
|
||||
lang("gui.clandetails.bank.deposit.status.lore", depositStatus),
|
||||
lang("gui.clandetails.bank.withdraw.toggle.lore"),
|
||||
lang("gui.clandetails.bank.deposit.toggle.lore")),
|
||||
Material.GOLD_INGOT, 34);
|
||||
bank.setLorePermission(RankPermission.BANK_BALANCE);
|
||||
bank.setVerifiedOnly(ClickType.MIDDLE);
|
||||
bank.setListener(ClickType.MIDDLE, () -> InventoryController.runSubcommand(getViewer(), "toggle withdraw", true));
|
||||
bank.setPermission(ClickType.MIDDLE, "simpleclans.leader.withdraw-toggle");
|
||||
bank.setVerifiedOnly(ClickType.RIGHT);
|
||||
bank.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(), "toggle deposit", true));
|
||||
bank.setPermission(ClickType.RIGHT, "simpleclans.leader.deposit-toggle");
|
||||
|
||||
add(bank);
|
||||
}
|
||||
|
||||
private void addFf() {
|
||||
String personalFf = cp.isFriendlyFire() ? lang("allowed") : lang("auto");
|
||||
String clanFf = clan.isFriendlyFire() ? lang("allowed") : lang("blocked");
|
||||
SCComponent ff = new SCComponentImpl(lang("gui.clandetails.ff.title"),
|
||||
Arrays.asList(lang("gui.clandetails.ff.personal.lore", personalFf),
|
||||
lang("gui.clandetails.ff.clan.lore", clanFf),
|
||||
lang("gui.clandetails.ff.personal.toggle.lore"),
|
||||
lang("gui.clandetails.ff.clan.toggle.lore")),
|
||||
Material.GOLDEN_SWORD, 32);
|
||||
|
||||
ff.setListener(ClickType.LEFT, this::togglePersonalFf);
|
||||
ff.setPermission(ClickType.LEFT, "simpleclans.member.ff");
|
||||
ff.setListener(ClickType.RIGHT, this::toggleClanFf);
|
||||
ff.setPermission(ClickType.RIGHT, "simpleclans.leader.ff");
|
||||
add(ff);
|
||||
}
|
||||
|
||||
private void toggleClanFf() {
|
||||
String arg;
|
||||
if (clan.isFriendlyFire()) {
|
||||
arg = lang("block");
|
||||
} else {
|
||||
arg = lang("allow");
|
||||
}
|
||||
InventoryController.runSubcommand(getViewer(), String.format("clanff %s", arg), true);
|
||||
}
|
||||
|
||||
private void togglePersonalFf() {
|
||||
String arg;
|
||||
if (cp.isFriendlyFire()) {
|
||||
arg = lang("auto");
|
||||
} else {
|
||||
arg = lang("allow");
|
||||
}
|
||||
InventoryController.runSubcommand(getViewer(), String.format("ff %s", arg), true);
|
||||
}
|
||||
|
||||
private void addRegroup() {
|
||||
SCComponent regroup = new SCComponentImpl(lang("gui.clandetails.regroup.title"),
|
||||
Arrays.asList(lang("gui.clandetails.regroup.lore.home"),
|
||||
lang("gui.clandetails.regroup.lore.me")),
|
||||
Material.BEACON, 30);
|
||||
regroup.setVerifiedOnly(ClickType.LEFT);
|
||||
regroup.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "home regroup", false));
|
||||
regroup.setPermission(ClickType.LEFT, RankPermission.HOME_REGROUP);
|
||||
regroup.setVerifiedOnly(ClickType.RIGHT);
|
||||
regroup.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(), "home regroup me", false));
|
||||
regroup.setPermission(ClickType.RIGHT, RankPermission.HOME_REGROUP);
|
||||
add(regroup);
|
||||
}
|
||||
|
||||
private void addHome() {
|
||||
SCComponent home = new SCComponentImpl(lang("gui.clandetails.home.title"),
|
||||
Arrays.asList(lang("gui.clandetails.home.lore.teleport"),
|
||||
lang("gui.clandetails.home.lore.set"),
|
||||
lang("gui.clandetails.home.lore.clear")),
|
||||
Material.MAGENTA_BED, 28);
|
||||
home.setVerifiedOnly(ClickType.LEFT);
|
||||
home.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "home", false));
|
||||
home.setPermission(ClickType.LEFT, RankPermission.HOME_TP);
|
||||
home.setVerifiedOnly(ClickType.RIGHT);
|
||||
home.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(), "home set", false));
|
||||
home.setPermission(ClickType.RIGHT, RankPermission.HOME_SET);
|
||||
home.setVerifiedOnly(ClickType.MIDDLE);
|
||||
home.setListener(ClickType.MIDDLE, () -> InventoryController.runSubcommand(getViewer(), "home clear", false));
|
||||
home.setPermission(ClickType.MIDDLE, RankPermission.HOME_SET);
|
||||
add(home);
|
||||
}
|
||||
|
||||
private void addRoster() {
|
||||
SCComponent roster = new SCComponentImpl(lang("gui.clandetails.roster.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.roster.lore")), Material.PLAYER_HEAD, 19);
|
||||
if (roster.getItemMeta() != null) {
|
||||
SkullMeta itemMeta = (SkullMeta) roster.getItemMeta();
|
||||
List<ClanPlayer> members = clan.getMembers();
|
||||
itemMeta.setOwningPlayer(Bukkit.getOfflinePlayer(
|
||||
members.get((int) (Math.random() * members.size())).getUniqueId()));
|
||||
roster.setItemMeta(itemMeta);
|
||||
}
|
||||
roster.setVerifiedOnly(ClickType.LEFT);
|
||||
roster.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new RosterFrame(getViewer(), this, clan)));
|
||||
roster.setPermission(ClickType.LEFT, "simpleclans.member.roster");
|
||||
add(roster);
|
||||
}
|
||||
|
||||
private void addCoords() {
|
||||
SCComponent coords = new SCComponentImpl(lang("gui.clandetails.coords.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.coords.lore")), Material.COMPASS, 21);
|
||||
coords.setVerifiedOnly(ClickType.LEFT);
|
||||
coords.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new CoordsFrame(getViewer(), this, clan)));
|
||||
coords.setPermission(ClickType.LEFT, RankPermission.COORDS);
|
||||
add(coords);
|
||||
}
|
||||
|
||||
private void addAllies() {
|
||||
SCComponent allies = new SCComponentImpl(lang("gui.clandetails.allies.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.allies.lore")), Material.CYAN_BANNER, 23);
|
||||
allies.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new AlliesFrame(getViewer(), this, clan)));
|
||||
allies.setPermission(ClickType.LEFT, "simpleclans.anyone.alliances");
|
||||
add(allies);
|
||||
}
|
||||
|
||||
private void addRivals() {
|
||||
SCComponent rivals = new SCComponentImpl(lang("gui.clandetails.rivals.title"),
|
||||
Collections.singletonList(lang("gui.clandetails.rivals.lore")), Material.RED_BANNER, 25);
|
||||
rivals.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new RivalsFrame(getViewer(), this, clan)));
|
||||
rivals.setPermission(ClickType.LEFT, "simpleclans.anyone.rivalries");
|
||||
add(rivals);
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.clandetails.title", Helper.stripColors(clan.getColorTag()),
|
||||
clan.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class ClanListFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private final List<Clan> clans = plugin.getClanManager().getClans();
|
||||
private final Paginator paginator;
|
||||
|
||||
public ClanListFrame(SCFrame parent, Player viewer) {
|
||||
super(parent, viewer);
|
||||
paginator = new Paginator(getSize() - 9, clans.size());
|
||||
plugin.getClanManager().sortClansByKDR(clans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
Clan clan = clans.get(i);
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.clanlist.clan.title", clan.getColorTag(), clan.getName()),
|
||||
Arrays.asList(lang("gui.clanlist.clan.lore.position", i + 1),
|
||||
lang("gui.clanlist.clan.lore.kdr", Helper.formatKDR(clan.getTotalKDR())),
|
||||
lang("gui.clanlist.clan.lore.members", clan.getMembers().size())),
|
||||
Material.BLACK_BANNER, slot);
|
||||
c.setLorePermission("simpleclans.anyone.list");
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.clanlist.title", clans.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
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.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class Components {
|
||||
|
||||
private Components() {
|
||||
}
|
||||
|
||||
public static SCComponent getPlayerComponent(SCFrame frame, Player viewer, OfflinePlayer subject, int slot,
|
||||
boolean openDetails) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getCreateClanPlayer(subject.getUniqueId());
|
||||
|
||||
return getPlayerComponent(frame, viewer, cp, slot, openDetails);
|
||||
}
|
||||
|
||||
public static SCComponent getPlayerComponent(SCFrame frame, Player viewer, ClanPlayer cp, int slot,
|
||||
boolean openDetails) {
|
||||
SimpleClans pl = SimpleClans.getInstance();
|
||||
|
||||
String status = cp.getClan() == null ? lang("free.agent")
|
||||
: (cp.isLeader() ? lang("leader")
|
||||
: (cp.isTrusted() ? lang("trusted") : lang("untrusted")));
|
||||
SCComponent c = new SCComponentImpl(lang("gui.playerdetails.player.title", cp.getName()),
|
||||
Arrays.asList(
|
||||
cp.getClan() == null ? lang("gui.playerdetails.player.lore.noclan")
|
||||
: lang("gui.playerdetails.player.lore.clan", cp.getClan().getColorTag(),
|
||||
cp.getClan().getName()),
|
||||
lang("gui.playerdetails.player.lore.rank",
|
||||
Helper.parseColors(cp.getRankDisplayName())),
|
||||
lang("gui.playerdetails.player.lore.status", status),
|
||||
lang("gui.playerdetails.player.lore.kdr",
|
||||
new DecimalFormat("#.#").format(cp.getKDR())),
|
||||
lang("gui.playerdetails.player.lore.kill.totals", cp.getRivalKills(),
|
||||
cp.getNeutralKills(), cp.getCivilianKills()),
|
||||
lang("gui.playerdetails.player.lore.deaths", cp.getDeaths()),
|
||||
lang("gui.playerdetails.player.lore.join.date", cp.getJoinDateString()),
|
||||
lang("gui.playerdetails.player.lore.last.seen", cp.getLastSeenString()),
|
||||
lang("gui.playerdetails.player.lore.past.clans", cp.getPastClansString(
|
||||
lang("gui.playerdetails.player.lore.past.clans.separator"))),
|
||||
lang("gui.playerdetails.player.lore.inactive", cp.getInactiveDays(),
|
||||
pl.getSettingsManager().getPurgePlayers())),
|
||||
Material.PLAYER_HEAD, slot);
|
||||
SkullMeta itemMeta = (SkullMeta) c.getItemMeta();
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(cp.getUniqueId());
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setOwningPlayer(offlinePlayer);
|
||||
c.setItemMeta(itemMeta);
|
||||
}
|
||||
if (viewer.getUniqueId().equals(cp.getUniqueId())) {
|
||||
c.setLorePermission("simpleclans.member.lookup");
|
||||
} else {
|
||||
c.setLorePermission("simpleclans.anyone.lookup");
|
||||
}
|
||||
if (openDetails) {
|
||||
c.setListener(ClickType.LEFT,
|
||||
() -> InventoryDrawer.open(new PlayerDetailsFrame(viewer, frame, offlinePlayer)));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static SCComponent getClanComponent(@NotNull SCFrame frame, @NotNull Player viewer,
|
||||
@Nullable Clan clan, int slot, boolean openDetails) {
|
||||
SimpleClans pl = SimpleClans.getInstance();
|
||||
String name;
|
||||
List<String> lore;
|
||||
if (clan != null) {
|
||||
name = lang("gui.clandetails.clan.title", clan.getColorTag(), clan.getName());
|
||||
lore = Arrays.asList(
|
||||
lang("gui.clandetails.clan.lore.description",
|
||||
clan.getDescription() != null && !clan.getDescription().isEmpty() ? clan.getDescription() : lang("no.description")),
|
||||
lang("gui.clandetails.clan.lore.status", clan.isVerified() ? lang("verified") : lang("unverified")),
|
||||
lang("gui.clandetails.clan.lore.leaders", clan.getLeadersString("", ", ")),
|
||||
lang("gui.clandetails.clan.lore.online.members", clan.getOnlineMembers().size(), clan.getMembers().size()),
|
||||
lang("gui.clandetails.clan.lore.kdr", Helper.formatKDR(clan.getTotalKDR())),
|
||||
lang("gui.clandetails.clan.lore.kill.totals", clan.getTotalRival(), clan.getTotalNeutral(), clan.getTotalCivilian()),
|
||||
lang("gui.clandetails.clan.lore.deaths", clan.getTotalDeaths()),
|
||||
lang("gui.clandetails.clan.lore.fee", clan.isMemberFeeEnabled()
|
||||
? lang("fee.enabled") : lang("fee.disabled"), clan.getMemberFee()),
|
||||
lang("gui.clandetails.clan.lore.allies", clan.getAllies().isEmpty() ? lang("none") : clan.getAllyString(lang("gui.clandetails.clan.lore.allies.separator"))),
|
||||
lang("gui.clandetails.clan.lore.rivals", clan.getRivals().isEmpty() ? lang("none") : clan.getRivalString(lang("gui.clandetails.clan.lore.rivals.separator"))),
|
||||
lang("gui.clandetails.clan.lore.founded", clan.getFoundedString()),
|
||||
lang("gui.clandetails.clan.lore.inactive", clan.getInactiveDays(), (clan.isVerified() ?
|
||||
pl.getSettingsManager().getPurgeClan() : pl.getSettingsManager().getPurgeUnverified())
|
||||
));
|
||||
} else {
|
||||
name = lang("gui.clandetails.free.agent.title");
|
||||
lore = null;
|
||||
}
|
||||
|
||||
SCComponent c = new SCComponentImpl(name, lore, Material.GREEN_BANNER, slot);
|
||||
if (openDetails && clan != null) {
|
||||
c.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new ClanDetailsFrame(frame, viewer, clan)));
|
||||
}
|
||||
|
||||
if (clan != null && clan.isMember(viewer)) {
|
||||
c.setLorePermission("simpleclans.member.profile");
|
||||
} else {
|
||||
c.setLorePermission("simpleclans.anyone.profile");
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static SCComponent getBackComponent(SCFrame parent, int slot) {
|
||||
SCComponent back = new SCComponentImpl(lang("gui.back.title"), null,
|
||||
Material.ARROW, slot);
|
||||
back.setListener(ClickType.LEFT, () -> InventoryDrawer.open(parent));
|
||||
return back;
|
||||
}
|
||||
|
||||
public static SCComponent getPanelComponent(int slot) {
|
||||
return new SCComponentImpl(" ", null, Material.GRAY_STAINED_GLASS_PANE, slot);
|
||||
}
|
||||
|
||||
public static SCComponent getPreviousPageComponent(int slot, @Nullable Runnable listener, @NotNull Paginator paginator) {
|
||||
if (!paginator.hasPreviousPage()) {
|
||||
return getPanelComponent(slot);
|
||||
}
|
||||
SCComponent c = new SCComponentImpl(lang("gui.previous.page.title"), null,
|
||||
Material.STONE_BUTTON, slot);
|
||||
c.setListener(ClickType.LEFT, listener);
|
||||
return c;
|
||||
}
|
||||
|
||||
public static SCComponent getNextPageComponent(int slot, @Nullable Runnable listener, @NotNull Paginator paginator) {
|
||||
if (!paginator.hasNextPage()) {
|
||||
return getPanelComponent(slot);
|
||||
}
|
||||
SCComponent c = new SCComponentImpl(lang("gui.next.page.title"), null,
|
||||
Material.STONE_BUTTON, slot);
|
||||
c.setListener(ClickType.LEFT, listener);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class CoordsFrame extends SCFrame {
|
||||
|
||||
private final Clan subject;
|
||||
private Paginator paginator;
|
||||
|
||||
public CoordsFrame(Player viewer, SCFrame parent, Clan subject) {
|
||||
super(parent, viewer);
|
||||
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
List<ClanPlayer> allMembers = subject.getOnlineMembers();
|
||||
allMembers.sort((cp1, cp2) -> Boolean.compare(cp1.isLeader(), cp2.isLeader()));
|
||||
|
||||
paginator = new Paginator(getSize() - 9, allMembers.size());
|
||||
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
ClanPlayer cp = allMembers.get(i);
|
||||
Location cpLoc = cp.toPlayer().getLocation();
|
||||
int distance = (int) Math.ceil(cpLoc.toVector().distance(getViewer().getLocation().toVector()));
|
||||
|
||||
SCComponent c = new SCComponentImpl(lang("gui.playerdetails.player.title", cp.getName()),
|
||||
Arrays.asList(lang("gui.coords.player.lore.distance", distance),
|
||||
lang("gui.coords.player.lore.coords", cpLoc.getBlockX(),
|
||||
cpLoc.getBlockY(), cpLoc.getBlockZ()),
|
||||
lang("gui.coords.player.lore.world", Objects.requireNonNull(cpLoc.getWorld()).getName())),
|
||||
Material.PLAYER_HEAD, slot);
|
||||
SkullMeta itemMeta = (SkullMeta) c.getItemMeta();
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(cp.getUniqueId());
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setOwningPlayer(offlinePlayer);
|
||||
c.setItemMeta(itemMeta);
|
||||
}
|
||||
c.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new PlayerDetailsFrame(getViewer(), this, offlinePlayer)));
|
||||
c.setLorePermission(RankPermission.COORDS);
|
||||
add(c);
|
||||
slot++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTitle() {
|
||||
return lang("gui.coords.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class InviteFrame extends SCFrame {
|
||||
|
||||
private Paginator paginator;
|
||||
|
||||
public InviteFrame(SCFrame parent, Player viewer) {
|
||||
super(parent, viewer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
ClanManager cm = plugin.getClanManager();
|
||||
List<Player> players = plugin.getServer().getOnlinePlayers().stream().filter(p -> cm.getClanPlayer(p) == null).collect(Collectors.toList());
|
||||
paginator = new Paginator(getSize() - 9, players.size());
|
||||
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
|
||||
Player player = players.get(i);
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.invite.player.title", player.getName()),
|
||||
Collections.singletonList(lang("gui.invite.player.lore")), Material.PLAYER_HEAD, slot);
|
||||
SkullMeta itemMeta = (SkullMeta) c.getItemMeta();
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getUniqueId());
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setOwningPlayer(offlinePlayer);
|
||||
c.setItemMeta(itemMeta);
|
||||
}
|
||||
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "invite " + player.getName(), false));
|
||||
c.setPermission(ClickType.LEFT, RankPermission.INVITE);
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.invite.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 3 * 9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class LeaderboardFrame extends SCFrame {
|
||||
|
||||
private final Paginator paginator;
|
||||
private final List<ClanPlayer> clanPlayers = SimpleClans.getInstance().getClanManager().getAllClanPlayers();
|
||||
|
||||
public LeaderboardFrame(Player viewer, SCFrame parent) {
|
||||
super(parent, viewer);
|
||||
paginator = new Paginator(getSize() - 9, clanPlayers.size());
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
plugin.getClanManager().sortClanPlayersByKDR(clanPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 2 || slot == 6 || slot == 7)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 2));
|
||||
|
||||
add(Components.getPreviousPageComponent(6, this::previousPage, paginator));
|
||||
add(Components.getNextPageComponent(7, this::nextPage, paginator));
|
||||
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
ClanPlayer cp = clanPlayers.get(i);
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.leaderboard.player.title", i + 1, cp.getName()),
|
||||
Arrays.asList(
|
||||
cp.getClan() == null ? lang("gui.playerdetails.player.lore.noclan")
|
||||
: lang("gui.playerdetails.player.lore.clan",
|
||||
cp.getClan().getColorTag(), cp.getClan().getName()),
|
||||
lang("gui.playerdetails.player.lore.kdr", Helper.formatKDR(cp.getKDR())),
|
||||
lang("gui.playerdetails.player.lore.last.seen", cp.getLastSeenString())),
|
||||
Material.PLAYER_HEAD, slot);
|
||||
SkullMeta itemMeta = (SkullMeta) c.getItemMeta();
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(cp.getUniqueId());
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setOwningPlayer(offlinePlayer);
|
||||
c.setItemMeta(itemMeta);
|
||||
}
|
||||
c.setListener(ClickType.LEFT,
|
||||
() -> InventoryDrawer.open(new PlayerDetailsFrame(getViewer(), this, offlinePlayer)));
|
||||
c.setLorePermission("simpleclans.anyone.leaderboard");
|
||||
add(c);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (paginator.previousPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (paginator.nextPage()) {
|
||||
updateFrame();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.leaderboard.title", clanPlayers.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user