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