/f list tool tips

This commit is contained in:
drtshock 2014-11-13 12:45:57 -06:00
parent e585ab57a9
commit 64e234144e
4 changed files with 56 additions and 6 deletions

View File

@ -51,7 +51,7 @@ public class CmdInvite extends FCommand {
// Tooltips, colors, and commands only apply to the string immediately before it. // Tooltips, colors, and commands only apply to the string immediately before it.
FancyMessage message = new FancyMessage(fme.describeTo(you, true)).tooltip("Click to join!").command("f join " + myFaction.getTag()).then(" has invited you to join ").color(ChatColor.YELLOW).tooltip("Click to join!").command("f join " + myFaction.getTag()).then(myFaction.describeTo(you)).tooltip("Click to join!").command("f join " + myFaction.getTag()); FancyMessage message = new FancyMessage(fme.describeTo(you, true)).tooltip("Click to join!").command("f join " + myFaction.getTag()).then(" has invited you to join ").color(ChatColor.YELLOW).tooltip("Click to join!").command("f join " + myFaction.getTag()).then(myFaction.describeTo(you)).tooltip("Click to join!").command("f join " + myFaction.getTag());
message.send(you.getPlayer()); sendFancyMessage(message);
//you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you)); //you.msg("%s<i> invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you));
myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), you.describeTo(myFaction)); myFaction.msg("%s<i> invited %s<i> to your faction.", fme.describeTo(myFaction, true), you.describeTo(myFaction));

View File

@ -1,13 +1,17 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
public class CmdList extends FCommand { public class CmdList extends FCommand {
@ -71,7 +75,7 @@ public class CmdList extends FCommand {
} }
}); });
ArrayList<String> lines = new ArrayList<String>(); ArrayList<FancyMessage> lines = new ArrayList<FancyMessage>();
factionList.add(0, Factions.getInstance().getNone()); factionList.add(0, Factions.getInstance().getNone());
@ -89,16 +93,37 @@ public class CmdList extends FCommand {
end = factionList.size(); end = factionList.size();
} }
lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount)); lines.add(new FancyMessage(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount)));
for (Faction faction : factionList.subList(start, end)) { for (Faction faction : factionList.subList(start, end)) {
if (faction.isNone()) { if (faction.isNone()) {
lines.add(p.txt.parse("<i>Factionless<i> %d online", Factions.getInstance().getNone().getFPlayersWhereOnline(true).size())); String online = String.valueOf(faction.getFPlayersWhereOnline(true).size());
FancyMessage msg = new FancyMessage("Factionless " + online + " online").color(ChatColor.YELLOW);
lines.add(msg);
continue; continue;
} }
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d", faction.getTag(fme), faction.getFPlayersWhereOnline(true).size(), faction.getFPlayers().size(), faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded())); String online = " " + faction.getFPlayersWhereOnline(true).size() + "/" + faction.getFPlayers().size() + " online";
FancyMessage msg = new FancyMessage(faction.getTag(fme) + online).color(ChatColor.YELLOW).tooltip(getToolTips(faction));
lines.add(msg);
//lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d", faction.getTag(fme), faction.getFPlayersWhereOnline(true).size(), faction.getFPlayers().size(), faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded()));
} }
sendMessage(lines); sendFancyMessage(lines);
}
private List<String> getToolTips(Faction faction) {
List<String> lines = new ArrayList<String>();
for (String s : p.getConfig().getStringList("tooltips.list")) {
lines.add(replaceFInfoTags(s, faction));
}
return lines;
}
private String replaceFInfoTags(String s, Faction faction) {
boolean raidable = faction.getLandRounded() > faction.getPower();
FPlayer fLeader = faction.getFPlayerAdmin();
String leader = fLeader == null ? "Server" : fLeader.getName().substring(0, fLeader.getName().length() > 14 ? 13 : fLeader.getName().length());
return s.replace("{power}", String.valueOf(faction.getPowerRounded())).replace("{maxPower}", String.valueOf(faction.getPowerMaxRounded())).replace("{leader}", leader).replace("{chunks}", String.valueOf(faction.getLandRounded())).replace("{raidable}", String.valueOf(raidable)).replace("{warps}", String.valueOf(faction.getWarps().size()));
} }
} }

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.zcore; package com.massivecraft.factions.zcore;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
import mkremins.fanciful.FancyMessage;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -257,6 +258,16 @@ 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);
}
}
// -------------------------------------------- // // -------------------------------------------- //
// Argument Readers // Argument Readers
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -38,6 +38,20 @@ warp-cost:
# http://i.gyazo.com/6a1a31222e58a5d60ff341c13f6a8404.gif # http://i.gyazo.com/6a1a31222e58a5d60ff341c13f6a8404.gif
disable-pistons-in-territory: false disable-pistons-in-territory: false
# ToolTips
# This section is to configure tooltips for things like /f list
tooltips:
# This shows up when someone does /f list for the top factions.
# It will not sure up for factionless of course, just actual factions.
# You can't use color codes here.
list:
- "Leader: {leader}"
- "Claimed: {chunks}"
- "Raidable: {raidable}"
- "Warps: {warps}"
- "Power: {power}/{maxPower}"
# Configuration section for Scoreboards # Configuration section for Scoreboards
# This will allow you to completely customize how your scoreboards look. # This will allow you to completely customize how your scoreboards look.
# Make sure that no lines are duplicates of each other otherwise only the first will display. # Make sure that no lines are duplicates of each other otherwise only the first will display.