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)) && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
{ {
event.setInstaBreak(true); 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(LoadProperties.miningrequirespickaxe)
{ {
if(m.isMiningPick(inhand)) if(m.isMiningPick(inhand))
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin); Mining.SuperBreakerBlockCheck(player, block, plugin);
} else { } else {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block, plugin); Mining.SuperBreakerBlockCheck(player, block, plugin);
} }
} }

View File

@ -276,256 +276,112 @@ public class Mining
} }
//Pre-processing //Pre-processing
Location loc = block.getLocation();
int id = block.getTypeId(); int id = block.getTypeId();
Material mat = Material.getMaterial(id);
int xp = 0; 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 //STONE
if(id == 1) if(id == 1 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5)
{ {
xp += LoadProperties.mstone; xp += LoadProperties.mstone;
blockProcCheck(block, player); blockProcCheck(block, player);
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 //SANDSTONE
else if(id == 24) else if(id == 24 && block.getData() != (byte) 5)
{
if(block.getData() != (byte) 5)
{ {
xp += LoadProperties.msandstone; xp += LoadProperties.msandstone;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
} }
//NETHERRACK //NETHERRACK
else if(id == 87) else if(id == 87 && block.getData() != (byte) 5)
{ {
if(block.getData() != (byte) 5){
xp += LoadProperties.mnetherrack; xp += LoadProperties.mnetherrack;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
} }
//GLOWSTONE //GLOWSTONE
else if(id == 89) else if(id == 89 && block.getData() != (byte) 5)
{ {
if(block.getData() != (byte) 5){
xp += LoadProperties.mglowstone; xp += LoadProperties.mglowstone;
blockProcCheck(block, player); blockProcCheck(block, player);
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 //COAL
else if(id == 16) else if(id == 16 && block.getData() != (byte) 5)
{ {
if(block.getData() != (byte) 5){
xp += LoadProperties.mcoal; xp += LoadProperties.mcoal;
blockProcCheck(block, player); blockProcCheck(block, player);
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 //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; xp += LoadProperties.mgold;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
} }
//OBSIDIAN //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; xp += LoadProperties.mobsidian;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
} }
//DIAMOND //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; xp += LoadProperties.mdiamond;
blockProcCheck(block, player); blockProcCheck(block, player);
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 //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; xp += LoadProperties.miron;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
}
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
} }
//REDSTONE //REDSTONE
else if((id == 73 || id == 74) && m.getTier(player) >= 3) else if((id == 73 || id == 74) && m.getTier(player) >= 3 && !plugin.misc.blockWatchList.contains(block))
{
if(!plugin.misc.blockWatchList.contains(block))
{ {
xp += LoadProperties.mredstone; xp += LoadProperties.mredstone;
blockProcCheck(block, player); blockProcCheck(block, player);
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 //LAPIS
else if(id == 21 && m.getTier(player) >= 3){ else if(id == 21 && m.getTier(player) >= 3 && block.getData() != (byte) 5)
if(block.getData() != (byte) 5){ {
xp += LoadProperties.mlapis; xp += LoadProperties.mlapis;
blockProcCheck(block, player); blockProcCheck(block, player);
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 //NETHER BRICK
else if(id == 112){ else if(id == 112 && block.getData() != (byte) 5)
if(block.getData() != (byte) 5){ {
xp += LoadProperties.mnetherbrick; xp += LoadProperties.mnetherbrick;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
} }
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//END STONE //END STONE
else if(id == 121){ else if(id == 121 && block.getData() != (byte) 5)
if(block.getData() != (byte) 5){ {
xp += LoadProperties.mendstone; xp += LoadProperties.mendstone;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
} }
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//MOSS STONE //MOSS STONE
else if(id == 48){ else if(id == 48 && block.getData() != (byte) 5){
if(block.getData() != (byte) 5){
xp += LoadProperties.mmossstone; xp += LoadProperties.mmossstone;
blockProcCheck(block, player); blockProcCheck(block, player);
blockProcCheck(block, player); blockProcCheck(block, player);
} }
m.mcDropItem(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//STONE BRICK //STONE BRICK
else if(id == 98){ else if(id == 98 && !plugin.misc.blockWatchList.contains(block)){
if(!plugin.misc.blockWatchList.contains(block)){
xp += LoadProperties.mstonebrick; xp += LoadProperties.mstonebrick;
blockProcCheck(block, player); blockProcCheck(block, player);
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) if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
PP.addXP(SkillType.MINING, xp, player); 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.block.Block;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
import org.bukkit.Statistic;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.spout.SpoutStuff;
import org.getspout.spoutapi.sound.SoundEffect;
public class Unarmed { public class Unarmed {
public static void berserkActivationCheck(Player player) 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());
}
} }