Fixed War Spout feed and stats text not scaling with Spout settings (Small, Normal, Large, Auto). Much better now.

This commit is contained in:
taoneill 2012-01-29 11:28:31 -05:00
parent 4b69b14e10
commit ea454e3027
8 changed files with 54 additions and 54 deletions

View File

@ -39,7 +39,7 @@ import com.tommytony.war.job.HelmetProtectionTask;
import com.tommytony.war.job.SpoutFadeOutMessageJob;
import com.tommytony.war.mapper.WarYmlMapper;
import com.tommytony.war.mapper.WarzoneYmlMapper;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.WarHub;
import com.tommytony.war.structure.ZoneLobby;
import com.tommytony.war.utility.ChatFixUtil;
@ -86,7 +86,7 @@ public class War extends JavaPlugin {
private final WarConfigBag warConfig = new WarConfigBag();
private final WarzoneConfigBag warzoneDefaultConfig = new WarzoneConfigBag();
private final TeamConfigBag teamDefaultConfig = new TeamConfigBag();
private SpoutMessenger spoutMessenger = null;
private SpoutDisplayer spoutMessenger = null;
public War() {
super();
@ -121,7 +121,7 @@ public class War extends JavaPlugin {
try {
Class.forName("org.getspout.spoutapi.player.SpoutPlayer");
isSpoutServer = true;
spoutMessenger = new SpoutMessenger();
spoutMessenger = new SpoutDisplayer();
} catch (ClassNotFoundException e) {
isSpoutServer = false;
}
@ -912,7 +912,7 @@ public class War extends JavaPlugin {
return this.warConfig;
}
public SpoutMessenger getSpoutMessenger() {
public SpoutDisplayer getSpoutMessenger() {
return this.spoutMessenger ;
}
}

View File

@ -34,7 +34,7 @@ import com.tommytony.war.job.InitZoneJob;
import com.tommytony.war.job.LoadoutResetJob;
import com.tommytony.war.job.ScoreCapReachedJob;
import com.tommytony.war.mapper.LoadoutYmlMapper;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.Monument;
@ -818,8 +818,8 @@ public class Warzone {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()),
SpoutMessenger.cleanForNotification("ran out of lives."),
SpoutDisplayer.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()),
SpoutDisplayer.cleanForNotification("ran out of lives."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
10000);
@ -886,8 +886,8 @@ public class Warzone {
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."),
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
5000);
@ -915,8 +915,8 @@ public class Warzone {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.YELLOW + "."),
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.YELLOW + "."),
Material.TNT,
(short)0,
5000);
@ -940,8 +940,8 @@ public class Warzone {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "."),
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "."),
Material.CAKE,
(short)0,
5000);

View File

@ -11,7 +11,7 @@ public enum TeamKind {
BLUE ((byte) 3, Material.WOOL, ChatColor.BLUE, 23),
GOLD ((byte) 4, Material.WOOL, ChatColor.YELLOW, 403), // yellow = gold
GREEN ((byte) 5, Material.WOOL, ChatColor.GREEN, 612),
PINK ((byte) 6, Material.WOOL, ChatColor.WHITE, 929),
PINK ((byte) 6, Material.WOOL, ChatColor.LIGHT_PURPLE, 929),
GRAY ((byte) 7, Material.WOOL, ChatColor.DARK_GRAY, 600),
IRON ((byte) 8, Material.WOOL, ChatColor.GRAY, 154), // lightgrey = iron
DIAMOND ((byte) 9, Material.WOOL, ChatColor.DARK_AQUA, 738), // cyan = diamond
@ -67,11 +67,11 @@ public enum TeamKind {
case 3:
return new Color(0,0,255);
case 4:
return new Color(0,255,255);
return new Color(255,215,0);
case 5:
return new Color(0,255,0);
case 6:
return new Color(255,255,255);
return new Color(255,128,255);
case 7:
return new Color(100,100,100);
case 8:

View File

@ -25,7 +25,7 @@ import com.tommytony.war.Warzone;
import com.tommytony.war.config.FlagReturn;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.Monument;
@ -66,8 +66,8 @@ public class WarBlockListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
SpoutDisplayer.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
team.getKind().getMaterial(),
team.getKind().getData(),
10000);
@ -256,8 +256,8 @@ public class WarBlockListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
SpoutDisplayer.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
ownerTeam.getKind().getMaterial(),
ownerTeam.getKind().getData(),
10000);
@ -318,8 +318,8 @@ public class WarBlockListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " stole"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "your flag!"),
SpoutDisplayer.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " stole"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag!"),
lostFlagTeam.getKind().getMaterial(),
lostFlagTeam.getKind().getData(),
5000);
@ -363,8 +363,8 @@ public class WarBlockListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " has "),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.YELLOW + "!"),
SpoutDisplayer.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " has "),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.YELLOW + "!"),
Material.TNT,
(short)0,
5000);
@ -406,8 +406,8 @@ public class WarBlockListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " has "),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
SpoutDisplayer.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " has "),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
Material.CAKE,
(short)0,
5000);

View File

@ -42,7 +42,7 @@ import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.job.DeferredBlockResetsJob;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.utility.DeferredBlockReset;
@ -204,8 +204,8 @@ public class WarEntityListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(attackerTeam.getKind().getColor() + a.getName() + ChatColor.YELLOW + " made "),
SpoutMessenger.cleanForNotification(defenderTeam.getKind().getColor() + d.getName() + ChatColor.YELLOW + " blow up!"),
SpoutDisplayer.cleanForNotification(attackerTeam.getKind().getColor() + a.getName() + ChatColor.YELLOW + " made "),
SpoutDisplayer.cleanForNotification(defenderTeam.getKind().getColor() + d.getName() + ChatColor.YELLOW + " blow up!"),
Material.TNT,
(short)0,
10000);

View File

@ -39,7 +39,7 @@ import com.tommytony.war.command.ZoneSetter;
import com.tommytony.war.config.FlagReturn;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.WarHub;
@ -544,8 +544,8 @@ public class WarPlayerListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
10000);
@ -610,8 +610,8 @@ public class WarPlayerListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " blew up "),
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + "'s spawn!"),
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " blew up "),
SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + "'s spawn!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
10000);
@ -683,8 +683,8 @@ public class WarPlayerListener implements Listener {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
10000);

View File

@ -11,7 +11,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.tommytony.war.Team;
import com.tommytony.war.War;
import com.tommytony.war.Warzone;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.spout.SpoutDisplayer;
public class ScoreCapReachedJob implements Runnable {
@ -30,8 +30,8 @@ public class ScoreCapReachedJob implements Runnable {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification("Match won! " + ChatColor.WHITE + "Winners:"),
SpoutMessenger.cleanForNotification(SpoutMessenger.addMissingColor(winnersStr, zone)),
SpoutDisplayer.cleanForNotification("Match won! " + ChatColor.WHITE + "Winners:"),
SpoutDisplayer.cleanForNotification(SpoutDisplayer.addMissingColor(winnersStr, zone)),
Material.CAKE,
(short)0,
10000);

View File

@ -21,7 +21,7 @@ import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamKind;
public class SpoutMessenger {
public class SpoutDisplayer {
private static int LINE_HEIGHT = 5;
private static int LINE_HEIGHT_WITH_MARGIN = 8;
@ -123,10 +123,10 @@ public class SpoutMessenger {
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()) {
List<Integer> statsOffset = new ArrayList<Integer>();
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
List<GenericLabel> statsLines = getStatsLines(zone, statsOffset);
drawMessages(sp.getName(), statsLines, statsOffset);
}
}
@ -148,7 +148,7 @@ public class SpoutMessenger {
GenericLabel teamsHeader = new GenericLabel(ChatColor.GRAY + "War> " + ChatColor.WHITE + zone.getName());
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText()) + 1;
teamsHeader.setAlign(WidgetAnchor.TOP_LEFT)
teamsHeader.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3)
.setY(2)
.setWidth(teamsHeaderWidth)
@ -167,7 +167,7 @@ public class SpoutMessenger {
else {
line.setText(t.getKind().getColor() + teamStr.replace("(", ChatColor.GRAY + "(" + ChatColor.WHITE).replace(")", ChatColor.GRAY + ")" + ChatColor.WHITE));
}
line.setAlign(WidgetAnchor.TOP_LEFT)
line.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
@ -189,7 +189,7 @@ public class SpoutMessenger {
// points header
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "score");
int pointsHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
pointsHeader.setAlign(WidgetAnchor.TOP_LEFT)
pointsHeader.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 2)
.setY(2)
.setWidth(pointsHeaderWidth)
@ -202,7 +202,7 @@ public class SpoutMessenger {
// scores
line = new GenericLabel(t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE));
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
line.setAlign(WidgetAnchor.TOP_LEFT)
line.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
@ -223,7 +223,7 @@ public class SpoutMessenger {
// lifepool header
GenericLabel livesHeader = new GenericLabel(ChatColor.GRAY + "lives");
int livesHeaderWidth = GenericLabel.getStringWidth(livesHeader.getText());
livesHeader.setAlign(WidgetAnchor.TOP_LEFT)
livesHeader.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4 + scoreMax + 2)
.setY(2)
.setWidth(livesHeaderWidth)
@ -236,7 +236,7 @@ public class SpoutMessenger {
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.setAlign(WidgetAnchor.TOP_LEFT)
line.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4 + scoreMax + 4)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
@ -259,7 +259,7 @@ public class SpoutMessenger {
for (GenericLabel l : scorelines) { lines.add(l); }
for (GenericLabel l : lifelines) { lines.add(l); }
offset.add(3 + teamMax + 1 + scoreMax + 1 + lifeMax + 2);
offset.add(3 + teamMax + 1 + scoreMax + 1 + lifeMax + 5);
offset.add(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN);
}
@ -287,7 +287,7 @@ public class SpoutMessenger {
gradient.setAnchor(WidgetAnchor.TOP_LEFT);
gradient.setTopColor(new Color(0.0F, 0.0F, 0.0F, 0.4F)); // (order is Red, Green, Blue, Alpha)
gradient.setBottomColor(new Color(0.0F, 0.0F, 0.0F, 0.0F));
gradient.setHeight(statsOffset.get(1) + 4).setWidth((int)(statsOffset.get(0) * 1.15));
gradient.setHeight(statsOffset.get(1) + 4).setWidth((int)(statsOffset.get(0)));
player.getMainScreen().attachWidget(War.war, gradient);
@ -306,7 +306,7 @@ public class SpoutMessenger {
teamGradient.setY(2 + LINE_HEIGHT_WITH_MARGIN);
teamGradient.setTopColor(spoutColor);
teamGradient.setBottomColor(new Color(256, 256, 256, 1.0F));
teamGradient.setHeight(2).setWidth((int)(statsOffset.get(0) * 1.15));
teamGradient.setHeight(2).setWidth((int)(statsOffset.get(0)));
player.getMainScreen().attachWidget(War.war, teamGradient);
@ -335,7 +335,7 @@ public class SpoutMessenger {
GenericLabel label = new GenericLabel(word);
int width = GenericLabel.getStringWidth(word);
label.setAlign(WidgetAnchor.TOP_LEFT);
label.setAnchor(WidgetAnchor.TOP_LEFT);
label.setWidth(width);
label.setHeight(LINE_HEIGHT);
label.setX(horizontalOffset);