Fix clients getting kicked from too many allies/enemies.
This commit is contained in:
parent
b970755cb1
commit
356842ab41
@ -11,6 +11,7 @@ import com.massivecraft.factions.struct.Role;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class CmdShow extends FCommand {
|
||||
@ -87,32 +88,46 @@ public class CmdShow extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
FancyMessage allies = new FancyMessage("Allies: ").color(ChatColor.GOLD);
|
||||
FancyMessage enemies = new FancyMessage("Enemies: ").color(ChatColor.GOLD);
|
||||
boolean firstAlly = true;
|
||||
boolean firstEnemy = true;
|
||||
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
||||
if (otherFaction == faction) {
|
||||
continue;
|
||||
}
|
||||
ArrayList<FancyMessage> allies = new ArrayList<FancyMessage>();
|
||||
ArrayList<FancyMessage> enemies = new ArrayList<FancyMessage>();
|
||||
FancyMessage currentAllies = new FancyMessage("Allies: ").color(ChatColor.GOLD);
|
||||
FancyMessage currentEnemies = new FancyMessage("Enemies: ").color(ChatColor.GOLD);
|
||||
|
||||
Relation rel = otherFaction.getRelationTo(faction);
|
||||
String s = otherFaction.getTag(fme);
|
||||
if (rel.isAlly()) {
|
||||
if (firstAlly)
|
||||
allies.then(s).tooltip(getToolTips(otherFaction));
|
||||
else
|
||||
alies.then(", " + s).tooltip(getToolTips(otherFaction));
|
||||
firstAlly = false;
|
||||
} else if (rel.isEnemy()) {
|
||||
if (firstEnemy)
|
||||
enemies.then(s).tooltip(getToolTips(otherFaction));
|
||||
else
|
||||
enemies.then(", " + s).tooltip(getToolTips(otherFaction));
|
||||
firstEnemy = false;
|
||||
}
|
||||
}
|
||||
boolean firstAlly = true;
|
||||
boolean firstEnemy = true;
|
||||
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
|
||||
if (otherFaction == faction) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Relation rel = otherFaction.getRelationTo(faction);
|
||||
String s = otherFaction.getTag(fme);
|
||||
if (rel.isAlly()) {
|
||||
if (firstAlly)
|
||||
currentAllies.then(s).tooltip(getToolTips(otherFaction));
|
||||
else
|
||||
currentAllies.then(", " + s).tooltip(getToolTips(otherFaction));
|
||||
firstAlly = false;
|
||||
|
||||
if (currentAllies.toJSONString().length() >= 32700) { // Client gets kicked at 32767, some leniency
|
||||
allies.add(currentAllies);
|
||||
currentAllies = new FancyMessage();
|
||||
}
|
||||
} else if (rel.isEnemy()) {
|
||||
if (firstEnemy)
|
||||
currentEnemies.then(s).tooltip(getToolTips(otherFaction));
|
||||
else
|
||||
currentEnemies.then(", " + s).tooltip(getToolTips(otherFaction));
|
||||
firstEnemy = false;
|
||||
|
||||
if (currentEnemies.toJSONString().length() >= 32700) { // Client gets kicked at 32767, some leniency
|
||||
enemies.add(currentEnemies);
|
||||
currentEnemies = new FancyMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
allies.add(currentAllies);
|
||||
enemies.add(currentEnemies);
|
||||
|
||||
FancyMessage online = new FancyMessage("Members online: ").color(ChatColor.GOLD);
|
||||
FancyMessage offline = new FancyMessage("Members offline: ").color(ChatColor.GOLD);
|
||||
|
Loading…
Reference in New Issue
Block a user