From 388fd364ac48a0d511b01c83639ed184130ab18c Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 1 Feb 2012 00:20:01 -0500 Subject: [PATCH] Updated to remove unused "smelt" property. Minor optimizations in Mining.java --- .../nossr50/listeners/mcBlockListener.java | 6 +- .../java/com/gmail/nossr50/skills/Mining.java | 151 +++++++----------- 2 files changed, 60 insertions(+), 97 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index 087a5a35f..da4e99919 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -76,7 +76,7 @@ public class mcBlockListener implements Listener if(m.shouldBeWatched(block)) { int id = block.getTypeId(); - if (id == 17 || id == 39 || id == 40 || id == 91 || id == 86 || id == 73) { + if (id == 17 || id == 39 || id == 40 || id == 91 || id == 86 || id == 73 || id == 74) { plugin.misc.blockWatchList.add(block); } else { //block.setData((byte) 5); //Change the byte @@ -160,11 +160,11 @@ public class mcBlockListener implements Listener { if(m.isMiningPick(inhand)) { - Mining.miningBlockCheck(false, player, block, plugin); + Mining.miningBlockCheck(player, block, plugin); } } else { - Mining.miningBlockCheck(false, player, block, plugin); + Mining.miningBlockCheck(player, block, plugin); } } /* diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 00840a89f..3a7de4260 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -152,7 +152,7 @@ public class Mining } } - public static void miningBlockCheck(Boolean smelt, Player player, Block block, mcMMO plugin) + public static void miningBlockCheck(Player player, Block block, mcMMO plugin) { PlayerProfile PP = Users.getProfile(player); if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5) @@ -160,110 +160,71 @@ public class Mining int xp = 0; int id = block.getTypeId(); - if(id == 1 || id == 24) - { - xp += LoadProperties.mstone; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //OBSIDIAN - else if(id == 49) - { - xp += LoadProperties.mobsidian; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //NETHERRACK - else if(id == 87) - { - xp += LoadProperties.mnetherrack; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //GLOWSTONE - else if(id == 89) - { - xp += LoadProperties.mglowstone; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //COAL - else if(id == 16) - { - xp += LoadProperties.mcoal; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //GOLD - else if(id == 14) - { - xp += LoadProperties.mgold; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //DIAMOND - else if(id == 56) - { - xp += LoadProperties.mdiamond; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //IRON - else if(id == 15) - { - xp += LoadProperties.miron; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //REDSTONE - else if(id == 73 || id == 74) - { - xp += LoadProperties.mredstone; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } - //LAPUS - else if(id == 21) - { - xp += LoadProperties.mlapis; - if(smelt = false) - blockProcCheck(block, player); - else - blockProcCheck(block, player); - } + switch (id) { + //STONE + case 1: + xp += LoadProperties.mstone; + break; + //SANDSTONE + case 24: + xp += LoadProperties.msandstone; + break; + //OBSIDIAN + case 49: + xp += LoadProperties.mobsidian; + break; + //NETHERRACK + case 87: + xp += LoadProperties.mnetherrack; + break; + //GLOWSTONE + case 89: + xp += LoadProperties.mglowstone; + break; + //COAL + case 16: + xp += LoadProperties.mcoal; + break; + //GOLD + case 14: + xp += LoadProperties.mgold; + break; + //DIAMOND + case 56: + xp += LoadProperties.mdiamond; + break; + //IRON + case 15: + xp += LoadProperties.miron; + break; + //REDSTONE + case 73: + xp += LoadProperties.mredstone; + break; + case 74: + xp += LoadProperties.mredstone; + break; + //LAPIS + case 21: + xp += LoadProperties.mlapis; + break; + } + + blockProcCheck(block, player); PP.addXP(SkillType.MINING, xp, player); Skills.XpCheckSkill(SkillType.MINING, player); } + /* * Handling SuperBreaker stuff */ public static Boolean canBeSuperBroken(Block block) { int t = block.getTypeId(); - if(t == 49 || t == 87 || t == 89 || t == 73 || t == 74 || t == 56 || t == 21 || t == 1 || t == 16 || t == 14 || t == 15) - { + if(t == 49 || t == 87 || t == 89 || t == 73 || t == 74 || t == 56 || t == 21 || t == 1 || t == 16 || t == 14 || t == 15 || t == 112) return true; - } else { + else return false; - } } public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin) @@ -278,6 +239,7 @@ public class Mining m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); } + //Pre-processing Location loc = block.getLocation(); Material mat = Material.getMaterial(block.getTypeId()); int xp = 0; @@ -285,6 +247,7 @@ public class Mining ItemStack item = new ItemStack(mat, 1, (byte)0, damage); int id = block.getTypeId(); + if(id == 1 || id == 24) { if(id == 1)