F Show Async Calling

This commit is contained in:
Driftay 2020-05-19 06:22:09 -04:00
parent 7d3c4d6e33
commit c22e3a5227
2 changed files with 35 additions and 31 deletions

View File

@ -84,37 +84,41 @@ public class CmdShow extends FCommand {
} }
List<FancyMessage> fancy = new ArrayList<>(); List<FancyMessage> fancy = new ArrayList<>();
for (String raw : show) { List<String> finalShow = show;
String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations Faction finalFaction = faction;
if (parsed == null) { instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> {
continue; // Due to minimal f show. for (String raw : finalShow) {
} String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
if (parsed == null) {
if (context.fPlayer != null) { continue; // Due to minimal f show.
parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed);
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> 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();
} }
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<FancyMessage> 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 @Override

View File

@ -39,9 +39,9 @@ public abstract class FRelationCommand extends FCommand {
@Override @Override
public void perform(CommandContext context) { public void perform(CommandContext context) {
Faction them = context.argAsFaction(0); Faction them = context.argAsFaction(0);
if (them == null) { if (them == null) return;
return;
} if(!context.faction.isNormal()) return;
if (!them.isNormal()) { if (!them.isNormal()) {
context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE); context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE);