Merge branch 'thanos-mineware' into develop

This commit is contained in:
cnr 2016-07-14 03:41:00 -05:00
commit 1d1c3ef1be
3 changed files with 101 additions and 108 deletions

View File

@ -85,7 +85,6 @@ import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeColorCha
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeDeadlyTnt;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeDiamondHunt;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeEggSmash;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeEmpty;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeFallingBlocks;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeFastFood;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeKangarooJump;
@ -184,7 +183,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private static final float SPECTATOR_KNOCKBACK_SOUND_VOLUME = 2.0F;
private static final float SPECTATOR_KNOCKBACK_SOUND_PITCH = 0.5F;
private static final int MIN_PLAYERS_BLOCK_ATTEMPT = 1;
private static final int GENERIC_SCOREBOARD_PLAYER_COUNT = 15;
private static final int LOST_ONE_LIFE = MAX_LIVES - 1;
@ -381,33 +379,26 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private Challenge selectChallenge()
{
if (GetPlayers(false).size() > MIN_PLAYERS_BLOCK_ATTEMPT)
int limit = _list.size();
int attemps = 0;
Challenge instance = _list.random();
while (!isSuitable(instance))
{
int limit = _list.size();
int attemps = 0;
Challenge instance = _list.random();
while (!isSuitable(instance))
if (attemps < limit)
{
if (attemps < limit)
{
instance = _list.random();
attemps++;
}
else
{
_list.resetPlayed();
attemps = 0;
}
instance = _list.random();
attemps++;
}
else
{
_list.resetPlayed();
attemps = 0;
}
}
return instance;
}
else
{
return new ChallengeEmpty(this);
}
return instance;
}
private boolean isSuitable(Challenge instance)
@ -1215,21 +1206,21 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_winners.remove(player);
}
@EventHandler
public void blockStartAttempt(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
// If there is only 1 player and the game starts, do not teleport him to the map.
if (GetState() == GameState.Recruit && GetCountdown() >= 0 && GetPlayers(false).size() <= MIN_PLAYERS_BLOCK_ATTEMPT)
{
UtilServer.broadcast(F.main("Game", C.cRed + "This game requires at least 2 players to start."));
SetCountdown(-1);
Manager.GetLobby().DisplayWaiting();
}
}
// @EventHandler
// public void blockStartAttempt(UpdateEvent event)
// {
// if (event.getType() != UpdateType.TICK)
// return;
//
// // If there is only 1 player and the game starts, do not teleport him to the map.
//
// if (GetState() == GameState.Recruit && GetCountdown() >= 0 && GetPlayers(false).size() <= MIN_PLAYERS_BLOCK_ATTEMPT)
// {
// UtilServer.broadcast(F.main("Game", C.cRed + "This game requires at least 2 players to start."));
// SetCountdown(-1);
// Manager.GetLobby().DisplayWaiting();
// }
// }
/*
* Miscellaneous
@ -1495,73 +1486,73 @@ public class BawkBawkBattles extends TeamGame implements IThrown
return "";
}
// @EventHandler
// public void debugCommands(PlayerCommandPreprocessEvent event)
// {
// Player player = event.getPlayer();
// String message = event.getMessage();
//
// if (Manager.GetClients().hasRank(player, Rank.SNR_MODERATOR))
// {
// if (message.startsWith("/restrict"))
// {
// String[] pieces = message.split(" ");
//
// if (pieces.length > 1)
// {
// String challenge = F.combine(pieces, 1, null, false).trim();
//
// if (_list.restrict(challenge))
// {
// UtilPlayer.message(player, F.main("Game", "Restricted to " + F.elem(challenge) + " challenge."));
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "Could not find any challenge by that name."));
// }
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "All challenge restrictions were cleared."));
// _list.unrestrict();
// }
//
// event.setCancelled(true);
// }
// else if (message.startsWith("/skip"))
// {
// if (IsLive())
// {
// endCurrentChallenge();
//
// Announce(C.cAqua + C.Bold + player.getName() + " skipped this challenge.");
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "You cannot skip a challenge if the game is not started."));
// }
//
// event.setCancelled(true);
// }
// else if (message.startsWith("/lose"))
// {
// if (IsLive() && _challenge != null && IsAlive(player))
// {
// setLives(player, 0);
// _challenge.getData().addLostPlayer(player);
// _deathEffect.playDeath(player, player.getLocation());
// GetScoreboard().ResetScore(player.getName());
// _chickenAttack.start(player);
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "You cannot lose at this time."));
// }
//
// event.setCancelled(true);
// }
// }
// }
// @EventHandler
// public void debugCommands(PlayerCommandPreprocessEvent event)
// {
// Player player = event.getPlayer();
// String message = event.getMessage();
//
// if (Manager.GetClients().hasRank(player, Rank.SNR_MODERATOR))
// {
// if (message.startsWith("/restrict"))
// {
// String[] pieces = message.split(" ");
//
// if (pieces.length > 1)
// {
// String challenge = F.combine(pieces, 1, null, false).trim();
//
// if (_list.restrict(challenge))
// {
// UtilPlayer.message(player, F.main("Game", "Restricted to " + F.elem(challenge) + " challenge."));
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "Could not find any challenge by that name."));
// }
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "All challenge restrictions were cleared."));
// _list.unrestrict();
// }
//
// event.setCancelled(true);
// }
// else if (message.startsWith("/skip"))
// {
// if (IsLive())
// {
// endCurrentChallenge();
//
// Announce(C.cAqua + C.Bold + player.getName() + " skipped this challenge.");
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "You cannot skip a challenge if the game is not started."));
// }
//
// event.setCancelled(true);
// }
// else if (message.startsWith("/lose"))
// {
// if (IsLive() && _challenge != null && IsAlive(player))
// {
// setLives(player, 0);
// _challenge.getData().addLostPlayer(player);
// _deathEffect.playDeath(player, player.getLocation());
// GetScoreboard().ResetScore(player.getName());
// _chickenAttack.start(player);
// }
// else
// {
// UtilPlayer.message(player, F.main("Game", "You cannot lose at this time."));
// }
//
// event.setCancelled(true);
// }
// }
// }
/*
* Helper methods

View File

@ -8,7 +8,7 @@ import org.bukkit.Location;
public class ChallengeSettings
{
private Challenge _challenge;
private int _minPlayers = 2;
private int _minPlayers = 1;
private int _maxPlayers = 250;
private int _maxCompletedCount;
private long _startTime;

View File

@ -12,6 +12,8 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
/**
* This challenge is used to prevent the game from crashing if it's forced to start with only one player.
*
* @deprecated
*/
public class ChallengeEmpty extends Challenge
{