mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-05 09:10:14 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f34b947e59 |
No files matched your search
+12
-3
@@ -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,7 +4,7 @@
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.14.3</version>
|
||||
<version>2.14.4.1</version>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
@@ -130,7 +130,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.5</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>
|
||||
|
||||
@@ -24,6 +24,8 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
private int homeX = 0;
|
||||
private int homeY = 0;
|
||||
private int homeZ = 0;
|
||||
private String homeWorld = "";
|
||||
private float homeYaw = 0;
|
||||
private float homePitch = 0;
|
||||
private @Nullable String homeWorld = "";
|
||||
private boolean allowWithdraw = false;
|
||||
private boolean allowDeposit = true;
|
||||
private boolean feeEnabled;
|
||||
@@ -1633,6 +1637,8 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
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();
|
||||
@@ -1674,16 +1680,19 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
if (flag.equals("homeZ")) {
|
||||
homeZ = ((Long) flags.get(flag)).intValue();
|
||||
}
|
||||
|
||||
if (flag.equals("homeYaw")) {
|
||||
homeYaw = ((Double) flags.get(flag)).floatValue();
|
||||
}
|
||||
if (flag.equals("homePitch")) {
|
||||
homePitch = ((Double) 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,6 +1719,8 @@ 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);
|
||||
@@ -1717,7 +1728,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
homeX = home.getBlockX();
|
||||
homeY = home.getBlockY();
|
||||
homeZ = home.getBlockZ();
|
||||
homeWorld = home.getWorld().getName();
|
||||
homeYaw = home.getYaw();
|
||||
homePitch = home.getPitch();
|
||||
homeWorld = home.getWorld() == null ? null : home.getWorld().getName();
|
||||
}
|
||||
SimpleClans.getInstance().getStorageManager().updateClan(this);
|
||||
}
|
||||
@@ -1736,9 +1749,9 @@ public class Clan implements Serializable, Comparable<Clan> {
|
||||
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);
|
||||
return new Location(world, homeX, world.getHighestBlockYAt(homeX, homeZ), homeZ, homeYaw, homePitch);
|
||||
} else {
|
||||
return new Location(world, homeX, homeY, homeZ);
|
||||
return new Location(world, homeX, homeY, homeZ, homeYaw, homePitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -202,7 +204,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 +378,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 +517,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 +819,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 +831,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 +858,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);
|
||||
|
||||
|
||||
@@ -9,10 +9,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;
|
||||
@@ -249,7 +249,7 @@ 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()) {
|
||||
return message;
|
||||
|
||||
@@ -216,6 +216,6 @@ 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");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+45
-13
@@ -6,12 +6,14 @@ 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.TagValidator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -41,7 +43,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")
|
||||
@@ -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", Helper.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) {
|
||||
@@ -186,7 +218,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 +234,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%purge")
|
||||
@Subcommand("%admin %purge")
|
||||
@CommandPermission("simpleclans.admin.purge")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.purge}")
|
||||
@@ -220,7 +252,7 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("player.purged", sender));
|
||||
}
|
||||
|
||||
@Subcommand("%disband")
|
||||
@Subcommand("%mod %disband")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandPermission("simpleclans.mod.disband")
|
||||
@Description("{@@command.description.mod.disband}")
|
||||
@@ -267,7 +299,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 +309,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;
|
||||
|
||||
|
||||
@@ -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}")) {
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
@@ -86,20 +86,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 +162,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),"
|
||||
@@ -1062,15 +1062,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 +1081,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 +1115,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,7 @@ 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)
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
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 net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.appendLegacy(split[i]);
|
||||
if (i >= placeholders.size()) {
|
||||
continue;
|
||||
}
|
||||
appendPlaceholder(receiver, builder, placeholders.get(i));
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
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).appendLegacy(lang("clickable." + placeholder, receiver))
|
||||
.event(new ClickEvent(RUN_COMMAND, "/" + placeholder))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(lang("hover.click.to." + placeholder,
|
||||
receiver))));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,6 +49,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
|
||||
@@ -209,6 +210,7 @@ leader=leader
|
||||
roster=roster
|
||||
trusted=trusted
|
||||
untrusted=untrusted
|
||||
in.rank=in rank
|
||||
deaths=Deaths
|
||||
weights=Weights
|
||||
stats=stats
|
||||
@@ -256,7 +258,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 +356,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}
|
||||
|
||||
@@ -8,8 +8,6 @@ authors:
|
||||
- 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:
|
||||
@@ -30,10 +28,6 @@ permissions:
|
||||
description: Can disband any clan
|
||||
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 +103,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 +119,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 +143,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
|
||||
@@ -204,6 +194,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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user