diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java index ee52eadd6..f250a8972 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java @@ -585,7 +585,10 @@ public class MineWare extends SoloGame implements IThrown if (_challenge != null) { - _challenge.CurrentPlaying.remove(event.getPlayer()); + if (_challenge.CurrentPlaying != null) + { + _challenge.CurrentPlaying.remove(event.getPlayer()); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaterHorror.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaterHorror.java index 2e6672a19..f981f83a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaterHorror.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaterHorror.java @@ -7,7 +7,6 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Boat; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -20,14 +19,12 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.scheduler.BukkitRunnable; import org.spigotmc.event.entity.EntityDismountEvent; -import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilTextBottom; import mineplex.core.explosion.ExplosionEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -36,12 +33,13 @@ import nautilus.game.arcade.game.games.mineware.MineWare; public class ChallengeWaterHorror extends Challenge { - private Player _previous; + private int _tntSpawnMax = 3; + private int _tntSpawnMin = 1; + private int _tntExplodeAfter = 2; // Seconds + private HashMap _boats = new HashMap(); - private String[] _warnings = { - "Watch out!", - "Incoming!" - }; + private Location dropsite = getCenter().clone().add(0, 7.0, 0); + private Location base = dropsite.clone().subtract(0, 0.5, 0); public ChallengeWaterHorror(MineWare host) { @@ -106,6 +104,8 @@ public class ChallengeWaterHorror extends Challenge { if (y < 6) { + // Container + if (absX == size || absZ == size) { if (y == 5) @@ -117,6 +117,9 @@ public class ChallengeWaterHorror extends Challenge block.setType(Material.DIRT); } } + + // Water + else if (absX < size || absZ < size) { if (y == 5) @@ -131,6 +134,8 @@ public class ChallengeWaterHorror extends Challenge } else { + // Fences + if (absX == size || absZ == size) { block.setType(Material.FENCE); @@ -144,194 +149,6 @@ public class ChallengeWaterHorror extends Challenge } } - private void removeIce() - { - int size = getArenaSize(); - - for (int x = -size; x <= size; x++) - { - for (int z = -size; z <= size; z++) - { - Block block = getCenter().getBlock().getRelative(x, 5, z); - - if (block.getType() == Material.ICE) - block.setType(Material.WATER); - } - } - } - - @EventHandler - public void onEntityDismount(EntityDismountEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - if (event.getEntity() instanceof Boat) - { - event.setCancelled(true); - } - } - - @EventHandler - public void onVehicleDestroy(VehicleDestroyEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - if (event.getVehicle() instanceof Boat) - event.setCancelled(true); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - Player player = event.getPlayer(); - - if (isDone(player)) - return; - - Boat boat = _boats.get(player); - - boat.remove(); - _boats.remove(player); - } - - @EventHandler - public void onPlayerDeath(PlayerDeathEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - Player player = event.getEntity(); - - if (isDone(player)) - return; - - Boat boat = _boats.get(player); - - boat.remove(); - _boats.remove(player); - } - - @EventHandler - public void onExplosion(ExplosionEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - event.GetBlocks().clear(); - } - - @EventHandler - public void onBlockFromTo(BlockFromToEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - if (event.getBlock().getType() == Material.ICE) - event.setCancelled(true); - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - return; - - if (event.getType() != UpdateType.TICK) - return; - - for (Entity entity : Host.WorldData.World.getEntities()) - { - if (entity instanceof TNTPrimed) - { - if (entity.isValid() && !entity.isOnGround()) - { - UtilParticle.PlayParticleToAll(ParticleType.CRIT, entity.getLocation(), 0.0F, 0.0F, 0.0F, 0.0F, 1, - ViewDist.LONG); - - new BukkitRunnable() - { - @Override - public void run() - { - entity.getWorld().playSound(entity.getLocation(), Sound.ORB_PICKUP, 0.5F, 1.0F); - } - }.runTaskLater(Host.getArcadeManager().getPlugin(), 20L); - } - - } - } - } - - private void startTNTSpawnTask() - { - new BukkitRunnable() - { - @Override - public void run() - { - if (!Host.IsLive() || !Host.isChallengeStarted()) - { - cancel(); - return; - } - - ArrayList players = Host.GetPlayers(true); - int amount = (int) players.size() / 2; - - for (int i = 0; i < amount; i++) - { - Player selected = players.get(UtilMath.r(players.size())); - - if (_previous != null) - { - while (selected.equals(_previous)) - selected = players.get(UtilMath.r(players.size())); - } - else - { - _previous = selected; - } - - createExplosive(selected); - } - } - }.runTaskTimer(Host.getArcadeManager().getPlugin(), 40L, 60L); - } - - private void createExplosive(Player player) - { - Location target = player.getLocation(); - Block selection = target.getBlock(); - - Block[] dropsites = { - selection.getRelative(BlockFace.NORTH), - selection.getRelative(BlockFace.SOUTH), - selection.getRelative(BlockFace.EAST), - selection.getRelative(BlockFace.WEST) - }; - - Location dropsite = UtilMath.randomElement(dropsites).getLocation(); - - dropsite.getWorld().playSound(dropsite, Sound.ZOMBIE_WOODBREAK, 0.5F, 1.3F); - - TNTPrimed explosive = dropsite.getWorld().spawn(dropsite, TNTPrimed.class); - explosive.setFuseTicks(40); - - UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target), 0.6D, true, 1.3D, 0.0D, 1.0D, false); - warn(player); - } - - private void warn(Player player) - { - String warning = UtilMath.randomElement(_warnings); - UtilTextBottom.display(C.cGold + C.Bold + warning, player); - } - @Override public void setupPlayers() { @@ -364,4 +181,188 @@ public class ChallengeWaterHorror extends Challenge _boats.clear(); } + + @EventHandler + public void onUpdateEntityTrail(UpdateEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + for (Entity entity : Host.WorldData.World.getEntities()) + { + if (entity instanceof TNTPrimed) + { + if (entity.isValid() && !entity.isOnGround()) + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation(), 0.2F, 0.2F, 0.2F, + 0.0F, 2, + ViewDist.LONG); + + new BukkitRunnable() + { + @Override + public void run() + { + entity.getWorld().playSound(entity.getLocation(), Sound.ORB_PICKUP, 0.5F, 1.0F); + } + }.runTaskLater(Host.getArcadeManager().getPlugin(), 20L); + } + + } + } + } + + @EventHandler + public void onUpdateSpawnerParticle(UpdateEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + UtilParticle.PlayParticleToAll(ParticleType.FLAME, dropsite, 0.3F, 0.3F, 0.3F, 0.03F, 2, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, base, 0.1F, 0.1F, 0.1F, 0.0F, 2, + ViewDist.LONG); + } + + @EventHandler + public void onEntityDismount(EntityDismountEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + if (event.getEntity() instanceof Boat) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onVehicleDestroy(VehicleDestroyEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + if (event.getVehicle() instanceof Boat) + event.setCancelled(true); + } + + @EventHandler + public void onExplosion(ExplosionEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + event.GetBlocks().clear(); + } + + @EventHandler + public void onBlockFromTo(BlockFromToEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + if (event.getBlock().getType() == Material.ICE) + event.setCancelled(true); + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + Player player = event.getEntity(); + + if (isDone(player)) + return; + + player.eject(); + + Boat boat = _boats.get(player); + + boat.remove(); + _boats.remove(player); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + return; + + Player player = event.getPlayer(); + + if (isDone(player)) + return; + + player.eject(); + + Boat boat = _boats.get(player); + + boat.remove(); + _boats.remove(player); + } + + private void startTNTSpawnTask() + { + new BukkitRunnable() + { + @Override + public void run() + { + if (!Host.IsLive() || !Host.isChallengeStarted()) + { + cancel(); + return; + } + + ArrayList players = Host.GetPlayers(true); + int times = UtilMath.r(_tntSpawnMax) + _tntSpawnMin; + + if (times > players.size()) + times = players.size(); + + System.out.println("Times: " + times); + + for (int i = 0; i < times; i++) + { + Player target = UtilMath.randomElement(players); + createExplosive(target, dropsite); + } + + dropsite.getWorld().playSound(dropsite, Sound.ZOMBIE_WOODBREAK, 0.5F, 1.3F); + } + }.runTaskTimer(Host.getArcadeManager().getPlugin(), 40L, 40L); + } + + private void createExplosive(Player player, Location dropsite) + { + Location target = player.getLocation(); + + TNTPrimed explosive = dropsite.getWorld().spawn(dropsite, TNTPrimed.class); + explosive.setFuseTicks(_tntExplodeAfter * 20); + + UtilAction.velocity(explosive, UtilAlg.getTrajectory(dropsite, target), 0.6D, true, 1.3D, 0.0D, 1.0D, false); + } + + private void removeIce() + { + int size = getArenaSize(); + + for (int x = -size; x <= size; x++) + { + for (int z = -size; z <= size; z++) + { + Block block = getCenter().getBlock().getRelative(x, 5, z); + + if (block.getType() == Material.ICE) + block.setType(Material.WATER); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathText.java index 4a1b350b1..3bc5c1170 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathText.java @@ -8,7 +8,8 @@ public class DeathText "Nom nom nom!", "Bawk Bawk!", "Delicious Meal!", - "Nom nom, bawk!" + "Nom nom, bawk!", + "Yummy, delicious!" }; public String getRandom()