From 80abd0db91f20cc7c4f35a18f870d275436b6403 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Sat, 4 Feb 2012 08:48:37 -0500 Subject: [PATCH 1/3] Fixed issue with Silk Touch & Double/Triple drops while mining. --- src/main/java/com/gmail/nossr50/skills/Mining.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 6a1fbc59c..5ebd5f7ef 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -16,8 +16,6 @@ */ package com.gmail.nossr50.skills; -import net.minecraft.server.Enchantment; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Statistic; @@ -25,6 +23,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.getspout.spoutapi.sound.SoundEffect; +import org.bukkit.enchantments.Enchantment; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; @@ -90,7 +89,7 @@ public class Mining } //Drop natural block with Silk Touch - if(player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)){ + if(player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)){ m.mcDropItem(loc, item); return; } @@ -271,7 +270,7 @@ public class Mining PlayerProfile PP = Users.getProfile(player); if(LoadProperties.toolsLoseDurabilityFromAbilities) { - if(!player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) + if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY)) m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); } @@ -322,7 +321,7 @@ public class Mining blockProcCheck(block, player); } //OBSIDIAN - else if(id == 49 && block.getData() != (byte) 5) + else if(id == 49 && m.getTier(player) >= 4 && block.getData() != (byte) 5) { xp += LoadProperties.mobsidian; blockProcCheck(block, player); From bb70289cb35bd1d73ff41d0b6e461bf91d256289 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Sat, 4 Feb 2012 09:35:07 -0500 Subject: [PATCH 2/3] More fixes for instaBreak, moving abilities to individual skill files. --- .../nossr50/listeners/mcBlockListener.java | 74 ++++++------------- .../com/gmail/nossr50/skills/Excavation.java | 22 +++++- .../com/gmail/nossr50/skills/WoodCutting.java | 8 +- 3 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index e7110d6eb..8357b076c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -247,7 +247,7 @@ public class mcBlockListener implements Listener * EXCAVATION */ if(Excavation.canBeGigaDrillBroken(block) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5) - Excavation.excavationProcCheck(block.getData(), block.getType(), block.getLocation(), player); + Excavation.excavationProcCheck(block.getType(), block.getLocation(), player); /* * HERBALISM */ @@ -312,54 +312,21 @@ public class mcBlockListener implements Listener /* * GIGA DRILL BREAKER CHECKS */ - if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player) - && Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand)) - { - int x = 0; - - while(x < 3) + if(PP.getGigaDrillBreakerMode() + && Excavation.canBeGigaDrillBroken(block) + && m.blockBreakSimulate(block, player) + && mcPermissions.getInstance().excavationAbility(player)) + { + if(LoadProperties.excavationRequiresShovel) { - if(block.getData() != (byte)5) - Excavation.excavationProcCheck(block.getData(), block.getType(), block.getLocation(), player); - x++; + if(m.isShovel(inhand)){ + event.setInstaBreak(true); + Excavation.gigaDrillBreaker(player, block); + } + } else { + event.setInstaBreak(true); + Excavation.gigaDrillBreaker(player, block); } - - Material mat = Material.getMaterial(block.getTypeId()); - - if(block.getType() == Material.GRASS) - mat = Material.DIRT; - if(block.getType() == Material.CLAY) - mat = Material.CLAY_BALL; - if(block.getType() == Material.MYCEL) - mat = Material.DIRT; - - byte type = block.getData(); - ItemStack item = new ItemStack(mat, 1, (byte)0, type); - - block.setType(Material.AIR); - - player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType()); - - if(LoadProperties.toolsLoseDurabilityFromAbilities) - { - if(!inhand.getEnchantments().containsKey(Enchantment.DURABILITY)) - m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); - } - - 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); - } - - //Spout stuff - if(LoadProperties.spoutEnabled) - SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); } /* * BERSERK MODE CHECKS @@ -367,7 +334,8 @@ public class mcBlockListener implements Listener if(PP.getBerserkMode() && m.blockBreakSimulate(block, player) && player.getItemInHand().getTypeId() == 0 - && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78)) + && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78) + && mcPermissions.getInstance().unarmedAbility(player)) { event.setInstaBreak(true); if(LoadProperties.spoutEnabled) @@ -380,14 +348,14 @@ public class mcBlockListener implements Listener if(PP.getSuperBreakerMode() && Mining.canBeSuperBroken(block) && m.blockBreakSimulate(block, player) - && mcPermissions.getInstance().mining(player)) + && mcPermissions.getInstance().miningAbility(player)) { - if(LoadProperties.miningrequirespickaxe) { - if(m.isMiningPick(inhand)) + if(m.isMiningPick(inhand)){ event.setInstaBreak(true); Mining.SuperBreakerBlockCheck(player, block, plugin); + } } else { event.setInstaBreak(true); Mining.SuperBreakerBlockCheck(player, block, plugin); @@ -398,16 +366,18 @@ public class mcBlockListener implements Listener * LEAF BLOWER CHECKS */ if(block.getTypeId() == 18 - && mcPermissions.getInstance().woodcutting(player) + && mcPermissions.getInstance().woodcuttingAbility(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 && m.blockBreakSimulate(block, player)) { if(LoadProperties.woodcuttingrequiresaxe) { if(m.isAxes(inhand)) + event.setInstaBreak(true); WoodCutting.leafBlower(player, block); } else{ + event.setInstaBreak(true); WoodCutting.leafBlower(player, block); } diff --git a/src/main/java/com/gmail/nossr50/skills/Excavation.java b/src/main/java/com/gmail/nossr50/skills/Excavation.java index 107f20fd1..ae37850c2 100644 --- a/src/main/java/com/gmail/nossr50/skills/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/Excavation.java @@ -23,6 +23,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.locale.mcLocale; +import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; import com.gmail.nossr50.config.LoadProperties; @@ -74,7 +75,7 @@ public class Excavation Material t = block.getType(); return t == Material.DIRT || t == Material.GRASS || t == Material.SAND || t == Material.GRAVEL || t == Material.CLAY || t == Material.MYCEL || t == Material.SOUL_SAND; } - public static void excavationProcCheck(byte data, Material type, Location loc, Player player) + public static void excavationProcCheck(Material type, Location loc, Player player) { if(LoadProperties.excavationRequiresShovel && !m.isShovel(player.getItemInHand())) return; @@ -253,4 +254,23 @@ public class Excavation PP.addXP(SkillType.EXCAVATION, xp, player); Skills.XpCheckSkill(SkillType.EXCAVATION, player); } + + public static void gigaDrillBreaker(Player player, Block block) + { + if(LoadProperties.toolsLoseDurabilityFromAbilities) + { + if(!player.getItemInHand.containsEnchantment(Enchantment.DURABILITY)) + m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); + } + + if(block.getData() != (byte)5) + { + Excavation.excavationProcCheck(block.getType(), block.getLocation(), player); + Excavation.excavationProcCheck(block.getType(), block.getLocation(), player); + Excavation.excavationProcCheck(block.getType(), block.getLocation(), player); + } + + if(LoadProperties.spoutEnabled) + SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 076383501..4045c7d07 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -17,7 +17,6 @@ package com.gmail.nossr50.skills; import java.util.ArrayList; -import net.minecraft.server.Enchantment; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -25,10 +24,10 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.Statistic; +import org.bukkit.enchantments.Enchantment; 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; @@ -203,7 +202,7 @@ public class WoodCutting public static void leafBlower(Player player, Block block){ if(LoadProperties.toolsLoseDurabilityFromAbilities) { - if(!player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY)) + if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY)) m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); } @@ -213,9 +212,6 @@ public class WoodCutting m.mcDropItem(block.getLocation(), x); } - block.setType(Material.AIR); - player.incrementStatistic(Statistic.MINE_BLOCK, block.getType()); - if(LoadProperties.spoutEnabled) SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); } From 0068a3f07aa5405ea632cd5aa6b6085c9ce7bb83 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Sat, 4 Feb 2012 10:45:37 -0500 Subject: [PATCH 3/3] Fixed compile errors from last commit. --- .../java/com/gmail/nossr50/listeners/mcBlockListener.java | 2 +- src/main/java/com/gmail/nossr50/skills/Excavation.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index 8357b076c..b3edb81d7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -366,7 +366,7 @@ public class mcBlockListener implements Listener * LEAF BLOWER CHECKS */ if(block.getTypeId() == 18 - && mcPermissions.getInstance().woodcuttingAbility(player) + && mcPermissions.getInstance().woodCuttingAbility(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 && m.blockBreakSimulate(block, player)) { diff --git a/src/main/java/com/gmail/nossr50/skills/Excavation.java b/src/main/java/com/gmail/nossr50/skills/Excavation.java index ae37850c2..e278af8fb 100644 --- a/src/main/java/com/gmail/nossr50/skills/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/Excavation.java @@ -22,6 +22,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.enchantments.Enchantment; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.Users; @@ -29,6 +30,7 @@ import com.gmail.nossr50.m; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; +import org.getspout.spoutapi.sound.SoundEffect; public class Excavation @@ -259,7 +261,7 @@ public class Excavation { if(LoadProperties.toolsLoseDurabilityFromAbilities) { - if(!player.getItemInHand.containsEnchantment(Enchantment.DURABILITY)) + if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY)) m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); }