From b2a595b01b1f57077a5307f5f497e1ceed12e9ee Mon Sep 17 00:00:00 2001 From: Cheese Date: Mon, 7 Dec 2015 12:02:53 +1100 Subject: [PATCH] snwo fight changes --- .../game/games/snowfight/SnowFight.java | 61 ++++++------ .../game/games/snowfight/kits/KitMedic.java | 94 +------------------ .../games/snowfight/kits/KitSportsman.java | 39 ++------ .../games/snowfight/kits/KitTactician.java | 77 ++------------- .../arcade/kit/perks/PerkPotionGenerator.java | 84 +++++++++++++++++ 5 files changed, 135 insertions(+), 220 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPotionGenerator.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index 492f82da9..5e8be4cd6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -201,27 +201,29 @@ public class SnowFight extends TeamGame return; // Item - - if (!_tiles.containsKey(player)) - { - _tiles.put(player, 0); - } - - if (GetKit(player) instanceof KitSportsman) - UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); - - - int tiles = _tiles.get(player); - _tiles.put(player, tiles + 1); - - if (!(GetKit(player) instanceof KitSportsman)) - { - if (_tiles.get(player) == 2) - { - UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); - _tiles.put(player, 0); - } - } +// +// if (!_tiles.containsKey(player)) +// { +// _tiles.put(player, 0); +// } +// +// if (GetKit(player) instanceof KitSportsman) +// UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); +// +// +// int tiles = _tiles.get(player); +// _tiles.put(player, tiles + 1); +// +// if (!(GetKit(player) instanceof KitSportsman)) +// { +// if (_tiles.get(player) == 2) +// { +// UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); +// _tiles.put(player, 0); +// } +// } + + UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); // Snow Height SnowDecrease(event.getBlock(), 1); @@ -606,16 +608,19 @@ public class SnowFight extends TeamGame long time = 1000 * 195 - (System.currentTimeMillis() - this.GetStateTime()); - if (time > 0) + if(IsLive()) { - Scoreboard.Write(C.cYellow + C.Bold + "Meteors"); - if(IsLive()) + if (time > 0) + { + Scoreboard.Write(C.cYellow + C.Bold + "Meteors in"); Scoreboard.Write(UtilTime.MakeStr(time, 0)); + } + else + { + Scoreboard.Write(C.cGold + C.Bold + "Meteors!"); + } } - else - { - Scoreboard.Write(C.cGold + C.Bold + "Meteors!"); - } + Scoreboard.Draw(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java index efebaf42e..4c524b981 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java @@ -1,30 +1,17 @@ package nautilus.game.arcade.game.games.snowfight.kits; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; 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.PerkPotionGenerator; -import org.bukkit.Color; import org.bukkit.Material; -import org.bukkit.entity.Egg; -import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.potion.Potion; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; public class KitMedic extends Kit @@ -36,20 +23,12 @@ public class KitMedic extends Kit new String[] { - "To the rescue...!", - " ", - "Gets 1 Snowball every second tile.", - "Left-Click Snow to pick up Snowballs (Max. 16)", - "Right-Click Snowballs to throw them.", - " ", - "Gets 1 Healing Potion every 32 seconds [max. 1]", - "Slowness II when hit.", - " ", - "Supports all nearby allies with REGENERATION." + "Throw warmth potions to heal allies!", }, new Perk[] { + new PerkPotionGenerator("Warmth Potions", 30, 1, PotionType.INSTANT_HEAL, true, "Warmth Potion", false) }, EntityType.SKELETON, new ItemStack(Material.POTION)); @@ -62,6 +41,8 @@ public class KitMedic extends Kit { player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); } @Override @@ -72,69 +53,4 @@ public class KitMedic extends Kit ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); } - - @EventHandler - public void Aura(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - continue; - - for (Player other : Manager.GetGame().GetPlayers(true)) - { - if (other.equals(player)) - continue; - - if (UtilMath.offset(player, other) > 4) - continue; - - if( Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) - Manager.GetCondition().Factory().Regen("Aura", other, player, 1.9, 0, false, false, false); - } - } - } - - @EventHandler - public void KitItems(UpdateEvent event) - { - if(!Manager.GetGame().IsLive()) - return; - - if (event.getType() == UpdateType.SLOWEST) - { - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - continue; - - Potion potion = new Potion(PotionType.INSTANT_HEAL); - potion.setSplash(true); - player.getInventory().setItem(1, potion.toItemStack(1)); - } - } - } - - @EventHandler - public void Splash(PotionSplashEvent event) - { - if(event.getEntity().getShooter() instanceof Player) - { - if(!HasKit((Player) event.getEntity().getShooter())) - return; - - for(Entity entity : event.getAffectedEntities()) - { - if(entity instanceof Player) - { - Manager.GetCondition().Factory().Slow("Heal Potion", (Player)entity, (Player)event.getEntity().getShooter(), 5.0, 1, false, false, false, false); - } - } - - } - } - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java index 43bd655e3..1bf093f0a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java @@ -19,6 +19,7 @@ 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.PerkDoubleJump; import nautilus.game.arcade.kit.perks.PerkFallDamage; public class KitSportsman extends Kit @@ -31,17 +32,13 @@ public class KitSportsman extends Kit new String[] { "Trained to be the fastest on snow and ice.", - "", - "Gets 1 Snowball every tile", - "Left-Click Snow to pick up Snowballs (Max. 16)", - "Right-Click Snowballs to throw them.", - "", - "Supports all nearby allies with SPEED." + }, new Perk[] { - new PerkFallDamage(3) + new PerkDoubleJump("Snow Jump", 1, 0.8, true, 8000, true), + new PerkFallDamage(2), }, EntityType.SKELETON, new ItemStack(Material.SNOW_BALL)); @@ -53,6 +50,8 @@ public class KitSportsman extends Kit { player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); } @Override @@ -63,30 +62,4 @@ public class KitSportsman extends Kit ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); } - - @EventHandler - public void Aura(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - continue; - - for (Player other : Manager.GetGame().GetPlayers(true)) - { - if (other.equals(player)) - continue; - - if (UtilMath.offset(player, other) > 4) - continue; - - if( Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) - Manager.GetCondition().Factory().Speed("Aura", other, player, 1.9, 0, false, false, false); - } - } - } - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java index a0aec26c1..f69d290d5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java @@ -1,27 +1,18 @@ package nautilus.game.arcade.game.games.snowfight.kits; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; 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.PerkFallDamage; +import nautilus.game.arcade.kit.perks.PerkConstructor; +import nautilus.game.arcade.kit.perks.PerkIronSkin; -import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.potion.PotionType; public class KitTactician extends Kit { @@ -32,18 +23,11 @@ public class KitTactician extends Kit new String[] { "No Snowfight is complete without a tactical game!", - " ", - "Gets 1 Snowball every second tile.", - "Left-Click Snow to pick up Snowballs (Max. 16)", - "Right-Click Snowballs to throw them.", - " ", - "Gets 1 Barrier every 32 seconds [max. 2]", - "Place Barriers to improve your defense.", - "You cant place Barriers above Ice, Packed Ice or Fences.", - " ", - "Supports all nearby allies with RESISTANCE." + }, new Perk[] { + new PerkConstructor("Barrier", 30, 1, Material.FENCE, "Warmth Potion", false), + new PerkIronSkin(0.25) }, EntityType.SKELETON, new ItemStack(Material.FENCE)); @@ -55,6 +39,8 @@ public class KitTactician extends Kit { player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(4, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); player.getInventory().setItem(7, ItemStackFactory.Instance.CreateStack(Material.COMPASS.getId(), (byte) 0, 1, "§a§lTracking Compass")); } @@ -66,53 +52,4 @@ public class KitTactician extends Kit ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); } - - @EventHandler - public void Aura(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - continue; - - for (Player other : Manager.GetGame().GetPlayers(true)) - { - if (other.equals(player)) - continue; - - if (UtilMath.offset(player, other) > 4) - continue; - - if( Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) - Manager.GetCondition().Factory().Protection("Aura", other, player, 1.9, 0, false, false, false); - } - } - } - - @EventHandler - public void KitItems(UpdateEvent event) - { - if(!Manager.GetGame().IsLive()) - return; - - if (event.getType() == UpdateType.SLOWEST) - { - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - continue; - - int amount = 0; - if (player.getInventory().getItem(1) != null && UtilInv.contains(player, Material.FENCE, (byte) 0, 1)) - amount = 2; - else - amount = 1; - player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.FENCE, (byte) 0, amount, "Barrier")); - } - } - } - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPotionGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPotionGenerator.java new file mode 100644 index 000000000..5f355428e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPotionGenerator.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.kit.perks; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.event.PerkConstructorEvent; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionType; + +public class PerkPotionGenerator extends Perk +{ + private int _max = 0; + private double _time = 0; + + private PotionType _type; + private boolean _splash; + private String _name; + + public PerkPotionGenerator(String perkName, double time, int max, PotionType type, boolean splash, String name, boolean visible) + { + super(perkName, new String[] + { + C.cGray + "Receive 1 " + name + " every " + time + " seconds. Maximum of " + max + ".", + }, visible); + + _time = time; + _splash = splash; + + _name = name; + } + + @EventHandler + public void Construct(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player cur : UtilServer.getPlayers()) + { + if (!Kit.HasKit(cur)) + continue; + + if (!Manager.GetGame().IsAlive(cur)) + continue; + + if (Manager.isSpectator(cur)) + continue; + + if (!Recharge.Instance.use(cur, GetName(), (long) (_time * 1000), false, false)) + continue; + + Potion potion = new Potion(_type); + potion.setSplash(_splash); + ItemStack stack = potion.toItemStack(1); + ItemMeta meta = stack.getItemMeta(); + meta.setDisplayName(_name); + + if (UtilInv.contains(cur, stack.getType(), (byte)0, _max)) + continue; + + PerkConstructorEvent cE = new PerkConstructorEvent(cur); + Bukkit.getServer().getPluginManager().callEvent(cE); + + if (cE.isCancelled()) + continue; + + //Add + cur.getInventory().addItem(stack); + + cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f); + } + } +}