Revert "Remove Fanciful, fix compilation (part 1/2)"

This reverts commit fc1d08e507.
We have users on builds before this was included in Spigot. We don't want to break those servers.
This commit is contained in:
drtshock
2015-05-25 15:46:18 -05:00
parent 1481d604d4
commit de57060819
11 changed files with 132 additions and 170 deletions

View File

@@ -5,10 +5,8 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
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 mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdDeinvite extends FCommand {
@@ -33,18 +31,13 @@ public class CmdDeinvite extends FCommand {
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) {
TextComponent component = new TextComponent(TL.COMMAND_DEINVITE_CANDEINVITE.toString());
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
for (String id : myFaction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id;
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);
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name);
}
fme.getPlayer().spigot().sendMessage(component);
sendFancyMessage(msg);
return;
}

View File

@@ -5,12 +5,9 @@ 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 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 mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
import java.util.Map;
@@ -31,17 +28,12 @@ public class CmdFWarp extends FCommand {
public void perform() {
//TODO: check if in combat.
if (args.size() == 0) {
TextComponent component = new TextComponent(TL.COMMAND_FWARP_WARPS.toString());
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
FancyMessage msg = new FancyMessage(TL.COMMAND_FWARP_WARPS.toString()).color(ChatColor.GOLD);
Map<String, LazyLocation> warps = myFaction.getWarps();
for (String s : warps.keySet()) {
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);
msg.then(s + " ").tooltip(TL.COMMAND_FWARP_CLICKTOWARP.toString()).command(Conf.baseCommandAliases.get(0) + " warp " + s).color(ChatColor.WHITE);
}
fme.getPlayer().spigot().sendMessage(component);
sendFancyMessage(msg);
} else if (args.size() > 1) {
fme.msg(TL.COMMAND_FWARP_COMMANDFORMAT);
} else {

View File

@@ -4,7 +4,8 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import net.md_5.bungee.api.chat.*;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdInvite extends FCommand {
@@ -49,13 +50,9 @@ public class CmdInvite extends FCommand {
}
// Tooltips, colors, and commands only apply to the string immediately before it.
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]);
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());
you.getPlayer().spigot().sendMessage(component);
message.send(you.getPlayer());
//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));

View File

@@ -8,11 +8,9 @@ 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 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 mkremins.fanciful.FancyMessage;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
public class CmdKick extends FCommand {
@@ -36,28 +34,19 @@ public class CmdKick extends FCommand {
public void perform() {
FPlayer toKick = this.argIsSet(0) ? this.argAsBestFPlayerMatch(0) : null;
if (toKick == null) {
TextComponent component = new TextComponent(TL.COMMAND_KICK_CANDIDATES.toString());
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
FancyMessage msg = new FancyMessage(TL.COMMAND_KICK_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName();
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);
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s);
}
if (fme.getRole() == Role.ADMIN) {
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) {
String s = player.getName();
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);
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command(Conf.baseCommandAliases.get(0) + " kick " + s);
}
}
fme.getPlayer().spigot().sendMessage(component);
sendFancyMessage(msg);
return;
}

View File

@@ -6,10 +6,8 @@ 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 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 mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdMod extends FCommand {
@@ -33,18 +31,13 @@ public class CmdMod extends FCommand {
public void perform() {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) {
TextComponent component = new TextComponent(TL.COMMAND_MOD_CANDIDATES.toString());
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
String s = player.getName();
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);
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command(Conf.baseCommandAliases.get(0) + " mod " + s);
}
fme.getPlayer().spigot().sendMessage(component);
sendFancyMessage(msg);
return;
}

View File

@@ -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 net.md_5.bungee.api.chat.BaseComponent;
import mkremins.fanciful.FancyMessage;
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.hasComponent(parsed)) {
List<BaseComponent> components = TagUtil.parseComponent(faction, fme, parsed);
if (components != null) {
fme.getPlayer().spigot().sendMessage(components.toArray(new BaseComponent[components.size()]));
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
if (fancy != null) {
sendFancyMessage(fancy);
}
continue;
}

View File

@@ -5,10 +5,8 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
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 mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
public class CmdShowInvites extends FCommand {
@@ -23,19 +21,14 @@ public class CmdShowInvites extends FCommand {
@Override
public void perform() {
TextComponent component = new TextComponent(TL.COMMAND_SHOWINVITES_PENDING.toString());
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
for (String id : myFaction.getInvites()) {
FPlayer fp = FPlayers.getInstance().getById(id);
String name = fp != null ? fp.getName() : id;
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);
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command(Conf.baseCommandAliases.get(0) + " deinvite " + name);
}
fme.getPlayer().spigot().sendMessage(component);
sendFancyMessage(msg);
}
@Override