Fix teleport delay and incorrect win placement.

Players that die during a challenge have the ability to fly
around as spectators. Although, once the challenge was ended
their fly mode was removed and they would fall for a very short
amount of time, which was noticeable. With that fix, players
now get reset once they are teleported to the spawn locations
of the next challenge. That happened because during the player
reset and spawn teleportation, the map would be generated, as a
result, causing a very small notable delay.

Moreover, win placement was fixed. In the previous version, the
third player would appear as second and the second player would
appear as the third one. The cause of this issue was that, after
the second and the third player is added to the winner list, the
last player that is remaining alive is added as first. To fix that,
I've implemented a swap method that changes the location of the
second with the third player.
This commit is contained in:
Thanos paravantis 2016-04-09 11:04:23 +03:00
parent cc68b7087a
commit 0b780c8e99
2 changed files with 39 additions and 64 deletions

View File

@ -76,7 +76,6 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge; import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeList; import nautilus.game.arcade.game.games.mineware.challenge.ChallengeList;
import nautilus.game.arcade.game.games.mineware.challenge.other.ChallengeSeperateRooms;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeAnvilDance; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeAnvilDance;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeArrowRampage; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeArrowRampage;
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBlockLobbers; import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBlockLobbers;
@ -156,13 +155,13 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private String _skipCommand = "skip"; private String _skipCommand = "skip";
private String _markCommand = "mark"; private String _markCommand = "mark";
List<String> _countdown = Arrays.asList( private List<String> _countdown = Arrays.asList(
C.cRed + C.Bold + "3", C.cRed + C.Bold + "3",
C.cYellow + C.Bold + "2", C.cYellow + C.Bold + "2",
C.cGreen + C.Bold + "1", C.cGreen + C.Bold + "1",
C.cWhite + C.Bold + "GO!"); C.cWhite + C.Bold + "GO!");
/** /*
* TODO: Bugs * TODO: Bugs
* *
* - Small delay on spectator reset? * - Small delay on spectator reset?
@ -190,6 +189,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
"Last player with lives wins!" "Last player with lives wins!"
}); });
_settings.setMaxLives(2);
// Damage = false; // Damage = false;
DamagePvP = false; DamagePvP = false;
DamagePvE = false; DamagePvE = false;
@ -345,7 +346,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
} }
_challenge = selectChallenge(); _challenge = selectChallenge();
resetPlayers();
keepSearchingWhenNull(); keepSearchingWhenNull();
resetLastChallengeMap(); resetLastChallengeMap();
@ -358,14 +358,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_challenge.markSpawnLocations(); _challenge.markSpawnLocations();
teleportPlayersToSpawnpoints(); teleportPlayersToSpawnpoints();
resetPlayers();
teleportSpectatorsToSpawn(); teleportSpectatorsToSpawn();
if (_challenge instanceof ChallengeSeperateRooms)
{
ChallengeSeperateRooms challengeWithRooms = (ChallengeSeperateRooms) _challenge;
challengeWithRooms.assignRooms();
}
_delay = System.currentTimeMillis(); _delay = System.currentTimeMillis();
_settings.setWaiting(true); _settings.setWaiting(true);
} }
@ -579,18 +574,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
{ {
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
if (_challenge instanceof ChallengeSeperateRooms) UtilTextTop.displayTextBar(player, _challenge.getTimeLeftPercent(), C.cYellow + C.Bold + _challenge.getName());
{ player.setLevel(_challenge.getRemainingPlaces());
UtilTextTop.display(C.cYellow + C.Bold + _challenge.getDescription()[0], player); player.setExp(_challenge.getTimeLeftPercent());
player.setLevel(_challenge.getRemainingPlaces());
player.setExp(_challenge.getTimeLeftPercent());
}
else
{
UtilTextTop.displayTextBar(player, _challenge.getTimeLeftPercent(), C.cYellow + C.Bold + _challenge.getName());
player.setLevel(_challenge.getRemainingPlaces());
player.setExp(_challenge.getTimeLeftPercent());
}
} }
} }
@ -1492,8 +1478,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (living <= 1) if (living <= 1)
{ {
_winners.add(0, getChallengers().get(0)); _winners.add(0, getChallengers().get(0));
Collections.swap(_winners, 2, 1);
// Collections.reverse(_winners);
if (_winners.size() >= 1) if (_winners.size() >= 1)
{ {

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge; import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType; import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
@ -102,29 +101,29 @@ public class ChallengeNavigationMaze extends Challenge
addBlock(mazeBlock); addBlock(mazeBlock);
} }
// for (int i = 0; i < 30; i++) // for (int i = 0; i < 30; i++)
// { // {
// ArrayList<Block> mazeBlocks = generateMaze(); // ArrayList<Block> mazeBlocks = generateMaze();
// //
// if (isMazeValid()) // if (isMazeValid())
// { // {
// for (Block mazeBlock : mazeBlocks) // for (Block mazeBlock : mazeBlocks)
// { // {
// addBlock(mazeBlock); // addBlock(mazeBlock);
// } // }
// //
// break; // break;
// } // }
// else // else
// { // {
// System.out.print("Generated bad maze, trying again.."); // System.out.print("Generated bad maze, trying again..");
// //
// for (Block mazeBlock : mazeBlocks) // for (Block mazeBlock : mazeBlocks)
// { // {
// mazeBlock.setTypeIdAndData(Material.AIR.getId(), (byte) 0, false); // mazeBlock.setTypeIdAndData(Material.AIR.getId(), (byte) 0, false);
// } // }
// } // }
// } // }
} }
@Override @Override
@ -164,22 +163,21 @@ public class ChallengeNavigationMaze extends Challenge
{ {
Block block = nextLoop.remove(0); Block block = nextLoop.remove(0);
for (BlockFace face : new BlockFace[] { for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH })
BlockFace.EAST,
BlockFace.WEST,
BlockFace.SOUTH,
BlockFace.NORTH
})
{ {
Block b = block.getRelative(face); Block b = block.getRelative(face);
if (blocks.contains(b)) if (blocks.contains(b))
{
continue; continue;
}
blocks.add(b); blocks.add(b);
if (b.getType() == Material.STONE || b.getX() < getCenter().getX() + -14 || b.getZ() < getCenter().getZ() + -12 || b.getZ() > getCenter().getZ() + 15) if (b.getType() == Material.STONE || b.getX() < getCenter().getX() + -14 || b.getZ() < getCenter().getZ() + -12 || b.getZ() > getCenter().getZ() + 15)
{
continue; continue;
}
if (b.getX() >= getCenter().getX() + 15) if (b.getX() >= getCenter().getX() + 15)
{ {
@ -199,12 +197,6 @@ public class ChallengeNavigationMaze extends Challenge
ArrayList<Block> blocks = new ArrayList<Block>(); ArrayList<Block> blocks = new ArrayList<Block>();
int[][] maze = new MazeGenerator(11, 10).getMaze(); int[][] maze = new MazeGenerator(11, 10).getMaze();
// Divisable by 2's are up and down walls
// Other's are left and right. All walls have a corner block.
// This means I need to loop over all of the blocks, figure out if its a corner if yes then set block
// Else if its a wall, then figure out if I'm making the wall or not
for (int x = 1; x < 11; x++) for (int x = 1; x < 11; x++)
{ {
for (int z = 1; z < 10; z++) for (int z = 1; z < 10; z++)
@ -223,7 +215,6 @@ public class ChallengeNavigationMaze extends Challenge
blocks.add(block); blocks.add(block);
} }
// Set blocks for x
if (x < 10 && (maze[x][z] & 8) == 0) if (x < 10 && (maze[x][z] & 8) == 0)
{ {
for (int i = 1; i <= 2; i++) for (int i = 1; i <= 2; i++)
@ -243,7 +234,6 @@ public class ChallengeNavigationMaze extends Challenge
} }
// Set blocks for z
if ((maze[x][z] & 1) == 0) if ((maze[x][z] & 1) == 0)
{ {
for (int i = 1; i <= 2; i++) for (int i = 1; i <= 2; i++)