From 36a706b7b6a91001796927fc93eeee340b1352c1 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 5 Mar 2012 21:57:46 -0500 Subject: [PATCH] Fix for Blast Mining not always activating bonuses. --- Changelog.txt | 2 ++ .../java/com/gmail/nossr50/config/Misc.java | 3 +- .../nossr50/listeners/mcBlockListener.java | 7 ---- .../nossr50/listeners/mcEntityListener.java | 35 ++++++------------- .../nossr50/listeners/mcPlayerListener.java | 5 +-- .../java/com/gmail/nossr50/skills/Taming.java | 2 -- 6 files changed, 16 insertions(+), 38 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 585133f7d..f8d03d3f7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -12,6 +12,8 @@ Version 2.0.00-dev + Added ability to summon Ocelots with Call of the Wild = Fixed ClassCastException from Taming preventDamage checks = Fixed issue with Blast Mining not seeing TNT for detonation due to snow + ! Changed Call of the Wild to activate on left-click rather than right-click + ! Changed Blast Mining to track based on Entity ID vs. Location Version 1.3.02 + Added in game guides for Mining, Excavation, and Acrobatics. Simply type /skillname ? to access them diff --git a/src/main/java/com/gmail/nossr50/config/Misc.java b/src/main/java/com/gmail/nossr50/config/Misc.java index 8e9684eda..2d13f612f 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 HashSet blockWatchList = new HashSet(); 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 8f9dbd2a3..1daebae04 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -70,9 +70,6 @@ public class mcBlockListener implements Listener int id = block.getTypeId(); Material mat = block.getType(); - //TNT placement checks - needed for Blast Mining - if(mat.equals(Material.TNT) && mcPermissions.getInstance().blastMining(player)) - plugin.misc.tntTracker.put(block.getLocation(), player); //Check if the blocks placed should be monitored so they do not give out XP in the future if(m.shouldBeWatched(mat)) { @@ -154,10 +151,6 @@ public class mcBlockListener implements Listener /* * MINING */ - //TNT removal checks - needed for Blast Mining - if(id == 46 && plugin.misc.tntTracker.containsKey(block.getLocation())) - plugin.misc.tntTracker.remove(block.getLocation()); - if(mcPermissions.getInstance().mining(player)) { if(LoadProperties.miningrequirespickaxe && m.isMiningPick(inhand)) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index f18836238..96011da5c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -16,7 +16,6 @@ */ package com.gmail.nossr50.listeners; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -55,7 +54,6 @@ import com.gmail.nossr50.skills.BlastMining; import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Taming; - public class mcEntityListener implements Listener { private final mcMMO plugin; @@ -162,21 +160,13 @@ public class mcEntityListener implements Listener @EventHandler (priority = EventPriority.LOW) public void onExplosionPrime(ExplosionPrimeEvent event) { - if(event.getEntity() instanceof TNTPrimed) + Entity entity = event.getEntity(); + if(entity instanceof TNTPrimed) { - Location location = event.getEntity().getLocation(); - System.out.println("UNNORMALIZED LOCATION"); - System.out.println(location); - //Ugly code to make it recognize the location - location.setX(location.getBlockX()+1); - location.setY(location.getBlockY()); - location.setZ(location.getBlockZ()+1); - System.out.println("NORMALIZED LOCATION"); - System.out.println(location); - - if(plugin.misc.tntTracker.containsKey(location)) + int id = entity.getEntityId(); + if(plugin.misc.tntTracker.containsKey(id)) { - Player player = plugin.misc.tntTracker.get(location); + Player player = plugin.misc.tntTracker.get(id); BlastMining.biggerBombs(player, event); } } @@ -185,20 +175,15 @@ public class mcEntityListener implements Listener @EventHandler (priority = EventPriority.LOW) public void onEnitityExplode(EntityExplodeEvent event) { + Entity entity = event.getEntity(); if(event.getEntity() instanceof TNTPrimed) { - Location location = event.getEntity().getLocation(); - - //Ugly code to make it recognize the location - location.setX(location.getBlockX()+1); - location.setY(location.getBlockY()); - location.setZ(location.getBlockZ()+1); - - if(plugin.misc.tntTracker.containsKey(location)) + int id = entity.getEntityId(); + if(plugin.misc.tntTracker.containsKey(id)) { - Player player = plugin.misc.tntTracker.get(location); + Player player = plugin.misc.tntTracker.get(id); BlastMining.dropProcessing(player, event, plugin); - plugin.misc.tntTracker.remove(location); + plugin.misc.tntTracker.remove(id); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java index 69c5ef075..888e5e506 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -259,7 +259,7 @@ public class mcPlayerListener implements Listener if(action == Action.RIGHT_CLICK_BLOCK && m.abilityBlockCheck(block)) Item.itemchecks(player, plugin); - if(player.isSneaking() && mcPermissions.getInstance().taming(player) && (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)) + if(player.isSneaking() && mcPermissions.getInstance().taming(player) && (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK)) { if(is.getType().equals(Material.RAW_FISH)) Taming.animalSummon(EntityType.OCELOT, player); @@ -294,7 +294,8 @@ public class mcPlayerListener implements Listener player.sendMessage(ChatColor.GRAY+"**BOOM**"); - TNTPrimed tnt = player.getWorld().spawn(b.getLocation(), TNTPrimed.class); + TNTPrimed tnt = player.getWorld().spawn(b.getLocation(), TNTPrimed.class); + plugin.misc.tntTracker.put(tnt.getEntityId(), player); b.setType(Material.AIR); tnt.setFuseTicks(0); PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining diff --git a/src/main/java/com/gmail/nossr50/skills/Taming.java b/src/main/java/com/gmail/nossr50/skills/Taming.java index 4dde90b9c..c99a8bf0f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Taming.java +++ b/src/main/java/com/gmail/nossr50/skills/Taming.java @@ -195,9 +195,7 @@ public class Taming world.spawnCreature(player.getLocation(), type); int amount = item.getAmount(); - System.out.println(amount); amount = amount - summonAmount; - System.out.println(amount); player.setItemInHand(new ItemStack(summonItem, amount)); player.sendMessage(mcLocale.getString("m.TamingSummon")); }