Bug fixes

This commit is contained in:
Morten 2015-12-22 16:02:45 +01:00
parent c683ce5f0a
commit 14fd00a368
10 changed files with 226 additions and 92 deletions

View File

@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -52,7 +53,9 @@ import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.holeinwall.KitNormal;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeAnvilDance;
@ -102,16 +105,17 @@ import nautilus.game.arcade.kit.Kit;
public class MineWare extends SoloGame implements IThrown
{
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
private Challenge _challenge;
private ArrayList<Block> _lastOrderBlocks;
private long _challengeTime;
public boolean _currentCrumble = false;
private boolean _waitingChallenge = true;
private boolean _allMessageSent = false;
private boolean _sendingMessages = false;
private boolean _isChallengeStarted = false;
private long _challengeTime;
private Challenge _challenge;
private ArrayList<Block> _lastOrderBlocks;
private ArrayList<Player> _places = new ArrayList<Player>();
private ArrayList<Class<? extends Challenge>> _challenges = new ArrayList<Class<? extends Challenge>>();
private ArrayList<Class<? extends Challenge>> _challengesCopy = new ArrayList<Class<? extends Challenge>>();
@ -181,9 +185,27 @@ public class MineWare extends SoloGame implements IThrown
{
SetState(GameState.End);
AnnounceEnd(getWinners());
for(Player players: GetPlayers(false))
{
if(getWinners().contains(players))
{
AddGems(players, 40, "1st Place", false, false);
}
if(_places.size() >= 1)
{
AddGems(_places.get(0), 20, "Third Place", false, false);
}
if(_places.size() >= 2)
{
AddGems(_places.get(1), 30, "Second Place", false, false);
}
AddGems(players, 10, "Participation", false, false);
}
}
}
@Override
public boolean isInsideMap(Player player)
{
@ -449,6 +471,10 @@ public class MineWare extends SoloGame implements IThrown
public void onQuit(PlayerQuitEvent event)
{
_lives.remove(event.getPlayer());
if(_places.contains(event.getPlayer()))
{
_places.remove(event.getPlayer());
}
if (_challenge != null)
{
@ -834,6 +860,15 @@ public class MineWare extends SoloGame implements IThrown
return;
int lives = GetLives(player);
int playersAlive = 0;
for(Player players: _lives.keySet())
{
if(_lives.get(players) > 0)
{
playersAlive++;
}
}
lives -= 1;
_lives.put(player, lives);
@ -844,8 +879,11 @@ public class MineWare extends SoloGame implements IThrown
}
else
{
if(playersAlive <= 3)
{
_places.add(player);
}
gameLostMessage(player);
Scoreboard.ResetScore(player.getName());
SetPlayerState(player, PlayerState.OUT);
@ -869,6 +907,10 @@ public class MineWare extends SoloGame implements IThrown
{
LoseLife(player, true);
}
if(_challenge.IsCompleted(player))
{
AddGems(player, 3, "Completed Challenge", true, true);
}
}
// Deregister
@ -918,12 +960,12 @@ public class MineWare extends SoloGame implements IThrown
}
if (_challenge != null && _isChallengeStarted)
{
Scoreboard.Write(C.cRed + "Players Currently completed");
Scoreboard.Write("" + _challenge.Completed.size());
Scoreboard.Write(C.cGreen + "Players Currently Alive");
Scoreboard.Write("" + _challenge.getCurrentyAlive(false).size());
Scoreboard.WriteBlank();
Scoreboard.Write(C.cRed + "Players Currently Out");
Scoreboard.Write("" + _challenge.Lost.size());
Scoreboard.WriteBlank();
}
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGreen + "Players In");

View File

@ -51,6 +51,7 @@ public class ChallengeAnvilDance extends Challenge
// The amount of anvils that have yet to land in the platform or are launched in air.
private HashSet<FallingBlock> _fallingAnvils = new HashSet<FallingBlock>();
private long killCurrentTime;
private BukkitTask _fireworkTask;
@ -215,6 +216,7 @@ public class ChallengeAnvilDance extends Challenge
}
_paused = true;
killCurrentTime = System.currentTimeMillis()+3000;
playFireworksTask();
for(Player player : UtilServer.getPlayers())
@ -339,6 +341,10 @@ public class ChallengeAnvilDance extends Challenge
cancel();
return;
}
if(killCurrentTime > System.currentTimeMillis())
{
return;
}
for(Entity entity : block.getNearbyEntities(0.05, 0.05, 0.05))
{
@ -348,6 +354,8 @@ public class ChallengeAnvilDance extends Challenge
if(isDone(player))
return;
if(!Host.IsAlive(player))
return;
player.damage(player.getHealth());
cancel();

View File

@ -52,9 +52,9 @@ public class ChallengeDogvsCat extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() + 1); x <= getArenaSize()-1; x++)
for(int x = -(getArenaSize() - 1); x <= getArenaSize()-1; x++)
{
for(int z = -(getArenaSize() + 1); z <= getArenaSize()-1; z++)
for(int z = -(getArenaSize() - 1); z <= getArenaSize()-1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
{
@ -187,8 +187,8 @@ public class ChallengeDogvsCat extends Challenge
int dogScore = calculateScore("dog");
UtilTextMiddle.display(C.cBlue + C.Bold + "Dogs: " + C.cGreen + _dogScore + "/" + dogScore + " - " + C.cRed + C.Bold
+ "Cats: " + C.cGreen + _catScore + "/" + catScore, "");
UtilTextMiddle.display("", C.cBlue + C.Bold + " Dogs: " + C.cGreen + _dogScore + "/" + dogScore + C.cGray + " - " + C.cRed + C.Bold
+ "Cats: " + C.cGreen + _catScore + "/" + catScore);
if(_catScore >= catScore)
{

View File

@ -321,6 +321,8 @@ public class ChallengeFallingBlocks extends Challenge
if(isDone(player))
return;
if(!Host.IsAlive(player))
return;
player.damage(player.getHealth());
cancel();

View File

@ -47,7 +47,8 @@ public class ChallengeMinecartDance extends Challenge
public ChallengeMinecartDance(MineWare host)
{
super(host, ChallengeType.LastStanding, "Minecart Dance", "Get ready when the fireworks change color.", "Once they're green, get inside a minecart!");
super(host, ChallengeType.LastStanding, "Musical Minecart", "Get ready when the fireworks change color.",
"Once they're green, get inside a minecart!");
}
@Override
@ -55,11 +56,11 @@ public class ChallengeMinecartDance extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize(7) - 1); x <= getArenaSize(7); x++)
for (int x = -(getArenaSize(7) - 1); x <= getArenaSize(7); x++)
{
for(int z = -(getArenaSize(7) - 1); z <= getArenaSize(7); z++)
for (int z = -(getArenaSize(7) - 1); z <= getArenaSize(7); z++)
{
if(x % 2 == 0 && z % 2 == 0)
if (x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
@ -71,15 +72,17 @@ public class ChallengeMinecartDance extends Challenge
@Override
public void cleanupRoom()
{
if(_isPlayingMusic)
if (_isPlayingMusic)
{
_isPlayingMusic = false;
for(Player player: UtilServer.getPlayers())
for (Player player : UtilServer.getPlayers())
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY()+5, getCenter().getBlockZ()), 0, false));
((CraftPlayer) player).getHandle().playerConnection
.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(),
getCenter().getBlockY() + 5, getCenter().getBlockZ()), 0, false));
}
}
for(Minecart minecarts : _minecarts)
for (Minecart minecarts : _minecarts)
{
minecarts.remove();
}
@ -96,28 +99,28 @@ public class ChallengeMinecartDance extends Challenge
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
for (int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
for (int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
for (int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
if (y == 0)
{
b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16));
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
if (Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
if (b.getType() != Material.AIR)
{
addBlock(b);
}
@ -129,20 +132,20 @@ public class ChallengeMinecartDance extends Challenge
@EventHandler
public void gameChecker(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTEST)
if (event.getType() != UpdateType.FASTEST)
{
return;
}
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
if(_state == 3)
if (_state == 3)
{
_availableMinecarts = 0;
for(Minecart mc : _minecarts)
for (Minecart mc : _minecarts)
{
if(!mc.isEmpty())
if (!mc.isEmpty())
{
continue;
}
@ -151,11 +154,11 @@ public class ChallengeMinecartDance extends Challenge
_availableMinecarts++;
}
}
if(_availableMinecarts == 0)
if (_availableMinecarts == 0)
{
for(Player player : getCurrentyAlive(true))
for (Player player : getCurrentyAlive(true))
{
if(!player.isInsideVehicle())
if (!player.isInsideVehicle())
{
Host.WorldData.World.strikeLightningEffect(player.getLocation());
setLost(player);
@ -166,9 +169,9 @@ public class ChallengeMinecartDance extends Challenge
_timeSinceLastState = System.currentTimeMillis();
_state = 1;
for(Minecart minecarts : _minecarts)
for (Minecart minecarts : _minecarts)
{
if(!minecarts.isEmpty())
if (!minecarts.isEmpty())
{
minecarts.eject();
}
@ -184,28 +187,30 @@ public class ChallengeMinecartDance extends Challenge
{
// Main event that's fired each sec
if(event.getType() != UpdateType.SEC)
if (event.getType() != UpdateType.SEC)
{
return;
}
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
if(_state == 1) // waiting
if (_state == 1) // waiting
{
if(!_isPlayingMusic)
if (!_isPlayingMusic)
{
_isPlayingMusic = true;
for(Player player: UtilServer.getPlayers())
for (Player player : UtilServer.getPlayers())
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY()+5, getCenter().getBlockZ()), 2259, false));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005,
new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter()
.getBlockZ()), 2259, false));
}
}
if(_timeSinceLastState + 5500 < System.currentTimeMillis())
if (_timeSinceLastState + 5500 < System.currentTimeMillis())
{
if(UtilMath.r(4) == 0)
if (UtilMath.r(4) == 0)
{
_state = 2;
}
@ -219,7 +224,7 @@ public class ChallengeMinecartDance extends Challenge
spawnFireworkAtCorners(Color.RED);
}
}
if(_state == 2) // stateChange
if (_state == 2) // stateChange
{
new BukkitRunnable()
{
@ -227,33 +232,45 @@ public class ChallengeMinecartDance extends Challenge
@Override
public void run()
{
for(int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
spawnFireworkAtCorners(Color.GREEN);
//Thread.sleep((500)); // 10th tick, causing lag
// Thread.sleep((500)); // 10th tick, causing lag
}
}
}.runTaskLater(Host.Manager.getPlugin(), 0);
if(_isPlayingMusic)
if (_isPlayingMusic)
{
_isPlayingMusic = false;
for(Player player: UtilServer.getPlayers())
for (Player player : UtilServer.getPlayers())
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY()+5, getCenter().getBlockZ()), 0, false));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005,
new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter()
.getBlockZ()), 0, false));
}
}
for(int i = 0; i < getCurrentyAlive(true).size()/2; i++)
for (int i = 0; i < getCurrentyAlive(true).size() / 2; i++)
{
Minecart minecart = Host.WorldData.World.spawn(new Location(Host.WorldData.World,
UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7)), 2, UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7))), Minecart.class);
Minecart minecart = Host.WorldData.World.spawn(
new Location(Host.WorldData.World, UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7)), 2,
UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7))), Minecart.class);
UtilEnt.ghost(minecart, true, false);
_minecarts.add(minecart);
}
_state = 3;
if(getCurrentyAlive(false).size() >= 10)
{
startTimer(Math.round(getCurrentyAlive(false).size()/2.5));
}
else
{
startTimer(Math.round(4));
}
}
else if(_state == 3)
else if (_state == 3)
{
new BukkitRunnable()
{
@ -261,14 +278,14 @@ public class ChallengeMinecartDance extends Challenge
@Override
public void run()
{
if(_state != 3 || !Host.IsLive())
if (_state != 3 || !Host.IsLive())
{
this.cancel();
}
int minecarts = 0;
for(Minecart minecart : _minecarts)
for (Minecart minecart : _minecarts)
{
if(!minecart.isEmpty())
if (!minecart.isEmpty())
{
minecarts++;
}
@ -283,43 +300,86 @@ public class ChallengeMinecartDance extends Challenge
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event)
{
if(!Host.IsLive())
if (!Host.IsLive())
{
return;
}
if(event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleInteract(VehicleEnterEvent event)
{
if(!Host.IsLive())
{
return;
}
if(!(event.getEntered() instanceof Player))
{
return;
}
Player player = (Player) event.getEntered();
if(isLost(player) || !Host.IsPlaying(player))
if (event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleInteract(VehicleEnterEvent event)
{
if (!Host.IsLive())
{
return;
}
if (!(event.getEntered() instanceof Player))
{
return;
}
Player player = (Player) event.getEntered();
if (isLost(player) || !Host.IsPlaying(player))
{
event.setCancelled(true);
}
}
public void startTimer(long ticks)
{
new BukkitRunnable()
{
@Override
public void run()
{
if (_state == 3)
{
for (Player player : getCurrentyAlive(true))
{
if (!player.isInsideVehicle())
{
Host.WorldData.World.strikeLightningEffect(player.getLocation());
setLost(player);
UtilPlayer.message(player, F.main("Minecart Dance", "You didn't make it inside a Minecart in time!"));
}
}
_timeSinceLastState = System.currentTimeMillis();
_state = 1;
for (Minecart minecarts : _minecarts)
{
if (!minecarts.isEmpty())
{
minecarts.eject();
}
minecarts.remove();
}
_minecarts.clear();
}
else
{
this.cancel();
}
}
}.runTaskLater(Host.Manager.getPlugin(), ticks);
}
public void spawnFireworkAtCorners(Color color)
{
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, getArenaSize() + 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, getArenaSize() + 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, -getArenaSize() - 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, -getArenaSize() - 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, getArenaSize() + 5),
Type.BALL_LARGE, color, false, false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, getArenaSize() + 5),
Type.BALL_LARGE, color, false, false);
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, -getArenaSize() - 5),
Type.BALL_LARGE, color, false, false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, -getArenaSize() - 5),
Type.BALL_LARGE, color, false, false);
}
}

View File

@ -21,7 +21,7 @@ public class ChallengeNavigateMaze extends Challenge
private HashMap<Player, Long> _playerCompletionTime = new HashMap<Player, Long>();
public ChallengeNavigateMaze(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Nagivation maze", "Go to the other side of the maze.");
super(host, ChallengeType.FirstComplete, "Nagivation Maze", "Go to the other side of the maze.");
}
@Override

View File

@ -28,7 +28,7 @@ public class ChallengePickASide extends Challenge
public ChallengePickASide(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Pick a Side", "The side with the least players wins!");
super(host, ChallengeType.FirstComplete, "Pick a Side", "The side with the fewest players wins!", "No... Standing in the middle won't work");
}
public int getMinPlayers()

View File

@ -39,6 +39,7 @@ public class ChallengeRedLightGreenLight extends Challenge
private boolean _canMove;
private int _minTimeBeforeGreen = 2500;
private int _minTimeBeforeRed = 1500;
private int _villagerLocationX = 30;
private long _timeBeforeAction;
private long _timeSinceLastGreen;
private long _timeSinceLastRed;
@ -119,6 +120,10 @@ public class ChallengeRedLightGreenLight extends Challenge
b.setType(Material.WOOL);
b.setData(_colorList.get(colorPicker).byteValue());
}
if(x == _villagerLocationX)
{
b.setType(Material.COAL_BLOCK);
}
if(b.getType() != Material.AIR)
{
addBlock(b);
@ -133,7 +138,7 @@ public class ChallengeRedLightGreenLight extends Challenge
}
Host.CreatureAllowOverride = true;
_host = (Villager)getCenter().getWorld().spawnEntity(new Location(getCenter().getWorld(), 30, 1, 0), EntityType.VILLAGER);
_host = (Villager)getCenter().getWorld().spawnEntity(new Location(getCenter().getWorld(), _villagerLocationX, 2, 0), EntityType.VILLAGER);
UtilEnt.Vegetate(_host);
UtilEnt.ghost(_host, true, false);
Host.CreatureAllowOverride = false;
@ -150,7 +155,7 @@ public class ChallengeRedLightGreenLight extends Challenge
{
return;
}
if(event.getPlayer().getLocation().getX() > 30) // Wins the challenge
if(event.getPlayer().getLocation().getX() > _villagerLocationX) // Wins the challenge
{
SetCompleted(event.getPlayer());
}

View File

@ -131,8 +131,21 @@ public class ChallengeShootChickens extends Challenge
{
return;
}
UpdateType speed;
if(getCurrentyAlive(false).size() >= 40)
{
speed = UpdateType.FASTEST;
}
else if(getCurrentyAlive(false).size() >= 20)
{
speed = UpdateType.FASTER;
}
else
{
speed = UpdateType.FAST;
}
if (event.getType() != UpdateType.FAST)
if (event.getType() != speed)
{
return;
}

View File

@ -189,6 +189,10 @@ public class ChallengeWaveCrush extends Challenge
{
return;
}
if(!Host.IsAlive(thePlayer))
{
return;
}
Host.Manager.GetDamage().NewDamageEvent(target, null, null, DamageCause.PROJECTILE, 9999.0, false, false, false, "Falling Block",
"Wave crush");
}