Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f74885e8f | ||
|
|
c4a253efb7 | ||
|
|
f34b947e59 |
No files matched your search
|
Before Width: | Height: | Size: 418 KiB |
|
Before Width: | Height: | Size: 243 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.9 MiB |
@@ -1,5 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
@@ -11,12 +20,12 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
|
||||
@@ -4,18 +4,8 @@
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.14.3</version>
|
||||
<version>2.14.7</version>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://104.236.246.108:8080</url>
|
||||
</ciManagement>
|
||||
<scm>
|
||||
<connection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</connection>
|
||||
<developerConnection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</developerConnection>
|
||||
<tag>SimpleClans</tag>
|
||||
<url>http://github.com/marcelo-mason/SimpleClans.git/tree/master/</url>
|
||||
</scm>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -130,7 +120,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.14.4.1</version>
|
||||
<version>2.14.7</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -200,20 +200,6 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<!-- GitHub/Jenkins -->
|
||||
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://104.236.246.108:8080</url>
|
||||
</ciManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</connection>
|
||||
<developerConnection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</developerConnection>
|
||||
<url>http://github.com/marcelo-mason/SimpleClans.git/tree/master/</url>
|
||||
<tag>SimpleClans</tag>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,13 +26,7 @@ public class ChatBlock {
|
||||
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;
|
||||
}
|
||||
@@ -498,14 +493,11 @@ public class ChatBlock {
|
||||
/**
|
||||
* Cuts the message apart into whole words short enough to fit on one line
|
||||
*
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
private static String[] wordWrap(String msg) {
|
||||
// Split each word apart
|
||||
|
||||
ArrayList<String> split = new ArrayList<>();
|
||||
split.addAll(Arrays.asList(msg.split(" ")));
|
||||
ArrayList<String> split = new ArrayList<>(Arrays.asList(msg.split(" ")));
|
||||
|
||||
// Create an array list for the output
|
||||
|
||||
@@ -545,18 +537,16 @@ public class ChatBlock {
|
||||
|
||||
// Merge the words into a sentence (that now fits into a single chat line) and add them to the output array.
|
||||
|
||||
String merged = combineSplit(words.toArray(new String[words.size()]));
|
||||
String merged = combineSplit(words.toArray(new String[0]));
|
||||
out.add(merged);
|
||||
}
|
||||
|
||||
// Convert to an array and return
|
||||
|
||||
return out.toArray(new String[out.size()]);
|
||||
return out.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
private static String combineSplit(String[] string) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -572,9 +562,6 @@ public class ChatBlock {
|
||||
/**
|
||||
* Cuts apart a word that is too long to fit on one line
|
||||
*
|
||||
* @param lengthBefore
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private static String[] wordCut(int lengthBefore, String str) {
|
||||
int length = lengthBefore;
|
||||
@@ -609,8 +596,6 @@ public class ChatBlock {
|
||||
/**
|
||||
* Outputs a single line out, crops overflow
|
||||
*
|
||||
* @param receiver
|
||||
* @param msg
|
||||
*/
|
||||
public static void saySingle(CommandSender receiver, String msg) {
|
||||
if (receiver == null) {
|
||||
@@ -623,38 +608,31 @@ public class ChatBlock {
|
||||
/**
|
||||
* Outputs a message to a user
|
||||
*
|
||||
* @param receiver
|
||||
* @param msg
|
||||
*/
|
||||
public static void sendMessage(@Nullable CommandSender receiver, @NotNull String msg) {
|
||||
if (receiver == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] message = colorize(wordWrap(msg));
|
||||
|
||||
for (String out : message) {
|
||||
receiver.sendMessage(out);
|
||||
}
|
||||
receiver.sendMessage(ChatUtils.parseColors(msg));
|
||||
// String[] message = colorize(wordWrap(msg));
|
||||
//
|
||||
// for (String out : message) {
|
||||
// receiver.sendMessage(out);
|
||||
// }
|
||||
}
|
||||
|
||||
public static void sendMessageKey(@Nullable CommandSender receiver, @NotNull String key, @NotNull Object... args) {
|
||||
sendMessage(receiver, lang(key, receiver, args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send blank lie
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void startColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send blank lie
|
||||
* Send blank line
|
||||
*
|
||||
* @param receiver
|
||||
*/
|
||||
public static void sendBlank(CommandSender receiver) {
|
||||
if (receiver == null) {
|
||||
@@ -667,8 +645,6 @@ public class ChatBlock {
|
||||
/**
|
||||
* Colors each line
|
||||
*
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static String[] say(String message) {
|
||||
return colorize(wordWrap(message));
|
||||
@@ -678,10 +654,6 @@ public class ChatBlock {
|
||||
return colorize(wordWrap(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
private static String[] colorize(String[] message) {
|
||||
try {
|
||||
return colorizeBase(message);
|
||||
@@ -690,21 +662,12 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static String colorize(String message) {
|
||||
return colorizeBase(new String[]{
|
||||
message
|
||||
})[0];
|
||||
public static @Nullable String colorize(String message) {
|
||||
return colorizeBase(new String[]{ message })[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
private static String[] colorizeBase(String[] message) {
|
||||
|
||||
private static @Nullable String[] colorizeBase(String[] message) {
|
||||
if (message != null && message[0] != null && !message[0].isEmpty()) {
|
||||
// Go through each line
|
||||
|
||||
@@ -720,9 +683,8 @@ public class ChatBlock {
|
||||
// advance x to the next character
|
||||
x += 1;
|
||||
|
||||
try {
|
||||
lastColor = ChatColor.getByChar(msg.charAt(x)) + "";
|
||||
} catch (Exception ignored) {
|
||||
if (x < msg.length()) {
|
||||
lastColor = ChatColor.COLOR_CHAR + "" + msg.charAt(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -734,6 +696,7 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.*;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.Placeholder;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -24,8 +19,12 @@ import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
@@ -48,14 +47,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private List<String> bb = new ArrayList<>();
|
||||
private final List<String> members = new ArrayList<>();
|
||||
private final HashMap<String, Clan> warringClans = new HashMap<>();
|
||||
private int homeX = 0;
|
||||
private int homeY = 0;
|
||||
private int homeZ = 0;
|
||||
private String homeWorld = "";
|
||||
private double homeX = 0;
|
||||
private double homeY = 0;
|
||||
private double homeZ = 0;
|
||||
private float homeYaw = 0;
|
||||
private float homePitch = 0;
|
||||
private @Nullable String homeWorld = "";
|
||||
private boolean allowWithdraw = false;
|
||||
private boolean allowDeposit = true;
|
||||
private boolean feeEnabled;
|
||||
private List<Rank> ranks = new ArrayList<>();
|
||||
private @Nullable String defaultRank = null;
|
||||
private @Nullable ItemStack banner;
|
||||
|
||||
/**
|
||||
@@ -66,14 +68,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
this.tag = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tag
|
||||
* @param name
|
||||
* @param verified
|
||||
*/
|
||||
public Clan(String tag, String name, boolean verified) {
|
||||
this.tag = Helper.cleanTag(tag);
|
||||
this.colorTag = Helper.parseColors(tag);
|
||||
this.colorTag = ChatUtils.parseColors(tag);
|
||||
this.name = name;
|
||||
this.founded = (new Date()).getTime();
|
||||
this.lastUsed = (new Date()).getTime();
|
||||
@@ -113,8 +110,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* deposits money to the clan
|
||||
*
|
||||
* @param amount
|
||||
* @param player
|
||||
*/
|
||||
public void deposit(double amount, Player player) {
|
||||
BankDepositEvent event = new BankDepositEvent(player, this, amount);
|
||||
@@ -140,8 +135,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* withdraws money to the clan
|
||||
*
|
||||
* @param amount
|
||||
* @param player
|
||||
*/
|
||||
public void withdraw(double amount, Player player) {
|
||||
BankWithdrawEvent event = new BankWithdrawEvent(player, this, amount);
|
||||
@@ -167,6 +160,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
@Placeholder("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -192,7 +186,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param description
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
@@ -201,7 +194,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Sets the clan's fee
|
||||
*
|
||||
* @param fee
|
||||
*/
|
||||
public void setMemberFee(double fee) {
|
||||
if (fee < 0) {
|
||||
@@ -224,6 +216,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the balance
|
||||
*/
|
||||
@Placeholder("balance")
|
||||
public double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
@@ -242,6 +235,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
@Placeholder("tag")
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
@@ -274,8 +268,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Returns the number of days the clan has been inactive
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("inactivedays")
|
||||
public int getInactiveDays() {
|
||||
Timestamp now = new Timestamp((new Date()).getTime());
|
||||
return (int) Math.floor(Dates.differenceInDays(new Timestamp(getLastUsed()), now));
|
||||
@@ -295,6 +289,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the friendlyFire
|
||||
*/
|
||||
@Placeholder("friendly_fire")
|
||||
public boolean isFriendlyFire() {
|
||||
return friendlyFire;
|
||||
}
|
||||
@@ -347,6 +342,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the allies
|
||||
*/
|
||||
@Placeholder(value = "allies_count", resolver = "list_size")
|
||||
public List<String> getAllies() {
|
||||
return Collections.unmodifiableList(allies);
|
||||
}
|
||||
@@ -376,8 +372,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* The string representation of the founded date
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("founded")
|
||||
public String getFoundedString() {
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.founded));
|
||||
}
|
||||
@@ -396,6 +392,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the colorTag
|
||||
*/
|
||||
@Placeholder("color_tag")
|
||||
public String getColorTag() {
|
||||
return colorTag;
|
||||
}
|
||||
@@ -406,13 +403,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param colorTag the colorTag to set
|
||||
*/
|
||||
public void setColorTag(String colorTag) {
|
||||
this.colorTag = Helper.parseColors(colorTag);
|
||||
this.colorTag = ChatUtils.parseColors(colorTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a bulletin board message without announcer
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void addBb(String msg) {
|
||||
addBbWithoutSaving(msg);
|
||||
@@ -423,7 +419,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Adds a bulletin board message without saving it to the database
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void addBbWithoutSaving(String msg) {
|
||||
while (bb.size() > SimpleClans.getInstance().getSettingsManager().getBbSize()) {
|
||||
@@ -436,7 +431,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Adds a bulletin board message without announcer and saves it to the database
|
||||
*
|
||||
* @param msg
|
||||
*
|
||||
* @param updateLastUsed should the clan's last used time be updated as well?
|
||||
*/
|
||||
@@ -456,7 +450,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void importMember(ClanPlayer cp) {
|
||||
String uuid;
|
||||
@@ -474,7 +467,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* (used internally)
|
||||
*
|
||||
* @param playerUniqueId
|
||||
*/
|
||||
public void removeMember(UUID playerUniqueId) {
|
||||
this.members.remove(playerUniqueId.toString());
|
||||
@@ -483,8 +475,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Get total clan size
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("size")
|
||||
public int getSize() {
|
||||
return this.members.size();
|
||||
}
|
||||
@@ -494,6 +486,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the rivals
|
||||
*/
|
||||
@Placeholder(value = "rivals_count", resolver = "list_size")
|
||||
public List<String> getRivals() {
|
||||
return Collections.unmodifiableList(rivals);
|
||||
}
|
||||
@@ -514,8 +507,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check if the tag is a rival
|
||||
*
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
public boolean isRival(String tag) {
|
||||
return rivals.contains(tag);
|
||||
@@ -524,8 +515,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check if the tag is an ally
|
||||
*
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
public boolean isAlly(String tag) {
|
||||
return allies.contains(tag);
|
||||
@@ -535,8 +524,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Tells you if the clan is verified, always returns true if no verification
|
||||
* is required
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("is_verified")
|
||||
public boolean isVerified() {
|
||||
return !SimpleClans.getInstance().getSettingsManager().isRequireVerification() || verified;
|
||||
|
||||
@@ -556,6 +545,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the capeUrl
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCapeUrl() {
|
||||
return capeUrl;
|
||||
}
|
||||
@@ -565,6 +555,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @param capeUrl the capeUrl to set
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCapeUrl(String capeUrl) {
|
||||
this.capeUrl = capeUrl;
|
||||
}
|
||||
@@ -627,70 +618,65 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Returns a separator delimited string with all the ally clan's colored
|
||||
* tags
|
||||
*
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public String getAllyString(String sep) {
|
||||
String out = "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String allyTag : getAllies()) {
|
||||
Clan ally = SimpleClans.getInstance().getClanManager().getClan(allyTag);
|
||||
|
||||
if (ally != null) {
|
||||
out += ally.getColorTag() + sep;
|
||||
out.append(ally.getColorTag()).append(sep);
|
||||
}
|
||||
}
|
||||
|
||||
out = Helper.stripTrailing(out, sep);
|
||||
out = new StringBuilder(Helper.stripTrailing(out.toString(), sep));
|
||||
|
||||
if (out.trim().isEmpty()) {
|
||||
if (out.toString().trim().isEmpty()) {
|
||||
return ChatColor.BLACK + "None";
|
||||
}
|
||||
|
||||
return Helper.parseColors(out);
|
||||
return ChatUtils.parseColors(out.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a separator delimited string with all the rival clan's colored
|
||||
* tags
|
||||
*
|
||||
* @param sep
|
||||
* @return
|
||||
*/
|
||||
public String getRivalString(String sep) {
|
||||
String out = "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String rivalTag : getRivals()) {
|
||||
Clan rival = SimpleClans.getInstance().getClanManager().getClan(rivalTag);
|
||||
|
||||
if (rival != null) {
|
||||
if (isWarring(rivalTag)) {
|
||||
out += ChatColor.DARK_RED + "[" + Helper.stripColors(rival.getColorTag()) + "]" + sep;
|
||||
out.append(ChatColor.DARK_RED).append("[").append(ChatUtils.stripColors(rival.getColorTag()))
|
||||
.append("]").append(sep);
|
||||
} else {
|
||||
out += rival.getColorTag() + sep;
|
||||
out.append(rival.getColorTag()).append(sep);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
out = Helper.stripTrailing(out, sep);
|
||||
out = new StringBuilder(Helper.stripTrailing(out.toString(), sep));
|
||||
|
||||
if (out.trim().isEmpty()) {
|
||||
if (out.toString().trim().isEmpty()) {
|
||||
return ChatColor.BLACK + "None";
|
||||
}
|
||||
|
||||
return Helper.parseColors(out);
|
||||
return ChatUtils.parseColors(out.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a separator delimited string with all the leaders
|
||||
*
|
||||
* @param prefix
|
||||
* @param sep
|
||||
* @return the formatted leaders string
|
||||
*/
|
||||
public String getLeadersString(String prefix, String sep) {
|
||||
String out = "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (String member : members) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(UUID.fromString(member));
|
||||
@@ -699,17 +685,16 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
|
||||
if (cp.isLeader()) {
|
||||
out += prefix + cp.getName() + sep;
|
||||
out.append(prefix).append(cp.getName()).append(sep);
|
||||
}
|
||||
}
|
||||
|
||||
return Helper.stripTrailing(out, sep);
|
||||
return Helper.stripTrailing(out.toString(), sep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is a leader of a clan
|
||||
*
|
||||
* @param player
|
||||
* @return the leaders
|
||||
*/
|
||||
public boolean isLeader(Player player) {
|
||||
@@ -720,16 +705,13 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check if a player is a leader of a clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return the leaders
|
||||
*/
|
||||
public boolean isLeader(UUID playerUniqueId) {
|
||||
if (isMember(playerUniqueId)) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerUniqueId);
|
||||
|
||||
if (cp != null && cp.isLeader()) {
|
||||
return true;
|
||||
}
|
||||
return cp != null && cp.isLeader();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -782,6 +764,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the members
|
||||
*/
|
||||
@Placeholder(value = "onlinemembers_count", resolver = "list_size", config = "filter_vanished")
|
||||
public List<ClanPlayer> getOnlineMembers() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
@@ -790,7 +773,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
if (cp == null) {
|
||||
continue;
|
||||
}
|
||||
if (cp.toPlayer() != null && cp.toPlayer().isOnline()) {
|
||||
if (cp.toPlayer() != null) {
|
||||
out.add(cp);
|
||||
}
|
||||
}
|
||||
@@ -803,6 +786,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
*
|
||||
* @return the leaders
|
||||
*/
|
||||
@Placeholder(value = "leader_size", resolver = "list_size")
|
||||
public List<ClanPlayer> getLeaders() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
|
||||
@@ -847,7 +831,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Get all clan's members
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<ClanPlayer> getAllMembers() {
|
||||
List<ClanPlayer> out = new ArrayList<>();
|
||||
@@ -869,7 +852,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Get all the ally clan's members
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<ClanPlayer> getAllAllyMembers() {
|
||||
Set<ClanPlayer> out = new HashSet<>();
|
||||
@@ -888,8 +870,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Gets the clan's total KDR
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("total_kdr")
|
||||
@Placeholder(value = "topclans_position", resolver = "ranking_position")
|
||||
public float getTotalKDR() {
|
||||
if (members.isEmpty()) {
|
||||
return 0;
|
||||
@@ -918,8 +901,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Gets the clan's total KDR
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("total_deaths")
|
||||
public int getTotalDeaths() {
|
||||
int totalDeaths = 0;
|
||||
|
||||
@@ -942,8 +925,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Gets average weighted kills for the clan
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("average_wk")
|
||||
public int getAverageWK() {
|
||||
int total = 0;
|
||||
|
||||
@@ -963,11 +946,16 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return total / getSize();
|
||||
}
|
||||
|
||||
@Placeholder("total_kills")
|
||||
public int getTotalKills() {
|
||||
return getTotalCivilian() + getTotalNeutral() + getTotalRival();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets total rival kills for the clan
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("total_rival")
|
||||
public int getTotalRival() {
|
||||
int total = 0;
|
||||
|
||||
@@ -990,8 +978,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Gets total neutral kills for the clan
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("total_neutral")
|
||||
public int getTotalNeutral() {
|
||||
int total = 0;
|
||||
|
||||
@@ -1014,8 +1002,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Gets total civilian kills for the clan
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("total_civilian")
|
||||
public int getTotalCivilian() {
|
||||
int total = 0;
|
||||
|
||||
@@ -1038,7 +1026,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check whether the clan has crossed the rival limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean reachedRivalLimit() {
|
||||
int rivalCount = rivals.size();
|
||||
@@ -1053,13 +1040,15 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Add a new player to the clan
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void addPlayerToClan(ClanPlayer cp) {
|
||||
cp.removePastClan(getColorTag());
|
||||
cp.setClan(this);
|
||||
cp.setLeader(false);
|
||||
cp.setTrusted(SimpleClans.getInstance().getSettingsManager().isClanTrustByDefault());
|
||||
if (defaultRank != null) {
|
||||
cp.setRank(defaultRank);
|
||||
}
|
||||
|
||||
importMember(cp);
|
||||
|
||||
@@ -1086,10 +1075,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Remove a player from a clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
*/
|
||||
public void removePlayerFromClan(UUID playerUniqueId) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerUniqueId);
|
||||
if (cp == null || !isMember(playerUniqueId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove clan group-permission
|
||||
SimpleClans.getInstance().getPermissionsManager().removeClanPermissions(cp);
|
||||
@@ -1124,10 +1115,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Promote a member to a leader of a clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
*/
|
||||
public void promote(UUID playerUniqueId) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerUniqueId);
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getCreateClanPlayer(playerUniqueId);
|
||||
|
||||
cp.setLeader(true);
|
||||
cp.setTrusted(true);
|
||||
@@ -1148,10 +1138,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Demote a leader back to a member of a clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
*/
|
||||
public void demote(UUID playerUniqueId) {
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getClanPlayer(playerUniqueId);
|
||||
ClanPlayer cp = SimpleClans.getInstance().getClanManager().getCreateClanPlayer(playerUniqueId);
|
||||
|
||||
cp.setLeader(false);
|
||||
|
||||
@@ -1166,7 +1155,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Add an ally to a clan, and the clan to the ally
|
||||
*
|
||||
* @param ally
|
||||
*/
|
||||
public void addAlly(Clan ally) {
|
||||
removeRival(ally.getTag());
|
||||
@@ -1183,7 +1171,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Remove an ally form the clan, and the clan from the ally
|
||||
*
|
||||
* @param ally
|
||||
*/
|
||||
public void removeAlly(Clan ally) {
|
||||
removeAlly(ally.getTag());
|
||||
@@ -1197,7 +1184,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Add a rival to the clan, and the clan to the rival
|
||||
*
|
||||
* @param rival
|
||||
*/
|
||||
public void addRival(Clan rival) {
|
||||
removeAlly(rival.getTag());
|
||||
@@ -1214,7 +1200,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Removes a rival from the clan, the clan from the rival
|
||||
*
|
||||
* @param rival
|
||||
*/
|
||||
public void removeRival(Clan rival) {
|
||||
removeRival(rival.getTag());
|
||||
@@ -1236,8 +1221,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check whether any clan member is online
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("is_anyonline")
|
||||
public boolean isAnyOnline() {
|
||||
for (String member : members) {
|
||||
if (Helper.isOnline(UUID.fromString(member))) {
|
||||
@@ -1279,7 +1264,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check whether all leaders of a clan are online
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean allLeadersOnline() {
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
@@ -1296,8 +1280,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check whether all leaders, except for the one passed in, are online
|
||||
*
|
||||
* @param playerName
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean allOtherLeadersOnline(String playerName) {
|
||||
@@ -1319,8 +1301,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Check whether all leaders, except for the one passed in, are online
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return
|
||||
*/
|
||||
public boolean allOtherLeadersOnline(UUID playerUniqueId) {
|
||||
List<ClanPlayer> leaders = getLeaders();
|
||||
@@ -1341,7 +1321,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Change a clan's tag
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
public void changeClanTag(String tag) {
|
||||
setColorTag(tag);
|
||||
@@ -1351,8 +1330,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Announce message to a whole clan
|
||||
*
|
||||
* @param playerName
|
||||
* @param msg
|
||||
*/
|
||||
public void clanAnnounce(String playerName, String msg) {
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getClanChatAnnouncementColor() + msg;
|
||||
@@ -1371,7 +1348,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Announce message to a all the leaders of a clan
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void leaderAnnounce(String msg) {
|
||||
String message = SimpleClans.getInstance().getSettingsManager().getClanChatAnnouncementColor() + msg;
|
||||
@@ -1391,34 +1367,28 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Add a new bb message and announce it to all online members of a clan
|
||||
*
|
||||
* @param announcerName
|
||||
* @param msg
|
||||
*/
|
||||
public void addBb(String announcerName, String msg) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getBbColor() + msg);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new bb message and announce it to all online members of a clan
|
||||
*
|
||||
* @param announcerName
|
||||
* @param msg
|
||||
* @param updateLastUsed
|
||||
*/
|
||||
public void addBb(String announcerName, String msg, boolean updateLastUsed) {
|
||||
if (isVerified()) {
|
||||
addBb(SimpleClans.getInstance().getSettingsManager().getBbColor() + msg, updateLastUsed);
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
clanAnnounce(announcerName, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays bb to a player
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void displayBb(Player player) {
|
||||
if (isVerified()) {
|
||||
@@ -1433,7 +1403,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
for (String msg : bb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
@@ -1444,7 +1414,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Displays bb to a player
|
||||
* @implNote may want to refactor displaybb(Player) to use this?
|
||||
*
|
||||
* @param player
|
||||
* @param maxSize amount of lines to display
|
||||
*/
|
||||
public void displayBb(Player player, int maxSize) {
|
||||
@@ -1459,7 +1428,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
for (String msg : localBb) {
|
||||
if (!sendBbTime(player, msg)) {
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + Helper.parseColors(msg));
|
||||
ChatBlock.sendMessage(player, SimpleClans.getInstance().getSettingsManager().getBbAccentColor() + "* " + SimpleClans.getInstance().getSettingsManager().getBbColor() + ChatUtils.parseColors(msg));
|
||||
}
|
||||
}
|
||||
ChatBlock.sendBlank(player);
|
||||
@@ -1471,6 +1440,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param msg the bb message
|
||||
* @return true if sent
|
||||
*/
|
||||
@SuppressWarnings({"BooleanMethodIsAlwaysInverted", "deprecation"})
|
||||
private boolean sendBbTime(Player player, String msg) {
|
||||
try {
|
||||
int index = msg.indexOf("_");
|
||||
@@ -1483,8 +1453,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
.getColorizedMessage(SimpleClans.getInstance()
|
||||
.getSettingsManager().getBbAccentColor() + "* " +
|
||||
SimpleClans.getInstance().getSettingsManager()
|
||||
.getBbColor() + Helper.parseColors(
|
||||
msg.substring(++index, msg.length()))));
|
||||
.getBbColor() + ChatUtils.parseColors(
|
||||
msg.substring(++index))));
|
||||
TextComponent textComponent = new TextComponent(msg);
|
||||
textComponent.setHoverEvent(
|
||||
new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
@@ -1538,21 +1508,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
final Clan thisOne = this;
|
||||
|
||||
SimpleClans.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(SimpleClans.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleClans.getInstance().getClanManager().removeClan(thisOne.getTag());
|
||||
SimpleClans.getInstance().getStorageManager().deleteClan(thisOne);
|
||||
}
|
||||
SimpleClans.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(SimpleClans.getInstance(), () -> {
|
||||
SimpleClans.getInstance().getClanManager().removeClan(thisOne.getTag());
|
||||
SimpleClans.getInstance().getStorageManager().deleteClan(thisOne);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this clan can be rivaled
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("is_unrivable")
|
||||
public boolean isUnrivable() {
|
||||
return SimpleClans.getInstance().getSettingsManager().isUnrivable(getTag());
|
||||
}
|
||||
@@ -1561,7 +1527,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Returns whether this clan is warring with another clan
|
||||
*
|
||||
* @param tag the tag of the clan we are at war with
|
||||
* @return
|
||||
*/
|
||||
public boolean isWarring(String tag) {
|
||||
return warringClans.containsKey(tag);
|
||||
@@ -1571,7 +1536,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Returns whether this clan is warring with another clan
|
||||
*
|
||||
* @param clan the clan we are testing against
|
||||
* @return
|
||||
*/
|
||||
public boolean isWarring(Clan clan) {
|
||||
return warringClans.containsKey(clan.getTag());
|
||||
@@ -1580,7 +1544,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Add a clan to be at war with
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
public void addWarringClan(Clan clan) {
|
||||
if (!warringClans.containsKey(clan.getTag())) {
|
||||
@@ -1592,8 +1555,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Remove a warring clan
|
||||
*
|
||||
* @param clan
|
||||
* @return
|
||||
*/
|
||||
public boolean removeWarringClan(Clan clan) {
|
||||
Clan warring = warringClans.remove(clan.getTag());
|
||||
@@ -1628,11 +1589,12 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
|
||||
JSONArray warring = new JSONArray();
|
||||
warring.addAll(warringClans.keySet());
|
||||
|
||||
json.put("warring", warring);
|
||||
json.put("homeX", homeX);
|
||||
json.put("homeY", homeY);
|
||||
json.put("homeZ", homeZ);
|
||||
json.put("homePitch", homePitch);
|
||||
json.put("homeYaw", homeYaw);
|
||||
json.put("homeWorld", homeWorld == null ? "" : homeWorld);
|
||||
|
||||
return json.toString();
|
||||
@@ -1654,7 +1616,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
try {
|
||||
if (flag.equals("warring")) {
|
||||
JSONArray clans = (JSONArray) flags.get(flag);
|
||||
|
||||
if (clans != null) {
|
||||
for (Object tag : clans) {
|
||||
SimpleClans.debug("warring added: " + tag.toString());
|
||||
@@ -1662,28 +1623,28 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag.equals("homeX")) {
|
||||
homeX = ((Long) flags.get(flag)).intValue();
|
||||
homeX = ((Number) flags.get(flag)).doubleValue();
|
||||
}
|
||||
|
||||
if (flag.equals("homeY")) {
|
||||
homeY = ((Long) flags.get(flag)).intValue();
|
||||
homeY = ((Number) flags.get(flag)).doubleValue();
|
||||
}
|
||||
|
||||
if (flag.equals("homeZ")) {
|
||||
homeZ = ((Long) flags.get(flag)).intValue();
|
||||
homeZ = ((Number) flags.get(flag)).doubleValue();
|
||||
}
|
||||
if (flag.equals("homeYaw")) {
|
||||
homeYaw = ((Number) flags.get(flag)).floatValue();
|
||||
}
|
||||
if (flag.equals("homePitch")) {
|
||||
homePitch = ((Number) flags.get(flag)).floatValue();
|
||||
}
|
||||
|
||||
if (flag.equals("homeWorld")) {
|
||||
homeWorld = (String) flags.get(flag);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
for (StackTraceElement el : ex.getStackTrace()) {
|
||||
System.out.print("Failed reading flag: " + flag);
|
||||
System.out.print("Value: " + flags.get(flag));
|
||||
System.out.print(el.toString());
|
||||
}
|
||||
Logger logger = SimpleClans.getInstance().getLogger();
|
||||
logger.log(Level.SEVERE, String.format("Failed reading flag: %s, value: %s", flag,
|
||||
flags.get(flag)), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1710,14 +1671,16 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
homeY = 0;
|
||||
homeX = 0;
|
||||
homeZ = 0;
|
||||
homePitch = 0;
|
||||
homeYaw = 0;
|
||||
homeWorld = null;
|
||||
} else {
|
||||
home.setY(home.getBlockY() + 1);
|
||||
|
||||
homeX = home.getBlockX();
|
||||
homeY = home.getBlockY();
|
||||
homeZ = home.getBlockZ();
|
||||
homeWorld = home.getWorld().getName();
|
||||
homeX = home.getX();
|
||||
homeY = home.getY();
|
||||
homeZ = home.getZ();
|
||||
homeYaw = home.getYaw();
|
||||
homePitch = home.getPitch();
|
||||
homeWorld = home.getWorld() == null ? null : home.getWorld().getName();
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1726,20 +1689,17 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
if (homeWorld == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
World world = SimpleClans.getInstance().getServer().getWorld(homeWorld);
|
||||
|
||||
World world = Bukkit.getWorld(homeWorld);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(world.getBlockAt(homeX, homeY, homeZ).getType().equals(XMaterial.AIR.parseMaterial())) ||
|
||||
!(world.getBlockAt(homeX, homeY + 1, homeZ).getType().equals(XMaterial.AIR.parseMaterial()))
|
||||
|| homeY == 0) {
|
||||
return new Location(world, homeX, world.getHighestBlockYAt(homeX, homeZ), homeZ);
|
||||
} else {
|
||||
return new Location(world, homeX, homeY, homeZ);
|
||||
Location location = new Location(world, homeX, homeY, homeZ, homeYaw, homePitch);
|
||||
if (location.getBlock().getType() != Material.AIR ||
|
||||
location.clone().add(0, 1, 0).getBlock().getType() != Material.AIR) {
|
||||
location.setY(world.getHighestBlockYAt(location) + 1);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getTagLabel(boolean isLeader) {
|
||||
@@ -1778,7 +1738,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Enables or disables the fee
|
||||
*
|
||||
* @param enable
|
||||
*/
|
||||
public void setMemberFeeEnabled(boolean enable) {
|
||||
feeEnabled = enable;
|
||||
@@ -1787,6 +1746,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* @return the allowWithdraw
|
||||
*/
|
||||
@Placeholder("allow_withdraw")
|
||||
public boolean isAllowWithdraw() {
|
||||
return allowWithdraw;
|
||||
}
|
||||
@@ -1801,6 +1761,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* @return the allowDeposit
|
||||
*/
|
||||
@Placeholder("allow_deposit")
|
||||
public boolean isAllowDeposit() {
|
||||
return allowDeposit;
|
||||
}
|
||||
@@ -1816,16 +1777,14 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* Checks if the clan has the specified rank
|
||||
*
|
||||
* @param name the rank
|
||||
* @return
|
||||
*/
|
||||
public boolean hasRank(String name) {
|
||||
public boolean hasRank(@Nullable String name) {
|
||||
return getRank(name) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a rank
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void createRank(String name) {
|
||||
ranks.add(new Rank(name));
|
||||
@@ -1843,7 +1802,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Sets the clan's ranks
|
||||
*
|
||||
* @param ranks
|
||||
*/
|
||||
public void setRanks(List<Rank> ranks) {
|
||||
if (ranks == null) {
|
||||
@@ -1855,7 +1813,6 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
/**
|
||||
* Deletes a rank with the specified name
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void deleteRank(String name) {
|
||||
Rank r = getRank(name);
|
||||
@@ -1876,7 +1833,7 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
* @param name the rank name
|
||||
* @return a rank or null
|
||||
*/
|
||||
public @Nullable Rank getRank(String name) {
|
||||
public @Nullable Rank getRank(@Nullable String name) {
|
||||
if (name != null) {
|
||||
for (Rank r : ranks) {
|
||||
if (r.getName().equals(name)) {
|
||||
@@ -1887,6 +1844,29 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default rank for this clan.
|
||||
*
|
||||
* @param name The name of the rank to be set as default
|
||||
*/
|
||||
public void setDefaultRank(@Nullable String name) {
|
||||
// I don't know how this could happen, but if it somehow does, here's a check for it
|
||||
if (!hasRank(name)) {
|
||||
defaultRank = null;
|
||||
} else {
|
||||
defaultRank = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default rank for this clan.
|
||||
*
|
||||
* @return The default rank or null if there is no default
|
||||
*/
|
||||
public @Nullable String getDefaultRank() {
|
||||
return defaultRank;
|
||||
}
|
||||
|
||||
public void setBanner(@Nullable ItemStack banner) {
|
||||
if (banner == null) {
|
||||
this.banner = null;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.Placeholder;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,7 +14,6 @@ import org.json.simple.JSONValue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
@@ -30,7 +31,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
private boolean leader;
|
||||
private boolean trusted;
|
||||
private String tag;
|
||||
private Clan clan;
|
||||
private @Nullable Clan clan;
|
||||
private boolean friendlyFire;
|
||||
private int neutralKills;
|
||||
private int rivalKills;
|
||||
@@ -67,7 +68,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
*/
|
||||
@Deprecated
|
||||
public ClanPlayer(String playerName)
|
||||
@@ -190,6 +190,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the leader
|
||||
*/
|
||||
@Placeholder("is_leader")
|
||||
public boolean isLeader()
|
||||
{
|
||||
return leader;
|
||||
@@ -200,11 +201,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @param leader the leader to set
|
||||
*/
|
||||
public void setLeader(boolean leader)
|
||||
{
|
||||
if (leader)
|
||||
{
|
||||
trusted = leader;
|
||||
public void setLeader(boolean leader) {
|
||||
if (leader) {
|
||||
trusted = true;
|
||||
}
|
||||
|
||||
this.leader = leader;
|
||||
@@ -213,15 +212,12 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Check whether the player is an ally with another player
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isAlly(Player player)
|
||||
{
|
||||
public boolean isAlly(Player player) {
|
||||
ClanPlayer allycp = SimpleClans.getInstance().getClanManager().getClanPlayer(player);
|
||||
|
||||
if (allycp != null)
|
||||
{
|
||||
if (allycp != null) {
|
||||
//noinspection ConstantConditions
|
||||
return allycp.getClan().isAlly(tag);
|
||||
}
|
||||
|
||||
@@ -231,15 +227,12 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Check whether the player is an rival with another player
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isRival(Player player)
|
||||
{
|
||||
public boolean isRival(Player player) {
|
||||
ClanPlayer allycp = SimpleClans.getInstance().getClanManager().getClanPlayer(player);
|
||||
|
||||
if (allycp != null)
|
||||
{
|
||||
if (allycp != null) {
|
||||
//noinspection ConstantConditions
|
||||
return allycp.getClan().isRival(tag);
|
||||
}
|
||||
|
||||
@@ -279,6 +272,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return a verbal representation of how many days ago a player was last seen
|
||||
*/
|
||||
@Placeholder("lastseendays")
|
||||
public String getLastSeenDaysString()
|
||||
{
|
||||
return getLastSeenDaysString(null);
|
||||
@@ -313,20 +307,23 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Returns number of days since the player was last seen
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getLastSeenDays()
|
||||
{
|
||||
public double getLastSeenDays() {
|
||||
return Dates.differenceInDays(new Timestamp(lastSeen), new Timestamp((new Date()).getTime()));
|
||||
}
|
||||
|
||||
@Placeholder("total_kills")
|
||||
public int getTotalKills() {
|
||||
return getRivalKills() + getCivilianKills() + getNeutralKills();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rival kills this player has
|
||||
*
|
||||
* @return the rivalKills
|
||||
*/
|
||||
public int getRivalKills()
|
||||
{
|
||||
@Placeholder("rival_kills")
|
||||
public int getRivalKills() {
|
||||
return rivalKills;
|
||||
}
|
||||
|
||||
@@ -354,6 +351,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the civilianKills
|
||||
*/
|
||||
@Placeholder("civilian_kills")
|
||||
public int getCivilianKills()
|
||||
{
|
||||
return civilianKills;
|
||||
@@ -383,6 +381,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the neutralKills
|
||||
*/
|
||||
@Placeholder("neutral_kills")
|
||||
public int getNeutralKills()
|
||||
{
|
||||
return neutralKills;
|
||||
@@ -428,6 +427,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the friendlyFire
|
||||
*/
|
||||
@Placeholder("is_friendlyfire_on")
|
||||
public boolean isFriendlyFire()
|
||||
{
|
||||
return friendlyFire;
|
||||
@@ -468,6 +468,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the deaths
|
||||
*/
|
||||
@Placeholder("deaths")
|
||||
public int getDeaths()
|
||||
{
|
||||
return deaths;
|
||||
@@ -493,9 +494,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
|
||||
/**
|
||||
* Returns weighted kill score for this player (kills multiplied by the different weights)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("weighted_kills")
|
||||
public double getWeightedKills()
|
||||
{
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
@@ -504,9 +504,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
|
||||
/**
|
||||
* Returns weighted-kill/death ratio
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("kdr")
|
||||
@Placeholder(value = "topplayers_position", resolver = "ranking_position")
|
||||
public float getKDR()
|
||||
{
|
||||
int totalDeaths = getDeaths();
|
||||
@@ -542,8 +542,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Returns a string representation of the join date, blank if not in a clan
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("join_date")
|
||||
public String getJoinDateString()
|
||||
{
|
||||
if (joinDate == 0)
|
||||
@@ -558,6 +558,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return a string representation of the last seen date
|
||||
*/
|
||||
@Placeholder("lastseen")
|
||||
@NotNull
|
||||
public String getLastSeenString()
|
||||
{
|
||||
@@ -575,7 +576,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
|
||||
public String getLastSeenString(@Nullable CommandSender sender) {
|
||||
Player player = toPlayer();
|
||||
if (player != null && player.isOnline() && !Helper.isVanished(sender, player)) {
|
||||
if (player != null && player.isOnline() && !VanishUtils.isVanished(sender, player)) {
|
||||
return lang("online", sender);
|
||||
}
|
||||
return new java.text.SimpleDateFormat("MMM dd, ''yy h:mm a").format(new Date(this.lastSeen));
|
||||
@@ -584,8 +585,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Returns the number of days the player has been inactive
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Placeholder("inactive_days")
|
||||
public int getInactiveDays()
|
||||
{
|
||||
Timestamp now = new Timestamp((new Date()).getTime());
|
||||
@@ -597,18 +598,16 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the PackedPastClans
|
||||
*/
|
||||
public String getPackedPastClans()
|
||||
{
|
||||
String packedPastClans = "";
|
||||
public String getPackedPastClans() {
|
||||
StringBuilder packedPastClans = new StringBuilder();
|
||||
|
||||
Set<String> pt = getPastClans();
|
||||
|
||||
for (String pastClan : pt)
|
||||
{
|
||||
packedPastClans += pastClan + "|";
|
||||
for (String pastClan : pt) {
|
||||
packedPastClans.append(pastClan).append("|");
|
||||
}
|
||||
|
||||
return Helper.stripTrailing(packedPastClans, "|");
|
||||
return Helper.stripTrailing(packedPastClans.toString(), "|");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,7 +623,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Adds a past clan to the player (does not update the clanplayer to db)
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
public void addPastClan(String tag)
|
||||
{
|
||||
@@ -702,7 +700,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Returns the time in millis when the player resigned from the clan
|
||||
*
|
||||
* @param tag
|
||||
* @return the time in millis
|
||||
*/
|
||||
public Long getResignTime(String tag) {
|
||||
@@ -712,7 +709,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Sets the resign times (does not update to db)
|
||||
*
|
||||
* @param resignTimes
|
||||
*/
|
||||
public void setResignTimes(Map<String, Long> resignTimes) {
|
||||
if (resignTimes != null) {
|
||||
@@ -729,7 +725,6 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
/**
|
||||
* Adds the clan to the resign times map
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
public void addResignTime(String tag) {
|
||||
if (tag != null) resignTimes.put(tag, System.currentTimeMillis());
|
||||
@@ -741,6 +736,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
* @return the clan
|
||||
*/
|
||||
@Nullable
|
||||
@Placeholder(value = "in_clan", resolver = "not_null_return")
|
||||
public Clan getClan()
|
||||
{
|
||||
return clan;
|
||||
@@ -751,14 +747,11 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @param clan the clan to set
|
||||
*/
|
||||
public void setClan(Clan clan)
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
public void setClan(@Nullable Clan clan) {
|
||||
if (clan == null) {
|
||||
this.tag = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
this.tag = clan.getTag();
|
||||
}
|
||||
|
||||
@@ -770,6 +763,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
@Placeholder("tag")
|
||||
public String getTag()
|
||||
{
|
||||
return tag;
|
||||
@@ -780,6 +774,7 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the tag
|
||||
*/
|
||||
@Placeholder("tag_label")
|
||||
public String getTagLabel()
|
||||
{
|
||||
if (clan == null)
|
||||
@@ -795,8 +790,9 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
*
|
||||
* @return the trusted
|
||||
*/
|
||||
public boolean isTrusted()
|
||||
{
|
||||
@Placeholder(value = "is_trusted", resolver = "member_status")
|
||||
@Placeholder(value = "is_member", resolver = "member_status")
|
||||
public boolean isTrusted() {
|
||||
return leader || trusted;
|
||||
}
|
||||
|
||||
@@ -945,6 +941,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
}
|
||||
}
|
||||
|
||||
@Placeholder(value = "clanchat_player_color", resolver = "player_color")
|
||||
@Placeholder(value = "allychat_player_color", resolver = "player_color")
|
||||
public @NotNull Channel getChannel()
|
||||
{
|
||||
return channel;
|
||||
@@ -991,8 +989,8 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public boolean isBbEnabled()
|
||||
{
|
||||
@Placeholder("is_bb_enabled")
|
||||
public boolean isBbEnabled() {
|
||||
return bbEnabled;
|
||||
}
|
||||
|
||||
@@ -1002,57 +1000,52 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
}
|
||||
|
||||
public boolean isCapeEnabled()
|
||||
{
|
||||
@Deprecated
|
||||
public boolean isCapeEnabled() {
|
||||
return capeEnabled;
|
||||
}
|
||||
|
||||
public void setCapeEnabled(boolean capeEnabled)
|
||||
{
|
||||
@Deprecated
|
||||
public void setCapeEnabled(boolean capeEnabled) {
|
||||
this.capeEnabled = capeEnabled;
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
}
|
||||
|
||||
public boolean isTagEnabled()
|
||||
{
|
||||
@Placeholder("is_tag_enabled")
|
||||
public boolean isTagEnabled() {
|
||||
return tagEnabled;
|
||||
}
|
||||
|
||||
public void setTagEnabled(boolean tagEnabled)
|
||||
{
|
||||
public void setTagEnabled(boolean tagEnabled) {
|
||||
this.tagEnabled = tagEnabled;
|
||||
SimpleClans.getInstance().getStorageManager().updateClanPlayer(this);
|
||||
SimpleClans.getInstance().getClanManager().updateDisplayName(this.toPlayer());
|
||||
}
|
||||
|
||||
public boolean isUseChatShortcut()
|
||||
{
|
||||
@Deprecated
|
||||
public boolean isUseChatShortcut() {
|
||||
return useChatShortcut;
|
||||
}
|
||||
|
||||
@Placeholder("rank_displayname")
|
||||
public String getRankDisplayName() {
|
||||
if (clan != null) {
|
||||
Rank r = clan.getRank(rank);
|
||||
if (r != null) {
|
||||
return r.getDisplayName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
if (clan != null) {
|
||||
Rank r = clan.getRank(rank);
|
||||
if (r != null) {
|
||||
return r.getDisplayName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rank id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Placeholder("rank")
|
||||
public String getRankId() {
|
||||
return rank;
|
||||
return rank;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the rank displayname
|
||||
*
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public String getRank()
|
||||
@@ -1111,13 +1104,13 @@ public class ClanPlayer implements Serializable, Comparable<ClanPlayer>
|
||||
allyChatMute = b;
|
||||
}
|
||||
|
||||
public boolean isMuted()
|
||||
{
|
||||
return clanChatMute;
|
||||
}
|
||||
@Placeholder("is_muted")
|
||||
public boolean isMuted() {
|
||||
return clanChatMute;
|
||||
}
|
||||
|
||||
public boolean isMutedAlly()
|
||||
{
|
||||
return allyChatMute;
|
||||
}
|
||||
@Placeholder("is_mutedally")
|
||||
public boolean isMutedAlly() {
|
||||
return allyChatMute;
|
||||
}
|
||||
}
|
||||
@@ -15,111 +15,51 @@ public class Dates {
|
||||
private Dates() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMonths(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMonths(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInYears(Timestamp date1, Timestamp date2) {
|
||||
return differenceInYears(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInDays(Timestamp date1, Timestamp date2) {
|
||||
return differenceInDays(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInHours(Timestamp date1, Timestamp date2) {
|
||||
return differenceInHours(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMinutes(Timestamp date1, Timestamp date2) {
|
||||
return differenceInMinutes(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInSeconds(Timestamp date1, Timestamp date2) {
|
||||
return differenceInSeconds(new Date(date1.getTime()), new Date(date2.getTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMonths(Date date1, Date date2) {
|
||||
return differenceInYears(date1, date2) * 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInYears(Date date1, Date date2) {
|
||||
double days = differenceInDays(date1, date2);
|
||||
return days / 365.2425;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInDays(Date date1, Date date2) {
|
||||
return differenceInHours(date1, date2) / 24.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInHours(Date date1, Date date2) {
|
||||
return differenceInMinutes(date1, date2) / 60.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInMinutes(Date date1, Date date2) {
|
||||
return differenceInSeconds(date1, date2) / 60.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @return
|
||||
*/
|
||||
public static double differenceInSeconds(Date date1, Date date2) {
|
||||
return differenceInMilliseconds(date1, date2) / 1000.0;
|
||||
}
|
||||
@@ -135,15 +75,12 @@ public class Dates {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of the amount of time labeled as days, hours, minutes, seconds
|
||||
* @author RoboMWM, LaxWasHere
|
||||
* @param seconds the time in seconds
|
||||
* @param depth Max amount of detail (e.g. only display days and hours if set to 1 and seconds > 1 day)
|
||||
* @return
|
||||
* @return the string representation of the amount of time labeled as days, hours, minutes, seconds
|
||||
*/
|
||||
public static String formatTime(Long seconds, int depth)
|
||||
{
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
public static String formatTime(Long seconds, int depth) {
|
||||
if (seconds == null || seconds < 1) {
|
||||
return lang("bb.moments");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -77,51 +79,74 @@ public class Helper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JSON String to a list of Ranks
|
||||
*
|
||||
* @param json the JSON String
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static @Nullable 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;
|
||||
|
||||
public static @Nullable JSONObject parseJson(String json) {
|
||||
if (json != null && !json.isEmpty()) {
|
||||
try {
|
||||
return (JSONObject) new JSONParser().parse(json);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of Ranks to a JSON String
|
||||
* Parses a list of ranks from the specified JSONObject
|
||||
*
|
||||
* @param ranks
|
||||
* @param jo the JSON Object
|
||||
* @return a list of ranks or null if the JSON String is null/empty
|
||||
*/
|
||||
public static @Nullable List<Rank> ranksFromJson(JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the default rank from the specified JSONObject
|
||||
*
|
||||
* @param jo the JSON object
|
||||
* @return the default rank or null if not found and/or it does not exist
|
||||
*/
|
||||
public static @Nullable String defaultRankFromJson(JSONObject jo) {
|
||||
if (jo != null && !jo.isEmpty()) {
|
||||
if (!jo.containsKey("defaultRank")) {
|
||||
return null;
|
||||
} else {
|
||||
return (String) jo.get("defaultRank");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of ranks and the default rank to a JSON String
|
||||
*
|
||||
* @param ranks the ranks
|
||||
* @param defaultRank the default rank
|
||||
* @return a JSON String
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String ranksToJson(List<Rank> ranks) {
|
||||
public static String ranksToJson(List<Rank> ranks, @Nullable String defaultRank) {
|
||||
if (ranks == null)
|
||||
ranks = new ArrayList<Rank>();
|
||||
|
||||
@@ -140,6 +165,7 @@ public class Helper {
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("ranks", array);
|
||||
object.put("defaultRank", defaultRank);
|
||||
return object.toJSONString();
|
||||
}
|
||||
|
||||
@@ -202,7 +228,8 @@ public class Helper {
|
||||
List<Player> players = SimpleClans.getInstance().getServer().matchPlayer(playerName);
|
||||
|
||||
if (players.size() == 1) {
|
||||
return SimpleClans.getInstance().getPermissionsManager().getPrefix(players.get(0)) + players.get(0).getName() + SimpleClans.getInstance().getPermissionsManager().getSuffix(players.get(0));
|
||||
PermissionsManager pm = SimpleClans.getInstance().getPermissionsManager();
|
||||
return pm.getPrefix(players.get(0)) + players.get(0).getName() + pm.getSuffix(players.get(0));
|
||||
}
|
||||
|
||||
return playerName;
|
||||
@@ -375,6 +402,9 @@ public class Helper {
|
||||
if (hexValue == null) {
|
||||
return "";
|
||||
}
|
||||
if (hexValue.startsWith("&#")) {
|
||||
return ChatUtils.parseColors(hexValue);
|
||||
}
|
||||
|
||||
ChatColor color = ChatColor.getByChar(hexValue);
|
||||
if (color == null) {
|
||||
@@ -511,25 +541,21 @@ public class Helper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert color hex values with ampersand to special character
|
||||
*
|
||||
* @param msg
|
||||
* @return
|
||||
* @deprecated use {@link ChatUtils#parseColors(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String parseColors(String msg) {
|
||||
return msg.replace("&", "\u00a7");
|
||||
return ChatUtils.parseColors(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes color codes from strings
|
||||
*
|
||||
* @param msg
|
||||
* @return
|
||||
* @deprecated use {@link ChatUtils#stripColors(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String stripColors(String msg) {
|
||||
String out = msg.replaceAll("[&][0-9a-fk-or]", "");
|
||||
out = out.replaceAll(String.valueOf((char) 194), "");
|
||||
return out.replaceAll("[\u00a7][0-9a-fk-or]", "");
|
||||
return ChatUtils.stripColors(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -817,8 +843,8 @@ public class Helper {
|
||||
|
||||
String leaderColor = sm.getAllyChatLeaderColor();
|
||||
String memberColor = sm.getAllyChatMemberColor();
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getAllyChatRank()).replace("%rank%", rank) : "";
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatUtils.parseColors(cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatUtils.parseColors(sm.getAllyChatRank()).replace("%rank%", rank) : "";
|
||||
|
||||
String message = replacePlaceholders(sm.getAllyChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
if (placeholders != null) {
|
||||
@@ -829,8 +855,13 @@ public class Helper {
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String replacePlaceholders(String messageFormat, ClanPlayer cp, String leaderColor, String memberColor, String rankFormat, String msg) {
|
||||
return ChatColor.translateAlternateColorCodes('&', messageFormat)
|
||||
private static String replacePlaceholders(String messageFormat,
|
||||
ClanPlayer cp,
|
||||
String leaderColor,
|
||||
String memberColor,
|
||||
String rankFormat,
|
||||
String msg) {
|
||||
return ChatUtils.parseColors(messageFormat)
|
||||
.replace("%clan%", Objects.requireNonNull(cp.getClan()).getColorTag())
|
||||
.replace("%nick-color%", (cp.isLeader() ? leaderColor : memberColor))
|
||||
.replace("%player%", cp.getName())
|
||||
@@ -851,8 +882,8 @@ public class Helper {
|
||||
|
||||
String leaderColor = sm.getClanChatLeaderColor();
|
||||
String memberColor = sm.getClanChatMemberColor();
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getClanChatRank()).replace("%rank%", rank) : "";
|
||||
String rank = cp.getRankId().isEmpty() ? null : ChatUtils.parseColors(cp.getRankDisplayName());
|
||||
String rankFormat = rank != null ? ChatUtils.parseColors(sm.getClanChatRank()).replace("%rank%", rank) : "";
|
||||
|
||||
String message = replacePlaceholders(sm.getClanChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.SCCommandManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.SimpleClansExpansion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.*;
|
||||
@@ -9,10 +10,10 @@ import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.tasks.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatFormatMigration;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.UpdateChecker;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@@ -36,7 +37,7 @@ 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 static final Logger logger = Logger.getLogger("SimpleClans");
|
||||
private SCCommandManager commandManager;
|
||||
private ClanManager clanManager;
|
||||
private RequestManager requestManager;
|
||||
@@ -45,6 +46,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
private PermissionsManager permissionsManager;
|
||||
private TeleportManager teleportManager;
|
||||
private boolean hasUUID;
|
||||
private static final Pattern ACF_PLACEHOLDER_PATTERN = Pattern.compile("\\{(?<key>[a-zA-Z]+?)}");
|
||||
|
||||
/**
|
||||
* @return the logger
|
||||
@@ -127,7 +129,7 @@ public class SimpleClans extends JavaPlugin {
|
||||
private void hookIntoPAPI() {
|
||||
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
getLogger().info("PlaceholderAPI found. Registering hook...");
|
||||
new PlaceholdersManager(this).register();
|
||||
new SimpleClansExpansion(this).register();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,9 +251,9 @@ public class SimpleClans extends JavaPlugin {
|
||||
if (lang == null) {
|
||||
return null;
|
||||
}
|
||||
String message = ChatColor.translateAlternateColorCodes('&', lang);
|
||||
String message = ChatUtils.parseColors(lang);
|
||||
// contains acf placeholders like {commandprefix}
|
||||
if (Pattern.compile("\\{(?<key>[a-zA-Z]+?)}").matcher(message).find()) {
|
||||
if (ACF_PLACEHOLDER_PATTERN.matcher(message).find()) {
|
||||
return message;
|
||||
}
|
||||
return MessageFormat.format(message, arguments);
|
||||
|
||||
@@ -160,10 +160,10 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
getCommandReplacements().addReplacements(
|
||||
"basic_conditions", "not_blacklisted|not_banned",
|
||||
"clan", sm.getCommandClan(),
|
||||
"deny", sm.getCommandDeny(),
|
||||
"deny", sm.getCommandDeny() + "|deny",
|
||||
"more", sm.getCommandMore(),
|
||||
"ally_chat", sm.getCommandAlly(),
|
||||
"accept", sm.getCommandAccept(),
|
||||
"accept", sm.getCommandAccept() + "|accept",
|
||||
"clan_chat", sm.getCommandClanChat()
|
||||
);
|
||||
|
||||
@@ -216,6 +216,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
"modtag", "bb", "clear", "rival", "ally", "add", "remove", "stats", "coords", "vitals", "rivalries",
|
||||
"alliances", "leaderboard", "allow", "block", "auto", "check", "assign", "unassign", "delete", "me",
|
||||
"setdisplayname", "permissions", "tag", "deposit", "withdraw", "set", "status", "tp", "all", "everyone",
|
||||
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help");
|
||||
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help", "mod",
|
||||
"setdefault", "removedefault");
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.ResignPrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -102,7 +103,7 @@ public class ClanCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", Helper.parseColors(tag)));
|
||||
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.changeClanTag(tag);
|
||||
cm.updateDisplayName(player);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.CreateRankNamePrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
@@ -67,7 +68,7 @@ public class RankCommand extends BaseCommand {
|
||||
@Description("{@@command.description.rank.create}")
|
||||
public void create(Player player, Clan clan) {
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateRankNamePrompt())
|
||||
.withLocalEcho(true).buildConversation(player);
|
||||
.withLocalEcho(true).withTimeout(60).buildConversation(player);
|
||||
conversation.getContext().setSessionData("clan", clan);
|
||||
conversation.begin();
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class RankCommand extends BaseCommand {
|
||||
int count = 1;
|
||||
for (Rank rank : ranks) {
|
||||
ChatBlock.sendMessage(player, AQUA + lang("ranks.list.item", player, count,
|
||||
Helper.parseColors(rank.getDisplayName()) + AQUA, rank.getName()));
|
||||
ChatUtils.parseColors(rank.getDisplayName()) + AQUA, rank.getName()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -117,6 +118,23 @@ public class RankCommand extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("rank.displayname.updated", player));
|
||||
}
|
||||
|
||||
@Subcommand("%setdefault")
|
||||
@CommandPermission("simpleclans.leader.rank.setdefault")
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.setdefault}")
|
||||
public void setDefault(Player player, Clan clan, @Name("rank") Rank rank) {
|
||||
clan.setDefaultRank(rank.getName());
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.setdefault", player, rank.getDisplayName()));
|
||||
}
|
||||
|
||||
@Subcommand("%removedefault")
|
||||
@CommandPermission("simpleclans.leader.rank.removedefault")
|
||||
@Description("{@@command.description.rank.removedefault}")
|
||||
public void removeDefault(Player player, Clan clan) {
|
||||
clan.setDefaultRank(null);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.removedefault", player));
|
||||
}
|
||||
|
||||
@Subcommand("%permissions")
|
||||
public class PermissionsCommand extends BaseCommand {
|
||||
private final String validPermissionsToMessage = Helper.toMessage(Helper.fromPermissionArray(), ",");
|
||||
|
||||
@@ -23,12 +23,12 @@ public class CanVoteCondition extends AbstractCommandCondition {
|
||||
ClanPlayer cp = clanManager.getCreateClanPlayer(player.getUniqueId());
|
||||
Clan clan = cp.getClan();
|
||||
if (clan != null) {
|
||||
if (!clan.isLeader(player)) {
|
||||
throw new ConditionFailedException(RED + lang("no.leader.permissions", player));
|
||||
}
|
||||
if (!requestManager.hasRequest(clan.getTag())) {
|
||||
throw new ConditionFailedException(lang("nothing.to.vote", player));
|
||||
}
|
||||
if (!clan.isLeader(player)) {
|
||||
throw new ConditionFailedException(RED + lang("no.leader.permissions", player));
|
||||
}
|
||||
if (cp.getVote() != null) {
|
||||
throw new ConditionFailedException(RED + lang("you.have.already.voted", player));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class InputVerifiedCondition extends AbstractParameterCondition<ClanInput
|
||||
BukkitCommandExecutionContext execContext,
|
||||
ClanInput value)
|
||||
throws InvalidCommandArgument {
|
||||
if (!value.getClan().isVerified()) {
|
||||
if (!value.getClan().isVerified() && !context.getIssuer().hasPermission("simpleclans.mod.bypass")) {
|
||||
throw new ConditionFailedException(lang("other.clan.not.verified", execContext.getSender()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.data;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -35,7 +36,7 @@ public class ClanRoster extends Sendable {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = (cp.isTrusted() ? sm.getPageTrustedColor() : sm.getPageUnTrustedColor()) + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !Helper.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class ClanRoster extends Sendable {
|
||||
Player p = cp.toPlayer();
|
||||
|
||||
String name = sm.getPageLeaderColor() + cp.getName();
|
||||
String lastSeen = p != null && p.isOnline() && !Helper.isVanished(sender, p) ? GREEN + lang("online", sender)
|
||||
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender)
|
||||
: WHITE + cp.getLastSeenDaysString(sender);
|
||||
|
||||
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
|
||||
|
||||
@@ -75,10 +75,19 @@ public class Lookup extends Sendable {
|
||||
|
||||
@NotNull
|
||||
private String getPlayerStatus() {
|
||||
return target == null || targetClan == null ? lang("free.agent", sender) : (target.isLeader() ?
|
||||
sm.getPageLeaderColor() + lang("leader", sender) : (target.isTrusted() ?
|
||||
sm.getPageTrustedColor() + lang("trusted", sender) : sm.getPageUnTrustedColor() +
|
||||
lang("untrusted", sender)));
|
||||
if (target == null || targetClan == null) {
|
||||
return lang("free.agent", sender);
|
||||
}
|
||||
if (target.isLeader()) {
|
||||
return sm.getPageLeaderColor() + lang("leader", sender);
|
||||
}
|
||||
if (target.isTrusted()) {
|
||||
return sm.getPageTrustedColor() + lang("trusted", sender);
|
||||
}
|
||||
if (target.getRankId() != null && !target.getRankId().isEmpty()) {
|
||||
return sm.getPageTrustedColor() + lang("in.rank", sender);
|
||||
}
|
||||
return sm.getPageUnTrustedColor() + lang("untrusted", sender);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -75,7 +75,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
initialData.put(TAG_KEY, tag);
|
||||
initialData.put(NAME_KEY, name);
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateClanTagPrompt())
|
||||
.withLocalEcho(true).withInitialSessionData(initialData).buildConversation(player);
|
||||
.withLocalEcho(true).withTimeout(60).withInitialSessionData(initialData).buildConversation(player);
|
||||
conversation.begin();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,15 @@ import co.aikar.commands.bukkit.contexts.OnlinePlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -41,7 +44,7 @@ public class StaffCommands extends BaseCommand {
|
||||
@Dependency
|
||||
private StorageManager storage;
|
||||
|
||||
@Subcommand("%place")
|
||||
@Subcommand("%mod %place")
|
||||
@CommandPermission("simpleclans.mod.place")
|
||||
@CommandCompletion("@players @clans")
|
||||
@HelpSearchTags("move put")
|
||||
@@ -59,9 +62,8 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
|
||||
if (oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
|
||||
oldClan.clanAnnounce(player.getName(), AQUA + lang("clan.has.been.disbanded",
|
||||
oldClan.getName()));
|
||||
oldClan.disband();
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.cannot.move.the.last.leader", sender));
|
||||
return;
|
||||
} else {
|
||||
oldClan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
|
||||
oldClan.removePlayerFromClan(player.getUniqueId());
|
||||
@@ -75,7 +77,37 @@ public class StaffCommands extends BaseCommand {
|
||||
newClanInput.addPlayerToClan(cp);
|
||||
}
|
||||
|
||||
@Subcommand("%reload")
|
||||
@Subcommand("%mod %modtag")
|
||||
@CommandPermission("simpleclans.mod.modtag")
|
||||
@Description("{@@command.description.modtag.other}")
|
||||
public void modtag(Player player, @Name("clan") ClanInput clanInput, @Single @Name("tag") String tag) {
|
||||
Clan clan = clanInput.getClan();
|
||||
TagChangeEvent event = new TagChangeEvent(player, clan, tag);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
tag = event.getNewTag();
|
||||
String cleanTag = Helper.cleanTag(tag);
|
||||
|
||||
TagValidator validator = new TagValidator(plugin, player, tag);
|
||||
if (validator.getErrorMessage() != null) {
|
||||
ChatBlock.sendMessage(player, validator.getErrorMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cleanTag.equals(clan.getTag())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.can.only.modify.the.color.and.case.of.the.tag",
|
||||
player));
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
|
||||
clan.changeClanTag(tag);
|
||||
player.sendMessage(lang("0.tag.changed.to.1", player, clan.getTag(), tag));
|
||||
}
|
||||
|
||||
@Subcommand("%admin %reload")
|
||||
@CommandPermission("simpleclans.admin.reload")
|
||||
@Description("{@@command.description.reload}")
|
||||
public void reload(CommandSender sender) {
|
||||
@@ -92,7 +124,7 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("configuration.reloaded", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%home %set")
|
||||
@Subcommand("%mod %home %set")
|
||||
@CommandPermission("simpleclans.mod.home")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.mod.home.set}")
|
||||
@@ -104,7 +136,7 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatColor.YELLOW + Helper.toLocationString(loc));
|
||||
}
|
||||
|
||||
@Subcommand("%home %tp")
|
||||
@Subcommand("%mod %home %tp")
|
||||
@CommandCompletion("@clans:has_home")
|
||||
@CommandPermission("simpleclans.mod.hometp")
|
||||
@Description("{@@command.description.mod.home.tp}")
|
||||
@@ -119,7 +151,7 @@ public class StaffCommands extends BaseCommand {
|
||||
plugin.getTeleportManager().teleportToHome(player, clan.getClan());
|
||||
}
|
||||
|
||||
@Subcommand("%ban")
|
||||
@Subcommand("%mod %ban")
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.ban}")
|
||||
@@ -139,7 +171,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%unban")
|
||||
@Subcommand("%mod %unban")
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.unban}")
|
||||
@@ -159,7 +191,7 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.removed.from.the.banned.list", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%globalff %allow")
|
||||
@Subcommand("%mod %globalff %allow")
|
||||
@CommandPermission("simpleclans.mod.globalff")
|
||||
@Description("{@@command.description.globalff.allow}")
|
||||
public void allowGlobalFf(CommandSender sender) {
|
||||
@@ -171,7 +203,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%globalff %auto")
|
||||
@Subcommand("%mod %globalff %auto")
|
||||
@CommandPermission("simpleclans.mod.globalff")
|
||||
@Description("{@@command.description.globalff.auto}")
|
||||
public void autoGlobalFf(CommandSender sender) {
|
||||
@@ -185,8 +217,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subcommand("%verify")
|
||||
@Subcommand("%mod %verify")
|
||||
@CommandPermission("simpleclans.mod.verify")
|
||||
@CommandCompletion("@clans:unverified")
|
||||
@Description("{@@command.description.mod.verify}")
|
||||
@@ -202,7 +233,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%purge")
|
||||
@Subcommand("%admin %purge")
|
||||
@CommandPermission("simpleclans.admin.purge")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.purge}")
|
||||
@@ -220,7 +251,24 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.purged", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%disband")
|
||||
@Subcommand("%mod %kick")
|
||||
@Description("{@@command.description.mod.kick}")
|
||||
@CommandPermission("simpleclans.mod.kick")
|
||||
@CommandCompletion("@all_non_leaders|@all_leaders")
|
||||
public void kick(CommandSender sender, @Conditions("clan_member") @Name("player") ClanPlayerInput cp) {
|
||||
ClanPlayer clanPlayer = cp.getClanPlayer();
|
||||
Clan clan = Objects.requireNonNull(clanPlayer.getClan());
|
||||
if (clan.getLeaders().size() == 1) {
|
||||
ChatBlock.sendMessageKey(sender, "cannot.kick.last.leader");
|
||||
return;
|
||||
}
|
||||
|
||||
clan.addBb(sender.getName(), AQUA + lang("has.been.kicked.by", clanPlayer.getName(),
|
||||
sender.getName(), sender));
|
||||
clan.removePlayerFromClan(clanPlayer.getUniqueId());
|
||||
}
|
||||
|
||||
@Subcommand("%mod %disband")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandPermission("simpleclans.mod.disband")
|
||||
@Description("{@@command.description.mod.disband}")
|
||||
@@ -248,6 +296,7 @@ public class StaffCommands extends BaseCommand {
|
||||
|
||||
clan.addBb(sender.getName(), AQUA + lang("promoted.to.leader", promotePl.getName()));
|
||||
clan.promote(promotePl.getUniqueId());
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.promoted", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%admin %demote")
|
||||
@@ -267,7 +316,7 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.demoted", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%resetkdr %everyone")
|
||||
@Subcommand("%admin %resetkdr %everyone")
|
||||
@CommandPermission("simpleclans.admin.resetkdr")
|
||||
@Description("{@@command.description.resetkdr.everyone}")
|
||||
public void resetKdr(CommandSender sender) {
|
||||
@@ -277,7 +326,7 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.have.reseted.kdr.of.all.players", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%resetkdr")
|
||||
@Subcommand("%admin %resetkdr")
|
||||
@CommandCompletion("@players")
|
||||
@CommandPermission("simpleclans.admin.resetkdr")
|
||||
@Description("{@@command.description.resetkdr.player}")
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Request;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -22,7 +23,7 @@ public class RequestEvent extends Event {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class TagChangeEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final @NotNull Clan clan;
|
||||
private final @NotNull Clan clan;
|
||||
private @NotNull String newTag;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@Repeatable(Placeholders.class)
|
||||
public @interface Placeholder {
|
||||
|
||||
String value();
|
||||
String resolver() default "method_return";
|
||||
String config() default "";
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class PlaceholderResolver {
|
||||
|
||||
protected final SimpleClans plugin;
|
||||
|
||||
public PlaceholderResolver(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract String getId();
|
||||
|
||||
/**
|
||||
* Resolves the placeholder and returns its value
|
||||
*
|
||||
* @param player the player involved in the placeholder request
|
||||
* @param object the subject of the Placeholder, usually a {@link Clan} or a {@link ClanPlayer}
|
||||
* @param method the annotated method
|
||||
* @param placeholder the placeholder to resolve
|
||||
* @param config configuration for the resolver
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config);
|
||||
|
||||
@Nullable
|
||||
protected Object invoke(@NotNull Object object, @NotNull Method method, @NotNull String placeholder) {
|
||||
try {
|
||||
return method.invoke(object);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, String.format("Error parsing placeholder %s", placeholder), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Placeholders {
|
||||
|
||||
Placeholder[] value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class SimpleClansExpansion extends PlaceholderExpansion {
|
||||
|
||||
private static final Pattern TOP_CLANS_PATTERN = Pattern.compile("(?<strip>^topclans_(?<position>\\d+)_)clan_");
|
||||
private static final Pattern TOP_PLAYERS_PATTERN = Pattern.compile("(?<strip>^topplayers_(?<position>\\d+)_)");
|
||||
private static final Map<String, PlaceholderResolver> RESOLVERS = new HashMap<>();
|
||||
private List<String> placeholders;
|
||||
private final SimpleClans plugin;
|
||||
private final ClanManager clanManager;
|
||||
|
||||
public SimpleClansExpansion(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
clanManager = plugin.getClanManager();
|
||||
registerResolvers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getName() {
|
||||
return plugin.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return getName().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return plugin.getDescription().getAuthors().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> getPlaceholders() {
|
||||
if (placeholders == null) {
|
||||
this.placeholders = new ArrayList<>();
|
||||
addPlaceholders("simpleclans_", ClanPlayer.class, placeholders);
|
||||
addPlaceholders("simpleclans_clan_", Clan.class, placeholders);
|
||||
}
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
private void addPlaceholders(String prefix, Class<?> clazz, List<String> placeholders) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
Placeholder[] annotations = method.getAnnotationsByType(Placeholder.class);
|
||||
for (Placeholder annotation : annotations) {
|
||||
placeholders.add("%" + prefix + annotation.value() + "%");
|
||||
//Commented because the list would be very long
|
||||
//placeholders.add("%simpleclans_topplayers_<number>_" + annotation.value() + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String params) {
|
||||
ClanPlayer cp = null;
|
||||
if (player != null) {
|
||||
cp = clanManager.getAnyClanPlayer(player.getUniqueId());
|
||||
}
|
||||
Clan clan = cp != null ? cp.getClan() : null;
|
||||
Matcher matcher = TOP_CLANS_PATTERN.matcher(params);
|
||||
if (matcher.find()) {
|
||||
int position = Integer.parseInt(matcher.group("position"));
|
||||
clan = getFromPosition(clanManager.getClans(), position, clanManager::sortClansByKDR);
|
||||
params = params.replace(matcher.group("strip"), "");
|
||||
}
|
||||
matcher = TOP_PLAYERS_PATTERN.matcher(params);
|
||||
if (matcher.find()) {
|
||||
int position = Integer.parseInt(matcher.group("position"));
|
||||
cp = getFromPosition(clanManager.getAllClanPlayers(), position, clanManager::sortClanPlayersByKDR);
|
||||
params = params.replace(matcher.group("strip"), "");
|
||||
}
|
||||
return getValue(player, cp, clan, params);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T getFromPosition(List<T> list, int position, Consumer<List<T>> sort) {
|
||||
if (isPositionValid(list, position)) {
|
||||
sort.accept(list);
|
||||
return list.get(position - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPositionValid(@NotNull Collection<?> collection, int position) {
|
||||
return position >= 1 && position <= collection.size();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getValue(@Nullable OfflinePlayer player, @Nullable ClanPlayer cp, @Nullable Clan clan,
|
||||
@NotNull String placeholder) {
|
||||
if (placeholder.startsWith("clan_")) {
|
||||
placeholder = placeholder.replace("clan_", "");
|
||||
return getValue(player, clan, placeholder);
|
||||
}
|
||||
return getValue(player, cp, placeholder);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getValue(@Nullable OfflinePlayer player, @Nullable Object object, @NotNull String placeholder) {
|
||||
if (object != null) {
|
||||
for (Method declaredMethod : object.getClass().getDeclaredMethods()) {
|
||||
Placeholder[] annotations = declaredMethod.getAnnotationsByType(Placeholder.class);
|
||||
for (Placeholder p : annotations) {
|
||||
if (p.value().equals(placeholder)) {
|
||||
return resolve(player, object, declaredMethod, p.resolver(), placeholder, p.config());
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.getLogger().warning(String.format("Placeholder %s not found", placeholder));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String resolverId, @NotNull String placeholder, @NotNull String config) {
|
||||
PlaceholderResolver resolver = RESOLVERS.get(resolverId);
|
||||
if (resolver != null) {
|
||||
return resolver.resolve(player, object, method, placeholder, getConfigMap(config));
|
||||
}
|
||||
plugin.getLogger().warning(String.format("Resolver %s for %s not found", resolverId, placeholder));
|
||||
return "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, String> getConfigMap(@NotNull String config) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
String[] elements = config.split(",");
|
||||
for (String element : elements) {
|
||||
String[] keyAndValue = element.split(":");
|
||||
map.put(keyAndValue[0], keyAndValue.length > 1 ? keyAndValue[1] : null);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private void registerResolvers() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers");
|
||||
Set<Class<? extends PlaceholderResolver>> resolvers = reflections.getSubTypesOf(PlaceholderResolver.class);
|
||||
plugin.getLogger().info(String.format("Registering %d placeholder resolvers...", resolvers.size()));
|
||||
for (Class<? extends PlaceholderResolver> r : resolvers) {
|
||||
try {
|
||||
PlaceholderResolver resolver = r.getConstructor(SimpleClans.class).newInstance(plugin);
|
||||
RESOLVERS.put(resolver.getId(), resolver);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
|
||||
NoSuchMethodException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Error registering placeholder resolver", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ListSizeResolver extends PlaceholderResolver {
|
||||
public ListSizeResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "list_size";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config) {
|
||||
Object result = invoke(object, method, placeholder);
|
||||
String size = "";
|
||||
if (result instanceof List) {
|
||||
size = String.valueOf(((List<?>) result).size());
|
||||
if (config.containsKey("filter_vanished")) {
|
||||
size = String.valueOf(VanishUtils.getNonVanished(player != null ? player.getPlayer() : null,
|
||||
(List<ClanPlayer>) result).size());
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanFalse;
|
||||
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanTrue;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class MemberStatusResolver extends PlaceholderResolver {
|
||||
public MemberStatusResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "member_status";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config) {
|
||||
boolean result = false;
|
||||
if (object instanceof ClanPlayer) {
|
||||
ClanPlayer cp = (ClanPlayer) object;
|
||||
if (placeholder.equals("is_member")) {
|
||||
result = cp.getClan() != null && !cp.isTrusted();
|
||||
}
|
||||
if (placeholder.equals("is_trusted")) {
|
||||
result = cp.getClan() != null && !cp.isLeader() && cp.isTrusted();
|
||||
}
|
||||
}
|
||||
return result ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class MethodReturnResolver extends PlaceholderResolver {
|
||||
|
||||
public MethodReturnResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "method_return";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config) {
|
||||
Object result = invoke(object, method, placeholder);
|
||||
if (result == null) {
|
||||
return "";
|
||||
}
|
||||
if (result instanceof Boolean) {
|
||||
return ((Boolean) result) ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
}
|
||||
return String.valueOf(result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanFalse;
|
||||
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanTrue;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NotNullReturnResolver extends PlaceholderResolver {
|
||||
public NotNullReturnResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "not_null_return";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config) {
|
||||
return invoke(object, method, placeholder) != null ? booleanTrue() : booleanFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerColorResolver extends PlaceholderResolver {
|
||||
public PlayerColorResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "player_color";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config) {
|
||||
ClanPlayer cp = object instanceof ClanPlayer ? ((ClanPlayer) object) : null;
|
||||
if (cp == null) return "";
|
||||
switch (placeholder) {
|
||||
case "clanchat_player_color": {
|
||||
return getClanChatColor(cp);
|
||||
}
|
||||
case "allychat_player_color": {
|
||||
return getAllyChatColor(cp);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getClanChatColor(ClanPlayer player) {
|
||||
if (player.isLeader()) {
|
||||
return plugin.getSettingsManager().getClanChatLeaderColor();
|
||||
}
|
||||
if (player.isTrusted()) {
|
||||
return plugin.getSettingsManager().getClanChatTrustedColor();
|
||||
}
|
||||
if (player.getClan() != null) {
|
||||
return plugin.getSettingsManager().getClanChatMemberColor();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getAllyChatColor(ClanPlayer player) {
|
||||
if (player.isLeader()) {
|
||||
return plugin.getSettingsManager().getAllyChatLeaderColor();
|
||||
}
|
||||
if (player.isTrusted()) {
|
||||
return plugin.getSettingsManager().getAllyChatTrustedColor();
|
||||
}
|
||||
if (player.getClan() != null) {
|
||||
return plugin.getSettingsManager().getAllyChatMemberColor();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RankingPositionResolver extends PlaceholderResolver {
|
||||
public RankingPositionResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "ranking_position";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
|
||||
@NotNull String placeholder, @NotNull Map<String, String> config) {
|
||||
if (object instanceof Clan) {
|
||||
List<Clan> clans = plugin.getClanManager().getClans();
|
||||
plugin.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
return String.valueOf(clans.indexOf(object) + 1);
|
||||
}
|
||||
if (object instanceof ClanPlayer) {
|
||||
List<ClanPlayer> clanPlayers = plugin.getClanManager().getAllClanPlayers();
|
||||
plugin.getClanManager().sortClanPlayersByKDR(clanPlayers);
|
||||
|
||||
return String.valueOf(clanPlayers.indexOf(object) + 1);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -163,8 +163,14 @@ public class LanguageResource {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
int lineCount = 0;
|
||||
try {
|
||||
while (reader.readLine() != null) {
|
||||
lineCount++;
|
||||
while (true) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
if (!line.startsWith("#")) {
|
||||
lineCount++;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
lineCount = -1;
|
||||
|
||||
@@ -12,9 +12,15 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FriendlyFire implements Listener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final Map<UUID, Long> warned = new HashMap<>();
|
||||
private static final long WARN_DELAY = 10000;
|
||||
|
||||
public FriendlyFire(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -59,14 +65,24 @@ public class FriendlyFire implements Listener {
|
||||
}
|
||||
|
||||
if (victimClan.equals(attackerClan)) {
|
||||
ChatBlock.sendMessageKey(attacker, "cannot.attack.clan.member");
|
||||
warn(attacker, "cannot.attack.clan.member");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (victimClan.isAlly(attackerClan.getTag())) {
|
||||
ChatBlock.sendMessageKey(attacker, "cannot.attack.ally");
|
||||
warn(attacker, "cannot.attack.ally");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void warn(Player attacker, String messageKey) {
|
||||
long timestamp = warned.getOrDefault(attacker.getUniqueId(), 0L);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
|
||||
if (timestamp + WARN_DELAY <= currentTimeMillis) {
|
||||
ChatBlock.sendMessageKey(attacker, messageKey);
|
||||
warned.put(attacker.getUniqueId(), currentTimeMillis);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,9 +36,11 @@ public class PlayerDeath implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDeath(PlayerDeathEvent event) {
|
||||
SimpleClans.debug("A player died");
|
||||
Player victim = event.getEntity();
|
||||
if (plugin.getSettingsManager().isBlacklistedWorld(victim.getLocation().getWorld())
|
||||
|| victim.hasMetadata("NPC")) {
|
||||
SimpleClans.debug("Blacklisted world");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,6 +95,7 @@ public class PlayerDeath implements Listener {
|
||||
@Contract("_, null -> true")
|
||||
private boolean isInvalidKill(@NotNull Player victim, @Nullable Player attacker) {
|
||||
if (attacker == null || attacker.getUniqueId().equals(victim.getUniqueId())) {
|
||||
SimpleClans.debug("Attacker is not a player or victim and attacker have the same UUID");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PvPOnlyInWar implements Listener {
|
||||
|
||||
@@ -39,7 +40,8 @@ public class PvPOnlyInWar implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void process(EntityDamageEvent event, Player attacker, Player victim, Clan attackerClan, Clan victimClan) {
|
||||
private void process(EntityDamageEvent event, Player attacker, Player victim, @Nullable Clan attackerClan,
|
||||
@Nullable Clan victimClan) {
|
||||
if (attackerClan == null || victimClan == null) {
|
||||
ChatBlock.sendMessageKey(attacker, "must.be.in.clan.to.pvp", victim.getName());
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -14,8 +14,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.NONE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -76,14 +74,15 @@ public class SCPlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void handleChatTags(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
|
||||
if (cp == null || plugin.getSettingsManager().isBlacklistedWorld(player.getWorld())) {
|
||||
if (plugin.getSettingsManager().isBlacklistedWorld(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
Clan clan = Objects.requireNonNull(cp.getClan());
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
String tagLabel = cp != null && cp.isTagEnabled() ? cp.getTagLabel() : null;
|
||||
|
||||
if (plugin.getSettingsManager().isCompatMode() && plugin.getSettingsManager().isChatTags()) {
|
||||
if (cp.isTagEnabled()) {
|
||||
String tagLabel = clan.getTagLabel(cp.isLeader());
|
||||
if (tagLabel != null) {
|
||||
if (player.getDisplayName().contains("{clan}")) {
|
||||
player.setDisplayName(player.getDisplayName().replace("{clan}", tagLabel));
|
||||
} else if (event.getFormat().contains("{clan}")) {
|
||||
|
||||
@@ -55,20 +55,15 @@ public final class ClanManager {
|
||||
/**
|
||||
* Adds a kill to the memory
|
||||
*
|
||||
* @param kill
|
||||
*/
|
||||
public void addKill(Kill kill) {
|
||||
if (kill == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Kill> list = kills.get(kill.getKiller());
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
kills.put(kill.getKiller(), list);
|
||||
}
|
||||
|
||||
Iterator<Kill> iterator = list.iterator();
|
||||
List<Kill> list = kills.computeIfAbsent(kill.getKiller(), k -> new ArrayList<>());
|
||||
|
||||
Iterator<Kill> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Kill oldKill = iterator.next();
|
||||
if (oldKill.getVictim().equals(kill.getKiller())) {
|
||||
@@ -89,9 +84,7 @@ public final class ClanManager {
|
||||
|
||||
/**
|
||||
* Checks if this kill respects the delay
|
||||
*
|
||||
* @param kill
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public boolean isKillBeforeDelay(Kill kill) {
|
||||
if (kill == null) {
|
||||
@@ -102,19 +95,16 @@ public final class ClanManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator<Kill> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
for (Kill oldKill : list) {
|
||||
if (oldKill.getVictim().equals(kill.getVictim())) {
|
||||
|
||||
Kill oldKill = iterator.next();
|
||||
if (oldKill.getVictim().equals(kill.getVictim())) {
|
||||
|
||||
final int delay = plugin.getSettingsManager().getDelayBetweenKills();
|
||||
long timePassed = oldKill.getTime().until(kill.getTime(), ChronoUnit.MINUTES);
|
||||
if (timePassed < delay) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
final int delay = plugin.getSettingsManager().getDelayBetweenKills();
|
||||
long timePassed = oldKill.getTime().until(kill.getTime(), ChronoUnit.MINUTES);
|
||||
if (timePassed < delay) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -122,7 +112,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Import a clan into the in-memory store
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
public void importClan(Clan clan) {
|
||||
this.clans.put(clan.getTag(), clan);
|
||||
@@ -131,7 +120,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Import a clan player into the in-memory store
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void importClanPlayer(ClanPlayer cp) {
|
||||
if (cp.getUniqueId() != null) {
|
||||
@@ -142,9 +130,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Create a new clan
|
||||
*
|
||||
* @param player
|
||||
* @param colorTag
|
||||
* @param name
|
||||
*/
|
||||
public void createClan(Player player, String colorTag, String name) {
|
||||
ClanPlayer cp = getCreateClanPlayer(player.getUniqueId());
|
||||
@@ -166,7 +151,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Reset a player's KDR
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void resetKdr(ClanPlayer cp) {
|
||||
cp.setCivilianKills(0);
|
||||
@@ -179,7 +163,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Delete a players data file
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void deleteClanPlayer(ClanPlayer cp) {
|
||||
Clan clan = cp.getClan();
|
||||
@@ -193,7 +176,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Delete a player data from memory
|
||||
*
|
||||
* @param playerUniqueId
|
||||
*/
|
||||
public void deleteClanPlayerFromMemory(UUID playerUniqueId) {
|
||||
clanPlayers.remove(playerUniqueId.toString());
|
||||
@@ -202,7 +184,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Remove a clan from memory
|
||||
*
|
||||
* @param tag
|
||||
*/
|
||||
public void removeClan(String tag) {
|
||||
clans.remove(tag);
|
||||
@@ -211,8 +192,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Whether the tag belongs to a clan
|
||||
*
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
public boolean isClan(String tag) {
|
||||
return clans.containsKey(Helper.cleanTag(tag));
|
||||
@@ -221,8 +200,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Returns the clan the tag belongs to
|
||||
*
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
public Clan getClan(String tag) {
|
||||
return clans.get(Helper.cleanTag(tag));
|
||||
@@ -237,7 +214,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Get a player's clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return null if not in a clan
|
||||
*/
|
||||
@Nullable
|
||||
@@ -261,7 +237,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Returns the collection of all clan players, including the disabled ones
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<ClanPlayer> getAllClanPlayers() {
|
||||
return new ArrayList<>(clanPlayers.values());
|
||||
@@ -271,10 +246,8 @@ public final class ClanManager {
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan Used for BungeeCord Reload ClanPlayer and your Clan
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getClanPlayerJoinEvent(Player player) {
|
||||
public @Nullable ClanPlayer getClanPlayerJoinEvent(Player player) {
|
||||
SimpleClans.getInstance().getStorageManager().importFromDatabaseOnePlayer(player);
|
||||
return getClanPlayer(player.getUniqueId());
|
||||
}
|
||||
@@ -283,10 +256,8 @@ public final class ClanManager {
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getClanPlayer(OfflinePlayer player) {
|
||||
public @Nullable ClanPlayer getClanPlayer(OfflinePlayer player) {
|
||||
return getClanPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
@@ -294,10 +265,8 @@ public final class ClanManager {
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getClanPlayer(Player player) {
|
||||
public @Nullable ClanPlayer getClanPlayer(Player player) {
|
||||
return getClanPlayer((OfflinePlayer) player);
|
||||
}
|
||||
|
||||
@@ -305,10 +274,8 @@ public final class ClanManager {
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getClanPlayer(UUID playerUniqueId) {
|
||||
public @Nullable ClanPlayer getClanPlayer(UUID playerUniqueId) {
|
||||
ClanPlayer cp = clanPlayers.get(playerUniqueId.toString());
|
||||
|
||||
if (cp == null) {
|
||||
@@ -332,10 +299,8 @@ public final class ClanManager {
|
||||
* Gets the ClanPlayer data object if a player is currently in a clan, null
|
||||
* if he's not in a clan
|
||||
*
|
||||
* @param playerDisplayName
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getClanPlayerName(String playerDisplayName) {
|
||||
public @Nullable ClanPlayer getClanPlayerName(String playerDisplayName) {
|
||||
UUID uuid = UUIDMigration.getForcedPlayerUUID(playerDisplayName);
|
||||
|
||||
if (uuid == null) {
|
||||
@@ -361,8 +326,6 @@ public final class ClanManager {
|
||||
* not currently in one, their data file persists and can be accessed. their
|
||||
* clan will be null though.
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public ClanPlayer getAnyClanPlayer(UUID playerUniqueId) {
|
||||
@@ -377,10 +340,8 @@ public final class ClanManager {
|
||||
/**
|
||||
* Gets the ClanPlayer object for the player, creates one if not found
|
||||
*
|
||||
* @param playerDisplayName
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getCreateClanPlayerUUID(String playerDisplayName) {
|
||||
public @Nullable ClanPlayer getCreateClanPlayerUUID(String playerDisplayName) {
|
||||
UUID playerUniqueId = UUIDMigration.getForcedPlayerUUID(playerDisplayName);
|
||||
if (playerUniqueId != null) {
|
||||
return getCreateClanPlayer(playerUniqueId);
|
||||
@@ -392,8 +353,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Gets the ClanPlayer object for the player, creates one if not found
|
||||
*
|
||||
* @param playerUniqueId
|
||||
* @return
|
||||
*/
|
||||
public ClanPlayer getCreateClanPlayer(UUID playerUniqueId) {
|
||||
if (clanPlayers.containsKey(playerUniqueId.toString())) {
|
||||
@@ -435,9 +394,8 @@ public final class ClanManager {
|
||||
/**
|
||||
* Update the players display name with his clan's tag
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void updateDisplayName(Player player) {
|
||||
public void updateDisplayName(@Nullable Player player) {
|
||||
// do not update displayname if in compat mode
|
||||
|
||||
if (plugin.getSettingsManager().isCompatMode()) {
|
||||
@@ -477,7 +435,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Process a player and his clan's last seen date
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void updateLastSeen(Player player) {
|
||||
ClanPlayer cp = getAnyClanPlayer(player.getUniqueId());
|
||||
@@ -533,7 +490,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Get a count of rivable clans
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getRivableClanCount() {
|
||||
int clanCount = 0;
|
||||
@@ -550,8 +506,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Returns a formatted string detailing the players armor
|
||||
*
|
||||
* @param inv
|
||||
* @return
|
||||
*/
|
||||
public String getArmorString(PlayerInventory inv) {
|
||||
String out = "";
|
||||
@@ -649,8 +603,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Returns a formatted string detailing the players weapons
|
||||
*
|
||||
* @param inv
|
||||
* @return
|
||||
*/
|
||||
public String getWeaponString(PlayerInventory inv) {
|
||||
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
|
||||
@@ -811,56 +763,50 @@ public final class ClanManager {
|
||||
/**
|
||||
* Returns a formatted string detailing the players health
|
||||
*
|
||||
* @param health
|
||||
* @return
|
||||
*/
|
||||
public String getHealthString(double health) {
|
||||
String out = "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
if (health >= 16) {
|
||||
out += ChatColor.GREEN;
|
||||
out.append(ChatColor.GREEN);
|
||||
} else if (health >= 8) {
|
||||
out += ChatColor.GOLD;
|
||||
out.append(ChatColor.GOLD);
|
||||
} else {
|
||||
out += ChatColor.RED;
|
||||
out.append(ChatColor.RED);
|
||||
}
|
||||
|
||||
for (int i = 0; i < health; i++) {
|
||||
out += '|';
|
||||
out.append('|');
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted string detailing the players hunger
|
||||
*
|
||||
* @param health
|
||||
* @return
|
||||
*/
|
||||
public String getHungerString(int health) {
|
||||
String out = "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
if (health >= 16) {
|
||||
out += ChatColor.GREEN;
|
||||
out.append(ChatColor.GREEN);
|
||||
} else if (health >= 8) {
|
||||
out += ChatColor.GOLD;
|
||||
out.append(ChatColor.GOLD);
|
||||
} else {
|
||||
out += ChatColor.RED;
|
||||
out.append(ChatColor.RED);
|
||||
}
|
||||
|
||||
for (int i = 0; i < health; i++) {
|
||||
out += '|';
|
||||
out.append('|');
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by active
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*
|
||||
*/
|
||||
public void sortClansByActive(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
@@ -869,15 +815,13 @@ public final class ClanManager {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Long) c1.getLastUsed()).compareTo(c2.getLastUsed()) * o;
|
||||
return Long.compare(c1.getLastUsed(), c2.getLastUsed()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by founded date
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*
|
||||
*/
|
||||
public void sortClansByFounded(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
@@ -886,15 +830,13 @@ public final class ClanManager {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Long) c1.getFounded()).compareTo(c2.getFounded()) * o;
|
||||
return Long.compare(c1.getFounded(), c2.getFounded()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by kdr
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*
|
||||
*/
|
||||
public void sortClansByKDR(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
@@ -903,15 +845,13 @@ public final class ClanManager {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Float) c1.getTotalKDR()).compareTo(c2.getTotalKDR()) * o;
|
||||
return Float.compare(c1.getTotalKDR(), c2.getTotalKDR()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by size
|
||||
*
|
||||
* @param clans
|
||||
* @param asc
|
||||
*
|
||||
*/
|
||||
public void sortClansBySize(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
@@ -920,14 +860,13 @@ public final class ClanManager {
|
||||
o = -1;
|
||||
}
|
||||
|
||||
return ((Integer) c1.getSize()).compareTo(c2.getSize()) * o;
|
||||
return Integer.compare(c1.getSize(), c2.getSize()) * o;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by name
|
||||
*
|
||||
* @param clans
|
||||
*/
|
||||
public void sortClansByName(List<Clan> clans, boolean asc) {
|
||||
clans.sort((c1, c2) -> {
|
||||
@@ -943,74 +882,52 @@ public final class ClanManager {
|
||||
/**
|
||||
* Sort clans by KDR
|
||||
*
|
||||
* @param clans
|
||||
* @return
|
||||
*/
|
||||
public void sortClansByKDR(List<Clan> clans) {
|
||||
Collections.sort(clans, new Comparator<Clan>() {
|
||||
clans.sort((c1, c2) -> {
|
||||
Float o1 = c1.getTotalKDR();
|
||||
Float o2 = c2.getTotalKDR();
|
||||
|
||||
@Override
|
||||
public int compare(Clan c1, Clan c2) {
|
||||
Float o1 = c1.getTotalKDR();
|
||||
Float o2 = c2.getTotalKDR();
|
||||
|
||||
return o2.compareTo(o1);
|
||||
}
|
||||
return o2.compareTo(o1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clans by KDR
|
||||
*
|
||||
* @param clans
|
||||
*/
|
||||
public void sortClansBySize(List<Clan> clans) {
|
||||
Collections.sort(clans, new Comparator<Clan>() {
|
||||
clans.sort((c1, c2) -> {
|
||||
Integer o1 = c1.getAllMembers().size();
|
||||
Integer o2 = c2.getAllMembers().size();
|
||||
|
||||
@Override
|
||||
public int compare(Clan c1, Clan c2) {
|
||||
Integer o1 = c1.getAllMembers().size();
|
||||
Integer o2 = c2.getAllMembers().size();
|
||||
|
||||
return o2.compareTo(o1);
|
||||
}
|
||||
return o2.compareTo(o1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clan players by KDR
|
||||
*
|
||||
* @param cps
|
||||
* @return
|
||||
*/
|
||||
public void sortClanPlayersByKDR(List<ClanPlayer> cps) {
|
||||
Collections.sort(cps, new Comparator<ClanPlayer>() {
|
||||
cps.sort((c1, c2) -> {
|
||||
Float o1 = c1.getKDR();
|
||||
Float o2 = c2.getKDR();
|
||||
|
||||
@Override
|
||||
public int compare(ClanPlayer c1, ClanPlayer c2) {
|
||||
Float o1 = c1.getKDR();
|
||||
Float o2 = c2.getKDR();
|
||||
|
||||
return o2.compareTo(o1);
|
||||
}
|
||||
return o2.compareTo(o1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort clan players by last seen days
|
||||
*
|
||||
* @param cps
|
||||
*/
|
||||
public void sortClanPlayersByLastSeen(List<ClanPlayer> cps) {
|
||||
Collections.sort(cps, new Comparator<ClanPlayer>() {
|
||||
cps.sort((c1, c2) -> {
|
||||
Double o1 = c1.getLastSeenDays();
|
||||
Double o2 = c2.getLastSeenDays();
|
||||
|
||||
@Override
|
||||
public int compare(ClanPlayer c1, ClanPlayer c2) {
|
||||
Double o1 = c1.getLastSeenDays();
|
||||
Double o2 = c2.getLastSeenDays();
|
||||
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
return o1.compareTo(o2);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1032,8 +949,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase member fee set
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseMemberFeeSet(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseMemberFeeSet()) {
|
||||
@@ -1058,8 +973,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase clan creation
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseCreation(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseCreation()) {
|
||||
@@ -1084,8 +997,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase invite
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseInvite(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseInvite()) {
|
||||
@@ -1110,8 +1021,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase Home Teleport
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseHomeTeleport(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseHomeTeleport()) {
|
||||
@@ -1136,8 +1045,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase Home Teleport Set
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseHomeTeleportSet(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseHomeTeleportSet()) {
|
||||
@@ -1162,8 +1069,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase Reset Kdr
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseResetKdr(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseResetKdr()) {
|
||||
@@ -1188,8 +1093,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase Home Regroup
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseHomeRegroup(Player player) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
@@ -1229,8 +1132,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Purchase clan verification
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean purchaseVerification(Player player) {
|
||||
if (!plugin.getSettingsManager().isePurchaseVerification()) {
|
||||
@@ -1255,9 +1156,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Processes a clan chat command
|
||||
*
|
||||
* @param player
|
||||
* @param tag
|
||||
* @param msg
|
||||
*/
|
||||
public void processClanChat(Player player, String tag, String msg) {
|
||||
Clan clan = plugin.getClanManager().getClan(tag);
|
||||
@@ -1272,8 +1170,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Processes a clan chat command
|
||||
*
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void processClanChat(Player player, final String msg) {
|
||||
final ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
@@ -1367,8 +1263,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Processes a ally chat command
|
||||
*
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void processAllyChat(Player player, final String msg) {
|
||||
final ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
@@ -1442,9 +1336,6 @@ public final class ClanManager {
|
||||
/**
|
||||
* Processes a global chat command
|
||||
*
|
||||
* @param player
|
||||
* @param msg
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean processGlobalChat(Player player, String msg) {
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
file = new File(SimpleClans.getInstance().getDataFolder() + File.separator + "language.yml");
|
||||
check();
|
||||
}
|
||||
|
||||
private void check() {
|
||||
boolean exists = (file).exists();
|
||||
|
||||
loadDefaults();
|
||||
|
||||
if (exists) {
|
||||
loadFile();
|
||||
}
|
||||
|
||||
saveFile();
|
||||
}
|
||||
|
||||
private void loadDefaults() {
|
||||
try {
|
||||
InputStream defaultLanguage = getClass().getResourceAsStream("/language.yml");
|
||||
language = (HashMap<String, String>) new Yaml().load(defaultLanguage);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFile() {
|
||||
try {
|
||||
InputStream fileLanguage = new FileInputStream(file);
|
||||
language = (HashMap<String, String>) new Yaml().load(fileLanguage);
|
||||
} catch (FileNotFoundException e) {
|
||||
// file not found
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile() {
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
options.setWidth(99999999);
|
||||
options.setAllowUnicode(true);
|
||||
|
||||
try {
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
|
||||
|
||||
try {
|
||||
new Yaml(options).dump(language, out);
|
||||
|
||||
for (String comment : comments) {
|
||||
out.write(comment);
|
||||
}
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// could not save
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
Object o = language.get(key);
|
||||
|
||||
if (o != null) {
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
return "Missing language for "+key;
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,7 @@ 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 net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
@@ -62,7 +57,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Whether economy plugin exists and is enabled
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasEconomy() {
|
||||
return economy != null && economy.isEnabled();
|
||||
@@ -95,7 +89,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Adds all permissions for a clan
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
public void updateClanPermissions(Clan clan) {
|
||||
for (ClanPlayer cp : clan.getMembers()) {
|
||||
@@ -106,7 +99,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Adds permissions for a player
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void addPlayerPermissions(@Nullable ClanPlayer cp) {
|
||||
if (cp == null) {
|
||||
@@ -137,7 +129,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Removes permissions for a clan (when it gets disbanded for example)
|
||||
*
|
||||
* @param clan
|
||||
*/
|
||||
public void removeClanPermissions(Clan clan) {
|
||||
for (ClanPlayer cp : clan.getMembers()) {
|
||||
@@ -148,12 +139,11 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Removes permissions for a player (when he gets kicked for example)
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void removeClanPlayerPermissions(ClanPlayer cp) {
|
||||
if (cp != null && cp.getClan() != null && cp.toPlayer() != null) {
|
||||
Player player = cp.toPlayer();
|
||||
if (player.isOnline() && permissions.containsKey(cp.getClan().getTag()) && permAttaches.containsKey(player)) {
|
||||
if (player != null && permissions.containsKey(cp.getClan().getTag()) && permAttaches.containsKey(player)) {
|
||||
permAttaches.get(player).remove();
|
||||
permAttaches.remove(player);
|
||||
}
|
||||
@@ -161,7 +151,6 @@ public final class PermissionsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clan
|
||||
* @return the permissions for a clan
|
||||
*/
|
||||
public List<String> getPermissions(Clan clan) {
|
||||
@@ -178,9 +167,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Charge a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean playerChargeMoney(String player, double money) {
|
||||
@@ -190,9 +176,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Charge a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
public boolean playerChargeMoney(OfflinePlayer player, double money) {
|
||||
return economy.withdrawPlayer(player, money).transactionSuccess();
|
||||
@@ -201,9 +184,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Charge a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
public boolean playerChargeMoney(Player player, double money) {
|
||||
return playerChargeMoney((OfflinePlayer) player, money);
|
||||
@@ -212,9 +192,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Grants a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
public boolean playerGrantMoney(Player player, double money) {
|
||||
return economy.depositPlayer(player, money).transactionSuccess();
|
||||
@@ -223,9 +200,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Grants a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean playerGrantMoney(String player, double money) {
|
||||
@@ -235,9 +209,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Grants a player some money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return
|
||||
*/
|
||||
public boolean playerGrantMoney(OfflinePlayer player, double money) {
|
||||
return economy.depositPlayer(player, money).transactionSuccess();
|
||||
@@ -246,8 +217,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Check if a user has the money
|
||||
*
|
||||
* @param player
|
||||
* @param money
|
||||
* @return whether he has the money
|
||||
*/
|
||||
public boolean playerHasMoney(Player player, double money) {
|
||||
@@ -257,7 +226,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Returns the players money
|
||||
*
|
||||
* @param player
|
||||
* @return the players money
|
||||
*/
|
||||
public double playerGetMoney(Player player) {
|
||||
@@ -272,7 +240,7 @@ public final class PermissionsManager {
|
||||
* @param perm the permission
|
||||
* @return whether he has the permission
|
||||
*/
|
||||
public boolean has(String world, OfflinePlayer player, String perm) {
|
||||
public boolean has(@Nullable String world, OfflinePlayer player, String perm) {
|
||||
if (player != null && permission != null) {
|
||||
return permission.playerHas(world, player, perm);
|
||||
}
|
||||
@@ -289,14 +257,18 @@ public final class PermissionsManager {
|
||||
*/
|
||||
public boolean has(Player player, String perm) {
|
||||
if (player == null) {
|
||||
SimpleClans.debug("null player");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasPermission;
|
||||
if (permission != null) {
|
||||
return permission.has(player, perm);
|
||||
hasPermission = permission.has(player, perm);
|
||||
} else {
|
||||
return player.hasPermission(perm);
|
||||
hasPermission = player.hasPermission(perm);
|
||||
}
|
||||
SimpleClans.debug(String.format("Permission %s is %s for %s", perm, hasPermission, player.getName()));
|
||||
return hasPermission;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,7 +277,6 @@ public final class PermissionsManager {
|
||||
* @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) {
|
||||
@@ -338,8 +309,10 @@ public final class PermissionsManager {
|
||||
boolean hasRankPermission = false;
|
||||
String rankName = clanPlayer.getRankId();
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan.hasRank(rankName)) {
|
||||
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
|
||||
//noinspection ConstantConditions
|
||||
if (clan.hasRank(rankName)) {
|
||||
//noinspection ConstantConditions
|
||||
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
|
||||
} else {
|
||||
if (rankName != null && !rankName.isEmpty()) {
|
||||
clanPlayer.setRank(null);
|
||||
@@ -360,7 +333,6 @@ public final class PermissionsManager {
|
||||
* @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) {
|
||||
@@ -396,8 +368,11 @@ public final class PermissionsManager {
|
||||
boolean hasRankPermission = false;
|
||||
String rankName = clanPlayer.getRankId();
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan.hasRank(rankName)) {
|
||||
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
|
||||
if (clan != null) {
|
||||
Rank rank = clan.getRank(rankName);
|
||||
if (rank != null) {
|
||||
hasRankPermission = rank.getPermissions().contains(permission.toString());
|
||||
}
|
||||
} else {
|
||||
if (rankName != null && !rankName.isEmpty()) {
|
||||
clanPlayer.setRank(null);
|
||||
@@ -415,7 +390,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Gives the player permissions linked to a clan
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void addClanPermissions(ClanPlayer cp) {
|
||||
if (!plugin.getSettingsManager().isEnableAutoGroups()) {
|
||||
@@ -450,13 +424,11 @@ public final class PermissionsManager {
|
||||
if (!permission.playerInGroup(cp.toPlayer(), "sc_untrusted")) {
|
||||
permission.playerAddGroup(cp.toPlayer(), "sc_untrusted");
|
||||
}
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_trusted");
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_leader");
|
||||
} else {
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_untrusted");
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_trusted");
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_leader");
|
||||
}
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_trusted");
|
||||
permission.playerRemoveGroup(cp.toPlayer(), "sc_leader");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -464,7 +436,6 @@ public final class PermissionsManager {
|
||||
/**
|
||||
* Removes permissions linked to a clan from the player
|
||||
*
|
||||
* @param cp
|
||||
*/
|
||||
public void removeClanPermissions(ClanPlayer cp) {
|
||||
if (!plugin.getSettingsManager().isEnableAutoGroups()) {
|
||||
@@ -479,35 +450,30 @@ public final class PermissionsManager {
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean setupPermissions() {
|
||||
private void setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permission = permissionProvider.getProvider();
|
||||
}
|
||||
return permission != null;
|
||||
}
|
||||
|
||||
private Boolean setupChat() {
|
||||
private void setupChat() {
|
||||
RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||
if (chatProvider != null) {
|
||||
chat = chatProvider.getProvider();
|
||||
}
|
||||
|
||||
return chat != null;
|
||||
}
|
||||
|
||||
private Boolean setupEconomy() {
|
||||
private void setupEconomy() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
public String getPrefix(Player p) {
|
||||
String out = "";
|
||||
@@ -552,8 +518,6 @@ public final class PermissionsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
public String getSuffix(Player p) {
|
||||
try {
|
||||
|
||||
@@ -1,442 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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 extends PlaceholderExpansion {
|
||||
|
||||
/**
|
||||
* The {@link Pattern} that identifies the top {@link Clan}s placeholder
|
||||
*
|
||||
* @since 1.12.3
|
||||
*/
|
||||
private static final Pattern TOP_CLANS_PATTERN = Pattern.compile("^topclans_\\d+_clan_");
|
||||
|
||||
/**
|
||||
* The {@link List} containing all the placeholders of the {@link SimpleClans} {@link Plugin}
|
||||
*
|
||||
* @since 1.12.3
|
||||
*/
|
||||
private static final List<String> PLACEHOLDERS_LIST = new ArrayList<>();
|
||||
|
||||
static {
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_neutral_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_rival_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_civilian_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_total_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_weighted_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_deaths%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_kdr%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_in_clan%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_leader%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_trusted%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_member%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_bb_enabled%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_usechatshortcut%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_allychat%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_clanchat%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_globalchat%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_cape_enabled%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_tag_enabled%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_friendlyfire_on%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_muted%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_is_mutedally%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_join_date%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_inactive_days%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_lastseen%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_lastseendays%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_tag%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_tag_label%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_rank%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_rank_displayname%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clanchat_player_color%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_allychat_player_color%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_neutral%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_civilian%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_rival%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_deaths%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_kdr%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_average_wk%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_leader_size%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_balance%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_allow_withdraw%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_allow_deposit%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_size%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_name%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_color_tag%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_tag%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_founded%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_friendly_fire%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_is_unrivable%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_is_anyonline%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_is_verified%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_capeurl%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_inactivedays%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_onlinemembers_count%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_allies_count%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_rivals_count%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_clan_topclans_position%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_neutral%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_civilian%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_rival%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_kills%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_deaths%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_kdr%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_average_wk%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_leader_size%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_balance%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_allow_withdraw%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_allow_deposit%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_size%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_name%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_color_tag%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_tag%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_founded%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_friendly_fire%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_is_unrivable%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_is_anyonline%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_is_verified%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_capeurl%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_inactivedays%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_onlinemembers_count%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_allies_count%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_rivals_count%");
|
||||
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_topclans_position%");
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link SimpleClans} {@link Plugin} instance
|
||||
*
|
||||
* @since 2.10.1
|
||||
*/
|
||||
private final SimpleClans simpleClans;
|
||||
|
||||
/**
|
||||
* The {@link PlaceholdersManager} constructor
|
||||
*
|
||||
* @param simpleClans The {@link SimpleClans} {@link Plugin}
|
||||
*
|
||||
* @since 2.10.1
|
||||
*/
|
||||
public PlaceholdersManager(@NotNull SimpleClans simpleClans) {
|
||||
this.simpleClans = simpleClans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, @NotNull String identifier) {
|
||||
Clan clan = null;
|
||||
|
||||
if (TOP_CLANS_PATTERN.matcher(identifier).find()) {
|
||||
// getting the position
|
||||
int position = Integer.parseInt(identifier.substring(9, identifier.indexOf('_', 9)));
|
||||
|
||||
List<Clan> clans = simpleClans.getClanManager().getClans();
|
||||
|
||||
// validating position
|
||||
if (position < 1 || position > clans.size()) {
|
||||
return "";
|
||||
}
|
||||
simpleClans.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
clan = clans.get(position - 1);
|
||||
identifier = identifier.substring(identifier.indexOf('_', 9) + 1);
|
||||
}
|
||||
if (clan == null) {
|
||||
if (player == null) {
|
||||
return "";
|
||||
}
|
||||
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 simpleClans.getSettingsManager().getClanChatLeaderColor();
|
||||
}
|
||||
if (player.isTrusted()) {
|
||||
return simpleClans.getSettingsManager().getClanChatTrustedColor();
|
||||
}
|
||||
if (clan != null) {
|
||||
return simpleClans.getSettingsManager().getClanChatMemberColor();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
case "allychat_player_color": {
|
||||
if (player.isLeader()) {
|
||||
return simpleClans.getSettingsManager().getAllyChatLeaderColor();
|
||||
}
|
||||
if (player.isTrusted()) {
|
||||
return simpleClans.getSettingsManager().getAllyChatTrustedColor();
|
||||
}
|
||||
if (clan != null) {
|
||||
return simpleClans.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(VanishUtils.getNonVanished(player == null ? null : player.toPlayer(),
|
||||
clan).size());
|
||||
}
|
||||
case "clan_allies_count": {
|
||||
return String.valueOf(clan.getAllies().size());
|
||||
}
|
||||
case "clan_rivals_count": {
|
||||
return String.valueOf(clan.getRivals().size());
|
||||
}
|
||||
case "clan_topclans_position": {
|
||||
List<Clan> clans = simpleClans.getClanManager().getClans();
|
||||
simpleClans.getClanManager().sortClansByKDR(clans);
|
||||
|
||||
return String.valueOf(clans.indexOf(clan) + 1);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return getName().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
List<String> authors = new ArrayList<>(simpleClans.getDescription().getAuthors());
|
||||
authors.add("Peng1104");
|
||||
return authors.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return simpleClans.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String params) {
|
||||
ClanPlayer clanPlayer = null;
|
||||
if (player != null) {
|
||||
clanPlayer = simpleClans.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
}
|
||||
return getPlaceholderValue(clanPlayer, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return simpleClans.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> getPlaceholders() {
|
||||
return PLACEHOLDERS_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRegister() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.sacredlabyrinth.phaed.simpleclans.managers;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.RequestEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.RequestFinishedEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -406,42 +407,24 @@ public final class RequestManager {
|
||||
* @param req the Request
|
||||
*/
|
||||
public void ask(final Request req) {
|
||||
final String tag = plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketLeft() + plugin.getSettingsManager().getTagDefaultColor() + req.getClan().getColorTag() + plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketRight();
|
||||
final String message = tag + " " + plugin.getSettingsManager().getRequestMessageColor() + req.getMsg();
|
||||
|
||||
if (req.getType().equals(ClanRequest.INVITE)) {
|
||||
Player player = Bukkit.getPlayerExact(req.getTarget());
|
||||
|
||||
if (player != null) {
|
||||
String options = lang("accept.or.deny", player, ChatBlock.makeEmpty(Helper.stripColors(tag)) + " " + ChatColor.DARK_GREEN + "/" + plugin.getSettingsManager().getCommandAccept() + plugin.getSettingsManager().getPageHeadingsColor(), ChatColor.DARK_RED + "/" + plugin.getSettingsManager().getCommandDeny());
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, message);
|
||||
ChatBlock.sendMessage(player, options);
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
String message = lang("request.message", req.getClan().getColorTag(), req.getMsg());
|
||||
ArrayList<Player> recipients = new ArrayList<>();
|
||||
if (req.getType() == ClanRequest.INVITE) {
|
||||
recipients.add(Bukkit.getPlayerExact(req.getTarget()));
|
||||
} else {
|
||||
for (ClanPlayer cp : req.getAcceptors()) {
|
||||
if (cp.getVote() == null) {
|
||||
Player player = cp.toPlayer();
|
||||
|
||||
if (player != null) {
|
||||
String options = lang("accept.or.deny", player, ChatBlock.makeEmpty(Helper.stripColors(tag)) + " " + ChatColor.DARK_GREEN + "/" + plugin.getSettingsManager().getCommandAccept() + plugin.getSettingsManager().getPageHeadingsColor(), ChatColor.DARK_RED + "/" + plugin.getSettingsManager().getCommandDeny());
|
||||
|
||||
ChatBlock.sendBlank(player);
|
||||
ChatBlock.sendMessage(player, message);
|
||||
ChatBlock.sendMessage(player, options);
|
||||
ChatBlock.sendBlank(player);
|
||||
}
|
||||
recipients.add(cp.toPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new RequestEvent(req));
|
||||
for (Player recipient : recipients) {
|
||||
if (recipient != null) {
|
||||
recipient.spigot().sendMessage(ChatUtils.toBaseComponents(recipient, message));
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(new RequestEvent(req)));
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -177,7 +178,7 @@ public final class SettingsManager {
|
||||
private boolean moneyperkill;
|
||||
private double KDRMultipliesPerKill;
|
||||
private boolean teleportBlocks;
|
||||
private boolean AutoGroupGroupName;
|
||||
private boolean autoGroupGroupName;
|
||||
private boolean tamableMobsSharing;
|
||||
private boolean allowReGroupCommand;
|
||||
private boolean useThreads;
|
||||
@@ -205,6 +206,7 @@ public final class SettingsManager {
|
||||
config = plugin.getConfig();
|
||||
main = new File(plugin.getDataFolder() + File.separator + "config.yml");
|
||||
load();
|
||||
warnAboutAutoGroupGroupName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +393,7 @@ public final class SettingsManager {
|
||||
teleportBlocks = getConfig().getBoolean("settings.teleport-blocks");
|
||||
language = getConfig().getString("settings.language", "");
|
||||
languagePerPlayer = getConfig().getBoolean("settings.user-language-selector", true);
|
||||
AutoGroupGroupName = getConfig().getBoolean("permissions.auto-group-groupname");
|
||||
autoGroupGroupName = getConfig().getBoolean("permissions.auto-group-groupname");
|
||||
tamableMobsSharing = getConfig().getBoolean("settings.tameable-mobs-sharing");
|
||||
allowReGroupCommand = getConfig().getBoolean("settings.allow-regroup-command");
|
||||
loreLength = getConfig().getInt("settings.lore-length", 38);
|
||||
@@ -425,6 +427,15 @@ public final class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void warnAboutAutoGroupGroupName() {
|
||||
Plugin luckPerms = Bukkit.getServer().getPluginManager().getPlugin("LuckPerms");
|
||||
if (luckPerms != null && autoGroupGroupName) {
|
||||
plugin.getLogger().warning("LuckPerms was found and the setting auto-group-groupname is enabled.");
|
||||
plugin.getLogger().warning("Be careful with that as players will be automatically added in the group" +
|
||||
" that matches their clan tag.");
|
||||
}
|
||||
}
|
||||
|
||||
public int getLoreLength() {
|
||||
return loreLength;
|
||||
}
|
||||
@@ -1681,7 +1692,7 @@ public final class SettingsManager {
|
||||
* @return the AutoGroupGroupName
|
||||
*/
|
||||
public boolean isAutoGroupGroupName() {
|
||||
return AutoGroupGroupName;
|
||||
return autoGroupGroupName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.storage.DBCore;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.storage.MySQLCore;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.storage.SQLiteCore;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.YAMLSerializer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDFetcher;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
|
||||
@@ -17,6 +18,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -86,20 +88,20 @@ public final class StorageManager {
|
||||
plugin.getLogger().info("Creating table: sc_clans");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ("
|
||||
+ " `id` bigint(20) NOT NULL auto_increment,"
|
||||
+ " `verified` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `color_tag` varchar(25) NOT NULL,"
|
||||
+ " `name` varchar(100) NOT NULL,"
|
||||
+ " `description` varchar(255),"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `founded` bigint NOT NULL,"
|
||||
+ " `last_used` bigint NOT NULL,"
|
||||
+ " `packed_allies` text NOT NULL,"
|
||||
+ " `packed_rivals` text NOT NULL,"
|
||||
+ " `packed_bb` mediumtext NOT NULL,"
|
||||
+ " `cape_url` varchar(255) NOT NULL,"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `id` bigint(20) NOT NULL auto_increment,"
|
||||
+ " `verified` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `color_tag` varchar(255) NOT NULL,"
|
||||
+ " `name` varchar(100) NOT NULL,"
|
||||
+ " `description` varchar(255),"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `founded` bigint NOT NULL,"
|
||||
+ " `last_used` bigint NOT NULL,"
|
||||
+ " `packed_allies` text NOT NULL,"
|
||||
+ " `packed_rivals` text NOT NULL,"
|
||||
+ " `packed_bb` mediumtext NOT NULL,"
|
||||
+ " `cape_url` varchar(255) NOT NULL,"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `balance` double(64,2),"
|
||||
+ " `fee_enabled` tinyint(1) default '0',"
|
||||
+ " `fee_value` double(64,2),"
|
||||
@@ -162,20 +164,20 @@ public final class StorageManager {
|
||||
plugin.getLogger().info("Creating table: sc_clans");
|
||||
|
||||
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ("
|
||||
+ " `id` bigint(20),"
|
||||
+ " `verified` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `color_tag` varchar(25) NOT NULL,"
|
||||
+ " `name` varchar(100) NOT NULL,"
|
||||
+ " `description` varchar(255),"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `founded` bigint NOT NULL,"
|
||||
+ " `last_used` bigint NOT NULL,"
|
||||
+ " `packed_allies` text NOT NULL,"
|
||||
+ " `packed_rivals` text NOT NULL,"
|
||||
+ " `packed_bb` mediumtext NOT NULL,"
|
||||
+ " `cape_url` varchar(255) NOT NULL,"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `id` bigint(20),"
|
||||
+ " `verified` tinyint(1) default '0',"
|
||||
+ " `tag` varchar(25) NOT NULL,"
|
||||
+ " `color_tag` varchar(255) NOT NULL,"
|
||||
+ " `name` varchar(100) NOT NULL,"
|
||||
+ " `description` varchar(255),"
|
||||
+ " `friendly_fire` tinyint(1) default '0',"
|
||||
+ " `founded` bigint NOT NULL,"
|
||||
+ " `last_used` bigint NOT NULL,"
|
||||
+ " `packed_allies` text NOT NULL,"
|
||||
+ " `packed_rivals` text NOT NULL,"
|
||||
+ " `packed_bb` mediumtext NOT NULL,"
|
||||
+ " `cape_url` varchar(255) NOT NULL,"
|
||||
+ " `flags` text NOT NULL,"
|
||||
+ " `balance` double(64,2) default 0.0,"
|
||||
+ " `fee_enabled` tinyint(1) default '0',"
|
||||
+ " `fee_value` double(64,2),"
|
||||
@@ -316,7 +318,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
for (Clan clan : purge) {
|
||||
plugin.getLogger().info(MessageFormat.format(lang("purging.clan"), clan.getName()));
|
||||
plugin.getLogger().info(lang("purging.clan", clan.getName()));
|
||||
deleteClan(clan);
|
||||
clans.remove(clan);
|
||||
}
|
||||
@@ -336,7 +338,7 @@ public final class StorageManager {
|
||||
}
|
||||
|
||||
for (ClanPlayer cp : purge) {
|
||||
plugin.getLogger().info(MessageFormat.format(lang("purging.player.data"), cp.getName()));
|
||||
plugin.getLogger().info(lang("purging.player.data", cp.getName()));
|
||||
deleteClanPlayer(cp);
|
||||
cps.remove(cp);
|
||||
}
|
||||
@@ -360,7 +362,7 @@ public final class StorageManager {
|
||||
boolean verified = res.getBoolean("verified");
|
||||
boolean friendly_fire = res.getBoolean("friendly_fire");
|
||||
String tag = res.getString("tag");
|
||||
String color_tag = Helper.parseColors(res.getString("color_tag"));
|
||||
String color_tag = ChatUtils.parseColors(res.getString("color_tag"));
|
||||
String name = res.getString("name");
|
||||
String description = res.getString("description");
|
||||
String packed_allies = res.getString("packed_allies");
|
||||
@@ -368,7 +370,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");
|
||||
JSONObject ranks = Helper.parseJson(res.getString("ranks"));
|
||||
long founded = res.getLong("founded");
|
||||
long last_used = res.getLong("last_used");
|
||||
double balance = res.getDouble("balance");
|
||||
@@ -402,6 +404,7 @@ public final class StorageManager {
|
||||
clan.setMemberFee(feeValue);
|
||||
clan.setMemberFeeEnabled(feeEnabled);
|
||||
clan.setRanks(Helper.ranksFromJson(ranks));
|
||||
clan.setDefaultRank(Helper.defaultRankFromJson(ranks));
|
||||
clan.setBanner(banner);
|
||||
|
||||
out.add(clan);
|
||||
@@ -440,7 +443,7 @@ public final class StorageManager {
|
||||
boolean verified = res.getBoolean("verified");
|
||||
boolean friendly_fire = res.getBoolean("friendly_fire");
|
||||
String tag = res.getString("tag");
|
||||
String color_tag = Helper.parseColors(res.getString("color_tag"));
|
||||
String color_tag = ChatUtils.parseColors(res.getString("color_tag"));
|
||||
String name = res.getString("name");
|
||||
String description = res.getString("description");
|
||||
String packed_allies = res.getString("packed_allies");
|
||||
@@ -448,7 +451,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");
|
||||
JSONObject ranks = Helper.parseJson(res.getString("ranks"));
|
||||
long founded = res.getLong("founded");
|
||||
long last_used = res.getLong("last_used");
|
||||
double balance = res.getDouble("balance");
|
||||
@@ -482,6 +485,7 @@ public final class StorageManager {
|
||||
clan.setMemberFee(feeValue);
|
||||
clan.setMemberFeeEnabled(feeEnabled);
|
||||
clan.setRanks(Helper.ranksFromJson(ranks));
|
||||
clan.setDefaultRank(Helper.defaultRankFromJson(ranks));
|
||||
clan.setBanner(banner);
|
||||
|
||||
out = clan;
|
||||
@@ -528,7 +532,7 @@ public final class StorageManager {
|
||||
long last_seen = res.getLong("last_seen");
|
||||
long join_date = res.getLong("join_date");
|
||||
String flags = res.getString("flags");
|
||||
String packed_past_clans = Helper.parseColors(res.getString("packed_past_clans"));
|
||||
String packed_past_clans = ChatUtils.parseColors(res.getString("packed_past_clans"));
|
||||
String resign_times = res.getString("resign_times");
|
||||
Locale locale = Helper.forLanguageTag(res.getString("locale"));
|
||||
|
||||
@@ -699,7 +703,7 @@ public final class StorageManager {
|
||||
"`packed_bb`, `cape_url`, `flags`, `balance`) ";
|
||||
String values = "VALUES ( '"
|
||||
+ Helper.escapeQuotes(YAMLSerializer.serialize(clan.getBanner())) + "','"
|
||||
+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks())) + "','"
|
||||
+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks(), clan.getDefaultRank())) + "','"
|
||||
+ Helper.escapeQuotes(clan.getDescription())+ "',"
|
||||
+ (clan.isMemberFeeEnabled() ? 1 : 0) +","
|
||||
+ Helper.escapeQuotes(String.valueOf(clan.getMemberFee())) + ","
|
||||
@@ -787,7 +791,7 @@ public final class StorageManager {
|
||||
|
||||
private String getUpdateClanQuery(Clan clan) {
|
||||
String query = "UPDATE `sc_clans`" +
|
||||
" SET ranks = '"+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks())) +"'," +
|
||||
" SET ranks = '"+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks(), clan.getDefaultRank())) +"'," +
|
||||
" banner = '" + Helper.escapeQuotes(YAMLSerializer.serialize(clan.getBanner())) + "'," +
|
||||
" description = '" + Helper.escapeQuotes(clan.getDescription())+ "'," +
|
||||
" fee_enabled = "+ (clan.isMemberFeeEnabled() ? 1 : 0) +"," +
|
||||
@@ -1062,15 +1066,15 @@ public final class StorageManager {
|
||||
private void updateDatabase() {
|
||||
String query = null;
|
||||
|
||||
/**
|
||||
/*
|
||||
* From 2.2.6.3 to 2.3
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "balance")) {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `balance` double(64,2);";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* From 2.7.16 to 2.7.17
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "fee_enabled")) {
|
||||
@@ -1081,24 +1085,24 @@ public final class StorageManager {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `fee_value` double(64,2);";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* From 2.7.21 to 2.7.22
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "description")) {
|
||||
query = "ALTER TABLE sc_clans ADD COLUMN `description` varchar(255);";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* From 2.7.22 to 2.7.23
|
||||
*/
|
||||
if (!core.existsColumn("sc_players", "resign_times")) {
|
||||
query = "ALTER TABLE sc_players ADD COLUMN `resign_times` text;";
|
||||
core.execute(query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* From 2.8.2 to 2.9
|
||||
*/
|
||||
if (!core.existsColumn("sc_clans", "ranks")) {
|
||||
@@ -1115,7 +1119,11 @@ public final class StorageManager {
|
||||
core.execute("ALTER TABLE sc_clans ADD COLUMN `banner` text;");
|
||||
}
|
||||
|
||||
/**
|
||||
if (plugin.getSettingsManager().isUseMysql()) {
|
||||
core.execute("ALTER TABLE sc_clans MODIFY color_tag VARCHAR(255);");
|
||||
}
|
||||
|
||||
/*
|
||||
* Bukkit 1.7.5+ UUID Migration
|
||||
*/
|
||||
if (!core.existsColumn("sc_kills", "attacker_uuid")) {
|
||||
|
||||
@@ -84,7 +84,7 @@ public final class TeleportManager {
|
||||
z = z + zz;
|
||||
|
||||
plugin.getTeleportManager().addPlayer(player, new Location(location.getWorld(), x + .5,
|
||||
location.getBlockY(), z + .5), clan.getName());
|
||||
location.getBlockY(), z + .5, location.getYaw(), location.getPitch()), clan.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,13 +2,13 @@ package net.sacredlabyrinth.phaed.simpleclans.ui;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.FrameOpenEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.WordWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.ChatPaginator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -69,6 +69,10 @@ public class InventoryDrawer {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated use {@link InventoryDrawer#open(SCFrame)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void update(@NotNull SCFrame frame) {
|
||||
open(frame);
|
||||
@@ -105,8 +109,11 @@ public class InventoryDrawer {
|
||||
if (oldLore != null) {
|
||||
ArrayList<String> newLore = new ArrayList<>();
|
||||
for (String line : oldLore) {
|
||||
String[] strings = ChatPaginator.wordWrap(line, plugin.getSettingsManager().getLoreLength());
|
||||
newLore.addAll(Arrays.asList(strings));
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
WordWrapper wrapper = new WordWrapper(line, plugin.getSettingsManager().getLoreLength());
|
||||
newLore.addAll(Arrays.asList(wrapper.wrap()));
|
||||
}
|
||||
itemMeta.setLore(newLore);
|
||||
c.setItemMeta(itemMeta);
|
||||
|
||||
@@ -3,9 +3,9 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
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.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
@@ -41,16 +41,14 @@ public class Components {
|
||||
boolean openDetails) {
|
||||
SimpleClans pl = SimpleClans.getInstance();
|
||||
|
||||
String status = cp.getClan() == null ? lang("free.agent",viewer)
|
||||
: (cp.isLeader() ? lang("leader",viewer)
|
||||
: (cp.isTrusted() ? lang("trusted",viewer) : lang("untrusted",viewer)));
|
||||
String status = getPlayerStatus(viewer, cp);
|
||||
SCComponent c = new SCComponentImpl(lang("gui.playerdetails.player.title",viewer, cp.getName()),
|
||||
Arrays.asList(
|
||||
cp.getClan() == null ? lang("gui.playerdetails.player.lore.noclan",viewer)
|
||||
: lang("gui.playerdetails.player.lore.clan",viewer, cp.getClan().getColorTag(),
|
||||
cp.getClan().getName()),
|
||||
lang("gui.playerdetails.player.lore.rank",viewer,
|
||||
Helper.parseColors(cp.getRankDisplayName())),
|
||||
ChatUtils.parseColors(cp.getRankDisplayName())),
|
||||
lang("gui.playerdetails.player.lore.status",viewer, status),
|
||||
lang("gui.playerdetails.player.lore.kdr",viewer,
|
||||
new DecimalFormat("#.#").format(cp.getKDR())),
|
||||
@@ -78,6 +76,23 @@ public class Components {
|
||||
return c;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getPlayerStatus(Player viewer, ClanPlayer cp) {
|
||||
if (cp.getClan() == null) {
|
||||
return lang("free.agent", viewer);
|
||||
}
|
||||
if (cp.isLeader()) {
|
||||
return lang("leader", viewer);
|
||||
}
|
||||
if (cp.isTrusted()) {
|
||||
return lang("trusted", viewer);
|
||||
}
|
||||
if (cp.getRankId() != null && !cp.getRankId().isEmpty()) {
|
||||
return lang("in.rank", viewer);
|
||||
}
|
||||
return lang("untrusted", viewer);
|
||||
}
|
||||
|
||||
public static SCComponent getClanComponent(@NotNull SCFrame frame, @NotNull Player viewer,
|
||||
@Nullable Clan clan, int slot, boolean openDetails) {
|
||||
SimpleClans pl = SimpleClans.getInstance();
|
||||
@@ -167,6 +182,7 @@ public class Components {
|
||||
return c;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setOwningPlayer(@NotNull ItemStack item, @NotNull OfflinePlayer player) {
|
||||
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
|
||||
if (itemMeta == null) {
|
||||
|
||||
@@ -24,12 +24,15 @@ public class LanguageSelectorFrame extends SCFrame {
|
||||
|
||||
private final ClanPlayer clanPlayer;
|
||||
private final SimpleClans plugin;
|
||||
private Paginator paginator;
|
||||
private final Paginator paginator;
|
||||
private final List<Locale> languages;
|
||||
|
||||
public LanguageSelectorFrame(@Nullable SCFrame parent, @NotNull Player viewer) {
|
||||
super(parent, viewer);
|
||||
plugin = SimpleClans.getInstance();
|
||||
clanPlayer = plugin.getClanManager().getCreateClanPlayer(viewer.getUniqueId());
|
||||
languages = LanguageResource.getAvailableLocales();
|
||||
paginator = new Paginator(getSize() - 9, languages.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +47,6 @@ public class LanguageSelectorFrame extends SCFrame {
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
List<Locale> languages = LanguageResource.getAvailableLocales();
|
||||
paginator = new Paginator(getSize() - 9, languages.size());
|
||||
addHeader();
|
||||
int slot = 9;
|
||||
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
|
||||
|
||||
@@ -14,17 +14,18 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class PermissionsFrame extends SCFrame {
|
||||
private final Rank rank;
|
||||
private Paginator paginator;
|
||||
private final Paginator paginator;
|
||||
private final String[] permissions;
|
||||
|
||||
public PermissionsFrame(SCFrame parent, Player viewer, Rank rank) {
|
||||
super(parent, viewer);
|
||||
this.rank = rank;
|
||||
permissions = rank.getPermissions().toArray(new String[0]);
|
||||
paginator = new Paginator(getSize() - 9, permissions.length);
|
||||
}
|
||||
|
||||
@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)
|
||||
@@ -71,7 +72,7 @@ public class PermissionsFrame extends SCFrame {
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
InventoryDrawer.open(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
@@ -18,17 +19,19 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private final OfflinePlayer subject;
|
||||
private final String subjectName;
|
||||
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();
|
||||
ClanPlayer cp = plugin.getClanManager().getCreateClanPlayer(subject.getUniqueId());
|
||||
subjectName = cp.getName();
|
||||
clan = cp.getClan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createComponents() {
|
||||
String subjectName = subject.getName();
|
||||
for (int slot = 0; slot < 9; slot++) {
|
||||
if (slot == 4)
|
||||
continue;
|
||||
@@ -41,14 +44,23 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
if (!isSameClan()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
addKick();
|
||||
addPromoteDemote();
|
||||
addAssignUnassign();
|
||||
addTrustUntrust();
|
||||
}
|
||||
|
||||
private void addKick() {
|
||||
SCComponent kick = new SCComponentImpl(lang("gui.playerdetails.kick.title",getViewer()), null, XMaterial.RED_WOOL,
|
||||
28);
|
||||
kick.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "kick", true, subjectName));
|
||||
kick.setConfirmationRequired(ClickType.LEFT);
|
||||
kick.setPermission(ClickType.LEFT, RankPermission.KICK);
|
||||
add(kick);
|
||||
}
|
||||
|
||||
private void addPromoteDemote() {
|
||||
SCComponent promoteDemote = new SCComponentImpl(lang("gui.playerdetails.promote.demote.title",getViewer()),
|
||||
Arrays.asList(lang("gui.playerdetails.promote.lore.left.click",getViewer()),
|
||||
lang("gui.playerdetails.demote.lore.right.click",getViewer())),
|
||||
@@ -62,7 +74,9 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
promoteDemote.setConfirmationRequired(ClickType.RIGHT);
|
||||
add(promoteDemote);
|
||||
promoteDemote.setPermission(ClickType.RIGHT, "simpleclans.leader.demote");
|
||||
}
|
||||
|
||||
private void addAssignUnassign() {
|
||||
SCComponentImpl assignUnassign = new SCComponentImpl(lang("gui.playerdetails.assign.unassign.title",getViewer()),
|
||||
Arrays.asList(lang("gui.playerdetails.assign.lore.left.click",getViewer()),
|
||||
lang("gui.playerdetails.unassign.lore.right.click",getViewer())),
|
||||
@@ -75,7 +89,9 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
() -> InventoryDrawer.open(new RanksFrame(this, getViewer(), clan, subject)));
|
||||
add(assignUnassign);
|
||||
assignUnassign.setPermission(ClickType.LEFT, "simpleclans.leader.rank.assign");
|
||||
}
|
||||
|
||||
private void addTrustUntrust() {
|
||||
SCComponent trustUntrust = new SCComponentImpl(lang("gui.playerdetails.trust.untrust.title",getViewer()),
|
||||
Arrays.asList(lang("gui.playerdetails.trust.lore.left.click",getViewer()),
|
||||
lang("gui.playerdetails.untrust.lore.right.click",getViewer())),
|
||||
@@ -93,7 +109,7 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.playerdetails.title",getViewer(), subject.getName());
|
||||
return lang("gui.playerdetails.title",getViewer(), subjectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,10 +2,11 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
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.managers.ClanManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -21,21 +22,19 @@ 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 Paginator paginator;
|
||||
private final OfflinePlayer toEdit;
|
||||
private final List<Rank> ranks;
|
||||
|
||||
public RanksFrame(SCFrame parent, Player viewer, Clan subject, @Nullable OfflinePlayer toEdit) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
this.toEdit = toEdit;
|
||||
ranks = subject != null ? subject.getRanks() : new ArrayList<>();
|
||||
paginator = new Paginator(getSize() - 9, ranks.size());
|
||||
}
|
||||
|
||||
@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;
|
||||
@@ -61,13 +60,13 @@ public class RanksFrame extends SCFrame {
|
||||
if (toEdit == null) {
|
||||
lore = Arrays.asList(
|
||||
lang("gui.ranks.rank.displayname.lore",getViewer(),
|
||||
Helper.parseColors(rank.getDisplayName())),
|
||||
ChatUtils.parseColors(rank.getDisplayName())),
|
||||
lang("gui.ranks.rank.edit.permissions.lore",getViewer()),
|
||||
lang("gui.ranks.rank.remove.lore",getViewer()));
|
||||
} else {
|
||||
lore = Arrays.asList(
|
||||
lang("gui.ranks.rank.displayname.lore",getViewer(),
|
||||
Helper.parseColors(rank.getDisplayName())),
|
||||
ChatUtils.parseColors(rank.getDisplayName())),
|
||||
lang("gui.ranks.rank.assign.lore",getViewer(), toEdit.getName()));
|
||||
}
|
||||
SCComponent c = new SCComponentImpl(lang("gui.ranks.rank.title",getViewer(), rank.getName()), lore,
|
||||
@@ -111,7 +110,8 @@ public class RanksFrame extends SCFrame {
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
if (toEdit != null) {
|
||||
String rank = SimpleClans.getInstance().getClanManager().getAnyClanPlayer(toEdit.getUniqueId()).getRankId();
|
||||
ClanManager clanManager = SimpleClans.getInstance().getClanManager();
|
||||
String rank = clanManager.getCreateClanPlayer(toEdit.getUniqueId()).getRankId();
|
||||
return lang("gui.ranks.title.set.rank",getViewer(), rank);
|
||||
}
|
||||
return lang("gui.ranks.title",getViewer());
|
||||
|
||||
@@ -17,18 +17,19 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class RivalsFrame extends SCFrame {
|
||||
private final SimpleClans plugin = SimpleClans.getInstance();
|
||||
private Paginator paginator;
|
||||
private final Paginator paginator;
|
||||
private final Clan subject;
|
||||
private final List<String> rivals;
|
||||
|
||||
public RivalsFrame(Player viewer, SCFrame parent, Clan subject) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
rivals = subject.getRivals();
|
||||
paginator = new Paginator(getSize() - 9, rivals.size());
|
||||
}
|
||||
|
||||
@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)
|
||||
|
||||
@@ -3,10 +3,10 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames.staff;
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.Components;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.RosterFrame;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -50,7 +50,7 @@ public class ClanDetailsFrame extends SCFrame {
|
||||
Collections.singletonList(lang("gui.staffclandetails.disband.lore", getViewer())),
|
||||
XMaterial.BARRIER, 34);
|
||||
disband.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"disband", false, clan.getTag()));
|
||||
"mod disband", false, clan.getTag()));
|
||||
disband.setConfirmationRequired(ClickType.LEFT);
|
||||
disband.setPermission(ClickType.LEFT, "simpleclans.mod.disband");
|
||||
add(disband);
|
||||
@@ -71,7 +71,7 @@ public class ClanDetailsFrame extends SCFrame {
|
||||
verify.setPermission(ClickType.LEFT, "simpleclans.mod.verify");
|
||||
verify.setConfirmationRequired(ClickType.LEFT);
|
||||
verify.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"verify", false, clan.getTag()));
|
||||
"mod verify", false, clan.getTag()));
|
||||
}
|
||||
add(verify);
|
||||
}
|
||||
@@ -84,10 +84,10 @@ public class ClanDetailsFrame extends SCFrame {
|
||||
SCComponent home = new SCComponentImpl(lang("gui.clandetails.home.title", getViewer()), lore,
|
||||
XMaterial.MAGENTA_BED, 30);
|
||||
home.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"home tp", false, clan.getTag()));
|
||||
"mod home tp", false, clan.getTag()));
|
||||
home.setPermission(ClickType.LEFT, "simpleclans.mod.hometp");
|
||||
home.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"home set", false, clan.getTag()));
|
||||
"mod home set", false, clan.getTag()));
|
||||
home.setPermission(ClickType.RIGHT, "simpleclans.mod.home");
|
||||
home.setConfirmationRequired(ClickType.RIGHT);
|
||||
add(home);
|
||||
@@ -111,7 +111,7 @@ public class ClanDetailsFrame extends SCFrame {
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.clandetails.title", getViewer(), Helper.stripColors(clan.getColorTag()),
|
||||
return lang("gui.clandetails.title", getViewer(), ChatUtils.stripColors(clan.getColorTag()),
|
||||
clan.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ClanListFrame extends SCFrame {
|
||||
} else {
|
||||
if (toPlace != null) {
|
||||
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"place", false, toPlace.getName(), clan.getTag()));
|
||||
"mod place", false, toPlace.getName(), clan.getTag()));
|
||||
c.setConfirmationRequired(ClickType.LEFT);
|
||||
c.setPermission(ClickType.LEFT, "simpleclans.mod.place");
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class ClanListFrame extends SCFrame {
|
||||
}
|
||||
|
||||
private void updateFrame() {
|
||||
InventoryDrawer.update(this);
|
||||
InventoryDrawer.open(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.ui.frames.staff;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.Components;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -21,7 +22,7 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
public PlayerDetailsFrame(@NotNull Player viewer, SCFrame parent, @NotNull OfflinePlayer subject) {
|
||||
super(parent, viewer);
|
||||
this.subject = subject;
|
||||
subjectName = subject.getName();
|
||||
subjectName = SimpleClans.getInstance().getClanManager().getCreateClanPlayer(subject.getUniqueId()).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +65,7 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
lang("gui.playerdetails.purge.lore", getViewer())).build();
|
||||
purge.setConfirmationRequired(ClickType.LEFT);
|
||||
purge.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"purge", false, subjectName));
|
||||
"admin purge", false, subjectName));
|
||||
purge.setPermission(ClickType.LEFT, "simpleclans.admin.purge");
|
||||
add(purge);
|
||||
}
|
||||
@@ -74,7 +75,7 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
.withSlot(30).withDisplayName(lang("gui.main.reset.kdr.title", getViewer()))
|
||||
.withLoreLine(lang("gui.playerdetails.resetkdr.lore", getViewer())).build();
|
||||
resetKdr.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"resetkdr", false, subjectName));
|
||||
"admin resetkdr", false, subjectName));
|
||||
resetKdr.setConfirmationRequired(ClickType.LEFT);
|
||||
resetKdr.setPermission(ClickType.LEFT, "simpleclans.admin.resetkdr");
|
||||
add(resetKdr);
|
||||
@@ -100,15 +101,15 @@ public class PlayerDetailsFrame extends SCFrame {
|
||||
banUnban.setPermission(ClickType.LEFT, "simpleclans.mod.ban");
|
||||
banUnban.setPermission(ClickType.RIGHT, "simpleclans.mod.ban");
|
||||
banUnban.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"ban", false, subjectName));
|
||||
"mod ban", false, subjectName));
|
||||
banUnban.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
|
||||
"unban", false, subjectName));
|
||||
"mod unban", false, subjectName));
|
||||
add(banUnban);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle() {
|
||||
return lang("gui.playerdetails.title", getViewer(), subject.getName());
|
||||
return lang("gui.playerdetails.title", getViewer(), subjectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,7 +73,7 @@ public class StaffFrame extends SCFrame {
|
||||
reload.setPermission(ClickType.LEFT, "simpleclans.admin.reload");
|
||||
reload.setConfirmationRequired(ClickType.LEFT);
|
||||
reload.setListener(ClickType.LEFT, () ->
|
||||
InventoryController.runSubcommand(getViewer(), "reload", false));
|
||||
InventoryController.runSubcommand(getViewer(), "admin reload", false));
|
||||
add(reload);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class StaffFrame extends SCFrame {
|
||||
} else {
|
||||
arg = "allow";
|
||||
}
|
||||
InventoryController.runSubcommand(getViewer(), "globalff", true, arg);
|
||||
InventoryController.runSubcommand(getViewer(), "mod globalff", true, arg);
|
||||
});
|
||||
add(globalFf);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.*;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
|
||||
import static net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class ChatUtils {
|
||||
|
||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("(%([A-Za-z]+)%)");
|
||||
private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("&#(\\w{5}[0-9A-Fa-f])");
|
||||
private static boolean supportsHexColors;
|
||||
|
||||
static {
|
||||
try {
|
||||
ChatColor.class.getDeclaredMethod("of", String.class);
|
||||
supportsHexColors = true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
supportsHexColors = false;
|
||||
}
|
||||
}
|
||||
|
||||
private ChatUtils() {
|
||||
}
|
||||
|
||||
public static String parseColors(@NotNull String text) {
|
||||
// Special thanks to the Spigot community!
|
||||
// https://www.spigotmc.org/threads/hex-color-code-translate.449748/#post-3867795
|
||||
if (supportsHexColors) {
|
||||
Matcher matcher = HEX_COLOR_PATTERN.matcher(text);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(buffer, ChatColor.of("#" + matcher.group(1)).toString());
|
||||
}
|
||||
text = matcher.appendTail(buffer).toString();
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
public static String stripColors(String text) {
|
||||
if (supportsHexColors) {
|
||||
Matcher matcher = HEX_COLOR_PATTERN.matcher(text);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(buffer, "");
|
||||
}
|
||||
text = matcher.appendTail(buffer).toString();
|
||||
}
|
||||
return oldStripColors(text);
|
||||
}
|
||||
|
||||
private static String oldStripColors(String text) {
|
||||
return text.replaceAll("[&][0-9A-Za-z]", "")
|
||||
.replaceAll(String.valueOf((char) 194), "") //don't know why
|
||||
.replaceAll("[\u00a7][0-9A-Za-z]", "");
|
||||
}
|
||||
|
||||
public static BaseComponent[] toBaseComponents(@Nullable CommandSender receiver, @NotNull String text) {
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
ArrayList<String> placeholders = new ArrayList<>();
|
||||
Matcher matcher = PLACEHOLDER_PATTERN.matcher(text);
|
||||
while (matcher.find()) {
|
||||
placeholders.add(matcher.group(0));
|
||||
}
|
||||
String[] split = PLACEHOLDER_PATTERN.split(text);
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
builder.append(split[i]);
|
||||
if (i >= placeholders.size()) {
|
||||
continue;
|
||||
}
|
||||
appendPlaceholder(receiver, builder, placeholders.get(i));
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void appendPlaceholder(@Nullable CommandSender receiver, ComponentBuilder builder, String placeholder) {
|
||||
Matcher matcher = PLACEHOLDER_PATTERN.matcher(placeholder);
|
||||
if (!matcher.find()) {
|
||||
return;
|
||||
}
|
||||
placeholder = matcher.group(2);
|
||||
builder.retain(FormatRetention.FORMATTING).append(lang("clickable." + placeholder, receiver))
|
||||
.event(new ClickEvent(RUN_COMMAND, "/" + placeholder))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
|
||||
(lang("hover.click.to." + placeholder, receiver)))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops through the input and returns the last color codes
|
||||
*
|
||||
* @param input the input
|
||||
* @return the last color codes
|
||||
*/
|
||||
@NotNull
|
||||
public static String getLastColors(@NotNull String input) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
int length = input.length();
|
||||
|
||||
for (int index = length - 1; index > -1; index--) {
|
||||
boolean found = false;
|
||||
String color = String.valueOf(input.charAt(index));
|
||||
if (ChatColor.ALL_CODES.contains(color)) {
|
||||
if (index - 1 >= 0) {
|
||||
char section = input.charAt(index - 1);
|
||||
if (section == COLOR_CHAR) {
|
||||
index--;
|
||||
result.insert(0, section + color);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found && result.length() != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static void applyLastColorToFollowingLines(@NotNull List<String> lines) {
|
||||
if (lines.get(0).length() == 0 || lines.get(0).charAt(0) != COLOR_CHAR) {
|
||||
lines.set(0, ChatColor.WHITE + lines.get(0));
|
||||
}
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
final String pLine = lines.get(i - 1);
|
||||
final String subLine = lines.get(i);
|
||||
|
||||
if (subLine.length() == 0 || subLine.charAt(0) != COLOR_CHAR) {
|
||||
lines.set(i, getLastColors(pLine) + subLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class TagValidator {
|
||||
@@ -31,9 +29,9 @@ public class TagValidator {
|
||||
*/
|
||||
@Nullable
|
||||
public String getErrorMessage() {
|
||||
String cleanTag = Helper.stripColors(this.tag);
|
||||
if (tag.length() > 25) {
|
||||
return lang("your.clan.color.tag.cannot.be.longer.than.characters", player, 25);
|
||||
String cleanTag = ChatUtils.stripColors(this.tag);
|
||||
if (tag.length() > 255 && plugin.getSettingsManager().isUseMysql()) {
|
||||
return lang("your.clan.color.tag.cannot.be.longer.than.characters", player, 255);
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass")) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -52,7 +53,7 @@ public class UpdateChecker {
|
||||
if (parse.isJsonObject()) {
|
||||
String latestVersion = parse.getAsJsonObject().get("name").getAsString();
|
||||
|
||||
if (!version.equals(latestVersion)) {
|
||||
if (compareVersions(version, latestVersion) < 0) {
|
||||
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/");
|
||||
@@ -69,4 +70,18 @@ public class UpdateChecker {
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
public static int compareVersions(@NotNull String a, @NotNull String b) {
|
||||
String[] aSplit = a.split("\\.");
|
||||
String[] bSplit = b.split("\\.");
|
||||
int length = Math.max(aSplit.length, bSplit.length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int aPart = aSplit.length > i ? Integer.parseInt(aSplit[i]) : 0;
|
||||
int bPart = bSplit.length > i ? Integer.parseInt(bSplit[i]) : 0;
|
||||
if (aPart != bPart) {
|
||||
return Integer.compare(aPart, bPart);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils.applyLastColorToFollowingLines;
|
||||
|
||||
public class WordWrapper {
|
||||
|
||||
private final String rawString;
|
||||
private final int lineLength;
|
||||
char[] rawChars;
|
||||
StringBuilder word = new StringBuilder();
|
||||
StringBuilder line = new StringBuilder();
|
||||
List<String> lines = new LinkedList<>();
|
||||
int lineColorChars = 0;
|
||||
|
||||
public WordWrapper(@NotNull String rawString, int lineLength) {
|
||||
this.rawString = rawString;
|
||||
this.lineLength = lineLength > 0 ? lineLength : 319;
|
||||
rawChars = (rawString + ' ').toCharArray(); // add a trailing space to trigger pagination
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] wrap() {
|
||||
// A string shorter than the lineWidth is a single line
|
||||
if (rawString.length() <= lineLength && !rawString.contains("\n")) {
|
||||
return new String[]{rawString};
|
||||
}
|
||||
|
||||
for (int i = 0; i < rawChars.length; i++) {
|
||||
char c = rawChars[i];
|
||||
// skip chat color modifiers
|
||||
if (c == COLOR_CHAR) {
|
||||
processChatColorModifiers(rawChars[i + 1]);
|
||||
i++; // Eat the next character as we have already processed it
|
||||
continue;
|
||||
}
|
||||
if (c == ' ' || c == '\n') {
|
||||
processSpace();
|
||||
processLineBreak(c);
|
||||
} else {
|
||||
word.append(c);
|
||||
}
|
||||
}
|
||||
addLastLine();
|
||||
// Iterate over the wrapped lines, applying the last color from one line to the beginning of the next
|
||||
applyLastColorToFollowingLines(lines);
|
||||
|
||||
return lines.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private void addLastLine() {
|
||||
if (line.length() > 0) { // Only add the last line if there is anything to add
|
||||
lines.add(line.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void processLineBreak(char c) {
|
||||
if (c == '\n') { // Newline forces the line to flush
|
||||
lines.add(line.toString());
|
||||
line = new StringBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
private void processSpace() {
|
||||
if (line.length() == 0 && word.length() - lineColorChars > lineLength) { // special case: extremely long word begins a line
|
||||
lines.addAll(split(word.toString(), lineLength));
|
||||
} else if (line.length() + 1 + word.length() - lineColorChars == lineLength) { // Line exactly the correct length...newline
|
||||
processLineCorrectLength();
|
||||
} else if (line.length() + 1 + word.length() - lineColorChars > lineLength) { // Line too long...break the line
|
||||
processLineTooLong();
|
||||
} else {
|
||||
appendWord();
|
||||
}
|
||||
word = new StringBuilder();
|
||||
}
|
||||
|
||||
private void appendWord() {
|
||||
if (line.length() > 0) {
|
||||
line.append(' ');
|
||||
}
|
||||
line.append(word);
|
||||
}
|
||||
|
||||
private void processLineTooLong() {
|
||||
for (String partialWord : split(word.toString(), lineLength)) {
|
||||
if (line.length() > 0) {
|
||||
lines.add(line.toString());
|
||||
}
|
||||
line = new StringBuilder(partialWord);
|
||||
}
|
||||
lineColorChars = 0;
|
||||
}
|
||||
|
||||
private void processLineCorrectLength() {
|
||||
appendWord();
|
||||
lines.add(line.toString());
|
||||
line = new StringBuilder();
|
||||
lineColorChars = 0;
|
||||
}
|
||||
|
||||
private void processChatColorModifiers(char rawChar) {
|
||||
word.append(COLOR_CHAR);
|
||||
word.append(rawChar);
|
||||
lineColorChars += 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Breaks a String, using the passed length and respecting color codes, into a List of Strings
|
||||
*
|
||||
* @param input the input
|
||||
* @return the split input
|
||||
*/
|
||||
@NotNull
|
||||
public static List<String> split(@NotNull String input, int length) {
|
||||
List<String> split = new ArrayList<>();
|
||||
int nonColorCount = 0;
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
if (nonColorCount == length) {
|
||||
split.add(input.substring(0, i));
|
||||
input = input.substring(i);
|
||||
nonColorCount = 0;
|
||||
i = 0;
|
||||
}
|
||||
char c = input.charAt(i);
|
||||
if (c == COLOR_CHAR) {
|
||||
if (i + 1 < input.length()) {
|
||||
String s = String.valueOf(input.charAt(i + 1));
|
||||
if (ChatColor.ALL_CODES.contains(s)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
nonColorCount++;
|
||||
}
|
||||
if (!input.isEmpty()) {
|
||||
split.add(input);
|
||||
}
|
||||
return split;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ create.command=create
|
||||
delete.command=delete
|
||||
rank.command=rank
|
||||
setdisplayname.command=setdisplayname
|
||||
setdefault.command=setdefault
|
||||
removedefault.command=removedefault
|
||||
permissions.command=permissions
|
||||
list.command=list
|
||||
list.order.asc=asc
|
||||
@@ -49,6 +51,7 @@ purge.command=purge
|
||||
trust.command=trust
|
||||
untrust.command=untrust
|
||||
admin.command=admin
|
||||
mod.command=mod
|
||||
promote.command=promote
|
||||
demote.command=demote
|
||||
clanff.command=clanff
|
||||
@@ -142,6 +145,7 @@ command.description.ally.add=Adds an ally
|
||||
command.description.clan=Opens the GUI
|
||||
command.description.disband=Disbands your clan
|
||||
command.description.mod.disband=Disbands a clan
|
||||
command.description.mod.kick=Kicks a player from a clan
|
||||
command.description.modtag=Modifies your clan's tag
|
||||
command.description.purge=Purges some player's data
|
||||
command.description.setbanner=Sets your clan's banner
|
||||
@@ -177,6 +181,8 @@ command.description.rank.create=Creates a rank
|
||||
command.description.rank.delete=Deletes a rank
|
||||
command.description.rank.list=Lists your clan''s ranks
|
||||
command.description.rank.setdisplayname=Sets a rank''s display name
|
||||
command.description.rank.setdefault=Sets the default rank
|
||||
command.description.rank.removedefault=Removes the default rank
|
||||
command.description.rank.permissions.available=Lists the available rank permissions
|
||||
command.description.rank.permissions.rank=Lists a rank''s permissions
|
||||
command.description.rank.permissions.add=Adds a permission to a rank
|
||||
@@ -209,6 +215,7 @@ leader=leader
|
||||
roster=roster
|
||||
trusted=trusted
|
||||
untrusted=untrusted
|
||||
in.rank=in rank
|
||||
deaths=Deaths
|
||||
weights=Weights
|
||||
stats=stats
|
||||
@@ -256,7 +263,12 @@ inviting.you.to.join={0} is inviting you to join {1}
|
||||
asking.for.the.deletion={0} is asking for the deletion of the clan
|
||||
asking.for.the.promotion={0} is asking for the promotion of {1}
|
||||
asking.for.the.demotion={0} is asking for the demotion of {1}
|
||||
accept.or.deny={0} or {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
request.message= \n &8[&8{0}&8] &b{1}\n %accept% &bor %deny%\n
|
||||
clickable.accept=&a&l[ACCEPT]
|
||||
clickable.deny=&c&l[DENY]
|
||||
hover.click.to.accept=&aClick here to accept
|
||||
hover.click.to.deny=&cClick here to deny
|
||||
not.sufficient.money=You do not have sufficient money in your account
|
||||
account.has.been.debited=Your account has been debited {0}
|
||||
mysql.connection.successful=MySQL Connection successful
|
||||
@@ -349,6 +361,7 @@ inactive.0=Inactive: {0}
|
||||
clan.commands=clan commands
|
||||
you.can.only.modify.the.color.and.case.of.the.tag=You can only modify the color and case of the tag
|
||||
tag.changed.to.0=Tag changed to {0}
|
||||
0.tag.changed.to.1=&bSuccessfully changed {0}''s tag to {1}
|
||||
name.0=Name: {0}
|
||||
description.0=Description: {0}
|
||||
leaders.0=Leaders: {0}
|
||||
@@ -463,7 +476,9 @@ resign.no=No
|
||||
resign.confirmation=Are you sure you want to resign? {0}
|
||||
resign.success=You have successfully resigned from your clan
|
||||
you.cannot.demote.the.last.leader=You cannot demote the last leader
|
||||
you.cannot.move.the.last.leader=You cannot move the last leader
|
||||
player.successfully.demoted=The player was successfully demoted
|
||||
player.successfully.promoted=The player was successfully promoted
|
||||
bb.ago= ago
|
||||
bb.moments=moments
|
||||
bb.seconds= seconds
|
||||
@@ -489,6 +504,8 @@ no.description=No description
|
||||
the.player.must.wait.0.before.joining.your.clan.again=This player must wait {0} minute(s) before joining your clan again
|
||||
disabled.command=Disabled command
|
||||
rank.displayname.updated=The rank''s display name was updated!
|
||||
rank.setdefault=The clan''s default rank has now been set to {0}
|
||||
rank.removedefault=The clan''s default rank has been removed
|
||||
rank.0.permissions=Rank {0}''s permissions:
|
||||
available.rank.permissions=Available permissions for ranks:
|
||||
rank.already.exists=Rank already exists
|
||||
@@ -778,6 +795,8 @@ clans.not.at.war.pvp.denied=&cYour clan is not at war with {0}!
|
||||
cannot.attack.civilians=&cYou cannot attack civilians!
|
||||
cannot.attack.clan.member=&cYou cannot attack another clan member!
|
||||
cannot.attack.ally=&cYou cannot attack an ally!
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
cannot.change.member.fee.now=&cYou cannot change the member fee close to its collection time.
|
||||
cannot.change.member.fee.hours=&cTry again in {0} hours...
|
||||
cannot.change.member.fee.minutes=&cTry again in {0} minute(s)...
|
||||
cannot.change.member.fee.minutes=&cTry again in {0} minute(s)...
|
||||
cannot.kick.last.leader=&cYou cannot kick the last leader!
|
||||
@@ -0,0 +1,22 @@
|
||||
description.command=popis
|
||||
create.command=vytvořit
|
||||
delete.command=smazat
|
||||
rank.command=hodnost
|
||||
setdisplayname.command=setdisplayname
|
||||
permissions.command=permissions
|
||||
list.command=list
|
||||
list.order.asc=vzestupne
|
||||
list.order.desc=sestupne
|
||||
list.type.name=jmeno
|
||||
list.type.kdr=kdr
|
||||
list.type.size=velikost
|
||||
list.type.founded=nalezen
|
||||
list.type.active=aktivní
|
||||
profile.command=profil
|
||||
roster.command=roster
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -83,6 +83,7 @@ acf-core.parameter.order=bestellung
|
||||
acf-core.parameter.help=seite oder schlüsselwörter
|
||||
command.description.stats=Zeigt die Mitgliederstatistik deines Clans an
|
||||
command.description.rivalries=Zeigt alle Clan-Rivalitäten
|
||||
command.description.kick=Wirf ein Mitglied aus deinem Clan
|
||||
home-menu=/{0} Home{1} - Teleportiert dich in die Clan Basis
|
||||
home-set-menu=/{0} Home set{1} - Setzt die Clan Basis
|
||||
home-clear-menu=/{0} Home clear{1} - Entfernt die Clan Basis
|
||||
@@ -156,7 +157,7 @@ proposing.an.alliance={0} schlägt vor ein Allianz mit {1} einzugehen
|
||||
inviting.you.to.join={0} lädt dich zum Beitritt ein {1}
|
||||
asking.for.the.deletion={0} fragt nach einer Löschung des Clans
|
||||
asking.for.the.promotion={0} fragt nach einer Beförderung für {1}
|
||||
accept.or.deny={0} bzw. {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=Du hast nicht genügend Geld auf deinem Konto
|
||||
account.has.been.debited=Ihr Konto wurde belastet {0}
|
||||
mysql.connection.successful=Verbindung hergestellt
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
description.command=description
|
||||
create.command=create
|
||||
delete.command=delete
|
||||
delete.command=eliminar
|
||||
rank.command=rank
|
||||
setdisplayname.command=setdisplayname
|
||||
permissions.command=permissions
|
||||
permissions.command=permisos
|
||||
list.command=list
|
||||
list.order.asc=asc
|
||||
list.order.desc=desc
|
||||
list.type.name=name
|
||||
list.type.name=nombre
|
||||
list.type.kdr=kdr
|
||||
list.type.size=size
|
||||
list.type.founded=founded
|
||||
list.type.active=active
|
||||
list.type.size=tamaño
|
||||
list.type.founded=fundado
|
||||
list.type.active=activo
|
||||
profile.command=profile
|
||||
roster.command=roster
|
||||
lookup.command=lookup
|
||||
@@ -22,29 +22,29 @@ vitals.command=vitals
|
||||
coords.command=coords
|
||||
stats.command=stats
|
||||
ally.command=ally
|
||||
add.command=add
|
||||
remove.command=remove
|
||||
allow.command=allow
|
||||
block.command=block
|
||||
add.command=añadir
|
||||
remove.command=eliminar
|
||||
allow.command=permitir
|
||||
block.command=bloquear
|
||||
auto.command=auto
|
||||
check.command=check
|
||||
assign.command=assign
|
||||
unassign.command=unassign
|
||||
check.command=verificar
|
||||
assign.command=asignar
|
||||
unassign.command=desasignar
|
||||
rival.command=rival
|
||||
bb.command=bb
|
||||
clear.command=clear
|
||||
clear.command=limpiar
|
||||
modtag.command=modtag
|
||||
toggle.command=toggle
|
||||
tag.command=tag
|
||||
deposit.command=deposit
|
||||
all.command=all
|
||||
withdraw.command=withdraw
|
||||
tag.command=etiqueta
|
||||
deposit.command=deposito
|
||||
all.command=todo
|
||||
withdraw.command=retirar
|
||||
invite.command=invite
|
||||
kick.command=kick
|
||||
bank.command=bank
|
||||
status.command=status
|
||||
status.command=estado
|
||||
fee.command=fee
|
||||
set.command=set
|
||||
set.command=poner
|
||||
purge.command=purge
|
||||
trust.command=trust
|
||||
untrust.command=untrust
|
||||
@@ -63,27 +63,27 @@ globalff.command=globalff
|
||||
kills.command=kills
|
||||
mostkilled.command=mostkilled
|
||||
war.command=war
|
||||
start.command=start
|
||||
end.command=end
|
||||
start.command=iniciar
|
||||
end.command=terminar
|
||||
home.command=home
|
||||
regroup.command=regroup
|
||||
me.command=me
|
||||
regroup.command=reagrupar
|
||||
me.command=yo
|
||||
tp.command=tp
|
||||
setrank.command=setrank
|
||||
place.command=place
|
||||
resetkdr.command=resetkdr
|
||||
everyone.command=everyone
|
||||
setbanner.command=setbanner
|
||||
everyone.command=todos
|
||||
setbanner.command=fijarbanner
|
||||
help.command=ayuda
|
||||
acf-core.parameter.member=miembro
|
||||
acf-core.parameter.rank=rango
|
||||
acf-core.parameter.leader=líder
|
||||
acf-core.parameter.leader=lider
|
||||
acf-core.parameter.displayname=nombre de pantalla
|
||||
acf-core.parameter.permission=permiso
|
||||
acf-core.parameter.permission=permisos
|
||||
acf-core.parameter.message=mensaje
|
||||
acf-core.parameter.tag=tag
|
||||
acf-core.parameter.tag=etiqueta
|
||||
acf-core.parameter.fee=tarifa
|
||||
acf-core.parameter.description=descripción
|
||||
acf-core.parameter.description=descripcion
|
||||
acf-core.parameter.player=jugador
|
||||
acf-core.parameter.clan=clan
|
||||
acf-core.parameter.type=tipo
|
||||
@@ -255,7 +255,7 @@ inviting.you.to.join={0} te esta invitando unirte a {1}
|
||||
asking.for.the.deletion={0} esta solicitando la eliminacion del clan
|
||||
asking.for.the.promotion={0} esta solicitando promover a {1}
|
||||
asking.for.the.demotion={0} esta solicitando degradar a {1}
|
||||
accept.or.deny={0} o {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=No tienes suficiente dinero en tu cuenta
|
||||
account.has.been.debited=Se ha descontado de tu cuenta {0}
|
||||
mysql.connection.successful=MySQL Connection successful
|
||||
@@ -529,6 +529,7 @@ gui.main.reset.kdr.lore=&7Clic izquierdo para reiniciar tu KDR
|
||||
gui.main.leaderboard.title=&fTablero de posiciones
|
||||
gui.main.leaderboard.lore=&7Clic izquierdo para ver el tablero de posiciones
|
||||
gui.main.staff.title=&fStaff
|
||||
gui.main.staff.lore=&7Clic izquierdo para abrir el menú del personal
|
||||
gui.staff.title=Staff
|
||||
gui.staff.clan.list.lore.left.click=&7Clic izquierdo para ver la lista de clanes
|
||||
gui.staff.clan.list.lore.right.click=&7Clic derecho para ver la lista de clanes sin verificar
|
||||
@@ -750,3 +751,6 @@ clans.not.at.war.pvp.denied=&cTu clan no esta en guerra con {0}\!
|
||||
cannot.attack.civilians=&cNo puedes atacar civiles\!
|
||||
cannot.attack.clan.member=&cNo puedes atacar miembros de tu clan\!
|
||||
cannot.attack.ally=&cNo puedes atacar a un aliado\!
|
||||
cannot.change.member.fee.now=&cNo puedes cambiar la cuota de miembro cerca de su tiempo de recogida.
|
||||
cannot.change.member.fee.hours=&cInténtalo de nuevo en {0} horas...
|
||||
cannot.change.member.fee.minutes=&cInténtalo de nuevo en {0} minuto(s)...
|
||||
@@ -6,7 +6,7 @@ setdisplayname.command=setdisplayname
|
||||
permissions.command=permissions
|
||||
list.command=liste
|
||||
list.order.desc=desc
|
||||
list.type.name=nome
|
||||
list.type.name=nom
|
||||
list.type.kdr=kda
|
||||
list.type.size=taille
|
||||
list.type.founded=fondé
|
||||
@@ -21,7 +21,7 @@ vitals.command=vitaux
|
||||
coords.command=coordonnées
|
||||
stats.command=statistiques
|
||||
ally.command=allie
|
||||
add.command=ajouter
|
||||
add.command=ajoute
|
||||
remove.command=retirer
|
||||
allow.command=autoriser
|
||||
block.command=bloquer
|
||||
@@ -48,6 +48,7 @@ purge.command=purge
|
||||
trust.command=confiance
|
||||
untrust.command=méfiance
|
||||
admin.command=admin
|
||||
mod.command=modérateur
|
||||
promote.command=promouvoir
|
||||
demote.command=rétrograder
|
||||
clanff.command=clanff
|
||||
@@ -81,10 +82,12 @@ acf-core.parameter.displayname=Nom affiché
|
||||
acf-core.parameter.permission=autorisation
|
||||
acf-core.parameter.message=message
|
||||
acf-core.parameter.tag=tag
|
||||
acf-core.parameter.name=nom
|
||||
acf-core.parameter.description=description
|
||||
acf-core.parameter.player=joueur
|
||||
acf-core.parameter.clan=clan
|
||||
acf-core.parameter.help=page ou mots-clés
|
||||
command.description.stats=Montre les stats des membres de votre clan
|
||||
command.description.list=Liste de tous les clans
|
||||
command.description.ally=Parle dans le chat des alliés
|
||||
command.description.deny=Refuser une demande
|
||||
@@ -212,7 +215,7 @@ inviting.you.to.join={0} vous invite à rejoindre {1}
|
||||
asking.for.the.deletion={0} demande la suppression du clan
|
||||
asking.for.the.promotion={0} demande la promotion de {1}
|
||||
asking.for.the.demotion={0} demande la rétrogradation de {1}
|
||||
accept.or.deny={0} ou {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=Vous n'avez pas assez d'argent sur votre compte
|
||||
account.has.been.debited=Votre compte a été débité {0}
|
||||
mysql.connection.successful=MySQL Connexion réussie
|
||||
|
||||
@@ -72,7 +72,7 @@ inviting.you.to.join={0} meghívott téged, hogy csatlakozz {1}
|
||||
asking.for.the.deletion={0} a klán törlését kéri
|
||||
asking.for.the.promotion={0} kéri a promóció {1}
|
||||
asking.for.the.demotion={0} kéri a promóció {1}
|
||||
accept.or.deny={0} vagy {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=Nincs elegendő pénz a fiókodban
|
||||
account.has.been.debited=A fiókod terhelésre került {0}
|
||||
mysql.connection.successful=MySQL kapcsolat sikeres
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
description.command=descrizione
|
||||
create.command=creare
|
||||
create.command=crea
|
||||
delete.command=elimina
|
||||
rank.command=grado
|
||||
rank.command=rango
|
||||
profile.command=profilo
|
||||
roster.command=membri
|
||||
lookup.command=ricerca
|
||||
@@ -144,7 +144,7 @@ proposing.an.alliance={0} sta proponendo un''alleanza con {1}
|
||||
inviting.you.to.join={0} ti sta invitando ad unirti a {1}
|
||||
asking.for.the.deletion={0} chiede l''eliminazione del clan
|
||||
asking.for.the.promotion={0} chiede la promozione di {1}
|
||||
accept.or.deny={0} oppure {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=Non hai abbastanza soldi sul tuo conto
|
||||
mysql.connection.successful=Connessione MySQL riuscita
|
||||
mysql.connection.failed=Connessione MySQL fallita
|
||||
|
||||
@@ -95,4 +95,5 @@ command.description.regroup.me=Hergroepeert je clan leden naar je locatie
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -46,4 +46,5 @@ help.command=hjelp
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -1,5 +1,5 @@
|
||||
description.command=opis
|
||||
create.command=stworz
|
||||
description.command=Opis
|
||||
create.command=utwórz
|
||||
delete.command=usun
|
||||
rank.command=ranking
|
||||
setdisplayname.command=ustaw nazwe wyswietlana
|
||||
@@ -255,7 +255,7 @@ inviting.you.to.join={0} zaprasza cie do przylaczenia sie do {1}}
|
||||
asking.for.the.deletion={0} wnioskuje za usunieciem klanu
|
||||
asking.for.the.promotion={0} wnioskuje o awansowanie {1}
|
||||
asking.for.the.demotion={0} wnioskuje o degradacje {1}
|
||||
accept.or.deny={0} lub {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=Nie posiadasz wystarczajacej ilosci dukatow
|
||||
account.has.been.debited=Twoje konto zostalo zmniejszone o {0}
|
||||
mysql.connection.successful=MySQL udane polaczenie
|
||||
@@ -753,4 +753,4 @@ cannot.attack.clan.member=&cNie możesz zaatakować innego członka klanu\!
|
||||
cannot.attack.ally=&cNie możesz zaatakować sojusznika\!
|
||||
cannot.change.member.fee.now=&cNie możesz zmienić składki członkowskiej blisko czasu jej pobrania.
|
||||
cannot.change.member.fee.hours=&cSpróbuj ponownie za {0} godzin...
|
||||
cannot.change.member.fee.minutes=&cSpróbuj ponownie za {0} minut...
|
||||
cannot.change.member.fee.minutes=&cSpróbuj ponownie za {0} minut...
|
||||
@@ -49,6 +49,7 @@ purge.command=apagar
|
||||
trust.command=confiar
|
||||
untrust.command=naoconfiar
|
||||
admin.command=admin
|
||||
mod.command=mod
|
||||
promote.command=promover
|
||||
demote.command=rebaixar
|
||||
clanff.command=clanff
|
||||
@@ -82,6 +83,7 @@ acf-core.parameter.displayname=nome de exibição
|
||||
acf-core.parameter.permission=permissão
|
||||
acf-core.parameter.message=mensagem
|
||||
acf-core.parameter.tag=tag
|
||||
acf-core.parameter.name=nome
|
||||
acf-core.parameter.fee=taxa
|
||||
acf-core.parameter.description=descrição
|
||||
acf-core.parameter.player=jogador
|
||||
@@ -208,6 +210,7 @@ leader=líder
|
||||
roster=membros
|
||||
trusted=confiável
|
||||
untrusted=não-confiável
|
||||
in.rank=no cargo
|
||||
deaths=Morreu
|
||||
weights=Pesos
|
||||
stats=estatísticas
|
||||
@@ -255,7 +258,12 @@ inviting.you.to.join={0} está te convidando para ser membro de {1}
|
||||
asking.for.the.deletion={0} está pedindo pela remoção do clã
|
||||
asking.for.the.promotion={0} está pedindo pela promoção de {1}
|
||||
asking.for.the.demotion={0} está pedindo pelo rebaixamento de {1}
|
||||
accept.or.deny={0} ou {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
request.message= \n &8[&8{0}&8] &b{1}\n %accept% &bou %deny%\n
|
||||
clickable.accept=&a&l[ACEITAR]
|
||||
clickable.deny=&c&l[REJEITAR]
|
||||
hover.click.to.accept=&aClique aqui para aceitar
|
||||
hover.click.to.deny=&cClique aqui para rejeitar
|
||||
not.sufficient.money=Você não tem dinheiro suficiente em sua conta
|
||||
account.has.been.debited={0} foram debitados de sua conta
|
||||
mysql.connection.successful=Conexão MySQL bem sucedida
|
||||
@@ -348,6 +356,7 @@ inactive.0=Inativo\: {0}
|
||||
clan.commands=comandos de clã
|
||||
you.can.only.modify.the.color.and.case.of.the.tag=Você pode modificar apenas a cor ou a caixa (maiúsculo ou minúsculo) da tag
|
||||
tag.changed.to.0=Tag modificada para {0}
|
||||
0.tag.changed.to.1=&bAlterou a tag do clã de {0} para {1}
|
||||
name.0=Nome\: {0}
|
||||
description.0=Descrição\: {0}
|
||||
leaders.0=Líderes\: {0}
|
||||
@@ -529,7 +538,7 @@ gui.main.reset.kdr.lore=&7Clique com o botão esquerdo para redefinir o seu KDR
|
||||
gui.main.leaderboard.title=&fRanking
|
||||
gui.main.leaderboard.lore=&7Clique com o botão esquerdo para ver o ranking
|
||||
gui.main.staff.title=&fEquipe
|
||||
gui.main.staff.lore=&7Clique com o botão esquerdo para abrir o menu da Staff
|
||||
gui.main.staff.lore=&7Clique com o botão esquerdo para abrir o menu da equipe
|
||||
gui.staff.title=Equipe
|
||||
gui.staff.clan.list.lore.left.click=&7Clique com o botão esquerdo para ver todos os clãs
|
||||
gui.staff.clan.list.lore.right.click=&7Clique com o botão direito para ver todos os clãs não verificados
|
||||
@@ -753,4 +762,4 @@ cannot.attack.clan.member=&cVocê não pode atacar um membro do clã\!
|
||||
cannot.attack.ally=&cVocê não pode atacar um aliado\!
|
||||
cannot.change.member.fee.now=&cVocê não pode modificar a taxa perto do horário de coleta.
|
||||
cannot.change.member.fee.hours=&cTente novamente em {0} horas...
|
||||
cannot.change.member.fee.minutes=&cTente novamente em {0} minuto(s)...
|
||||
cannot.change.member.fee.minutes=&cTente novamente em {0} minuto(s)...
|
||||
@@ -73,4 +73,5 @@ command.description.regroup.home=Adu' membri clanului la casa ta
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -49,6 +49,7 @@ purge.command=очистка
|
||||
trust.command=доверие
|
||||
untrust.command=недоверие
|
||||
admin.command=админ
|
||||
mod.command=мод
|
||||
promote.command=повысить
|
||||
demote.command=понизить
|
||||
clanff.command=кланфф
|
||||
@@ -66,7 +67,7 @@ war.command=война
|
||||
start.command=начать
|
||||
end.command=конец
|
||||
home.command=дом
|
||||
regroup.command=перегруппироваться
|
||||
regroup.command=созвать
|
||||
me.command=мне
|
||||
tp.command=телепортировать
|
||||
setrank.command=установить ранг
|
||||
@@ -82,6 +83,7 @@ acf-core.parameter.displayname=отображаемое имя
|
||||
acf-core.parameter.permission=права
|
||||
acf-core.parameter.message=сообщение
|
||||
acf-core.parameter.tag=тег
|
||||
acf-core.parameter.name=имя
|
||||
acf-core.parameter.fee=комиссия
|
||||
acf-core.parameter.description=описание
|
||||
acf-core.parameter.player=игрок
|
||||
@@ -92,7 +94,7 @@ acf-core.parameter.help=страница или ключевые слова
|
||||
command.description.stats=Показать статистику участников вашего клана
|
||||
command.description.rivalries=Показать всех соперников клана
|
||||
command.description.mostkilled=Показать общую статистику убийств на всём сервере
|
||||
command.description.kills=Показывает количество убийств вашего или другого игрока
|
||||
command.description.kills=Показать количество убийств вашего или другого игрока
|
||||
command.description.lookup=Посмотреть информацию о себе
|
||||
command.description.lookup.other=Посмотреть информацию об игроке
|
||||
command.description.leaderboard=Показать таблицу лидеров
|
||||
@@ -108,16 +110,16 @@ command.description.deny=Отклонить запрос
|
||||
command.description.accept=Принять запрос
|
||||
command.description.more=Показать больше информации
|
||||
command.description.create=Создать клан
|
||||
command.description.ff.allow=Разрешить участникам вашего клана бить друг друга
|
||||
command.description.ff.allow=Разрешить "огонь по своим" для вас
|
||||
command.description.ff.auto=Установить ваш статус "огонь по своим" по умолчанию
|
||||
command.description.globalff.allow=Разрешить участникам всех кланов бить друг друга
|
||||
command.description.globalff.allow=Установить глобальный статус "огонь по своим" на разрешено
|
||||
command.description.globalff.auto=Установить глобальный статус "огонь по своим" по умолчанию
|
||||
command.description.clanff.allow=Разрешить "огонь по своим" участникам вашего клана
|
||||
command.description.clanff.block=Запретить "огонь по своим" участникам вашего клана
|
||||
command.description.description=Установить описание вашего клана
|
||||
command.description.ban=Запретить игроку использовать команды клана
|
||||
command.description.unban=Разрешить игроку использовать команды клана
|
||||
command.description.regroup.me=Перегруппировать участников вашего клана в ваше текущее местоположение
|
||||
command.description.regroup.me=Созвать участников вашего клана к вам
|
||||
command.description.regroup.home=Созвать всех участников на вашу базу
|
||||
command.description.home.tp=Телепортироваться на базу вашего клана
|
||||
command.description.home.clear=Удалить базу вашего клана
|
||||
@@ -163,7 +165,7 @@ command.description.admin.demote=Понизить лидера из любого
|
||||
command.description.demote=Понизить лидера
|
||||
command.description.admin.promote=Повысить любого участника из любого клана
|
||||
command.description.promote=Повысить участника до лидера
|
||||
command.description.toggle.bb=Следует ли показывать вашим участникам доску объявлений при входе на сервер
|
||||
command.description.toggle.bb=Следует ли показывать доску объявлений при входе на сервер
|
||||
command.description.toggle.tag=Показывать ли рядом с вашим именем тег клана
|
||||
command.description.toggle.deposit=Можно ли вносить средства в банковский счёт вашего клана
|
||||
command.description.toggle.withdraw=Можно ли выводить средства с банковского счёта вашего клана
|
||||
@@ -208,6 +210,7 @@ leader=лидер
|
||||
roster=список
|
||||
trusted=проверенный
|
||||
untrusted=недоверенный
|
||||
in.rank=в ранге
|
||||
deaths=Смертей
|
||||
weights=Весит
|
||||
stats=статистика
|
||||
@@ -222,7 +225,7 @@ profile=профиль
|
||||
civilian.abbreviation=Жители
|
||||
rank=Ранг
|
||||
leaders=Лидеры
|
||||
none=Нету
|
||||
none=Нет
|
||||
today=Сегодня
|
||||
kills=Убиты
|
||||
mostkilled=Наибольшее число убийств
|
||||
@@ -255,7 +258,12 @@ inviting.you.to.join={0} пригласил вас присоединится к
|
||||
asking.for.the.deletion={0} предлагает удалить клан
|
||||
asking.for.the.promotion={0} просит повышение {1}
|
||||
asking.for.the.demotion={0} просит понизить {1}
|
||||
accept.or.deny={0} или {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
request.message= \n&8[&8{0}&8] &b{1}\n %accept% &bили %deny%\n
|
||||
clickable.accept=&a&l[ПРИНЯТЬ]
|
||||
clickable.deny=&c&l[ОТКЛОНИТЬ]
|
||||
hover.click.to.accept=Нажмите, чтобы принять
|
||||
hover.click.to.deny=Нажмите, чтобы отклонить
|
||||
not.sufficient.money=На вашем балансе недостаточно средств
|
||||
account.has.been.debited=С вашего баланса было списано {0}
|
||||
mysql.connection.successful=Соединение с MySQL прошло успешно
|
||||
@@ -271,7 +279,7 @@ nothing.more.to.see=Больше ничего нет
|
||||
nothing.to.vote=&cНечего принимать или отклонять
|
||||
no.leader.permissions=Вы не имеете права лидера
|
||||
you.have.already.voted=Вы уже проголосовали
|
||||
has.voted.to.deny={0} проголосовал за отказ
|
||||
has.voted.to.deny={0} проголосовал, чтобы отклонить
|
||||
view.next.page=Введите /{0} для просмотра следующей страницы.
|
||||
voted.to.accept={0} проголосовал за принятие
|
||||
bulletin.board.header={0}* {1}{2} доска объявлений
|
||||
@@ -348,6 +356,7 @@ inactive.0=Неактивно\: {0}
|
||||
clan.commands=команды клана
|
||||
you.can.only.modify.the.color.and.case.of.the.tag=Вы можете изменить только цвет и регистр тега
|
||||
tag.changed.to.0=Тег изменён на {0}
|
||||
0.tag.changed.to.1=&bТег {0} успешно изменён на {1}
|
||||
name.0=Имя\: {0}
|
||||
description.0=Описание\:{0}
|
||||
leaders.0=Лидер\: {0}
|
||||
@@ -425,7 +434,7 @@ depositoff=Пополнение выключено
|
||||
withdrawon=Вывод включён
|
||||
withdrawoff=Вывод выключен
|
||||
feeoff=Участники клана больше не вносят комиссию на банковский счёт вашего клана.
|
||||
feeon=Участники клана теперь вносят комиссию на банковский счёт вашего клана. \nУчастники, не имеющие достаточное количество денег, будут автоматически кикнуты с клана.
|
||||
feeon=Участники клана теперь вносят комиссию на банковский счёт вашего клана. Участники, не имеющие достаточное количество денег, будут автоматически кикнуты с клана.
|
||||
home.base.only.once=База клана может быть установлена лишь один раз
|
||||
now.at.homebase=Вы сейчас находитесь на базе клана {0}
|
||||
hombase.set=База клана\: {0}
|
||||
@@ -436,7 +445,7 @@ rival.limit.reached=Вы достигли лимита войн, пока что
|
||||
you.moved.teleport.cancelled=Вы перемещены, телепортация отменена
|
||||
waiting.for.teleport.stand.still.for.0.seconds=Ожидание телепортирования, оставайтесь на месте ещё {0} секунд
|
||||
on=включить
|
||||
off=Выключить
|
||||
off=выключить
|
||||
leave=покинуть
|
||||
join=присоединиться
|
||||
mute=молчать
|
||||
@@ -521,7 +530,7 @@ gui.main.languageselector.lore.left.click=&7ЛКМ\: Посмотреть спи
|
||||
gui.main.languageselector.lore.right.click=&7ПКМ\: &bПомочь с переводом
|
||||
gui.main.other.commands.title=&fДругие команды
|
||||
gui.main.other.commands.lore=&7ЛКМ\: Посмотреть все команды клана
|
||||
gui.main.clan.list.title=&fСписок Кланов
|
||||
gui.main.clan.list.title=&fСписок кланов
|
||||
gui.main.clan.list.lore=&7ЛКМ\: Список всех кланов
|
||||
gui.main.reset.kdr.title=&fСбросить KDR
|
||||
gui.main.reset.kdr.lore.price=&7Цена\: &b{0}
|
||||
@@ -569,7 +578,7 @@ gui.clanlist.clan.lore.members=&7Участники\: &b{0}
|
||||
gui.coords.title=Координаты
|
||||
gui.coords.player.lore.distance=&7Расстояние\: &b{0}
|
||||
gui.coords.player.lore.coords=&7Координаты\: &b{0} {1} {2}
|
||||
gui.coords.player.lore.world=&fМир\: {0}
|
||||
gui.coords.player.lore.world=&7Мир\: &b{0}
|
||||
gui.invite.title=Пригласить игрока
|
||||
gui.invite.player.title=&f{0}
|
||||
gui.invite.player.price.lore=&7Цена\: &b{0}
|
||||
@@ -605,7 +614,7 @@ gui.clandetails.clan.lore.status=&7Статус\: &b{0}
|
||||
gui.clandetails.clan.lore.leaders=&7Лидеры\: &b{0}
|
||||
gui.clandetails.clan.lore.online.members=&7Участников онлайн\: &b{0}/{1}
|
||||
gui.clandetails.clan.lore.kdr=&7KDR\: &b{0}
|
||||
gui.clandetails.clan.lore.kill.totals=&7Убито всего\: &b[Враги\:{0} Нейтральные\:{1} Игроки\:{2}]
|
||||
gui.clandetails.clan.lore.kill.totals=&7Убито всего\: &b[Соперники\: {0} Нейтралы\: {1} Без клана\: {2}]
|
||||
gui.clandetails.clan.lore.deaths=&7Смертей\: &b{0}
|
||||
gui.clandetails.clan.lore.fee=&7Комиссия\: &b{0}, {1}$
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -629,11 +638,11 @@ gui.clandetails.home.title=&fДом
|
||||
gui.clandetails.home.lore.teleport.price=&7Цена телепортирования\: &b{0}
|
||||
gui.clandetails.home.lore.teleport=&7ЛКМ\: Телепортироваться на базу вашего клана
|
||||
gui.staffclandetails.home.lore.teleport=&7ЛКМ\: Телепорироваться на базу этого клана
|
||||
gui.clandetails.home.lore.clear=&7Кликните средней кнопкой мыши, чтобы очистить дом вашего клана
|
||||
gui.clandetails.home.lore.clear=&7СКМ\: Удалить точку базы вашего клана
|
||||
gui.clandetails.home.lore.set.price=&7Установить цену\: &b{0}
|
||||
gui.clandetails.home.lore.set=&7ПКМ\: Установить точку базы вашего клана
|
||||
gui.staffclandetails.home.lore.set=&7ПКМ\: Установить точку базы для этого клана
|
||||
gui.clandetails.regroup.title=&fПерегруппировать
|
||||
gui.clandetails.regroup.title=&fСозвать
|
||||
gui.clandetails.regroup.lore.price=&7Цена\: &b{0}
|
||||
gui.clandetails.regroup.lore.home=&7ЛКМ\: Телепортировать всех участников вашего клана на базу
|
||||
gui.clandetails.regroup.lore.me=&7ПКМ\: Телепортировать участников вашего клана к вам
|
||||
@@ -653,7 +662,7 @@ gui.clandetails.fee.status.lore=&7Статус\: &b{0}
|
||||
gui.clandetails.fee.value.lore=&7Значение\: &b{0}
|
||||
gui.clandetails.fee.toggle.lore=&7ЛКМ\: Изменить статус комиссии
|
||||
gui.clandetails.rank.title=&fРанг
|
||||
gui.clandetails.rank.lore=&7ЛКМ\: Посмотреть список рангов клана и их редактирование
|
||||
gui.clandetails.rank.lore=&7ЛКМ\: Посмотреть ранги клана и редактировать их
|
||||
gui.clandetails.verified.title=&fПодтвержден
|
||||
gui.clandetails.not.verified.title=&fНе подтвержден
|
||||
gui.clandetails.verify.price.lore=&7Цена\: &b{0}
|
||||
@@ -680,7 +689,7 @@ gui.playerdetails.player.lore.clan=&7Клан\: &b[{0}&b] {1}
|
||||
gui.playerdetails.player.lore.rank=&7Ранг\: &b{0}
|
||||
gui.playerdetails.player.lore.status=&7Статус\: &b{0}
|
||||
gui.playerdetails.player.lore.kdr=&7KDR\: &b{0}
|
||||
gui.playerdetails.player.lore.kill.totals=&7Убито всего\: &b[Враги\:{0} Нейтральные\:{1} Игроки\:{2}]
|
||||
gui.playerdetails.player.lore.kill.totals=&7Убито всего\: &b[Соперники\: {0} Нейтралы\: {1} Без клана\: {2}]
|
||||
gui.playerdetails.player.lore.deaths=&7Смертей\: &b{0}
|
||||
gui.playerdetails.player.lore.join.date=&7Дата вступления\: &b{0}
|
||||
gui.playerdetails.player.lore.last.seen=&7Был в сети\: &b{0}
|
||||
@@ -737,7 +746,7 @@ you.must.hold.a.banner=&cУ вас в руках должен быть флаг\
|
||||
you.changed.clan.banner=&bВы изменили флаг своего клана\!
|
||||
your.clan.already.verified=&cКлан уже подтвержден\!
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
clan.profile=\n&7Профиль клана &b%clan_name% &8-------------------------------------------\n \n &7Название\: &e[&8%clan_color_tag%&e] &b%clan_name%\n &7Описание\: &f%clan_description%\n &7Статус\: &f%clan_verified%\n &7Лидеры\: %clan_leaders%\n &7Участников онлайн\: &f%clan_online_count%&7/&f%clan_size%\n &7KDR\: &e%clan_kdr%\n &7Всего убийств\: &8[Соперников\: &f%clan_rival_kills%, &8Нейтральных\: &f%clan_neutral_kills%, &8Гражданских\:&f%clan_civilian_kills%&8]\n &7Смертей\: &f%clan_deaths%\n &7Комиссия\: &f%clan_fee_enabled%&7, &f%clan_fee_value% $\n &7Союзники\: &f%clan_allies%\n &7Соперники\: &f%clan_rivals%\n &7Основан\: &f%clan_founded%\n &7Неактивность клана\: &f%clan_inactive_days%&7/&f%clan_max_inactive_days% дня\n
|
||||
clan.profile=\n&7Профиль клана &b%clan_name% &8-------------------------------------------\n \n &7Название\: &e[&8%clan_color_tag%&e] &b%clan_name%\n &7Описание\: &f%clan_description%\n &7Статус\: &f%clan_verified%\n &7Лидеры\: %clan_leaders%\n &7Участников онлайн\: &f%clan_online_count%&7/&f%clan_size%\n &7KDR\: &e%clan_kdr%\n &7Всего убийств\: &8[Соперников\:&f%clan_rival_kills% &8Нейтральных\:&f%clan_neutral_kills% &8Гражданских\:&f%clan_civilian_kills%&8]\n &7Смерти\: &f%clan_deaths%\n &7Комиссия\: &f%clan_fee_enabled%&7, &f%clan_fee_value% $\n &7Союзники\: &f%clan_allies%\n &7Враги\: &f%clan_rivals%\n &7Основан\: &f%clan_founded%\n &7Неактивно\: &f%clan_inactive_days%&7/&f%clan_max_inactive_days% дня\n
|
||||
player.lookup.clanname=&e[&8%clan_color_tag%&e] &b%clan_name%
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
player.lookup.killtype=&7Тип убийства\: %player_kill_type%\n
|
||||
@@ -753,4 +762,4 @@ cannot.attack.clan.member=&cВы не можете атаковать участ
|
||||
cannot.attack.ally=&cВы не можете атаковать союзников\!
|
||||
cannot.change.member.fee.now=&cИзменить комиссию участника клана невозможно, так как приближается время её сбора
|
||||
cannot.change.member.fee.hours=&cПовторите попытку через {0} часов...
|
||||
cannot.change.member.fee.minutes=&cПовторите попытку через {0} минут(ы)...
|
||||
cannot.change.member.fee.minutes=&cПовторите попытку через {0} минут(ы)...
|
||||
@@ -36,4 +36,5 @@ reload.command=omladda
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -140,7 +140,7 @@ inviting.you.to.join={0} seni klana katılmaya davet ediyor {1}
|
||||
asking.for.the.deletion={0} Klanın silinmesini istiyor
|
||||
asking.for.the.promotion={0} Promosyonunu istiyor {1}
|
||||
asking.for.the.demotion={0} düşmanı istiyor {1}
|
||||
accept.or.deny={0} veya {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=Hesabınızda yeterli para yok
|
||||
account.has.been.debited={0} Hesabınız borçlandırıldı
|
||||
mysql.connection.successful=MySQL bağlantısı başarılı
|
||||
|
||||
@@ -43,4 +43,5 @@ help.command=допомогу
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -115,7 +115,7 @@ inviting.you.to.join={0} 邀请您加入 {1}
|
||||
asking.for.the.deletion={0} 正在请求删除帮派
|
||||
asking.for.the.promotion={0} 正在请求 {1} 的提升
|
||||
asking.for.the.demotion={0} 正在请求 {1} 的降级
|
||||
accept.or.deny={0} 或 {1}
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
not.sufficient.money=您的账户没有足够的资金
|
||||
account.has.been.debited=你的账户已经被扣除了 {0}
|
||||
mysql.connection.successful=MySQL 连接成功
|
||||
|
||||
@@ -62,4 +62,5 @@ command.description.accept=接受請求
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
# suppress inspection "TrailingSpacesInProperty"
|
||||
@@ -1,15 +1,13 @@
|
||||
name: SimpleClans
|
||||
main: net.sacredlabyrinth.phaed.simpleclans.SimpleClans
|
||||
version: '${project.version}'
|
||||
softdepend: [VanishNoPacket, Permissions, PermissionsBukkit, Vault, PermissionsEx, mChat, mChatSuite, PlaceholderAPI]
|
||||
softdepend: [VanishNoPacket, Permissions, PermissionsBukkit, Vault, PermissionsEx, mChat, mChatSuite, PlaceholderAPI, LuckPerms]
|
||||
api-version: '1.13'
|
||||
authors:
|
||||
- Phaed
|
||||
- RoinujNosde
|
||||
website: https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
permissions:
|
||||
simpleclans.admin.permissions:
|
||||
description: Can grant clans permissions
|
||||
simpleclans.admin.reload:
|
||||
description: Can reload configuration
|
||||
simpleclans.admin.purge:
|
||||
@@ -28,12 +26,10 @@ permissions:
|
||||
description: Can ban players from the entire plugin
|
||||
simpleclans.mod.disband:
|
||||
description: Can disband any clan
|
||||
simpleclans.mod.kick:
|
||||
description: Can kick any player
|
||||
simpleclans.mod.globalff:
|
||||
description: Can turn off global friendly fire protection
|
||||
simpleclans.mod.nohide:
|
||||
description: Messages from these players cannot be hidden via chat commands
|
||||
simpleclans.mod.home:
|
||||
description: Can set other clan's home
|
||||
simpleclans.mod.hometp:
|
||||
description: Can teleport to all clans homes
|
||||
simpleclans.mod.bypass:
|
||||
@@ -109,14 +105,10 @@ permissions:
|
||||
description: Can modify his clan's tag
|
||||
simpleclans.leader.description:
|
||||
description: Can modify his clan's description
|
||||
simpleclans.leader.cape:
|
||||
description: Can set his clan's cape url
|
||||
simpleclans.leader.bb-clear:
|
||||
description: Can clear his clan's bb
|
||||
simpleclans.leader.setbanner:
|
||||
description: Can set his clan's banner
|
||||
simpleclans.member.cape-toggle:
|
||||
description: Can toggle his cape on/off
|
||||
simpleclans.member.kills:
|
||||
description: Can view his and other's kills
|
||||
simpleclans.member.tag-toggle:
|
||||
@@ -129,6 +121,8 @@ permissions:
|
||||
description: Can keep items when teleporting home
|
||||
simpleclans.mod.place:
|
||||
description: Can manually place players in clans
|
||||
simpleclans.mod.modtag:
|
||||
description: Can change a clan's tag
|
||||
simpleclans.mod.staffgui:
|
||||
description: Can open the staff gui
|
||||
simpleclans.leader.fee:
|
||||
@@ -151,8 +145,6 @@ permissions:
|
||||
description: Can set trust levels for members
|
||||
simpleclans.leader.war:
|
||||
description: Can start wars
|
||||
simpleclans.leader.setrank:
|
||||
description: Can set ranks
|
||||
simpleclans.leader.coloredrank:
|
||||
description: Can set colored ranks
|
||||
default: true
|
||||
@@ -178,6 +170,10 @@ permissions:
|
||||
description: Can remove permissions from a rank
|
||||
simpleclans.leader.rank.setdisplayname:
|
||||
description: Can set the rank displayname
|
||||
simpleclans.leader.rank.setdefault:
|
||||
description: Can set the default rank
|
||||
simpleclans.leader.rank.removedefault:
|
||||
description: Can remove the default rank
|
||||
simpleclans.member.bank:
|
||||
description: Can use banks
|
||||
simpleclans.admin.*:
|
||||
@@ -196,6 +192,7 @@ permissions:
|
||||
simpleclans.mod.verify: true
|
||||
simpleclans.mod.ban: true
|
||||
simpleclans.mod.disband: true
|
||||
simpleclans.mod.kick: true
|
||||
simpleclans.mod.globalff: true
|
||||
simpleclans.mod.bypass: true
|
||||
simpleclans.mod.home: true
|
||||
@@ -204,6 +201,7 @@ permissions:
|
||||
simpleclans.mod.nopvpinwar: true
|
||||
simpleclans.mod.place: true
|
||||
simpleclans.mod.staffgui: true
|
||||
simpleclans.mod.modtag: true
|
||||
simpleclans.anyone.*:
|
||||
description: Permissions for anyone
|
||||
default: true
|
||||
@@ -269,6 +267,8 @@ permissions:
|
||||
simpleclans.leader.coloredrank: true
|
||||
simpleclans.leader.bb-clear: true
|
||||
simpleclans.leader.rank.setdisplayname: true
|
||||
simpleclans.leader.rank.setdefault: true
|
||||
simpleclans.leader.rank.removedefault: true
|
||||
simpleclans.leader.rank.list: true
|
||||
simpleclans.leader.rank.create: true
|
||||
simpleclans.leader.rank.assign: true
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class ChatUtilsTest {
|
||||
|
||||
@Test
|
||||
void getLastColors() {
|
||||
String lastColors = ChatUtils.getLastColors("§aa mensagem§x termina com §4vermelho");
|
||||
assertEquals("§4", lastColors);
|
||||
lastColors = ChatUtils.getLastColors("§aa mensagem§x termina com §a§4vermelho");
|
||||
assertEquals("§a§4", lastColors);
|
||||
lastColors = ChatUtils.getLastColors("§aa mensagem§x termina com §a§4ver§fmel§§§§§§§§§§ho");
|
||||
assertEquals("§f", lastColors);
|
||||
lastColors = ChatUtils.getLastColors("§aa mensagem§x termina com");
|
||||
assertEquals("§x", lastColors);
|
||||
lastColors = ChatUtils.getLastColors("§aa mensagem§ ax termina com");
|
||||
assertEquals("§a", lastColors);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class UpdateCheckerTest {
|
||||
|
||||
@Test
|
||||
void compareVersions() {
|
||||
assertEquals(UpdateChecker.compareVersions("0.0", "0"), 0);
|
||||
assertTrue(UpdateChecker.compareVersions("0.1", "0") > 0);
|
||||
assertTrue(UpdateChecker.compareVersions("1", "1.1.1") < 0);
|
||||
assertTrue(UpdateChecker.compareVersions("1.1", "1") > 0);
|
||||
assertTrue(UpdateChecker.compareVersions("1", "0") > 0);
|
||||
assertEquals(UpdateChecker.compareVersions("1.0.0", "1"), 0);
|
||||
assertEquals(UpdateChecker.compareVersions("1.0", "1"), 0);
|
||||
assertEquals(UpdateChecker.compareVersions("1.0.0", "1.0"), 0);
|
||||
assertEquals(UpdateChecker.compareVersions("1.0.0", "1.0.0"), 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.utils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class WordWrapperTest {
|
||||
|
||||
@Test
|
||||
void wrap() {
|
||||
String[] wrap = new WordWrapper("a§aa", 2).wrap();
|
||||
assertArrayEquals(new String[] {"§fa§aa"}, wrap);
|
||||
wrap = new WordWrapper("a§aa a§aa", 2).wrap();
|
||||
assertArrayEquals(new String[] {"§fa§aa", "§aa§aa"}, wrap);
|
||||
}
|
||||
|
||||
@Test
|
||||
void split() {
|
||||
String s = "§x§f§f§f§f§f§f";
|
||||
List<String> split = WordWrapper.split(s, 1);
|
||||
assertEquals(1, split.size());
|
||||
assertLinesMatch(Collections.singletonList("§x§f§f§f§f§f§f"), split);
|
||||
s = "§x§f§f§f§f§f§faa";
|
||||
split = WordWrapper.split(s, 1);
|
||||
assertEquals(2, split.size());
|
||||
assertLinesMatch(Arrays.asList("§x§f§f§f§f§f§fa", "a"), split);
|
||||
s = "§x§fa§tfa§fa§f§f§faa";
|
||||
split = WordWrapper.split(s, 3);
|
||||
assertEquals(3, split.size());
|
||||
assertLinesMatch(Arrays.asList("§x§fa§t", "fa§fa", "§f§f§faa"), split);
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 4.5 MiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 4.5 MiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 18 KiB |