2012-05-01 19:58:47 +02:00
|
|
|
package com.gmail.nossr50.skills.gathering;
|
2011-11-28 14:17:01 +01:00
|
|
|
|
2012-12-06 20:11:12 +01:00
|
|
|
import java.lang.reflect.Method;
|
2012-03-13 08:00:49 +01:00
|
|
|
import java.util.ArrayList;
|
2012-02-21 19:10:51 +01:00
|
|
|
import java.util.List;
|
2012-03-14 16:43:18 +01:00
|
|
|
import java.util.Map;
|
2012-03-26 17:04:17 +02:00
|
|
|
import java.util.Random;
|
2012-02-21 19:10:51 +01:00
|
|
|
|
2012-01-29 08:51:59 +01:00
|
|
|
import org.bukkit.Location;
|
2011-11-28 14:17:01 +01:00
|
|
|
import org.bukkit.Material;
|
2011-12-01 18:46:46 +01:00
|
|
|
import org.bukkit.enchantments.Enchantment;
|
2012-03-13 08:00:49 +01:00
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.Item;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Sheep;
|
2011-11-28 14:17:01 +01:00
|
|
|
import org.bukkit.event.player.PlayerFishEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2011-12-01 18:46:46 +01:00
|
|
|
import org.bukkit.material.Wool;
|
2011-11-28 14:17:01 +01:00
|
|
|
|
2012-11-21 21:49:54 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2012-04-26 16:27:57 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2012-05-17 16:26:21 +02:00
|
|
|
import com.gmail.nossr50.config.TreasuresConfig;
|
2011-11-28 14:17:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2012-02-21 08:53:34 +01:00
|
|
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.Combat;
|
|
|
|
import com.gmail.nossr50.util.ItemChecks;
|
|
|
|
import com.gmail.nossr50.util.Misc;
|
2012-04-30 14:26:37 +02:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2012-05-01 19:58:47 +02:00
|
|
|
import com.gmail.nossr50.util.Skills;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.util.Users;
|
2011-11-28 14:17:01 +01:00
|
|
|
|
|
|
|
public class Fishing {
|
2012-01-19 20:29:03 +01:00
|
|
|
|
2012-03-26 17:04:17 +02:00
|
|
|
private static Random random = new Random();
|
2012-11-21 21:49:54 +01:00
|
|
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
2012-03-26 17:04:17 +02:00
|
|
|
|
2012-03-13 08:00:49 +01:00
|
|
|
/**
|
|
|
|
* Get the player's current fishing loot tier.
|
|
|
|
*
|
2012-07-03 16:04:04 +02:00
|
|
|
* @param profile The profile of the player
|
2012-03-13 08:00:49 +01:00
|
|
|
* @return the player's current fishing rank
|
|
|
|
*/
|
2012-07-03 16:04:04 +02:00
|
|
|
public static int getFishingLootTier(PlayerProfile profile) {
|
|
|
|
int level = profile.getSkillLevel(SkillType.FISHING);
|
2012-03-13 08:00:49 +01:00
|
|
|
int fishingTier;
|
|
|
|
|
2012-04-27 05:58:21 +02:00
|
|
|
if (level >= Config.getInstance().getFishingTierLevelsTier5()) {
|
2012-03-13 08:00:49 +01:00
|
|
|
fishingTier = 5;
|
|
|
|
}
|
2012-04-27 05:58:21 +02:00
|
|
|
else if (level >= Config.getInstance().getFishingTierLevelsTier4()) {
|
2012-03-13 08:00:49 +01:00
|
|
|
fishingTier = 4;
|
|
|
|
}
|
2012-04-27 05:58:21 +02:00
|
|
|
else if (level >= Config.getInstance().getFishingTierLevelsTier3()) {
|
2012-03-13 08:00:49 +01:00
|
|
|
fishingTier = 3;
|
|
|
|
}
|
2012-04-27 05:58:21 +02:00
|
|
|
else if (level >= Config.getInstance().getFishingTierLevelsTier2()) {
|
2012-03-13 08:00:49 +01:00
|
|
|
fishingTier = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fishingTier = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fishingTier;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get item results from Fishing.
|
|
|
|
*
|
|
|
|
* @param player The player that was fishing
|
|
|
|
* @param event The event to modify
|
|
|
|
*/
|
|
|
|
private static void getFishingResults(Player player, PlayerFishEvent event) {
|
2012-10-30 19:46:52 +01:00
|
|
|
if(player == null)
|
|
|
|
return;
|
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
PlayerProfile profile = Users.getProfile(player);
|
2012-03-13 08:00:49 +01:00
|
|
|
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
|
|
|
Item theCatch = (Item) event.getCaught();
|
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
switch (getFishingLootTier(profile)) {
|
2012-03-13 08:00:49 +01:00
|
|
|
case 1:
|
2012-05-17 16:26:21 +02:00
|
|
|
rewards = TreasuresConfig.getInstance().fishingRewardsTier1;
|
2012-03-13 08:00:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2012-05-17 16:26:21 +02:00
|
|
|
rewards = TreasuresConfig.getInstance().fishingRewardsTier2;
|
2012-03-13 08:00:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2012-05-17 16:26:21 +02:00
|
|
|
rewards = TreasuresConfig.getInstance().fishingRewardsTier3;
|
2012-03-13 08:00:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2012-05-17 16:26:21 +02:00
|
|
|
rewards = TreasuresConfig.getInstance().fishingRewardsTier4;
|
2012-03-13 08:00:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2012-05-17 16:26:21 +02:00
|
|
|
rewards = TreasuresConfig.getInstance().fishingRewardsTier5;
|
2012-03-13 08:00:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-30 14:26:37 +02:00
|
|
|
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
|
2012-04-24 15:21:21 +02:00
|
|
|
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
|
|
|
|
2012-07-02 17:09:55 +02:00
|
|
|
int randomChance = 100;
|
|
|
|
|
|
|
|
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
|
|
|
randomChance = (int) (randomChance * 0.75);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
|
2012-07-06 17:57:17 +02:00
|
|
|
Users.getPlayer(player).addXP(SkillType.FISHING, treasure.getXp());
|
2012-04-24 15:21:21 +02:00
|
|
|
theCatch.setItemStack(treasure.getDrop());
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
|
|
|
}
|
|
|
|
|
2012-03-27 13:51:30 +02:00
|
|
|
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
|
|
|
|
|
|
|
|
if (maxDurability > 0) {
|
|
|
|
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
|
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process results from Fishing.
|
|
|
|
*
|
|
|
|
* @param event The event to modify
|
|
|
|
*/
|
|
|
|
public static void processResults(PlayerFishEvent event) {
|
|
|
|
Player player = event.getPlayer();
|
2012-10-30 19:46:52 +01:00
|
|
|
if(player == null)
|
|
|
|
return;
|
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
PlayerProfile profile = Users.getProfile(player);
|
2012-03-13 08:00:49 +01:00
|
|
|
|
|
|
|
getFishingResults(player, event);
|
2012-04-30 14:26:37 +02:00
|
|
|
Item theCatch = (Item) event.getCaught();
|
2012-03-13 08:00:49 +01:00
|
|
|
|
|
|
|
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
|
2012-11-21 21:49:54 +01:00
|
|
|
final int ENCHANTMENT_CHANCE = advancedConfig.getFishingEnchantmentChance();
|
2012-03-13 08:00:49 +01:00
|
|
|
boolean enchanted = false;
|
|
|
|
ItemStack fishingResults = theCatch.getItemStack();
|
2012-03-14 18:33:00 +01:00
|
|
|
|
2012-04-27 11:47:11 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
2012-07-02 17:09:55 +02:00
|
|
|
|
2012-10-31 20:39:04 +01:00
|
|
|
if (ItemChecks.isEnchantable(fishingResults)) {
|
2012-07-02 17:09:55 +02:00
|
|
|
int randomChance = 100;
|
|
|
|
|
|
|
|
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
2012-11-07 13:32:30 +01:00
|
|
|
randomChance = (int) (randomChance * 0.75);
|
2012-07-02 17:09:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
|
2012-03-14 16:43:18 +01:00
|
|
|
for (Enchantment newEnchant : Enchantment.values()) {
|
|
|
|
if (newEnchant.canEnchantItem(fishingResults)) {
|
|
|
|
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2012-03-14 16:43:18 +01:00
|
|
|
for (Enchantment oldEnchant : resultEnchantments.keySet()) {
|
2012-11-01 06:47:04 +01:00
|
|
|
if (oldEnchant.conflictsWith(newEnchant))
|
|
|
|
continue;
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
2012-03-14 16:43:18 +01:00
|
|
|
/* Actual chance to have an enchantment is related to your fishing skill */
|
2012-07-03 16:04:04 +02:00
|
|
|
if (random.nextInt(15) < Fishing.getFishingLootTier(profile)) {
|
2012-03-14 16:43:18 +01:00
|
|
|
enchanted = true;
|
2012-03-26 17:04:17 +02:00
|
|
|
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2012-03-14 18:33:00 +01:00
|
|
|
if (randomEnchantLevel < newEnchant.getStartLevel()) {
|
|
|
|
randomEnchantLevel = newEnchant.getStartLevel();
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
2012-03-14 16:43:18 +01:00
|
|
|
|
2012-11-01 06:47:04 +01:00
|
|
|
if(randomEnchantLevel >= 1000)
|
|
|
|
continue;
|
|
|
|
|
2012-03-14 16:43:18 +01:00
|
|
|
fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enchanted) {
|
2012-04-27 11:47:11 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shake a mob, have them drop an item.
|
|
|
|
*
|
|
|
|
* @param event The event to modify
|
|
|
|
*/
|
|
|
|
public static void shakeMob(PlayerFishEvent event) {
|
2012-07-02 17:09:55 +02:00
|
|
|
int randomChance = 100;
|
|
|
|
|
|
|
|
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
|
2012-11-07 13:32:30 +01:00
|
|
|
randomChance = (int) (randomChance * 1.25);
|
2012-07-02 17:09:55 +02:00
|
|
|
}
|
|
|
|
|
2012-11-07 13:30:20 +01:00
|
|
|
final Player player = event.getPlayer();
|
|
|
|
final PlayerProfile profile = Users.getProfile(player);
|
2012-11-13 01:33:37 +01:00
|
|
|
int lootTier = getFishingLootTier(profile);
|
2012-06-05 15:57:10 +02:00
|
|
|
|
2012-11-08 20:15:40 +01:00
|
|
|
int dropChance = getShakeChance(lootTier);
|
|
|
|
|
2012-11-07 13:30:20 +01:00
|
|
|
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
|
2012-11-13 01:33:37 +01:00
|
|
|
dropChance = (int) (dropChance * 1.25); //With lucky perk on max level tier, its 100%
|
2012-11-07 13:30:20 +01:00
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2012-11-07 13:30:20 +01:00
|
|
|
final int DROP_CHANCE = random.nextInt(100);
|
|
|
|
final int DROP_NUMBER = random.nextInt(randomChance) + 1;
|
2012-10-29 22:27:22 +01:00
|
|
|
|
2012-11-07 13:30:20 +01:00
|
|
|
LivingEntity le = (LivingEntity) event.getCaught();
|
|
|
|
EntityType type = le.getType();
|
|
|
|
Location location = le.getLocation();
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2012-11-07 13:30:20 +01:00
|
|
|
if (DROP_CHANCE < dropChance) {
|
|
|
|
|
2012-11-13 01:33:37 +01:00
|
|
|
switch (type) {
|
|
|
|
case BLAZE:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.BLAZE_ROD));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAVE_SPIDER:
|
|
|
|
if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.STRING));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHICKEN:
|
|
|
|
if (DROP_NUMBER > 66) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.FEATHER));
|
|
|
|
} else if (DROP_NUMBER > 33) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.RAW_CHICKEN));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.EGG));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COW:
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
|
|
|
|
} else if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.LEATHER));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CREEPER:
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ENDERMAN:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.ENDER_PEARL));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GHAST:
|
|
|
|
if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.GHAST_TEAR));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IRON_GOLEM:
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
|
|
|
} else if (DROP_NUMBER > 85) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.IRON_INGOT));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.RED_ROSE));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MAGMA_CUBE:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.MAGMA_CREAM));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MUSHROOM_COW:
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
|
|
|
|
} else if (DROP_NUMBER > 90) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.MUSHROOM_SOUP));
|
|
|
|
} else if (DROP_NUMBER > 60) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.LEATHER));
|
|
|
|
} else if (DROP_NUMBER > 30) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.RED_MUSHROOM));
|
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.RED_MUSHROOM), 50, 2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIG:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.PORK));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIG_ZOMBIE:
|
|
|
|
if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.GOLD_NUGGET));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SHEEP:
|
|
|
|
final Sheep sheep = (Sheep) le;
|
|
|
|
|
|
|
|
if (!sheep.isSheared()) {
|
|
|
|
final Wool wool = new Wool();
|
|
|
|
wool.setColor(sheep.getColor());
|
|
|
|
|
|
|
|
final ItemStack theWool = wool.toItemStack();
|
|
|
|
theWool.setAmount(1 + random.nextInt(6));
|
|
|
|
|
|
|
|
Misc.dropItem(location, theWool);
|
|
|
|
sheep.setSheared(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SKELETON:
|
2012-12-06 20:11:12 +01:00
|
|
|
Object o;
|
|
|
|
Class c;
|
|
|
|
Method m;
|
|
|
|
|
|
|
|
o = le;
|
|
|
|
c = o.getClass();
|
|
|
|
|
|
|
|
boolean isWitherSkeleton = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
m = c.getDeclaredMethod("getHandle");
|
|
|
|
o = m.invoke(o);
|
|
|
|
|
|
|
|
c = o.getClass();
|
|
|
|
m = c.getDeclaredMethod("getSkeletonType");
|
|
|
|
o = m.invoke(o);
|
|
|
|
|
|
|
|
if(o instanceof Integer)
|
|
|
|
isWitherSkeleton = (((Integer) o) == 1);
|
|
|
|
} catch(Exception e) {}
|
|
|
|
|
|
|
|
if (isWitherSkeleton) {
|
2012-11-13 01:33:37 +01:00
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1));
|
|
|
|
} else if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.BONE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.COAL));
|
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.COAL), 50, 2);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM));
|
|
|
|
} else if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.BONE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.ARROW));
|
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.ARROW), 50, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLIME:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SLIME_BALL));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SNOWMAN:
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SNOW_BALL));
|
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.SNOW_BALL), 50, 4);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPIDER:
|
|
|
|
if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.STRING));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SQUID:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WITCH:
|
|
|
|
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
if (DROP_NUMBER_2 > 66) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8197));
|
|
|
|
} else if (DROP_NUMBER_2 > 33) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8195));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8194));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (DROP_NUMBER_2 > 88) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.GLASS_BOTTLE));
|
|
|
|
} else if (DROP_NUMBER_2 > 75) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.GLOWSTONE_DUST));
|
|
|
|
} else if (DROP_NUMBER_2 > 63) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
|
|
|
} else if (DROP_NUMBER_2 > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.REDSTONE));
|
|
|
|
} else if (DROP_NUMBER_2 > 38) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
|
|
|
} else if (DROP_NUMBER_2 > 25) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.STICK));
|
|
|
|
} else if (DROP_NUMBER_2 > 13) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SUGAR));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.POTION));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZOMBIE:
|
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Combat.dealDamage(le, 1);
|
|
|
|
}
|
2012-11-08 20:15:40 +01:00
|
|
|
/**
|
|
|
|
* Gets chance of shake success.
|
|
|
|
*
|
|
|
|
* @param rank Treasure hunter rank
|
|
|
|
* @return The chance of a successful shake
|
|
|
|
*/
|
|
|
|
public static int getShakeChance(int lootTier) {
|
|
|
|
switch (lootTier) {
|
|
|
|
case 1:
|
|
|
|
return Config.getInstance().getShakeChanceRank1();
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return Config.getInstance().getShakeChanceRank2();
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
return Config.getInstance().getShakeChanceRank3();
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
return Config.getInstance().getShakeChanceRank4();
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
return Config.getInstance().getShakeChanceRank5();
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
}
|
2011-11-28 14:17:01 +01:00
|
|
|
}
|