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)); }); }