From b986cf968e10b7ee71f44bd6c89fef2c7fcae1f3 Mon Sep 17 00:00:00 2001 From: Morten Date: Sat, 18 Jul 2015 15:10:03 +0200 Subject: [PATCH] Added new kits, Changed Compass feature, Fixed a lot of bugs --- .../arcade/game/games/wither/WitherGame.java | 273 +++++++++++++++--- .../game/games/wither/kit/KitHumanArcher.java | 34 +-- .../games/wither/kit/KitHumanBuilder.java | 65 ----- .../games/wither/kit/KitWitherMinion.java | 99 ++++--- 4 files changed, 303 insertions(+), 168 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index bbe50ac57..539bcfe83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -1,40 +1,28 @@ package nautilus.game.arcade.game.games.wither; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.EntityEffect; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.ThrownPotion; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.data.BlockData; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -43,13 +31,48 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.paintball.PlayerCopy; -import nautilus.game.arcade.game.games.wither.kit.*; +import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent; +import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher; +import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic; +import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor; +import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.NullKit; import nautilus.game.arcade.kit.perks.data.IBlockRestorer; +import nautilus.game.arcade.stats.WitherAssaultReviveTracker; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; public class WitherGame extends TeamGame implements IBlockRestorer { @@ -59,6 +82,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer private double _witherFactor = 2.5; private int _yLimit = 0; + private int _maxY; private long _gameTime = 300000; @@ -68,6 +92,8 @@ public class WitherGame extends TeamGame implements IBlockRestorer // private HashMap _lives = new HashMap(); private HashSet _blocks = new HashSet(); + + private ArrayList _locationsOfBlocks = new ArrayList(); public WitherGame(ArcadeManager manager) { @@ -75,24 +101,22 @@ public class WitherGame extends TeamGame implements IBlockRestorer new Kit[] { - new KitHumanArcher(manager), new NullKit(manager), - new NullKit(manager), new NullKit(manager), + new KitHumanArcher(manager), + new KitHumanMedic(manager), + new KitHumanEditor(manager), + new NullKit(manager), new KitWitherMinion(manager), }, new String[] { - C.cGreen + "Humans" + C.cWhite - + " Run and hide from the Withers", + C.cGreen + "Humans" + C.cWhite + " Run and hide from the Withers", C.cGreen + "Humans" + C.cWhite + " Revive your dead allies!", - C.cGreen + "Humans" + C.cWhite - + " Win by surviving for 5 minutes", + C.cGreen + "Humans" + C.cWhite + " Win by surviving for 5 minutes", " ", - C.cRed + "Withers" + C.cWhite - + " Moves very slowly when near ground", - C.cRed + "Withers" + C.cWhite - + " Kill all the Humans within 5 Minutes", + C.cRed + "Withers" + C.cWhite + " Moves very slowly when near ground", + C.cRed + "Withers" + C.cWhite + " Kill all the Humans within 5 Minutes", }); this.DeathOut = true; @@ -101,9 +125,12 @@ public class WitherGame extends TeamGame implements IBlockRestorer this.DeathSpectateSecs = 4; this.HungerSet = 20; this.WorldBoundaryKill = false; - - this.CompassEnabled = true; - this.CompassGiveItem = false; + this.CompassEnabled = false; + + //Customizing for the Editor kit + this.BlockBreak = true; + this.BlockPlace = true; + this.ItemPickup = true; this.KitRegisterState = GameState.Prepare; @@ -112,9 +139,13 @@ public class WitherGame extends TeamGame implements IBlockRestorer _help = new String[] { - C.cRed + C.Bold + "This game is still under development!", + "This game will soon not be under development anymore ;)", + "Blocks placed by an Editor can be passed by other humans by " + C.cDGreen + "Right-clicking the block", + "Withers are too powerful to be killed. Hiding is the only option!", + "Medics are a valuable asset. Stick with them and keep them safe!", }; + } @Override @@ -177,6 +208,151 @@ public class WitherGame extends TeamGame implements IBlockRestorer setWither(player, true); } +// @EventHandler +// public void assignCompassOnStart(GameStateChangeEvent event) +// { +// if (event.GetState() != GameState.Live) +// return; +// +// for (Player players : _withers.GetPlayers(true)) +// { +// ItemStack compass = new ItemBuilder(Material.COMPASS, 1).build(); +// +// ItemMeta im = compass.getItemMeta(); +// im.setLore(new ArrayList(Arrays.asList( +// F.item("A compass that trigger"), +// F.item("your ability to track humans!")))); +// im.setDisplayName(F.name("Scent Trigger")); +// +// compass.setItemMeta(im); +// +// players.getInventory().setItem(7, compass); +// } +// } + + // Cancel wither shooting in waiting lobby + @EventHandler + public void onWitherSkullFire(ProjectileLaunchEvent event) + { + if (GetState() == GameState.Recruit || GetState() == GameState.Prepare) + { + Projectile proj = event.getEntity(); + WitherSkull ws = (WitherSkull) proj; + + if (ws.getShooter() instanceof Wither) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void handleCustomBlockPlace(BlockPlaceEvent event) + { + if(!IsLive()) + { + return; + } + if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor")) + { + event.setCancelled(true); + return; + } + + _maxY = GetTeamList().get(1).GetSpawn().getBlockY() - 5; + if(event.getBlock().getLocation().getBlockY() < _maxY) + { + event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); + event.setCancelled(true); + return; + } + + _locationsOfBlocks.add(event.getBlock().getLocation()); + } + + @EventHandler + public void handleCustomBlockbreak(BlockBreakEvent event) + { + if(!IsLive()) + { + return; + } + if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor")) + { + event.setCancelled(true); + return; + } + + Location blockLocation = event.getBlock().getLocation(); + _maxY = GetTeamList().get(1).GetSpawn().getBlockY() - 4; + if(blockLocation.add(0,1,0).getBlock().getType() == Material.AIR) + { + for(Player humans: _runners.GetPlayers(true)) + { + if(IsAlive(humans)) + { + if(humans.getLocation().add(0,-1,0).getBlock().equals(event.getBlock())) + { + if(humans.getName() != event.getPlayer().getName()) + { + event.setCancelled(true); + return; + } + } + } + } + } + + if(blockLocation.getBlockY() < _maxY) + { + event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!")); + event.setCancelled(true); + return; + } + } + + @EventHandler + public void handleCustomItemPickup(PlayerPickupItemEvent event) + { + if(!IsLive()) + { + return; + } + if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor")) + { + event.setCancelled(true); + return; + } + } + + //On Player interact with a placed block by Editor + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if(!IsLive()) + { + return; + } + if(!IsAlive(event.getPlayer())) + { + return; + } + if(event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + Block clickedBlock = event.getClickedBlock(); + + if(_locationsOfBlocks.contains(clickedBlock.getLocation())) + { + if(!(event.getPlayer().getInventory().getItem(event.getPlayer().getInventory().getHeldItemSlot()) instanceof Block)) + { + UtilParticle.PlayParticle(ParticleType.FLAME, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); + Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000); + } + } + } + } + public void setWither(Player player, boolean forced) { // _lives.remove(player); @@ -184,7 +360,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer SetPlayerTeam(player, _withers, true); // Kit - Kit newKit = GetKits()[4]; + Kit newKit = GetKits()[GetKits().length-1]; SetKit(player, newKit, false); newKit.ApplyKit(player); @@ -244,6 +420,24 @@ public class WitherGame extends TeamGame implements IBlockRestorer false); } } + + @EventHandler + public void removeUselessPlayerCopies(UpdateEvent event) + { + if(event.getType() != UpdateType.TWOSEC) + return; + + for(Player players: _doubles.keySet()) + { + if(!players.isOnline()) + { + PlayerCopy pc = _doubles.get(players); + pc.GetEntity().remove(); + _doubles.remove(players); + } + } + + } // @EventHandler // public void playerLivesDisplay(PlayerKitGiveEvent event) @@ -272,9 +466,10 @@ public class WitherGame extends TeamGame implements IBlockRestorer return; // Players Quit - if (GetPlayers(true).size() < 2) + if (GetPlayers(true).size() < 1) { SetState(GameState.End); + _locationsOfBlocks.clear(); } GameTeam winner = null; @@ -307,6 +502,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer // End SetState(GameState.End); + _locationsOfBlocks.clear(); } } @@ -390,6 +586,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer for (Player player : _withers.GetPlayers(true)) { ArrayList collisions = new ArrayList(); + _maxY = GetTeamList().get(1).GetSpawn().getBlockY(); // Fly Speed double speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006; @@ -569,7 +766,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer _doubles.put(player, new PlayerCopy(this, player, ChatColor.YELLOW)); } - + public void playerIn(final Player player, final LivingEntity copy) { // State @@ -662,6 +859,8 @@ public class WitherGame extends TeamGame implements IBlockRestorer copyIterator.remove(); AddGems(thrower, 3, "Revived Ally", true, true); + + Bukkit.getPluginManager().callEvent(new HumanReviveEvent(thrower, copy.GetPlayer())); } // Revive diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java index 5fb97dbe3..bfdbbb8ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanArcher.java @@ -24,22 +24,20 @@ public class KitHumanArcher extends Kit { public KitHumanArcher(ArcadeManager manager) { - super(manager, "Human Archer", KitAvailability.Free, + super(manager, "Human Archer", KitAvailability.Free, - new String[] - { - "" - }, + new String[] + { + "" + }, - new Perk[] - { + new Perk[] + { new PerkDoubleJump("Double Jump", 1.2, 1, true, 4000, true), new PerkWitherArrowBlind(6), new PerkFletcher(4, 4, true), - - }, - EntityType.ZOMBIE, - null); + + }, EntityType.ZOMBIE, null); } @@ -48,20 +46,20 @@ public class KitHumanArcher extends Kit { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); - - ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 - PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); + + ItemStack potion = new ItemStack(Material.POTION, 2, (short) 16429); // 16422 + PotionMeta potionMeta = (PotionMeta) potion.getItemMeta(); potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion"); potion.setItemMeta(potionMeta); player.getInventory().addItem(potion); - + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); } - + @Override - public void SpawnCustom(LivingEntity ent) + public void SpawnCustom(LivingEntity ent) { - + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java deleted file mode 100644 index d6c168aa4..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitHumanBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -package nautilus.game.arcade.game.games.wither.kit; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; - -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkBlockRestorer; -import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import nautilus.game.arcade.kit.perks.PerkIronShell; - -public class KitHumanBuilder extends Kit -{ - public KitHumanBuilder(ArcadeManager manager) - { - super(manager, "Human Builder", KitAvailability.Free, - - new String[] - { - "" - }, - - new Perk[] - { - new PerkDoubleJump("Double Jump", 1, 0.8, true, 6000, true), - new PerkIronShell(), - new PerkBlockRestorer() - }, - EntityType.ZOMBIE, - null); - - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SPADE)); - - ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 - PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion"); - potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java index 72a3e93de..92c03e455 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/kit/KitWitherMinion.java @@ -26,57 +26,60 @@ public class KitWitherMinion extends Kit { public KitWitherMinion(ArcadeManager manager) { - super(manager, "Wither", KitAvailability.Free, + super(manager, "Wither", KitAvailability.Free, - new String[] - { - "" - }, + new String[] + { + "" + }, - new Perk[] - { - new PerkWitherArrows(), - new PerkWitherAttack(), - new PerkWitherMinion() - }, - EntityType.WITHER, - null); + new Perk[] + { + new PerkWitherArrows(), new PerkWitherAttack(), + new PerkWitherMinion(), new PerkWitherCompassScent() + }, EntityType.WITHER, null); } - -// @Override -// public void SpawnCustom(LivingEntity ent) -// { -// ent.setMaxHealth(300); -// ent.setHealth(300); -// -// DisguiseWither disguise = new DisguiseWither(ent); -// disguise.SetName(C.cYellow + "Wither"); -// disguise.SetCustomNameVisible(true); -// Manager.GetDisguise().disguise(disguise); -// } - - + + // @Override + // public void SpawnCustom(LivingEntity ent) + // { + // ent.setMaxHealth(300); + // ent.setHealth(300); + // + // DisguiseWither disguise = new DisguiseWither(ent); + // disguise.SetName(C.cYellow + "Wither"); + // disguise.SetCustomNameVisible(true); + // Manager.GetDisguise().disguise(disguise); + // } @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, - C.cYellow + C.Bold + "Left-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Wither Skull")); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, - C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Skeletal Minions")); - - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS, (byte)0, 1, - C.cYellow + C.Bold + "Human Finder X-9000")); + public void GiveItems(Player player) + { + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, + (byte) 0, 1, C.cYellow + C.Bold + "Left-Click" + + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + + "Wither Skull")); - //Disguise + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, + (byte) 0, 1, C.cYellow + C.Bold + "Right-Click" + + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + + "Skeletal Minions")); + + player.getInventory().addItem( + ItemStackFactory.Instance + .CreateStack(Material.COMPASS, (byte) 0, 1, C.cYellow + + C.Bold + "Human Finder X-9000")); + + // Disguise DisguiseWither disguise = new DisguiseWither(player); - if (Manager.GetGame().GetTeam(player) != null) - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - else - disguise.setName(player.getName()); + if (Manager.GetGame().GetTeam(player) != null) + disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + + player.getName()); + else disguise.setName(player.getName()); disguise.setCustomNameVisible(true); Manager.GetDisguise().disguise(disguise); @@ -87,25 +90,25 @@ public class KitWitherMinion extends Kit { if (event.IsCancelled()) return; - + Player player = event.GetDamageePlayer(); if (player == null) return; - + if (HasKit(player)) event.SetCancelled("Wither Immunity"); } - + @EventHandler(priority = EventPriority.LOWEST) public void witherMeleeCancel(CustomDamageEvent event) { if (event.IsCancelled()) return; - + Player player = event.GetDamagerPlayer(true); if (player == null) return; - + if (!HasKit(player)) return; @@ -120,7 +123,7 @@ public class KitWitherMinion extends Kit { if (event.getType() != UpdateType.TICK) return; - + for (Player player : UtilServer.getPlayers()) { if (!HasKit(player))