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; 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()); 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)); }); } 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..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); } } @@ -75,6 +73,7 @@ public class CmdWild extends FCommand implements WaitedTask { } if (!success) { p.sendMessage(TL.COMMAND_WILD_FAILED.toString()); + teleportRange.remove(p); } } @@ -114,6 +113,7 @@ public class CmdWild extends FCommand implements WaitedTask { @Override public void handleFailure(Player player) { player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString()); + teleportRange.remove(player); } } 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); } 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())), 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); }