Turf Wars: Apply knockback on all players when there are only two in the match.

This commit is contained in:
Thanos paravantis 2016-01-04 17:19:40 +02:00
parent f6ce98f65b
commit 47c78bcba1
2 changed files with 211 additions and 318 deletions

1
.gitignore vendored
View File

@ -54,3 +54,4 @@ zSotanna2
/Pocket
/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_
/RemoteSystemsTempFiles
/.recommenders/caches

View File

@ -62,34 +62,28 @@ import nautilus.game.arcade.stats.BlockShreadStatTracker;
import nautilus.game.arcade.stats.TheComebackStatTracker;
import net.minecraft.server.v1_8_R3.EntityArrow;
public class TurfForts extends TeamGame
{
public static class ShredBlockEvent extends BlockEvent
{
public class TurfForts extends TeamGame {
public static class ShredBlockEvent extends BlockEvent {
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList()
{
public static HandlerList getHandlerList() {
return handlers;
}
@Override
public HandlerList getHandlers()
{
public HandlerList getHandlers() {
return getHandlerList();
}
private final Arrow _arrow;
public ShredBlockEvent(Block theBlock, Arrow arrow)
{
public ShredBlockEvent(Block theBlock, Arrow arrow) {
super(theBlock);
_arrow = arrow;
}
public Arrow getArrow()
{
public Arrow getArrow() {
return _arrow;
}
}
@ -115,24 +109,13 @@ public class TurfForts extends TeamGame
private Set<UUID> playersThatNeedBlocks = new HashSet<UUID>();
public TurfForts(ArcadeManager manager)
{
public TurfForts(ArcadeManager manager) {
super(manager, GameType.TurfWars,
new Kit[]
{
new KitMarksman(manager),
new KitInfiltrator(manager),
new KitShredder(manager),
},
new Kit[] { new KitMarksman(manager), new KitInfiltrator(manager), new KitShredder(manager), },
new String[]
{
"You have 30 seconds to build your Fort!",
"",
"Each kill advances your turf forwards.",
"Take over all the turf to win!"
});
new String[] { "You have 30 seconds to build your Fort!", "", "Each kill advances your turf forwards.",
"Take over all the turf to win!" });
this.StrictAntiHack = true;
this.HungerSet = 20;
@ -144,16 +127,12 @@ public class TurfForts extends TeamGame
this.DamageSelf = false;
this.DeathSpectateSecs = 4;
registerStatTrackers(
new BlockShreadStatTracker(this),
new BehindEnemyLinesStatTracker(this),
new TheComebackStatTracker(this)
);
registerStatTrackers(new BlockShreadStatTracker(this), new BehindEnemyLinesStatTracker(this),
new TheComebackStatTracker(this));
}
@Override
public void ParseData()
{
public void ParseData() {
_turf = WorldData.GetDataLocs("YELLOW");
_red = WorldData.GetDataLocs("RED").get(0);
@ -162,15 +141,18 @@ public class TurfForts extends TeamGame
_blue = WorldData.GetDataLocs("BLUE").get(0);
_blueBase = WorldData.GetDataLocs("LIGHT_BLUE").get(0);
if (_red.getBlockX() > _blue.getBlockX()) xRed = 1;
else if (_red.getBlockX() < _blue.getBlockX()) xRed = -1;
if (_red.getBlockX() > _blue.getBlockX())
xRed = 1;
else if (_red.getBlockX() < _blue.getBlockX())
xRed = -1;
if (_red.getBlockZ() > _blue.getBlockZ()) zRed = 1;
else if (_red.getBlockZ() < _blue.getBlockZ()) zRed = -1;
if (_red.getBlockZ() > _blue.getBlockZ())
zRed = 1;
else if (_red.getBlockZ() < _blue.getBlockZ())
zRed = -1;
// Color Turf
for (Location loc : _turf)
{
for (Location loc : _turf) {
if (UtilMath.offset(loc, _red) < UtilMath.offset(loc, _blue))
MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14);
else
@ -179,8 +161,7 @@ public class TurfForts extends TeamGame
}
@EventHandler
public void PlayerKillAward(CombatDeathEvent event)
{
public void PlayerKillAward(CombatDeathEvent event) {
if (!(event.GetEvent().getEntity() instanceof Player))
return;
@ -202,26 +183,19 @@ public class TurfForts extends TeamGame
if (GetTeam(killer).equals(GetTeam(killed)))
return;
if (GetTeam(killer).GetColor() == ChatColor.RED)
{
if (GetTeam(killer).GetColor() == ChatColor.RED) {
TurfMove(true);
}
else
{
} else {
TurfMove(false);
}
}
private void TurfMove(boolean red)
{
for (int line = 0; line < GetLinesPerKill(); line++)
{
if (red)
{
private void TurfMove(boolean red) {
for (int line = 0; line < GetLinesPerKill(); line++) {
if (red) {
if (xRed != 0)
for (Location loc : _turf)
if (loc.getBlockX() == _blue.getBlockX())
{
if (loc.getBlockX() == _blue.getBlockX()) {
MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14);
for (int i = 1; i < 6; i++)
@ -229,11 +203,9 @@ public class TurfForts extends TeamGame
MapUtil.QuickChangeBlockAt(loc.clone().add(0, i, 0), 0, (byte) 0);
}
if (zRed != 0)
for (Location loc : _turf)
if (loc.getBlockZ() == _blue.getBlockZ())
{
if (loc.getBlockZ() == _blue.getBlockZ()) {
MapUtil.QuickChangeBlockAt(loc, 159, (byte) 14);
for (int i = 1; i < 6; i++)
@ -243,13 +215,10 @@ public class TurfForts extends TeamGame
_red.subtract(xRed, 0, zRed);
_blue.subtract(xRed, 0, zRed);
}
else
{
} else {
if (xRed != 0)
for (Location loc : _turf)
if (loc.getBlockX() == _red.getBlockX())
{
if (loc.getBlockX() == _red.getBlockX()) {
MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3);
for (int i = 1; i < 6; i++)
@ -259,8 +228,7 @@ public class TurfForts extends TeamGame
if (zRed != 0)
for (Location loc : _turf)
if (loc.getBlockZ() == _red.getBlockZ())
{
if (loc.getBlockZ() == _red.getBlockZ()) {
MapUtil.QuickChangeBlockAt(loc, 159, (byte) 3);
for (int i = 1; i < 6; i++)
@ -277,10 +245,8 @@ public class TurfForts extends TeamGame
}
@EventHandler
public void BowCancel(EntityShootBowEvent event)
{
if (!_fight)
{
public void BowCancel(EntityShootBowEvent event) {
if (!_fight) {
UtilPlayer.message(event.getEntity(), F.main("Game", "You cannot attack during Build Time!"));
event.setCancelled(true);
@ -289,21 +255,17 @@ public class TurfForts extends TeamGame
}
@EventHandler
public void BlockBreak(BlockBreakEvent event)
{
if (event.isCancelled()) // this statement might save just a small amount of time
public void BlockBreak(BlockBreakEvent event) {
if (event.isCancelled()) // this statement might save just a small
// amount of time
return;
if (!IsAlive(event.getPlayer()))
{
if (!IsAlive(event.getPlayer())) {
event.setCancelled(true);
return;
}
if (UtilPlayer.isSpectator(event.getPlayer()))
{
if (UtilPlayer.isSpectator(event.getPlayer())) {
event.setCancelled(true);
return;
}
@ -313,36 +275,33 @@ public class TurfForts extends TeamGame
GameTeam team = GetTeam(event.getPlayer());
GameTeam otherTeam = GetOtherTeam(team);
if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED) || (block.getData() == 3 && team.GetColor() != ChatColor.AQUA))
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!"));
if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED)
|| (block.getData() == 3 && team.GetColor() != ChatColor.AQUA)) {
UtilPlayer.message(event.getPlayer(), F.main("Game",
"You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!"));
event.setCancelled(true);
return;
}
}
@EventHandler(ignoreCancelled = true)
public void BlockPlace(BlockPlaceEvent event)
{
public void BlockPlace(BlockPlaceEvent event) {
// Remoeved and replaced by ignoreCancelled = true
// if (event.isCancelled())
// return;
GameTeam team = GetTeam(event.getPlayer());
if (team == null)
{
if (team == null) {
event.setCancelled(true);
return;
}
if (!IsAlive(event.getPlayer()))
{
if (!IsAlive(event.getPlayer())) {
event.setCancelled(true);
return;
}
if (UtilPlayer.isSpectator(event.getPlayer()))
{
if (UtilPlayer.isSpectator(event.getPlayer())) {
event.setCancelled(true);
return;
}
@ -352,17 +311,16 @@ public class TurfForts extends TeamGame
while (block.getTypeId() == 0)
block = block.getRelative(BlockFace.DOWN);
if (block.getData() != team.GetColorData())
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + "."));
if (block.getData() != team.GetColorData()) {
UtilPlayer.message(event.getPlayer(),
F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + "."));
event.setCancelled(true);
return;
}
// Height
boolean aboveTurf = false;
for (int i = 1; i <= 5; i++)
{
for (int i = 1; i <= 5; i++) {
if (event.getBlock().getRelative(BlockFace.DOWN, i).getTypeId() != 159)
continue;
@ -370,8 +328,7 @@ public class TurfForts extends TeamGame
break;
}
if (!aboveTurf)
{
if (!aboveTurf) {
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot build this high above Turf."));
event.setCancelled(true);
return;
@ -379,8 +336,7 @@ public class TurfForts extends TeamGame
}
@EventHandler
public void BlockDamage(ProjectileHitEvent event)
{
public void BlockDamage(ProjectileHitEvent event) {
if (event.getEntity().getShooter() == null)
return;
@ -397,12 +353,9 @@ public class TurfForts extends TeamGame
final Arrow arrow = (Arrow) event.getEntity();
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
public void run()
{
try
{
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() {
public void run() {
try {
EntityArrow entityArrow = ((CraftArrow) arrow).getHandle();
Field fieldX = EntityArrow.class.getDeclaredField("d");
@ -419,27 +372,28 @@ public class TurfForts extends TeamGame
Block block = arrow.getWorld().getBlockAt(x, y, z);
if (block.getTypeId() == 35)
{
if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId());
}
else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
if (block.getTypeId() == 35) {
if (block.getData() == 14 /*
* && team.GetColor() !=
* ChatColor.RED
*/) {
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND,
Material.REDSTONE_BLOCK.getId());
} else if (block.getData() == 3 /*
* && team.GetColor() !=
* ChatColor.AQUA
*/) {
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND,
Material.LAPIS_BLOCK.getId());
}
Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow));
block.setType(Material.AIR);
}
arrow.remove();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
}
@ -447,60 +401,47 @@ public class TurfForts extends TeamGame
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetCause() == DamageCause.FALL)
{
public void Damage(CustomDamageEvent event) {
if (event.GetCause() == DamageCause.FALL) {
event.SetCancelled("No Fall");
return;
}
if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK))
{
if (!_fight && (event.GetCause() == DamageCause.PROJECTILE || event.GetCause() == DamageCause.ENTITY_ATTACK)) {
event.SetCancelled("Build Time");
return;
}
Player damager = event.GetDamagerPlayer(true);
if (damager == null) return;
if (damager == null)
return;
if (event.GetCause() == DamageCause.PROJECTILE)
{
if (event.GetCause() == DamageCause.PROJECTILE) {
event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false);
if (GetKit(damager).GetName().contains("Shredder"))
{
if (GetKit(damager).GetName().contains("Shredder")) {
event.SetCancelled("Shredder");
Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null,
DamageCause.CUSTOM, 9, true, true, false,
damager.getName(), "Barrage");
Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.CUSTOM, 9, true,
true, false, damager.getName(), "Barrage");
return;
}
else
{
} else {
event.AddMod("Turf Forts", "One Hit Kill", 30, false);
}
}
else if (event.GetCause() == DamageCause.ENTITY_ATTACK)
{
} else if (event.GetCause() == DamageCause.ENTITY_ATTACK) {
event.AddMod("Turf Forts", "Nullify", -event.GetDamageInitial(), false);
if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD))
{
if (UtilGear.isMat(damager.getItemInHand(), Material.IRON_SWORD)) {
event.AddMod("Turf Forts", "One Hit Kill", 12, false);
}
else
{
} else {
event.AddMod("Turf Forts", "One Hit Kill", 6, false);
}
}
}
@EventHandler
public void ScoreboardTitle(UpdateEvent event)
{
public void ScoreboardTitle(UpdateEvent event) {
if (GetState() != GameState.Live)
return;
@ -512,48 +453,42 @@ public class TurfForts extends TeamGame
return;
long time;
if (!_fight)
{
if (!_fight) {
time = _buildTime - (System.currentTimeMillis() - _phaseTime);
if (time <= 0)
{
if (time <= 0) {
_fight = true;
_lines++;
Announce(" ");
Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold + GetLinesPerKill() + " Turf Lines");
Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold + " has begun!");
Announce(C.cWhite + C.Bold + "1 Kill" + C.cWhite + C.Bold + " = " + C.cWhite + C.Bold
+ GetLinesPerKill() + " Turf Lines");
Announce(C.cWhite + C.Bold + "90 Seconds of " + C.cYellow + C.Bold + "Combat Time" + C.cWhite + C.Bold
+ " has begun!");
Announce(" ");
_phaseTime = System.currentTimeMillis();
}
}
else
{
else {
time = _fightTime - (System.currentTimeMillis() - _phaseTime);
if (time <= 0)
{
if (time <= 0) {
_fight = false;
Announce(" ");
Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold + " has begun!");
Announce(C.cWhite + C.Bold + "20 Seconds of " + C.cGreen + C.Bold + "Build Time" + C.cWhite + C.Bold
+ " has begun!");
Announce(" ");
_phaseTime = System.currentTimeMillis();
for (GameTeam team : GetTeamList())
{
for (Player player : team.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
for (GameTeam team : GetTeamList()) {
for (Player player : team.GetPlayers(true)) {
if (UtilPlayer.isSpectator(player)) {
this.playersThatNeedBlocks.add(player.getUniqueId());
}
else
{
} else {
addBlocks(team, player);
}
}
@ -562,51 +497,44 @@ public class TurfForts extends TeamGame
}
}
public void addBlocks(GameTeam team, Player player)
{
public void addBlocks(GameTeam team, Player player) {
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOL, team.GetColorData(), 24));
}
@EventHandler(ignoreCancelled = true)
public void onQuit(PlayerQuitEvent event)
{
public void onQuit(PlayerQuitEvent event) {
this.playersThatNeedBlocks.remove(event.getPlayer().getUniqueId());
}
@EventHandler(ignoreCancelled = true)
public void onSpawn(PlayerKitGiveEvent event)
{
public void onSpawn(PlayerKitGiveEvent event) {
Player player = event.getPlayer();
if (this.playersThatNeedBlocks.contains(player.getUniqueId()))
{
if (this.playersThatNeedBlocks.contains(player.getUniqueId())) {
this.playersThatNeedBlocks.remove(player.getUniqueId());
this.addBlocks(GetTeam(player), player);
}
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
public void ScoreboardUpdate(UpdateEvent event) {
if (event.getType() != UpdateType.FAST)
return;
Scoreboard.Reset();
for (GameTeam team : this.GetTeamList())
{
for (GameTeam team : this.GetTeamList()) {
int lines = 0;
if (team.GetColor() == ChatColor.RED) lines = GetRedLines();
else lines = GetBlueLines();
if (team.GetColor() == ChatColor.RED)
lines = GetRedLines();
else
lines = GetBlueLines();
Scoreboard.WriteBlank();
Scoreboard.Write(lines + " " + team.GetColor() + team.GetName());
}
if (!_fight)
{
if (!_fight) {
long time = _buildTime - (System.currentTimeMillis() - _phaseTime);
Scoreboard.WriteBlank();
@ -615,8 +543,7 @@ public class TurfForts extends TeamGame
}
else
{
else {
long time = _fightTime - (System.currentTimeMillis() - _phaseTime);
Scoreboard.WriteBlank();
@ -627,89 +554,72 @@ public class TurfForts extends TeamGame
Scoreboard.Draw();
}
public int GetRedLines()
{
public int GetRedLines() {
if (!InProgress())
return 0;
if (xRed != 0)
{
if (xRed != 0) {
return Math.abs(_redBase.getBlockX() - _red.getBlockX());
}
return Math.abs(_redBase.getBlockZ() - _red.getBlockZ());
}
public int GetBlueLines()
{
public int GetBlueLines() {
if (!InProgress())
return 0;
if (xRed != 0)
{
if (xRed != 0) {
return Math.abs(_blueBase.getBlockX() - _blue.getBlockX());
}
return Math.abs(_blueBase.getBlockZ() - _blue.getBlockZ());
}
public int getLines(GameTeam team)
{
public int getLines(GameTeam team) {
if (team.GetColor() == ChatColor.RED)
return GetRedLines();
else
return GetBlueLines();
}
public int GetLinesPerKill()
{
public int GetLinesPerKill() {
return _lines;
//return Math.min(5, 1 + (int)((System.currentTimeMillis() - GetStateTime() - 30000) / 60000));
// return Math.min(5, 1 + (int)((System.currentTimeMillis() -
// GetStateTime() - 30000) / 60000));
}
@EventHandler
public void PlayerDeath(PlayerDeathEvent event)
{
public void PlayerDeath(PlayerDeathEvent event) {
_enemyTurf.remove(event.getEntity());
}
@EventHandler
public void Territory(UpdateEvent event)
{
public void Territory(UpdateEvent event) {
if (!IsLive())
return;
if (event.getType() != UpdateType.FASTER)
return;
for (GameTeam team : this.GetTeamList())
{
for (Player player : team.GetPlayers(true))
{
for (GameTeam team : this.GetTeamList()) {
for (Player player : team.GetPlayers(true)) {
if (((CraftPlayer) player).getHandle().spectating)
continue;
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
// Apply velocity even if the player is sneaking near turf edges.
// Apply velocity even if the player is sneaking near turf
// edges.
if (block.isEmpty())
{
Block[] nearby = {
block.getRelative(BlockFace.NORTH),
block.getRelative(BlockFace.SOUTH),
block.getRelative(BlockFace.WEST),
block.getRelative(BlockFace.EAST),
block.getRelative(BlockFace.NORTH_EAST),
block.getRelative(BlockFace.NORTH_WEST),
block.getRelative(BlockFace.SOUTH_EAST),
block.getRelative(BlockFace.SOUTH_WEST)
};
if (block.isEmpty() && player.isOnGround()) {
Block[] nearby = { block.getRelative(BlockFace.NORTH), block.getRelative(BlockFace.SOUTH),
block.getRelative(BlockFace.WEST), block.getRelative(BlockFace.EAST),
block.getRelative(BlockFace.NORTH_EAST), block.getRelative(BlockFace.NORTH_WEST),
block.getRelative(BlockFace.SOUTH_EAST), block.getRelative(BlockFace.SOUTH_WEST) };
for (Block near : nearby)
{
if (near.getTypeId() == 159)
{
for (Block near : nearby) {
if (near.getType() == Material.STAINED_CLAY || near.getType() == Material.WOOL) {
block = near;
break;
}
@ -725,21 +635,20 @@ public class TurfForts extends TeamGame
byte data = block.getData();
// Slow
if (_enemyTurf.containsKey(player))
{
if (_enemyTurf.containsKey(player)) {
int time = (int) ((System.currentTimeMillis() - _enemyTurf.get(player)) / 2500);
if (time > 0)
Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false, false, false, false);
Manager.GetCondition().Factory().Slow("Infiltrator Slow", player, player, 0.9, time - 1, false,
false, false, false);
}
// On Enemy Turf
if ((team.GetColor() == ChatColor.RED && data == 3) || (team.GetColor() == ChatColor.AQUA && data == 14))
{
if ((team.GetColor() == ChatColor.RED && data == 3)
|| (team.GetColor() == ChatColor.AQUA && data == 14)) {
// Infiltrate
if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil"))
{
if (_fight && GetKit(player) != null && GetKit(player).GetName().contains("Infil")) {
if (!_enemyTurf.containsKey(player))
_enemyTurf.put(player, System.currentTimeMillis());
@ -747,19 +656,22 @@ public class TurfForts extends TeamGame
continue;
}
if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false))
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2, false, 0, 0.8, 1, true);
if (Recharge.Instance.use(player, "Territory Knockback", 2000, false, false)) {
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), team.GetSpawn()), 2,
false, 0, 0.8, 1, true);
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
UtilPlayer.message(player, F.main("Game", "You cannot walk on the enemies turf!"));
}
return;
// Looks like that with 'return' if there are only two
// players, one of them will not get knockback.
// return;
}
// On Own Turf
else if ((team.GetColor() == ChatColor.RED && data == 14) || (team.GetColor() == ChatColor.AQUA && data == 3))
{
else if ((team.GetColor() == ChatColor.RED && data == 14)
|| (team.GetColor() == ChatColor.AQUA && data == 3)) {
_enemyTurf.remove(player);
}
}
@ -767,27 +679,17 @@ public class TurfForts extends TeamGame
}
/*
@EventHandler
public void ItemRemoval(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.FAST)
return;
for (Entity ent : _red.getWorld().getEntities())
{
if (!(ent instanceof Item))
continue;
if (ent.getTicksLived() > 40)
ent.remove();
}
}
* @EventHandler public void ItemRemoval(UpdateEvent event) { if (!IsLive())
* return;
*
* if (event.getType() != UpdateType.FAST) return;
*
* for (Entity ent : _red.getWorld().getEntities()) { if (!(ent instanceof
* Item)) continue;
*
* if (ent.getTicksLived() > 40) ent.remove(); } }
*/
public GameTeam GetOtherTeam(GameTeam team) {
return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED);
}
@ -800,26 +702,19 @@ public class TurfForts extends TeamGame
}
@Override
public void EndCheck()
{
public void EndCheck() {
if (!IsLive())
return;
if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0)
{
if (GetRedLines() == 0 || GetTeam(ChatColor.RED).GetPlayers(true).size() == 0) {
AnnounceEnd(GetTeam(ChatColor.AQUA));
}
else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0)
{
} else if (GetBlueLines() == 0 || GetTeam(ChatColor.AQUA).GetPlayers(true).size() == 0) {
AnnounceEnd(GetTeam(ChatColor.RED));
}
else
} else
return;
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (GameTeam team : GetTeamList()) {
if (WinnerTeam != null && team.equals(WinnerTeam)) {
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false, false);
}
@ -833,23 +728,20 @@ public class TurfForts extends TeamGame
SetState(GameState.End);
}
public Long getEnemyTurfEntranceTime(Player player)
{
public Long getEnemyTurfEntranceTime(Player player) {
return _enemyTurf.get(player);
}
// Keep ladders placed on ice when block updates occur.
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event)
{
public void onBlockPhysics(BlockPhysicsEvent event) {
if (!IsLive())
return;
Block block = event.getBlock();
if (block.getType() == Material.LADDER)
{
if (block.getType() == Material.LADDER) {
event.setCancelled(true);
}
}