2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.Faction;
|
2015-05-13 03:34:00 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-10-09 18:35:39 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2015-01-22 00:58:33 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2015-05-13 03:34:00 +02:00
|
|
|
import com.massivecraft.factions.zcore.util.TagReplacer;
|
|
|
|
import com.massivecraft.factions.zcore.util.TagUtil;
|
2018-02-17 19:17:37 +01:00
|
|
|
import me.clip.placeholderapi.PlaceholderAPI;
|
2015-05-25 22:46:18 +02:00
|
|
|
import mkremins.fanciful.FancyMessage;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-11-17 20:16:58 +01:00
|
|
|
import java.util.ArrayList;
|
2014-12-15 00:24:25 +01:00
|
|
|
import java.util.List;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
public class CmdShow extends FCommand {
|
2015-05-13 03:34:00 +02:00
|
|
|
|
2017-12-19 11:18:13 +01:00
|
|
|
List<String> defaults = new ArrayList<>();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
public CmdShow() {
|
2014-07-01 22:10:18 +02:00
|
|
|
this.aliases.add("show");
|
|
|
|
this.aliases.add("who");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2015-05-13 03:34:00 +02:00
|
|
|
// add defaults to /f show in case config doesnt have it
|
|
|
|
defaults.add("{header}");
|
|
|
|
defaults.add("<a>Description: <i>{description}");
|
|
|
|
defaults.add("<a>Joining: <i>{joining} {peaceful}");
|
|
|
|
defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}");
|
|
|
|
defaults.add("<a>Founded: <i>{create-date}");
|
|
|
|
defaults.add("<a>This faction is permanent, remaining even with no members.");
|
|
|
|
defaults.add("<a>Land value: <i>{land-value} {land-refund}");
|
2017-12-19 09:37:17 +01:00
|
|
|
defaults.add("<a>Balance: <i>{faction-balance}");
|
2015-05-13 03:34:00 +02:00
|
|
|
defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}");
|
|
|
|
defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}");
|
|
|
|
defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}");
|
|
|
|
|
2015-01-03 01:19:57 +01:00
|
|
|
// this.requiredArgs.add("");
|
2014-04-04 20:55:21 +02:00
|
|
|
this.optionalArgs.put("faction tag", "yours");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.SHOW.node;
|
|
|
|
this.disableOnLock = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
|
|
|
senderMustBeAdmin = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
Faction faction = myFaction;
|
|
|
|
if (this.argIsSet(0)) {
|
|
|
|
faction = this.argAsFaction(0);
|
2015-05-07 17:39:04 +02:00
|
|
|
}
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
2016-12-17 00:16:42 +01:00
|
|
|
}
|
|
|
|
|
2018-01-05 03:10:49 +01:00
|
|
|
if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")
|
2016-12-17 00:16:42 +01:00
|
|
|
&& P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) {
|
|
|
|
msg(TL.COMMAND_SHOW_EXEMPT);
|
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2015-05-13 03:34:00 +02:00
|
|
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
2015-01-22 00:58:33 +01:00
|
|
|
if (!payForCommand(Conf.econCostShow, TL.COMMAND_SHOW_TOSHOW, TL.COMMAND_SHOW_FORSHOW)) {
|
2014-12-30 05:02:18 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-13 03:34:00 +02:00
|
|
|
List<String> show = P.p.getConfig().getStringList("show");
|
|
|
|
if (show == null || show.isEmpty()) {
|
|
|
|
show = defaults;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2015-05-13 03:34:00 +02:00
|
|
|
if (!faction.isNormal()) {
|
|
|
|
String tag = faction.getTag(fme);
|
|
|
|
// send header and that's all
|
|
|
|
String header = show.get(0);
|
|
|
|
if (TagReplacer.HEADER.contains(header)) {
|
|
|
|
msg(p.txt.titleize(tag));
|
|
|
|
} else {
|
|
|
|
msg(p.txt.parse(TagReplacer.FACTION.replace(header, tag)));
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
2015-05-13 03:34:00 +02:00
|
|
|
return; // we only show header for non-normal factions
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|
2014-11-17 21:30:41 +01:00
|
|
|
|
2015-05-13 03:34:00 +02:00
|
|
|
for (String raw : show) {
|
|
|
|
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
|
2015-08-06 23:59:54 +02:00
|
|
|
if (parsed == null) {
|
|
|
|
continue; // Due to minimal f show.
|
|
|
|
}
|
2018-02-17 19:17:37 +01:00
|
|
|
|
|
|
|
parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed);
|
|
|
|
|
2015-05-25 22:46:18 +02:00
|
|
|
if (TagUtil.hasFancy(parsed)) {
|
|
|
|
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
|
|
|
|
if (fancy != null) {
|
|
|
|
sendFancyMessage(fancy);
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
2015-05-13 03:34:00 +02:00
|
|
|
continue;
|
2014-11-17 21:30:41 +01:00
|
|
|
}
|
2015-05-13 03:34:00 +02:00
|
|
|
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();
|
|
|
|
}
|
2015-08-06 23:59:54 +02:00
|
|
|
if (parsed.contains("%")) {
|
2015-08-06 23:09:07 +02:00
|
|
|
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
|
|
|
|
}
|
2015-05-13 03:34:00 +02:00
|
|
|
msg(p.txt.parse(parsed));
|
2014-12-11 05:32:47 +01:00
|
|
|
}
|
|
|
|
}
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_SHOW_COMMANDDESCRIPTION;
|
|
|
|
}
|
2015-02-26 15:58:09 +01:00
|
|
|
|
2015-01-02 20:38:35 +01:00
|
|
|
}
|