mirror of
https://github.com/taoneill/war.git
synced 2024-11-24 03:05:54 +01:00
Re-added Spout stats board in a more compact format, with messages now coming underneath the stats board at the top left of the screen. Added notification when flag is dropped.
This commit is contained in:
parent
9ff98d0bbf
commit
2adb328115
@ -64,7 +64,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
if (sp.isSpoutCraftEnabled()) {
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
sp.sendNotification(
|
sp.sendNotification(
|
||||||
SpoutMessenger.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
|
SpoutMessenger.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
|
||||||
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName()),
|
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
|
||||||
team.getKind().getMaterial(),
|
team.getKind().getMaterial(),
|
||||||
team.getKind().getData(),
|
team.getKind().getData(),
|
||||||
5000);
|
5000);
|
||||||
@ -218,7 +218,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
if (sp.isSpoutCraftEnabled()) {
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
sp.sendNotification(
|
sp.sendNotification(
|
||||||
SpoutMessenger.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
|
SpoutMessenger.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
|
||||||
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName()),
|
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
|
||||||
Material.OBSIDIAN,
|
Material.OBSIDIAN,
|
||||||
(short)0,
|
(short)0,
|
||||||
5000);
|
5000);
|
||||||
@ -278,7 +278,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
if (sp.isSpoutCraftEnabled()) {
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
sp.sendNotification(
|
sp.sendNotification(
|
||||||
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " stole"),
|
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " stole"),
|
||||||
SpoutMessenger.cleanForNotification("your flag!"),
|
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "your flag!"),
|
||||||
lostFlagTeam.getKind().getMaterial(),
|
lostFlagTeam.getKind().getMaterial(),
|
||||||
lostFlagTeam.getKind().getData(),
|
lostFlagTeam.getKind().getData(),
|
||||||
5000);
|
5000);
|
||||||
|
@ -150,6 +150,13 @@ public class WarEntityListener extends EntityListener {
|
|||||||
team.teamcast(killMessage);
|
team.teamcast(killMessage);
|
||||||
}
|
}
|
||||||
defenderWarzone.handleDeath(d);
|
defenderWarzone.handleDeath(d);
|
||||||
|
|
||||||
|
|
||||||
|
if (War.war.isSpoutServer()) {
|
||||||
|
// make sure score is updated
|
||||||
|
War.war.getSpoutMessenger().updateStats(defenderWarzone);
|
||||||
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
|
} else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
|
||||||
|
@ -517,7 +517,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
if (sp.isSpoutCraftEnabled()) {
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
sp.sendNotification(
|
sp.sendNotification(
|
||||||
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
|
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
|
||||||
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag"),
|
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
|
||||||
victim.getKind().getMaterial(),
|
victim.getKind().getMaterial(),
|
||||||
victim.getKind().getData(),
|
victim.getKind().getData(),
|
||||||
5000);
|
5000);
|
||||||
|
@ -1,21 +1,8 @@
|
|||||||
package bukkit.tommytony.war;
|
package bukkit.tommytony.war;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||||
import org.getspout.spoutapi.event.spout.SpoutListener;
|
import org.getspout.spoutapi.event.spout.SpoutListener;
|
||||||
import org.getspout.spoutapi.gui.Color;
|
|
||||||
import org.getspout.spoutapi.gui.GenericLabel;
|
|
||||||
import org.getspout.spoutapi.gui.WidgetAnchor;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
|
|
||||||
import com.tommytony.war.Team;
|
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.config.TeamConfig;
|
|
||||||
|
|
||||||
public class WarSpoutListener extends SpoutListener {
|
public class WarSpoutListener extends SpoutListener {
|
||||||
static Plugin plugin;
|
static Plugin plugin;
|
||||||
@ -31,101 +18,4 @@ public class WarSpoutListener extends SpoutListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateStats(Warzone zone) {
|
|
||||||
if (false) {
|
|
||||||
List<GenericLabel> teamlines = new ArrayList<GenericLabel>();
|
|
||||||
List<GenericLabel> playerlines = new ArrayList<GenericLabel>();
|
|
||||||
List<GenericLabel> scorelines = new ArrayList<GenericLabel>();
|
|
||||||
List<GenericLabel> lifelines = new ArrayList<GenericLabel>();
|
|
||||||
int teammax = -15, playmax = -15, scoremax = -15;
|
|
||||||
GenericLabel line;
|
|
||||||
|
|
||||||
// First, we collect all the team names
|
|
||||||
int linecounter = 0;
|
|
||||||
for (Team t : zone.getTeams()) {
|
|
||||||
// team name
|
|
||||||
line = new GenericLabel(t.getName());
|
|
||||||
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
|
|
||||||
else line.setTextColor(t.getKind().getSpoutColor());
|
|
||||||
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
|
||||||
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
|
||||||
teamlines.add(line);
|
|
||||||
linecounter++;
|
|
||||||
}
|
|
||||||
// We need to find the longest name
|
|
||||||
for (GenericLabel l : teamlines) {
|
|
||||||
if (GenericLabel.getStringWidth(l.getText()) > teammax) teammax=GenericLabel.getStringWidth(l.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now for the players
|
|
||||||
linecounter = 0;
|
|
||||||
for (Team t : zone.getTeams()) {
|
|
||||||
// player number
|
|
||||||
line = new GenericLabel("Players: "+t.getPlayers().size());
|
|
||||||
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
|
|
||||||
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
|
||||||
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
|
||||||
playerlines.add(line);
|
|
||||||
linecounter++;
|
|
||||||
}
|
|
||||||
// Again, we need the longest entry
|
|
||||||
for (GenericLabel l : playerlines) {
|
|
||||||
if (GenericLabel.getStringWidth(l.getText()) > playmax) playmax=GenericLabel.getStringWidth(l.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// is there even a score cap (or is it just 1 point)?
|
|
||||||
|
|
||||||
linecounter = 0;
|
|
||||||
for (Team t : zone.getTeams()) {
|
|
||||||
// scores
|
|
||||||
line = new GenericLabel(t.getPoints()+"/"+t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)+" points");
|
|
||||||
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
|
|
||||||
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
|
||||||
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15+playmax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
|
||||||
scorelines.add(line);
|
|
||||||
linecounter++;
|
|
||||||
}
|
|
||||||
// I bet you know what is done here!
|
|
||||||
for (GenericLabel l : scorelines) {
|
|
||||||
if (GenericLabel.getStringWidth(l.getText()) > scoremax) scoremax=GenericLabel.getStringWidth(l.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
// and finally, lives.
|
|
||||||
linecounter = 0;
|
|
||||||
for (Team t : zone.getTeams()) {
|
|
||||||
line = new GenericLabel(t.getRemainingLifes()+"/"+t.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL)+" lives");
|
|
||||||
if (t.getPlayers().size()==0) line.setTextColor(new Color(100,100,100));
|
|
||||||
line.setTooltip("Warzone: "+zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
|
||||||
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3+teammax+15+playmax+15+scoremax+15).setY(3+linecounter*(GenericLabel.getStringHeight("O")+3)).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
|
||||||
scorelines.add(line);
|
|
||||||
linecounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now to print it to the Spout players!
|
|
||||||
List<GenericLabel> lines = new ArrayList<GenericLabel>();
|
|
||||||
for (GenericLabel l : teamlines) lines.add(l);
|
|
||||||
for (GenericLabel l : playerlines) lines.add(l);
|
|
||||||
for (GenericLabel l : scorelines) lines.add(l);
|
|
||||||
for (GenericLabel l : lifelines) lines.add(l);
|
|
||||||
for (Team team : zone.getTeams()) {
|
|
||||||
for (Player player : team.getPlayers()) {
|
|
||||||
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
|
||||||
if (sp.isSpoutCraftEnabled()) {
|
|
||||||
drawStats(sp, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void drawStats(SpoutPlayer sp, List<GenericLabel> lines) {
|
|
||||||
// remove old stats first
|
|
||||||
removeStats(sp);
|
|
||||||
for (GenericLabel l : lines) sp.getMainScreen().attachWidget(plugin, l.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeStats(SpoutPlayer sp) {
|
|
||||||
//sp.getMainScreen().removeWidgets(plugin);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -323,10 +323,6 @@ public class Team {
|
|||||||
|
|
||||||
SignHelper.setToSign(War.war, signBlock, (byte) signData, lines);
|
SignHelper.setToSign(War.war, signBlock, (byte) signData, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (War.war.isSpoutServer()) {
|
|
||||||
WarSpoutListener.updateStats(warzone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBlock(int x, int y, int z, TeamKind kind) {
|
private void setBlock(int x, int y, int z, TeamKind kind) {
|
||||||
|
@ -787,6 +787,21 @@ public class Warzone {
|
|||||||
victim.getFlagVolume().resetBlocks();
|
victim.getFlagVolume().resetBlocks();
|
||||||
victim.initializeTeamFlag();
|
victim.initializeTeamFlag();
|
||||||
playerWarzone.removeThief(player.getName());
|
playerWarzone.removeThief(player.getName());
|
||||||
|
|
||||||
|
if (War.war.isSpoutServer()) {
|
||||||
|
for (Player p : victim.getPlayers()) {
|
||||||
|
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||||
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
|
sp.sendNotification(
|
||||||
|
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
|
||||||
|
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "your flag."),
|
||||||
|
playerTeam.getKind().getMaterial(),
|
||||||
|
playerTeam.getKind().getData(),
|
||||||
|
5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Team t : playerWarzone.getTeams()) {
|
for (Team t : playerWarzone.getTeams()) {
|
||||||
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
|
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
|
||||||
}
|
}
|
||||||
@ -844,14 +859,8 @@ public class Warzone {
|
|||||||
player.setFireTicks(0);
|
player.setFireTicks(0);
|
||||||
player.setRemainingAir(300);
|
player.setRemainingAir(300);
|
||||||
|
|
||||||
if (War.war.isSpoutServer()) {
|
// To hide stats
|
||||||
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
War.war.getSpoutMessenger().updateStats(player);
|
||||||
if (sp.isSpoutCraftEnabled()) {
|
|
||||||
WarSpoutListener.removeStats(sp);
|
|
||||||
sp.setTitle(ChatColor.WHITE + player.getName());
|
|
||||||
}
|
|
||||||
sp.resetTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
War.war.msg(player, "Your inventory is being restored.");
|
War.war.msg(player, "Your inventory is being restored.");
|
||||||
if (War.war.getWarHub() != null) {
|
if (War.war.getWarHub() != null) {
|
||||||
|
@ -41,16 +41,9 @@ public class ScoreCapReachedJob implements Runnable {
|
|||||||
}
|
}
|
||||||
String winnersStrAndExtra = "Score cap reached. Game is over! Winning team(s): " + this.winnersStr;
|
String winnersStrAndExtra = "Score cap reached. Game is over! Winning team(s): " + this.winnersStr;
|
||||||
winnersStrAndExtra += ". Resetting warzone and your inventory...";
|
winnersStrAndExtra += ". Resetting warzone and your inventory...";
|
||||||
t.teamcast(winnersStr);
|
t.teamcast(winnersStrAndExtra);
|
||||||
boolean isSpoutServer = War.war.isSpoutServer();
|
boolean isSpoutServer = War.war.isSpoutServer();
|
||||||
for (Player tp : t.getPlayers()) {
|
for (Player tp : t.getPlayers()) {
|
||||||
|
|
||||||
if (isSpoutServer) {
|
|
||||||
SpoutPlayer sp = SpoutManager.getPlayer(tp);
|
|
||||||
if (sp.isSpoutCraftEnabled()) {
|
|
||||||
WarSpoutListener.removeStats(sp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Send everyone to rally point (or zone lobby if not rally point)
|
// Send everyone to rally point (or zone lobby if not rally point)
|
||||||
if (this.zone.getRallyPoint() != null) {
|
if (this.zone.getRallyPoint() != null) {
|
||||||
tp.teleport(this.zone.getRallyPoint());
|
tp.teleport(this.zone.getRallyPoint());
|
||||||
|
@ -18,6 +18,7 @@ import bukkit.tommytony.war.War;
|
|||||||
import com.tommytony.war.Team;
|
import com.tommytony.war.Team;
|
||||||
import com.tommytony.war.TeamKind;
|
import com.tommytony.war.TeamKind;
|
||||||
import com.tommytony.war.Warzone;
|
import com.tommytony.war.Warzone;
|
||||||
|
import com.tommytony.war.config.TeamConfig;
|
||||||
|
|
||||||
public class SpoutMessenger {
|
public class SpoutMessenger {
|
||||||
|
|
||||||
@ -28,7 +29,11 @@ public class SpoutMessenger {
|
|||||||
playerMessages.put(sp.getName(), new ArrayList<PlayerMessage>());
|
playerMessages.put(sp.getName(), new ArrayList<PlayerMessage>());
|
||||||
}
|
}
|
||||||
playerMessages.get(sp.getName()).add(new PlayerMessage(message));
|
playerMessages.get(sp.getName()).add(new PlayerMessage(message));
|
||||||
drawMessages(sp.getName());
|
|
||||||
|
List<Integer> statsOffset = new ArrayList<Integer>();
|
||||||
|
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(sp.getName()), statsOffset);
|
||||||
|
drawMessages(sp.getName(), lines, statsOffset.get(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fadeOutOldMessages() {
|
public void fadeOutOldMessages() {
|
||||||
@ -48,7 +53,9 @@ public class SpoutMessenger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (toRemove.size() > 0) {
|
if (toRemove.size() > 0) {
|
||||||
drawMessages(playerName);
|
List<Integer> statsOffset = new ArrayList<Integer>();
|
||||||
|
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(playerName), statsOffset);
|
||||||
|
drawMessages(playerName, lines, statsOffset.get(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,7 +89,153 @@ public class SpoutMessenger {
|
|||||||
return toNotify;
|
return toNotify;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawMessages(String playerName) {
|
public void updateStats(Warzone zone) {
|
||||||
|
List<Integer> statsOffset = new ArrayList<Integer>();
|
||||||
|
List<GenericLabel> statsLines = getStatsLines(zone, statsOffset);
|
||||||
|
for (Team t : zone.getTeams()) {
|
||||||
|
for (Player p : t.getPlayers()) {
|
||||||
|
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||||
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
|
drawMessages(sp.getName(), statsLines, statsOffset.get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateStats(Player player) {
|
||||||
|
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
||||||
|
List<Integer> statsOffset = new ArrayList<Integer>();
|
||||||
|
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||||
|
List<GenericLabel> statsLines = getStatsLines(zone, statsOffset);
|
||||||
|
if (sp.isSpoutCraftEnabled()) {
|
||||||
|
drawMessages(sp.getName(), statsLines, statsOffset.get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<GenericLabel> getStatsLines(Warzone zone, List<Integer> offset) {
|
||||||
|
List<GenericLabel> lines = new ArrayList<GenericLabel>();
|
||||||
|
offset.add(0);
|
||||||
|
offset.add(0);
|
||||||
|
|
||||||
|
if (zone != null) {
|
||||||
|
offset.clear();
|
||||||
|
|
||||||
|
List<GenericLabel> teamlines = new ArrayList<GenericLabel>();
|
||||||
|
List<GenericLabel> playerlines = new ArrayList<GenericLabel>();
|
||||||
|
List<GenericLabel> scorelines = new ArrayList<GenericLabel>();
|
||||||
|
List<GenericLabel> lifelines = new ArrayList<GenericLabel>();
|
||||||
|
int teamMax = 5, scoreMax = 5, lifeMax = 5;
|
||||||
|
GenericLabel line;
|
||||||
|
|
||||||
|
GenericLabel teamsHeader = new GenericLabel(ChatColor.GRAY + "War> " + ChatColor.WHITE + zone.getName());
|
||||||
|
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText());
|
||||||
|
teamsHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(2).setY(2).setWidth(teamsHeaderWidth);
|
||||||
|
lines.add(teamsHeader);
|
||||||
|
|
||||||
|
// First, we collect all the team names
|
||||||
|
int lineCounter = 1;
|
||||||
|
for (Team t : zone.getTeams()) {
|
||||||
|
// team name
|
||||||
|
String teamStr = t.getName() + "-" + t.getPlayers().size() + "/" + t.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE);
|
||||||
|
line = new GenericLabel(teamStr);
|
||||||
|
if (t.getPlayers().size() == 0) {
|
||||||
|
line.setText(teamStr.replace("-", " "));
|
||||||
|
line.setTextColor(new Color(100,100,100));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line.setText(t.getKind().getColor() + teamStr.replace("-", " " + ChatColor.WHITE));
|
||||||
|
}
|
||||||
|
line.setTooltip("Warzone: " + zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
||||||
|
line.setAlign(WidgetAnchor.TOP_LEFT).setX(2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
||||||
|
teamlines.add(line);
|
||||||
|
lineCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to find the longest name
|
||||||
|
for (GenericLabel l : teamlines) {
|
||||||
|
if (GenericLabel.getStringWidth(l.getText()) > teamMax) {
|
||||||
|
teamMax = GenericLabel.getStringWidth(l.getText());
|
||||||
|
}
|
||||||
|
if (teamsHeaderWidth > teamMax) {
|
||||||
|
teamMax = teamsHeaderWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// First line with headers
|
||||||
|
int headerOffset = teamMax - 2;
|
||||||
|
|
||||||
|
GenericLabel livesHeader = new GenericLabel(ChatColor.GRAY + "points");
|
||||||
|
int pointsHeaderWidth = GenericLabel.getStringWidth(livesHeader.getText());
|
||||||
|
livesHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(headerOffset).setY(2).setWidth(pointsHeaderWidth);
|
||||||
|
headerOffset += pointsHeaderWidth + 6;
|
||||||
|
lines.add(livesHeader);
|
||||||
|
|
||||||
|
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "lives");
|
||||||
|
int livesHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
|
||||||
|
pointsHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(headerOffset).setY(2).setWidth(livesHeaderWidth);
|
||||||
|
lines.add(pointsHeader);
|
||||||
|
|
||||||
|
lineCounter = 1;
|
||||||
|
for (Team t : zone.getTeams()) {
|
||||||
|
// scores
|
||||||
|
line = new GenericLabel(t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE));
|
||||||
|
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
|
||||||
|
line.setTooltip("Warzone: " + zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
||||||
|
line.setAlign(WidgetAnchor.TOP_LEFT).setX(2 + teamMax + 2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
||||||
|
scorelines.add(line);
|
||||||
|
lineCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GenericLabel l : scorelines) {
|
||||||
|
if (GenericLabel.getStringWidth(l.getText()) > scoreMax) {
|
||||||
|
scoreMax = GenericLabel.getStringWidth(l.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pointsHeaderWidth > scoreMax) {
|
||||||
|
scoreMax = pointsHeaderWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// and finally, lives.
|
||||||
|
lineCounter = 1;
|
||||||
|
for (Team t : zone.getTeams()) {
|
||||||
|
line = new GenericLabel(t.getRemainingLifes() + "/" + t.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
|
||||||
|
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
|
||||||
|
line.setTooltip("Warzone: " + zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
|
||||||
|
line.setAlign(WidgetAnchor.TOP_LEFT).setX(2 + teamMax + 2 + scoreMax + 2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
||||||
|
lifelines.add(line);
|
||||||
|
lineCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GenericLabel l : lifelines) {
|
||||||
|
if (GenericLabel.getStringWidth(l.getText()) > lifeMax) {
|
||||||
|
lifeMax = GenericLabel.getStringWidth(l.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (livesHeaderWidth > lifeMax) {
|
||||||
|
lifeMax = livesHeaderWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GenericLabel l : teamlines) { lines.add(l); }
|
||||||
|
for (GenericLabel l : playerlines) { lines.add(l); }
|
||||||
|
for (GenericLabel l : scorelines) { lines.add(l); }
|
||||||
|
for (GenericLabel l : lifelines) { lines.add(l); }
|
||||||
|
|
||||||
|
offset.add(2 + teamMax + 2 + scoreMax + 2 + lifeMax + 2);
|
||||||
|
offset.add(2 + lineCounter * 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void drawStats(SpoutPlayer sp, List<GenericLabel> lines) {
|
||||||
|
for (GenericLabel l : lines) {
|
||||||
|
sp.getMainScreen().attachWidget(War.war, l.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawMessages(String playerName, List<GenericLabel> statsLines, Integer statsOffset) {
|
||||||
Player bukkitPlayer = War.war.getServer().getPlayer(playerName);
|
Player bukkitPlayer = War.war.getServer().getPlayer(playerName);
|
||||||
if (bukkitPlayer != null) {
|
if (bukkitPlayer != null) {
|
||||||
SpoutPlayer player = SpoutManager.getPlayer(bukkitPlayer);
|
SpoutPlayer player = SpoutManager.getPlayer(bukkitPlayer);
|
||||||
@ -91,20 +244,22 @@ public class SpoutMessenger {
|
|||||||
// remove old widgets
|
// remove old widgets
|
||||||
clear(player);
|
clear(player);
|
||||||
|
|
||||||
|
drawStats(player, statsLines);
|
||||||
|
|
||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
int rank = 0;
|
int rank = 0;
|
||||||
Warzone zone = Warzone.getZoneByPlayerName(playerName);
|
Warzone zone = Warzone.getZoneByPlayerName(playerName);
|
||||||
int verticalOffset = 2;
|
int verticalOffset = statsOffset + 4;
|
||||||
|
|
||||||
for (PlayerMessage message : messages) {
|
for (PlayerMessage message : messages) {
|
||||||
int horizontalOffset = 2;
|
int horizontalOffset = 2;
|
||||||
|
|
||||||
String messageStr = "War> " + message.getMessage();
|
String messageStr = ChatColor.GRAY + ">" + ChatColor.WHITE + " " + message.getMessage();
|
||||||
String[] words = messageStr.split(" ");
|
String[] words = messageStr.split(" ");
|
||||||
|
|
||||||
for (String word : words) {
|
for (String word : words) {
|
||||||
|
|
||||||
if (horizontalOffset > 230) {
|
if (horizontalOffset > 160) {
|
||||||
horizontalOffset = 2;
|
horizontalOffset = 2;
|
||||||
verticalOffset += 8;
|
verticalOffset += 8;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user