diff --git a/Changelog.txt b/Changelog.txt index 3f3f7314e..961e4df55 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -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) diff --git a/src/main/java/com/gmail/nossr50/config/Misc.java b/src/main/java/com/gmail/nossr50/config/Misc.java index 993b70c2f..9ba7dd4b6 100644 --- a/src/main/java/com/gmail/nossr50/config/Misc.java +++ b/src/main/java/com/gmail/nossr50/config/Misc.java @@ -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 treeFeller = new ArrayList(); public HashMap arrowTracker = new HashMap(); public ArrayList bleedTracker = new ArrayList(); + 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 e7aeb0c03..56d3035d2 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -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)) { diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index 9eaae96a1..d70ec48c6 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -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;