From c8fc792fdd0aa6b4c90e80ce513da6bfca90f9c3 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 30 Nov 2013 20:40:09 +1100 Subject: [PATCH] UHC prep for s4 Draw updates --- .../game/arcade/game/games/draw/Draw.java | 54 ++- .../arcade/game/games/hideseek/HideSeek.java | 2 +- .../game/arcade/game/games/uhc/UHC.java | 319 ++++++++++++------ .../game/arcade/managers/GameManager.java | 4 +- 4 files changed, 271 insertions(+), 108 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 04e9f4be9..2aceb55ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.draw; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import org.bukkit.Bukkit; @@ -56,6 +57,8 @@ public class Draw extends SoloGame //Brush private byte _brushColor = 15; private Location _brushPrevious = null; + + private boolean _lockDrawer = true; //Round private int _roundCount = 0; @@ -71,7 +74,8 @@ public class Draw extends SoloGame private Collection _textBlocks = null; private String[] _words; - + private HashSet _usedWords = new HashSet(); + public Draw(ArcadeManager manager) { super(manager, GameType.Draw, @@ -198,7 +202,7 @@ public class Draw extends SoloGame if (_round != null && (_round.IsDone() || _drawers.GetPlayers(true).isEmpty() || _round.AllGuessed(_guessers.GetPlayers(true)))) { Announce(C.cGold + C.Bold + "Round " + (_roundCount+1) + " Ended: " + C.cYellow + C.Bold + "The word was " + _round.Word + "!"); - _textBlocks = UtilText.MakeText(_round.Word, _textLocation, BlockFace.NORTH, 159, (byte)15, TextAlign.CENTER); + _textBlocks = UtilText.MakeText(_round.Word, _textLocation, BlockFace.WEST, 159, (byte)15, TextAlign.CENTER); _roundTime = System.currentTimeMillis(); _round = null; @@ -212,6 +216,7 @@ public class Draw extends SoloGame player.setAllowFlight(false); player.setFlying(false); + player.setFlySpeed(0.1f); player.teleport(_guessers.GetSpawn()); } @@ -230,16 +235,23 @@ public class Draw extends SoloGame _guessers.RemovePlayer(drawer); _drawers.AddPlayer(drawer); + //Get Word + String word = _words[UtilMath.r(_words.length)]; + while (!_usedWords.add(word)) + word = _words[UtilMath.r(_words.length)]; + //Create Round - _round = new DrawRound(this, drawer, _words[UtilMath.r(_words.length)]); + _round = new DrawRound(this, drawer, word); //Prep Drawer drawer.teleport(_drawerLocation); drawer.setAllowFlight(true); drawer.setFlying(true); + drawer.setFlySpeed(0.4f); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Paint Brush")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Thin Paint Brush")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Thick Paint Brush")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, "Clear Canvas")); @@ -328,6 +340,9 @@ public class Draw extends SoloGame if (!IsLive()) return; + if (!_lockDrawer) + return; + if (!_drawers.HasPlayer(event.getPlayer())) return; @@ -372,6 +387,18 @@ public class Draw extends SoloGame //Color block.setData(_brushColor); + //Thick Brush + if (UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) + { + for (Block other : UtilBlock.getSurrounding(block, false)) + { + if (!_canvas.contains(other)) + continue; + + other.setData(_brushColor); + } + } + //Join Dots if (_brushPrevious != null) { @@ -385,15 +412,30 @@ public class Draw extends SoloGame continue; fixBlock.setData(_brushColor); + + //Thick Brush + if (UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) + { + for (Block other : UtilBlock.getSurrounding(fixBlock, false)) + { + if (!_canvas.contains(other)) + continue; + + other.setData(_brushColor); + } + } } } for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.FIZZ, 0.2f, 2f); + _lockDrawer = false; + _brushPrevious = block.getLocation().add(0.5, 0.5, 0.5); } } + @EventHandler public void PaintReset(PlayerInteractEvent event) @@ -416,7 +458,9 @@ public class Draw extends SoloGame Reset(); + //Restore _brushColor = color; + _lockDrawer = false; for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.EXPLODE, 0.5f, 1.5f); @@ -506,6 +550,8 @@ public class Draw extends SoloGame _textBlocks.clear(); _textBlocks = null; } + + _lockDrawer = true; } public void AddScore(Player player, double amount) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index 8378b4b96..694f1ef77 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -261,7 +261,7 @@ public class HideSeek extends TeamGame player.getInventory().setItem(28, ItemStackFactory.Instance.CreateStack(Material.ARROW)); //Meower - player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.SUGAR, (byte)0, 1, C.cYellow + C.Bold + "Meow" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "+0.5 Gems")); + player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.SUGAR, (byte)0, 1, C.cYellow + C.Bold + "Meow" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "+0.25 Gems")); //Firework ItemStack firework = ItemStackFactory.Instance.CreateStack(Material.FIREWORK, (byte)0, 5, C.cYellow + C.Bold + "Firework" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "+2 Gems"); 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 da8647343..b12f191ad 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 @@ -1,11 +1,14 @@ package nautilus.game.arcade.game.games.uhc; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import org.bukkit.ChatColor; import org.bukkit.Chunk; +import org.bukkit.Difficulty; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -15,7 +18,9 @@ import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.CaveSpider; +import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Ghast; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; @@ -25,6 +30,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -82,9 +88,6 @@ import nautilus.game.arcade.managers.GameLobbyManager; public class UHC extends TeamGame { - //private Objective _listHealth; - private Map _map; - private NautHashMap _deathTime = new NautHashMap(); private NautHashMap _rejoinTime = new NautHashMap(); @@ -96,6 +99,13 @@ public class UHC extends TeamGame private long _lastMinute = System.currentTimeMillis(); private boolean _soloGame = false; + private boolean _timerStarted = false; + private boolean _ended = false; + + private ArrayList _portalBlock = null; + private ArrayList _portal = null; + private boolean _portalCreated = false; + private GameTeam _lastDragonDamager = null; public UHC(ArcadeManager manager) { @@ -139,19 +149,13 @@ public class UHC extends TeamGame this.DeathMessages = false; this.SoupEnabled = false; - - this.IdleKick = true; - this.AutoStart = true; - this.CompassEnabled = true; + + this.IdleKick = false; + this.AutoStart = false; + this.CompassEnabled = false; CraftRecipes(); - ///_listHealth = this.GetScoreboard().registerNewObjective("Health", "health"); - //_listHealth.setDisplaySlot(DisplaySlot.PLAYER_LIST); - - _map = new Map(manager.GetPlugin()); - _map.SetDefaultUrl("http://chivebox.com/img/mc/uhc.png"); - //Disable Custom Mob Drops (and EXP Disable) Manager.GetCreature().SetDisableCustomDrops(true); @@ -159,10 +163,28 @@ public class UHC extends TeamGame Manager.GetAntiStack().SetEnabled(false); } + @Override + public void ParseData() + { + _portalBlock = WorldData.GetDataLocs("YELLOW"); + _portal = WorldData.GetDataLocs("BLACK"); + + //Set Portal Blocks + for (int i=0 ; i<_portalBlock.size() ; i++) + { + if (i<6) + _portalBlock.get(i).getBlock().setTypeIdAndData(Material.ENDER_PORTAL_FRAME.getId(), (byte)4, true); + else + _portalBlock.get(i).getBlock().setTypeIdAndData(Material.ENDER_PORTAL_FRAME.getId(), (byte)0, true); + } + } @EventHandler public void TimeUpdate(UpdateEvent event) { + if (!_timerStarted) + return; + if (!IsLive()) return; @@ -386,7 +408,7 @@ public class UHC extends TeamGame else if (team.GetColor() == ChatColor.AQUA) team.SetName("Aqua"); else if (team.GetColor() == ChatColor.LIGHT_PURPLE) team.SetName("Purple"); else if (team.GetColor() == ChatColor.WHITE) team.SetName("White"); - } + } } @EventHandler @@ -577,9 +599,7 @@ public class UHC extends TeamGame public void PlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - - - + GameTeam team = GetTeam(player); if (team == null) return; @@ -593,7 +613,7 @@ public class UHC extends TeamGame if (player.isDead()) return; - + /* XXX if (true) { //Announcement @@ -602,6 +622,7 @@ public class UHC extends TeamGame player.damage(5000); return; } + */ if (_combatTime.containsKey(player.getName()) && !UtilTime.elapsed(_combatTime.get(player.getName()), 15000)) { @@ -618,7 +639,7 @@ public class UHC extends TeamGame GetLocationStore().put(player.getName(), player.getLocation()); //Announcement - Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! 10 minutes to reconnect."); + Announce(team.GetColor() + C.Bold + player.getName() + " has disconnected! 30 minutes to reconnect."); } @EventHandler @@ -685,6 +706,42 @@ public class UHC extends TeamGame } } + @EventHandler + public void CreatureCull(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.SLOW) + return; + + HashMap> ents = new HashMap>(); + + for (Entity ent : WorldData.World.getEntities()) + { + if (!ents.containsKey(ent.getType())) + ents.put(ent.getType(), new ArrayList()); + + ents.get(ent.getType()).add(ent); + } + + for (EntityType type : ents.keySet()) + { + ArrayList entList = ents.get(type); + int count = 0; + + while (entList.size() > 300) + { + Entity ent = entList.remove(UtilMath.r(entList.size())); + ent.remove(); + count++; + } + + if (count > 0) + System.out.println("Removed " + count + " " + type); + } + } + @EventHandler public void PlayerRejoinExpire(UpdateEvent event) { @@ -697,7 +754,7 @@ public class UHC extends TeamGame { String name = rejoinIterator.next(); - if (!UtilTime.elapsed(_rejoinTime.get(name), 600000)) + if (!UtilTime.elapsed(_rejoinTime.get(name), 1800000)) continue; rejoinIterator.remove(); @@ -705,7 +762,7 @@ public class UHC extends TeamGame //Get Team (By Name) GameTeam team = _rejoinTeam.remove(name); if (team != null) - Announce(team.GetColor() + C.Bold + name + " did not reconnent in time!"); + Announce(team.GetColor() + C.Bold + name + " did not reconnect in time!"); } } @@ -838,7 +895,7 @@ public class UHC extends TeamGame if (event.getRegainReason() == RegainReason.SATIATED) event.setCancelled(true); } - + @EventHandler public void HeadPlaceCancel(BlockPlaceEvent event) { @@ -886,6 +943,14 @@ public class UHC extends TeamGame if (event.getMessage().startsWith("/kill")) event.setCancelled(true); + if (event.getMessage().startsWith("/uhc timer start")) + { + event.setCancelled(true); + _timerStarted = true; + + Announce(event.getPlayer().getName() + " started the 20 minute timer!"); + } + if (event.getMessage().startsWith("/uhc game start")) { this.SetCountdownForce(true); @@ -926,8 +991,6 @@ public class UHC extends TeamGame Announce(event.getPlayer().getName() + " set time to Day and Night!"); } - - } @EventHandler @@ -1027,6 +1090,18 @@ 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 SpecialDamage(EntityDamageEvent event) { @@ -1065,38 +1140,6 @@ public class UHC extends TeamGame } } } - - @EventHandler - public void SpiderPoison(EntityDamageEvent event) - { - if (event.isCancelled()) - return; - - if (!(event.getEntity() instanceof LivingEntity)) - return; - - //Damager - LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true); - if (damagerEnt != null) - { - if (damagerEnt instanceof CaveSpider) - { - Manager.GetCondition().Factory().Poison("Cave Spider", (LivingEntity)event.getEntity(), damagerEnt, 7, 0, false, false, false); - } - } - } - - @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) @@ -1116,30 +1159,6 @@ public class UHC extends TeamGame } } - boolean hungerHurt = false; - @EventHandler - public void HungerHurt(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!InProgress()) - return; - - hungerHurt = !hungerHurt; - - if (!hungerHurt) - return; - - for (Player player : GetPlayers(true)) - { - if (player.getHealth() <= 10 && player.getFoodLevel() == 0) - { - player.damage(1); - } - } - } - @EventHandler public void TabHealth(UpdateEvent event) { @@ -1176,7 +1195,7 @@ public class UHC extends TeamGame String health = " - " + col; if (_soloGame) health = " - "; - + int hp = (int)(player.getHealth() + 0.9999999999); if (hp % 2 == 0) @@ -1209,7 +1228,7 @@ public class UHC extends TeamGame if (_soloGame) return (team.GetPlayers(true).isEmpty()); - return (team.GetPlayers(true).size() < 3); + return (team.GetPlayers(true).size() < 4); } @Override @@ -1299,24 +1318,36 @@ public class UHC extends TeamGame return true; } + @Override + public void Announce(String message) + { + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.message(player, message); + } + + System.out.println("[Announcement] " + message); + } + @Override public void EndCheck() { if (!IsLive()) return; + if (_ended) + return; + 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); + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); //Offline Player Team for (GameTeam team : _rejoinTeam.values()) - if (team.GetColor() != ChatColor.DARK_GRAY) - teamsAlive.add(team); + teamsAlive.add(team); if (teamsAlive.size() <= 1) { @@ -1324,21 +1355,107 @@ public class UHC extends TeamGame if (teamsAlive.size() > 0) AnnounceEnd(teamsAlive.get(0)); - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - AddGems(player, 10, "Winning Team", false); - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false); - } - //End - SetState(GameState.End); + _ended = true; + //SetState(GameState.End); } } + + @EventHandler + public void DragonDamage(EntityDamageEvent event) + { + if (!IsLive()) + return; + + if (_ended) + return; + + if (!(event.getEntity() instanceof EnderDragon)) + return; + + //Damager + LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true); + if (damagerEnt != null) + { + if (damagerEnt instanceof Player) + { + Player damager = (Player)damagerEnt; + + GameTeam team = GetTeam(damager); + + if (team != null && team.GetColor() == ChatColor.DARK_GRAY) + { + if (_lastDragonDamager == null || !_lastDragonDamager.equals(team)) + { + _lastDragonDamager = team; + Announce(team.GetColor() + C.Bold + team.GetName() + " are attacking the Ender Dragon!"); + } + } + } + } + } + + @EventHandler + public void DragonDeath(EntityDeathEvent event) + { + if (!IsLive()) + return; + + if (_ended) + return; + + if (_lastDragonDamager == null) + return; + + AnnounceEnd(_lastDragonDamager); + _ended = true; + } + + @EventHandler + public void PortalCreate(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.SEC) + return; + + boolean complete = true; + for (Location loc : _portalBlock) + { + if (loc.getBlock().getType() != Material.ENDER_PORTAL_FRAME) + loc.getBlock().setType(Material.ENDER_PORTAL_FRAME); + + if (loc.getBlock().getData() < 4) + complete = false; + } + + if (complete) + { + if (!_portalCreated) + { + for (Player player : UtilServer.getPlayers()) + player.playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 1f); + + Announce(ChatColor.WHITE + C.Bold + "The portal to The End has been opened!"); + } + + _portalCreated = true; + + for (Location loc : _portal) + loc.getBlock().setTypeIdAndData(Material.ENDER_PORTAL.getId(), (byte)0, false); + } + else + { + for (Location loc : _portal) + loc.getBlock().setType(Material.AIR); + } + } + + @EventHandler + public void PortalBreak(BlockBreakEvent event) + { + if (event.getBlock().getType() == Material.ENDER_PORTAL_FRAME) + event.setCancelled(true); + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 9757b1f8d..2789ea081 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -292,8 +292,8 @@ public class GameManager implements Listener if (game.GetTeamList().size() == 2) color = ChatColor.GREEN; if (game.GetTeamList().size() == 3) color = ChatColor.AQUA; if (game.GetTeamList().size() == 4) color = ChatColor.GOLD; - if (game.GetTeamList().size() == 5) color = ChatColor.DARK_BLUE; - if (game.GetTeamList().size() == 6) color = ChatColor.LIGHT_PURPLE; + if (game.GetTeamList().size() == 5) color = ChatColor.LIGHT_PURPLE; + if (game.GetTeamList().size() == 6) color = ChatColor.DARK_BLUE; if (game.GetTeamList().size() == 7) color = ChatColor.WHITE; if (game.GetTeamList().size() == 8) color = ChatColor.BLUE; if (game.GetTeamList().size() == 9) color = ChatColor.DARK_GREEN;