Continue refactoring and comment main class
This commit is contained in:
parent
6cc8f854c4
commit
3a5ec7dc5d
@ -491,6 +491,27 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
removeSolidBlockForPlayers();
|
removeSolidBlockForPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeSolidBlockForPlayers()
|
||||||
|
{
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
removeSolidBlock(player.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private void removeSolidBlock(Location location)
|
||||||
|
{
|
||||||
|
Block block = location.getBlock();
|
||||||
|
|
||||||
|
if (!block.isEmpty() && _challenge.getData().isModifiedBlock(block))
|
||||||
|
{
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
block.setData((byte) 0);
|
||||||
|
_challenge.getData().removeModifiedBlock(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void teamTeleport(boolean firstRun)
|
private void teamTeleport(boolean firstRun)
|
||||||
{
|
{
|
||||||
TeamChallenge teamChallenge = (TeamChallenge) _challenge;
|
TeamChallenge teamChallenge = (TeamChallenge) _challenge;
|
||||||
@ -547,12 +568,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void hideMapDuringCountdown(GamePrepareCountdownCommence event)
|
public void addEffectsDuringCountdown(GamePrepareCountdownCommence event)
|
||||||
{
|
{
|
||||||
for (Player player : GetPlayers(true))
|
for (Player player : GetPlayers(true))
|
||||||
{
|
{
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 1));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 2));
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,6 +702,18 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeEffectsFromPlayers()
|
||||||
|
{
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.BLINDNESS) && player.hasPotionEffect(PotionEffectType.NIGHT_VISION))
|
||||||
|
{
|
||||||
|
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||||
|
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addEffectsToPlayers()
|
private void addEffectsToPlayers()
|
||||||
{
|
{
|
||||||
for (Player player : GetPlayers(true))
|
for (Player player : GetPlayers(true))
|
||||||
@ -880,6 +913,91 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
EndCheck();
|
EndCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void killRemainingPlayers()
|
||||||
|
{
|
||||||
|
for (Player player : getPlayersAlive())
|
||||||
|
{
|
||||||
|
if (_challenge.getData().hasAnyoneCompleted() && !_challenge.getData().isCompleted(player))
|
||||||
|
{
|
||||||
|
int lives = lives(player) - 1;
|
||||||
|
|
||||||
|
if (lives > 0)
|
||||||
|
{
|
||||||
|
_challenge.setLost(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handleDeath(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addChallengeGemReward(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addChallengeGemReward(Player player)
|
||||||
|
{
|
||||||
|
if (_challenge.getData().isCompleted(player))
|
||||||
|
{
|
||||||
|
AddGems(player, 3, "Completed Challenge", true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sortLastChallengeBlocks()
|
||||||
|
{
|
||||||
|
_lastChallengeBlocks = new ArrayList<Block>(_challenge.getData().getModifiedBlocks());
|
||||||
|
|
||||||
|
Collections.sort(_lastChallengeBlocks, new Comparator<Block>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public int compare(Block o1, Block o2)
|
||||||
|
{
|
||||||
|
return new Integer(o2.getY()).compareTo(o1.getY());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EndCheck()
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (getPlayersWithRemainingLives() <= 1)
|
||||||
|
{
|
||||||
|
if (getPlayersAlive().get(0) != null)
|
||||||
|
{
|
||||||
|
_winners.add(0, getPlayersAlive().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_winners.size() > 2)
|
||||||
|
{
|
||||||
|
Collections.swap(_winners, 2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_winners.size() >= 1)
|
||||||
|
{
|
||||||
|
AddGems(_winners.get(0), 40, "First Place", false, false);
|
||||||
|
|
||||||
|
if (_winners.size() >= 2)
|
||||||
|
{
|
||||||
|
AddGems(_winners.get(1), 30, "Second Place", false, false);
|
||||||
|
|
||||||
|
if (_winners.size() >= 3)
|
||||||
|
{
|
||||||
|
AddGems(_winners.get(2), 20, "Third Place", false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : super.GetPlayers(false))
|
||||||
|
AddGems(player, 10, "Participation", false, false);
|
||||||
|
|
||||||
|
AnnounceEnd(_winners);
|
||||||
|
SetState(GameState.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateChallengeTimer()
|
private void updateChallengeTimer()
|
||||||
{
|
{
|
||||||
for (Player player : UtilServer.getPlayers())
|
for (Player player : UtilServer.getPlayers())
|
||||||
@ -914,6 +1032,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Death
|
||||||
|
*/
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void death(PlayerDeathEvent event)
|
public void death(PlayerDeathEvent event)
|
||||||
{
|
{
|
||||||
@ -1015,6 +1137,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2.0F, 1.0F);
|
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* End reset
|
||||||
|
*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void end(GameStateChangeEvent event)
|
public void end(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
@ -1031,6 +1157,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chicken attack
|
||||||
|
*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void chickenAttack(UpdateEvent event)
|
public void chickenAttack(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -1107,6 +1237,28 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
_chickenAttack.kill(player);
|
_chickenAttack.kill(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void blockChickenAttackMemberDamage(EntityDamageEvent event)
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getEntity() instanceof Chicken)
|
||||||
|
{
|
||||||
|
Chicken chicken = (Chicken) event.getEntity();
|
||||||
|
|
||||||
|
if (_chickenAttack.isGroupMember(chicken))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getCause() == DamageCause.VOID)
|
||||||
|
{
|
||||||
|
chicken.teleport(_chickenAttack.getPlatformCenter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void spectatorApproachPlayer(UpdateEvent event)
|
public void spectatorApproachPlayer(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -1139,6 +1291,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Completed players
|
||||||
|
*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preventVoidDeath(PlayerMoveEvent event)
|
public void preventVoidDeath(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
@ -1182,6 +1338,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cancel/Quit
|
||||||
|
*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void cancel(GameStateChangeEvent event)
|
public void cancel(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
@ -1226,6 +1386,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Miscellaneous
|
||||||
|
*/
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void blockTeleport(MineplexTeleportEvent event)
|
public void blockTeleport(MineplexTeleportEvent event)
|
||||||
{
|
{
|
||||||
@ -1253,28 +1417,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void blockChickenAttackMemberDamage(EntityDamageEvent event)
|
|
||||||
{
|
|
||||||
if (!IsLive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getEntity() instanceof Chicken)
|
|
||||||
{
|
|
||||||
Chicken chicken = (Chicken) event.getEntity();
|
|
||||||
|
|
||||||
if (_chickenAttack.isGroupMember(chicken))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getCause() == DamageCause.VOID)
|
|
||||||
{
|
|
||||||
chicken.teleport(_chickenAttack.getPlatformCenter());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void blockBlood(ItemSpawnEvent event)
|
public void blockBlood(ItemSpawnEvent event)
|
||||||
@ -1345,10 +1487,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void removeFeetBlocks(GamePrepareCountdownCommence event)
|
public void removeFeetBlocks(GamePrepareCountdownCommence event)
|
||||||
{
|
{
|
||||||
for (Player player : GetPlayers(true))
|
removeSolidBlockForPlayers();
|
||||||
{
|
|
||||||
removeSolidBlock(player.getLocation());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug Only
|
// Debug Only
|
||||||
@ -1524,96 +1663,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
Scoreboard.Draw();
|
Scoreboard.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeSolidBlockForPlayers()
|
/*
|
||||||
{
|
* Helper methods
|
||||||
for (Player player : GetPlayers(true))
|
*/
|
||||||
{
|
|
||||||
removeSolidBlock(player.getLocation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void removeSolidBlock(Location location)
|
|
||||||
{
|
|
||||||
Block block = location.getBlock();
|
|
||||||
|
|
||||||
if (!block.isEmpty() && _challenge.getData().isModifiedBlock(block))
|
|
||||||
{
|
|
||||||
block.setType(Material.AIR);
|
|
||||||
block.setData((byte) 0);
|
|
||||||
_challenge.getData().removeModifiedBlock(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// private void startChallengeDescriptionThread()
|
|
||||||
// {
|
|
||||||
// Thread thread = new Thread(new Runnable()
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public void run()
|
|
||||||
// {
|
|
||||||
// showChallengeDescription(_challenge);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// thread.start();
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void removeEffectsFromPlayers()
|
|
||||||
{
|
|
||||||
for (Player player : GetPlayers(true))
|
|
||||||
{
|
|
||||||
if (player.hasPotionEffect(PotionEffectType.BLINDNESS) && player.hasPotionEffect(PotionEffectType.NIGHT_VISION))
|
|
||||||
{
|
|
||||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
|
||||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void killRemainingPlayers()
|
|
||||||
{
|
|
||||||
for (Player player : getPlayersAlive())
|
|
||||||
{
|
|
||||||
if (_challenge.getData().hasAnyoneCompleted() && !_challenge.getData().isCompleted(player))
|
|
||||||
{
|
|
||||||
int lives = lives(player) - 1;
|
|
||||||
|
|
||||||
if (lives > 0)
|
|
||||||
{
|
|
||||||
_challenge.setLost(player);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handleDeath(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addChallengeGemReward(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addChallengeGemReward(Player player)
|
|
||||||
{
|
|
||||||
if (_challenge.getData().isCompleted(player))
|
|
||||||
{
|
|
||||||
AddGems(player, 3, "Completed Challenge", true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortLastChallengeBlocks()
|
|
||||||
{
|
|
||||||
_lastChallengeBlocks = new ArrayList<Block>(_challenge.getData().getModifiedBlocks());
|
|
||||||
|
|
||||||
Collections.sort(_lastChallengeBlocks, new Comparator<Block>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare(Block o1, Block o2)
|
|
||||||
{
|
|
||||||
return new Integer(o2.getY()).compareTo(o1.getY());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInsideMap(Player player)
|
public boolean isInsideMap(Player player)
|
||||||
@ -1632,46 +1684,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
return _lives.get(player);
|
return _lives.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*
|
||||||
public void EndCheck()
|
* Getter methods
|
||||||
{
|
*/
|
||||||
if (!IsLive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (getPlayersWithRemainingLives() <= 1)
|
|
||||||
{
|
|
||||||
if (getPlayersAlive().get(0) != null)
|
|
||||||
{
|
|
||||||
_winners.add(0, getPlayersAlive().get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_winners.size() > 2)
|
|
||||||
{
|
|
||||||
Collections.swap(_winners, 2, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_winners.size() >= 1)
|
|
||||||
{
|
|
||||||
AddGems(_winners.get(0), 40, "First Place", false, false);
|
|
||||||
|
|
||||||
if (_winners.size() >= 2)
|
|
||||||
{
|
|
||||||
AddGems(_winners.get(1), 30, "Second Place", false, false);
|
|
||||||
|
|
||||||
if (_winners.size() >= 3)
|
|
||||||
{
|
|
||||||
AddGems(_winners.get(2), 20, "Third Place", false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : super.GetPlayers(false))
|
|
||||||
AddGems(player, 10, "Participation", false, false);
|
|
||||||
|
|
||||||
AnnounceEnd(_winners);
|
|
||||||
SetState(GameState.End);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameTeam getPlayerTeam()
|
public GameTeam getPlayerTeam()
|
||||||
{
|
{
|
||||||
@ -1724,6 +1739,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
return _chickenAttack;
|
return _chickenAttack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Player related getter methods
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of players contained on the player's team.
|
* Returns the list of players contained on the player's team.
|
||||||
*
|
*
|
||||||
@ -1776,6 +1795,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inherited methods
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user