diff --git a/Dev Builds/Korra.jar b/Dev Builds/Korra.jar index 7d9ed38d..f4569308 100644 Binary files a/Dev Builds/Korra.jar and b/Dev Builds/Korra.jar differ diff --git a/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java b/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java index da126aa5..ddeccd37 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java +++ b/src/com/projectkorra/ProjectKorra/Ability/AbilityModuleManager.java @@ -103,6 +103,7 @@ public class AbilityModuleManager { if (a == StockAbilities.EarthTunnel) shiftabilities.add(a.name()); if (a == StockAbilities.EarthArmor) shiftabilities.add(a.name()); if (a == StockAbilities.EarthGrab) shiftabilities.add(a.name()); + if (a == StockAbilities.Extraction) metalbendingabilities.add(a.name()); } } else if (StockAbilities.isFirebending(a)) { diff --git a/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java b/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java index 055ca899..dc5b985c 100644 --- a/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java +++ b/src/com/projectkorra/ProjectKorra/Ability/StockAbilities.java @@ -4,7 +4,7 @@ public enum StockAbilities { AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, - Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, + Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction, HeatControl, Blaze, FireJet, Illumination, WallOfFire, FireBlast, Lightning, FireBurst, FireShield, @@ -23,7 +23,7 @@ public enum StockAbilities { } private enum EarthbendingAbilities { - Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave; + Catapult, RaiseEarth, EarthGrab, EarthTunnel, EarthBlast, Collapse, Tremorsense, EarthArmor, Shockwave, Extraction; } private enum FirebendingAbilities { diff --git a/src/com/projectkorra/ProjectKorra/ConfigManager.java b/src/com/projectkorra/ProjectKorra/ConfigManager.java index 9d3c22a1..7605d451 100644 --- a/src/com/projectkorra/ProjectKorra/ConfigManager.java +++ b/src/com/projectkorra/ProjectKorra/ConfigManager.java @@ -321,6 +321,12 @@ public class ConfigManager { config.addDefault("Abilities.Earth.EarthTunnel.Radius", 0.25); config.addDefault("Abilities.Earth.EarthTunnel.Revert", true); config.addDefault("Abilities.Earth.EarthTunnel.Interval", 30); + + config.addDefault("Abilities.Earth.Extraction.Enabled", true); + config.addDefault("Abilities.Earth.Extraction.Description", "This ability allows metalbenders to extract the minerals from ore blocks. To use, simply tap sneak while looking at an ore block with metal in it (iron, gold, quartz) and the ore will be extracted and drop in front of you. This ability has a small chance of doubling or tripling the loot. This ability has a short cooldown."); + config.addDefault("Abilities.Earth.Extraction.Cooldown", 10000); + config.addDefault("Abilities.Earth.Extraction.TripleLootChance", 15); + config.addDefault("Abilities.Earth.Extraction.DoubleLootChance", 40); config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true); config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. " diff --git a/src/com/projectkorra/ProjectKorra/PKListener.java b/src/com/projectkorra/ProjectKorra/PKListener.java index fe7b19a9..d23032bb 100644 --- a/src/com/projectkorra/ProjectKorra/PKListener.java +++ b/src/com/projectkorra/ProjectKorra/PKListener.java @@ -75,6 +75,7 @@ import com.projectkorra.ProjectKorra.earthbending.EarthGrab; import com.projectkorra.ProjectKorra.earthbending.EarthPassive; import com.projectkorra.ProjectKorra.earthbending.EarthTunnel; import com.projectkorra.ProjectKorra.earthbending.EarthWall; +import com.projectkorra.ProjectKorra.earthbending.Extraction; import com.projectkorra.ProjectKorra.earthbending.Shockwave; import com.projectkorra.ProjectKorra.earthbending.Tremorsense; import com.projectkorra.ProjectKorra.firebending.ArcOfFire; @@ -298,6 +299,10 @@ public class PKListener implements Listener { if (abil.equalsIgnoreCase("Tremorsense")) { Methods.getBendingPlayer(player.getName()).toggleTremorsense(); } + + if (abil.equalsIgnoreCase("Extraction")) { + new Extraction(player); + } } diff --git a/src/com/projectkorra/ProjectKorra/earthbending/Extraction.java b/src/com/projectkorra/ProjectKorra/earthbending/Extraction.java new file mode 100644 index 00000000..18e19147 --- /dev/null +++ b/src/com/projectkorra/ProjectKorra/earthbending/Extraction.java @@ -0,0 +1,91 @@ +package com.projectkorra.ProjectKorra.earthbending; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.projectkorra.ProjectKorra.Methods; +import com.projectkorra.ProjectKorra.ProjectKorra; + +public class Extraction { + + private static Map cooldowns = new HashMap(); + private long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.Extraction.Cooldown"); + private static int doublechance = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Extraction.DoubleLootChance"); + private static int triplechance = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Extraction.TripleLootChance"); + + public Extraction(Player player) { + if (cooldowns.containsKey(player.getName())) { + if (cooldowns.get(player.getName()) + cooldown >= System.currentTimeMillis()) { + return; + } else { + cooldowns.remove(player.getName()); + } + } + + Block block = player.getTargetBlock(null, 5); + if (block == null) { + return; + } + if (!Methods.isRegionProtectedFromBuild(player, "Extraction", block.getLocation())) { + if (Methods.canMetalbend(player) && Methods.canBend(player.getName(), "Extraction")) { + Random rand = new Random(); + if (rand.nextInt(99) + 1 <= triplechance) { + if (block.getType() == Material.IRON_ORE) { + block.setType(Material.STONE); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.IRON_INGOT, 3)); + } + if (block.getType() == Material.GOLD_ORE){ + block.setType(Material.STONE); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.GOLD_INGOT, 3)); + } + if (block.getType() == Material.QUARTZ_ORE) { + block.setType(Material.NETHERRACK); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.QUARTZ, 3)); + } + cooldowns.put(player.getName(), System.currentTimeMillis()); + return; + } + else if (rand.nextInt(99) + 1 <= doublechance) { + if (block.getType() == Material.IRON_ORE) { + block.setType(Material.STONE); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.IRON_INGOT, 2)); + } + if (block.getType() == Material.GOLD_ORE){ + block.setType(Material.STONE); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.GOLD_INGOT, 2)); + } + if (block.getType() == Material.QUARTZ_ORE) { + block.setType(Material.NETHERRACK); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.QUARTZ, 2)); + } + cooldowns.put(player.getName(), System.currentTimeMillis()); + return; + } else { + if (block.getType() == Material.IRON_ORE) { + block.setType(Material.STONE); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.IRON_INGOT)); + } + if (block.getType() == Material.GOLD_ORE){ + block.setType(Material.STONE); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.GOLD_INGOT)); + } + if (block.getType() == Material.QUARTZ_ORE) { + block.setType(Material.NETHERRACK); + player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.QUARTZ)); + } + cooldowns.put(player.getName(), System.currentTimeMillis()); + return; + } + } + } + } + +} diff --git a/src/config.yml b/src/config.yml index 17fc76cf..f3715a4a 100644 --- a/src/config.yml +++ b/src/config.yml @@ -232,6 +232,12 @@ Abilities: Radius: 0.25 Revert: true Interval: 30 + Extraction: + Enabled: true + Description: "This ability allows metalbenders to extract the minerals from ore blocks. To use, simply tap sneak while looking at an ore block with metal in it (iron, gold, etc) and the ore will be extracted and drop in front of you. This ability has a small chance of doubling or tripling the loot. This ability has a short cooldown." + Cooldown: 10000 + TripleLootChance: 15 + DoubleLootChance: 40 RaiseEarth: Enabled: true Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it." diff --git a/src/plugin.yml b/src/plugin.yml index bf07022c..041b799a 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ProjectKorra author: ProjectKorra -version: 1.2.0 BETA 4 +version: 1.2.0 BETA 5 main: com.projectkorra.ProjectKorra.ProjectKorra commands: projectkorra: