From 4a2325f244f2e71a1a0b7fcf72ea759d09a22186 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Sat, 4 Feb 2012 01:36:03 -0500 Subject: [PATCH] Moved more stuff into skill files. --- .../nossr50/listeners/mcBlockListener.java | 70 +++++-------------- .../com/gmail/nossr50/skills/Unarmed.java | 34 +++++++++ .../com/gmail/nossr50/skills/WoodCutting.java | 22 ++++++ 3 files changed, 75 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index 46c6dc86b..d1bbd88a5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -237,7 +237,7 @@ public class mcBlockListener implements Listener } if(LoadProperties.toolsLoseDurabilityFromAbilities) { - if(inhand.getEnchantments().containsKey(Enchantment.DURABILITY)) + if(!inhand.getEnchantments().containsKey(Enchantment.DURABILITY)) m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); } plugin.misc.treeFeller.clear(); @@ -342,7 +342,7 @@ public class mcBlockListener implements Listener if(LoadProperties.toolsLoseDurabilityFromAbilities) { - if(inhand.getEnchantments().containsKey(Enchantment.DURABILITY)) + if(!inhand.getEnchantments().containsKey(Enchantment.DURABILITY)) m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); } @@ -369,45 +369,17 @@ public class mcBlockListener implements Listener && player.getItemInHand().getTypeId() == 0 && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78)) { - Material mat = Material.getMaterial(block.getTypeId()); - - if(block.getTypeId() == 2) - mat = Material.DIRT; - if(block.getTypeId() == 78) - mat = Material.SNOW_BALL; - if(block.getTypeId() == 82) - mat = Material.CLAY_BALL; - if(block.getTypeId() == 110) - mat = Material.DIRT; - - byte type = block.getData(); - - ItemStack item = new ItemStack(mat, 1, (byte)0, type); - player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType()); - - block.setType(Material.AIR); - - if(item.getType() == Material.CLAY_BALL) - { - m.mcDropItem(block.getLocation(), item); - m.mcDropItem(block.getLocation(), item); - m.mcDropItem(block.getLocation(), item); - m.mcDropItem(block.getLocation(), item); - } else - { - m.mcDropItem(block.getLocation(), item); - } - - if(LoadProperties.spoutEnabled) - SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); + event.setInstaBreak(true); + Unarmed.berserk(player, block); } /* * SUPER BREAKER CHECKS */ if(PP.getSuperBreakerMode() - && Mining.canBeSuperBroken(block) - && m.blockBreakSimulate(block, player)) + && Mining.canBeSuperBroken(block) + && m.blockBreakSimulate(block, player) + && mcPermissions.getInstance().mining(player)) { if(LoadProperties.miningrequirespickaxe) @@ -420,26 +392,22 @@ public class mcBlockListener implements Listener } /* - * LEAF BLOWER + * LEAF BLOWER CHECKS */ - if(block.getTypeId() == 18 && mcPermissions.getInstance().woodcutting(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 && m.isAxes(player.getItemInHand()) && m.blockBreakSimulate(block, player)) + if(block.getTypeId() == 18 + && mcPermissions.getInstance().woodcutting(player) + && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 + && m.blockBreakSimulate(block, player)) { - - if(LoadProperties.toolsLoseDurabilityFromAbilities) - { - if(inhand.getEnchantments().containsKey(Enchantment.DURABILITY)) - m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); - } - - if(Math.random() * 10 > 9) + if(LoadProperties.woodcuttingrequiresaxe) { - ItemStack x = new ItemStack(Material.SAPLING, 1, (short)0, (byte)(block.getData()-8)); - m.mcDropItem(block.getLocation(), x); + if(m.isAxes(inhand)) + WoodCutting.leafBlower(player, block); } - block.setType(Material.AIR); - player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType()); - if(LoadProperties.spoutEnabled) - SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); + else{ + WoodCutting.leafBlower(player, block); + } + } if(block.getType() == Material.AIR && plugin.misc.blockWatchList.contains(block)) { diff --git a/src/main/java/com/gmail/nossr50/skills/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/Unarmed.java index 817ce32be..e5fb906f5 100644 --- a/src/main/java/com/gmail/nossr50/skills/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/Unarmed.java @@ -25,7 +25,9 @@ import com.gmail.nossr50.m; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; +import com.gmail.nossr50.listeners.Material; import com.gmail.nossr50.locale.mcLocale; +import com.gmail.nossr50.spout.SpoutStuff; public class Unarmed { public static void berserkActivationCheck(Player player) @@ -108,4 +110,36 @@ public class Unarmed { } } } + + public static void berserk(Player player, Block block){ + + Material mat = Material.getMaterial(block.getTypeId()); + byte damage = 0; + + if(block.getTypeId() == 2 || block.getTypeId() == 110) + mat = Material.DIRT; + if(block.getTypeId() == 78) + mat = Material.SNOW_BALL; + if(block.getTypeId() == 82) + mat = Material.CLAY_BALL; + + ItemStack item = new ItemStack(mat, 1, (byte)0, damage); + player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType()); + +// block.setType(Material.AIR); + + if(item.getType() == Material.CLAY_BALL) + { + m.mcDropItem(block.getLocation(), item); + m.mcDropItem(block.getLocation(), item); + m.mcDropItem(block.getLocation(), item); + m.mcDropItem(block.getLocation(), item); + } else + { + m.mcDropItem(block.getLocation(), item); + } + + if(LoadProperties.spoutEnabled) + SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); + } } diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 16955c902..f1380c38f 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -27,9 +27,11 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; +import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.config.*; @@ -195,4 +197,24 @@ public class WoodCutting PP.addXP(SkillType.WOODCUTTING, xp, player); Skills.XpCheckSkill(SkillType.WOODCUTTING, player); } + + public static void leafBlower(Player player, Block block){ + if(LoadProperties.toolsLoseDurabilityFromAbilities) + { + if(!player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) + m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); + } + + if(Math.random() * 10 > 9) + { + ItemStack x = new ItemStack(Material.SAPLING, 1, (short)0, (byte)(block.getData()-8)); + m.mcDropItem(block.getLocation(), x); + } + + block.setType(Material.AIR); + player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType()); + + if(LoadProperties.spoutEnabled) + SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); + } }