Changed Super Breaker to use instaBreak.

This commit is contained in:
gmcferrin 2012-02-04 02:52:31 -05:00
parent 2c380f609e
commit 897f4d3694
3 changed files with 67 additions and 244 deletions

View File

@ -370,7 +370,8 @@ public class mcBlockListener implements Listener
&& (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
{
event.setInstaBreak(true);
Unarmed.berserk(player, block);
if(LoadProperties.spoutEnabled)
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
/*
@ -385,8 +386,10 @@ public class mcBlockListener implements Listener
if(LoadProperties.miningrequirespickaxe)
{
if(m.isMiningPick(inhand))
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
} else {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin);
}
}

View File

@ -276,256 +276,112 @@ public class Mining
}
//Pre-processing
Location loc = block.getLocation();
int id = block.getTypeId();
Material mat = Material.getMaterial(id);
int xp = 0;
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
boolean silkTouch = player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH);
//STONE
if(id == 1)
{
if(block.getData() != (byte) 5)
if(id == 1 && block.getData() != (byte) 5)
{
xp += LoadProperties.mstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
if(!silkTouch)
{
mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//SANDSTONE
else if(id == 24)
{
if(block.getData() != (byte) 5)
else if(id == 24 && block.getData() != (byte) 5)
{
xp += LoadProperties.msandstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//NETHERRACK
else if(id == 87)
else if(id == 87 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.mnetherrack;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//GLOWSTONE
else if(id == 89)
else if(id == 89 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.mglowstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
if(!silkTouch)
{
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
}
else
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//COAL
else if(id == 16)
else if(id == 16 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.mcoal;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
if(!silkTouch)
{
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//GOLD
else if(id == 14 && m.getTier(player) >= 3)
else if(id == 14 && m.getTier(player) >= 3 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.mgold;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//OBSIDIAN
else if(id == 49 && m.getTier(player) >= 4)
else if(id == 49 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.mobsidian;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//DIAMOND
else if(id == 56 && m.getTier(player) >= 3)
else if(id == 56 && m.getTier(player) >= 3 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.mdiamond;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
if(!silkTouch)
{
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//IRON
else if(id == 15 && m.getTier(player) >= 2)
else if(id == 15 && m.getTier(player) >= 2 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5){
xp += LoadProperties.miron;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//REDSTONE
else if((id == 73 || id == 74) && m.getTier(player) >= 3)
{
if(!plugin.misc.blockWatchList.contains(block))
else if((id == 73 || id == 74) && m.getTier(player) >= 3 && !plugin.misc.blockWatchList.contains(block))
{
xp += LoadProperties.mredstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
if(!silkTouch)
{
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
}
else
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//LAPIS
else if(id == 21 && m.getTier(player) >= 3){
if(block.getData() != (byte) 5){
else if(id == 21 && m.getTier(player) >= 3 && block.getData() != (byte) 5)
{
xp += LoadProperties.mlapis;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
if(!silkTouch)
{
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
if(Math.random() * 10 > 5)
m.mcDropItem(loc, item);
}
else
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//NETHER BRICK
else if(id == 112){
if(block.getData() != (byte) 5){
else if(id == 112 && block.getData() != (byte) 5)
{
xp += LoadProperties.mnetherbrick;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//END STONE
else if(id == 121){
if(block.getData() != (byte) 5){
else if(id == 121 && block.getData() != (byte) 5)
{
xp += LoadProperties.mendstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//MOSS STONE
else if(id == 48){
if(block.getData() != (byte) 5){
else if(id == 48 && block.getData() != (byte) 5){
xp += LoadProperties.mmossstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//STONE BRICK
else if(id == 98){
if(!plugin.misc.blockWatchList.contains(block)){
else if(id == 98 && !plugin.misc.blockWatchList.contains(block)){
xp += LoadProperties.mstonebrick;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
PP.addXP(SkillType.MINING, xp, player);

View File

@ -21,16 +21,12 @@ import org.bukkit.entity.Player;
import org.bukkit.block.Block;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
import org.bukkit.Statistic;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.spout.SpoutStuff;
import org.getspout.spoutapi.sound.SoundEffect;
public class Unarmed {
public static void berserkActivationCheck(Player player)
@ -113,36 +109,4 @@ public class Unarmed {
}
}
}
public static void berserk(Player player, Block block){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
if(block.getTypeId() == 2 || block.getTypeId() == 110)
mat = Material.DIRT;
if(block.getTypeId() == 78)
mat = Material.SNOW_BALL;
if(block.getTypeId() == 82)
mat = Material.CLAY_BALL;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
// block.setType(Material.AIR);
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);
}
if(LoadProperties.spoutEnabled)
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}