diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java index 7ea77ef52..f62a51da7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java @@ -1,16 +1,18 @@ package mineplex.core.progression; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.progression.data.KitAbilityDetail; import mineplex.core.progression.math.Calculations; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.UUID; /** * The API class all kits with the new system must use @@ -53,7 +55,7 @@ public interface ProgressiveKit * * @return The map of upgrades and their details */ - List getAbilityDetails(); + HashMap> getAbilityDetails(); /** * Retrieve the current level of this kit diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index a99565c9a..32535e00f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -5,8 +5,53 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.block.Chest; +import org.bukkit.block.DoubleChest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Egg; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; @@ -15,6 +60,7 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -23,9 +69,7 @@ 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.common.util.UtilTime.TimeUnit; import mineplex.core.explosion.ExplosionEvent; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.ChestLoot; import mineplex.core.loot.RandomItem; import mineplex.core.updater.UpdateType; @@ -38,15 +82,14 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.skywars.data.TNTGenerator; import nautilus.game.arcade.game.games.skywars.events.PlayerKillZombieEvent; -import nautilus.game.arcade.game.games.skywars.kits.KitChicken; -import nautilus.game.arcade.game.games.skywars.kits.KitDestructor; -import nautilus.game.arcade.game.games.skywars.kits.KitMiner; -import nautilus.game.arcade.game.games.skywars.kits.KitMadScientist; +import nautilus.game.arcade.game.games.skywars.kits.KitDevourer; +import nautilus.game.arcade.game.games.skywars.kits.KitGatherer; +import nautilus.game.arcade.game.games.skywars.kits.KitPricklyPete; +import nautilus.game.arcade.game.games.skywars.kits.KitRock; +import nautilus.game.arcade.game.games.skywars.kits.KitSharpshooter; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.stats.DeathBomberStatTracker; import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; @@ -54,55 +97,12 @@ import nautilus.game.arcade.stats.SkywarsTNTStatTracker; import nautilus.game.arcade.stats.WinWithoutOpeningChestStatTracker; import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.Chest; -import org.bukkit.block.DoubleChest; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Egg; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemDespawnEvent; -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.inventory.ItemStack; -import org.bukkit.util.Vector; - @SuppressWarnings("deprecation") public abstract class Skywars extends Game { //./parse 19 30 56 - private long _crumbleTime = 210000; + private long _crumbleTime = 150000; private ArrayList _worldBlocks = new ArrayList(); private HashSet _lootedBlocks = new HashSet(); @@ -112,10 +112,11 @@ public abstract class Skywars extends Game private NautHashMap _zombies = new NautHashMap(); private ArrayList _spawnChests = new ArrayList(); + private ArrayList _connectorChests = new ArrayList(); private ArrayList _middleChests = new ArrayList(); private HashMap _tntMap = new HashMap(); - private HashSet _pearls = new HashSet(); + private HashMap _pearlMap = new HashMap(); private long _lastChicken = 0; @@ -126,22 +127,41 @@ public abstract class Skywars extends Game private ChestLoot _playerTool = new ChestLoot(); private ChestLoot _playerProjectile = new ChestLoot(); private ChestLoot _playerBlock = new ChestLoot(); + private ChestLoot _playerMisc = new ChestLoot(); + + private ChestLoot _connectorArmor = new ChestLoot(); + private ChestLoot _connectorFood = new ChestLoot(); + private ChestLoot _connectorTool = new ChestLoot(); + private ChestLoot _connectorProjectile = new ChestLoot(); + private ChestLoot _connectorBlock = new ChestLoot(); + private ChestLoot _connectorMisc = new ChestLoot(); private ChestLoot _middleArmor = new ChestLoot(); private ChestLoot _middleFood = new ChestLoot(); private ChestLoot _middleTool = new ChestLoot(); private ChestLoot _middleProjectile = new ChestLoot(); private ChestLoot _middleBlock = new ChestLoot(); + private ChestLoot _middleBooks = new ChestLoot(); + private ChestLoot _middleMisc = new ChestLoot(); + + private Enchantment[] _armorEnchantments = new Enchantment[] { Enchantment.PROTECTION_ENVIRONMENTAL, Enchantment.PROTECTION_PROJECTILE, Enchantment.PROTECTION_FIRE, Enchantment.THORNS }; + private Enchantment[] _toolEnchantments = new Enchantment[] { Enchantment.DIG_SPEED, Enchantment.DURABILITY, Enchantment.LOOT_BONUS_BLOCKS }; + private Enchantment[] _swordEnchantments = new Enchantment[] { Enchantment.DAMAGE_ALL, Enchantment.FIRE_ASPECT, Enchantment.KNOCKBACK }; + private Enchantment[] _bowEnchantments = new Enchantment[] { Enchantment.ARROW_DAMAGE, Enchantment.ARROW_FIRE, Enchantment.ARROW_KNOCKBACK }; + private HashMap _commonBookEnchantments = new HashMap(); + private HashMap _rareBookEnchantments = new HashMap(); + @SuppressWarnings("unchecked") public Skywars(ArcadeManager manager, GameType type, String[] description) { super(manager, type, new Kit[] { - new KitChicken(manager), - new KitMiner(manager), - new KitMadScientist(manager), - new KitDestructor(manager), + new KitGatherer(manager), + new KitDevourer(manager), + new KitRock(manager), + new KitPricklyPete(manager), + new KitSharpshooter(manager) }, description); @@ -162,7 +182,7 @@ public abstract class Skywars extends Game QuitDropItems = true; WorldTimeSet = 0; - WorldBoundaryKill = false; + WorldBoundaryKill = true; DamageSelf = true; DamageTeamSelf = true; @@ -193,16 +213,38 @@ public abstract class Skywars extends Game }; + setupPlayerLoot(); + setupConnectorLoot(); + setupMiddleLoot(); + + setupBookEnchantments(); + setAlreadyAnnounced(false); + registerStatTrackers( + new SkywarsTNTStatTracker(this), + new DeathBomberStatTracker(this, 3), //TNT Kills + new SkywarsKillZombieStatTracker(this), + new WinWithoutOpeningChestStatTracker(this), + new WinWithoutWearingArmorStatTracker(this)); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageTaken, + DamageDealt + ); + } public void ParseData() { - setupPlayerLoot(); - setupMiddleLoot(); parseCreateZombieSpawns(); parseCreateMiddleChests(); + parseCreateConnectorChests(); parseCreatePlayerChests(); parseCreatePlayerWebs(); @@ -277,11 +319,11 @@ public abstract class Skywars extends Game private void parseCreateMiddleChests() { - for (int i=0 ; i<4 && !WorldData.GetDataLocs("YELLOW").isEmpty() ; i++) + for (int i=0 ; i<4 && !WorldData.GetDataLocs("BLACK").isEmpty() ; i++) { - Location loc = UtilAlg.Random(WorldData.GetDataLocs("YELLOW")); + Location loc = UtilAlg.Random(WorldData.GetDataLocs("BLACK")); - WorldData.GetDataLocs("YELLOW").remove(loc); + WorldData.GetDataLocs("BLACK").remove(loc); loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true); @@ -289,6 +331,21 @@ public abstract class Skywars extends Game _worldBlocks.add(loc.getBlock()); } } + + private void parseCreateConnectorChests() + { + for (int i=0 ; i<4 && !WorldData.GetDataLocs("GRAY").isEmpty() ; i++) + { + Location loc = UtilAlg.Random(WorldData.GetDataLocs("GRAY")); + + WorldData.GetDataLocs("GRAY").remove(loc); + + loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true); + + _connectorChests.add(loc.getBlock()); + _worldBlocks.add(loc.getBlock()); + } + } private void parseCreatePlayerChests() { @@ -367,10 +424,26 @@ public abstract class Skywars extends Game } } } + + private void setupBookEnchantments() + { + _commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 3); + _commonBookEnchantments.put(Enchantment.FIRE_ASPECT, 1); + _commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 3); + _commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + + _rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 4); + _rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 3); + _rareBookEnchantments.put(Enchantment.ARROW_FIRE, 1); + _rareBookEnchantments.put(Enchantment.FIRE_ASPECT, 2); + _rareBookEnchantments.put(Enchantment.ARROW_KNOCKBACK, 1); + _rareBookEnchantments.put(Enchantment.KNOCKBACK, 2); + _rareBookEnchantments.put(Enchantment.THORNS, 1); + } @EventHandler - public void blockUpdate(UpdateEvent event) + public void onUpdateCrumble(UpdateEvent event) { if (event.getType() != UpdateType.TICK) { @@ -435,6 +508,11 @@ public abstract class Skywars extends Game bestBlock.getLocation().add(0.5D, 0.5D, 0.5D), bestBlock.getType(), bestBlock.getData()); } + if(bestBlock.getType() == Material.WOODEN_DOOR || bestBlock.getType() == Material.IRON_DOOR_BLOCK) + { + MapUtil.QuickChangeBlockAt(bestBlock.getLocation().add(0, 1, 0), + Material.AIR); + } MapUtil.QuickChangeBlockAt(bestBlock.getLocation(), Material.AIR); } @@ -442,7 +520,7 @@ public abstract class Skywars extends Game } @EventHandler - public void createIslandChickens(UpdateEvent event) + public void onUpdateChickens(UpdateEvent event) { if (!IsLive()) return; @@ -473,9 +551,9 @@ public abstract class Skywars extends Game } @EventHandler - public void sandMapWarning(GameStateChangeEvent event) + public void onGameStateChangeMapWarning(GameStateChangeEvent event) { - if (event.GetState() != Game.GameState.Live) + if (event.GetState() != GameState.Live) return; if (WorldData.MapName.equals("Sahara")) @@ -485,9 +563,9 @@ public abstract class Skywars extends Game } @EventHandler - public void createIslandOres(GameStateChangeEvent event) + public void onGameStateChangeCreateOres(GameStateChangeEvent event) { - if (event.GetState() != Game.GameState.Prepare) + if (event.GetState() != GameState.Prepare) { return; } @@ -498,19 +576,21 @@ public abstract class Skywars extends Game // Allocate chests to their nearest spawn point for (Location oreLoc : WorldData.GetCustomLocs("56")) { - // Gets the spawn point closest to the current - Location closestOre = UtilAlg.findClosest(oreLoc, - GetTeamList().get(0).GetSpawns()); + for (GameTeam team : GetTeamList()) //This handles Team Skywars + { + // Gets the spawn point closest to the current + Location closestOre = UtilAlg.findClosest(oreLoc, team.GetSpawns()); - if (UtilMath.offset2d(oreLoc, closestOre) > 8) - continue; + if (UtilMath.offset2d(oreLoc, closestOre) > 8) + continue; + + // Ensure the list exists + if (!islandOres.containsKey(closestOre)) + islandOres.put(closestOre, new ArrayList()); - // Ensure the list exists - if (!islandOres.containsKey(closestOre)) - islandOres.put(closestOre, new ArrayList()); - - // Add this chest location to the spawn - islandOres.get(closestOre).add(oreLoc); + // Add this chest location to the spawn + islandOres.get(closestOre).add(oreLoc); + } } // Vein Counts @@ -554,7 +634,7 @@ public abstract class Skywars extends Game } @EventHandler - public void createRandomChests(GameStateChangeEvent event) + public void onGameStateChangeCreateChests(GameStateChangeEvent event) { if (event.GetState() != Game.GameState.Live) { @@ -630,7 +710,7 @@ public abstract class Skywars extends Game } @EventHandler - public void openChest(PlayerInteractEvent event) + public void onPlayerInteract(PlayerInteractEvent event) { if (event.isCancelled()) { @@ -668,18 +748,19 @@ public abstract class Skywars extends Game } @EventHandler - public void pickupTNT(PlayerPickupItemEvent e) + public void onPlayerPickupItem(PlayerPickupItemEvent e) { ItemStack is = e.getItem().getItemStack(); Player player = e.getPlayer(); if (is.getType() == Material.TNT) { - e.setCancelled(_tntGen.pickup(player, e.getItem())); + e.setCancelled(true); + _tntGen.pickup(player, e.getItem()); } } @EventHandler - public void onTNTThrow(PlayerInteractEvent e) + public void onPlayerInteractTNT(PlayerInteractEvent e) { if (!IsLive()) { @@ -720,23 +801,25 @@ public abstract class Skywars extends Game } @EventHandler - public void ItemDespawn(ItemDespawnEvent event) + public void onItemDespawn(ItemDespawnEvent event) { event.setCancelled(true); } @EventHandler - public void handleTNTCannon(UpdateEvent e) + public void onUpdateTNTCannon(UpdateEvent e) { if (!IsLive()) return; if (e.getType() == UpdateType.FAST) + { _tntGen.update(); + } } @EventHandler - public void zombieUpdate(UpdateEvent event) + public void onUpdateZombie(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; @@ -764,7 +847,7 @@ public abstract class Skywars extends Game } @EventHandler - public void zombieTarget(EntityTargetLivingEntityEvent event) + public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) { if (event.getTarget() != null && event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie)event.getEntity())) { @@ -780,61 +863,68 @@ public abstract class Skywars extends Game } @EventHandler - public void noZombieBurn(EntityCombustEvent e) + public void onEntityCombust(EntityCombustEvent event) { - if ((e.getEntity() instanceof Zombie)) + if ((event.getEntity() instanceof Zombie)) { - e.setDuration(0); - e.setCancelled(true); + event.setDuration(0); + event.setCancelled(true); } } @EventHandler - public void blockBurn(BlockBurnEvent event) + public void onBlockBurn(BlockBurnEvent event) { event.setCancelled(true); } @EventHandler - public void blockDecay(LeavesDecayEvent event) + public void onBlockDecay(LeavesDecayEvent event) { event.setCancelled(true); } @EventHandler - public void blockFade(BlockFadeEvent event) + public void onBlockFade(BlockFadeEvent event) { event.setCancelled(true); } @EventHandler - public void blockSpread(BlockSpreadEvent event) + public void onBlockSpread(BlockSpreadEvent event) { event.setCancelled(true); } @EventHandler - public void onBlockPlaceAdd(BlockPlaceEvent e) + public void onBlockPlaceAdd(BlockPlaceEvent event) { - _worldBlocks.add(e.getBlock()); + Material material = event.getBlock().getType(); + _worldBlocks.add(event.getBlock()); - if (e.getBlock().getType() == Material.CHEST || - e.getBlock().getType() == Material.PISTON_BASE || - e.getBlock().getType() == Material.PISTON_STICKY_BASE || - e.getBlock().getType() == Material.HOPPER) + if (material == Material.CHEST || + material == Material.PISTON_BASE || + material == Material.PISTON_STICKY_BASE || + material == Material.HOPPER) { - e.setCancelled(true); + event.setCancelled(true); } } + + @EventHandler + public void onBlockPhysics(BlockPhysicsEvent event) + { + _worldBlocks.add(event.getBlock()); + } @EventHandler - public void blockBonusDrops(BlockBreakEvent e) + public void onBlockBreakBonusDrops(BlockBreakEvent event) { - e.setExpToDrop(0); + event.setExpToDrop(0); - final Block block = e.getBlock(); + final Block block = event.getBlock(); - if (e.getBlock().getType() == Material.WEB) + if (block.getType() == Material.WEB) { Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { @@ -848,10 +938,10 @@ public abstract class Skywars extends Game } - if (e.getBlock().getType() == Material.GRAVEL) + if (block.getType() == Material.GRAVEL) { - e.setCancelled(true); - e.getBlock().setType(Material.AIR); + event.setCancelled(true); + block.setType(Material.AIR); Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { @@ -864,10 +954,10 @@ public abstract class Skywars extends Game }}, 1); } - if (e.getBlock().getType() == Material.IRON_ORE) + if (block.getType() == Material.IRON_ORE) { - e.setCancelled(true); - e.getBlock().setType(Material.AIR); + event.setCancelled(true); + block.setType(Material.AIR); Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { @@ -881,50 +971,43 @@ public abstract class Skywars extends Game } @EventHandler - public void onKillZombie(EntityDeathEvent e) + public void onEntityDeathZombie(EntityDeathEvent event) { - if (e.getEntity() instanceof Zombie) + if (event.getEntity() instanceof Zombie) { - Zombie ent = (Zombie) e.getEntity(); + Zombie ent = (Zombie) event.getEntity(); if (_zombies.containsKey(ent)) { if (ent.getKiller() instanceof Player) { - Player p = ent.getKiller(); + Player player = ent.getKiller(); Bukkit.getPluginManager().callEvent( - new PlayerKillZombieEvent(p, ent)); + new PlayerKillZombieEvent(player, ent)); } } } - else - { - return; - } } @EventHandler - public void blockBreak(BlockBreakEvent e) + public void onBlockBreakTNTSpawner(BlockBreakEvent event) { - if (e.getBlock().getType() == Material.IRON_BLOCK) + Material material = event.getBlock().getType(); + if (material == Material.IRON_BLOCK || material == Material.REDSTONE_BLOCK) { - e.setCancelled(true); - } - if (e.getBlock().getType() == Material.REDSTONE_BLOCK) - { - e.setCancelled(true); + event.setCancelled(true); } } @EventHandler - public void disableDamageToLevel(CustomDamageEvent event) + public void onCustomDamageToLevel(CustomDamageEvent event) { event.SetDamageToLevel(false); } @EventHandler - public void mobLoot(EntityDeathEvent event) + public void onEntityDeathMobLoot(EntityDeathEvent event) { //Zombie Loot if (event.getEntity() instanceof Zombie && _zombies.containsKey((Zombie)event.getEntity())) @@ -948,7 +1031,7 @@ public abstract class Skywars extends Game } @EventHandler - public void eggHit(CustomDamageEvent event) + public void onCustomDamageEgg(CustomDamageEvent event) { if (event.GetProjectile() == null) return; @@ -986,7 +1069,7 @@ public abstract class Skywars extends Game } @EventHandler - public void projectile(EntityDamageByEntityEvent event) + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if(event.getDamager() instanceof Snowball || event.getDamager() instanceof Egg || event.getDamager() instanceof EnderPearl) { @@ -1023,7 +1106,14 @@ public abstract class Skywars extends Game { //Armor for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _playerArmor.getLoot()); + { + ItemStack itemStack = _playerArmor.getLoot(); + if (UtilMath.r(3) == 0) + { + itemStack.addEnchantment(_armorEnchantments[UtilMath.r(_armorEnchantments.length - 1)], UtilMath.r(2) + 1); + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } //Food for (int i=0 ; i<1 + UtilMath.r(3) ; i++) @@ -1031,7 +1121,25 @@ public abstract class Skywars extends Game //Tool for (int i=0 ; i<1 + UtilMath.r(2) ; i++) - chest.getBlockInventory().setItem(getIndex(used), _playerTool.getLoot()); + { + ItemStack itemStack = _playerTool.getLoot(); + if (UtilMath.r(3) == 0) + { + if (UtilItem.isSword(itemStack)) + { + itemStack.addEnchantment(_swordEnchantments[UtilMath.r(_swordEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (itemStack.getType() == Material.BOW) + { + itemStack.addEnchantment(_bowEnchantments[UtilMath.r(_bowEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (UtilItem.isTool(itemStack)) + { + itemStack.addEnchantment(_toolEnchantments[UtilMath.r(_toolEnchantments.length - 1)], UtilMath.r(2) + 1); + } + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } //Projectile for (int i=0 ; i<1 + UtilMath.r(2) ; i++) @@ -1040,9 +1148,65 @@ public abstract class Skywars extends Game //Block for (int i=0 ; i<1 + UtilMath.r(2) ; i++) chest.getBlockInventory().setItem(getIndex(used), _playerBlock.getLoot()); + + //Misc + for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + chest.getBlockInventory().setItem(getIndex(used), _playerMisc.getLoot()); } - //Other - else if (_middleChests.contains(block)) + //Connector + else if (_connectorChests.contains(block)) + { + //Armor + for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + { + ItemStack itemStack = _connectorArmor.getLoot(); + if (UtilMath.r(3) == 0) + { + itemStack.addEnchantment(_armorEnchantments[UtilMath.r(_armorEnchantments.length - 1)], UtilMath.r(2) + 1); + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } + + //Food + for (int i=0 ; i<1 + UtilMath.r(3) ; i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorFood.getLoot()); + + //Tool + for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + { + ItemStack itemStack = _connectorTool.getLoot(); + if (UtilMath.r(3) == 0) + { + if (UtilItem.isSword(itemStack)) + { + itemStack.addEnchantment(_swordEnchantments[UtilMath.r(_swordEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (UtilItem.isTool(itemStack)) + { + itemStack.addEnchantment(_toolEnchantments[UtilMath.r(_toolEnchantments.length - 1)], UtilMath.r(2) + 1); + } + else if (itemStack.getType() == Material.BOW) + { + itemStack.addEnchantment(_bowEnchantments[UtilMath.r(_bowEnchantments.length - 1)], UtilMath.r(2) + 1); + } + } + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } + + //Projectile + for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorProjectile.getLoot()); + + //Block + for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorBlock.getLoot()); + + //Misc + for (int i=0 ; i<1 + UtilMath.r(2) ; i++) + chest.getBlockInventory().setItem(getIndex(used), _connectorMisc.getLoot()); + } + //Middle + else { //Armor for (int i=0 ; i<1 + UtilMath.r(2) ; i++) @@ -1063,28 +1227,33 @@ public abstract class Skywars extends Game //Block for (int i=0 ; i<1 + UtilMath.r(2) ; i++) chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot()); - } - else - { - //Armor - for (int i=0 ; i blocks = event.GetBlocks().iterator(); + + while (blocks.hasNext()) + { + Block block = blocks.next(); + if (block.getType() == Material.CHEST || block.getType() == Material.ANVIL) + { + blocks.remove(); + } + } + } + + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent event) + { + if (event.getBlock().getType() == Material.ANVIL) + { + event.setCancelled(true); + } } @EventHandler(priority = EventPriority.MONITOR) - public void OreReveal(BlockBreakEvent event) + public void onBlockBreakOreReveal(BlockBreakEvent event) { if (event.isCancelled()) return; @@ -1219,7 +1457,7 @@ public abstract class Skywars extends Game } @EventHandler - public void tntDamageAttribute(ExplosionPrimeEvent event) + public void onExplosionPrime(ExplosionPrimeEvent event) { Player player = _tntMap.get(event.getEntity()); if (player != null) @@ -1232,7 +1470,7 @@ public abstract class Skywars extends Game } @EventHandler - public void pearlRide(ProjectileLaunchEvent event) + public void onProjectileLaunch(ProjectileLaunchEvent event) { if (!IsLive()) return; @@ -1248,46 +1486,43 @@ public abstract class Skywars extends Game Player shooter = (Player)event.getEntity().getShooter(); - if (event.getEntity().hasMetadata("Destructor")) - return; - - event.getEntity().setPassenger(shooter); - - _pearls.add(event.getEntity()); - - ((CraftPlayer)shooter).getHandle().spectating = true; + _pearlMap.put(event.getEntity(), shooter); } @EventHandler - public void pearlUpdate(UpdateEvent event) + public void onProjectileHit(ProjectileHitEvent event) + { + if (_pearlMap.get(event.getEntity()) == null) + { + return; + } + + Player player = _pearlMap.get(event.getEntity()); + Location playerLocation = player.getLocation(); + Location entityLocation = event.getEntity().getLocation(); + float yaw = playerLocation.getYaw(); + float pitch = playerLocation.getPitch(); + + player.setFallDistance(0); + player.teleport(new Location(player.getWorld(), entityLocation.getX(), entityLocation.getY(), entityLocation.getZ(), yaw, pitch)); + + _pearlMap.remove(event.getEntity()); + } + + @EventHandler + public void onUpdatePeral(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - //Disable Spec - for (Player player : GetPlayers(true)) - if (((CraftPlayer)player).getHandle().spectating && player.getVehicle() == null) - ((CraftPlayer)player).getHandle().spectating = false; - - Iterator pearlIter = _pearls.iterator(); - - while (pearlIter.hasNext()) - { - Projectile proj = pearlIter.next(); - - if (!proj.isValid()) - { - proj.remove(); - pearlIter.remove(); - continue; - } - - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, proj.getLocation(), 0f, 0f, 0f, 0f, 1, ViewDist.MAX, UtilServer.getPlayers()); + for (Entity entity : _pearlMap.keySet()) + { + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, entity.getLocation(), 0f, 0f, 0f, 0f, 1, ViewDist.MAX, UtilServer.getPlayers()); } } @EventHandler - public void killLevelReward(CombatDeathEvent event) + public void onCombatDeathEventLevels(CombatDeathEvent event) { Game game = Manager.GetGame(); if (game == null) return; @@ -1332,8 +1567,16 @@ public abstract class Skywars extends Game { if (assist) return 3; - else - return 12; + return 12; + } + + @EventHandler + public void onCommand(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().startsWith("/crumble")) + { + _crumbleTime = 1000; + } } public TNTGenerator getTnTGen() @@ -1351,6 +1594,11 @@ public abstract class Skywars extends Game return _spawnChests; } + public ArrayList getConnectorChests() + { + return _connectorChests; + } + public ArrayList getMiddleChests() { return _middleChests; @@ -1361,4 +1609,5 @@ public abstract class Skywars extends Game return _lootedBlocks; } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java index a77873967..e2eff233c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java @@ -17,7 +17,6 @@ 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.Game.GameState; import nautilus.game.arcade.stats.DeathBomberStatTracker; import nautilus.game.arcade.stats.SkywarsKillZombieStatTracker; import nautilus.game.arcade.stats.SkywarsTNTStatTracker; @@ -29,6 +28,7 @@ public class SoloSkywars extends Skywars private GameTeam _players; + @SuppressWarnings("unchecked") public SoloSkywars(ArcadeManager manager) { this(manager, GameType.Skywars); @@ -51,6 +51,7 @@ public class SoloSkywars extends Skywars ); } + @SuppressWarnings("unchecked") public SoloSkywars(ArcadeManager manager, GameType type) { super(manager, type, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitChicken.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitChicken.java deleted file mode 100644 index 058875fc6..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitChicken.java +++ /dev/null @@ -1,47 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkChicken; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitChicken extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "BAWK BAWK. Eggs!", - "", - "Get a chicken that follows you around", - "And lays eggs every " + C.cGreen + 8 + C.cWhite + " seconds!" - }; - - private static final Perk[] PERKS = { - new PerkChicken() - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.EGG); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE), - ItemStackFactory.Instance.CreateStack(Material.WOOD_PICKAXE) - }; - - - public KitChicken(ArcadeManager manager) - { - super(manager, "Chicken Farmer", "skywarschickenfarmer", KitAvailability.Free, 0, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - ((PerkChicken) PERKS[0]).spawnChicken(player, player.getLocation()); - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDestructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDestructor.java deleted file mode 100644 index a735ffbcd..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDestructor.java +++ /dev/null @@ -1,58 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.achievement.Achievement; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkDestructor; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitDestructor extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "Your Ender Pearls make the world crumble!", - "", - receiveItem("Seismic Charge", 1, 40, 2), - C.cYellow + "Right-Click" + C.cWhite + " with Seismic Charge to " + C.cGreen + "Throw Seismic Charge", - }; - - private static final Perk[] PERKS = { - new PerkDestructor(40, 2, 2500, true) - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.ENDER_PEARL); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE), - ItemStackFactory.Instance.CreateStack(Material.WOOD_PICKAXE) - }; - - private static final Achievement[] ACHIEVEMENTS = { - Achievement.SKYWARS_BOMBER, - Achievement.SKYWARS_NOARMOR, - Achievement.SKYWARS_NOCHEST, - Achievement.SKYWARS_PLAYER_KILLS, - Achievement.SKYWARS_TNT, - Achievement.SKYWARS_WINS, - Achievement.SKYWARS_ZOMBIE_KILLS - }; - - public KitDestructor(ArcadeManager manager) - { - super(manager, "Destructor", "skywarsdestructor", KitAvailability.Achievement, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - - this.setAchievementRequirements(ACHIEVEMENTS); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDevourer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDevourer.java new file mode 100644 index 000000000..99f5f215d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitDevourer.java @@ -0,0 +1,80 @@ +package nautilus.game.arcade.game.games.skywars.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 nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkArmorUpgrade; + +public class KitDevourer extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "25 Cobblestone", + "", + "Each kill upgrades your lowest armor piece by 1 tier" + }; + + private static final Perk[] PERKS = { + new PerkArmorUpgrade() + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.COBBLESTONE, 25) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.OBSIDIAN); + + public KitDevourer(ArcadeManager manager) + { + super(manager, "Devourer", "skywarsdevourer", KitAvailability.Gem, 4000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); + setPerks(PERKS); + } + + @Override + public void GiveItems(Player player) + { + int level = getUpgradeLevel(player.getUniqueId()); + + switch (level) + { + case 0: + player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); + break; + case 1: + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + break; + case 2: + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + player.getInventory().addItem(new ItemStack(Material.GOLD_BOOTS)); + break; + case 3: + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + player.getInventory().addItem(new ItemStack(Material.GOLD_BOOTS)); + player.getInventory().addItem(new ItemStack(Material.GOLD_HELMET)); + break; + case 4: + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + player.getInventory().addItem(new ItemStack(Material.GOLD_BOOTS)); + player.getInventory().addItem(new ItemStack(Material.GOLD_HELMET)); + player.getInventory().addItem(new ItemStack(Material.GOLD_LEGGINGS)); + break; + case 5: + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + player.getInventory().addItem(new ItemStack(Material.GOLD_BOOTS)); + player.getInventory().addItem(new ItemStack(Material.GOLD_HELMET)); + player.getInventory().addItem(new ItemStack(Material.GOLD_LEGGINGS)); + player.getInventory().addItem(new ItemStack(Material.GOLD_CHESTPLATE)); + break; + } + + player.getInventory().addItem(PLAYER_ITEMS); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitGatherer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitGatherer.java new file mode 100644 index 000000000..4c6c58734 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitGatherer.java @@ -0,0 +1,97 @@ +package nautilus.game.arcade.game.games.skywars.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.C; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkIncreaseOre; + +public class KitGatherer extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Pickaxe" + C.cGray + " and " + C.cGreen + "Wood Sword", + "", + "Each ore mined drops double" + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.WOOD_SWORD) + }; + + private static final Material[] TYPES = { + Material.COAL_ORE, + Material.GOLD_ORE, + Material.IRON_ORE, + }; + + private static final Material[] TYPES_5 = { + Material.COAL_ORE, + Material.GOLD_ORE, + Material.IRON_ORE, + Material.DIAMOND_ORE, + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.WOOD_PICKAXE); + + public KitGatherer(ArcadeManager manager) + { + super(manager, "Gatherer", "skywarsgartherer", KitAvailability.Free, DESCRIPTION, new Perk[] { new PerkIncreaseOre(1, TYPES) }, EntityType.ZOMBIE, IN_HAND); + + for (int i = 0; i < 5; i++) + { + setPerks(i, new Perk[] { new PerkIncreaseOre(1, TYPES) }); + } + + setPerks(5, new Perk[] { new PerkIncreaseOre(1, TYPES_5) }); + setOtherPerks(2, "Gain Haste I"); + setOtherPerks(3, "Gain Haste I"); + setOtherPerks(4, "Gain Haste II"); + setOtherPerks(5, "Gain Haste III", "Diamond ore drops double"); + } + + @Override + public void GiveItems(Player player) + { + int level = getUpgradeLevel(player.getUniqueId()); + + player.getInventory().addItem(PLAYER_ITEMS); + + switch (level) + { + case 0: + player.getInventory().addItem(new ItemStack(Material.WOOD_PICKAXE)); + break; + case 1: + player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); + break; + case 2: + player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 0)); + break; + case 3: + player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE)); + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 0)); + break; + case 4: + player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE)); + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 1)); + break; + case 5: + player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE)); + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 2)); + break; + default: + break; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMadScientist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMadScientist.java deleted file mode 100644 index 7ebca6b01..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMadScientist.java +++ /dev/null @@ -1,45 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkMadScientist; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitMadScientist extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "Spawn crazy animals to fight for you!", - "", - receiveItem("Egg", 1, 90, 3), - "Eggs spawn a loyal minion to fight for you", - }; - - private static final Perk[] PERKS = { - new PerkMadScientist() - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.MONSTER_EGG); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE), - ItemStackFactory.Instance.CreateStack(Material.WOOD_PICKAXE) - }; - - public KitMadScientist(ArcadeManager manager) - { - super(manager, "Mad Scientist", "skywarsmadscientist", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMiner.java deleted file mode 100644 index 8d1e5946f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMiner.java +++ /dev/null @@ -1,45 +0,0 @@ -package nautilus.game.arcade.game.games.skywars.kits; - -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import nautilus.game.arcade.kit.perks.PerkDigger; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class KitMiner extends ProgressingKit -{ - private static final String[] DESCRIPTION = { - "Start with better tools!", - "", - "Receive " + C.cGreen + "Haste II" + C.cWhite + " the entire game" - }; - - private static final Perk[] PERKS = { - new PerkDigger(), - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.IRON_PICKAXE); - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_AXE), - ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE) - }; - - - public KitMiner(ArcadeManager manager) - { - super(manager, "Miner", "skywarsminer", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitPricklyPete.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitPricklyPete.java new file mode 100644 index 000000000..061e5dafd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitPricklyPete.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.skywars.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 nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkThorns; + +public class KitPricklyPete extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Pickaxe" + C.cGray + " and " + C.cGreen + "Wood Sword", + "", + "Each armor piece reflects 0.5 damage per hit every 10 seconds" + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.WOOD_PICKAXE), + new ItemStack(Material.WOOD_SWORD) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.CACTUS); + + public KitPricklyPete(ArcadeManager manager) + { + super(manager, "Prickly Pete", "skywarspricklypete", KitAvailability.Gem, 4000, DESCRIPTION, new Perk[] { new PerkThorns(0.5, 10) }, EntityType.ZOMBIE, IN_HAND); + setPerks(1, new Perk[] { new PerkThorns(1, 10) }); + setPerks(2, new Perk[] { new PerkThorns(1, 9) }); + setPerks(3, new Perk[] { new PerkThorns(1.5, 9) }); + setPerks(4, new Perk[] { new PerkThorns(1.5, 8) }); + setPerks(5, new Perk[] { new PerkThorns(2, 8) }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitRock.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitRock.java new file mode 100644 index 000000000..ae0deeb08 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitRock.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.skywars.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 nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkIronSkin; + +public class KitRock extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Pickaxe" + C.cGray + " and " + C.cGreen + "Wood Sword", + "", + "Take 0.1 less damage from all attacks" + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.WOOD_PICKAXE), + new ItemStack(Material.WOOD_SWORD) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.STONE); + + public KitRock(ArcadeManager manager) + { + super(manager, "The Rock", "skywarsrock", KitAvailability.Gem, 4000, DESCRIPTION, new Perk[] { new PerkIronSkin(0.1) }, EntityType.ZOMBIE, IN_HAND); + setPerks(1, new Perk[] { new PerkIronSkin(0.15) }); + setPerks(2, new Perk[] { new PerkIronSkin(0.2) }); + setPerks(3, new Perk[] { new PerkIronSkin(0.25) }); + setPerks(4, new Perk[] { new PerkIronSkin(0.3) }); + setPerks(5, new Perk[] { new PerkIronSkin(0.35) }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitSharpshooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitSharpshooter.java new file mode 100644 index 000000000..3e10cd60e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitSharpshooter.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.skywars.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 nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkFletcher; + +public class KitSharpshooter extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Start with " + C.cGreen + "Wood Pickaxe" + C.cGray + " and " + C.cGreen + "Bow", + "", + receiveArrowString(1, 12, 64) + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.WOOD_PICKAXE), + new ItemStack(Material.BOW) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BOW); + + public KitSharpshooter(ArcadeManager manager) + { + super(manager, "Sharpshooter", "skywarssharpshooter", KitAvailability.Gem, 4000, DESCRIPTION, new Perk[] { new PerkFletcher(12, 64, true, false) }, EntityType.ZOMBIE, IN_HAND); + setPerks(1, new Perk[] { new PerkFletcher(11, 64, true, false) }); + setPerks(2, new Perk[] { new PerkFletcher(10, 64, true, false) }); + setPerks(3, new Perk[] { new PerkFletcher(9, 64, true, false) }); + setPerks(4, new Perk[] { new PerkFletcher(8, 64, true, false) }); + setPerks(5, new Perk[] { new PerkFletcher(7, 64, true, false) }); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 4985238d4..1b4d579e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -1,6 +1,29 @@ package nautilus.game.arcade.kit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Firework; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.scheduler.BukkitRunnable; + import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + import mineplex.core.common.CurrencyType; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -22,27 +45,13 @@ import nautilus.game.arcade.shop.KitPackage; import net.minecraft.server.v1_8_R3.EntityFireworks; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; import net.minecraft.server.v1_8_R3.World; -import org.bukkit.*; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Firework; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; /** * Kit wrapper for all new kits */ public abstract class ProgressingKit extends Kit implements ProgressiveKit { - + private static final FireworkEffect EFFECT = FireworkEffect.builder() .withColor(Color.AQUA) .with(Type.BALL) @@ -50,18 +59,23 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit private String _internalName; private PlayerKitDataManager _dataManager; - private List _kitAbilityDetails; + private HashMap> _kitAbilityDetails; + private Perk[][] _perks; public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) { super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand); _internalName = internalName; _dataManager = manager.getKitProgressionManager().getDataManager(); - _kitAbilityDetails = Lists.newArrayList(); + _kitAbilityDetails = Maps.newHashMap(); + _perks = new Perk[6][kitPerks.length]; + + ArrayList details = Lists.newArrayList(); for (Perk perk : kitPerks) { - _kitAbilityDetails.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); + details.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); } + _kitAbilityDetails.put(0, details); } public ProgressingKit(ArcadeManager manager, String name, String internalName, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) @@ -69,11 +83,15 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); _internalName = internalName; _dataManager = manager.getKitProgressionManager().getDataManager(); - _kitAbilityDetails = Lists.newArrayList(); + _kitAbilityDetails = Maps.newHashMap(); + _perks = new Perk[6][kitPerks.length]; + + ArrayList details = Lists.newArrayList(); for (Perk perk : kitPerks) { - _kitAbilityDetails.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); + details.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); } + _kitAbilityDetails.put(0, details); } @@ -102,7 +120,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit } @Override - public List getAbilityDetails() + public HashMap> getAbilityDetails() { return _kitAbilityDetails; } @@ -320,6 +338,39 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit } return false; } + + public void setPerks(int level, Perk[] perks) + { + _perks[level] = perks; + ArrayList details = Lists.newArrayList(); + for (Perk perk : perks) + { + details.add(new KitAbilityDetail(perk.getIcon(), perk.GetName(), perk.GetDesc())); + perk.SetHost(this); + } + _kitAbilityDetails.put(level, details); + } + + public void setPerks(Perk[] perks) + { + for (int i = 1; i <= 5; i++) + { + setPerks(i, perks); + } + } + + public void setOtherPerks(int level, String... detail) + { + ArrayList details = _kitAbilityDetails.get(level); + //details.add(new KitAbilityDetail(getIcon(), KitMenu.OTHER_PERK_META, detail)); + _kitAbilityDetails.put(level, details); + } + + + public Perk[][] getPerks() + { + return _perks; + } public static String leap() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArmorUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArmorUpgrade.java new file mode 100644 index 000000000..4946c6d15 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArmorUpgrade.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilItem.ArmorMaterial; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkArmorUpgrade extends Perk +{ + + private static final ArmorMaterial[] ARMOR_PRIORTY = new ArmorMaterial[] { + ArmorMaterial.LEATHER, + ArmorMaterial.GOLD, + ArmorMaterial.CHAINMAIL, + ArmorMaterial.IRON, + ArmorMaterial.DIAMOND + }; + + public PerkArmorUpgrade() + { + super("Armor Upgrade", new String[] { "Every time you kill a player your weakest piece of armor is upgrade by 1 tier" }); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDeath(CombatDeathEvent event) + { + LivingEntity player = event.GetEvent().getEntity().getKiller(); + + if (!(player instanceof Player)) + { + return; + } + + if (!Kit.HasKit((Player) player)) + { + return; + } + + ItemStack[] armorContents = player.getEquipment().getArmorContents(); + ItemStack worstItem = null; + int worst = ARMOR_PRIORTY.length - 1; + int index = 0; + + for (int i = 0; i < armorContents.length; i++) + { + ItemStack itemStack = armorContents[i]; + + if (!UtilItem.isArmor(itemStack)) + { + continue; + } + + int cur = getIndex(ArmorMaterial.of(itemStack.getType())); + if (cur <= worst) + { + worstItem = itemStack; + worst = cur; + index = i; + } + } + + if (worst == ARMOR_PRIORTY.length - 1) + { + return; + } + + String worstItemPart = worstItem.getType().name().split("_")[1]; + String worstItemTier = ARMOR_PRIORTY[worst].name(); + String newItemTier = ARMOR_PRIORTY[worst + 1].name(); + worstItem = new ItemStack(Material.valueOf(newItemTier + "_" + worstItemPart)); + armorContents[index] = worstItem; + player.getEquipment().setArmorContents(armorContents); + player.sendMessage(F.main("Skill", "Your " + C.mSkill + formatItem(worstItemTier, worstItemPart) + C.cGray + " just upgraded to " + C.mSkill + formatItem(newItemTier, worstItemPart) + C.cGray + " by " + C.mSkill + "Armor Upgrade" + C.cGray + ".")); + } + + private int getIndex(ArmorMaterial armorMaterial) + { + for (int i = 0; i < ARMOR_PRIORTY.length; i++) + { + ArmorMaterial armorMaterial2 = ARMOR_PRIORTY[i]; + if (armorMaterial == armorMaterial2) + return i; + } + return 0; + } + + private String formatItem(String tier, String part) + { + return Character.toUpperCase(tier.charAt(0)) + tier.substring(1).toLowerCase() + " " + Character.toUpperCase(part.charAt(0)) + part.substring(1).toLowerCase(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java index f52eaf0c8..0d66a2957 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java @@ -3,12 +3,12 @@ package nautilus.game.arcade.kit.perks; import java.util.HashSet; import java.util.Iterator; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -37,23 +37,35 @@ public class PerkFletcher extends Perk private int _time = 0; private boolean _remove; private int _slot; + private boolean _instant = true; public PerkFletcher(int time, int max, boolean remove) { this(time, max, remove, -1); } + public PerkFletcher(int time, int max, boolean remove, boolean instant) + { + this(time, max, remove, -1, instant); + } + public PerkFletcher(int time, int max, boolean remove, int slot) + { + this(time, max, remove, slot, true); + } + + public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant) { super("Fletcher", new String[] { - C.cGray + "Receive 1 Arrow every " + time + " seconds. Maximum of " + max + ".", + "Receive 1 Arrow every " + time + " seconds. Maximum of " + max + ".", }); _time = time; _max = max; _remove = remove; _slot = slot; + _instant = instant; } public boolean isFletchedArrow(ItemStack stack) @@ -106,7 +118,12 @@ public class PerkFletcher extends Perk { if (event.getType() != UpdateType.FAST) return; - + + if (!UtilTime.elapsed(Manager.GetGame().getGameLiveTime(), _time * 1000) && !_instant) + { + return; + } + for (Player cur : UtilServer.getPlayers()) { if (Manager.isSpectator(cur)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIncreaseOre.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIncreaseOre.java new file mode 100644 index 000000000..285d074a3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIncreaseOre.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.kit.perks; + +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.inventory.ItemStack; + +public class PerkIncreaseOre extends Perk +{ + + private int extra; + private Material[] type; + + public PerkIncreaseOre(int extra, Material[] type) + { + super("Lucky Miner", new String[] { "Every ore you mine drops another " + extra + " extra" }); + this.extra = extra; + this.type = type; + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onBlockBreak(BlockBreakEvent event) + { + if (!Kit.HasKit(event.getPlayer())) + { + return; + } + + Block block = event.getBlock(); + boolean contains = false; + + for (Material type : this.type) + { + if (block.getType() == type) + { + contains = true; + break; + } + } + + if (!contains) + { + return; + } + + String type = block.getType() == Material.DIAMOND_ORE || block.getType() == Material.COAL_ORE ? block.getType().name().split("_")[0] : block.getType().name().split("_")[0] + "_INGOT"; + + for (int i = 0; i < extra; i++) + { + event.getBlock().getWorld().dropItem(block.getLocation(), new ItemStack(Material.valueOf(type))); + } + } + + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java index b1eafb953..ec662a740 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java @@ -5,7 +5,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import mineplex.core.common.util.C; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; @@ -17,7 +16,7 @@ public class PerkIronSkin extends Perk { super("Iron Skin", new String[] { - C.cGray + "You take " + d + " less damage from attacks", + "You take " + d + " less damage from attacks", }); _reduction = d; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThorns.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThorns.java new file mode 100644 index 000000000..057cf620d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkThorns.java @@ -0,0 +1,65 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkThorns extends Perk +{ + + private double _damage; + private double _cooldown; + + public PerkThorns(double damage, double cooldown) + { + super("Thorns", new String[] { "For each piece of armor you equip you reflect " + damage, "Cooldown of " + cooldown + " seconds" }); + this._damage = damage; + this._cooldown = cooldown; + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!Kit.HasKit(event.GetDamageePlayer())) + { + return; + } + + if (event.GetCause() == DamageCause.FALL || event.GetCause() == DamageCause.PROJECTILE) + { + return; + } + + if(!Recharge.Instance.use(event.GetDamageePlayer(), "Thorns", (long) _cooldown * 1000, false, false)) + return; + + double totalDamage = 0; + + for (ItemStack itemStack : event.GetDamageeEntity().getEquipment().getArmorContents()) + { + if (itemStack == null || itemStack.getType() == Material.AIR) + { + continue; + } + + totalDamage += _damage; + } + + if (totalDamage == 0) + { + return; + } + + Manager.GetDamage().NewDamageEvent(event.GetDamagerEntity(false), event.GetDamageeEntity(), event.GetProjectile(), DamageCause.THORNS, totalDamage * 2, false, true, true, event.GetDamageeEntity().getName(), "Thorns"); + event.GetDamagerPlayer(false).sendMessage(F.main("Skill", C.cYellow + event.GetDamageeEntity().getName() + C.cGray + " used" + C.mSkill + " Thorns" + C.cGray + ".")); + event.GetDamageePlayer().sendMessage(F.main("Skill", "You used" + C.mSkill + " Thorns" + C.cGray + " on " + C.cYellow + event.GetDamagerEntity(false).getName() + C.cGray + ".")); + } + +}