diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 161d8a8e4..5d025ca82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -125,7 +125,7 @@ public class ProjectileUser if (_hitBlock) { Block block = _thrown.getLocation().add(_thrown.getVelocity().normalize().multiply(0.6)).getBlock(); - if (!UtilBlock.airFoliage(block)) + if (!UtilBlock.airFoliage(block) && !block.isLiquid()) { _callback.Collide(null, block, this); return true; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java b/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java index 7ccf35882..77b91242c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/recharge/Recharge.java @@ -82,6 +82,10 @@ public class Recharge extends MiniPlugin { Get(cur).remove(ability); + //Event + RechargedEvent rechargedEvent = new RechargedEvent(cur, ability); + UtilServer.getServer().getPluginManager().callEvent(rechargedEvent); + if (informSet.contains(ability)) UtilPlayer.message(cur, F.main("Recharge", "You can use " + F.skill(ability) + ".")); } @@ -143,6 +147,11 @@ public class Recharge extends MiniPlugin Get(player).put(ability, System.currentTimeMillis()+rechargeEvent.GetRecharge()); } + + public void recharge(Player player, String ability) + { + Get(player).remove(ability); + } @EventHandler public void clearPlayer(PlayerQuitEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/recharge/RechargedEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/recharge/RechargedEvent.java new file mode 100644 index 000000000..dc0964590 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/recharge/RechargedEvent.java @@ -0,0 +1,39 @@ +package mineplex.core.recharge; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class RechargedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private String _ability; + + public RechargedEvent(Player player, String ability) + { + _player = player; + _ability = ability; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player GetPlayer() + { + return _player; + } + + public String GetAbility() + { + return _ability; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index 0d2a8f698..5e3886753 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -5,6 +5,7 @@ import java.util.HashMap; import org.bukkit.ChatColor; import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.castlesiege.CastleSiege; @@ -20,6 +21,7 @@ import nautilus.game.arcade.game.games.runner.Runner; import nautilus.game.arcade.game.games.smash.SuperSmash; import nautilus.game.arcade.game.games.snowfight.SnowFight; import nautilus.game.arcade.game.games.spleef.Spleef; +import nautilus.game.arcade.game.games.squidshooter.SquidShooter; import nautilus.game.arcade.game.games.turfforts.TurfForts; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival; @@ -36,6 +38,7 @@ public class GameFactory public Game CreateGame(GameType gameType, HashMap pastTeams) { if (gameType == GameType.Barbarians) return new Barbarians(_manager); + else if (gameType == GameType.BaconBrawl) return new BaconBrawl(_manager); else if (gameType == GameType.Bridge) return new Bridge(_manager); else if (gameType == GameType.CastleSiege) return new CastleSiege(_manager, pastTeams); else if (gameType == GameType.DeathTag) return new DeathTag(_manager); @@ -44,13 +47,14 @@ public class GameFactory else if (gameType == GameType.Evolution) return new Evolution(_manager); else if (gameType == GameType.HungerGames) return new HungerGames(_manager); else if (gameType == GameType.MineWare) return new MineWare(_manager); - else if (gameType == GameType.MilkCow) return new MilkCow(_manager); + else if (gameType == GameType.MilkCow) return new MilkCow(_manager); else if (gameType == GameType.Quiver) return new Quiver(_manager); else if (gameType == GameType.Runner) return new Runner(_manager); else if (gameType == GameType.SnowFight) return new SnowFight(_manager); else if (gameType == GameType.Smash) return new SuperSmash(_manager); else if (gameType == GameType.Spleef) return new Spleef(_manager); - else if (gameType == GameType.TurfWars) return new TurfForts(_manager); + else if (gameType == GameType.SquidShooter) return new SquidShooter(_manager); + else if (gameType == GameType.TurfWars) return new TurfForts(_manager); else if (gameType == GameType.UHC) return new UHC(_manager); else if (gameType == GameType.ZombieSurvival) return new ZombieSurvival(_manager); else return null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index e0a229ef8..253d6a535 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -3,6 +3,7 @@ package nautilus.game.arcade; public enum GameType { //Mini + BaconBrawl("Bacon Brawl"), Barbarians("A Barbarians Life"), Bridge("The Bridges"), CastleSiege("Castle Siege"), @@ -19,6 +20,7 @@ public enum GameType Smash("Super Smash Mobs"), SnowFight("Snow Fight"), Spleef("Super Spleef"), + SquidShooter("Squid Shooter"), TurfWars("Turf Wars"), UHC("Ultra Hardcore"), ZombieSurvival("Zombie Survival"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index a6c25bca2..aa0a8af30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -20,6 +20,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; @@ -158,6 +159,8 @@ public abstract class Game implements Listener public boolean DisplayLobbySide = true; public boolean AutoStart = true; + + public GameState KitRegisterState = GameState.Live; //Addons public boolean CompassEnabled = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java new file mode 100644 index 000000000..bbac27718 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/BaconBrawl.java @@ -0,0 +1,110 @@ +package nautilus.game.arcade.game.games.baconbrawl; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.baconbrawl.kits.*; +import nautilus.game.arcade.kit.Kit; + +public class BaconBrawl extends SoloGame +{ + public BaconBrawl(ArcadeManager manager) + { + super(manager, GameType.BaconBrawl, + + new Kit[] + { + new KitPig(manager), + new KitBabyPig(manager), + new KitSheepPig(manager) + }, + + new String[] + { + "Knock other pigs out of the arena!", + "Last pig in the arena wins!" + }); + + this.DamageTeamSelf = true; + this.HungerSet = 20; + this.PrepareFreeze = false; + } + + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + if (GetPlayers(true).size() == 1) + GetPlaces().add(0, GetPlayers(true).get(0)); + + if (GetPlaces().size() >= 1) + AddGems(GetPlaces().get(0), 15, "1st Place", false); + + if (GetPlaces().size() >= 2) + AddGems(GetPlaces().get(1), 10, "2nd Place", false); + + if (GetPlaces().size() >= 3) + AddGems(GetPlaces().get(2), 5, "3rd Place", false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + + SetState(GameState.End); + AnnounceEnd(GetPlaces()); + } + } + + @EventHandler + public void Hunger(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + return; + + if (!IsLive()) + return; + + for (Player player : GetPlayers(true)) + { + if (player.getFoodLevel() <= 0) + { + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.STARVATION, 4, false, true, false, + "Starvation", GetName()); + } + + UtilPlayer.hunger(player, -1); + } + } + + @EventHandler + public void HungerRestore(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(true); + if (damager != null) + UtilPlayer.hunger(damager, 2); + } + + @EventHandler + public void DamageEvent(CustomDamageEvent event) + { + if (event.GetCause() == DamageCause.ENTITY_ATTACK || event.GetCause() == DamageCause.CUSTOM || event.GetCause() == DamageCause.PROJECTILE) + { + event.GetDamageeEntity().setHealth(event.GetDamageeEntity().getMaxHealth()); + event.AddKnockback("Pig Wrestle", 2); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitBabyPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitBabyPig.java new file mode 100644 index 000000000..7029c77c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitBabyPig.java @@ -0,0 +1,83 @@ +package nautilus.game.arcade.game.games.baconbrawl.kits; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.disguise.disguises.DisguiseChicken; +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.PerkBaconBlast; +import nautilus.game.arcade.kit.perks.PerkSpeed; + +public class KitBabyPig extends Kit +{ + public KitBabyPig(ArcadeManager manager) + { + super(manager, "Bebe Piggles", KitAvailability.Green, + + new String[] + { + "Tiny pig runs so fast!" + }, + + new Perk[] + { + new PerkBaconBlast(), + new PerkSpeed(1), + }, + EntityType.PIG, + new ItemStack(Material.PORK)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + + //Disguise + DisguiseChicken disguise = new DisguiseChicken(player); + disguise.SetName(C.cYellow + player.getName()); + disguise.SetCustomNameVisible(true); + disguise.setBaby(); + Manager.GetDisguise().disguise(disguise); + } + + @Override + public Entity SpawnEntity(Location loc) + { + EntityType type = _entityType; + if (type == EntityType.PLAYER) + type = EntityType.ZOMBIE; + + LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); + + entity.setRemoveWhenFarAway(false); + entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit" + (GetAvailability() == KitAvailability.Blue ? ChatColor.GRAY + " (" + ChatColor.WHITE + "Ultra" + ChatColor.GRAY + ")" : "")); + entity.setCustomNameVisible(true); + entity.getEquipment().setItemInHand(_itemInHand); + + if (type == EntityType.PIG) + { + Pig sheep = (Pig)entity; + sheep.setBaby(); + } + + UtilEnt.Vegetate(entity); + + SpawnCustom(entity); + + return entity; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java new file mode 100644 index 000000000..240761e90 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitPig.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.baconbrawl.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguisePig; +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.PerkBodySlam; +import nautilus.game.arcade.kit.perks.PerkJump; + +public class KitPig extends Kit +{ + public KitPig(ArcadeManager manager) + { + super(manager, "El Muchacho Pigo", KitAvailability.Free, + + new String[] + { + "Such a fat pig. Oink." + }, + + new Perk[] + { + new PerkBodySlam(6, 2), + new PerkJump(1), + }, + EntityType.PIG, + new ItemStack(Material.PORK)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + + //Disguise + DisguisePig disguise = new DisguisePig(player); + disguise.SetName(C.cYellow + player.getName()); + disguise.SetCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java new file mode 100644 index 000000000..aff9daf13 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitSheepPig.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.game.games.baconbrawl.kits; + +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Sheep; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.disguise.disguises.DisguiseSheep; +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.PerkBackstabKnockback; +import nautilus.game.arcade.kit.perks.PerkPigCloak; + +public class KitSheepPig extends Kit +{ + public KitSheepPig(ArcadeManager manager) + { + super(manager, "'Pig'", KitAvailability.Blue, + + new String[] + { + "\"...Oink?\"" + }, + + new Perk[] + { + new PerkPigCloak(), + new PerkBackstabKnockback() + }, + EntityType.SHEEP, + new ItemStack(Material.WOOL)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + + //Disguise + DisguiseSheep disguise = new DisguiseSheep(player); + disguise.SetName(C.cYellow + player.getName()); + disguise.SetCustomNameVisible(true); + disguise.setColor(DyeColor.PINK); + Manager.GetDisguise().disguise(disguise); + } + + @Override + public Entity SpawnEntity(Location loc) + { + EntityType type = _entityType; + if (type == EntityType.PLAYER) + type = EntityType.ZOMBIE; + + LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); + + entity.setRemoveWhenFarAway(false); + entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit" + (GetAvailability() == KitAvailability.Blue ? ChatColor.GRAY + " (" + ChatColor.WHITE + "Ultra" + ChatColor.GRAY + ")" : "")); + entity.setCustomNameVisible(true); + entity.getEquipment().setItemInHand(_itemInHand); + + if (type == EntityType.SHEEP) + { + Sheep sheep = (Sheep)entity; + sheep.setColor(DyeColor.PINK); + } + + UtilEnt.Vegetate(entity); + + SpawnCustom(entity); + + return entity; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java index affd98509..3bc9dfecb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/barbarians/Barbarians.java @@ -12,7 +12,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.barbarians.kits.*; import nautilus.game.arcade.kit.Kit; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index 19ee4fcf1..194d7a36b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -95,6 +95,7 @@ public class DeathTag extends SoloGame //Undead Team _chasers = new GameTeam("Chasers", ChatColor.RED, _runners.GetSpawns()); + _chasers.SetVisible(false); GetTeamList().add(_chasers); RestrictKits(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java index ebe17208b..bbe6fb37c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java @@ -1,7 +1,10 @@ package nautilus.game.arcade.game.games.hungergames; +import java.util.AbstractMap; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map.Entry; import org.bukkit.Chunk; import org.bukkit.Effect; @@ -11,14 +14,20 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -39,9 +48,12 @@ public class HungerGames extends SoloGame private HashSet _openedChest = new HashSet(); private ArrayList _chestLoot = new ArrayList(); - private ArrayList _redSpread = new ArrayList(); - private HashSet _redChunks = new HashSet(); - + private ArrayList _redLocations = new ArrayList(); + private int _spreadType = 0; + private boolean _ignoreLiquids = true; + private ArrayList> _spreadTypeBlocks; + private HashMap _redOutTime = new HashMap(); + public HungerGames(ArcadeManager manager) { super(manager, GameType.HungerGames, @@ -68,6 +80,7 @@ public class HungerGames extends SoloGame this.SpawnDistanceRequirement = 48; + this.Damage = false; this.DamageSelf = true; this.DamageTeamSelf = true; @@ -75,7 +88,32 @@ public class HungerGames extends SoloGame this.GemMultiplier = 2; + _spreadType = UtilMath.r(3); + System.out.println("==================="); + System.out.println("SPREAD TYPE: " + _spreadType); + System.out.println("==================="); + _spreadTypeBlocks = new ArrayList>(); + + if (_spreadType == 0) + { + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(159, 14)); + } + else if (_spreadType == 1) + { + _ignoreLiquids = false; + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(78, 0)); + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(79, 0)); + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(80, 0)); + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(49, 0)); + } + else if (_spreadType == 2) + { + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(87, 0)); + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(88, 0)); + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(89, 0)); + _spreadTypeBlocks.add(new AbstractMap.SimpleEntry(153, 0)); + } } @Override @@ -266,67 +304,50 @@ public class HungerGames extends SoloGame Manager.GetCondition().EndCondition(damager, null, "Start Speed"); } + //If an item spawns and no one is there to see it, does it really spawn? No. + @EventHandler + public void ItemSpawn(ItemSpawnEvent event) + { + for (Player player : GetPlayers(true)) + if (UtilMath.offset(player, event.getEntity()) < 6) + return; + + event.setCancelled(true); + } + @EventHandler public void RedBorderStart(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) return; - - long time = System.currentTimeMillis(); - - /* - //X Borders - for (int x=WorldData.MinX/16 ; x<=WorldData.MaxX/16 ; x++) - { - _redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(x, WorldData.MinZ/16))); - _redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(x, WorldData.MaxZ/16))); - } - //Z Borders - for (int z=WorldData.MinZ/16 ; z<=WorldData.MaxZ/16 ; z++) - { - _redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(WorldData.MinX/16, z))); - _redChunks.add(UtilWorld.chunkToStr(WorldData.World.getChunkAt(WorldData.MaxX/16, z))); - } - */ - //Start Red Block block; - - if (true) - { - block = WorldData.World.getHighestBlockAt(0, 0); - while (!UtilBlock.solid(block)) - block = block.getRelative(BlockFace.DOWN); - _redSpread.add(block.getLocation()); - - return; - } - + for (int x=WorldData.MinX ; x<=WorldData.MaxX ; x++) { block = WorldData.World.getHighestBlockAt(x, WorldData.MinZ); while (!UtilBlock.solid(block)) block = block.getRelative(BlockFace.DOWN); - _redSpread.add(block.getLocation()); - + _redLocations.add(block.getLocation()); + block = WorldData.World.getHighestBlockAt(x, WorldData.MaxZ); while (!UtilBlock.solid(block)) block = block.getRelative(BlockFace.DOWN); - _redSpread.add(block.getLocation()); + _redLocations.add(block.getLocation()); } - + for (int z=WorldData.MinZ ; z<=WorldData.MaxZ ; z++) { block = WorldData.World.getHighestBlockAt(WorldData.MinX, z); while (!UtilBlock.solid(block)) block = block.getRelative(BlockFace.DOWN); - _redSpread.add(block.getLocation()); - + _redLocations.add(block.getLocation()); + block = WorldData.World.getHighestBlockAt(WorldData.MaxX, z); while (!UtilBlock.solid(block)) block = block.getRelative(BlockFace.DOWN); - _redSpread.add(block.getLocation()); + _redLocations.add(block.getLocation()); } } @@ -335,50 +356,56 @@ public class HungerGames extends SoloGame { if (event.getType() != UpdateType.TICK) return; - + if (!IsLive()) return; - - if (_redSpread.isEmpty()) + + if (_redLocations.isEmpty()) return; - System.out.println(_redSpread.size()); - - int max = Math.max(5, Math.min(400, _redSpread.size()/10)); - + int max = Math.max(5, Math.min(400, _redLocations.size()/10)); + for (int i=0 ; i WorldData.MaxX) return false; - if (block.getZ() < WorldData.MinZ) return false; - if (block.getZ() > WorldData.MaxZ) return false; - + } + + if (!UtilBlock.solid(block) || UtilBlock.airFoliage(block) || block.getType() == Material.CHEST) + { + if (!block.isLiquid()) + { + while (block.getType() == Material.VINE) + { + RedChangeBlock(block.getLocation(), 0, (byte)0); + block = block.getRelative(BlockFace.DOWN); + } + + //Remove Foliage + if (block.getType() != Material.AIR) + RedChangeBlock(block.getLocation(), 0, (byte)0); + + return false; + } + } + + //Outside Boundaries + if (block.getX() < WorldData.MinX || block.getX() > WorldData.MaxX || block.getZ() < WorldData.MinZ || block.getZ() > WorldData.MaxZ) + { + return false; + } + + //Inside Boundary + if (block.getChunk().getX() == 0 && block.getChunk().getZ() == 0) + { + return false; + } + + //Not Visible if (!UtilBlock.isVisible(block)) - return false; - - if (!UtilBlock.solid(block) || UtilBlock.airFoliage(block)) { - if (block.getType() != Material.AIR) - RedChangeBlock(block.getLocation(), 0, (byte)0); - return false; } - - //if (_redChunks.contains(UtilWorld.chunkToStr(block.getChunk()))) - if (!_redSpread.contains(block.getLocation())) - { - _redSpread.add(block.getLocation()); - return true; - } - - return false; + + //Apply + _redLocations.add(block.getLocation()); + return true; } public void RedChangeBlock(Location loc, int id, byte data) { MapUtil.ChunkBlockChange(loc, id, data); + for (Player player : UtilServer.getPlayers()) + { + if (player.getLocation().getChunk().getX() - loc.getChunk().getX() > 6) + continue; + + if (player.getLocation().getChunk().getZ() - loc.getChunk().getZ() > 6) + continue; + player.sendBlockChange(loc, id, data); + } + } + + public boolean IsRed(Block block) + { + for (Entry entry : _spreadTypeBlocks) + { + if (block.getTypeId() == entry.getKey() && block.getData() == entry.getValue()) + return true; + } + + return false; + } + + public void SetRed(Location loc) + { + //Red + if (_spreadType == 0) + { + RedChangeBlock(loc, 159, (byte)14); + } + //Snow + else if (_spreadType == 1) + { + if (loc.getBlock().getType() == Material.LEAVES) RedChangeBlock(loc, 79, (byte)0); + else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0); + else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0); + else RedChangeBlock(loc, 80, (byte)0); + } + //Nether + else + { + if (loc.getBlock().getType() == Material.LEAVES) RedChangeBlock(loc, 88, (byte)0); + else + { + double r = Math.random(); + if (r > 0.1) RedChangeBlock(loc, 87, (byte)0); + else RedChangeBlock(loc, 153, (byte)0); + } + } + } + + @EventHandler + public void RedAttack(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Player player : GetPlayers(true)) + { + boolean near = false; + + for (Block block : UtilBlock.getInRadius(player.getLocation(), 5d).keySet()) + { + if (!IsRed(block)) + continue; + + near = true; + + //Red + if (_spreadType == 0) + { + if (block.getRelative(BlockFace.UP).getType() == Material.AIR) + { + block.getRelative(BlockFace.UP).setType(Material.FIRE); + break; + } + } + + //Snow + else if (_spreadType == 1) + { + if (Math.random() > 0.8) + { + Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation()); + + Snowball ball = player.getWorld().spawn(block.getLocation().add(0.5, 1.5, 0.5).subtract(traj.clone().multiply(8 + UtilMath.r(8))), Snowball.class); + + ball.setVelocity(UtilAlg.getTrajectory(ball.getLocation(), player.getEyeLocation().add(0, 3, 0)).add(new Vector(Math.random()-0.5, Math.random()-0.5, Math.random()-0.5).multiply(0.1))); + } + } + + //Nether + if (_spreadType == 2) + { + if (block.getRelative(BlockFace.UP).getType() == Material.AIR) + { + block.getRelative(BlockFace.UP).setType(Material.FIRE); + break; + } + } + } + + if (!near) + { + if (!UtilEnt.isGrounded(player)) + { + Block block = player.getLocation().getBlock(); + + while (!UtilBlock.solid(block) && block.getY() > 0) + block = block.getRelative(BlockFace.DOWN); + + if (IsRed(block) || block.getY() == 0) + near = true; + } + } + + if (near) + { + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 1, false, true, false, + "Hunger Games", "Border"); + + player.sendMessage("INFECTION!"); + } + } + } + + @EventHandler + public void SnowballDamage(CustomDamageEvent event) + { + if (event.GetProjectile() == null) + return; + + if (!(event.GetProjectile() instanceof Snowball)) + return; + + event.AddMod("Snowball", "Snowball", 1, false); + + event.AddKnockback("Snowball", 4); + } + + @EventHandler + public void DebugCmd(PlayerCommandPreprocessEvent event) + { + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java index f291a1a5a..1638674a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitBlaze.java @@ -35,7 +35,7 @@ public class KitBlaze extends SmashKit new Perk[] { - new PerkSmashStats(6, 1.5, 0.25, 5), + new PerkSmashStats(6, 1.5, 0.15, 5), new PerkDoubleJump("Double Jump", 1, 1, false), new PerkKnockbackFire(1.50), new PerkSpeed(0), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java new file mode 100644 index 000000000..acf3cc5ad --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -0,0 +1,208 @@ +package nautilus.game.arcade.game.games.squidshooter; + +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.quiver.QuiverScore; +import nautilus.game.arcade.game.games.squidshooter.kits.*; +import nautilus.game.arcade.kit.Kit; + +public class SquidShooter extends SoloGame +{ + private ArrayList _ranks = new ArrayList(); + private ArrayList _lastScoreboard = new ArrayList(); + + public SquidShooter(ArcadeManager manager) + { + super(manager, GameType.SquidShooter, + + new Kit[] + { + new KitRifle(manager), + new KitShotgun(manager), + new KitSniper(manager), + }, + + new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Attack", + C.cYellow + "Tap Crouch" + C.cGray + " to use " + C.cGreen + "Squid Thrust", + "First player to 20 kills wins." + }); + + this.DeathOut = false; + this.DamageSelf = false; + this.DamageTeamSelf = true; + this.PrepareFreeze = false; + this.SpawnDistanceRequirement = 16; + this.CompassEnabled = true; + this.KitRegisterState = GameState.Prepare; + } + + @EventHandler(priority = EventPriority.HIGH) + public void GameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + GetObjectiveSide().setDisplayName(C.cWhite + C.Bold + "First to " + C.cGold + C.Bold + "20 Kills"); + } + + @EventHandler + public void Death(CombatDeathEvent event) + { + if (event.GetLog().GetKiller() == null) + return; + + if (!event.GetLog().GetKiller().IsPlayer()) + return; + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + return; + + //Score + AddKill(player); + } + + public void AddKill(Player player) + { + //Rank + for (QuiverScore score : _ranks) + { + if (score.Player.equals(player)) + { + score.Kills += 1; + EndCheck(); + return; + } + } + + _ranks.add(new QuiverScore(player, 1)); + } + + private void SortScores() + { + for (int i=0 ; i<_ranks.size() ; i++) + { + for (int j=_ranks.size()-1 ; j>0 ; j--) + { + if (_ranks.get(j).Kills > _ranks.get(j-1).Kills) + { + QuiverScore temp = _ranks.get(j); + _ranks.set(j, _ranks.get(j-1)); + _ranks.set(j-1, temp); + } + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //Wipe Last + for (String string : _lastScoreboard) + { + GetScoreboard().resetScores(Bukkit.getOfflinePlayer(string)); + } + _lastScoreboard.clear(); + + SortScores(); + + //Write New + for (QuiverScore score : _ranks) + { + String out = score.Kills + " " + C.cGreen + score.Player.getName(); + + if (out.length() >= 16) + out = out.substring(0, 15); + + _lastScoreboard.add(out); + + GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(score.Kills); + } + } + + @EventHandler + public void AirDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (!IsLive()) + return; + + for (Player player : GetPlayers(true)) + { + if (player.getLocation().getBlock().isLiquid()) + { + player.setFoodLevel(20); + continue; + } + + //Damage + if (player.getFoodLevel() == 0) + player.damage(1); + + //Hunger Lower + UtilPlayer.hunger(player, -1); + + //Slow + if (UtilEnt.isGrounded(player)) + Manager.GetCondition().Factory().Slow("On Land", player, player, 0.9, 2, false, false, false, false); + } + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + SortScores(); + + if ((!_ranks.isEmpty() && _ranks.get(0).Kills >= 20) || GetPlayers(true).size() <= 1) + { + //Set Places + _places.clear(); + for (int i=0 ; i<_ranks.size() ; i++) + _places.add(i, _ranks.get(i).Player); + + //Award Gems + if (_ranks.size() >= 1) + AddGems(_ranks.get(0).Player, 20, "1st Place", false); + + if (_ranks.size() >= 2) + AddGems(_ranks.get(1).Player, 15, "2nd Place", false); + + if (_ranks.size() >= 3) + AddGems(_ranks.get(2).Player, 10, "3rd Place", false); + + //Participation + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + + SetState(GameState.End); + AnnounceEnd(_places); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitRifle.java new file mode 100644 index 000000000..3a6b0c878 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitRifle.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.squidshooter.kits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSquid; +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.PerkSquidRifle; +import nautilus.game.arcade.kit.perks.PerkSquidSwim; + +public class KitRifle extends Kit +{ + public KitRifle(ArcadeManager manager) + { + super(manager, "Squid Gunner", KitAvailability.Free, + + new String[] + { + "All rounder squid! Fast projectile and reload!" + }, + + new Perk[] + { + new PerkSquidSwim(), + new PerkSquidRifle() + }, + EntityType.SQUID, + new ItemStack(Material.INK_SACK)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + + ItemStack helm = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET); + helm.addEnchantment(Enchantment.OXYGEN, 3); + player.getInventory().setHelmet(helm); + + //Disguise + DisguiseSquid disguise = new DisguiseSquid(player); + disguise.SetName(C.cWhite + player.getName()); + disguise.SetCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitShotgun.java new file mode 100644 index 000000000..ead976969 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitShotgun.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.squidshooter.kits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSquid; +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.PerkSquidShotgun; +import nautilus.game.arcade.kit.perks.PerkSquidSwim; + +public class KitShotgun extends Kit +{ + public KitShotgun(ArcadeManager manager) + { + super(manager, "Squid Blaster", KitAvailability.Green, + + new String[] + { + "Fires many slow projectiles." + }, + + new Perk[] + { + new PerkSquidSwim(), + new PerkSquidShotgun() + }, + EntityType.SQUID, + new ItemStack(Material.INK_SACK)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + + ItemStack helm = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET); + helm.addEnchantment(Enchantment.OXYGEN, 3); + player.getInventory().setHelmet(helm); + + //Disguise + DisguiseSquid disguise = new DisguiseSquid(player); + disguise.SetName(C.cWhite + player.getName()); + disguise.SetCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitSniper.java new file mode 100644 index 000000000..0cc188cdc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/kits/KitSniper.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.squidshooter.kits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSquid; +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.PerkSquidSniper; +import nautilus.game.arcade.kit.perks.PerkSquidSwim; + +public class KitSniper extends Kit +{ + public KitSniper(ArcadeManager manager) + { + super(manager, "Squid Sniper", KitAvailability.Blue, + + new String[] + { + "Hitting someone with Ink Sniper recharges it!" + }, + + new Perk[] + { + new PerkSquidSwim(), + new PerkSquidSniper() + }, + EntityType.SQUID, + new ItemStack(Material.INK_SACK)); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + + ItemStack helm = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_HELMET); + helm.addEnchantment(Enchantment.OXYGEN, 3); + player.getInventory().setHelmet(helm); + + //Disguise + DisguiseSquid disguise = new DisguiseSquid(player); + disguise.SetName(C.cWhite + player.getName()); + disguise.SetCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstabKnockback.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstabKnockback.java new file mode 100644 index 000000000..a7c50f13e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBackstabKnockback.java @@ -0,0 +1,62 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkBackstabKnockback extends Perk +{ + public PerkBackstabKnockback() + { + super("Backstab", new String[] + { + C.cGray + "+250% Knockback from behind opponents.", + }); + } + + @EventHandler(priority = EventPriority.HIGH) + public void Damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + return; + + Player damager = event.GetDamagerPlayer(false); + if (damager == null) return; + + if (!Kit.HasKit(damager)) + return; + + LivingEntity damagee = event.GetDamageeEntity(); + if (damagee == null) return; + + Vector look = damagee.getLocation().getDirection(); + look.setY(0); + look.normalize(); + + Vector from = damager.getLocation().toVector().subtract(damagee.getLocation().toVector()); + from.setY(0); + from.normalize(); + + Vector check = new Vector(look.getX() * -1, 0, look.getZ() * -1); + if (check.subtract(from).length() < 0.8) + { + //Damage + event.AddKnockback("Backstab Knockback", 2.5); + + //Effect + damagee.getWorld().playSound(damagee.getLocation(), Sound.PIG_DEATH, 1f, 2f); + return; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java new file mode 100644 index 000000000..11f823e84 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBaconBlast.java @@ -0,0 +1,115 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import nautilus.game.arcade.kit.Perk; + +public class PerkBaconBlast extends Perk implements IThrown +{ + public PerkBaconBlast() + { + super("Bacon Blast", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Bacon Blast" + }); + } + + + @EventHandler + public void Shoot(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (event.getPlayer().getItemInHand() == null) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 3000, true)) + return; + + event.setCancelled(true); + + UtilInv.Update(player); + + org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.PORK, (byte)0, 16)); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); + + Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, + null, 1f, 1f, + null, 1, UpdateType.SLOW, + 2d); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 2f, 2f); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Explode(data); + + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.PROJECTILE, 6, true, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + } + + @Override + public void Idle(ProjectileUser data) + { + Explode(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Explode(data); + } + + public void Explode(ProjectileUser data) + { + data.GetThrown().getWorld().createExplosion(data.GetThrown().getLocation(), 0.5f); + data.GetThrown().remove(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java index dc06fc92a..3c2caab73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFirefly.java @@ -86,7 +86,7 @@ public class PerkFirefly extends Perk FireflyData data = dataIterator.next(); //Teleport - if (!UtilTime.elapsed(data.Time, 1000)) + if (!UtilTime.elapsed(data.Time, 1250)) { data.Player.setVelocity(new Vector(0,0,0));//.teleport(data.Location); data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 0.2f, 0.6f); @@ -148,7 +148,7 @@ public class PerkFirefly extends Perk //Damage Event Manager.GetDamage().NewDamageEvent(other, data.Player, null, - DamageCause.CUSTOM, 12, true, true, false, + DamageCause.CUSTOM, 10, true, true, false, data.Player.getName(), GetName()); UtilPlayer.message(other, F.main("Game", F.elem(Manager.GetColor(data.Player) + data.Player.getName()) + " hit you with " + F.elem(GetName()) + ".")); @@ -174,7 +174,7 @@ public class PerkFirefly extends Perk if (!data.Player.equals(event.GetDamageeEntity())) continue; - if (!UtilTime.elapsed(data.Time, 1000))// && event.GetCause() == DamageCause.PROJECTILE) + if (!UtilTime.elapsed(data.Time, 1250))// && event.GetCause() == DamageCause.PROJECTILE) { dataIterator.remove(); } @@ -191,6 +191,6 @@ public class PerkFirefly extends Perk if (event.GetReason() == null || !event.GetReason().contains(GetName())) return; - event.AddKnockback(GetName(), 2.5); + event.AddKnockback(GetName(), 2); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java new file mode 100644 index 000000000..767a78de2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigCloak.java @@ -0,0 +1,104 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.Effect; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkPigCloak extends Perk +{ + public PerkPigCloak() + { + super("Cloak", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Cloak" + }); + } + + @EventHandler + public void Use(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + return; + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, GetName(), GetName(), 10000, true)) + return; + + //Action + Manager.GetCondition().Factory().Cloak(GetName(), player, player, 5, false, false); + + for (int i=0 ; i<3 ; i++) + { + player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 2f, 0.5f); + player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80); + } + + //Inform + UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(GetName()) + ".")); + } + + @EventHandler(priority = EventPriority.HIGH) + public void EndDamagee(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + Player damagee = event.GetDamageePlayer(); + if (damagee == null) return; + + if (!Kit.HasKit(damagee)) + return; + + //End + Manager.GetCondition().EndCondition(damagee, null, GetName()); + } + + @EventHandler(priority = EventPriority.HIGH) + public void EndDamager(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) return; + + if (!Kit.HasKit(damager)) + return; + + //End + Manager.GetCondition().EndCondition(damager, null, GetName()); + } + + @EventHandler + public void EndInteract(PlayerInteractEvent event) + { + if (!Kit.HasKit(event.getPlayer())) + return; + + Manager.GetCondition().EndCondition(event.getPlayer(), null, GetName()); + } + + @EventHandler + public void Reset(PlayerDeathEvent event) + { + //Remove Condition + Manager.GetCondition().EndCondition(event.getEntity(), null, GetName()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java new file mode 100644 index 000000000..772238e8e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidRifle.java @@ -0,0 +1,177 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.entity.Firework; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkSquidRifle extends Perk implements IThrown +{ + private HashMap _fireworks = new HashMap(); + + public PerkSquidRifle() + { + super("Ink Blaster", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Blaster" + }); + } + + @EventHandler + public void Recharge(RechargedEvent event) + { + if (!event.GetAbility().equals(GetName())) + return; + + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 3f, 1f); + } + + @EventHandler + public void Shoot(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (event.getPlayer().getItemInHand() == null) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 1500, true)) + return; + + event.setCancelled(true); + + UtilInv.Update(player); + + //Firework + FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(false).build(); + + try + { + Vector vel = player.getLocation().getDirection().multiply(1.8); + Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); + _fireworks.put(fw, vel); + + Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, + null, 1f, 1f, + null, 1, UpdateType.SLOW, + 2.5d); + } + catch (Exception e) + { + e.printStackTrace(); + } + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.75f); + } + + + + @EventHandler + public void FireworkUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator fwIterator = _fireworks.keySet().iterator(); + + while (fwIterator.hasNext()) + { + Firework fw = fwIterator.next(); + + if (!fw.isValid()) + { + fwIterator.remove(); + continue; + } + + fw.setVelocity(_fireworks.get(fw)); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Explode(data); + + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.PROJECTILE, 50, false, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + } + + @Override + public void Idle(ProjectileUser data) + { + Explode(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Explode(data); + } + + public void Explode(ProjectileUser data) + { + if (!(data.GetThrown() instanceof Firework)) + { + data.GetThrown().remove(); + return; + } + + Firework fw = (Firework)data.GetThrown(); + + try + { + Manager.GetFirework().detonateFirework(fw); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java new file mode 100644 index 000000000..c6f45b477 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidShotgun.java @@ -0,0 +1,194 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.entity.Firework; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkSquidShotgun extends Perk implements IThrown +{ + private HashMap _fireworks = new HashMap(); + + public PerkSquidShotgun() + { + super("Ink Shotgun", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun" + }); + } + + @EventHandler + public void Recharge(RechargedEvent event) + { + if (!event.GetAbility().equals(GetName())) + return; + + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 3f, 1f); + } + + @EventHandler + public void Shoot(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (event.getPlayer().getItemInHand() == null) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 2500, true)) + return; + + event.setCancelled(true); + + UtilInv.Update(player); + + //Firework + FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.BURST).trail(false).build(); + + for (int i=0 ; i<6 ; i++) + { + + Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); + random.normalize(); + random.multiply(0.3); + + try + { + Vector vel = player.getLocation().getDirection().multiply(1.4).add(random); + Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); + _fireworks.put(fw, vel); + + Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, + null, 1f, 1f, + null, 1, UpdateType.SLOW, + 2.5d); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.75f); + } + + + + @EventHandler + public void FireworkUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator fwIterator = _fireworks.keySet().iterator(); + + while (fwIterator.hasNext()) + { + Firework fw = fwIterator.next(); + + if (!fw.isValid()) + { + fwIterator.remove(); + continue; + } + + fw.setVelocity(_fireworks.get(fw)); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Explode(data); + + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.PROJECTILE, 12, false, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + + //Recharge + if (data.GetThrower() instanceof Player) + { + Player player = (Player)data.GetThrower(); + Recharge.Instance.recharge(player, GetName()); + player.playSound(player.getLocation(), Sound.NOTE_STICKS, 3f, 1f); + } + } + + @Override + public void Idle(ProjectileUser data) + { + Explode(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Explode(data); + } + + public void Explode(ProjectileUser data) + { + if (!(data.GetThrown() instanceof Firework)) + { + data.GetThrown().remove(); + return; + } + + Firework fw = (Firework)data.GetThrown(); + + try + { + Manager.GetFirework().detonateFirework(fw); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java new file mode 100644 index 000000000..3a8d0b51f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSniper.java @@ -0,0 +1,185 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.entity.Firework; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkSquidSniper extends Perk implements IThrown +{ + private HashMap _fireworks = new HashMap(); + + public PerkSquidSniper() + { + super("Ink Sniper", new String[] + { + C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Sniper" + }); + } + + @EventHandler + public void Recharge(RechargedEvent event) + { + if (!event.GetAbility().equals(GetName())) + return; + + event.GetPlayer().playSound(event.GetPlayer().getLocation(), Sound.NOTE_STICKS, 3f, 1f); + } + + @EventHandler + public void Shoot(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (event.getPlayer().getItemInHand() == null) + return; + + if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 4500, true)) + return; + + event.setCancelled(true); + + UtilInv.Update(player); + + //Firework + FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false).build(); + + try + { + Vector vel = player.getLocation().getDirection().multiply(3); + Firework fw = Manager.GetFirework().launchFirework(player.getEyeLocation().subtract(0, 0.5, 0).add(player.getLocation().getDirection()), effect, vel); + _fireworks.put(fw, vel); + + Manager.GetProjectile().AddThrow(fw, player, this, -1, true, true, true, + null, 1f, 1f, + null, 1, UpdateType.SLOW, + 3d); + } + catch (Exception e) + { + e.printStackTrace(); + } + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + + //Effect + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.75f); + } + + + + @EventHandler + public void FireworkUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator fwIterator = _fireworks.keySet().iterator(); + + while (fwIterator.hasNext()) + { + Firework fw = fwIterator.next(); + + if (!fw.isValid()) + { + fwIterator.remove(); + continue; + } + + fw.setVelocity(_fireworks.get(fw)); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Explode(data); + + if (target == null) + return; + + //Damage Event + Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null, + DamageCause.PROJECTILE, 50, false, true, false, + UtilEnt.getName(data.GetThrower()), GetName()); + + //Recharge + if (data.GetThrower() instanceof Player) + { + Player player = (Player)data.GetThrower(); + Recharge.Instance.recharge(player, GetName()); + player.playSound(player.getLocation(), Sound.NOTE_STICKS, 3f, 1f); + } + } + + @Override + public void Idle(ProjectileUser data) + { + Explode(data); + } + + @Override + public void Expire(ProjectileUser data) + { + Explode(data); + } + + public void Explode(ProjectileUser data) + { + if (!(data.GetThrown() instanceof Firework)) + { + data.GetThrown().remove(); + return; + } + + Firework fw = (Firework)data.GetThrown(); + + try + { + Manager.GetFirework().detonateFirework(fw); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSwim.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSwim.java new file mode 100644 index 000000000..edd49570d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSquidSwim.java @@ -0,0 +1,83 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.Iterator; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerToggleSneakEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkSquidSwim extends Perk +{ + private HashMap _active = new HashMap(); + + public PerkSquidSwim() + { + super("Swimming", new String[] + { + C.cYellow + "Tap Crouch" + C.cGray + " to use " + C.cGreen + "Squid Thrust" + }); + } + + @EventHandler + public void Use(PlayerToggleSneakEvent event) + { + if (event.isCancelled()) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + event.setCancelled(true); + + if (!player.getLocation().getBlock().isLiquid()) + return; + + if (!Recharge.Instance.use(player, GetName(), 500, false)) + return; + + //Velocity + UtilAction.velocity(player, 0.9, 0.2, 2, false); + + //Sound + player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.5f, 0.75f); + + _active.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void Reuse(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator swimIterator = _active.keySet().iterator(); + + while (swimIterator.hasNext()) + { + Player player = swimIterator.next(); + + if (UtilTime.elapsed(_active.get(player), 200)) + { + swimIterator.remove(); + continue; + } + + if (!player.getLocation().getBlock().isLiquid()) + continue; + + UtilAction.velocity(player, 0.9, 0.2, 2, false); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index b3171b2a3..c713a9081 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -598,7 +598,7 @@ public class GameFlagManager implements Listener if (!game.PrepareFreeze) return; - if (UtilMath.offset(event.getFrom(), event.getTo()) <= 0) + if (UtilMath.offset2d(event.getFrom(), event.getTo()) <= 0) return; event.getFrom().setPitch(event.getTo().getPitch()); 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 3ff368dda..adaaeb752 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 @@ -210,7 +210,7 @@ public class GameManager implements Listener @EventHandler public void KitRegister(GameStateChangeEvent event) { - if (event.GetState() != GameState.Live) + if (event.GetState() != event.GetGame().KitRegisterState) return; event.GetGame().RegisterKits(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java index 00207e573..594e25ae8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/FireworkHandler.java @@ -6,6 +6,7 @@ import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.entity.Firework; import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.util.Vector; public class FireworkHandler { @@ -57,4 +58,44 @@ public class FireworkHandler } return null; } + + public Firework launchFirework(Location loc, FireworkEffect fe, Vector dir) throws Exception + { + Firework fw = (Firework) loc.getWorld().spawn(loc, Firework.class); + + FireworkMeta data = (FireworkMeta) fw.getFireworkMeta(); + data.clearEffects(); + data.setPower(1); + data.addEffect(fe); + fw.setFireworkMeta(data); + + fw.setVelocity(dir); + + return fw; + } + + public void detonateFirework(Firework fw) throws Exception + { + Object nms_world = null; + Object nms_firework = null; + + + if(world_getHandle == null) + { + world_getHandle = getMethod(fw.getWorld().getClass(), "getHandle"); + firework_getHandle = getMethod(fw.getClass(), "getHandle"); + } + + nms_world = world_getHandle.invoke(fw.getWorld(), (Object[]) null); + nms_firework = firework_getHandle.invoke(fw, (Object[]) null); + + if(nms_world_broadcastEntityEffect == null) + { + nms_world_broadcastEntityEffect = getMethod(nms_world.getClass(), "broadcastEntityEffect"); + } + + nms_world_broadcastEntityEffect.invoke(nms_world, new Object[] {nms_firework, (byte) 17}); + + fw.remove(); + } } diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 5b4118376..d65e30e7d 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ