Properly split FancyMessages for /f show
This commit is contained in:
parent
6d2ca16002
commit
1ada19b02e
@ -13,6 +13,7 @@ import mkremins.fanciful.FancyMessage;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CmdShow extends FCommand {
|
public class CmdShow extends FCommand {
|
||||||
|
|
||||||
@ -54,8 +55,8 @@ public class CmdShow extends FCommand {
|
|||||||
double powerBoost = faction.getPowerBoost();
|
double powerBoost = faction.getPowerBoost();
|
||||||
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString() + powerBoost + ")");
|
||||||
|
|
||||||
ArrayList<FancyMessage> allies = new ArrayList<FancyMessage>();
|
List<FancyMessage> allies = new ArrayList<FancyMessage>();
|
||||||
ArrayList<FancyMessage> enemies = new ArrayList<FancyMessage>();
|
List<FancyMessage> enemies = new ArrayList<FancyMessage>();
|
||||||
FancyMessage currentAllies = new FancyMessage(TL.COMMAND_SHOW_ALLIES.toString()).color(ChatColor.GOLD);
|
FancyMessage currentAllies = new FancyMessage(TL.COMMAND_SHOW_ALLIES.toString()).color(ChatColor.GOLD);
|
||||||
FancyMessage currentEnemies = new FancyMessage(TL.COMMAND_SHOW_ENEMIES.toString()).color(ChatColor.GOLD);
|
FancyMessage currentEnemies = new FancyMessage(TL.COMMAND_SHOW_ENEMIES.toString()).color(ChatColor.GOLD);
|
||||||
|
|
||||||
@ -69,6 +70,11 @@ public class CmdShow extends FCommand {
|
|||||||
Relation rel = otherFaction.getRelationTo(faction);
|
Relation rel = otherFaction.getRelationTo(faction);
|
||||||
String s = otherFaction.getTag(fme);
|
String s = otherFaction.getTag(fme);
|
||||||
if (rel.isAlly()) {
|
if (rel.isAlly()) {
|
||||||
|
FancyMessage beforeAdd = null;
|
||||||
|
try {
|
||||||
|
beforeAdd = currentAllies.clone();
|
||||||
|
} catch (CloneNotSupportedException ignored) {}
|
||||||
|
|
||||||
if (firstAlly) {
|
if (firstAlly) {
|
||||||
currentAllies.then(s).tooltip(getToolTips(otherFaction));
|
currentAllies.then(s).tooltip(getToolTips(otherFaction));
|
||||||
} else {
|
} else {
|
||||||
@ -77,10 +83,15 @@ public class CmdShow extends FCommand {
|
|||||||
firstAlly = false;
|
firstAlly = false;
|
||||||
|
|
||||||
if (currentAllies.toJSONString().length() > Short.MAX_VALUE) {
|
if (currentAllies.toJSONString().length() > Short.MAX_VALUE) {
|
||||||
allies.add(currentAllies);
|
allies.add(beforeAdd);
|
||||||
currentAllies = new FancyMessage();
|
currentAllies = new FancyMessage(s).tooltip(getToolTips(otherFaction));
|
||||||
}
|
}
|
||||||
} else if (rel.isEnemy()) {
|
} else if (rel.isEnemy()) {
|
||||||
|
FancyMessage beforeAdd = null;
|
||||||
|
try {
|
||||||
|
beforeAdd = currentEnemies.clone();
|
||||||
|
} catch (CloneNotSupportedException ignored) {}
|
||||||
|
|
||||||
if (firstEnemy) {
|
if (firstEnemy) {
|
||||||
currentEnemies.then(s).tooltip(getToolTips(otherFaction));
|
currentEnemies.then(s).tooltip(getToolTips(otherFaction));
|
||||||
} else {
|
} else {
|
||||||
@ -89,42 +100,60 @@ public class CmdShow extends FCommand {
|
|||||||
firstEnemy = false;
|
firstEnemy = false;
|
||||||
|
|
||||||
if (currentEnemies.toJSONString().length() > Short.MAX_VALUE) {
|
if (currentEnemies.toJSONString().length() > Short.MAX_VALUE) {
|
||||||
enemies.add(currentEnemies);
|
enemies.add(beforeAdd);
|
||||||
currentEnemies = new FancyMessage();
|
currentEnemies = new FancyMessage(s).tooltip(getToolTips(otherFaction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allies.add(currentAllies);
|
allies.add(currentAllies);
|
||||||
enemies.add(currentEnemies);
|
enemies.add(currentEnemies);
|
||||||
|
|
||||||
FancyMessage online = new FancyMessage(TL.COMMAND_SHOW_MEMBERSONLINE.toString()).color(ChatColor.GOLD);
|
List<FancyMessage> online = new ArrayList<FancyMessage>();
|
||||||
FancyMessage offline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSOFFLINE.toString()).color(ChatColor.GOLD);
|
List<FancyMessage> offline = new ArrayList<FancyMessage>();
|
||||||
|
FancyMessage currentOnline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSONLINE.toString()).color(ChatColor.GOLD);
|
||||||
|
FancyMessage currentOffline = new FancyMessage(TL.COMMAND_SHOW_MEMBERSOFFLINE.toString()).color(ChatColor.GOLD);
|
||||||
boolean firstOnline = true;
|
boolean firstOnline = true;
|
||||||
boolean firstOffline = true;
|
boolean firstOffline = true;
|
||||||
for (FPlayer p : MiscUtil.rankOrder(faction.getFPlayers())) {
|
for (FPlayer p : MiscUtil.rankOrder(faction.getFPlayers())) {
|
||||||
String name = p.getNameAndTitle();
|
String name = p.getNameAndTitle();
|
||||||
if (p.isOnline()) {
|
if (p.isOnline()) {
|
||||||
|
FancyMessage beforeAdd = null;
|
||||||
|
try {
|
||||||
|
beforeAdd = currentOnline.clone();
|
||||||
|
} catch (CloneNotSupportedException ignored) {}
|
||||||
|
|
||||||
if (firstOnline) {
|
if (firstOnline) {
|
||||||
online.then(name).tooltip(getToolTips(p));
|
currentOnline.then(name).tooltip(getToolTips(p));
|
||||||
} else {
|
} else {
|
||||||
online.then(", " + name).tooltip(getToolTips(p));
|
currentOnline.then(", " + name).tooltip(getToolTips(p));
|
||||||
}
|
}
|
||||||
firstOnline = false;
|
firstOnline = false;
|
||||||
if (online.toJSONString().length() > Short.MAX_VALUE) {
|
|
||||||
online = new FancyMessage();
|
if (currentOnline.toJSONString().length() > Short.MAX_VALUE) {
|
||||||
|
online.add(beforeAdd);
|
||||||
|
currentOnline = new FancyMessage(name).tooltip(getToolTips(p));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
FancyMessage beforeAdd = null;
|
||||||
|
try {
|
||||||
|
beforeAdd = currentOffline.clone();
|
||||||
|
} catch (CloneNotSupportedException ignored) {}
|
||||||
|
|
||||||
if (firstOffline) {
|
if (firstOffline) {
|
||||||
offline.then(name).tooltip(getToolTips(p));
|
currentOffline.then(name).tooltip(getToolTips(p));
|
||||||
} else {
|
} else {
|
||||||
offline.then(", " + name).tooltip(getToolTips(p));
|
currentOffline.then(", " + name).tooltip(getToolTips(p));
|
||||||
}
|
}
|
||||||
firstOffline = false;
|
firstOffline = false;
|
||||||
if (offline.toJSONString().length() > Short.MAX_VALUE) {
|
|
||||||
offline = new FancyMessage();
|
if (currentOffline.toJSONString().length() > Short.MAX_VALUE) {
|
||||||
|
offline.add(beforeAdd);
|
||||||
|
currentOffline = new FancyMessage(name).tooltip(getToolTips(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
online.add(currentOnline);
|
||||||
|
offline.add(currentOffline);
|
||||||
|
|
||||||
// Send all at once ;D
|
// Send all at once ;D
|
||||||
msg(p.txt.titleize(faction.getTag(fme)));
|
msg(p.txt.titleize(faction.getTag(fme)));
|
||||||
|
Loading…
Reference in New Issue
Block a user