diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java index 9eb5c65b9..3c9e20705 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java @@ -28,6 +28,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scheduler.BukkitRunnable; public abstract class Challenge implements Listener @@ -43,7 +44,7 @@ public abstract class Challenge implements Listener protected long Duration; protected HashSet Completed = new HashSet(); protected HashSet Lost = new HashSet(); - protected HashSet currentPlaying; + protected HashSet CurrentPlaying; private boolean _teamBased; private boolean _crumble; @@ -80,6 +81,17 @@ public abstract class Challenge implements Listener setBorder(-100, 100, 0, 256, -100, 100); } + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + if(!Host.IsLive()) + { + return; + } + removePlayerFromAllLists(event.getPlayer()); + } + + public long getMaxTime() { return 60000; @@ -119,7 +131,7 @@ public abstract class Challenge implements Listener public void StartOrder() { - currentPlaying = new HashSet(getChallengers()); + CurrentPlaying = new HashSet(getChallengers()); setupPlayers(); Completed.clear(); @@ -352,7 +364,7 @@ public abstract class Challenge implements Listener public ArrayList getCurrentyAlive(boolean ignoreAlreadyWon) { ArrayList currentlyAlive = new ArrayList(); - for(Player player: currentPlaying) + for(Player player: CurrentPlaying) { if(isLost(player)) { @@ -396,6 +408,26 @@ public abstract class Challenge implements Listener return false; } + public void removePlayerFromAllLists(Player player) + { + if(Lost.contains(player)) + { + Lost.remove(player); + } + if(Completed.contains(player)) + { + Completed.remove(player); + } + if(_invisPlayers.contains(player)) + { + _invisPlayers.remove(player); + } + if(CurrentPlaying.contains(player)) + { + CurrentPlaying.remove(player); + } + } + public String getChallengeName() { return _challengeName; 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 573358076..71ac55080 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 @@ -37,6 +37,7 @@ import nautilus.game.arcade.game.games.mineware.challenges.ChallengeArrowRampage import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockLobbers; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockRunner; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBouncingBlock; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBuildRace; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeChestLoot; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeCloudFall; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeDogvsCat; @@ -113,6 +114,7 @@ public class MineWare extends SoloGame implements IThrown private ArrayList> _challenges = new ArrayList>(); private ArrayList> _challengesCopy = new ArrayList>(); + @SuppressWarnings("unchecked") public MineWare(ArcadeManager manager) { super(manager, GameType.MineWare, @@ -224,7 +226,7 @@ public class MineWare extends SoloGame implements IThrown _challenges.add(ChallengeCloudFall.class); _challenges.add(ChallengeInfestation.class); _challenges.add(ChallengeBouncingBlock.class); - _challenges.add(ChallengeBlockRunner.class); + _challenges.add(ChallengeBuildRace.class); _challenges.add(ChallengeFastFood.class); _challenges.add(ChallengeMinecartDance.class); _challenges.add(ChallengeRedLightGreenLight.class); @@ -432,6 +434,11 @@ public class MineWare extends SoloGame implements IThrown public void onQuit(PlayerQuitEvent event) { _lives.remove(event.getPlayer()); + + if(_challenge != null) + { + _challenge.CurrentPlaying.remove(event.getPlayer()); + } } public ArrayList getChallengers() @@ -675,7 +682,7 @@ public class MineWare extends SoloGame implements IThrown { if(_challenge.getCrumble() && !_challenge.getModifiedBlocks().isEmpty()) { - if(_currentCrumble == false && _challenge.Lost.size() >= _challenge.currentPlaying.size() / 2) + if(_currentCrumble == false && _challenge.Lost.size() >= _challenge.CurrentPlaying.size() / 2) { _currentCrumble = true; for(Player player : UtilServer.getPlayers()) @@ -689,7 +696,7 @@ public class MineWare extends SoloGame implements IThrown } else { - if((_challenge.currentPlaying.size() - _challenge.Lost.size()) <= 1 && _currentCrumble) + if((_challenge.CurrentPlaying.size() - _challenge.Lost.size()) <= 1 && _currentCrumble) { endCurrentChallenge(); _currentCrumble = false; @@ -743,7 +750,7 @@ public class MineWare extends SoloGame implements IThrown { return; } - if(event.getMessage().equalsIgnoreCase("/tp") || event.getMessage().equalsIgnoreCase("/teleport")) + if(event.getMessage().contains("/tp") || event.getMessage().contains("/teleport")) { CoreClient staff = getArcadeManager().GetClients().Get(event.getPlayer()); @@ -758,7 +765,6 @@ public class MineWare extends SoloGame implements IThrown Manager.addSpectator(player, true); } - } } @@ -850,7 +856,7 @@ public class MineWare extends SoloGame implements IThrown } Scoreboard.Reset(); - if(GetPlayers(false).size() > 14) + if(GetPlayers(true).size() > 14) { int alive = 0; for(Player cAlive : _lives.keySet()) @@ -860,17 +866,26 @@ public class MineWare extends SoloGame implements IThrown alive++; } } + if(_challenge != null && _isChallengeStarted) + { + 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 Alive"); + Scoreboard.Write(C.cGreen + "Players In"); Scoreboard.Write(alive + " "); Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players out: "); + Scoreboard.Write(C.cRed + "Players Out"); Scoreboard.Write((GetPlayers(false).size() - alive) + " "); } else { Scoreboard.WriteBlank(); - for(Player player : GetPlayers(false)) + for(Player player : GetPlayers(true)) { int currentLives = GetLives(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeAnvilDance.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeAnvilDance.java index e5a2ccac3..1f78c73af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeAnvilDance.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeAnvilDance.java @@ -4,13 +4,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilShapes; -import nautilus.game.arcade.game.games.mineware.Challenge; -import nautilus.game.arcade.game.games.mineware.MineWare; - import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; @@ -26,8 +19,16 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import nautilus.game.arcade.game.games.mineware.Challenge; +import nautilus.game.arcade.game.games.mineware.MineWare; + public class ChallengeAnvilDance extends Challenge { // The amount of seconds until the anvils start to dance. @@ -50,6 +51,8 @@ public class ChallengeAnvilDance extends Challenge // The amount of anvils that have yet to land in the platform or are launched in air. private HashSet _fallingAnvils = new HashSet(); + + private BukkitTask _fireworkTask; public ChallengeAnvilDance(MineWare host) { @@ -105,6 +108,7 @@ public class ChallengeAnvilDance extends Challenge @Override public void cleanupRoom() { + _fireworkTask.cancel(); _paused = false; for(Block block : _landedAnvils) @@ -289,7 +293,7 @@ public class ChallengeAnvilDance extends Challenge private void playFireworksTask() { - new BukkitRunnable() + _fireworkTask = new BukkitRunnable() { int height = _fireworkHeight; int times = 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBouncingBlock.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBouncingBlock.java index f3a23a7e1..bffad13f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBouncingBlock.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBouncingBlock.java @@ -215,7 +215,7 @@ public class ChallengeBouncingBlock extends Challenge if(b.getType() == Material.AIR || b.getType() == null) { - if(UtilMath.r(200) == 50) + if(UtilMath.r(50) == 0) { Byte color = (byte) UtilMath.r(16); while(color == 14) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeDogvsCat.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeDogvsCat.java index 989c8b1a5..d8b99b24f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeDogvsCat.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeDogvsCat.java @@ -173,7 +173,7 @@ public class ChallengeDogvsCat extends Challenge @EventHandler public void checkForWinner(UpdateEvent event) { - if(event.getType() != UpdateType.FASTEST) + if(event.getType() != UpdateType.TICK) { return; } @@ -187,8 +187,8 @@ public class ChallengeDogvsCat extends Challenge int dogScore = calculateScore("dog"); - UtilTextMiddle.display(C.cBlue + C.Bold + "Dog's: " + C.cGreen + _dogScore + "/" + dogScore + " - " + C.cRed + C.Bold - + "Cat's: " + C.cGreen + _catScore + "/" + catScore, ""); + UtilTextMiddle.display(C.cBlue + C.Bold + "Dogs: " + C.cGreen + _dogScore + "/" + dogScore + " - " + C.cRed + C.Bold + + "Cats: " + C.cGreen + _catScore + "/" + catScore, ""); if(_catScore >= catScore) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFishingDay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFishingDay.java index 778484457..5912ecee3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFishingDay.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFishingDay.java @@ -125,7 +125,7 @@ public class ChallengeFishingDay extends Challenge } else { - if(y == 5) + if(y == 5 && !getSpawns().contains(block.getLocation())) { block.setType(Material.GRASS); @@ -379,12 +379,15 @@ public class ChallengeFishingDay extends Challenge // Check if the player is retracting the hook. // Once hook is retracted, the entity is valid but not on ground. - return _fishing.get(fisher) && hook.isValid() && !hook.isOnGround(); + Location droppedHook = hook.getLocation(); + Block below = droppedHook.getBlock().getRelative(BlockFace.DOWN); + + return _fishing.get(fisher) && hook.isValid() && !hook.isOnGround() && below.getType() == Material.STATIONARY_WATER; } private void createExplosion(Player target, Location dropsite) { - if (Recharge.Instance.use(target, "TNT Spawn", 700, false, false)) + if(Recharge.Instance.use(target, "TNT Spawn", 700, false, false)) { World world = dropsite.getWorld(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMilkACow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMilkACow.java index f72fcdf2b..5d35f83fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMilkACow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMilkACow.java @@ -8,6 +8,10 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguiseVillager; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.mineware.Challenge; import nautilus.game.arcade.game.games.mineware.MineWare; @@ -33,6 +37,7 @@ public class ChallengeMilkACow extends Challenge private Villager _villager; private HashMap> _milked = new HashMap>(); private HashMap _score = new HashMap(); + private HashMap _cowIndicator = new HashMap(); public ChallengeMilkACow(MineWare host) { @@ -44,9 +49,11 @@ public class ChallengeMilkACow extends Challenge { for (Entity cow : _milked.keySet()) { + Hologram holo = _cowIndicator.get(cow); + holo.stop(); + cow.remove(); } - _villager.remove(); } @@ -72,8 +79,6 @@ public class ChallengeMilkACow extends Challenge @Override public void setupPlayers() { - setBorder(-16, 16, 0, 10, -16, 16); - for (Player player : Host.GetPlayers(true)) { DisguiseVillager disguise = new DisguiseVillager(player); @@ -135,7 +140,7 @@ public class ChallengeMilkACow extends Challenge String[] names = new String[] { - "Tom", "Steve", "John", "Harry", "Andrew", "Daniel", "Jorge", "Jim" + "Tom", "Steve", "John", "Harry", "Andrew", "Daniel", "Bobbae", "Jim" }; if (UtilMath.r(5) == 0) @@ -155,11 +160,42 @@ public class ChallengeMilkACow extends Challenge cow.setCustomNameVisible(true); _milked.put(cow, new ArrayList()); + _cowIndicator.put(cow, new Hologram(Host.Manager.getHologramManager(), cow.getLocation().clone().add(0, 2.5, 0), C.cRed + "Already Milked!")); + + Hologram holo = _cowIndicator.get(cow); + holo.setHologramTarget(HologramTarget.WHITELIST); + holo.setFollowEntity(cow); + holo.start(); } Host.CreatureAllowOverride = false; } + @EventHandler + public void cowIndicator(UpdateEvent event) + { + if(!Host.IsLive()) + { + return; + } + if(event.getType() != UpdateType.SEC) + { + return; + } + + for(Entity entCow: _milked.keySet()) + { + for(String playerName: _milked.get(entCow)) + { + Hologram holo = _cowIndicator.get(entCow); + if(!holo.containsPlayer(playerName)) + { + holo.addPlayer(playerName); + } + } + } + } + @EventHandler public void onEntityInteract(PlayerInteractEntityEvent event) { @@ -190,6 +226,7 @@ public class ChallengeMilkACow extends Challenge { p.setItemInHand(new ItemStack(Material.MILK_BUCKET)); _milked.get(ent).add(p.getName()); + Cow cow = (Cow) ent; } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java index 627c7d813..cdd290756 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java @@ -244,7 +244,7 @@ public class ChallengeMinecartDance extends Challenge } } - for(int i = 0; i < getCurrentyAlive(true).size() - 1; i++) + for(int i = 0; i < getCurrentyAlive(true).size()*0.66; 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); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeReverseTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeReverseTag.java index 7dabf6dc0..de0a59fcf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeReverseTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeReverseTag.java @@ -207,24 +207,13 @@ public class ChallengeReverseTag extends Challenge } } - private void removeTagged(final Player player) + private void removeTagged(Player player) { if(_tagged.contains(player.getName())) { UtilPlayer.message(player, C.cYellow + C.Bold + "You are " + C.cRed + "NO LONGER" + C.cYellow + " tagged!"); player.getInventory().setHelmet(new ItemStack(Material.AIR)); _tagged.remove(player.getName()); - _cooldowned.add(player.getName()); - - new BukkitRunnable() - { - - @Override - public void run() - { - _cooldowned.remove(player.getName()); - } - }.runTaskLater(Host.Manager.getPlugin(), 20*_cooldown); if(_nonTaggedPlayers.contains(player)) { @@ -238,13 +227,25 @@ public class ChallengeReverseTag extends Challenge } } - private void addTagged(Player player) + private void addTagged(final Player player) { if(!_tagged.contains(player.getName())) { UtilPlayer.message(player, C.cYellow + C.Bold + "You are " + C.cGreen + "NOW" + C.cYellow + " tagged! Keep it up!"); player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(35, (byte) 5)); _tagged.add(player.getName()); + _cooldowned.add(player.getName()); + + new BukkitRunnable() + { + + @Override + public void run() + { + _cooldowned.remove(player.getName()); + } + }.runTaskLater(Host.Manager.getPlugin(), 20*_cooldown); + for(int i = 0; i <= 8; i++) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaveCrush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaveCrush.java index 1a2d9d1de..d96ba40b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaveCrush.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaveCrush.java @@ -257,7 +257,7 @@ public class ChallengeWaveCrush extends Challenge FallingBlock fBlock = Host.WorldData.World.spawnFallingBlock(theBlock.getLocation().clone().add(0, 1, 0), theBlock.getType(), theBlock.getData()); - Host.Manager.GetProjectile().AddThrow(fBlock, null, Host, -1, true, false, true, true, 0.4f); + Host.Manager.GetProjectile().AddThrow(fBlock, null, Host, -1, true, false, true, true, 0.7f); fBlock.setVelocity(new Vector(0, 10, 0).normalize()); theBlock.setType(Material.AIR); theBlock = Host.WorldData.World.getBlockAt(theBlock.getX() - 1, theBlock.getY(), theBlock.getZ());