Framework for Blast Mining

This commit is contained in:
GJ 2012-02-07 01:36:57 -05:00
parent f9e7ae22f2
commit c70a23dd5c
4 changed files with 51 additions and 1 deletions

View File

@ -3,6 +3,7 @@ Changelog:
Version 2.0-dev
- Removed legacy Permission & PEX support. SuperPerms support only now.
- Added framework for new Mining sub-skill: Blast Mining.
Version 1.2.10
- Fixed issue with receiving Woodcutting XP for all blocks broken (Issue #103)

View File

@ -18,6 +18,8 @@ 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;
@ -35,6 +37,7 @@ public class Misc
public ArrayList<Block> treeFeller = new ArrayList<Block>();
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
public ArrayList<LivingEntity> bleedTracker = new ArrayList<LivingEntity>();
public HashMap<Location, Integer> tntTracker = new HashMap<Location, Integer>();
mcMMO plugin = null;
//BLEED QUE STUFF

View File

@ -67,6 +67,7 @@ public class mcBlockListener implements Listener
Block block;
Player player = event.getPlayer();
//When blocks are placed on snow this event reports the wrong block.
if (event.getBlockReplacedState() != null && event.getBlockReplacedState().getTypeId() == 78)
{
@ -77,6 +78,14 @@ public class mcBlockListener implements Listener
block = event.getBlock();
}
//TNT placement checks - needed for Blast Mining
if(block.getTypeId() == 46)
{
PlayerProfile PP = Users.getProfile(player);
int skill = PP.getSkillLevel(SkillType.MINING);
plugin.misc.tntTracker.put(block.getLocation(), skill);
}
//Check if the blocks placed should be monitored so they do not give out XP in the future
if(m.shouldBeWatched(block))
{

View File

@ -20,6 +20,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -29,6 +30,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Combat;
@ -40,6 +43,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.BlastMining;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
@ -52,7 +56,7 @@ public class mcEntityListener implements Listener
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.LOW)
public void onEntityDamage(EntityDamageEvent event)
{
if(event.isCancelled())
@ -77,6 +81,18 @@ public class mcEntityListener implements Listener
Users.addUser(defender);
}
/*
* Demolitions Expert
*/
if(event.getCause() == DamageCause.BLOCK_EXPLOSION)
{
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
BlastMining.demolitionsExpertise(player, event);
}
}
if(event.getEntity() instanceof LivingEntity)
{
//CraftEntity cEntity = (CraftEntity)event.getEntity();
@ -196,6 +212,27 @@ public class mcEntityListener implements Listener
}
}
@EventHandler (priority = EventPriority.LOW)
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if(event.getEntity() instanceof TNTPrimed)
{
int skillLevel = plugin.misc.tntTracker.get(event.getEntity().getLocation());
BlastMining.biggerBombs(skillLevel, event);
}
}
@EventHandler (priority = EventPriority.LOW)
public void onEnitityExplode(EntityExplodeEvent event)
{
if(event.getEntity() instanceof TNTPrimed)
{
int skillLevel = plugin.misc.tntTracker.get(event.getEntity().getLocation());
BlastMining.dropProcessing(skillLevel, event, plugin);
}
}
public boolean isBow(ItemStack is){
if (is.getTypeId() == 261){
return true;