commit
2f18da3cfb
@ -82,7 +82,7 @@ public class CmdDisband extends FCommand {
|
||||
}
|
||||
|
||||
if (!access) {
|
||||
if (Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) {
|
||||
if (Conf.useDisbandGUI && (!context.fPlayer.isAdminBypassing() || !context.player.isOp())) {
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||
return;
|
||||
|
@ -115,8 +115,6 @@ public class CmdJoin extends FCommand {
|
||||
fplayer.msg(TL.COMMAND_JOIN_MOVED, context.fPlayer.describeTo(fplayer, true), faction.getTag(fplayer));
|
||||
}
|
||||
|
||||
faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true));
|
||||
|
||||
fplayer.resetFactionData();
|
||||
|
||||
if (faction.altInvited(fplayer)) {
|
||||
@ -144,6 +142,8 @@ public class CmdJoin extends FCommand {
|
||||
System.out.print(e.getMessage());
|
||||
}
|
||||
|
||||
faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true));
|
||||
|
||||
if (Conf.logFactionJoin) {
|
||||
if (samePlayer) {
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());
|
||||
|
@ -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("<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}");
|
||||
defaults.add("<a>Balance: <i>{faction-balance}");
|
||||
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}");
|
||||
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<String> show = FactionsPlugin.getInstance().getConfig().getStringList("show");
|
||||
List<String> 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<String> finalShow = show;
|
||||
Faction finalFaction = faction;
|
||||
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
|
||||
List<FancyMessage> 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<FancyMessage> fancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
|
||||
if (fancy != null)
|
||||
context.sendFancyMessage(fancy);
|
||||
List<FancyMessage> 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));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,6 @@ public class CmdWild extends FCommand implements WaitedTask {
|
||||
public void perform(CommandContext context) {
|
||||
if (!teleportRange.containsKey(context.player)) {
|
||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
||||
} else {
|
||||
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +73,7 @@ public class CmdWild extends FCommand implements WaitedTask {
|
||||
}
|
||||
if (!success) {
|
||||
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
|
||||
teleportRange.remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,6 +113,7 @@ public class CmdWild extends FCommand implements WaitedTask {
|
||||
@Override
|
||||
public void handleFailure(Player player) {
|
||||
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
|
||||
teleportRange.remove(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -149,10 +149,7 @@ public enum FactionTag implements Tag {
|
||||
if (!this.foundInString(text)) {
|
||||
return text;
|
||||
}
|
||||
String result = null;
|
||||
if (this.biFunction != null) {
|
||||
result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
|
||||
}
|
||||
String result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
|
||||
return result == null ? null : text.replace(this.tag, result);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ public enum PlayerTag implements Tag {
|
||||
}),
|
||||
PLAYER_BALANCE("{balance}", (fp) -> Econ.isSetup() ? Econ.getFriendlyBalance(fp) : (Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance"))),
|
||||
PLAYER_POWER("{player-power}", (fp) -> String.valueOf(fp.getPowerRounded())),
|
||||
ROLE("{player-role}", FPlayer::getRolePrefix),
|
||||
PLAYER_MAXPOWER("{player-maxpower}", (fp) -> String.valueOf(fp.getPowerMaxRounded())),
|
||||
PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())),
|
||||
PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())),
|
||||
|
@ -47,33 +47,41 @@ public class TextUtil {
|
||||
String text = "";
|
||||
FancyMessage message = new FancyMessage(text);
|
||||
ChatColor color = null;
|
||||
ChatColor style = null;
|
||||
char[] chars = first.toCharArray();
|
||||
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
// changed this so javadocs wont throw an error
|
||||
String compareChar = chars[i] + "";
|
||||
if (compareChar.equals("§")) {
|
||||
if (color != null) {
|
||||
if (color.isColor()) {
|
||||
message.then(text).color(color);
|
||||
} else {
|
||||
message.then(text).style(color);
|
||||
if (color != null || style != null) {
|
||||
message.then(text);
|
||||
if (color != null)
|
||||
message.color(color);
|
||||
if (style != null) {
|
||||
message.style(style);
|
||||
style = null;
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
color = ChatColor.getByChar(chars[i + 1]);
|
||||
ChatColor tempColor = ChatColor.getByChar(chars[i + 1]);
|
||||
if (tempColor.isColor()) {
|
||||
color = tempColor;
|
||||
} else {
|
||||
style = tempColor;
|
||||
}
|
||||
i++; // skip color char
|
||||
} else {
|
||||
text += chars[i];
|
||||
}
|
||||
}
|
||||
if (text.length() > 0) {
|
||||
if (color != null) {
|
||||
if (color.isColor()) {
|
||||
message.then(text).color(color);
|
||||
} else {
|
||||
message.then(text).style(color);
|
||||
}
|
||||
if (color != null || style != null) {
|
||||
message.then(text);
|
||||
if (color != null)
|
||||
message.color(color);
|
||||
if (style != null)
|
||||
message.style(style);
|
||||
} else {
|
||||
message.text(text);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user