From 9bd33ab3df93012fff4f4be0f804567cc32f5edb Mon Sep 17 00:00:00 2001 From: NuclearW Date: Thu, 14 Feb 2013 00:34:50 -0500 Subject: [PATCH] Introducing Block Cracker --- Changelog.txt | 1 + .../java/com/gmail/nossr50/config/Config.java | 3 +++ .../nossr50/listeners/BlockListener.java | 22 ++++++++++------- .../gmail/nossr50/skills/unarmed/Unarmed.java | 24 +++++++++++++++++++ .../com/gmail/nossr50/util/BlockChecks.java | 12 ++++++++++ src/main/resources/config.yml | 2 ++ src/main/resources/plugin.yml | 3 +++ 7 files changed, 59 insertions(+), 8 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 5dff86f4f..a9d4b65a0 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -31,6 +31,7 @@ Version 1.4.00-dev + Added the "wait" music disc to the default fishing treasures + Added "Chinese (Taiwan)" localization files (zh_TW) + Added '/hardcore' and '/vampirism' commands for toggling these modes on or off. + + Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick = Fixed bug where splash potions could raise a player's unarmed level = Fixed bug where fired arrows could raise skill levels other than Archery = Fixed /ptp telporting the target to the player, rather than the other way around. diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index b50058b1a..6a930f935 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -256,6 +256,9 @@ public class Config extends ConfigLoader { public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); } public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); } + /* Unarmed */ + public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); } + /* Taming */ public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); } public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 260e75c39..fdc2e95f9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -35,6 +35,7 @@ import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.Salvage; import com.gmail.nossr50.skills.smelting.SmeltingManager; +import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.utilities.AbilityType; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; @@ -286,7 +287,7 @@ public class BlockListener implements Listener { else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) { SkillTools.abilityCheck(player, SkillType.EXCAVATION); } - else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW) && Permissions.berserk(player)) { + else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW || (block.getType() == Material.SMOOTH_BRICK && block.getData() == 0x0)) && Permissions.berserk(player)) { SkillTools.abilityCheck(player, SkillType.UNARMED); } } @@ -344,15 +345,20 @@ public class BlockListener implements Listener { Excavation.gigaDrillBreaker(mcMMOPlayer, block); } } - else if (profile.getAbilityMode(AbilityType.BERSERK) && SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) { - if (heldItem.getType() == Material.AIR) { - FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); - plugin.getServer().getPluginManager().callEvent(armswing); + else if (profile.getAbilityMode(AbilityType.BERSERK)) { + if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) { + if (heldItem.getType() == Material.AIR) { + FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); + plugin.getServer().getPluginManager().callEvent(armswing); - event.setInstaBreak(true); + event.setInstaBreak(true); + player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); + } + } + // Another perm check for the cracked blocks activation + else if (BlockChecks.canBeCracked(block) && player.hasPermission("mcmmo.ability.unarmed.blockcracker")) { + Unarmed.blockCracker(player, block); } - - player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH); } else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) { MiningManager miningManager = new MiningManager(mcMMOPlayer); diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java index 4df5e7a15..c15aca309 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -1,7 +1,12 @@ package com.gmail.nossr50.skills.unarmed; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.util.Misc; public class Unarmed { public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus(); @@ -16,8 +21,27 @@ public class Unarmed { public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax(); public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel(); + public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked(); + public static boolean pvpEnabled = Config.getInstance().getUnarmedPVP(); public static boolean pveEnabled = Config.getInstance().getUnarmedPVE(); public static double berserkDamageModifier = 1.5; + + public static void blockCracker(Player player, Block block) { + if (Misc.blockBreakSimulate(block, player, false)) { + Material type = block.getType(); + + switch (type) { + case SMOOTH_BRICK: + if (blockCrackerSmoothBrick && block.getData() == 0x0) { + block.setData((byte) 0x2); + } + return; + + default: + return; + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index ba2acc9f0..a6eb3a467 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -350,4 +350,16 @@ public final class BlockChecks { return true; } } + + public static boolean canBeCracked(Block block) { + switch(block.getType()) { + case SMOOTH_BRICK: + if (block.getData() == 0) { + return true; + } + + default: + return false; + } + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 376734a33..cd2e40d34 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -171,6 +171,8 @@ Skills: Enabled_For_PVP: true Enabled_For_PVE: true Level_Cap: 0 + Block_Cracker: + SmoothBrick_To_CrackedBrick: true Woodcutting: Level_Cap: 0 Requires_Axe: true diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2e4bdd05c..6218b6ffe 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -462,12 +462,15 @@ permissions: description: Allows access to all Unarmed abilities children: mcmmo.ability.unarmed.berserk: true + mcmmo.ability.unarmed.blockcracker: true mcmmo.ability.unarmed.bonusdamage: true mcmmo.ability.unarmed.deflect: true mcmmo.ability.unarmed.disarm: true mcmmo.ability.unarmed.irongrip: true mcmmo.ability.unarmed.berserk: description: Allows access to the Berserker ability + mcmmo.ability.unarmed.blockcracker: + description: Allows access to the Block Cracker ability mcmmo.ability.unarmed.bonusdamage: description: Allows bonus damage from Unarmed mcmmo.ability.unarmed.deflect: