Skip to content

Commit

Permalink
Updates to Blast Mining.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcferrin committed Mar 1, 2012
1 parent 0f89a9e commit d13549f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/gmail/nossr50/config/Misc.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void onBlockPlace(BlockPlaceEvent event)
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
Expand Down
34 changes: 26 additions & 8 deletions src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -180,12 +181,21 @@ public void onExplosionPrime(ExplosionPrimeEvent event)
{
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.");

This comment has been minimized.

Copy link
@nossr50

nossr50 Mar 1, 2012

Member

Make sure to remove this once we confirm its working.

Player player = plugin.misc.tntTracker.get(location);

BlastMining.biggerBombs(Users.getProfile(player).getSkillLevel(SkillType.MINING), event);
}
}
}
Expand All @@ -195,12 +205,20 @@ public void onEnitityExplode(EntityExplodeEvent event)
{
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);
}
}
}
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ public void onPlayerInteract(PlayerInteractEvent event)
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))
{
Expand Down Expand Up @@ -289,6 +281,20 @@ public void onPlayerInteract(PlayerInteractEvent event)
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)
Expand Down

0 comments on commit d13549f

Please sign in to comment.