mirror of
https://github.com/taoneill/war.git
synced 2025-01-03 06:17:33 +01:00
Drop Spoutcraft support
Spout has been dead for 5 years
This commit is contained in:
parent
81f839a0a2
commit
6b90371fce
@ -17,7 +17,6 @@ Features
|
||||
- Other game types: capture points and explosive-based objectives
|
||||
- Up to 16 teams!
|
||||
- Tons of customizable game rules, item loadouts and options (see [Instructions](http://war.tommytony.com/instructions))
|
||||
- SpoutPlugin integration for an enriched UI experience during combat for Spoutcraft users (http://spout.org)
|
||||
|
||||
Downloads
|
||||
---------
|
||||
|
@ -102,13 +102,6 @@
|
||||
</resources>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>spoutplugin</artifactId>
|
||||
<version>1.5.2-R1.0</version>
|
||||
<scope>compile</scope>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.tommytony.war;
|
||||
|
||||
import com.tommytony.war.config.*;
|
||||
import com.tommytony.war.spout.SpoutDisplayer;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -15,8 +14,6 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Sign;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.kitteh.tag.TagAPI;
|
||||
|
||||
import java.io.File;
|
||||
@ -341,10 +338,6 @@ public class Team {
|
||||
}
|
||||
block.update(true);
|
||||
}
|
||||
|
||||
if (War.war.isSpoutServer()) {
|
||||
War.war.getSpoutDisplayer().updateStats(this.warzone);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlock(int x, int y, int z, TeamKind kind) {
|
||||
@ -395,17 +388,7 @@ public class Team {
|
||||
|
||||
public void teamcast(String message, boolean isNotification) {
|
||||
for (Player player : this.players) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
||||
if (sp.isSpoutCraftEnabled() && isNotification) {
|
||||
// team notifications go to the top left for Spout players to lessen War spam in chat box
|
||||
War.war.getSpoutDisplayer().msg(sp, message);
|
||||
} else {
|
||||
War.war.msg(player, message);
|
||||
}
|
||||
} else {
|
||||
War.war.msg(player, message);
|
||||
}
|
||||
War.war.msg(player, message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,17 +399,7 @@ public class Team {
|
||||
|
||||
public void teamcast(String message, boolean isNotification, Object... args) {
|
||||
for (Player player : this.players) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
||||
if (sp.isSpoutCraftEnabled() && isNotification) {
|
||||
// team notifications go to the top left for Spout players to lessen War spam in chat box
|
||||
War.war.getSpoutDisplayer().msg(sp, MessageFormat.format(message, args));
|
||||
} else {
|
||||
War.war.msg(player, message, args);
|
||||
}
|
||||
} else {
|
||||
War.war.msg(player, message, args);
|
||||
}
|
||||
War.war.msg(player, message, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,16 +412,6 @@ public class Team {
|
||||
* @param ticks Duration the achievement should be displayed
|
||||
*/
|
||||
public void sendAchievement(String line1, String line2, ItemStack icon, int ticks) {
|
||||
if (!War.war.isSpoutServer())
|
||||
return;
|
||||
line1 = SpoutDisplayer.cleanForNotification(line1);
|
||||
line2 = SpoutDisplayer.cleanForNotification(line2);
|
||||
for (Player player : this.players) {
|
||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
if (!spoutPlayer.isSpoutCraftEnabled())
|
||||
continue;
|
||||
spoutPlayer.sendNotification(line1, line2, icon, ticks);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -468,9 +431,6 @@ public class Team {
|
||||
if (War.war.isTagServer()) {
|
||||
TagAPI.refreshPlayer(thePlayer);
|
||||
}
|
||||
if (War.war.isSpoutServer()) {
|
||||
War.war.getSpoutDisplayer().updateStats(thePlayer);
|
||||
}
|
||||
thePlayer.setFireTicks(0);
|
||||
thePlayer.setRemainingAir(300);
|
||||
if (!this.warzone.getReallyDeadFighters().contains(thePlayer.getName())) {
|
||||
|
@ -2,14 +2,15 @@ package com.tommytony.war;
|
||||
|
||||
import com.tommytony.war.command.WarCommandHandler;
|
||||
import com.tommytony.war.config.*;
|
||||
import com.tommytony.war.event.*;
|
||||
import com.tommytony.war.event.WarBlockListener;
|
||||
import com.tommytony.war.event.WarEntityListener;
|
||||
import com.tommytony.war.event.WarPlayerListener;
|
||||
import com.tommytony.war.event.WarTagListener;
|
||||
import com.tommytony.war.job.CapturePointTimer;
|
||||
import com.tommytony.war.job.HelmetProtectionTask;
|
||||
import com.tommytony.war.job.ScoreboardSwitchTimer;
|
||||
import com.tommytony.war.job.SpoutFadeOutMessageJob;
|
||||
import com.tommytony.war.mapper.WarYmlMapper;
|
||||
import com.tommytony.war.mapper.WarzoneYmlMapper;
|
||||
import com.tommytony.war.spout.SpoutDisplayer;
|
||||
import com.tommytony.war.structure.*;
|
||||
import com.tommytony.war.ui.UIManager;
|
||||
import com.tommytony.war.utility.*;
|
||||
@ -65,11 +66,9 @@ public class War extends JavaPlugin {
|
||||
private WarPlayerListener playerListener = new WarPlayerListener();
|
||||
private WarEntityListener entityListener = new WarEntityListener();
|
||||
private WarBlockListener blockListener = new WarBlockListener();
|
||||
private WarServerListener serverListener = new WarServerListener();
|
||||
private WarCommandHandler commandHandler = new WarCommandHandler();
|
||||
private PluginDescriptionFile desc = null;
|
||||
private boolean loaded = false;
|
||||
private boolean isSpoutServer = false;
|
||||
private boolean tagServer = false;
|
||||
// Zones and hub
|
||||
private List<Warzone> warzones = new ArrayList<Warzone>();
|
||||
@ -78,7 +77,6 @@ public class War extends JavaPlugin {
|
||||
private KillstreakReward killstreakReward;
|
||||
private MySQLConfig mysqlConfig;
|
||||
private Economy econ = null;
|
||||
private SpoutDisplayer spoutMessenger = null;
|
||||
private HubLobbyMaterials warhubMaterials = new HubLobbyMaterials(
|
||||
new ItemStack(Material.GLASS), new ItemStack(Material.OAK_WOOD),
|
||||
new ItemStack(Material.OBSIDIAN), new ItemStack(Material.GLOWSTONE));
|
||||
@ -121,14 +119,6 @@ public class War extends JavaPlugin {
|
||||
this.setLoaded(true);
|
||||
this.desc = this.getDescription();
|
||||
|
||||
// Spout server detection
|
||||
try {
|
||||
Class.forName("org.getspout.spoutapi.player.SpoutPlayer");
|
||||
isSpoutServer = true;
|
||||
spoutMessenger = new SpoutDisplayer();
|
||||
} catch (ClassNotFoundException e) {
|
||||
isSpoutServer = false;
|
||||
}
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC").newInstance();
|
||||
} catch (Exception e) {
|
||||
@ -143,7 +133,6 @@ public class War extends JavaPlugin {
|
||||
pm.registerEvents(this.playerListener, this);
|
||||
pm.registerEvents(this.entityListener, this);
|
||||
pm.registerEvents(this.blockListener, this);
|
||||
pm.registerEvents(this.serverListener, this);
|
||||
pm.registerEvents(this.UIManager, this);
|
||||
if (pm.isPluginEnabled("TagAPI")) {
|
||||
try {
|
||||
@ -269,10 +258,6 @@ public class War extends JavaPlugin {
|
||||
ScoreboardSwitchTimer sst = new ScoreboardSwitchTimer();
|
||||
sst.runTaskTimer(this, 500, 20 * 60);
|
||||
|
||||
if (this.isSpoutServer) {
|
||||
SpoutFadeOutMessageJob fadeOutMessagesTask = new SpoutFadeOutMessageJob();
|
||||
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, fadeOutMessagesTask, 100, 100);
|
||||
}
|
||||
if (this.mysqlConfig.isEnabled()) {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
||||
@ -1166,10 +1151,6 @@ public class War extends JavaPlugin {
|
||||
this.wandBearers.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSpoutServer() {
|
||||
return this.isSpoutServer;
|
||||
}
|
||||
|
||||
public Warzone zoneOfZoneWallAtProximity(Location location) {
|
||||
for (Warzone zone : this.warzones) {
|
||||
@ -1248,10 +1229,6 @@ public class War extends JavaPlugin {
|
||||
return this.warConfig;
|
||||
}
|
||||
|
||||
public SpoutDisplayer getSpoutDisplayer() {
|
||||
return this.spoutMessenger ;
|
||||
}
|
||||
|
||||
public HubLobbyMaterials getWarhubMaterials() {
|
||||
return this.warhubMaterials;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import com.tommytony.war.job.ZoneTimeJob;
|
||||
import com.tommytony.war.mapper.LoadoutYmlMapper;
|
||||
import com.tommytony.war.mapper.VolumeMapper;
|
||||
import com.tommytony.war.mapper.ZoneVolumeMapper;
|
||||
import com.tommytony.war.spout.SpoutDisplayer;
|
||||
import com.tommytony.war.structure.*;
|
||||
import com.tommytony.war.utility.*;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
@ -44,8 +43,6 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -529,11 +526,6 @@ public class Warzone {
|
||||
this.getLoadoutSelections().get(player.getName()).setStillInSpawn(true);
|
||||
}
|
||||
|
||||
// Spout
|
||||
if (War.war.isSpoutServer()) {
|
||||
SpoutManager.getPlayer(player).setTitle(team.getKind().getColor() + player.getName());
|
||||
}
|
||||
|
||||
War.war.getKillstreakReward().getAirstrikePlayers().remove(player.getName());
|
||||
|
||||
final LoadoutResetJob job = new LoadoutResetJob(this, team, player, isFirstRespawn, false);
|
||||
@ -641,9 +633,6 @@ public class Warzone {
|
||||
ItemStack[] contents = inventory.getContents();
|
||||
|
||||
String playerTitle = player.getName();
|
||||
if (War.war.isSpoutServer()) {
|
||||
playerTitle = SpoutManager.getPlayer(player).getTitle();
|
||||
}
|
||||
|
||||
this.playerStates.put(
|
||||
player.getName(),
|
||||
@ -675,9 +664,6 @@ public class Warzone {
|
||||
player.setExp(originalState.getExp());
|
||||
player.setAllowFlight(originalState.canFly());
|
||||
|
||||
if (War.war.isSpoutServer()) {
|
||||
SpoutManager.getPlayer(player).setTitle(originalState.getPlayerTitle());
|
||||
}
|
||||
}
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
}
|
||||
@ -1508,19 +1494,6 @@ public class Warzone {
|
||||
War.war.getServer().getPluginManager().callEvent(event1);
|
||||
|
||||
for (Team t : this.getTeams()) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
SpoutDisplayer.cleanForNotification("Match won! " + ChatColor.WHITE + "Winners:"),
|
||||
SpoutDisplayer.cleanForNotification(SpoutDisplayer.addMissingColor(winnersStr, this)),
|
||||
Material.CAKE,
|
||||
(short)0,
|
||||
10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
String winnersStrAndExtra = "Score cap reached. Game is over! Winning team(s): " + winnersStr;
|
||||
winnersStrAndExtra += ". Resetting warzone and your inventory...";
|
||||
t.teamcast(winnersStrAndExtra);
|
||||
@ -1777,9 +1750,6 @@ public class Warzone {
|
||||
playerItems.put(103, originalState.getHelmet());
|
||||
}
|
||||
|
||||
if (War.war.isSpoutServer()) {
|
||||
SpoutManager.getPlayer(player).setTitle(originalState.getPlayerTitle());
|
||||
}
|
||||
}
|
||||
|
||||
return playerItems;
|
||||
|
@ -6,9 +6,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
|
||||
public enum TeamKind {
|
||||
WHITE (DyeColor.WHITE, Material.WHITE_WOOL, ChatColor.WHITE, 450),
|
||||
@ -77,17 +74,6 @@ public enum TeamKind {
|
||||
return this.chatColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color of this team in the Spout client GUI.
|
||||
*
|
||||
* @return spout chat GUI color
|
||||
*/
|
||||
public Color getSpoutColor() {
|
||||
return new org.getspout.spoutapi.gui.Color(
|
||||
dyeColor.getColor().getRed(), dyeColor.getColor().getGreen(),
|
||||
dyeColor.getColor().getBlue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color of the wool block as a bukkit color.
|
||||
*
|
||||
|
@ -6,7 +6,6 @@ import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.config.TeamConfig;
|
||||
import com.tommytony.war.config.WarConfig;
|
||||
import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.spout.SpoutDisplayer;
|
||||
import com.tommytony.war.structure.Bomb;
|
||||
import com.tommytony.war.structure.Cake;
|
||||
import com.tommytony.war.structure.Monument;
|
||||
@ -25,8 +24,6 @@ import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -57,19 +54,6 @@ public class WarBlockListener implements Listener {
|
||||
Monument monument = zone.getMonumentFromCenterBlock(block);
|
||||
if (monument != null && !monument.hasOwner()) {
|
||||
monument.capture(team);
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : team.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
zone.broadcast("zone.monument.capture", monument.getName(), team.getName());
|
||||
event.setCancelled(false);
|
||||
return; // important otherwise cancelled down a few line by isImportantblock
|
||||
@ -257,19 +241,6 @@ public class WarBlockListener implements Listener {
|
||||
Monument monument = warzone.getMonumentFromCenterBlock(block);
|
||||
if (monument.hasOwner()) {
|
||||
Team ownerTeam = monument.getOwnerTeam();
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : team.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
warzone.broadcast("zone.monument.lose", ownerTeam.getName(), monument.getName());
|
||||
monument.uncapture();
|
||||
}
|
||||
@ -309,19 +280,6 @@ public class WarBlockListener implements Listener {
|
||||
for (Team t : warzone.getTeams()) {
|
||||
t.teamcast("zone.steal.flag.broadcast", team.getKind().getColor() + player.getName() + ChatColor.WHITE, lostFlagTeam.getName());
|
||||
if (t.getName().equals(lostFlagTeam.getName())) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
SpoutDisplayer.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " stole"),
|
||||
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag!"),
|
||||
lostFlagTeam.getKind().getMaterial(),
|
||||
lostFlagTeam.getKind().getData(),
|
||||
5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.teamcast("zone.steal.flag.prevent", team.getKind().getColor() + player.getName() + ChatColor.WHITE, team.getName());
|
||||
}
|
||||
}
|
||||
@ -349,19 +307,6 @@ public class WarBlockListener implements Listener {
|
||||
block.setType(Material.AIR);
|
||||
for (Team t : warzone.getTeams()) {
|
||||
t.teamcast("zone.steal.bomb.broadcast", team.getKind().getColor() + player.getName() + ChatColor.WHITE, ChatColor.GREEN + bomb.getName() + ChatColor.WHITE);
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.teamcast("zone.steal.bomb.prevent", team.getKind().getColor() + player.getName() + ChatColor.WHITE);
|
||||
}
|
||||
War.war.msg(player, "zone.steal.bomb.notice", bomb.getName());
|
||||
@ -385,19 +330,6 @@ public class WarBlockListener implements Listener {
|
||||
block.setType(Material.AIR);
|
||||
for (Team t : warzone.getTeams()) {
|
||||
t.teamcast("zone.steal.cake.broadcast", team.getKind().getColor() + player.getName() + ChatColor.WHITE, ChatColor.GREEN + cake.getName() + ChatColor.WHITE);
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.teamcast("zone.steal.cake.prevent", team.getKind().getColor() + player.getName() + ChatColor.WHITE);
|
||||
}
|
||||
War.war.msg(player, "zone.steal.cake.notice", cake.getName());
|
||||
|
@ -1,16 +1,24 @@
|
||||
package com.tommytony.war.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.Warzone.LeaveCause;
|
||||
import com.tommytony.war.command.ZoneSetter;
|
||||
import com.tommytony.war.config.FlagReturn;
|
||||
import com.tommytony.war.config.TeamConfig;
|
||||
import com.tommytony.war.config.WarConfig;
|
||||
|
||||
import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.structure.Bomb;
|
||||
import com.tommytony.war.structure.Cake;
|
||||
import com.tommytony.war.structure.WarHub;
|
||||
import com.tommytony.war.structure.ZoneLobby;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.utility.Loadout;
|
||||
import com.tommytony.war.utility.LoadoutSelection;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Item;
|
||||
@ -26,29 +34,11 @@ import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
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.Warzone.LeaveCause;
|
||||
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.SpoutDisplayer;
|
||||
import com.tommytony.war.structure.Bomb;
|
||||
import com.tommytony.war.structure.Cake;
|
||||
import com.tommytony.war.structure.WarHub;
|
||||
import com.tommytony.war.structure.ZoneLobby;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.utility.Loadout;
|
||||
import com.tommytony.war.utility.LoadoutSelection;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
@ -636,19 +626,6 @@ public class WarPlayerListener implements Listener {
|
||||
|
||||
// Notify everyone
|
||||
for (Team t : playerWarzone.getTeams()) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.teamcast("zone.flagcapture.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
|
||||
victim.getName(), playerTeam.getName());
|
||||
}
|
||||
@ -716,19 +693,6 @@ public class WarPlayerListener implements Listener {
|
||||
|
||||
// Notify everyone
|
||||
for (Team t : playerWarzone.getTeams()) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.teamcast("zone.bomb.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
|
||||
victim.getName(), playerTeam.getName());
|
||||
}
|
||||
@ -801,19 +765,6 @@ public class WarPlayerListener implements Listener {
|
||||
|
||||
// Notify everyone
|
||||
for (Team t : playerWarzone.getTeams()) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player p : t.getPlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(p);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.sendNotification(
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
t.teamcast("zone.cake.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
|
||||
ChatColor.GREEN + cake.getName() + ChatColor.WHITE, playerTeam.getName());
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package com.tommytony.war.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
|
||||
public class WarServerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginDisable(final PluginDisableEvent event) {
|
||||
if (event.getPlugin().getDataFolder().getName().equals("Spout")) {
|
||||
if (War.war.isSpoutServer()) {
|
||||
for (Player player : War.war.getServer().getOnlinePlayers()) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
||||
if (sp.isSpoutCraftEnabled()) {
|
||||
sp.getMainScreen().removeWidgets(War.war);
|
||||
}
|
||||
}
|
||||
War.war.getSpoutDisplayer().clearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,18 @@
|
||||
package com.tommytony.war.job;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.mapper.WarzoneYmlMapper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import org.mcstats.Metrics;
|
||||
import org.mcstats.Metrics.Graph;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class RestoreYmlWarzonesJob implements Runnable {
|
||||
|
||||
private final List<String> warzones;
|
||||
@ -63,9 +60,6 @@ public class RestoreYmlWarzonesJob implements Runnable {
|
||||
}
|
||||
language.addPlotter(new PlotterEnabled(langName));
|
||||
Graph plugins = metrics.createGraph("Extensions");
|
||||
if (War.war.isSpoutServer()) {
|
||||
plugins.addPlotter(new PlotterEnabled("Spout"));
|
||||
}
|
||||
if (War.war.isTagServer()) {
|
||||
plugins.addPlotter(new PlotterEnabled("TagAPI"));
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package com.tommytony.war.job;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
|
||||
public class SpoutFadeOutMessageJob implements Runnable {
|
||||
|
||||
public SpoutFadeOutMessageJob() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
War.war.getSpoutDisplayer().fadeOutOldMessages();
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.tommytony.war.spout;
|
||||
|
||||
public class PlayerMessage {
|
||||
|
||||
private final String message;
|
||||
private final long sendTime;
|
||||
|
||||
public PlayerMessage(String message) {
|
||||
this.message = message;
|
||||
this.sendTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public long getSendTime() {
|
||||
return sendTime;
|
||||
}
|
||||
}
|
@ -1,396 +0,0 @@
|
||||
package com.tommytony.war.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericGradient;
|
||||
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.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.config.TeamConfig;
|
||||
import com.tommytony.war.config.TeamKind;
|
||||
|
||||
public class SpoutDisplayer {
|
||||
|
||||
private static int LINE_HEIGHT = 5;
|
||||
private static int LINE_HEIGHT_WITH_MARGIN = 8;
|
||||
|
||||
Map<String, List<PlayerMessage>> playerMessages = new HashMap<String, List<PlayerMessage>>();
|
||||
|
||||
public void msg(SpoutPlayer sp, String message) {
|
||||
if (!playerMessages.containsKey(sp.getName())) {
|
||||
playerMessages.put(sp.getName(), new ArrayList<PlayerMessage>());
|
||||
}
|
||||
List<PlayerMessage> messages = playerMessages.get(sp.getName());
|
||||
messages.add(new PlayerMessage(message));
|
||||
|
||||
// prevent huge stack of messages, 5 max
|
||||
if (messages.size() > 5) {
|
||||
// remove first
|
||||
messages.remove(0);
|
||||
}
|
||||
|
||||
List<Integer> statsOffset = new ArrayList<Integer>();
|
||||
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(sp.getName()), statsOffset);
|
||||
|
||||
drawMessages(sp.getName(), lines, statsOffset);
|
||||
}
|
||||
|
||||
public void fadeOutOldMessages() {
|
||||
for (String playerName : playerMessages.keySet()) {
|
||||
List<PlayerMessage> messages = playerMessages.get(playerName);
|
||||
List<PlayerMessage> toRemove = new ArrayList<PlayerMessage>();
|
||||
|
||||
for (PlayerMessage message : messages) {
|
||||
if (System.currentTimeMillis() - message.getSendTime() > 15000) {
|
||||
|
||||
toRemove.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
for (PlayerMessage removing : toRemove) {
|
||||
messages.remove(removing);
|
||||
}
|
||||
|
||||
if (toRemove.size() > 0) {
|
||||
List<Integer> statsOffset = new ArrayList<Integer>();
|
||||
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(playerName), statsOffset);
|
||||
drawMessages(playerName, lines, statsOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clear(SpoutPlayer player) {
|
||||
player.getMainScreen().removeWidgets(War.war);
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
List<String> namesToRemove = new ArrayList<String>();
|
||||
for (String name : playerMessages.keySet()) {
|
||||
Player player = War.war.getServer().getPlayer(name);
|
||||
if (player != null && playerMessages.containsKey(name)) {
|
||||
clear(SpoutManager.getPlayer(player));
|
||||
}
|
||||
|
||||
namesToRemove.add(name);
|
||||
}
|
||||
|
||||
for (String toRemove : namesToRemove) {
|
||||
playerMessages.remove(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
public static String cleanForNotification(String toNotify) {
|
||||
if (toNotify.length() > 26) {
|
||||
return toNotify.substring(0, 25);
|
||||
}
|
||||
|
||||
return toNotify;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateStats(Player player) {
|
||||
SpoutPlayer sp = SpoutManager.getPlayer(player);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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 = 0, scoreMax = 0, lifeMax = 0;
|
||||
GenericLabel line;
|
||||
|
||||
GenericLabel teamsHeader = new GenericLabel(ChatColor.GRAY + "War> " + ChatColor.WHITE + zone.getName());
|
||||
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText()) + 1;
|
||||
teamsHeader.setAnchor(WidgetAnchor.TOP_LEFT)
|
||||
.setX(3)
|
||||
.setY(2)
|
||||
.setWidth(teamsHeaderWidth)
|
||||
.setHeight(LINE_HEIGHT);
|
||||
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.setTextColor(new Color(100,100,100));
|
||||
}
|
||||
else {
|
||||
line.setText(t.getKind().getColor() + teamStr.replace("(", ChatColor.GRAY + "(" + ChatColor.WHITE).replace(")", ChatColor.GRAY + ")" + ChatColor.WHITE));
|
||||
}
|
||||
line.setAnchor(WidgetAnchor.TOP_LEFT)
|
||||
.setX(3)
|
||||
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
|
||||
.setWidth(GenericLabel.getStringWidth(line.getText()))
|
||||
.setHeight(LINE_HEIGHT);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// points header
|
||||
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "score");
|
||||
int pointsHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
|
||||
pointsHeader.setAnchor(WidgetAnchor.TOP_LEFT)
|
||||
.setX(3 + teamMax + 2)
|
||||
.setY(2)
|
||||
.setWidth(pointsHeaderWidth)
|
||||
.setHeight(LINE_HEIGHT);
|
||||
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.setAnchor(WidgetAnchor.TOP_LEFT)
|
||||
.setX(3 + teamMax + 4)
|
||||
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
|
||||
.setWidth(GenericLabel.getStringWidth(line.getText()))
|
||||
.setHeight(LINE_HEIGHT);
|
||||
scorelines.add(line);
|
||||
lineCounter++;
|
||||
}
|
||||
|
||||
for (GenericLabel l : scorelines) {
|
||||
if (GenericLabel.getStringWidth(l.getText()) > scoreMax) {
|
||||
scoreMax = GenericLabel.getStringWidth(l.getText());
|
||||
}
|
||||
}
|
||||
if (pointsHeaderWidth > scoreMax) {
|
||||
scoreMax = pointsHeaderWidth;
|
||||
}
|
||||
|
||||
// lifepool header
|
||||
GenericLabel livesHeader = new GenericLabel(ChatColor.GRAY + "lives");
|
||||
int livesHeaderWidth = GenericLabel.getStringWidth(livesHeader.getText());
|
||||
livesHeader.setAnchor(WidgetAnchor.TOP_LEFT)
|
||||
.setX(3 + teamMax + 4 + scoreMax + 2)
|
||||
.setY(2)
|
||||
.setWidth(livesHeaderWidth)
|
||||
.setHeight(LINE_HEIGHT);
|
||||
lines.add(livesHeader);
|
||||
|
||||
|
||||
// and finally, lives.
|
||||
lineCounter = 1;
|
||||
for (Team t : zone.getTeams()) {
|
||||
line = new GenericLabel(t.getRemainingLives() + "/" + t.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
|
||||
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
|
||||
line.setAnchor(WidgetAnchor.TOP_LEFT)
|
||||
.setX(3 + teamMax + 4 + scoreMax + 4)
|
||||
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
|
||||
.setWidth(GenericLabel.getStringWidth(line.getText()))
|
||||
.setHeight(LINE_HEIGHT);
|
||||
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(3 + teamMax + 1 + scoreMax + 1 + lifeMax + 5);
|
||||
offset.add(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN);
|
||||
|
||||
}
|
||||
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, List<Integer> statsOffset) {
|
||||
Player bukkitPlayer = War.war.getServer().getPlayer(playerName);
|
||||
if (bukkitPlayer != null) {
|
||||
SpoutPlayer player = SpoutManager.getPlayer(bukkitPlayer);
|
||||
List<PlayerMessage> messages = playerMessages.get(playerName);
|
||||
|
||||
// remove old widgets
|
||||
clear(player);
|
||||
|
||||
// add bg
|
||||
GenericGradient gradient = new GenericGradient();
|
||||
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)));
|
||||
|
||||
player.getMainScreen().attachWidget(War.war, gradient);
|
||||
|
||||
// border in color of team
|
||||
GenericGradient teamGradient = new GenericGradient();
|
||||
teamGradient.setAnchor(WidgetAnchor.TOP_LEFT);
|
||||
|
||||
Team team = Team.getTeamByPlayerName(playerName);
|
||||
|
||||
Color spoutColor = new Color(250.0F, 250.0F, 250.0F, 1.0F);
|
||||
if (team != null) {
|
||||
spoutColor = team.getKind().getSpoutColor();
|
||||
}
|
||||
spoutColor.setAlpha(0.5F);
|
||||
|
||||
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)));
|
||||
|
||||
player.getMainScreen().attachWidget(War.war, teamGradient);
|
||||
|
||||
// update stats panel
|
||||
drawStats(player, statsLines);
|
||||
|
||||
// finally messages
|
||||
if (messages != null && messages.size() > 0) {
|
||||
Warzone zone = Warzone.getZoneByPlayerName(playerName);
|
||||
int verticalOffset = statsOffset.get(1) + 4;
|
||||
|
||||
for (PlayerMessage message : messages) {
|
||||
int horizontalOffset = 2;
|
||||
|
||||
String messageStr = ChatColor.GRAY + ">" + ChatColor.WHITE + " " + message.getMessage();
|
||||
String[] words = messageStr.split(" ");
|
||||
|
||||
for (String word : words) {
|
||||
|
||||
if (horizontalOffset > 160) {
|
||||
horizontalOffset = 2;
|
||||
verticalOffset += LINE_HEIGHT_WITH_MARGIN;
|
||||
}
|
||||
|
||||
word = addMissingColor(word, zone);
|
||||
|
||||
GenericLabel label = new GenericLabel(word);
|
||||
int width = GenericLabel.getStringWidth(word);
|
||||
label.setAnchor(WidgetAnchor.TOP_LEFT);
|
||||
label.setWidth(width);
|
||||
label.setHeight(LINE_HEIGHT);
|
||||
label.setX(horizontalOffset);
|
||||
label.setY(verticalOffset);
|
||||
|
||||
player.getMainScreen().attachWidget(War.war, label);
|
||||
|
||||
horizontalOffset += width + 2;
|
||||
}
|
||||
|
||||
verticalOffset += LINE_HEIGHT_WITH_MARGIN + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String addMissingColor(String word, Warzone zone) {
|
||||
if (zone != null) {
|
||||
for (Team team : zone.getTeams()) {
|
||||
for (Player player : team.getPlayers()) {
|
||||
if (word.startsWith(player.getName())) {
|
||||
return team.getKind().getColor() + word + ChatColor.WHITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (TeamKind kind : TeamKind.values()) {
|
||||
if (word.startsWith(kind.toString())) {
|
||||
return kind.getColor() + word + ChatColor.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
if (word.equals("War>")) {
|
||||
return ChatColor.GRAY + word + ChatColor.WHITE;
|
||||
}
|
||||
|
||||
// white by default
|
||||
return word;
|
||||
}
|
||||
|
||||
// private Color getWordColor(String word, Warzone zone) {
|
||||
// if (zone != null) {
|
||||
// for (Team team : zone.getTeams()) {
|
||||
// for (Player player : team.getPlayers()) {
|
||||
// if (word.startsWith(player.getName())) {
|
||||
// return team.getKind().getSpoutColor();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (TeamKind kind : TeamKind.values()) {
|
||||
// if (word.startsWith(kind.toString())) {
|
||||
// return kind.getSpoutColor();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (word.equals("War>")) {
|
||||
// return new Color(200,200,200);
|
||||
// }
|
||||
//
|
||||
// // white by default
|
||||
// return new Color(255,255,255);
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user