From 01913e72861667810b9ddaaa110fd300d33e9c29 Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Tue, 5 May 2020 18:30:09 +0300 Subject: [PATCH 1/8] Fixed an internal error. Player wasn't being removed from teleportRange after a failed teleportation. --- src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java index c0b0ba8d..a97ea2a3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java +++ b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java @@ -75,6 +75,7 @@ public class CmdWild extends FCommand implements WaitedTask { } if (!success) { p.sendMessage(TL.COMMAND_WILD_FAILED.toString()); + teleportRange.remove(p); } } @@ -114,6 +115,7 @@ public class CmdWild extends FCommand implements WaitedTask { @Override public void handleFailure(Player player) { player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString()); + teleportRange.remove(player); } } From 7fc1ad19adfffdeedb69aaa39dedc450af1d8652 Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Tue, 5 May 2020 18:32:50 +0300 Subject: [PATCH 2/8] Fixed an internal error. Trying to send a message without enough arguments. --- src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java index a97ea2a3..6a5d556d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java +++ b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java @@ -46,8 +46,6 @@ public class CmdWild extends FCommand implements WaitedTask { public void perform(CommandContext context) { if (!teleportRange.containsKey(context.player)) { context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory()); - } else { - context.fPlayer.msg(TL.COMMAND_WILD_WAIT); } } From 04273de995f71b9ed3ac51650b13a1c25de7d770 Mon Sep 17 00:00:00 2001 From: BrowkS Date: Wed, 6 May 2020 12:36:24 +0300 Subject: [PATCH 3/8] Removed an unnecessary check --- src/main/java/com/massivecraft/factions/tag/FactionTag.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/tag/FactionTag.java b/src/main/java/com/massivecraft/factions/tag/FactionTag.java index fda5a663..c799e47b 100644 --- a/src/main/java/com/massivecraft/factions/tag/FactionTag.java +++ b/src/main/java/com/massivecraft/factions/tag/FactionTag.java @@ -149,10 +149,7 @@ public enum FactionTag implements Tag { if (!this.foundInString(text)) { return text; } - String result = null; - if (this.biFunction != null) { - result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction); - } + String result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction); return result == null ? null : text.replace(this.tag, result); } From 55fd5ffdfd9f375d05145dd34099cdc731c574f5 Mon Sep 17 00:00:00 2001 From: BrowkS Date: Wed, 6 May 2020 13:07:16 +0300 Subject: [PATCH 4/8] Added {player-role} placeholder. --- src/main/java/com/massivecraft/factions/tag/PlayerTag.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/massivecraft/factions/tag/PlayerTag.java b/src/main/java/com/massivecraft/factions/tag/PlayerTag.java index c5b7d316..30a3a780 100644 --- a/src/main/java/com/massivecraft/factions/tag/PlayerTag.java +++ b/src/main/java/com/massivecraft/factions/tag/PlayerTag.java @@ -21,6 +21,7 @@ public enum PlayerTag implements Tag { }), PLAYER_BALANCE("{balance}", (fp) -> Econ.isSetup() ? Econ.getFriendlyBalance(fp) : (Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance"))), PLAYER_POWER("{player-power}", (fp) -> String.valueOf(fp.getPowerRounded())), + ROLE("{player-role}", FPlayer::getRolePrefix), PLAYER_MAXPOWER("{player-maxpower}", (fp) -> String.valueOf(fp.getPowerMaxRounded())), PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())), PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())), From bf2352130939de82583e9b9977c3165e6f1d1308 Mon Sep 17 00:00:00 2001 From: BrowkS Date: Wed, 6 May 2020 22:32:40 +0300 Subject: [PATCH 5/8] Sending join message to faction members after setting player's faction and role. --- src/main/java/com/massivecraft/factions/cmd/CmdJoin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index c69dc745..5bad4de5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -115,8 +115,6 @@ public class CmdJoin extends FCommand { fplayer.msg(TL.COMMAND_JOIN_MOVED, context.fPlayer.describeTo(fplayer, true), faction.getTag(fplayer)); } - faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true)); - fplayer.resetFactionData(); if (faction.altInvited(fplayer)) { @@ -144,6 +142,8 @@ public class CmdJoin extends FCommand { System.out.print(e.getMessage()); } + faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true)); + if (Conf.logFactionJoin) { if (samePlayer) { FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag()); From 541e1fc69bb6bdcb796403180f3ba20b8152b5f7 Mon Sep 17 00:00:00 2001 From: BrowkS Date: Thu, 7 May 2020 22:36:39 +0300 Subject: [PATCH 6/8] Fixed issue - ignoring "useDisbandGui" if the player is not an OP --- src/main/java/com/massivecraft/factions/cmd/CmdDisband.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index 0fc36239..6010810d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -82,7 +82,7 @@ public class CmdDisband extends FCommand { } if (!access) { - if (Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) { + if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) { if (!disbandMap.containsKey(context.player.getUniqueId().toString())) { new FDisbandFrame(context.faction).buildGUI(context.fPlayer); return; From 868e7f4102e8d54ce6904a1b2cabcae3d32ad37d Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Fri, 8 May 2020 20:27:03 +0300 Subject: [PATCH 7/8] Method weren't formatting both color and style to the same text. --- .../factions/zcore/util/TextUtil.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java index 95509f98..1b271c0d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java @@ -47,33 +47,41 @@ public class TextUtil { String text = ""; FancyMessage message = new FancyMessage(text); ChatColor color = null; + ChatColor style = null; char[] chars = first.toCharArray(); for (int i = 0; i < chars.length; i++) { // changed this so javadocs wont throw an error String compareChar = chars[i] + ""; if (compareChar.equals("ยง")) { - if (color != null) { - if (color.isColor()) { - message.then(text).color(color); - } else { - message.then(text).style(color); + if (color != null || style != null) { + message.then(text); + if (color != null) + message.color(color); + if (style != null) { + message.style(style); + style = null; } text = ""; } - color = ChatColor.getByChar(chars[i + 1]); + ChatColor tempColor = ChatColor.getByChar(chars[i + 1]); + if (tempColor.isColor()) { + color = tempColor; + } else { + style = tempColor; + } i++; // skip color char } else { text += chars[i]; } } if (text.length() > 0) { - if (color != null) { - if (color.isColor()) { - message.then(text).color(color); - } else { - message.then(text).style(color); - } + if (color != null || style != null) { + message.then(text); + if (color != null) + message.color(color); + if (style != null) + message.style(style); } else { message.text(text); } From 5fb8d06d98501818eb526cd894fd10ac38032b94 Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Fri, 8 May 2020 20:29:54 +0300 Subject: [PATCH 8/8] Fixed the asynchronous command dispatch issue. The issue was being thrown on PaperSpigot and its forks. --- .../massivecraft/factions/cmd/CmdShow.java | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index ce7354a6..43204fc8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -8,9 +8,11 @@ import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TagReplacer; import com.massivecraft.factions.zcore.util.TagUtil; import mkremins.fanciful.FancyMessage; +import org.bukkit.scheduler.BukkitScheduler; import java.util.ArrayList; import java.util.List; +import java.util.Objects; public class CmdShow extends FCommand { @@ -24,17 +26,21 @@ public class CmdShow extends FCommand { this.aliases.addAll(Aliases.show_show); // add defaults to /f show in case config doesnt have it - defaults.add("{header}"); - defaults.add("Description: {description}"); - defaults.add("Joining: {joining} {peaceful}"); - defaults.add("Land / Power / Maxpower: {chunks} / {power} / {maxPower}"); - defaults.add("Founded: {create-date}"); - defaults.add("This faction is permanent, remaining even with no members."); - defaults.add("Land value: {land-value} {land-refund}"); - defaults.add("Balance: {faction-balance}"); - defaults.add("Allies({allies}/{max-allies}): {allies-list}"); - defaults.add("Online: ({online}/{members}): {online-list}"); - defaults.add("Offline: ({offline}/{members}): {offline-list}"); + defaults.add("&8&m--------------&7 &8<&e{faction}&8> &8&m--------------"); + defaults.add("&4* &cOwner: &f{leader}"); + defaults.add("&4* &cDescription: &f{description}"); + defaults.add("&4* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}"); + defaults.add("&4* &cFaction Strikes: &f{strikes}"); + defaults.add("&4* &cFaction Points: &f{faction-points}"); + defaults.add("&4* &cFounded: &f{create-date}"); + defaults.add("&4* &cBalance: &f{faction-balance}"); + defaults.add("&4* &cAllies: &a{allies-list}"); + defaults.add("&4* &cEnemies: &4{enemies-list}"); + defaults.add("&4* &cOnline Members: &8[&f{online}/{members}&8] &a{online-list}"); + defaults.add("&4* &cOffline Members: &8[&f{offline}/{members}&8] &a{offline-list}"); + defaults.add("&4* &cAlts: &f{alts}"); + defaults.add("&4* &cBans: &f{faction-bancount}"); + defaults.add("&8&m----------------------------------------"); // this.requiredArgs.add(""); this.optionalArgs.put("faction tag", "yours"); @@ -45,6 +51,7 @@ public class CmdShow extends FCommand { @Override public void perform(CommandContext context) { Faction faction = context.faction; + FactionsPlugin instance = FactionsPlugin.getInstance(); if (context.argIsSet(0)) faction = context.argAsFaction(0); @@ -52,7 +59,7 @@ public class CmdShow extends FCommand { return; if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt") - && FactionsPlugin.getInstance().getConfig().getStringList("show-exempt").contains(faction.getTag())) { + && instance.getConfig().getStringList("show-exempt").contains(faction.getTag())) { context.msg(TL.COMMAND_SHOW_EXEMPT); return; } @@ -62,7 +69,7 @@ public class CmdShow extends FCommand { return; } - List show = FactionsPlugin.getInstance().getConfig().getStringList("show"); + List show = instance.getConfig().getStringList("show"); if (show == null || show.isEmpty()) show = defaults; @@ -71,16 +78,17 @@ public class CmdShow extends FCommand { // send header and that's all String header = show.get(0); if (TagReplacer.HEADER.contains(header)) { - context.msg(FactionsPlugin.getInstance().txt.titleize(tag)); + context.msg(instance.txt.titleize(tag)); } else { - context.msg(FactionsPlugin.getInstance().txt.parse(TagReplacer.FACTION.replace(header, tag))); + context.msg(instance.txt.parse(TagReplacer.FACTION.replace(header, tag))); } return; // we only show header for non-normal factions } List finalShow = show; Faction finalFaction = faction; - FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> { + List fancy = new ArrayList<>(); + instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> { for (String raw : finalShow) { String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations if (parsed == null) { @@ -92,9 +100,9 @@ public class CmdShow extends FCommand { } if (TagUtil.hasFancy(parsed)) { - List fancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed); - if (fancy != null) - context.sendFancyMessage(fancy); + List localFancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed); + if (localFancy != null) + fancy.addAll(localFancy); continue; } @@ -106,9 +114,12 @@ public class CmdShow extends FCommand { if (parsed.contains("%")) { parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. } - context.msg(FactionsPlugin.getInstance().txt.parse(parsed)); + parsed = FactionsPlugin.getInstance().txt.parse(parsed); + FancyMessage localFancy = instance.txt.parseFancy(parsed); + fancy.add(localFancy); } } + instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); }); }