More fixes for instaBreak, moving abilities to individual skill files.

This commit is contained in:
gmcferrin 2012-02-04 09:35:07 -05:00
parent 80abd0db91
commit bb70289cb3
3 changed files with 45 additions and 59 deletions

View File

@ -247,7 +247,7 @@ public class mcBlockListener implements Listener
* EXCAVATION
*/
if(Excavation.canBeGigaDrillBroken(block) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5)
Excavation.excavationProcCheck(block.getData(), block.getType(), block.getLocation(), player);
Excavation.excavationProcCheck(block.getType(), block.getLocation(), player);
/*
* HERBALISM
*/
@ -312,54 +312,21 @@ public class mcBlockListener implements Listener
/*
* GIGA DRILL BREAKER CHECKS
*/
if(PP.getGigaDrillBreakerMode() && m.blockBreakSimulate(block, player)
&& Excavation.canBeGigaDrillBroken(block) && m.isShovel(inhand))
{
int x = 0;
while(x < 3)
if(PP.getGigaDrillBreakerMode()
&& Excavation.canBeGigaDrillBroken(block)
&& m.blockBreakSimulate(block, player)
&& mcPermissions.getInstance().excavationAbility(player))
{
if(LoadProperties.excavationRequiresShovel)
{
if(block.getData() != (byte)5)
Excavation.excavationProcCheck(block.getData(), block.getType(), block.getLocation(), player);
x++;
if(m.isShovel(inhand)){
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
} else {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
Material mat = Material.getMaterial(block.getTypeId());
if(block.getType() == Material.GRASS)
mat = Material.DIRT;
if(block.getType() == Material.CLAY)
mat = Material.CLAY_BALL;
if(block.getType() == Material.MYCEL)
mat = Material.DIRT;
byte type = block.getData();
ItemStack item = new ItemStack(mat, 1, (byte)0, type);
block.setType(Material.AIR);
player.incrementStatistic(Statistic.MINE_BLOCK, event.getBlock().getType());
if(LoadProperties.toolsLoseDurabilityFromAbilities)
{
if(!inhand.getEnchantments().containsKey(Enchantment.DURABILITY))
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
}
if(item.getType() == Material.CLAY_BALL)
{
m.mcDropItem(block.getLocation(), item);
m.mcDropItem(block.getLocation(), item);
m.mcDropItem(block.getLocation(), item);
m.mcDropItem(block.getLocation(), item);
} else
{
m.mcDropItem(block.getLocation(), item);
}
//Spout stuff
if(LoadProperties.spoutEnabled)
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
/*
* BERSERK MODE CHECKS
@ -367,7 +334,8 @@ public class mcBlockListener implements Listener
if(PP.getBerserkMode()
&& m.blockBreakSimulate(block, player)
&& player.getItemInHand().getTypeId() == 0
&& (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
&& (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78)
&& mcPermissions.getInstance().unarmedAbility(player))
{
event.setInstaBreak(true);
if(LoadProperties.spoutEnabled)
@ -380,14 +348,14 @@ public class mcBlockListener implements Listener
if(PP.getSuperBreakerMode()
&& Mining.canBeSuperBroken(block)
&& m.blockBreakSimulate(block, player)
&& mcPermissions.getInstance().mining(player))
&& mcPermissions.getInstance().miningAbility(player))
{
if(LoadProperties.miningrequirespickaxe)
{
if(m.isMiningPick(inhand))
if(m.isMiningPick(inhand)){
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
}
} else {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
@ -398,16 +366,18 @@ public class mcBlockListener implements Listener
* LEAF BLOWER CHECKS
*/
if(block.getTypeId() == 18
&& mcPermissions.getInstance().woodcutting(player)
&& mcPermissions.getInstance().woodcuttingAbility(player)
&& PP.getSkillLevel(SkillType.WOODCUTTING) >= 100
&& m.blockBreakSimulate(block, player))
{
if(LoadProperties.woodcuttingrequiresaxe)
{
if(m.isAxes(inhand))
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}
else{
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}

View File

@ -23,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
@ -74,7 +75,7 @@ public class Excavation
Material t = block.getType();
return t == Material.DIRT || t == Material.GRASS || t == Material.SAND || t == Material.GRAVEL || t == Material.CLAY || t == Material.MYCEL || t == Material.SOUL_SAND;
}
public static void excavationProcCheck(byte data, Material type, Location loc, Player player)
public static void excavationProcCheck(Material type, Location loc, Player player)
{
if(LoadProperties.excavationRequiresShovel && !m.isShovel(player.getItemInHand()))
return;
@ -253,4 +254,23 @@ public class Excavation
PP.addXP(SkillType.EXCAVATION, xp, player);
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
}
public static void gigaDrillBreaker(Player player, Block block)
{
if(LoadProperties.toolsLoseDurabilityFromAbilities)
{
if(!player.getItemInHand.containsEnchantment(Enchantment.DURABILITY))
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
}
if(block.getData() != (byte)5)
{
Excavation.excavationProcCheck(block.getType(), block.getLocation(), player);
Excavation.excavationProcCheck(block.getType(), block.getLocation(), player);
Excavation.excavationProcCheck(block.getType(), block.getLocation(), player);
}
if(LoadProperties.spoutEnabled)
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}

View File

@ -17,7 +17,6 @@
package com.gmail.nossr50.skills;
import java.util.ArrayList;
import net.minecraft.server.Enchantment;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -25,10 +24,10 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Statistic;
import org.bukkit.enchantments.Enchantment;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
@ -203,7 +202,7 @@ public class WoodCutting
public static void leafBlower(Player player, Block block){
if(LoadProperties.toolsLoseDurabilityFromAbilities)
{
if(!player.getItemInHand().getEnchantments().containsKey(Enchantment.DURABILITY))
if(!player.getItemInHand().containsEnchantment(Enchantment.DURABILITY))
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
}
@ -213,9 +212,6 @@ public class WoodCutting
m.mcDropItem(block.getLocation(), x);
}
block.setType(Material.AIR);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
if(LoadProperties.spoutEnabled)
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}