commit
2f18da3cfb
@ -82,7 +82,7 @@ public class CmdDisband extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!access) {
|
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())) {
|
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||||
return;
|
return;
|
||||||
|
@ -115,8 +115,6 @@ public class CmdJoin extends FCommand {
|
|||||||
fplayer.msg(TL.COMMAND_JOIN_MOVED, context.fPlayer.describeTo(fplayer, true), faction.getTag(fplayer));
|
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();
|
fplayer.resetFactionData();
|
||||||
|
|
||||||
if (faction.altInvited(fplayer)) {
|
if (faction.altInvited(fplayer)) {
|
||||||
@ -144,6 +142,8 @@ public class CmdJoin extends FCommand {
|
|||||||
System.out.print(e.getMessage());
|
System.out.print(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
faction.msg(TL.COMMAND_JOIN_JOINED, fplayer.describeTo(faction, true));
|
||||||
|
|
||||||
if (Conf.logFactionJoin) {
|
if (Conf.logFactionJoin) {
|
||||||
if (samePlayer) {
|
if (samePlayer) {
|
||||||
FactionsPlugin.getInstance().log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());
|
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.TagReplacer;
|
||||||
import com.massivecraft.factions.zcore.util.TagUtil;
|
import com.massivecraft.factions.zcore.util.TagUtil;
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class CmdShow extends FCommand {
|
public class CmdShow extends FCommand {
|
||||||
|
|
||||||
@ -24,17 +26,21 @@ public class CmdShow extends FCommand {
|
|||||||
this.aliases.addAll(Aliases.show_show);
|
this.aliases.addAll(Aliases.show_show);
|
||||||
|
|
||||||
// add defaults to /f show in case config doesnt have it
|
// add defaults to /f show in case config doesnt have it
|
||||||
defaults.add("{header}");
|
defaults.add("&8&m--------------&7 &8<&e{faction}&8> &8&m--------------");
|
||||||
defaults.add("<a>Description: <i>{description}");
|
defaults.add("&4* &cOwner: &f{leader}");
|
||||||
defaults.add("<a>Joining: <i>{joining} {peaceful}");
|
defaults.add("&4* &cDescription: &f{description}");
|
||||||
defaults.add("<a>Land / Power / Maxpower: <i> {chunks} / {power} / {maxPower}");
|
defaults.add("&4* &cLand / Power / Max Power: &f{chunks} &8/ &f{power} &8/ &f{maxPower}");
|
||||||
defaults.add("<a>Founded: <i>{create-date}");
|
defaults.add("&4* &cFaction Strikes: &f{strikes}");
|
||||||
defaults.add("<a>This faction is permanent, remaining even with no members.");
|
defaults.add("&4* &cFaction Points: &f{faction-points}");
|
||||||
defaults.add("<a>Land value: <i>{land-value} {land-refund}");
|
defaults.add("&4* &cFounded: &f{create-date}");
|
||||||
defaults.add("<a>Balance: <i>{faction-balance}");
|
defaults.add("&4* &cBalance: &f{faction-balance}");
|
||||||
defaults.add("<a>Allies(<i>{allies}<a>/<i>{max-allies}<a>): {allies-list}");
|
defaults.add("&4* &cAllies: &a{allies-list}");
|
||||||
defaults.add("<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}");
|
defaults.add("&4* &cEnemies: &4{enemies-list}");
|
||||||
defaults.add("<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-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.requiredArgs.add("");
|
||||||
this.optionalArgs.put("faction tag", "yours");
|
this.optionalArgs.put("faction tag", "yours");
|
||||||
@ -45,6 +51,7 @@ public class CmdShow extends FCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
Faction faction = context.faction;
|
Faction faction = context.faction;
|
||||||
|
FactionsPlugin instance = FactionsPlugin.getInstance();
|
||||||
if (context.argIsSet(0))
|
if (context.argIsSet(0))
|
||||||
faction = context.argAsFaction(0);
|
faction = context.argAsFaction(0);
|
||||||
|
|
||||||
@ -52,7 +59,7 @@ public class CmdShow extends FCommand {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (context.fPlayer != null && !context.player.getPlayer().hasPermission("factions.show.bypassexempt")
|
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);
|
context.msg(TL.COMMAND_SHOW_EXEMPT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,7 +69,7 @@ public class CmdShow extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> show = FactionsPlugin.getInstance().getConfig().getStringList("show");
|
List<String> show = instance.getConfig().getStringList("show");
|
||||||
if (show == null || show.isEmpty())
|
if (show == null || show.isEmpty())
|
||||||
show = defaults;
|
show = defaults;
|
||||||
|
|
||||||
@ -71,16 +78,17 @@ public class CmdShow extends FCommand {
|
|||||||
// send header and that's all
|
// send header and that's all
|
||||||
String header = show.get(0);
|
String header = show.get(0);
|
||||||
if (TagReplacer.HEADER.contains(header)) {
|
if (TagReplacer.HEADER.contains(header)) {
|
||||||
context.msg(FactionsPlugin.getInstance().txt.titleize(tag));
|
context.msg(instance.txt.titleize(tag));
|
||||||
} else {
|
} 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
|
return; // we only show header for non-normal factions
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> finalShow = show;
|
List<String> finalShow = show;
|
||||||
Faction finalFaction = faction;
|
Faction finalFaction = faction;
|
||||||
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
|
List<FancyMessage> fancy = new ArrayList<>();
|
||||||
|
instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> {
|
||||||
for (String raw : finalShow) {
|
for (String raw : finalShow) {
|
||||||
String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
|
String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
|
||||||
if (parsed == null) {
|
if (parsed == null) {
|
||||||
@ -92,9 +100,9 @@ public class CmdShow extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (TagUtil.hasFancy(parsed)) {
|
if (TagUtil.hasFancy(parsed)) {
|
||||||
List<FancyMessage> fancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
|
List<FancyMessage> localFancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
|
||||||
if (fancy != null)
|
if (localFancy != null)
|
||||||
context.sendFancyMessage(fancy);
|
fancy.addAll(localFancy);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -106,9 +114,12 @@ public class CmdShow extends FCommand {
|
|||||||
if (parsed.contains("%")) {
|
if (parsed.contains("%")) {
|
||||||
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
|
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) {
|
public void perform(CommandContext context) {
|
||||||
if (!teleportRange.containsKey(context.player)) {
|
if (!teleportRange.containsKey(context.player)) {
|
||||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
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) {
|
if (!success) {
|
||||||
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
|
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
|
||||||
|
teleportRange.remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +113,7 @@ public class CmdWild extends FCommand implements WaitedTask {
|
|||||||
@Override
|
@Override
|
||||||
public void handleFailure(Player player) {
|
public void handleFailure(Player player) {
|
||||||
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
|
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
|
||||||
|
teleportRange.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -149,10 +149,7 @@ public enum FactionTag implements Tag {
|
|||||||
if (!this.foundInString(text)) {
|
if (!this.foundInString(text)) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
String result = null;
|
String result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
|
||||||
if (this.biFunction != null) {
|
|
||||||
result = this.function == null ? this.biFunction.apply(faction, player) : this.function.apply(faction);
|
|
||||||
}
|
|
||||||
return result == null ? null : text.replace(this.tag, result);
|
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_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())),
|
PLAYER_POWER("{player-power}", (fp) -> String.valueOf(fp.getPowerRounded())),
|
||||||
|
ROLE("{player-role}", FPlayer::getRolePrefix),
|
||||||
PLAYER_MAXPOWER("{player-maxpower}", (fp) -> String.valueOf(fp.getPowerMaxRounded())),
|
PLAYER_MAXPOWER("{player-maxpower}", (fp) -> String.valueOf(fp.getPowerMaxRounded())),
|
||||||
PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())),
|
PLAYER_KILLS("{player-kills}", (fp) -> String.valueOf(fp.getKills())),
|
||||||
PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())),
|
PLAYER_DEATHS("{player-deaths}", (fp) -> String.valueOf(fp.getDeaths())),
|
||||||
|
@ -47,33 +47,41 @@ public class TextUtil {
|
|||||||
String text = "";
|
String text = "";
|
||||||
FancyMessage message = new FancyMessage(text);
|
FancyMessage message = new FancyMessage(text);
|
||||||
ChatColor color = null;
|
ChatColor color = null;
|
||||||
|
ChatColor style = null;
|
||||||
char[] chars = first.toCharArray();
|
char[] chars = first.toCharArray();
|
||||||
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
for (int i = 0; i < chars.length; i++) {
|
||||||
// changed this so javadocs wont throw an error
|
// changed this so javadocs wont throw an error
|
||||||
String compareChar = chars[i] + "";
|
String compareChar = chars[i] + "";
|
||||||
if (compareChar.equals("§")) {
|
if (compareChar.equals("§")) {
|
||||||
if (color != null) {
|
if (color != null || style != null) {
|
||||||
if (color.isColor()) {
|
message.then(text);
|
||||||
message.then(text).color(color);
|
if (color != null)
|
||||||
} else {
|
message.color(color);
|
||||||
message.then(text).style(color);
|
if (style != null) {
|
||||||
|
message.style(style);
|
||||||
|
style = null;
|
||||||
}
|
}
|
||||||
text = "";
|
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
|
i++; // skip color char
|
||||||
} else {
|
} else {
|
||||||
text += chars[i];
|
text += chars[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (text.length() > 0) {
|
if (text.length() > 0) {
|
||||||
if (color != null) {
|
if (color != null || style != null) {
|
||||||
if (color.isColor()) {
|
message.then(text);
|
||||||
message.then(text).color(color);
|
if (color != null)
|
||||||
} else {
|
message.color(color);
|
||||||
message.then(text).style(color);
|
if (style != null)
|
||||||
}
|
message.style(style);
|
||||||
} else {
|
} else {
|
||||||
message.text(text);
|
message.text(text);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user