Fixed War without Spout being broken. Made 'monument freed' notification use owner team wool block.

This commit is contained in:
taoneill 2012-01-09 23:44:40 -05:00
parent 25bbf5b185
commit 38c91b5623
4 changed files with 21 additions and 11 deletions

View File

@ -90,7 +90,7 @@ public class War extends JavaPlugin {
private final WarConfigBag warConfig = new WarConfigBag(); private final WarConfigBag warConfig = new WarConfigBag();
private final WarzoneConfigBag warzoneDefaultConfig = new WarzoneConfigBag(); private final WarzoneConfigBag warzoneDefaultConfig = new WarzoneConfigBag();
private final TeamConfigBag teamDefaultConfig = new TeamConfigBag(); private final TeamConfigBag teamDefaultConfig = new TeamConfigBag();
private SpoutMessenger spoutMessenger = new SpoutMessenger(); private SpoutMessenger spoutMessenger = null;
public War() { public War() {
super(); super();
@ -128,6 +128,7 @@ public class War extends JavaPlugin {
try { try {
Class.forName("org.getspout.spoutapi.player.SpoutPlayer"); Class.forName("org.getspout.spoutapi.player.SpoutPlayer");
isSpoutServer = true; isSpoutServer = true;
spoutMessenger = new SpoutMessenger();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
isSpoutServer = false; isSpoutServer = false;
} }
@ -264,8 +265,10 @@ public class War extends JavaPlugin {
HelmetProtectionTask helmetProtectionTask = new HelmetProtectionTask(); HelmetProtectionTask helmetProtectionTask = new HelmetProtectionTask();
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, helmetProtectionTask, 250, 100); this.getServer().getScheduler().scheduleSyncRepeatingTask(this, helmetProtectionTask, 250, 100);
SpoutFadeOutMessageJob fadeOutMessagesTask = new SpoutFadeOutMessageJob(); if (this.isSpoutServer) {
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, fadeOutMessagesTask, 100, 100); SpoutFadeOutMessageJob fadeOutMessagesTask = new SpoutFadeOutMessageJob();
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, fadeOutMessagesTask, 100, 100);
}
this.log("War v" + this.desc.getVersion() + " is on.", Level.INFO); this.log("War v" + this.desc.getVersion() + " is on.", Level.INFO);
} }

View File

@ -212,6 +212,7 @@ public class WarBlockListener extends BlockListener {
Monument monument = warzone.getMonumentFromCenterBlock(block); Monument monument = warzone.getMonumentFromCenterBlock(block);
if (monument.hasOwner()) { if (monument.hasOwner()) {
List<Team> teams = warzone.getTeams(); List<Team> teams = warzone.getTeams();
Team ownerTeam = monument.getOwnerTeam();
if (War.war.isSpoutServer()) { if (War.war.isSpoutServer()) {
for (Player p : team.getPlayers()) { for (Player p : team.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p); SpoutPlayer sp = SpoutManager.getPlayer(p);
@ -219,14 +220,14 @@ public class WarBlockListener extends BlockListener {
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() + ChatColor.YELLOW + "!"), SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
Material.OBSIDIAN, ownerTeam.getKind().getMaterial(),
(short)0, ownerTeam.getKind().getData(),
5000); 5000);
} }
} }
} }
for (Team t : teams) { for (Team t : teams) {
t.teamcast("Team " + monument.getOwnerTeam().getName() + " loses control of monument " + monument.getName()); t.teamcast("Team " + ownerTeam.getName() + " loses control of monument " + monument.getName());
} }
monument.uncapture(); monument.uncapture();
} }

View File

@ -364,10 +364,14 @@ public class Team {
public void teamcast(String message, boolean isNotification) { public void teamcast(String message, boolean isNotification) {
for (Player player : this.players) { for (Player player : this.players) {
SpoutPlayer sp = SpoutManager.getPlayer(player); if (War.war.isSpoutServer()) {
if (sp.isSpoutCraftEnabled() && isNotification) { SpoutPlayer sp = SpoutManager.getPlayer(player);
// team notifications go to the top left for Spout players to lessen War spam in chat box if (sp.isSpoutCraftEnabled() && isNotification) {
War.war.getSpoutMessenger().msg(sp, message); // team notifications go to the top left for Spout players to lessen War spam in chat box
War.war.getSpoutMessenger().msg(sp, message);
} else {
War.war.msg(player, message);
}
} else { } else {
War.war.msg(player, message); War.war.msg(player, message);
} }

View File

@ -860,7 +860,9 @@ public class Warzone {
player.setRemainingAir(300); player.setRemainingAir(300);
// To hide stats // To hide stats
War.war.getSpoutMessenger().updateStats(player); if (War.war.isSpoutServer()) {
War.war.getSpoutMessenger().updateStats(player);
}
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) {