Remove Fanciful, fix compilation (part 1/2)
This commit is contained in:
parent
535aa5c90e
commit
fc1d08e507
14
pom.xml
14
pom.xml
@ -44,15 +44,10 @@
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>mkremins:fanciful</include>
|
||||
<include>com.google.code.gson:gson</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>mkremins.fanciful</pattern>
|
||||
<shadedPattern>com.massivecraft.factions.shade.mkremins.fanciful</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>com.massivecraft.factions.shade.com.google.gson</shadedPattern>
|
||||
@ -103,11 +98,6 @@
|
||||
<artifactId>EssentialsXChat</artifactId>
|
||||
<version>2.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mkremins</groupId>
|
||||
<artifactId>fanciful</artifactId>
|
||||
<version>0.3.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
@ -148,9 +138,5 @@
|
||||
<id>repo.mikeprimm.com</id>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>franga2000-repo</id>
|
||||
<url>http://repo.franga2000.com/artifactory/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
@ -5,8 +5,10 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class CmdDeinvite extends FCommand {
|
||||
|
||||
@ -31,13 +33,18 @@ public class CmdDeinvite extends FCommand {
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
TextComponent component = new TextComponent(TL.COMMAND_DEINVITE_CANDEINVITE.toString());
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
||||
for (String id : myFaction.getInvites()) {
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
TextComponent then = new TextComponent(name + " ");
|
||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name))}));
|
||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " deinvite " + name));
|
||||
component.addExtra(then);
|
||||
}
|
||||
sendFancyMessage(msg);
|
||||
fme.getPlayer().spigot().sendMessage(component);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,12 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.LazyLocation;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -28,12 +31,17 @@ public class CmdFWarp extends FCommand {
|
||||
public void perform() {
|
||||
//TODO: check if in combat.
|
||||
if (args.size() == 0) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_FWARP_WARPS.toString()).color(ChatColor.GOLD);
|
||||
TextComponent component = new TextComponent(TL.COMMAND_FWARP_WARPS.toString());
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
||||
Map<String, LazyLocation> warps = myFaction.getWarps();
|
||||
for (String s : warps.keySet()) {
|
||||
msg.then(s + " ").tooltip(TL.COMMAND_FWARP_CLICKTOWARP.toString()).command(Conf.baseCommandAliases.get(0) + " warp " + s).color(ChatColor.WHITE);
|
||||
TextComponent then = new TextComponent(s + " ");
|
||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_FWARP_CLICKTOWARP.toString())}));
|
||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " warp " + s));
|
||||
component.addExtra(then);
|
||||
}
|
||||
sendFancyMessage(msg);
|
||||
fme.getPlayer().spigot().sendMessage(component);
|
||||
} else if (args.size() > 1) {
|
||||
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
|
||||
} else {
|
||||
|
@ -4,8 +4,7 @@ import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.chat.*;
|
||||
|
||||
public class CmdInvite extends FCommand {
|
||||
|
||||
@ -50,9 +49,13 @@ public class CmdInvite extends FCommand {
|
||||
}
|
||||
|
||||
// Tooltips, colors, and commands only apply to the string immediately before it.
|
||||
FancyMessage message = new FancyMessage(fme.describeTo(you, true)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command(Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()).then(TL.COMMAND_INVITE_INVITEDYOU.toString()).color(ChatColor.YELLOW).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command(Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()).then(myFaction.describeTo(you)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()).command(Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag());
|
||||
TextComponent component = new TextComponent(fme.describeTo(you, true));
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_INVITE_CLICKTOJOIN.toString())}));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()));
|
||||
component.addExtra(new ComponentBuilder(TL.COMMAND_INVITE_INVITEDYOU.toString()).color(net.md_5.bungee.api.ChatColor.YELLOW).create()[0]);
|
||||
component.addExtra(new ComponentBuilder(myFaction.describeTo(you)).color(net.md_5.bungee.api.ChatColor.YELLOW).create()[0]);
|
||||
|
||||
message.send(you.getPlayer());
|
||||
you.getPlayer().spigot().sendMessage(component);
|
||||
|
||||
//you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
|
||||
myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), you.describeTo(myFaction));
|
||||
|
@ -8,9 +8,11 @@ import com.massivecraft.factions.event.FPlayerLeaveEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdKick extends FCommand {
|
||||
|
||||
@ -34,19 +36,28 @@ public class CmdKick extends FCommand {
|
||||
public void perform() {
|
||||
FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null;
|
||||
if (toKick == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||
TextComponent component = new TextComponent(TL.COMMAND_KICK_CANDIDATES.toString());
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||
TextComponent then = new TextComponent(s + " ");
|
||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_KICK_CLICKTOKICK.toString() + s)}));
|
||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " kick " + s));
|
||||
component.addExtra(then);
|
||||
}
|
||||
if (fme.getRole() == Role.ADMIN) {
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s);
|
||||
TextComponent then = new TextComponent(s + " ");
|
||||
then.setColor(net.md_5.bungee.api.ChatColor.GRAY);
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_KICK_CLICKTOKICK.toString() + s)}));
|
||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " kick " + s));
|
||||
component.addExtra(then);
|
||||
}
|
||||
}
|
||||
|
||||
sendFancyMessage(msg);
|
||||
fme.getPlayer().spigot().sendMessage(component);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,10 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class CmdMod extends FCommand {
|
||||
|
||||
@ -31,13 +33,18 @@ public class CmdMod extends FCommand {
|
||||
public void perform() {
|
||||
FPlayer you = this.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||
TextComponent component = new TextComponent(TL.COMMAND_MOD_CANDIDATES.toString());
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
||||
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command(Conf.baseCommandAliases.get(0) + " mod " + s);
|
||||
TextComponent then = new TextComponent(s + " ");
|
||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s)}));
|
||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " mod " + s));
|
||||
component.addExtra(then);
|
||||
}
|
||||
|
||||
sendFancyMessage(msg);
|
||||
fme.getPlayer().spigot().sendMessage(component);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import com.massivecraft.factions.struct.Permission;
|
||||
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 net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -79,10 +79,10 @@ public class CmdShow extends FCommand {
|
||||
|
||||
for (String raw : show) {
|
||||
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
|
||||
if (TagUtil.hasFancy(parsed)) {
|
||||
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
|
||||
if (fancy != null) {
|
||||
sendFancyMessage(fancy);
|
||||
if (TagUtil.hasComponent(parsed)) {
|
||||
List<BaseComponent> components = TagUtil.parseComponent(faction, fme, parsed);
|
||||
if (components != null) {
|
||||
fme.getPlayer().spigot().sendMessage(components.toArray(new BaseComponent[components.size()]));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -5,8 +5,10 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class CmdShowInvites extends FCommand {
|
||||
|
||||
@ -21,14 +23,19 @@ public class CmdShowInvites extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
|
||||
TextComponent component = new TextComponent(TL.COMMAND_SHOWINVITES_PENDING.toString());
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
||||
for (String id : myFaction.getInvites()) {
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
TextComponent then = new TextComponent(name + " ");
|
||||
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name))}));
|
||||
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " deinvite " + name));
|
||||
component.addExtra(then);
|
||||
}
|
||||
|
||||
sendFancyMessage(msg);
|
||||
fme.getPlayer().spigot().sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,6 @@ import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -269,16 +268,6 @@ public abstract class MCommand<T extends MPlugin> {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendFancyMessage(FancyMessage message) {
|
||||
message.send(sender);
|
||||
}
|
||||
|
||||
public void sendFancyMessage(List<FancyMessage> messages) {
|
||||
for (FancyMessage m : messages) {
|
||||
sendFancyMessage(m);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getToolTips(FPlayer player) {
|
||||
List<String> lines = new ArrayList<String>();
|
||||
for (String s : p.getConfig().getStringList("tooltips.show")) {
|
||||
|
@ -6,7 +6,9 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -74,33 +76,34 @@ public class TagUtil {
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scan a line and parse the fancy variable into a fancy list
|
||||
* Scan a line and parse the component variable into a component list
|
||||
*
|
||||
* @param faction for faction (viewers faction)
|
||||
* @param fme for player (viewer)
|
||||
* @param line fancy message prefix
|
||||
* @param line component prefix
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<FancyMessage> parseFancy(Faction faction, FPlayer fme, String line) {
|
||||
public static List<BaseComponent> parseComponent(Faction faction, FPlayer fme, String line) {
|
||||
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.FANCY)) {
|
||||
if (tagReplacer.contains(line)) {
|
||||
String clean = line.replace(tagReplacer.getTag(), ""); // remove tag
|
||||
return getFancy(faction, fme, tagReplacer, clean);
|
||||
return getComponent(faction, fme, tagReplacer, clean);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a line has fancy variables
|
||||
* Checks if a line has component variables
|
||||
*
|
||||
* @param line raw line from config with variables
|
||||
*
|
||||
* @return if the line has fancy variables
|
||||
*/
|
||||
public static boolean hasFancy(String line) {
|
||||
public static boolean hasComponent(String line) {
|
||||
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.FANCY)) {
|
||||
if (tagReplacer.contains(line)) {
|
||||
return true;
|
||||
@ -109,8 +112,9 @@ public class TagUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lets get fancy.
|
||||
* Lets get components?
|
||||
*
|
||||
* @param target Faction to get relate from
|
||||
* @param fme Player to relate to
|
||||
@ -118,11 +122,11 @@ public class TagUtil {
|
||||
*
|
||||
* @return list of fancy messages to send
|
||||
*/
|
||||
protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) {
|
||||
List<FancyMessage> fancyMessages = new ArrayList<FancyMessage>();
|
||||
protected static List<BaseComponent> getComponent(Faction target, FPlayer fme, TagReplacer type, String prefix) {
|
||||
List<BaseComponent> components = new ArrayList<BaseComponent>();
|
||||
switch (type) {
|
||||
case ALLIES_LIST:
|
||||
FancyMessage currentAllies = P.p.txt.parseFancy(prefix);
|
||||
BaseComponent currentAllies = P.p.txt.parseComponent(prefix);
|
||||
boolean firstAlly = true;
|
||||
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
||||
if (otherFaction == target) {
|
||||
@ -130,19 +134,27 @@ public class TagUtil {
|
||||
}
|
||||
String s = otherFaction.getTag(fme);
|
||||
if (otherFaction.getRelationTo(target).isAlly()) {
|
||||
currentAllies.then(firstAlly ? s : ", " + s);
|
||||
currentAllies.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction));
|
||||
TextComponent then = new TextComponent(firstAlly ? s : ", " + s);
|
||||
List<String> list = tipFaction(otherFaction);
|
||||
TextComponent[] hover = new TextComponent[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TextComponent component = new TextComponent(list.get(i));
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(otherFaction).name()));
|
||||
hover[i] = component;
|
||||
}
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
||||
currentAllies.addExtra(then);
|
||||
firstAlly = false;
|
||||
if (currentAllies.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||
fancyMessages.add(currentAllies);
|
||||
currentAllies = new FancyMessage("");
|
||||
if (currentAllies.toPlainText().length() > ARBITRARY_LIMIT) {
|
||||
components.add(currentAllies);
|
||||
currentAllies = new TextComponent("");
|
||||
}
|
||||
}
|
||||
}
|
||||
fancyMessages.add(currentAllies);
|
||||
return fancyMessages; // we must return here and not outside the switch
|
||||
components.add(currentAllies);
|
||||
return components; // we must return here and not outside the switch
|
||||
case ENEMIES_LIST:
|
||||
FancyMessage currentEnemies = P.p.txt.parseFancy(prefix);
|
||||
BaseComponent currentEnemies = P.p.txt.parseComponent(prefix);
|
||||
boolean firstEnemy = true;
|
||||
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
||||
if (otherFaction == target) {
|
||||
@ -150,49 +162,73 @@ public class TagUtil {
|
||||
}
|
||||
String s = otherFaction.getTag(fme);
|
||||
if (otherFaction.getRelationTo(target).isEnemy()) {
|
||||
currentEnemies.then(firstEnemy ? s : ", " + s);
|
||||
currentEnemies.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction));
|
||||
TextComponent then = new TextComponent(firstEnemy ? s : ", " + s);
|
||||
List<String> list = tipFaction(otherFaction);
|
||||
TextComponent[] hover = new TextComponent[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TextComponent component = new TextComponent(list.get(i));
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(otherFaction).name()));
|
||||
hover[i] = component;
|
||||
}
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
||||
currentEnemies.addExtra(then);
|
||||
firstEnemy = false;
|
||||
if (currentEnemies.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||
fancyMessages.add(currentEnemies);
|
||||
currentEnemies = new FancyMessage("");
|
||||
if (currentEnemies.toPlainText().length() > ARBITRARY_LIMIT) {
|
||||
components.add(currentEnemies);
|
||||
currentEnemies = new TextComponent("");
|
||||
}
|
||||
}
|
||||
}
|
||||
fancyMessages.add(currentEnemies);
|
||||
return fancyMessages; // we must return here and not outside the switch
|
||||
components.add(currentEnemies);
|
||||
return components; // we must return here and not outside the switch
|
||||
case ONLINE_LIST:
|
||||
FancyMessage currentOnline = P.p.txt.parseFancy(prefix);
|
||||
BaseComponent currentOnline = P.p.txt.parseComponent(prefix);
|
||||
boolean firstOnline = true;
|
||||
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayersWhereOnline(true))) {
|
||||
String name = p.getNameAndTitle();
|
||||
currentOnline.then(firstOnline ? name : ", " + name);
|
||||
currentOnline.tooltip(tipPlayer(p)).color(fme.getColorTo(p));
|
||||
TextComponent then = new TextComponent(firstOnline ? name : ", " + name);
|
||||
List<String> list = tipPlayer(p);
|
||||
TextComponent[] hover = new TextComponent[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TextComponent component = new TextComponent(list.get(i));
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(p).name()));
|
||||
hover[i] = component;
|
||||
}
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
||||
currentOnline.addExtra(then);
|
||||
firstOnline = false;
|
||||
if (currentOnline.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||
fancyMessages.add(currentOnline);
|
||||
currentOnline = new FancyMessage("");
|
||||
if (currentOnline.toPlainText().length() > ARBITRARY_LIMIT) {
|
||||
components.add(currentOnline);
|
||||
currentOnline = new TextComponent("");
|
||||
}
|
||||
}
|
||||
fancyMessages.add(currentOnline);
|
||||
return fancyMessages; // we must return here and not outside the switch
|
||||
components.add(currentOnline);
|
||||
return components; // we must return here and not outside the switch
|
||||
case OFFLINE_LIST:
|
||||
FancyMessage currentOffline = P.p.txt.parseFancy(prefix);
|
||||
BaseComponent currentOffline = P.p.txt.parseComponent(prefix);
|
||||
boolean firstOffline = true;
|
||||
for (FPlayer p : MiscUtil.rankOrder(target.getFPlayers())) {
|
||||
String name = p.getNameAndTitle();
|
||||
if (!p.isOnline()) {
|
||||
currentOffline.then(firstOffline ? name : ", " + name);
|
||||
currentOffline.tooltip(tipPlayer(p)).color(fme.getColorTo(p));
|
||||
TextComponent then = new TextComponent(firstOffline ? name : ", " + name);
|
||||
List<String> list = tipPlayer(p);
|
||||
TextComponent[] hover = new TextComponent[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TextComponent component = new TextComponent(list.get(i));
|
||||
component.setColor(net.md_5.bungee.api.ChatColor.valueOf(fme.getColorTo(p).name()));
|
||||
hover[i] = component;
|
||||
}
|
||||
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
||||
currentOffline.addExtra(then);
|
||||
firstOffline = false;
|
||||
if (currentOffline.toJSONString().length() > ARBITRARY_LIMIT) {
|
||||
fancyMessages.add(currentOffline);
|
||||
currentOffline = new FancyMessage("");
|
||||
if (currentOffline.toPlainText().length() > ARBITRARY_LIMIT) {
|
||||
components.add(currentOffline);
|
||||
currentOffline = new TextComponent("");
|
||||
}
|
||||
}
|
||||
}
|
||||
fancyMessages.add(currentOffline);
|
||||
return fancyMessages; // we must return here and not outside the switch
|
||||
components.add(currentOffline);
|
||||
return components; // we must return here and not outside the switch
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.zcore.util;
|
||||
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@ -55,41 +56,24 @@ public class TextUtil {
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Fancy parsing
|
||||
// Component parsing
|
||||
// -------------------------------------------- //
|
||||
|
||||
public FancyMessage parseFancy(String prefix) {
|
||||
return toFancy(parse(prefix));
|
||||
public BaseComponent parseComponent(String prefix) {
|
||||
return toComponent(parse(prefix));
|
||||
}
|
||||
|
||||
public static FancyMessage toFancy(String first) {
|
||||
String text = "";
|
||||
FancyMessage message = new FancyMessage(text);
|
||||
ChatColor color = null;
|
||||
char[] chars = first.toCharArray();
|
||||
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
if (chars[i] == '§') {
|
||||
if (color != null) {
|
||||
message.then(text).color(color);
|
||||
text = "";
|
||||
color = ChatColor.getByChar(chars[i + 1]);
|
||||
} else {
|
||||
color = ChatColor.getByChar(chars[i + 1]);
|
||||
}
|
||||
i++; // skip color char
|
||||
} else {
|
||||
text += chars[i];
|
||||
}
|
||||
public static BaseComponent toComponent(String first) {
|
||||
BaseComponent[] components = TextComponent.fromLegacyText(first);
|
||||
if (components.length == 0) {
|
||||
return null;
|
||||
}
|
||||
if (text.length() > 0) {
|
||||
if (color != null) {
|
||||
message.then(text).color(color);
|
||||
} else {
|
||||
message.text(text);
|
||||
}
|
||||
// convert it to a single component, for ease
|
||||
BaseComponent component = components[0];
|
||||
for (int i = 1; i < components.length; i++) {
|
||||
component.addExtra(components[i]);
|
||||
}
|
||||
return message;
|
||||
return component;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user