Update to mining

- Make a bit more efficient
 - Some more comments
This commit is contained in:
NuclearW 2012-01-31 12:59:33 -05:00
parent 563baea812
commit e82d5db4b3

View File

@ -82,16 +82,22 @@ public class Mining
Material mat = Material.getMaterial(block.getTypeId()); Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0; byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage); ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 int id = block.getTypeId();
&& block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
if(id != 89 && id != 73 && id != 74 && id != 56 && id != 21 && id != 1 && id != 16) {
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
if(block.getTypeId() == 89) return;
}
//GLOWSTONE
if(id == 89)
{ {
mat = Material.getMaterial(348); mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage); item = new ItemStack(mat, 1, (byte)0, damage);
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
} }
if(block.getTypeId() == 73 || block.getTypeId() == 74) //REDSTONE
else if(id == 73 || id == 74)
{ {
mat = Material.getMaterial(331); mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage); item = new ItemStack(mat, 1, (byte)0, damage);
@ -102,7 +108,8 @@ public class Mining
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
} }
} }
if(block.getTypeId() == 21) //LAPUS
else if(id == 21)
{ {
mat = Material.getMaterial(351); mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4); item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
@ -111,25 +118,29 @@ public class Mining
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
} }
if(block.getTypeId() == 56) //DIAMOND
else if(id == 56)
{ {
mat = Material.getMaterial(264); mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage); item = new ItemStack(mat, 1, (byte)0, damage);
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
} }
if(block.getTypeId() == 1) //STONE
else if(id == 1)
{ {
mat = Material.getMaterial(4); mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage); item = new ItemStack(mat, 1, (byte)0, damage);
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
} }
if(block.getTypeId() == 16) //COAL
else if(id == 16)
{ {
mat = Material.getMaterial(263); mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage); item = new ItemStack(mat, 1, (byte)0, damage);
m.mcDropItem(loc, item); m.mcDropItem(loc, item);
} }
} }
public static void blockProcCheck(Block block, Player player) public static void blockProcCheck(Block block, Player player)
{ {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
@ -147,7 +158,9 @@ public class Mining
if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5) if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5)
return; return;
int xp = 0; int xp = 0;
if(block.getTypeId() == 1 || block.getTypeId() == 24) int id = block.getTypeId();
if(id == 1 || id == 24)
{ {
xp += LoadProperties.mstone; xp += LoadProperties.mstone;
if(smelt = false) if(smelt = false)
@ -156,7 +169,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//OBSIDIAN //OBSIDIAN
if(block.getTypeId() == 49) else if(id == 49)
{ {
xp += LoadProperties.mobsidian; xp += LoadProperties.mobsidian;
if(smelt = false) if(smelt = false)
@ -165,7 +178,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//NETHERRACK //NETHERRACK
if(block.getTypeId() == 87) else if(id == 87)
{ {
xp += LoadProperties.mnetherrack; xp += LoadProperties.mnetherrack;
if(smelt = false) if(smelt = false)
@ -174,7 +187,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//GLOWSTONE //GLOWSTONE
if(block.getTypeId() == 89) else if(id == 89)
{ {
xp += LoadProperties.mglowstone; xp += LoadProperties.mglowstone;
if(smelt = false) if(smelt = false)
@ -183,7 +196,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//COAL //COAL
if(block.getTypeId() == 16) else if(id == 16)
{ {
xp += LoadProperties.mcoal; xp += LoadProperties.mcoal;
if(smelt = false) if(smelt = false)
@ -192,7 +205,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//GOLD //GOLD
if(block.getTypeId() == 14) else if(id == 14)
{ {
xp += LoadProperties.mgold; xp += LoadProperties.mgold;
if(smelt = false) if(smelt = false)
@ -201,7 +214,8 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//DIAMOND //DIAMOND
if(block.getTypeId() == 56){ else if(id == 56)
{
xp += LoadProperties.mdiamond; xp += LoadProperties.mdiamond;
if(smelt = false) if(smelt = false)
blockProcCheck(block, player); blockProcCheck(block, player);
@ -209,7 +223,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//IRON //IRON
if(block.getTypeId() == 15) else if(id == 15)
{ {
xp += LoadProperties.miron; xp += LoadProperties.miron;
if(smelt = false) if(smelt = false)
@ -218,7 +232,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//REDSTONE //REDSTONE
if(block.getTypeId() == 73 || block.getTypeId() == 74) else if(id == 73 || id == 74)
{ {
xp += LoadProperties.mredstone; xp += LoadProperties.mredstone;
if(smelt = false) if(smelt = false)
@ -227,7 +241,7 @@ public class Mining
blockProcCheck(block, player); blockProcCheck(block, player);
} }
//LAPUS //LAPUS
if(block.getTypeId() == 21) else if(id == 21)
{ {
xp += LoadProperties.mlapis; xp += LoadProperties.mlapis;
if(smelt = false) if(smelt = false)
@ -269,9 +283,11 @@ public class Mining
int xp = 0; int xp = 0;
byte damage = 0; byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage); ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() == 1 || block.getTypeId() == 24) int id = block.getTypeId();
if(id == 1 || id == 24)
{ {
if(block.getTypeId() == 1) if(id == 1)
{ {
mat = Material.COBBLESTONE; mat = Material.COBBLESTONE;
if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5) if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
@ -296,7 +312,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//NETHERRACK //NETHERRACK
if(block.getTypeId() == 87) else if(id == 87)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mnetherrack; xp += LoadProperties.mnetherrack;
@ -310,7 +326,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//GLOWSTONE //GLOWSTONE
if(block.getTypeId() == 89) else if(id == 89)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mglowstone; xp += LoadProperties.mglowstone;
@ -324,7 +340,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//COAL //COAL
if(block.getTypeId() == 16) else if(id == 16)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mcoal; xp += LoadProperties.mcoal;
@ -338,7 +354,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//GOLD //GOLD
if(block.getTypeId() == 14 && m.getTier(player) >= 3) else if(id == 14 && m.getTier(player) >= 3)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mgold; xp += LoadProperties.mgold;
@ -351,7 +367,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//OBSIDIAN //OBSIDIAN
if(block.getTypeId() == 49 && m.getTier(player) >= 4) else if(id == 49 && m.getTier(player) >= 4)
{ {
if(LoadProperties.toolsLoseDurabilityFromAbilities) if(LoadProperties.toolsLoseDurabilityFromAbilities)
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss); m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
@ -367,7 +383,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//DIAMOND //DIAMOND
if(block.getTypeId() == 56 && m.getTier(player) >= 3) else if(id == 56 && m.getTier(player) >= 3)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mdiamond; xp += LoadProperties.mdiamond;
@ -381,7 +397,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//IRON //IRON
if(block.getTypeId() == 15 && m.getTier(player) >= 2) else if(id == 15 && m.getTier(player) >= 2)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.miron; xp += LoadProperties.miron;
@ -394,7 +410,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//REDSTONE //REDSTONE
if((block.getTypeId() == 73 || block.getTypeId() == 74) && m.getTier(player) >= 3) else if((id == 73 || id == 74) && m.getTier(player) >= 3)
{ {
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5) if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5)
{ {
@ -415,7 +431,7 @@ public class Mining
block.setType(Material.AIR); block.setType(Material.AIR);
} }
//LAPUS //LAPUS
if(block.getTypeId() == 21 && m.getTier(player) >= 3){ else if(id == 21 && m.getTier(player) >= 3){
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){ if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mlapis; xp += LoadProperties.mlapis;
blockProcCheck(block, player); blockProcCheck(block, player);