From c22e3a52270fd38637a7afb8340041fc069806c7 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 19 May 2020 06:22:09 -0400 Subject: [PATCH] F Show Async Calling --- .../massivecraft/factions/cmd/CmdShow.java | 60 ++++++++++--------- .../cmd/relational/FRelationCommand.java | 6 +- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index d1c0b62e..6de26d8a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -84,37 +84,41 @@ public class CmdShow extends FCommand { } List fancy = new ArrayList<>(); - for (String raw : show) { - String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations - if (parsed == null) { - continue; // Due to minimal f show. - } - - if (context.fPlayer != null) { - parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); - } - - if (TagUtil.hasFancy(parsed)) { - List localFancy = TagUtil.parseFancy(faction, context.fPlayer, parsed); - if (localFancy != null) - fancy.addAll(localFancy); - - continue; - } - if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { - if (parsed.contains("{ig}")) { - // replaces all variables with no home TL - parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); + List finalShow = show; + Faction finalFaction = faction; + instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> { + for (String raw : finalShow) { + String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations + if (parsed == null) { + continue; // Due to minimal f show. } - if (parsed.contains("%")) { - parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. + + if (context.fPlayer != null) { + parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); + } + + if (TagUtil.hasFancy(parsed)) { + List localFancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed); + if (localFancy != null) + fancy.addAll(localFancy); + + continue; + } + if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) { + if (parsed.contains("{ig}")) { + // replaces all variables with no home TL + parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); + } + if (parsed.contains("%")) { + parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. + } + parsed = FactionsPlugin.getInstance().txt.parse(parsed); + FancyMessage localFancy = instance.txt.parseFancy(parsed); + fancy.add(localFancy); } - parsed = FactionsPlugin.getInstance().txt.parse(parsed); - FancyMessage localFancy = instance.txt.parseFancy(parsed); - fancy.add(localFancy); } - } - instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); + instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); + }); } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java index f39a7044..37274b7a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java @@ -39,9 +39,9 @@ public abstract class FRelationCommand extends FCommand { @Override public void perform(CommandContext context) { Faction them = context.argAsFaction(0); - if (them == null) { - return; - } + if (them == null) return; + + if(!context.faction.isNormal()) return; if (!them.isNormal()) { context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE);