浏览代码

Updates to Blast Mining.

GJ 13 年之前
父节点
当前提交
d13549ff6a

+ 3 - 1
src/main/java/com/gmail/nossr50/config/Misc.java

@@ -19,9 +19,11 @@ 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;
+import org.bukkit.entity.Player;
 
 import com.gmail.nossr50.mcMMO;
 
@@ -35,7 +37,7 @@ public class Misc
     public HashSet<Block> blockWatchList = new HashSet<Block>();
     public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
     public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();
-    public HashMap<Block, Integer> tntTracker = new HashMap<Block, Integer>();
+    public HashMap<Location, Player> tntTracker = new HashMap<Location, Player>();
     mcMMO plugin = null;
     
     //BLEED QUE STUFF

+ 1 - 1
src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java

@@ -75,7 +75,7 @@ public class mcBlockListener implements Listener
     	if(id == 46 && mcPermissions.getInstance().blastmining(player))
     	{
     		int skill = Users.getProfile(player).getSkillLevel(SkillType.MINING);
-    		plugin.misc.tntTracker.put(block, skill);
+    		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

+ 26 - 8
src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java

@@ -16,6 +16,7 @@
 */
 package com.gmail.nossr50.listeners;
 
+import org.bukkit.Location;
 import org.bukkit.block.Block;
 import org.bukkit.entity.Entity;
 import org.bukkit.entity.LivingEntity;
@@ -180,12 +181,21 @@ public class mcEntityListener implements Listener
 	{
 		if(event.getEntity() instanceof TNTPrimed)
 		{
-			Block block = event.getEntity().getLocation().getBlock();
+			Location location = event.getEntity().getLocation();
+			System.out.println("TNT Primed.");
 			
-			if(plugin.misc.tntTracker.get(block) != null)
+			//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(location.toString());
+			
+			if(plugin.misc.tntTracker.get(location) != null)
 			{
-				int skillLevel = plugin.misc.tntTracker.get(block);
-				BlastMining.biggerBombs(skillLevel, event);
+				System.out.println("Being Tracked.");
+				Player player = plugin.misc.tntTracker.get(location);
+				
+				BlastMining.biggerBombs(Users.getProfile(player).getSkillLevel(SkillType.MINING), event);
 			}
 		}		
 	}
@@ -195,12 +205,20 @@ public class mcEntityListener implements Listener
 	{
 		if(event.getEntity() instanceof TNTPrimed)
 		{
-			Block block = event.getLocation().getBlock();
+			Location location = event.getEntity().getLocation();
+			System.out.println("TNT Explode.");
+			
+			//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(location.toString());
 
-			if(plugin.misc.tntTracker.get(block) != null)
+			if(plugin.misc.tntTracker.get(location) != null)
 			{
-				int skillLevel = plugin.misc.tntTracker.get(block);
-				BlastMining.dropProcessing(skillLevel, event, plugin);
+				System.out.println("Being Tracked.");
+				Player player = plugin.misc.tntTracker.get(location);
+				BlastMining.dropProcessing(Users.getProfile(player).getSkillLevel(SkillType.MINING), event, plugin);
 			}
 		}
 	}

+ 14 - 8
src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java

@@ -185,14 +185,6 @@ public class mcPlayerListener implements Listener
 				event.setCancelled(true);
 				player.updateInventory();
 			}
-			
-			if(mat.equals(Material.TNT))
-			{
-				TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
-				block.setType(Material.AIR);
-				tnt.setFuseTicks(0);
-//				plugin.misc.tntTracker.remove(block);
-			}
 
 			if(LoadProperties.enableAbilities && m.abilityBlockCheck(block))
 			{
@@ -289,6 +281,20 @@ public class mcPlayerListener implements Listener
     	    	player.sendMessage(mcLocale.getString("m.TamingSummon"));
 			}
 		}
+		
+		if(action == Action.RIGHT_CLICK_AIR)
+		{
+			Block b = player.getTargetBlock(null, 100);
+			if(b.getType().equals(Material.TNT))
+			{
+				TNTPrimed tnt = player.getWorld().spawn(b.getLocation(), TNTPrimed.class);
+				b.setType(Material.AIR);
+				tnt.setFuseTicks(0);
+				if(plugin.misc.tntTracker.get(tnt.getLocation()) != null)
+					System.out.println(tnt.getLocation().toString());
+	//			plugin.misc.tntTracker.remove(block);
+			}
+		}
 	}
 
 	@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)