From ed804e333638ec27523b6b0162c967d5e1b1bcae Mon Sep 17 00:00:00 2001 From: Chiss Date: Wed, 9 Oct 2013 21:50:39 +1100 Subject: [PATCH] Dragon escape update --- .../nautilus/game/arcade/game/GameTeam.java | 22 -- .../game/games/dragonescape/DragonEscape.java | 16 +- .../games/dragonescape/DragonEscapeData.java | 7 +- .../games/dragonescape/kits/KitDisruptor.java | 4 +- .../games/dragonescape/kits/KitWarper.java | 2 +- .../game/arcade/game/games/uhc/UHC.java | 266 ++++-------------- .../game/arcade/managers/GameChatManager.java | 15 +- 7 files changed, 81 insertions(+), 251 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index e49a2960d..de801ece6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -288,28 +288,6 @@ public class GameTeam _spawnDistance = value; } - public void ReplaceReference(Player player) - { - Iterator playerIterator = _players.keySet().iterator(); - PlayerState state = null; - - while (playerIterator.hasNext()) - { - Player cur = playerIterator.next(); - - if (!cur.getName().equals(player.getName())) - continue; - - state = _players.get(cur); - playerIterator.remove(); - } - - if (state != null) - { - _players.put(player, state); - } - } - public void SetVisible(boolean b) { _visible = b; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 4a2404677..2a7d04113 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -58,8 +58,8 @@ public class DragonEscape extends SoloGame new Kit[] { new KitLeaper(manager), + new KitDisruptor(manager), new KitWarper(manager), - new KitDisruptor(manager) }, new String[] @@ -100,7 +100,7 @@ public class DragonEscape extends SoloGame } //Ignore Close - if (bestDist < 6 && WorldData.GetDataLocs("BLACK").size() > 1) + if (bestDist < 3 && WorldData.GetDataLocs("BLACK").size() > 1) { System.out.println("Ignoring Node"); WorldData.GetDataLocs("BLACK").remove(best); @@ -202,7 +202,7 @@ public class DragonEscape extends SoloGame } //Shortcut - if (postNode - preNode >= 2) + if (postNode - preNode >= 3) { if (!_warpTime.containsKey(score.Player) || UtilTime.elapsed(_warpTime.get(score.Player), 1000)) { @@ -215,10 +215,14 @@ public class DragonEscape extends SoloGame //Finish if (GetWaypointIndex(player.getLocation()) == _waypoints.size() - 1) { - _winner = player; - this.SetCustomWinLine(player.getName() + " reached the end of the course!"); + //Only if NEAR end. + if (UtilMath.offset(player.getLocation(), _waypoints.get(_waypoints.size()-1)) < 3) + { + _winner = player; + this.SetCustomWinLine(player.getName() + " reached the end of the course!"); - return true; + return true; + } } score.Score = playerScore; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java index 02bb83103..83b55c7d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscapeData.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.dragonescape; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilWorld; import org.bukkit.Location; import org.bukkit.entity.EnderDragon; @@ -39,9 +40,9 @@ public class DragonEscapeData Turn(); //Speed - double speed = 0.2; + double speed = 0.20; - speed += (System.currentTimeMillis() - Host.GetStateTime())/1000d * 0.001; + //speed += (System.currentTimeMillis() - Host.GetStateTime())/1000d * 0.001; //Speed Distance Boost /* @@ -65,6 +66,8 @@ public class DragonEscapeData Location.setYaw(180 + UtilAlg.GetYaw(Velocity)); Dragon.teleport(Location); + + System.out.println("Flying towards: " + UtilWorld.locToStrClean(Target)); } private void Turn() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitDisruptor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitDisruptor.java index 29e5396ea..fe086ea67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitDisruptor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitDisruptor.java @@ -17,7 +17,7 @@ public class KitDisruptor extends Kit { public KitDisruptor(ArcadeManager manager) { - super(manager, "Disruptor", KitAvailability.Blue, + super(manager, "Disruptor", KitAvailability.Green, new String[] { @@ -26,7 +26,7 @@ public class KitDisruptor extends Kit new Perk[] { - new PerkLeap("Leap", 1, 1, 8000, 2), + new PerkLeap("Leap", 1, 1, 8000, 3), new PerkDisruptor(8, 2) }, EntityType.ZOMBIE, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitWarper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitWarper.java index 54b75e9a6..818f153da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitWarper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/kits/KitWarper.java @@ -16,7 +16,7 @@ public class KitWarper extends Kit { public KitWarper(ArcadeManager manager) { - super(manager, "Warper", KitAvailability.Green, + super(manager, "Warper", KitAvailability.Blue, new String[] { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index f5e6774d2..8d844044b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -17,6 +17,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Ghast; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.EventHandler; @@ -31,6 +32,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerLoginEvent; @@ -85,12 +87,13 @@ public class UHC extends TeamGame private NautHashMap _deathTime = new NautHashMap(); private NautHashMap _rejoinTime = new NautHashMap(); - + private NautHashMap _rejoinTeam = new NautHashMap(); + private NautHashMap _combatTime = new NautHashMap(); private int _gameMinutes = 0; private long _lastMinute = System.currentTimeMillis(); - + private boolean _soloGame = false; public UHC(ArcadeManager manager) @@ -110,9 +113,9 @@ public class UHC extends TeamGame }); this.DamageTeamSelf = true; - + this.DeathDropItems = true; - + this.ItemDrop = true; this.ItemPickup = true; @@ -222,13 +225,10 @@ public class UHC extends TeamGame WorldData.World.setTime(2000); - //Kill Mobs + //Kill Evil Mobs for (Entity ent : WorldData.World.getEntities()) { - if (!(ent instanceof LivingEntity)) - continue; - - if (ent instanceof Player) + if (!(ent instanceof Monster)) continue; ent.remove(); @@ -245,25 +245,6 @@ public class UHC extends TeamGame } } - @EventHandler - public void KillMobs(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - //Kill Mobs - for (Entity ent : WorldData.World.getEntities()) - { - if (!(ent instanceof LivingEntity)) - continue; - - if (ent instanceof Player) - continue; - - ent.remove(); - } - } - @EventHandler public void WorldBoundaryCheck(PlayerMoveEvent event) { @@ -301,7 +282,7 @@ public class UHC extends TeamGame this.WorldData.MaxX = 1250; this.WorldData.MinZ = -1250; this.WorldData.MaxZ = 1250; - + for (int x=-79 ; x<=78 ; x++) { WorldBoundaryRed(WorldData.World.getChunkAt(x, 78)); @@ -320,7 +301,7 @@ public class UHC extends TeamGame this.WorldData.MaxX = 1000; this.WorldData.MinZ = -1000; this.WorldData.MaxZ = 1000; - + for (int x=-63 ; x<=62 ; x++) { WorldBoundaryRed(WorldData.World.getChunkAt(x, 62)); @@ -385,15 +366,15 @@ public class UHC extends TeamGame { team.SetColor(ChatColor.WHITE); team.SetName(i+""); - + i++; } - + _soloGame = true; - + return; } - + for (GameTeam team : GetTeamList()) { if (team.GetColor() == ChatColor.RED) team.SetName("Red"); @@ -425,7 +406,7 @@ public class UHC extends TeamGame double dist = 250; if (_soloGame) dist = 200; - + //Ensure 250 Blocks between Teams while (true) { @@ -599,11 +580,13 @@ public class UHC extends TeamGame GameTeam team = GetTeam(player); if (team == null) return; - if (team.GetColor() == ChatColor.DARK_GRAY) - { - team.RemovePlayer(player); + if (!team.IsAlive(player)) + return; + + team.RemovePlayer(player); + + if (team.GetColor() == ChatColor.DARK_GRAY) return; - } if (player.isDead()) return; @@ -614,17 +597,12 @@ public class UHC extends TeamGame Announce(team.GetColor() + C.Bold + player.getName() + " was killed for disconnecting during combat."); player.damage(5000); - team.SetPlayerState(player, PlayerState.OUT); - return; - } - - if (!team.IsAlive(player)) - { - team.RemovePlayer(player); return; } + //Store _rejoinTime.put(player.getName(), System.currentTimeMillis()); + _rejoinTeam.put(player.getName(), team); GetLocationStore().put(player.getName(), player.getLocation()); //Announcement @@ -713,55 +691,32 @@ public class UHC extends TeamGame rejoinIterator.remove(); //Get Team (By Name) - GameTeam team = GetTeam(name, false); + GameTeam team = _rejoinTeam.remove(name); if (team != null) - { Announce(team.GetColor() + C.Bold + name + " did not reconnent in time!"); - team.SetPlayerState(team.GetPlayer(name), PlayerState.OUT); - } } } - @EventHandler(priority = EventPriority.LOW) + @EventHandler(priority = EventPriority.LOWEST) public void PlayerLoginAllow(PlayerLoginEvent event) { if (!InProgress()) return; - //Get Team and OldPlayer - GameTeam team = null; - Player oldPlayer = null; - for (GameTeam curTeam : GetTeamList()) + //Rejoined + GameTeam team = _rejoinTeam.remove(event.getPlayer().getName()); + if (team != null && _rejoinTime.remove(event.getPlayer().getName()) != null) { - for (Player curPlayer : curTeam.GetPlayers(true)) - { - if (curPlayer.getName().equals(event.getPlayer().getName())) - { - oldPlayer = curPlayer; - team = curTeam; - break; - } - } - - if (oldPlayer != null) - break; - } - - if (team != null && oldPlayer != null) - { - team.ReplaceReference(event.getPlayer()); - - if (_rejoinTime.remove(oldPlayer.getName()) != null) - { - //Announcement - Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!"); - return; - } + team.AddPlayer(event.getPlayer()); + Announce(team.GetColor() + C.Bold + event.getPlayer().getName() + " has reconnected!"); + return; } + //Owner Bypass if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.OWNER)) return; + //Disallow event.setResult(PlayerLoginEvent.Result.KICK_OTHER); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.YELLOW + "You cannot join this UHC."); } @@ -871,6 +826,13 @@ public class UHC extends TeamGame if (event.getRegainReason() == RegainReason.SATIATED) event.setCancelled(true); } + + @EventHandler + public void HeadPlaceCancel(BlockPlaceEvent event) + { + if (event.getItemInHand().getType() == Material.SKULL || event.getItemInHand().getType() == Material.SKULL_ITEM) + event.setCancelled(true); + } @EventHandler public void ConsumeHeadApple(PlayerItemConsumeEvent event) @@ -1091,19 +1053,19 @@ public class UHC extends TeamGame } } } - + @EventHandler(priority = EventPriority.LOWEST) public void clearCreeperExplode(EntityExplodeEvent event) { event.setCancelled(true); } - + @EventHandler(priority = EventPriority.HIGHEST) public void clearCreeperExplodeReenable(EntityExplodeEvent event) { event.setCancelled(false); } - + @EventHandler public void SpecialCloak(UpdateEvent event) { @@ -1122,23 +1084,6 @@ public class UHC extends TeamGame } } - /* - @EventHandler - public void TabHealth(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (!InProgress()) - return; - - for (Player player : GetPlayers(true)) - { - _listHealth.getScore(player).setScore((int)player.getHealth()); - } - } - */ - @EventHandler public void HungerHurt(UpdateEvent event) { @@ -1218,43 +1163,12 @@ public class UHC extends TeamGame } } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - /* - for (GameTeam team : this.GetTeamList()) - { - String name = team.GetColor() + team.GetName(); - if (name.length() > 16) - name = name.substring(0, 16); - - int health = 0; - for (Player player : team.GetPlayers(true)) - { - health += (int)player.getHealth(); - } - - if (health <= 0) - { - GetScoreboard().resetScores(Bukkit.getOfflinePlayer(name)); - continue; - } - - Score score = GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(name)); - score.setScore(health); - } - */ - } - @Override public boolean CanJoinTeam(GameTeam team) { if (_soloGame) return (team.GetPlayers(true).isEmpty()); - + return (team.GetPlayers(true).size() < 3); } @@ -1298,12 +1212,12 @@ public class UHC extends TeamGame UtilPlayer.message(player, C.cYellow+ C.Bold + this.GetName()); UtilPlayer.message(player, ""); UtilPlayer.message(player, ""); - + if (team != null) { WinnerTeam = team; Winner = team.GetName() + " Team"; - + if (_soloGame) UtilPlayer.message(player, team.GetColor() + C.Bold + team.GetPlayers(false).get(0).getName() + " won the match!"); else @@ -1353,22 +1267,16 @@ public class UHC extends TeamGame ArrayList teamsAlive = new ArrayList(); + //Online Teams for (GameTeam team : this.GetTeamList()) if (team.GetColor() != ChatColor.DARK_GRAY) if (team.GetPlayers(true).size() > 0) teamsAlive.add(team); - /* - { - for (Player player : team.GetPlayers(true)) - { - if (player.isOnline()) - { - teamsAlive.add(team); - break; - } - } - } - */ + + //Offline Player Team + for (GameTeam team : _rejoinTeam.values()) + if (team.GetColor() != ChatColor.DARK_GRAY) + teamsAlive.add(team); if (teamsAlive.size() <= 1) { @@ -1393,72 +1301,4 @@ public class UHC extends TeamGame SetState(GameState.End); } } - - /* - @EventHandler - public void PlayersDisplay(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOW) - return; - - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(false)) - { - Announce(team.GetColor() + player.getName() + ": " + (IsAlive(player))); - } - } - } - - private NautHashMap _portalTime = new NautHashMap(); - private NautHashMap _portalTick = new NautHashMap(); - - @EventHandler - public void NetherPortal(EntityPortalEnterEvent event) - { - _portalTime.put(event.getEntity(), System.currentTimeMillis()); - - int ticks = 1; - if (_portalTick.containsKey(event.getEntity())) - ticks += _portalTick.get(event.getEntity()); - - _portalTick.put(event.getEntity(), ticks); - } - - @EventHandler - public void NetherUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - return; - - Iterator netherIterator = _portalTime.keySet().iterator(); - - while (netherIterator.hasNext()) - { - Entity ent = netherIterator.next(); - - //Left Portal - if (UtilTime.elapsed(_portalTime.get(ent), 1000)) - { - netherIterator.remove(); - _portalTick.remove(ent); - continue; - } - - int ticks = _portalTick.get(ent); - - if (ticks < 80) - continue; - - netherIterator.remove(); - _portalTick.remove(ent); - - Vector vec = ent.getLocation().toVector().multiply(1d/16d); - Block nether = vec.toLocation(UtilWorld.getWorldType(Environment.NETHER)).getBlock(); - - - //ent.teleport(nether, TeleportCause.NETHER_PORTAL); - } - } - */ } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index 0cdd78697..119e942ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -6,6 +6,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; @@ -19,14 +20,14 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; public class GameChatManager implements Listener { ArcadeManager Manager; - + public GameChatManager(ArcadeManager manager) { Manager = manager; - + Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin()); } - + @EventHandler public void MeCancel(PlayerCommandPreprocessEvent event) { @@ -42,7 +43,7 @@ public class GameChatManager implements Listener { if (event.isCancelled()) return; - + Player sender = event.getPlayer(); //Dead Prefix @@ -89,7 +90,11 @@ public class GameChatManager implements Listener else { globalMessage = true; - event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); + + if (Manager.GetGame().GetType() == GameType.UHC && team.GetColor() == ChatColor.WHITE) + event.setFormat(dead + rankStr + ChatColor.YELLOW + "%1$s " + C.cWhite + "%2$s"); + else + event.setFormat(dead + rankStr + team.GetColor() + "%1$s " + C.cWhite + "%2$s"); } }