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<>();
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<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();
List<String> 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<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

View File

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