mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-08 10:25:29 -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 |
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.
|
||||
@@ -4,3 +4,5 @@ SimpleClans.iml
|
||||
/bin/
|
||||
/.classpath
|
||||
/.project
|
||||
/dependency-reduced-pom.xml
|
||||
/simpleclans-mc1.8.iml
|
||||
@@ -3,13 +3,11 @@ SimpleClans
|
||||
|
||||
Full featured clan system for PVP Minecraft Servers
|
||||
|
||||
[](https://travis-ci.org/marcelo-mason/SimpleClans)
|
||||
[](https://github.com/marcelo-mason/SimpleClans/releases)
|
||||
[](https://github.com/marcelo-mason/SimpleClans/issues)
|
||||
[](https://ghit.me/repo/marcelo-mason/SimpleClans)
|
||||
[](https://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)
|
||||
|
||||
## Disclaimer:
|
||||
Spigot resource page: https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
|
||||
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.
|
||||
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.8.2</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-pt-br.yml</include>
|
||||
<include>language-zh.yml</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@@ -54,18 +52,41 @@
|
||||
<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>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
@@ -74,18 +95,44 @@
|
||||
<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>https://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>paper-repo</id>
|
||||
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
|
||||
<id>placeholderapi-repo</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bstats-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -51,6 +50,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private boolean allowWithdraw = false;
|
||||
private boolean allowDeposit = true;
|
||||
private boolean feeEnabled;
|
||||
private List<Rank> ranks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -300,26 +300,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return this.members.contains(player.getUniqueId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player is a member of this clan
|
||||
*
|
||||
@@ -469,23 +449,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
@@ -731,24 +694,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
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
|
||||
@@ -1106,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
|
||||
*
|
||||
@@ -1158,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);
|
||||
@@ -1171,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
|
||||
*
|
||||
@@ -1211,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
|
||||
*
|
||||
@@ -1344,7 +1217,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
online.remove(cp);
|
||||
|
||||
double minimum = SimpleClans.getInstance().getSettingsManager().getPercentageOnlineToDemote();
|
||||
double totalLeaders = getLeaders().size();
|
||||
// all leaders minus the one being demoted
|
||||
double totalLeaders = getLeaders().size() - 1;
|
||||
double onlineLeaders = online.size();
|
||||
|
||||
|
||||
@@ -1507,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();
|
||||
|
||||
@@ -1534,7 +1408,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
public void displayBb(Player player, int maxSize) {
|
||||
if (isVerified()) {
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.saySingle(player, MessageFormat.format(SimpleClans.getInstance().getLang("bulletin.board.header"), SimpleClans.getInstance().getSettingsManager().getBbAccentColor(), SimpleClans.getInstance().getSettingsManager().getPageHeadingsColor(), Helper.capitalize(getName())));
|
||||
ChatBlock.saySingle(player, 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) {
|
||||
@@ -1609,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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1894,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;
|
||||
}
|
||||
}
|
||||
@@ -543,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));
|
||||
}
|
||||
|
||||
@@ -977,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,10 +67,6 @@ public class Dates {
|
||||
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
|
||||
|
||||
@@ -5,6 +5,7 @@ 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;
|
||||
@@ -13,11 +14,13 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
/**
|
||||
@@ -37,6 +40,93 @@ public class Helper {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
@@ -73,8 +163,10 @@ public class Helper {
|
||||
* @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(1, 0));
|
||||
LocalDateTime d = LocalDateTime.of(now.toLocalDate(), LocalTime.of(hour, minute));
|
||||
long delay;
|
||||
if (now.isAfter(d)) {
|
||||
delay = now.until(d.plusDays(1), ChronoUnit.SECONDS);
|
||||
@@ -317,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
|
||||
@@ -457,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());
|
||||
@@ -631,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();
|
||||
@@ -639,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);
|
||||
@@ -673,7 +780,7 @@ public class Helper {
|
||||
|
||||
String leaderColor = sm.getAllyChatLeaderColor();
|
||||
String memberColor = sm.getAllyChatMemberColor();
|
||||
String rank = cp.getRank().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRank());
|
||||
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.getAllyChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
@@ -708,7 +815,7 @@ public class Helper {
|
||||
|
||||
String leaderColor = sm.getClanChatLeaderColor();
|
||||
String memberColor = sm.getClanChatMemberColor();
|
||||
String rank = cp.getRank().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRank());
|
||||
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.getClanChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
|
||||
@@ -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,213 +1,293 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.AcceptCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.AllyCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.ClanCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.DenyCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.GlobalCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.executors.MoreCommandExecutor;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCEntityListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCPlayerListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.LanguageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.RequestManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.TeleportManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.CollectFeeTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.CollectUpkeepTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.UpkeepWarningTask;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
|
||||
/**
|
||||
* @author Phaed
|
||||
*/
|
||||
public class SimpleClans extends JavaPlugin {
|
||||
|
||||
private ArrayList<String> messages = new ArrayList<>();
|
||||
private static SimpleClans instance;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private ClanManager clanManager;
|
||||
private RequestManager requestManager;
|
||||
private StorageManager storageManager;
|
||||
private SettingsManager settingsManager;
|
||||
private PermissionsManager permissionsManager;
|
||||
private TeleportManager teleportManager;
|
||||
private LanguageManager languageManager;
|
||||
private ChatFormatMigration chatFormatMigration;
|
||||
private boolean hasUUID;
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
*/
|
||||
public static Logger getLog() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
*/
|
||||
public static void debug(String msg) {
|
||||
if (getInstance().getSettingsManager().isDebugging()) {
|
||||
logger.log(Level.INFO, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static SimpleClans getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void log(String msg, Object... arg) {
|
||||
if (arg == null || arg.length == 0) {
|
||||
logger.log(Level.INFO, msg);
|
||||
} else {
|
||||
logger.log(Level.INFO, MessageFormat.format(msg, arg));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
settingsManager = new SettingsManager();
|
||||
this.hasUUID = UUIDMigration.canReturnUUID();
|
||||
languageManager = new LanguageManager();
|
||||
|
||||
permissionsManager = new PermissionsManager();
|
||||
requestManager = new RequestManager();
|
||||
clanManager = new ClanManager();
|
||||
storageManager = new StorageManager();
|
||||
teleportManager = new TeleportManager();
|
||||
chatFormatMigration = new ChatFormatMigration();
|
||||
|
||||
chatFormatMigration.migrateAllyChat();
|
||||
chatFormatMigration.migrateClanChat();
|
||||
|
||||
logger.info(MessageFormat.format(getLang("version.loaded"), getDescription().getName(), getDescription().getVersion()));
|
||||
|
||||
getServer().getPluginManager().registerEvents(new SCEntityListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new SCPlayerListener(), this);
|
||||
|
||||
permissionsManager.loadPermissions();
|
||||
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandClan());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandAccept());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandDeny());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandMore());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandAlly());
|
||||
CommandHelper.registerCommand(getSettingsManager().getCommandGlobal());
|
||||
|
||||
getCommand(getSettingsManager().getCommandClan()).setExecutor(new ClanCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandAccept()).setExecutor(new AcceptCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandDeny()).setExecutor(new DenyCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandMore()).setExecutor(new MoreCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandAlly()).setExecutor(new AllyCommandExecutor());
|
||||
getCommand(getSettingsManager().getCommandGlobal()).setExecutor(new GlobalCommandExecutor());
|
||||
|
||||
getCommand(getSettingsManager().getCommandClan()).setTabCompleter(new PlayerNameTabCompleter());
|
||||
logger.info("[SimpleClans] 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());
|
||||
|
||||
startTasks();
|
||||
}
|
||||
|
||||
private void startTasks() {
|
||||
if (getSettingsManager().isMemberFee()) {
|
||||
new CollectFeeTask().start();
|
||||
}
|
||||
if (getSettingsManager().isClanUpkeep()) {
|
||||
new CollectUpkeepTask().start();
|
||||
new UpkeepWarningTask().start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
getStorageManager().closeConnection();
|
||||
getPermissionsManager().savePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clanManager
|
||||
*/
|
||||
public ClanManager getClanManager() {
|
||||
return clanManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requestManager
|
||||
*/
|
||||
public RequestManager getRequestManager() {
|
||||
return requestManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storageManager
|
||||
*/
|
||||
public StorageManager getStorageManager() {
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the settingsManager
|
||||
*/
|
||||
public SettingsManager getSettingsManager() {
|
||||
return settingsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the permissionsManager
|
||||
*/
|
||||
public PermissionsManager getPermissionsManager() {
|
||||
return permissionsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg the path within the language file
|
||||
* @return the lang
|
||||
*/
|
||||
public String getLang(String msg) {
|
||||
return languageManager.get(msg);
|
||||
}
|
||||
|
||||
public TeleportManager getTeleportManager() {
|
||||
return teleportManager;
|
||||
}
|
||||
|
||||
public List<String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hasUUID
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasUUID() {
|
||||
return this.hasUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trueOrFalse
|
||||
*/
|
||||
public void setUUID(boolean trueOrFalse) {
|
||||
this.hasUUID = trueOrFalse;
|
||||
}
|
||||
|
||||
public LanguageManager getLanguageManager() {
|
||||
return languageManager;
|
||||
}
|
||||
}
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import 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;
|
||||
}
|
||||
}
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -38,22 +38,21 @@ public class BanCommand {
|
||||
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
if (uuid == null) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Player pl = SimpleClans.getInstance().getServer().getPlayer(uuid);
|
||||
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"));
|
||||
}
|
||||
|
||||
plugin.getClanManager().ban(uuid);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.added.to.banned.list"));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DemoteCommand {
|
||||
|
||||
clan.demote(toDemote.getUniqueId());
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("demoted.back.to.member"), Helper.capitalize(demotedName)));
|
||||
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;
|
||||
}
|
||||
@@ -92,14 +92,14 @@ public class DemoteCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("player.is.not.a.leader.of.your.clan"));
|
||||
return;
|
||||
}
|
||||
if (clan.getLeaders().size() != 1 && plugin.getSettingsManager().isConfirmationForDemote()) {
|
||||
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"), Helper.capitalize(demotedName)));
|
||||
+ MessageFormat.format(plugin.getLang("demoted.back.to.member"), demotedName));
|
||||
clan.demote(uuid);
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -9,6 +9,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 net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
@@ -41,9 +43,8 @@ public class DescriptionCommand {
|
||||
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.DESCRIPTION, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
@@ -63,6 +64,6 @@ public class DescriptionCommand {
|
||||
|
||||
clan.setDescription(description);
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("description.changed"));
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ 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;
|
||||
@@ -23,9 +25,10 @@ public class FeeCommand {
|
||||
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();
|
||||
@@ -48,8 +51,7 @@ public class FeeCommand {
|
||||
return;
|
||||
}
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("set")) {
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.leader.fee")) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
if (!plugin.getPermissionsManager().has(player, RankPermission.FEE_SET, PermissionLevel.LEADER, true)) {
|
||||
return;
|
||||
}
|
||||
if (!cp.isLeader()) {
|
||||
@@ -74,7 +76,7 @@ public class FeeCommand {
|
||||
clan.setMemberFee(newFee);
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("bb.fee.set"), newFee));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("fee.set"));
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,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;
|
||||
|
||||
/**
|
||||
@@ -43,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) {
|
||||
@@ -100,6 +102,6 @@ public class InviteCommand {
|
||||
}
|
||||
|
||||
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,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;
|
||||
@@ -43,10 +45,10 @@ 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;
|
||||
@@ -70,7 +72,7 @@ public class KickCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.kicked.by"), Helper.capitalize(arg[0]), player.getName()));
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("has.been.kicked.by"), arg[0], player.getName()));
|
||||
clan.removePlayerFromClan(kicked);
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,8 @@ public class KillsCommand {
|
||||
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 (!plugin.getPermissionsManager().has(player, RankPermission.KILLS, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String polledPlayerName = player.getName();
|
||||
@@ -83,7 +82,7 @@ public class KillsCommand {
|
||||
chatBlock.addRow(" " + playerKills.getKey(), ChatColor.AQUA + "" + count);
|
||||
}
|
||||
|
||||
ChatBlock.saySingle(player, plugin.getSettingsManager().getPageClanNameColor() + Helper.capitalize(name) + subColor + " " + plugin.getLang("kills") + " " + headColor + Helper.generatePageSeparator(plugin.getSettingsManager().getPageSep()));
|
||||
ChatBlock.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());
|
||||
|
||||
@@ -72,7 +72,7 @@ public class LookupCommand {
|
||||
}
|
||||
|
||||
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 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";
|
||||
|
||||
@@ -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,46 +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 && plugin.getPermissionsManager().has(player, "simpleclans.member.fee-check")) {
|
||||
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 (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.fee")) {
|
||||
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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.ally")) {
|
||||
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")) {
|
||||
@@ -129,27 +138,27 @@ 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 && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.description")) {
|
||||
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 (isVerified && isLeader && plugin.getPermissionsManager().has(player, "simpleclans.leader.fee")) {
|
||||
if (plugin.getSettingsManager().isMemberFee() && isVerified && plugin.getPermissionsManager().has(player, RankPermission.FEE_ENABLE, PermissionLevel.LEADER, false)) {
|
||||
toggles += "fee/";
|
||||
}
|
||||
|
||||
@@ -157,21 +166,48 @@ public class MenuCommand {
|
||||
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));
|
||||
}
|
||||
@@ -201,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")) {
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -46,9 +46,8 @@ public class MostKilledCommand {
|
||||
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 (!plugin.getPermissionsManager().has(player, RankPermission.MOSTKILLED, PermissionLevel.TRUSTED, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getStorageManager().getMostKilled(new DataCallback<Map<String, Integer>>() {
|
||||
|
||||
@@ -58,7 +58,7 @@ 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())));
|
||||
oldClan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("0.has.resigned"), player.getName()));
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ProfileCommand {
|
||||
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.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();
|
||||
|
||||
@@ -63,12 +63,19 @@ 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;
|
||||
}
|
||||
|
||||
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"), Helper.capitalize(promoted.getName())));
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + MessageFormat.format(plugin.getLang("promoted.to.leader"), promoted.getName()));
|
||||
clan.promote(promoted.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ 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;
|
||||
@@ -35,12 +37,21 @@ public class PurgeCommand {
|
||||
|
||||
if (args.length == 1) {
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(args[0]);
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(uuid);
|
||||
if (uuid == null || cp == null) {
|
||||
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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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()) + ChatColor.RESET, 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()) + ChatColor.RESET, lastSeen);
|
||||
chatBlock.addRow(" " + name, ChatColor.YELLOW + Helper.parseColors(cp.getRankDisplayName()) + ChatColor.RESET, lastSeen);
|
||||
}
|
||||
|
||||
boolean more = chatBlock.sendBlock(player, plugin.getSettingsManager().getPageSize());
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
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.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetRankCommand {
|
||||
public SetRankCommand() {
|
||||
@@ -22,46 +20,12 @@ public class SetRankCommand {
|
||||
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;
|
||||
}
|
||||
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(arg[0]);
|
||||
String rank = Helper.toMessage(Helper.removeFirst(arg));
|
||||
|
||||
if (uuid == null || (!clan.isMember(uuid) && !clan.isLeader(uuid))) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.player.matched"));
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer cpm = plugin.getClanManager().getClanPlayer(uuid);
|
||||
cpm.setRank(rank);
|
||||
plugin.getStorageManager().updateClanPlayer(cpm);
|
||||
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("player.rank.changed"));
|
||||
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());
|
||||
|
||||
@@ -3,10 +3,14 @@ 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
|
||||
*/
|
||||
@@ -39,24 +43,28 @@ public class ToggleCommand {
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isCapeEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("capeoff"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("capeoff"));
|
||||
cp.setCapeEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("capeon"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("capeon"));
|
||||
cp.setCapeEnabled(true);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("clan.is.not.verified"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("clan.is.not.verified"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("not.a.member.of.any.clan"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("not.a.member.of.any.clan"));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("insufficient.permissions"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions"));
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("bb") && plugin.getPermissionsManager().has(player, "simpleclans.member.bb-toggle")) {
|
||||
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) {
|
||||
@@ -64,10 +72,10 @@ public class ToggleCommand {
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isBbEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("bboff"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("bboff"));
|
||||
cp.setBbEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("bbon"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("bbon"));
|
||||
cp.setBbEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
@@ -75,7 +83,11 @@ public class ToggleCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("tag") && plugin.getPermissionsManager().has(player, "simpleclans.member.tag-toggle")) {
|
||||
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) {
|
||||
@@ -83,10 +95,10 @@ public class ToggleCommand {
|
||||
|
||||
if (clan.isVerified()) {
|
||||
if (cp.isTagEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("tagoff"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("tagoff"));
|
||||
cp.setTagEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("tagon"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("tagon"));
|
||||
cp.setTagEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
@@ -94,7 +106,11 @@ public class ToggleCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("deposit") && plugin.getPermissionsManager().has(player, "simpleclans.leader.deposit-toggle")) {
|
||||
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) {
|
||||
@@ -102,55 +118,55 @@ public class ToggleCommand {
|
||||
if (clan.isLeader(player)) {
|
||||
if (clan.isVerified()) {
|
||||
if (clan.isAllowDeposit()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("depositoff"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("depositoff"));
|
||||
clan.setAllowDeposit(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("depositon"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("depositon"));
|
||||
clan.setAllowDeposit(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("no.leader.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("fee") && plugin.getPermissionsManager().has(player, "simpleclans.leader.fee")) {
|
||||
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.isLeader(player)) {
|
||||
if (clan.isMemberFeeEnabled()) {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("feeoff"));
|
||||
clan.setMemberFeeEnabled(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("feeon"));
|
||||
clan.setMemberFeeEnabled(true);
|
||||
}
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
}
|
||||
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") && plugin.getPermissionsManager().has(player, "simpleclans.leader.withdraw-toggle")) {
|
||||
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 + plugin.getLang("withdrawoff"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("withdrawoff"));
|
||||
clan.setAllowWithdraw(false);
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + plugin.getLang("withdrawon"));
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("withdrawon"));
|
||||
clan.setAllowWithdraw(true);
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("no.leader.permissions"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("no.leader.permissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,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(arg[0]), 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);
|
||||
}
|
||||
|
||||
@@ -81,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(arg[0]), 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"));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -10,7 +11,6 @@ import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import static org.bukkit.conversations.Prompt.END_OF_CONVERSATION;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -29,23 +29,27 @@ public class ResignPrompt extends StringPrompt {
|
||||
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"), Helper.capitalize(player.getName())));
|
||||
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) {
|
||||
plugin.getClanManager().serverAnnounce(ChatColor.AQUA + MessageFormat.format(plugin.getLang("clan.has.been.disbanded"), clan.getName()));
|
||||
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"));
|
||||
}
|
||||
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -42,8 +42,9 @@ 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"));
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
|
||||
+121
-58
@@ -1,12 +1,65 @@
|
||||
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
|
||||
@@ -56,6 +109,7 @@ public final class ClanCommandExecutor implements CommandExecutor {
|
||||
private final ResetKDRCommand resetKDRCommand;
|
||||
private final PurgeCommand purgeCommand;
|
||||
private final DescriptionCommand descriptionCommand;
|
||||
private final RankCommand rankCommand;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -105,10 +159,11 @@ public final class ClanCommandExecutor implements CommandExecutor {
|
||||
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;
|
||||
@@ -118,102 +173,110 @@ public final class ClanCommandExecutor implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isBanned(player.getUniqueId())) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + plugin.getLang("banned"));
|
||||
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 if (subcommand.equalsIgnoreCase(plugin.getLang("fee.command")) || subcommand.equalsIgnoreCase("fee")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("fee.command",player)) || subcommand.equalsIgnoreCase("fee")) {
|
||||
feeCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("purge.command")) || subcommand.equalsIgnoreCase("purge")){
|
||||
} else if (subcommand.equalsIgnoreCase(lang("purge.command",player)) || subcommand.equalsIgnoreCase("purge")){
|
||||
purgeCommand.execute(player, subargs);
|
||||
} else if (subcommand.equalsIgnoreCase(plugin.getLang("description.command")) || subcommand.equalsIgnoreCase("description")) {
|
||||
} 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 + plugin.getLang("does.not.match"));
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("does.not.match",player));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -223,23 +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 if (subcommand.equalsIgnoreCase(plugin.getLang("purge.command")) || subcommand.equalsIgnoreCase("purge")) {
|
||||
} else if (subcommand.equalsIgnoreCase(lang("purge.command")) || subcommand.equalsIgnoreCase("purge")) {
|
||||
purgeCommand.execute(sender, subargs);
|
||||
} else {
|
||||
ChatBlock.sendMessage(sender, ChatColor.RED + plugin.getLang("does.not.match"));
|
||||
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());
|
||||
}
|
||||
|
||||
+2
-2
@@ -43,8 +43,8 @@ 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"));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -4,10 +4,10 @@ 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 net.sacredlabyrinth.phaed.simpleclans.Kill.Type;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -97,22 +97,22 @@ public class SCEntityListener implements Listener
|
||||
|
||||
}
|
||||
}
|
||||
String kdrExempt = "simpleclans.anyone.kdr-exempt";
|
||||
String kdrExempt = "simpleclans.other.kdr-exempt";
|
||||
PermissionsManager pm = plugin.getPermissionsManager();
|
||||
if (pm.has(attacker, kdrExempt) || pm.has(victim, kdrExempt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer attackerCp = plugin.getClanManager().getCreateClanPlayer(attacker.getUniqueId());
|
||||
ClanPlayer victimCp = plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId());
|
||||
|
||||
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 = attackerCp.getKDR();
|
||||
|
||||
if (victimCp.getClan() == null || attackerCp.getClan() == null || !victimCp.getClan().isVerified() || !attackerCp.getClan().isVerified())
|
||||
{
|
||||
addKill(Type.CIVILIAN, attackerCp, victimCp);
|
||||
addKill(Kill.Type.CIVILIAN, attackerCp, victimCp);
|
||||
} else if (attackerCp.getClan().isRival(victimCp.getTag()))
|
||||
{
|
||||
if (attackerCp.getClan().isWarring(victimCp.getClan()))
|
||||
@@ -122,14 +122,14 @@ public class SCEntityListener implements Listener
|
||||
{
|
||||
reward = (double) kdr * multipier * 2;
|
||||
}
|
||||
addKill(Type.RIVAL, attackerCp, victimCp);
|
||||
addKill(Kill.Type.RIVAL, attackerCp, victimCp);
|
||||
} else if (attackerCp.getClan().isAlly(victimCp.getTag()))
|
||||
{
|
||||
reward = (double) kdr * multipier * -1;
|
||||
} else
|
||||
{
|
||||
reward = (double) kdr * multipier;
|
||||
addKill(Type.NEUTRAL, attackerCp, victimCp);
|
||||
addKill(Kill.Type.NEUTRAL, attackerCp, victimCp);
|
||||
}
|
||||
|
||||
if (reward != 0 && plugin.getSettingsManager().isMoneyPerKill())
|
||||
@@ -144,11 +144,10 @@ public class SCEntityListener implements Listener
|
||||
|
||||
// record death for victim
|
||||
victimCp.addDeath();
|
||||
plugin.getStorageManager().updateClanPlayerAsync(victimCp);
|
||||
plugin.getStorageManager().updateClanPlayer(victimCp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addKill(Kill.Type type, ClanPlayer attacker, ClanPlayer victim) {
|
||||
if (type == null || attacker == null || victim == null) {
|
||||
return;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -18,15 +18,17 @@ 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 HashMap<ClanPlayer, List<Kill>> kills = 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<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -156,7 +158,7 @@ public final class ClanManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a player's kdr
|
||||
* Reset a player's KDR
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
@@ -165,7 +167,7 @@ public final class ClanManager {
|
||||
cp.setNeutralKills(0);
|
||||
cp.setRivalKills(0);
|
||||
cp.setDeaths(0);
|
||||
plugin.getStorageManager().updateClanPlayerAsync(cp);
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,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
|
||||
*
|
||||
@@ -304,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
|
||||
@@ -379,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
|
||||
@@ -410,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
|
||||
*
|
||||
@@ -497,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;
|
||||
@@ -527,22 +447,21 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Bans a player from clan commands
|
||||
*
|
||||
@@ -550,7 +469,10 @@ public final class ClanManager {
|
||||
*/
|
||||
public void ban(UUID uuid) {
|
||||
ClanPlayer cp = getClanPlayer(uuid);
|
||||
Clan clan = cp.getClan();
|
||||
Clan clan = null;
|
||||
if (cp != null) {
|
||||
clan = cp.getClan();
|
||||
}
|
||||
|
||||
if (clan != null) {
|
||||
if (clan.getSize() == 1) {
|
||||
@@ -569,32 +491,6 @@ public final class ClanManager {
|
||||
|
||||
plugin.getSettingsManager().addBanned(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
*/
|
||||
@Deprecated
|
||||
public void ban(String playerName) {
|
||||
ClanPlayer cp = getClanPlayer(playerName);
|
||||
Clan clan = cp.getClan();
|
||||
|
||||
if (clan != null) {
|
||||
if (clan.getSize() == 1) {
|
||||
clan.disband();
|
||||
} else {
|
||||
cp.setClan(null);
|
||||
cp.addPastClan(clan.getColorTag() + (cp.isLeader() ? ChatColor.DARK_RED + "*" : ""));
|
||||
cp.setLeader(false);
|
||||
cp.setJoinDate(0);
|
||||
clan.removeMember(playerName);
|
||||
|
||||
plugin.getStorageManager().updateClanPlayer(cp);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getSettingsManager().addBanned(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a count of rivable clans
|
||||
@@ -1313,26 +1209,26 @@ 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 {
|
||||
final List<ClanPlayer> receivers = new LinkedList<>();
|
||||
@@ -1416,26 +1312,26 @@ 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 {
|
||||
final List<ClanPlayer> receivers = new LinkedList<>();
|
||||
@@ -1462,7 +1358,7 @@ public final class ClanManager {
|
||||
}
|
||||
|
||||
String message = Helper.formatAllyChat(cp, ce.getMessage(), ce.getPlaceholders());
|
||||
SimpleClans.log(message);
|
||||
plugin.getLogger().info(message);
|
||||
|
||||
Player self = cp.toPlayer();
|
||||
ChatBlock.sendMessage(self, message);
|
||||
|
||||
@@ -9,13 +9,14 @@ import java.io.*;
|
||||
import java.util.HashMap;
|
||||
|
||||
@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() {
|
||||
|
||||
+126
-7
@@ -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
|
||||
*/
|
||||
@@ -281,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 "";
|
||||
}
|
||||
}
|
||||
+201
-157
@@ -44,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);
|
||||
}
|
||||
|
||||
@@ -64,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);
|
||||
}
|
||||
|
||||
@@ -81,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);
|
||||
}
|
||||
|
||||
@@ -99,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);
|
||||
@@ -113,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);
|
||||
}
|
||||
|
||||
@@ -131,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);
|
||||
}
|
||||
|
||||
@@ -149,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);
|
||||
}
|
||||
|
||||
@@ -167,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);
|
||||
}
|
||||
|
||||
@@ -233,152 +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)));
|
||||
clan.demote(demotedUniqueId);
|
||||
} 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)));
|
||||
clan.promote(promotedUniqueId);
|
||||
} 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
|
||||
*
|
||||
@@ -389,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;
|
||||
}
|
||||
@@ -403,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();
|
||||
|
||||
@@ -418,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1679
-1613
File diff suppressed because it is too large.
Load diff
@@ -16,6 +16,7 @@ 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;
|
||||
@@ -28,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<>();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -73,10 +76,10 @@ 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,"
|
||||
@@ -96,13 +99,14 @@ public final class StorageManager {
|
||||
+ " `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,"
|
||||
@@ -126,7 +130,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
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,"
|
||||
@@ -145,10 +149,11 @@ 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),"
|
||||
@@ -168,13 +173,14 @@ public final class StorageManager {
|
||||
+ " `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),"
|
||||
@@ -198,7 +204,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
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),"
|
||||
@@ -241,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();
|
||||
@@ -257,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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,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);
|
||||
}
|
||||
@@ -316,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);
|
||||
}
|
||||
@@ -348,6 +354,7 @@ public final class StorageManager {
|
||||
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");
|
||||
@@ -379,6 +386,7 @@ public final class StorageManager {
|
||||
clan.setBalance(balance);
|
||||
clan.setMemberFee(feeValue);
|
||||
clan.setMemberFeeEnabled(feeEnabled);
|
||||
clan.setRanks(Helper.ranksFromJson(ranks));
|
||||
|
||||
out.add(clan);
|
||||
} catch (Exception ex) {
|
||||
@@ -388,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,6 +432,7 @@ public final class StorageManager {
|
||||
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");
|
||||
@@ -455,6 +464,7 @@ public final class StorageManager {
|
||||
clan.setBalance(balance);
|
||||
clan.setMemberFee(feeValue);
|
||||
clan.setMemberFeeEnabled(feeEnabled);
|
||||
clan.setRanks(Helper.ranksFromJson(ranks));
|
||||
|
||||
out = clan;
|
||||
} catch (Exception ex) {
|
||||
@@ -464,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,8 +672,25 @@ public final class StorageManager {
|
||||
* @param clan
|
||||
*/
|
||||
public void insertClan(Clan clan) {
|
||||
String query = "INSERT INTO `sc_clans` (`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(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())) + "');";
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -672,6 +699,7 @@ public final class StorageManager {
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
@Deprecated
|
||||
public void updateClanAsync(final Clan clan) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@@ -725,8 +753,16 @@ public final class StorageManager {
|
||||
if (updateLastUsed) {
|
||||
clan.updateLastUsed();
|
||||
}
|
||||
String query = "UPDATE `sc_clans` SET 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()) + "';";
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -755,6 +791,7 @@ public final class StorageManager {
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
@Deprecated
|
||||
public void updateClanPlayerAsync(final ClanPlayer cp) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@@ -771,8 +808,16 @@ public final class StorageManager {
|
||||
*/
|
||||
public void updateClanPlayer(ClanPlayer cp) {
|
||||
cp.updateLastSeen();
|
||||
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() + "';";
|
||||
core.update(query);
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -847,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,14 +926,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,6 +1028,14 @@ public final class StorageManager {
|
||||
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
|
||||
@@ -1021,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();
|
||||
|
||||
@@ -1046,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,28 @@ 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() {
|
||||
long delay = Helper.getDelayTo(1, 0);
|
||||
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);
|
||||
}
|
||||
@@ -32,8 +42,6 @@ public class CollectFeeTask extends BukkitRunnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
final SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
for (Clan clan : plugin.getClanManager().getClans()) {
|
||||
final double memberFee = clan.getMemberFee();
|
||||
|
||||
@@ -49,7 +57,7 @@ public class CollectFeeTask extends BukkitRunnable {
|
||||
ChatBlock.sendMessage(cp.toPlayer(), ChatColor.AQUA +
|
||||
MessageFormat.format(plugin.getLang("fee.collected"), memberFee));
|
||||
clan.setBalance(clan.getBalance() + memberFee);
|
||||
plugin.getStorageManager().updateClanAsync(clan);
|
||||
plugin.getStorageManager().updateClan(clan);
|
||||
} else {
|
||||
clan.removePlayerFromClan(cp.getUniqueId());
|
||||
clan.addBb(ChatColor.AQUA +
|
||||
|
||||
@@ -12,12 +12,21 @@ 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() {
|
||||
long delay = Helper.getDelayTo(1, 30);
|
||||
int hour = settingsManager.getTasksCollectUpkeepHour();
|
||||
int minute = settingsManager.getTasksCollectUpkeepMinute();
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimerAsynchronously(SimpleClans.getInstance(), delay * 20, 86400 * 20);
|
||||
}
|
||||
@@ -27,9 +36,10 @@ public class CollectUpkeepTask extends BukkitRunnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
final SimpleClans plugin = SimpleClans.getInstance();
|
||||
final SettingsManager settingsManager = plugin.getSettingsManager();
|
||||
plugin.getClanManager().getClans().forEach((clan) -> {
|
||||
if (plugin == null) {
|
||||
throw new IllegalStateException("Use the start() method!");
|
||||
}
|
||||
plugin.getClanManager().getClans().forEach((clan) -> {
|
||||
if (settingsManager.isChargeUpkeepOnlyIfMemberFeeEnabled() && !clan.isMemberFeeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,24 @@ 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() {
|
||||
long delay = Helper.getDelayTo(12, 0);
|
||||
|
||||
this.runTaskTimerAsynchronously(SimpleClans.getInstance(), delay * 20, 86400 * 20);
|
||||
int hour = sm.getTasksCollectUpkeepWarningHour();
|
||||
int minute = sm.getTasksCollectUpkeepWarningMinute();
|
||||
long delay = Helper.getDelayTo(hour, minute);
|
||||
|
||||
this.runTaskTimerAsynchronously(plugin, delay * 20, 86400 * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +36,9 @@ public class UpkeepWarningTask extends BukkitRunnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
final SimpleClans plugin = SimpleClans.getInstance();
|
||||
final SettingsManager sm = plugin.getSettingsManager();
|
||||
if (plugin == null) {
|
||||
throw new IllegalStateException("Use the start() method!");
|
||||
}
|
||||
plugin.getClanManager().getClans().forEach((clan) -> {
|
||||
if (sm.isChargeUpkeepOnlyIfMemberFeeEnabled() && !clan.isMemberFeeEnabled()) {
|
||||
return;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
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 static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class MainFrame extends SCFrame {
|
||||
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
public MainFrame(Player viewer) {
|
||||
super(null, viewer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
add(Components.getPlayerComponent(this, getViewer(), getViewer(), 0, false));
|
||||
add(Components.getClanComponent(this, getViewer(),
|
||||
plugin.getClanManager().getCreateClanPlayer(getViewer().getUniqueId()).getClan(), 1, true));
|
||||
|
||||
SCComponent leaderboard = new SCComponentImpl(lang("gui.main.leaderboard.title"),
|
||||
Collections.singletonList(lang("gui.main.leaderboard.lore")), Material.PAINTING, 3);
|
||||
leaderboard.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new LeaderboardFrame(getViewer(), this)));
|
||||
leaderboard.setPermission(ClickType.LEFT, "simpleclans.anyone.leaderboard");
|
||||
add(leaderboard);
|
||||
|
||||
SCComponent clanList = new SCComponentImpl(lang("gui.main.clan.list.title"),
|
||||
Collections.singletonList(lang("gui.main.clan.list.lore")), Material.PURPLE_BANNER, 4);
|
||||
clanList.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new ClanListFrame(this, getViewer())));
|
||||
clanList.setPermission(ClickType.LEFT, "simpleclans.anyone.list");
|
||||
add(clanList);
|
||||
|
||||
SCComponent resetKdr = new SCComponentImpl(lang("gui.main.reset.kdr.title"),
|
||||
Collections.singletonList(lang("gui.main.reset.kdr.lore")), Material.ANVIL, 6);
|
||||
resetKdr.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "resetkdr", false));
|
||||
resetKdr.setPermission(ClickType.LEFT, "simpleclans.member.resetkdr");
|
||||
add(resetKdr);
|
||||
|
||||
SCComponent otherCommands = new SCComponentImpl(lang("gui.main.other.commands.title"),
|
||||
Collections.singletonList(lang("gui.main.other.commands.lore")), Material.BOOK, 8);
|
||||
otherCommands.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "help", false));
|
||||
add(otherCommands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.main.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Rank;
|
||||
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 static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class PermissionsFrame extends SCFrame {
|
||||
private final Rank rank;
|
||||
private Paginator paginator;
|
||||
|
||||
public PermissionsFrame(SCFrame parent, Player viewer, Rank rank) {
|
||||
super(parent, viewer);
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
String[] permissions = rank.getPermissions().toArray(new String[0]);
|
||||
paginator = new Paginator(getSize() - 9, permissions.length);
|
||||
|
||||
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.permissions.add.title"), null, Material.WHITE_WOOL,
|
||||
4);
|
||||
add.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new AddPermissionFrame(this, getViewer(), rank)));
|
||||
add.setPermission(ClickType.LEFT, "simpleclans.leader.rank.permissions.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++) {
|
||||
|
||||
String permission = permissions[i];
|
||||
|
||||
SCComponent c = new SCComponentImpl(lang("gui.permissions.permission.title", permission),
|
||||
Collections.singletonList(lang("gui.permissions.permission.lore")), Material.PAPER, slot);
|
||||
c.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("rank permissions %s remove %s", rank.getName(), permission), true));
|
||||
c.setPermission(ClickType.RIGHT, "simpleclans.leader.rank.permissions.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.permissions.title", rank.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 4 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class PlayerDetailsFrame extends SCFrame {
|
||||
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private final OfflinePlayer subject;
|
||||
private final Clan clan;
|
||||
|
||||
public PlayerDetailsFrame(Player viewer, SCFrame parent, OfflinePlayer subject) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
clan = plugin.getClanManager().getAnyClanPlayer(viewer.getUniqueId()).getClan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
String subjectName = subject.getName();
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 4)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
|
||||
add(Components.getBackComponent(getParent(), 4));
|
||||
add(Components.getPlayerComponent(this, getViewer(), subject, 13, false));
|
||||
|
||||
if (!isSameClan()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SCComponent kick = new SCComponentImpl(lang("gui.playerdetails.kick.title"), null, Material.RED_WOOL,
|
||||
28);
|
||||
kick.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "kick " + subjectName, true));
|
||||
kick.setPermission(ClickType.LEFT, RankPermission.KICK);
|
||||
add(kick);
|
||||
|
||||
SCComponent promoteDemote = new SCComponentImpl(lang("gui.playerdetails.promote.demote.title"),
|
||||
Arrays.asList(lang("gui.playerdetails.promote.lore.left.click"),
|
||||
lang("gui.playerdetails.demote.lore.right.click")),
|
||||
Material.GUNPOWDER, 30);
|
||||
promoteDemote.setListener(ClickType.LEFT,
|
||||
() -> InventoryController.runSubcommand(getViewer(), "promote " + subjectName, !plugin.getSettingsManager().isConfirmationForPromote()));
|
||||
promoteDemote.setPermission(ClickType.LEFT, "simpleclans.leader.promote");
|
||||
promoteDemote.setListener(ClickType.RIGHT,
|
||||
() -> InventoryController.runSubcommand(getViewer(), "demote " + subjectName, !plugin.getSettingsManager().isConfirmationForDemote()));
|
||||
add(promoteDemote);
|
||||
promoteDemote.setPermission(ClickType.RIGHT, "simpleclans.leader.demote");
|
||||
|
||||
SCComponentImpl assignUnassign = new SCComponentImpl(lang("gui.playerdetails.assign.unassign.title"),
|
||||
Arrays.asList(lang("gui.playerdetails.assign.lore.left.click"),
|
||||
lang("gui.playerdetails.unassign.lore.right.click")),
|
||||
Material.FEATHER, 32);
|
||||
assignUnassign.setListener(ClickType.RIGHT,
|
||||
() -> InventoryController.runSubcommand(getViewer(), "rank unassign " + subjectName, true));
|
||||
assignUnassign.setPermission(ClickType.RIGHT, "simpleclans.leader.rank.unassign");
|
||||
assignUnassign.setListener(ClickType.LEFT,
|
||||
() -> InventoryDrawer.open(new RanksFrame(this, getViewer(), clan, subject)));
|
||||
add(assignUnassign);
|
||||
assignUnassign.setPermission(ClickType.LEFT, "simpleclans.leader.rank.assign");
|
||||
|
||||
SCComponent trustUntrust = new SCComponentImpl(lang("gui.playerdetails.trust.untrust.title"),
|
||||
Arrays.asList(lang("gui.playerdetails.trust.lore.left.click"),
|
||||
lang("gui.playerdetails.untrust.lore.right.click")),
|
||||
Material.CYAN_DYE, 34);
|
||||
trustUntrust.setListener(ClickType.LEFT,
|
||||
() -> InventoryController.runSubcommand(getViewer(), "trust " + subjectName, true));
|
||||
trustUntrust.setPermission(ClickType.LEFT, "simpleclans.leader.settrust");
|
||||
trustUntrust.setListener(ClickType.RIGHT,
|
||||
() -> InventoryController.runSubcommand(getViewer(), "untrust " + subjectName, true));
|
||||
trustUntrust.setPermission(ClickType.RIGHT, "simpleclans.leader.settrust");
|
||||
add(trustUntrust);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.playerdetails.title", subject.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
int size = 3;
|
||||
if (isSameClan()) {
|
||||
size = 5;
|
||||
}
|
||||
return size * 9;
|
||||
}
|
||||
|
||||
private boolean isSameClan() {
|
||||
return clan != null && clan.isMember(subject.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
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.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class RanksFrame extends SCFrame {
|
||||
private Paginator paginator;
|
||||
private final Clan subject;
|
||||
private final OfflinePlayer toEdit;
|
||||
|
||||
public RanksFrame(SCFrame parent, Player viewer, Clan subject, @Nullable OfflinePlayer toEdit) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
this.toEdit = toEdit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
List<Rank> ranks = subject != null ? subject.getRanks() : new ArrayList<>();
|
||||
paginator = new Paginator(getSize() - 9, ranks.size());
|
||||
|
||||
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 create = new SCComponentImpl(lang("gui.ranks.create.title"),
|
||||
Collections.singletonList(lang("gui.ranks.create.lore")), Material.WHITE_WOOL, 4);
|
||||
create.setVerifiedOnly(ClickType.LEFT);
|
||||
create.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "rank create", false));
|
||||
create.setPermission(ClickType.LEFT, "simpleclans.leader.rank.create");
|
||||
add(create);
|
||||
|
||||
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++) {
|
||||
Rank rank = ranks.get(i);
|
||||
List<String> lore;
|
||||
if (toEdit == null) {
|
||||
lore = Arrays.asList(
|
||||
lang("gui.ranks.rank.displayname.lore",
|
||||
Helper.parseColors(rank.getDisplayName())),
|
||||
lang("gui.ranks.rank.edit.permissions.lore"),
|
||||
lang("gui.ranks.rank.remove.lore"));
|
||||
} else {
|
||||
lore = Arrays.asList(
|
||||
lang("gui.ranks.rank.displayname.lore",
|
||||
Helper.parseColors(rank.getDisplayName())),
|
||||
lang("gui.ranks.rank.assign.lore", toEdit.getName()));
|
||||
}
|
||||
SCComponent c = new SCComponentImpl(lang("gui.ranks.rank.title", rank.getName()), lore,
|
||||
Material.FILLED_MAP, slot);
|
||||
if (toEdit != null) {
|
||||
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("rank assign %s %s", toEdit.getName(), rank.getName()), true));
|
||||
c.setPermission(ClickType.LEFT, "simpleclans.leader.rank.assign");
|
||||
} else {
|
||||
c.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new PermissionsFrame(this, getViewer(), rank)));
|
||||
c.setPermission(ClickType.LEFT, "simpleclans.leader.rank.permissions.list");
|
||||
c.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("rank delete %s", rank.getName()), true));
|
||||
c.setPermission(ClickType.RIGHT, "simpleclans.leader.rank.delete");
|
||||
}
|
||||
c.setVerifiedOnly(ClickType.LEFT);
|
||||
c.setVerifiedOnly(ClickType.RIGHT);
|
||||
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() {
|
||||
if (toEdit != null) {
|
||||
String rank = SimpleClans.getInstance().getClanManager().getAnyClanPlayer(toEdit.getUniqueId()).getRankId();
|
||||
return lang("gui.ranks.title.set.rank", rank);
|
||||
}
|
||||
return lang("gui.ranks.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 3 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
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 RivalsFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private Paginator paginator;
|
||||
private final Clan subject;
|
||||
|
||||
public RivalsFrame(Player viewer, SCFrame parent, Clan subject) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
List<String> rivals = subject.getRivals();
|
||||
paginator = new Paginator(getSize() - 9, rivals.size());
|
||||
|
||||
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.rivals.add.title"), null, Material.RED_WOOL, 4);
|
||||
add.setVerifiedOnly(ClickType.LEFT);
|
||||
add.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new AddRivalFrame(this, getViewer(), subject)));
|
||||
add.setPermission(ClickType.LEFT, RankPermission.RIVAL_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(rivals.get(i));
|
||||
if (clan == null)
|
||||
continue;
|
||||
SCComponent c = new SCComponentImpl(
|
||||
lang("gui.clanlist.clan.title", clan.getColorTag(), clan.getName()),
|
||||
Collections.singletonList(lang("gui.rivals.clan.lore")), Material.RED_BANNER, slot );
|
||||
c.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
String.format("rival %s %s", lang("remove"), clan.getTag()), false));
|
||||
c.setPermission(ClickType.RIGHT, RankPermission.RIVAL_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.rivals.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class RosterFrame extends SCFrame {
|
||||
|
||||
private final Clan subject;
|
||||
private Paginator paginator;
|
||||
|
||||
public RosterFrame(Player viewer, SCFrame parent, Clan subject) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
List<ClanPlayer> allMembers = subject.getLeaders();
|
||||
allMembers.addAll(subject.getNonLeaders());
|
||||
paginator = new Paginator(getSize() - 9, allMembers.size());
|
||||
|
||||
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 invite = new SCComponentImpl(lang("gui.roster.invite.title"),
|
||||
Collections.singletonList(lang("gui.roster.invite.lore")), Material.LIME_WOOL, 4);
|
||||
invite.setListener(ClickType.LEFT, () -> InventoryDrawer.open(new InviteFrame(this, getViewer())));
|
||||
invite.setPermission(ClickType.LEFT, RankPermission.INVITE);
|
||||
add(invite);
|
||||
|
||||
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++) {
|
||||
add(Components.getPlayerComponent(this, getViewer(), allMembers.get(i), slot, true));
|
||||
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.roster.title", Helper.stripColors(subject.getColorTag()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 6 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
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 net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class WarningFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private final Object permission;
|
||||
|
||||
public WarningFrame(SCFrame parent, Player viewer, Object permission) {
|
||||
super(parent, viewer);
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 4)
|
||||
continue;
|
||||
add(Components.getPanelComponent(slot));
|
||||
}
|
||||
add(Components.getBackComponent(getParent(), 4));
|
||||
|
||||
int slot = 22;
|
||||
if (permission != null) {
|
||||
addNoPermissionComponent(permission, slot);
|
||||
} else {
|
||||
addNotVerifiedComponent(slot);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNotVerifiedComponent(int slot) {
|
||||
SCComponent verified = new SCComponentImpl(lang("gui.warning.not.verified.title"),
|
||||
Collections.singletonList(lang("gui.warning.not.verified.lore")), Material.LEVER, slot);
|
||||
add(verified);
|
||||
}
|
||||
|
||||
private void addNoPermissionComponent(Object permission, int slot) {
|
||||
List<String> lore;
|
||||
if (permission instanceof String) {
|
||||
lore = Collections.singletonList(lang("gui.warning.no.permission.plugin.lore"));
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(getViewer().getUniqueId());
|
||||
if (((String) permission).contains("simpleclans.leader") && !cp.isLeader()) {
|
||||
lore = Collections.singletonList(lang("gui.warning.no.permission.leader.lore"));
|
||||
}
|
||||
} else {
|
||||
RankPermission p = (RankPermission) permission;
|
||||
String level = p.getPermissionLevel() == PermissionLevel.LEADER ? lang("leader")
|
||||
: lang("trusted");
|
||||
lore = Collections.singletonList(lang("gui.warning.no.permission.rank.lore", level, p.toString()));
|
||||
}
|
||||
SCComponent perm = new SCComponentImpl(lang("gui.warning.no.permission.title"), lore,
|
||||
Material.BARRIER, slot);
|
||||
add(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.warning.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 4 * 9;
|
||||
}
|
||||
|
||||
}
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
@@ -7,10 +8,12 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ChatFormatMigration {
|
||||
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
|
||||
public void migrateClanChat() {
|
||||
SettingsManager sm = plugin.getSettingsManager();
|
||||
FileConfiguration c = sm.getConfig();
|
||||
@@ -0,0 +1,125 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*
|
||||
*/
|
||||
public class Paginator {
|
||||
|
||||
private int currentPage;
|
||||
private final int sizePerPage;
|
||||
private final int totalElements;
|
||||
|
||||
public Paginator(int sizePerPage, int totalElements) {
|
||||
if (sizePerPage < 1) {
|
||||
throw new IllegalArgumentException("sizePerPage cannot be less than 1");
|
||||
}
|
||||
if (totalElements < 0) {
|
||||
throw new IllegalArgumentException("totalElements cannot be less than 0");
|
||||
}
|
||||
this.sizePerPage = sizePerPage;
|
||||
this.totalElements = totalElements;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the total elements
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public int getTotalElements() {
|
||||
return totalElements;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the size per page
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public int getSizePerPage() {
|
||||
return sizePerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the minimal index based on the current page
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public int getMinIndex() {
|
||||
return getCurrentPage() * getSizePerPage();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the max index based on the current page
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public int getMaxIndex() {
|
||||
return (getCurrentPage() + 1) * getSizePerPage();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the current page, starting at 0
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the page number if there are elements to display
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public boolean nextPage() {
|
||||
if (!hasNextPage()) {
|
||||
return false;
|
||||
}
|
||||
currentPage++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if there is a next page
|
||||
*/
|
||||
public boolean hasNextPage() {
|
||||
return !((sizePerPage * (currentPage + 1)) > totalElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decreases the page number if current > 0
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public boolean previousPage() {
|
||||
if (hasPreviousPage()) {
|
||||
currentPage--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if there is a previous page
|
||||
*/
|
||||
public boolean hasPreviousPage() {
|
||||
return currentPage > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index the index
|
||||
* @return if this index will not cause any IndexOutOfBoundsException
|
||||
*
|
||||
* @author RoinujNosde
|
||||
*/
|
||||
public boolean isValidIndex(int index) {
|
||||
return index >= getMinIndex() && index < getMaxIndex() && index < getTotalElements();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RoinujNosde
|
||||
* @since 2.10.2
|
||||
*/
|
||||
public class UpdateChecker {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private static final String LATEST_VERSION_URL = "https://api.spiget.org/v2/resources/71242/versions/latest";
|
||||
private final String version;
|
||||
private final String userAgent;
|
||||
|
||||
public UpdateChecker(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
version = plugin.getDescription().getVersion();
|
||||
userAgent = "SimpleClans/" + version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the version installed is up-to-date
|
||||
*
|
||||
*/
|
||||
public void check() {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL(LATEST_VERSION_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("User-Agent", userAgent);
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream());
|
||||
|
||||
JsonElement parse = new JsonParser().parse(reader);
|
||||
if (parse.isJsonObject()) {
|
||||
String latestVersion = parse.getAsJsonObject().get("name").getAsString();
|
||||
|
||||
if (!version.equals(latestVersion)) {
|
||||
plugin.getLogger().info(String.format("You're running an outdated version (%s).", version));
|
||||
plugin.getLogger().info(String.format("The latest version is %s. Download it at:", latestVersion));
|
||||
plugin.getLogger().info("https://www.spigotmc.org/resources/simpleclans.71242/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
reader.close();
|
||||
} catch (MalformedURLException ignored) {
|
||||
} catch (IOException | JsonParseException ex) {
|
||||
plugin.getLogger().log(Level.WARNING, "Error checking the plugin version...");
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 119 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user