2012-05-01 19:58:47 +02:00
|
|
|
package com.gmail.nossr50.skills.gathering;
|
2011-11-28 14:17:01 +01:00
|
|
|
|
2012-03-13 08:00:49 +01:00
|
|
|
import java.util.ArrayList;
|
2012-02-21 19:10:51 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2013-01-08 17:31:07 +01:00
|
|
|
import org.bukkit.DyeColor;
|
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;
|
2012-12-22 10:11:18 +01:00
|
|
|
import org.bukkit.entity.Skeleton;
|
|
|
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
2011-11-28 14:17:01 +01:00
|
|
|
import org.bukkit.event.player.PlayerFishEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2012-12-25 07:01:10 +01:00
|
|
|
import org.bukkit.material.MaterialData;
|
2011-12-01 18:46:46 +01:00
|
|
|
import org.bukkit.material.Wool;
|
2013-01-09 00:45:44 +01:00
|
|
|
import org.bukkit.potion.Potion;
|
|
|
|
import org.bukkit.potion.PotionType;
|
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-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-12-24 22:56:25 +01: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;
|
|
|
|
|
2013-01-11 00:21:18 +01:00
|
|
|
if (level >= advancedConfig.getFishingTierLevelsTier5()) {
|
2012-03-13 08:00:49 +01:00
|
|
|
fishingTier = 5;
|
2013-01-11 00:21:18 +01:00
|
|
|
} else if (level >= advancedConfig.getFishingTierLevelsTier4()) {
|
2012-03-13 08:00:49 +01:00
|
|
|
fishingTier = 4;
|
2013-01-11 00:21:18 +01:00
|
|
|
} else if (level >= advancedConfig.getFishingTierLevelsTier3()) {
|
2012-12-24 22:56:25 +01:00
|
|
|
fishingTier = 3;
|
2013-01-11 00:21:18 +01:00
|
|
|
} else if (level >= advancedConfig.getFishingTierLevelsTier2()) {
|
2012-12-24 22:56:25 +01:00
|
|
|
fishingTier = 2;
|
|
|
|
} else {
|
|
|
|
fishingTier = 1;
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return fishingTier;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get item results from Fishing.
|
2012-12-24 22:56:25 +01:00
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* The player that was fishing
|
|
|
|
* @param event
|
|
|
|
* The event to modify
|
2012-03-13 08:00:49 +01:00
|
|
|
*/
|
|
|
|
private static void getFishingResults(Player player, PlayerFishEvent event) {
|
2012-12-24 22:56:25 +01:00
|
|
|
if (player == null)
|
2012-10-30 19:46:52 +01:00
|
|
|
return;
|
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
PlayerProfile profile = Users.getProfile(player);
|
2012-03-13 08:00:49 +01:00
|
|
|
Item theCatch = (Item) event.getCaught();
|
2013-01-11 23:55:54 +01:00
|
|
|
|
|
|
|
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasures(player)) {
|
|
|
|
int skillLevel = profile.getSkillLevel(SkillType.FISHING);
|
|
|
|
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
|
|
|
|
|
|
|
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
|
|
|
|
if (treasure.getDropLevel() <= skillLevel && treasure.getMaxLevel() >= skillLevel) {
|
|
|
|
rewards.add(treasure);
|
|
|
|
}
|
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2013-01-11 23:55:54 +01:00
|
|
|
if (rewards.size() <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2013-01-11 23:55:54 +01:00
|
|
|
FishingTreasure foundTreasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
2012-04-24 15:21:21 +02:00
|
|
|
|
2012-07-02 17:09:55 +02:00
|
|
|
int randomChance = 100;
|
2013-01-07 02:52:31 +01:00
|
|
|
if (Permissions.luckyFishing(player)) {
|
2012-07-02 17:09:55 +02:00
|
|
|
randomChance = (int) (randomChance * 0.75);
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:55:54 +01:00
|
|
|
if (Misc.getRandom().nextDouble() * randomChance <= foundTreasure.getDropChance()) {
|
|
|
|
Users.getPlayer(player).addXP(SkillType.FISHING, foundTreasure.getXp());
|
|
|
|
theCatch.setItemStack(foundTreasure.getDrop());
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
2013-01-11 23:55:54 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-03-13 08:00:49 +01:00
|
|
|
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
|
|
|
}
|
|
|
|
|
2013-01-03 17:40:22 +01:00
|
|
|
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
|
2012-03-27 13:51:30 +02:00
|
|
|
|
|
|
|
if (maxDurability > 0) {
|
2013-01-10 05:46:35 +01:00
|
|
|
theCatch.getItemStack().setDurability((short) (Misc.getRandom().nextInt(maxDurability))); // Change durability to random value
|
2012-03-27 13:51:30 +02:00
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2013-01-03 17:40:22 +01:00
|
|
|
Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process results from Fishing.
|
2012-12-24 22:56:25 +01:00
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
* The event to modify
|
2012-03-13 08:00:49 +01:00
|
|
|
*/
|
|
|
|
public static void processResults(PlayerFishEvent event) {
|
|
|
|
Player player = event.getPlayer();
|
2012-12-24 22:56:25 +01:00
|
|
|
if (player == null)
|
2012-10-30 19:46:52 +01:00
|
|
|
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) {
|
2013-01-10 21:22:47 +01:00
|
|
|
int lootTier = Fishing.getFishingLootTier(profile);
|
2013-01-10 22:54:57 +01:00
|
|
|
int magicHunterMultiplier = advancedConfig.getFishingMagicMultiplier();
|
2013-01-10 21:22:47 +01:00
|
|
|
int specificChance = 1;
|
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;
|
|
|
|
|
2013-01-07 02:52:31 +01:00
|
|
|
if (Permissions.luckyFishing(player)) {
|
2012-11-07 13:32:30 +01:00
|
|
|
randomChance = (int) (randomChance * 0.75);
|
2012-07-02 17:09:55 +02:00
|
|
|
}
|
2013-01-10 21:22:47 +01:00
|
|
|
|
2013-01-12 23:09:42 +01:00
|
|
|
if (player.getWorld().hasStorm()) {
|
|
|
|
randomChance = (int) (randomChance * 0.909);
|
|
|
|
}
|
|
|
|
|
2013-01-10 21:22:47 +01:00
|
|
|
/* CHANCE OF ITEM BEING ENCHANTED
|
2013-01-10 21:28:02 +01:00
|
|
|
* 5% - Tier 1
|
|
|
|
* 10% - Tier 2
|
|
|
|
* 15% - Tier 3
|
|
|
|
* 20% - Tier 4
|
|
|
|
* 25% - Tier 5
|
2013-01-10 21:22:47 +01:00
|
|
|
*/
|
2013-01-10 22:54:57 +01:00
|
|
|
if (Misc.getRandom().nextInt(randomChance) <= (lootTier * magicHunterMultiplier) && Permissions.fishingMagic(player)) {
|
2012-03-14 16:43:18 +01:00
|
|
|
for (Enchantment newEnchant : Enchantment.values()) {
|
|
|
|
if (newEnchant.canEnchantItem(fishingResults)) {
|
2013-01-10 21:22:47 +01:00
|
|
|
specificChance++;
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2013-01-10 21:22:47 +01:00
|
|
|
for (Enchantment oldEnchant : fishingResults.getEnchantments().keySet()) {
|
2012-11-01 06:47:04 +01:00
|
|
|
if (oldEnchant.conflictsWith(newEnchant))
|
2013-01-10 21:22:47 +01:00
|
|
|
specificChance--;
|
2012-11-01 06:47:04 +01:00
|
|
|
continue;
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 21:22:47 +01:00
|
|
|
/* CHANCE OF GETTING EACH ENCHANTMENT
|
|
|
|
* 50% - 1st Enchantment
|
|
|
|
* 33% - 2nd Enchantment
|
|
|
|
* 25% - 3rd Enchantment
|
|
|
|
* 20% - 4th Enchantment
|
|
|
|
* 16.66% - 5th Enchantment
|
|
|
|
* 14.29% - 6th Enchantment
|
|
|
|
* 12.5% - 7th Enchantment
|
|
|
|
* 11.11% - 8th Enchantment
|
2012-12-24 22:56:25 +01:00
|
|
|
*/
|
2013-01-10 21:22:47 +01:00
|
|
|
if (Misc.getRandom().nextInt(specificChance) < 1) {
|
2012-03-14 16:43:18 +01:00
|
|
|
enchanted = true;
|
2013-01-10 05:46:35 +01:00
|
|
|
int randomEnchantLevel = Misc.getRandom().nextInt(newEnchant.getMaxLevel()) + 1;
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2013-01-03 17:40:22 +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
|
|
|
|
2013-01-10 21:22:47 +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.
|
2012-12-24 22:56:25 +01:00
|
|
|
*
|
|
|
|
* @param event
|
|
|
|
* The event to modify
|
2012-03-13 08:00:49 +01:00
|
|
|
*/
|
|
|
|
public static void shakeMob(PlayerFishEvent event) {
|
2012-07-02 17:09:55 +02:00
|
|
|
int randomChance = 100;
|
|
|
|
|
2013-01-07 02:52:31 +01:00
|
|
|
if (Permissions.luckyFishing(event.getPlayer())) {
|
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);
|
2013-01-09 02:28:09 +01:00
|
|
|
|
2013-01-07 02:52:31 +01:00
|
|
|
if (Permissions.luckyFishing(player)) {
|
2013-01-09 02:28:09 +01:00
|
|
|
// With lucky perk on max level tier, its 100%
|
|
|
|
dropChance = (int) (dropChance * 1.25);
|
2012-11-07 13:30:20 +01:00
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
|
2013-01-10 05:46:35 +01:00
|
|
|
final int DROP_CHANCE = Misc.getRandom().nextInt(100);
|
|
|
|
final int DROP_NUMBER = Misc.getRandom().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:
|
2012-12-23 00:00:29 +01:00
|
|
|
if (DROP_NUMBER > 97) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4));
|
2012-11-13 01:33:37 +01:00
|
|
|
} 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:
|
2012-12-23 22:05:10 +01:00
|
|
|
if (DROP_NUMBER > 97) {
|
2012-11-13 01:33:37 +01:00
|
|
|
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) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.MUSHROOM_SOUP));
|
2012-11-13 01:33:37 +01:00
|
|
|
} 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 {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.RED_MUSHROOM));
|
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.RED_MUSHROOM), 50, 2);
|
2012-11-13 01:33:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIG:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.PORK));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIG_ZOMBIE:
|
|
|
|
if (DROP_NUMBER > 50) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
2012-11-13 01:33:37 +01:00
|
|
|
} 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();
|
2013-01-10 05:46:35 +01:00
|
|
|
theWool.setAmount(1 + Misc.getRandom().nextInt(6));
|
2012-11-13 01:33:37 +01:00
|
|
|
|
|
|
|
Misc.dropItem(location, theWool);
|
|
|
|
sheep.setSheared(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SKELETON:
|
2012-12-24 22:56:25 +01:00
|
|
|
if (((Skeleton) le).getSkeletonType() == SkeletonType.WITHER) {
|
2012-12-23 00:00:29 +01:00
|
|
|
if (DROP_NUMBER > 97) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.BONE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.COAL));
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.COAL), 50, 2);
|
2012-11-13 01:33:37 +01:00
|
|
|
}
|
|
|
|
} else {
|
2012-12-23 00:00:29 +01:00
|
|
|
if (DROP_NUMBER > 97) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.BONE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.ARROW));
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.ARROW), 50, 2);
|
2012-11-13 01:33:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLIME:
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SLIME_BALL));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SNOWMAN:
|
2012-12-23 22:05:10 +01:00
|
|
|
if (DROP_NUMBER > 97) {
|
2012-11-13 01:33:37 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SNOW_BALL));
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.randomDropItems(location, new ItemStack(Material.SNOW_BALL), 50, 4);
|
2012-11-13 01:33:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPIDER:
|
|
|
|
if (DROP_NUMBER > 50) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
|
|
|
} else {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.STRING));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-01-09 00:27:59 +01:00
|
|
|
case SQUID:
|
2013-01-09 00:14:12 +01:00
|
|
|
ItemStack item;
|
|
|
|
try {
|
2013-01-14 02:56:05 +01:00
|
|
|
item = (new MaterialData(Material.INK_SACK, DyeColor.BLACK.getData())).toItemStack(1);
|
2013-01-09 00:14:12 +01:00
|
|
|
}
|
2013-01-09 00:52:50 +01:00
|
|
|
catch(Exception e) {
|
2013-01-09 00:14:12 +01:00
|
|
|
item = (new MaterialData(Material.INK_SACK, (byte) 0)).toItemStack(1);
|
2013-01-14 02:56:05 +01:00
|
|
|
}
|
|
|
|
catch(NoSuchMethodError e) {
|
|
|
|
item = (new MaterialData(Material.INK_SACK, (byte) 0)).toItemStack(1);
|
2013-01-09 00:27:59 +01:00
|
|
|
}
|
2012-12-25 07:01:10 +01:00
|
|
|
|
|
|
|
Misc.dropItem(location, item);
|
2012-11-13 01:33:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WITCH:
|
2013-01-10 05:46:35 +01:00
|
|
|
final int DROP_NUMBER_2 = Misc.getRandom().nextInt(randomChance) + 1;
|
2012-11-13 01:33:37 +01:00
|
|
|
if (DROP_NUMBER > 95) {
|
|
|
|
if (DROP_NUMBER_2 > 66) {
|
2013-01-09 00:45:44 +01:00
|
|
|
Misc.dropItem(location, new Potion(PotionType.INSTANT_HEAL).toItemStack(1));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else if (DROP_NUMBER_2 > 33) {
|
2013-01-09 00:45:44 +01:00
|
|
|
Misc.dropItem(location, new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else {
|
2013-01-09 00:45:44 +01:00
|
|
|
Misc.dropItem(location, new Potion(PotionType.SPEED).toItemStack(1));
|
2012-11-13 01:33:37 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (DROP_NUMBER_2 > 88) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.GLASS_BOTTLE));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else if (DROP_NUMBER_2 > 75) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.GLOWSTONE_DUST));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else if (DROP_NUMBER_2 > 63) {
|
|
|
|
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
|
|
|
} else if (DROP_NUMBER_2 > 50) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.REDSTONE));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else if (DROP_NUMBER_2 > 38) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
2012-11-13 01:33:37 +01:00
|
|
|
} 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:
|
2012-12-23 00:00:29 +01:00
|
|
|
if (DROP_NUMBER > 97) {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2));
|
2012-11-13 01:33:37 +01:00
|
|
|
} else {
|
2012-12-25 07:01:10 +01:00
|
|
|
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
2012-11-13 01:33:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-03-13 08:00:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Combat.dealDamage(le, 1);
|
|
|
|
}
|
2012-12-24 22:56:25 +01:00
|
|
|
|
2012-11-08 20:15:40 +01:00
|
|
|
/**
|
|
|
|
* Gets chance of shake success.
|
2012-12-24 22:56:25 +01:00
|
|
|
*
|
|
|
|
* @param rank
|
|
|
|
* Treasure hunter rank
|
2012-11-08 20:15:40 +01:00
|
|
|
* @return The chance of a successful shake
|
|
|
|
*/
|
|
|
|
public static int getShakeChance(int lootTier) {
|
|
|
|
switch (lootTier) {
|
|
|
|
case 1:
|
2013-01-11 00:21:18 +01:00
|
|
|
return advancedConfig.getShakeChanceRank1();
|
2012-11-08 20:15:40 +01:00
|
|
|
|
|
|
|
case 2:
|
2013-01-11 00:21:18 +01:00
|
|
|
return advancedConfig.getShakeChanceRank2();
|
2012-11-08 20:15:40 +01:00
|
|
|
|
|
|
|
case 3:
|
2013-01-11 00:21:18 +01:00
|
|
|
return advancedConfig.getShakeChanceRank3();
|
2012-11-08 20:15:40 +01:00
|
|
|
|
|
|
|
case 4:
|
2013-01-11 00:21:18 +01:00
|
|
|
return advancedConfig.getShakeChanceRank4();
|
2012-11-08 20:15:40 +01:00
|
|
|
|
|
|
|
case 5:
|
2013-01-11 00:21:18 +01:00
|
|
|
return advancedConfig.getShakeChanceRank5();
|
2012-11-08 20:15:40 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
return 10;
|
|
|
|
}
|
2012-12-24 22:56:25 +01:00
|
|
|
}
|
2011-11-28 14:17:01 +01:00
|
|
|
}
|