2011-04-20 22:56:25 +02:00
|
|
|
package com.gmail.nossr50.skills;
|
|
|
|
|
2011-08-07 01:31:34 +02:00
|
|
|
import java.util.ArrayList;
|
2011-04-20 22:56:25 +02:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2011-07-16 09:12:26 +02:00
|
|
|
import com.gmail.nossr50.locale.mcLocale;
|
2011-04-20 22:56:25 +02:00
|
|
|
import com.gmail.nossr50.Users;
|
|
|
|
import com.gmail.nossr50.m;
|
|
|
|
import com.gmail.nossr50.config.LoadProperties;
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
2011-07-19 16:17:14 +02:00
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2011-04-20 22:56:25 +02:00
|
|
|
|
|
|
|
|
2011-07-19 16:17:14 +02:00
|
|
|
public class Excavation
|
|
|
|
{
|
2011-08-08 00:44:50 +02:00
|
|
|
public static void gigaDrillBreakerActivationCheck(Player player, Block block)
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
PlayerProfile PP = Users.getProfile(player);
|
2011-07-19 16:17:14 +02:00
|
|
|
if(m.isShovel(player.getItemInHand()))
|
|
|
|
{
|
|
|
|
if(block != null)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
if(!m.abilityBlockCheck(block))
|
|
|
|
return;
|
|
|
|
}
|
2011-07-19 16:17:14 +02:00
|
|
|
if(PP.getShovelPreparationMode())
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
PP.setShovelPreparationMode(false);
|
|
|
|
}
|
|
|
|
int ticks = 2;
|
2011-07-19 16:17:14 +02:00
|
|
|
int x = PP.getSkillLevel(SkillType.EXCAVATION);
|
|
|
|
while(x >= 50)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
x-=50;
|
|
|
|
ticks++;
|
|
|
|
}
|
|
|
|
|
2011-07-19 16:17:14 +02:00
|
|
|
if(!PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerDeactivatedTimeStamp() < System.currentTimeMillis())
|
|
|
|
{
|
2011-07-16 09:12:26 +02:00
|
|
|
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOn"));
|
2011-08-08 00:44:50 +02:00
|
|
|
for(Player y : player.getWorld().getPlayers())
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
|
2011-07-16 09:12:26 +02:00
|
|
|
y.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerPlayer", new Object[] {player.getName()}));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
PP.setGigaDrillBreakerActivatedTimeStamp(System.currentTimeMillis());
|
2011-04-30 22:53:08 +02:00
|
|
|
PP.setGigaDrillBreakerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
|
2011-04-20 22:56:25 +02:00
|
|
|
PP.setGigaDrillBreakerMode(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2011-07-19 16:17:14 +02:00
|
|
|
public static boolean canBeGigaDrillBroken(Block block)
|
|
|
|
{
|
2011-08-16 11:33:34 +02:00
|
|
|
return block.getType() == Material.DIRT || block.getType() == Material.GRASS || block.getType() == Material.SAND || block.getType() == Material.GRAVEL || block.getType() == Material.CLAY;
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
2011-08-16 13:29:32 +02:00
|
|
|
public static void excavationProcCheck(byte data, Material type, Location loc, Player player)
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
2011-09-06 02:02:11 +02:00
|
|
|
if(LoadProperties.excavationRequiresShovel && !m.isShovel(player.getItemInHand()))
|
|
|
|
return;
|
|
|
|
|
2011-04-20 22:56:25 +02:00
|
|
|
PlayerProfile PP = Users.getProfile(player);
|
2011-08-07 01:31:34 +02:00
|
|
|
ArrayList<ItemStack> is = new ArrayList<ItemStack>();
|
|
|
|
|
|
|
|
int xp = 0;
|
2011-07-19 22:57:08 +02:00
|
|
|
|
2011-08-07 01:31:34 +02:00
|
|
|
switch(type)
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
2011-08-16 13:29:32 +02:00
|
|
|
case GRASS:
|
2011-07-19 16:17:14 +02:00
|
|
|
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 250)
|
2011-07-18 21:22:41 +02:00
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
//CHANCE TO GET EGGS
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.eggs == true && Math.random() * 100 > 99)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.meggs;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.EGG, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
//CHANCE TO GET APPLES
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.apples == true && Math.random() * 100 > 99)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mapple;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.APPLE, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-07 01:31:34 +02:00
|
|
|
break;
|
2011-08-16 13:29:32 +02:00
|
|
|
case GRAVEL:
|
2011-08-07 01:31:34 +02:00
|
|
|
//CHANCE TO GET NETHERRACK
|
|
|
|
if(LoadProperties.netherrack == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 850 && Math.random() * 200 > 199)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mnetherrack;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.NETHERRACK, 1, (byte)0, (byte)0));
|
|
|
|
|
|
|
|
}
|
|
|
|
//CHANCE TO GET SULPHUR
|
|
|
|
if(LoadProperties.sulphur == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 75)
|
|
|
|
{
|
|
|
|
if(Math.random() * 10 > 9)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.msulphur;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.SULPHUR, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//CHANCE TO GET BONES
|
|
|
|
if(LoadProperties.bones == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 175)
|
|
|
|
{
|
|
|
|
if(Math.random() * 10 > 9)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mbones;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.BONE, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-08-16 13:29:32 +02:00
|
|
|
case SAND:
|
2011-08-07 01:31:34 +02:00
|
|
|
//CHANCE TO GET GLOWSTONE
|
|
|
|
if(LoadProperties.glowstone == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 50 && Math.random() * 100 > 95)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mglowstone2;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.GLOWSTONE_DUST, 1, (byte)0, (byte)0));
|
|
|
|
|
|
|
|
}
|
|
|
|
//CHANCE TO GET SOUL SAND
|
|
|
|
if(LoadProperties.slowsand == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 650 && Math.random() * 200 > 199)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mslowsand;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.SOUL_SAND, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
break;
|
2011-08-16 13:29:32 +02:00
|
|
|
case CLAY:
|
2011-08-20 19:25:48 +02:00
|
|
|
if(LoadProperties.slimeballs && PP.getSkillLevel(SkillType.EXCAVATION) >= 50)
|
2011-08-14 10:37:03 +02:00
|
|
|
{
|
|
|
|
if(Math.random() * 20 > 19)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mslimeballs;
|
2011-08-14 10:37:03 +02:00
|
|
|
is.add(new ItemStack(Material.SLIME_BALL, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
}
|
2011-08-16 11:33:34 +02:00
|
|
|
if(LoadProperties.string && PP.getSkillLevel(SkillType.EXCAVATION) >= 250)
|
|
|
|
{
|
|
|
|
if(Math.random() * 20 > 19)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mstring;
|
2011-08-16 11:33:34 +02:00
|
|
|
is.add(new ItemStack(Material.STRING, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
}
|
2011-08-20 19:25:48 +02:00
|
|
|
if(LoadProperties.watch && PP.getSkillLevel(SkillType.EXCAVATION) >= 500)
|
2011-08-16 11:33:34 +02:00
|
|
|
{
|
2011-08-20 19:25:48 +02:00
|
|
|
if(Math.random() * 100 > 99)
|
2011-08-16 11:33:34 +02:00
|
|
|
{
|
2011-08-20 19:25:48 +02:00
|
|
|
xp+= LoadProperties.mwatch;
|
2011-08-21 03:23:38 +02:00
|
|
|
is.add(new ItemStack(Material.WATCH, 1, (byte)0));
|
2011-08-16 11:33:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(LoadProperties.bucket && PP.getSkillLevel(SkillType.EXCAVATION) >= 500)
|
|
|
|
{
|
|
|
|
if(Math.random() * 100 > 99)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mbucket;
|
2011-08-16 11:33:34 +02:00
|
|
|
is.add(new ItemStack(Material.BUCKET, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(LoadProperties.web && PP.getSkillLevel(SkillType.EXCAVATION) >= 750)
|
|
|
|
{
|
|
|
|
if(Math.random() * 20 > 19)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mweb;
|
2011-08-16 11:33:34 +02:00
|
|
|
is.add(new ItemStack(Material.WEB, 1, (byte)0, (byte)0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
2011-08-07 01:31:34 +02:00
|
|
|
|
2011-04-20 22:56:25 +02:00
|
|
|
//DIRT SAND OR GRAVEL
|
2011-08-16 13:29:32 +02:00
|
|
|
if(type == Material.GRASS || type == Material.DIRT || type == Material.GRAVEL || type == Material.SAND || type == Material.CLAY)
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mbase;
|
2011-08-07 01:31:34 +02:00
|
|
|
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 750)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
//CHANCE TO GET CAKE
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.cake == true && Math.random() * 2000 > 1999)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mcake;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.CAKE, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-19 16:17:14 +02:00
|
|
|
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 350)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
//CHANCE TO GET DIAMOND
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.diamond == true && Math.random() * 750 > 749)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mdiamond2;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.DIAMOND, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-19 16:17:14 +02:00
|
|
|
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 250)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
//CHANCE TO GET YELLOW MUSIC
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.music == true && Math.random() * 2000 > 1999)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mmusic;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.GOLD_RECORD, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-19 16:17:14 +02:00
|
|
|
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 350)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
//CHANCE TO GET GREEN MUSIC
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.music == true && Math.random() * 2000 > 1999)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mmusic;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.GREEN_RECORD, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-07 01:31:34 +02:00
|
|
|
|
2011-04-20 22:56:25 +02:00
|
|
|
//GRASS OR DIRT
|
2011-08-16 13:29:32 +02:00
|
|
|
if(type == Material.DIRT || type == Material.GRASS)
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
|
|
|
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 50)
|
|
|
|
{
|
2011-04-20 22:56:25 +02:00
|
|
|
//CHANCE FOR COCOA BEANS
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.cocoabeans == true && Math.random() * 75 > 74)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mcocoa;
|
2011-08-16 11:33:34 +02:00
|
|
|
is.add(new ItemStack(Material.getMaterial(351), 1, (byte)0, (byte)3));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//CHANCE FOR SHROOMS
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.mushrooms == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 500 && Math.random() * 200 > 199)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mmushroom2;
|
2011-08-07 01:31:34 +02:00
|
|
|
switch((int) Math.random() * 1)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
is.add(new ItemStack(Material.BROWN_MUSHROOM, 1, (byte)0, (byte)0));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
is.add(new ItemStack(Material.RED_MUSHROOM, 1, (byte)0, (byte)0));
|
|
|
|
break;
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
2011-08-07 01:31:34 +02:00
|
|
|
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
//CHANCE TO GET GLOWSTONE
|
2011-07-19 16:17:14 +02:00
|
|
|
if(LoadProperties.glowstone == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 25 && Math.random() * 100 > 95)
|
|
|
|
{
|
2011-08-19 17:40:14 +02:00
|
|
|
xp+= LoadProperties.mglowstone2;
|
2011-08-07 01:31:34 +02:00
|
|
|
is.add(new ItemStack(Material.GLOWSTONE_DUST, 1, (byte)0, (byte)0));
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-07 01:31:34 +02:00
|
|
|
|
|
|
|
//Drop items
|
|
|
|
for(ItemStack x : is)
|
2011-07-19 16:17:14 +02:00
|
|
|
{
|
2011-08-07 01:31:34 +02:00
|
|
|
if(x != null)
|
|
|
|
loc.getWorld().dropItemNaturally(loc, x);
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
2011-08-07 01:31:34 +02:00
|
|
|
|
|
|
|
//Handle XP related tasks
|
|
|
|
PP.addXP(SkillType.EXCAVATION, xp);
|
2011-07-19 16:17:14 +02:00
|
|
|
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
|
2011-04-20 22:56:25 +02:00
|
|
|
}
|
|
|
|
}
|