From 86e373b49391664949bc7804449856c9fd4036e6 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 7 Feb 2012 15:28:41 -0500 Subject: [PATCH] Various fixes for Blast Mining. --- .../java/com/gmail/nossr50/config/Misc.java | 3 +- .../nossr50/listeners/mcBlockListener.java | 2 +- .../nossr50/listeners/mcEntityListener.java | 19 +++- .../com/gmail/nossr50/skills/BlastMining.java | 97 ++++++++++++++++--- 4 files changed, 98 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Misc.java b/src/main/java/com/gmail/nossr50/config/Misc.java index 9ba7dd4b6..2d184327a 100644 --- a/src/main/java/com/gmail/nossr50/config/Misc.java +++ b/src/main/java/com/gmail/nossr50/config/Misc.java @@ -19,7 +19,6 @@ package com.gmail.nossr50.config; import java.util.*; import java.util.logging.Logger; -import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -37,7 +36,7 @@ public class Misc public ArrayList treeFeller = new ArrayList(); public HashMap arrowTracker = new HashMap(); public ArrayList bleedTracker = new ArrayList(); - public HashMap tntTracker = new HashMap(); + public HashMap tntTracker = new HashMap(); mcMMO plugin = null; //BLEED QUE STUFF diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index 56d3035d2..c33095fef 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -83,7 +83,7 @@ public class mcBlockListener implements Listener { PlayerProfile PP = Users.getProfile(player); int skill = PP.getSkillLevel(SkillType.MINING); - plugin.misc.tntTracker.put(block.getLocation(), skill); + plugin.misc.tntTracker.put(block, skill); } //Check if the blocks placed should be monitored so they do not give out XP in the future diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index d70ec48c6..f5908c933 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -16,6 +16,7 @@ */ package com.gmail.nossr50.listeners; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -217,8 +218,13 @@ public class mcEntityListener implements Listener { if(event.getEntity() instanceof TNTPrimed) { - int skillLevel = plugin.misc.tntTracker.get(event.getEntity().getLocation()); - BlastMining.biggerBombs(skillLevel, event); + Block block = event.getEntity().getLocation().getBlock(); + + if(plugin.misc.tntTracker.get(block) != null) + { + int skillLevel = plugin.misc.tntTracker.get(block); + BlastMining.biggerBombs(skillLevel, event); + } } } @@ -228,8 +234,13 @@ public class mcEntityListener implements Listener { if(event.getEntity() instanceof TNTPrimed) { - int skillLevel = plugin.misc.tntTracker.get(event.getEntity().getLocation()); - BlastMining.dropProcessing(skillLevel, event, plugin); + Block block = event.getLocation().getBlock();; + + if(plugin.misc.tntTracker.get(block) != null) + { + int skillLevel = plugin.misc.tntTracker.get(block); + BlastMining.dropProcessing(skillLevel, event, plugin); + } } } diff --git a/src/main/java/com/gmail/nossr50/skills/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/BlastMining.java index 55281a3ba..afdd5d9ac 100644 --- a/src/main/java/com/gmail/nossr50/skills/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/BlastMining.java @@ -151,7 +151,7 @@ public class BlastMining{ if(skillLevel < 125) return; - //Drop 10% more ores + //+5% ores if(skillLevel >= 125 && skillLevel < 250) { event.setYield(0); @@ -160,7 +160,7 @@ public class BlastMining{ while(iterator2.hasNext()) { Block temp = iterator2.next(); - if(Math.random() * 100 < (yield + 10)) + if(Math.random() < (yield + .05)) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -169,7 +169,7 @@ public class BlastMining{ while(iterator3.hasNext()) { Block temp = iterator3.next(); - if(Math.random() * 100 < yield) + if(Math.random() < yield) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -177,7 +177,7 @@ public class BlastMining{ } } - //Drop 20% more ores + //+10% ores if(skillLevel >= 250 && skillLevel < 375) { event.setYield(0); @@ -186,7 +186,7 @@ public class BlastMining{ while(iterator2.hasNext()) { Block temp = iterator2.next(); - if(Math.random() * 100 < (yield + 20)) + if(Math.random() < (yield + .10)) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -195,7 +195,7 @@ public class BlastMining{ while(iterator3.hasNext()) { Block temp = iterator3.next(); - if(Math.random() * 100 < yield) + if(Math.random() < yield) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -203,8 +203,8 @@ public class BlastMining{ } } - //No debris - if(skillLevel >= 375 && skillLevel < 625) + //No debris, +15% ores + if(skillLevel >= 375 && skillLevel < 500) { event.setYield(0); Iterator iterator2 = ores.iterator(); @@ -212,7 +212,7 @@ public class BlastMining{ while(iterator2.hasNext()) { Block temp = iterator2.next(); - if(Math.random() * 100 < yield + 20) + if(Math.random() < (yield + .15)) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -220,8 +220,8 @@ public class BlastMining{ } } - //Double Drops - if(skillLevel >= 625 && skillLevel < 875) + //No debris, +20% ores + if(skillLevel >= 500 && skillLevel < 625) { event.setYield(0); Iterator iterator2 = ores.iterator(); @@ -229,7 +229,24 @@ public class BlastMining{ while(iterator2.hasNext()) { Block temp = iterator2.next(); - if(Math.random() * 100 < yield + 20) + if(Math.random() < (yield + .20)) + { + if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); + explosionBlockDrops(temp, event.getLocation()); + } + } + } + + //Double Drops, No Debris, +25% ores + if(skillLevel >= 625 && skillLevel < 750) + { + event.setYield(0); + Iterator iterator2 = ores.iterator(); + + while(iterator2.hasNext()) + { + Block temp = iterator2.next(); + if(Math.random() < (yield + .25)) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -242,8 +259,8 @@ public class BlastMining{ } } - //Triple Drops - if(skillLevel >= 875) + //Double Drops, No Debris, +30% ores + if(skillLevel >= 750 && skillLevel < 875) { event.setYield(0); Iterator iterator2 = ores.iterator(); @@ -251,7 +268,56 @@ public class BlastMining{ while(iterator2.hasNext()) { Block temp = iterator2.next(); - if(Math.random() * 100 < yield + 20) + if(Math.random() < (yield + .30)) + { + if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); + explosionBlockDrops(temp, event.getLocation()); + if(Math.random() * 1000 <= skillLevel) + { + if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); + explosionBlockDrops(temp, event.getLocation()); + } + } + } + } + + //Triple Drops, No debris, +35% ores + if(skillLevel >= 875 && skillLevel < 1000) + { + event.setYield(0); + Iterator iterator2 = ores.iterator(); + + while(iterator2.hasNext()) + { + Block temp = iterator2.next(); + if(Math.random() * 100 < (yield + .35)) + { + if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); + explosionBlockDrops(temp, event.getLocation()); + if(Math.random() * 1000 <= skillLevel || skillLevel > 1000) + { + if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); + explosionBlockDrops(temp, event.getLocation()); + } + if(Math.random() * 1000 <= skillLevel || skillLevel > 1000) + { + if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); + explosionBlockDrops(temp, event.getLocation()); + } + } + } + } + + //Triple Drops, No debris, +40% ores + if(skillLevel >= 1000) + { + event.setYield(0); + Iterator iterator2 = ores.iterator(); + + while(iterator2.hasNext()) + { + Block temp = iterator2.next(); + if(Math.random() * 100 < (yield + .40)) { if(temp.getData() != 5 && plugin.misc.blockWatchList.contains(temp)); explosionBlockDrops(temp, event.getLocation()); @@ -270,7 +336,6 @@ public class BlastMining{ } } - /* * Bigger Bombs (Unlocked at Mining 250) *