mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-30 12:44:45 +02:00
Squashed commit of the following:
commit cb3e057dee1f2b29838ab654a526baac1baab7d6 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:43:57 2013 -0500 1.4.00 release commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35 Author: NuclearW <incongruency@gmail.com> Date: Fri Mar 1 00:07:30 2013 -0500 \r -> \n commit b2ca22e0477c747143b0f08a28a096967ee6ffd7 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:53:56 2013 -0500 Commented-out code shouldn't be done like that. commit 92f131712cc671e3e616c14a22e22769ef6d6d0b Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 23:45:36 2013 -0500 More things we missed. commit 408b03766f6261a03a862a1ab7f5835772feda4a Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 23:20:13 2013 -0500 Format: util through spout and backup lib commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:50:08 2013 -0500 The things we missed the first time through... commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 22:05:29 2013 -0500 Formatting: Skills commit c097a6e188a7b760dd1b4389ed81dca417146b16 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:30:12 2013 -0500 Organize imports. commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:45 2013 -0500 Fixed a missing fallthrough comment from ChatCommand commit b4a76c9f022a2fd98bdd8f083accfea03becfd71 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 19:09:36 2013 -0500 Formatting: datatypes.* through events.* commit 3e57dd41d3265a7c8106c7eb026df926770a4d15 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:56:15 2013 -0500 Fix issue with bad rebase commit e8c8e06b2971555b7334e49128257e3af6f36892 Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 17:35:32 2013 -0500 Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and PlayerStat commit 13ecf1cc41f377a12991e357ac10abdcda24d6de Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:31:43 2013 -0500 Format: listeners.* through runnables.* commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 17:13:57 2013 -0500 Format PartyLockCommand commit d50abed10bf94e1a88df3dc5cc07c259aea920ea Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 16:54:08 2013 -0500 Format: base through config.* commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:21:40 2013 -0500 Example of using spaces to align like things commit 534190cfe2481e466fe459d65628550458cc2993 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:12:19 2013 -0500 Capitalization commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 15:07:43 2013 -0500 Updated readme, added standards.md commit 5ec0df70fb82c527420a2f437f27f31bd758f884 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 14:42:16 2013 -0500 Markdown was here, Creole is a loser commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 13:46:24 2013 -0500 Move MCStats shading to .metrics.mcstats commit eb9d67e66b1659d6abd2397ecf403343cfeffdda Author: GJ <gjmcferrin@gmail.com> Date: Thu Feb 28 13:37:37 2013 -0500 Move ALL the packages! commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0 Author: NuclearW <incongruency@gmail.com> Date: Thu Feb 28 12:37:12 2013 -0500 /r/n -> /n
This commit is contained in:
@ -1,201 +1,201 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class Fishing {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier5();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank5();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5();}},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier4();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank4();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4();}},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier3();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank3();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3();}},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier2();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank2();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2();}},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier1();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank1();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1();}};
|
||||
|
||||
int numerical;
|
||||
|
||||
private Tier(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
public int toNumerical() {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected int getShakeChance();
|
||||
abstract protected int getVanillaXPBoostModifier();
|
||||
}
|
||||
|
||||
// TODO: Get rid of that
|
||||
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||
public static final double STORM_MODIFIER = 0.909;
|
||||
|
||||
private Fishing() {}
|
||||
|
||||
/**
|
||||
* Finds the possible drops of an entity
|
||||
*
|
||||
* @param target Targeted entity
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
*/
|
||||
protected static void findPossibleDrops(LivingEntity target, Map<ItemStack, Integer> possibleDrops) {
|
||||
switch (target.getType()) {
|
||||
case BLAZE:
|
||||
possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100);
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
case SPIDER:
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50);
|
||||
possibleDrops.put(new ItemStack(Material.STRING), 50);
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
possibleDrops.put(new ItemStack(Material.FEATHER), 34);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33);
|
||||
possibleDrops.put(new ItemStack(Material.EGG), 33);
|
||||
break;
|
||||
|
||||
case COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 49);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49);
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 99);
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100);
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50);
|
||||
break;
|
||||
|
||||
case IRON_GOLEM:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12);
|
||||
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
|
||||
possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
possibleDrops.put(new ItemStack(Material.PORK), 100);
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50);
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100);
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2);
|
||||
possibleDrops.put(new ItemStack(Material.BONE), 49);
|
||||
possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49);
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100);
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1);
|
||||
possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9);
|
||||
possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.REDSTONE), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12);
|
||||
possibleDrops.put(new ItemStack(Material.STICK), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SUGAR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.POTION), 13);
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2);
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly chooses a drop among the list
|
||||
*
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
* @return Chosen ItemStack
|
||||
*/
|
||||
protected static ItemStack chooseDrop(Map<ItemStack, Integer> possibleDrops) {
|
||||
int dropProbability = Misc.getRandom().nextInt(100);
|
||||
int cumulatedProbability = 0;
|
||||
|
||||
for (Entry<ItemStack, Integer> entry : possibleDrops.entrySet()) {
|
||||
cumulatedProbability += entry.getValue();
|
||||
|
||||
if (dropProbability < cumulatedProbability) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public final class Fishing {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier5(); }
|
||||
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank5(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5(); }},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier4(); }
|
||||
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank4(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4(); }},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier3(); }
|
||||
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank3(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3(); }},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier2(); }
|
||||
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank2(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2(); }},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier1(); }
|
||||
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank1(); }
|
||||
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1(); }};
|
||||
|
||||
int numerical;
|
||||
|
||||
private Tier(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
public int toNumerical() {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected int getShakeChance();
|
||||
abstract protected int getVanillaXPBoostModifier();
|
||||
}
|
||||
|
||||
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||
|
||||
public static final double STORM_MODIFIER = 0.909;
|
||||
|
||||
private Fishing() {}
|
||||
|
||||
/**
|
||||
* Finds the possible drops of an entity
|
||||
*
|
||||
* @param target Targeted entity
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
*/
|
||||
protected static void findPossibleDrops(LivingEntity target, Map<ItemStack, Integer> possibleDrops) {
|
||||
switch (target.getType()) {
|
||||
case BLAZE:
|
||||
possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100);
|
||||
break;
|
||||
|
||||
case CAVE_SPIDER:
|
||||
case SPIDER:
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50);
|
||||
possibleDrops.put(new ItemStack(Material.STRING), 50);
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
possibleDrops.put(new ItemStack(Material.FEATHER), 34);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33);
|
||||
possibleDrops.put(new ItemStack(Material.EGG), 33);
|
||||
break;
|
||||
|
||||
case COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 49);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49);
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 99);
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100);
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50);
|
||||
break;
|
||||
|
||||
case IRON_GOLEM:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12);
|
||||
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
|
||||
possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5);
|
||||
possibleDrops.put(new ItemStack(Material.LEATHER), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30);
|
||||
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
possibleDrops.put(new ItemStack(Material.PORK), 100);
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
|
||||
possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50);
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100);
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2);
|
||||
possibleDrops.put(new ItemStack(Material.BONE), 49);
|
||||
possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49);
|
||||
break;
|
||||
|
||||
case SLIME:
|
||||
possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100);
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
|
||||
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1);
|
||||
possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1);
|
||||
possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9);
|
||||
possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SULPHUR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.REDSTONE), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12);
|
||||
possibleDrops.put(new ItemStack(Material.STICK), 13);
|
||||
possibleDrops.put(new ItemStack(Material.SUGAR), 12);
|
||||
possibleDrops.put(new ItemStack(Material.POTION), 13);
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2);
|
||||
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly chooses a drop among the list
|
||||
*
|
||||
* @param possibleDrops List of ItemStack that can be dropped
|
||||
* @return Chosen ItemStack
|
||||
*/
|
||||
protected static ItemStack chooseDrop(Map<ItemStack, Integer> possibleDrops) {
|
||||
int dropProbability = Misc.getRandom().nextInt(100);
|
||||
int cumulatedProbability = 0;
|
||||
|
||||
for (Entry<ItemStack, Integer> entry : possibleDrops.entrySet()) {
|
||||
cumulatedProbability += entry.getValue();
|
||||
|
||||
if (dropProbability < cumulatedProbability) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,125 +0,0 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String magicChanceLucky;
|
||||
private String chanceRaining = "";
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private String fishermansDietRank;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
private boolean canFishermansDiet;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier();
|
||||
|
||||
//TREASURE HUNTER
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
||||
enchantChance = enchantChance * 1.1D;
|
||||
}
|
||||
|
||||
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
|
||||
magicChance = treasureHunterStrings[0];
|
||||
magicChanceLucky = treasureHunterStrings[1];
|
||||
|
||||
//SHAKE
|
||||
String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability());
|
||||
shakeChance = shakeStrings[0];
|
||||
shakeChanceLucky = shakeStrings[1];
|
||||
|
||||
//FISHERMAN'S DIET
|
||||
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = Permissions.fishingTreasureHunter(player);
|
||||
canMagicHunt = Permissions.magicHunter(player);
|
||||
canShake = Permissions.shake(player);
|
||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining);
|
||||
}
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
if (skillValue < AdvancedConfig.getInstance().getShakeUnlockLevel()) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", AdvancedConfig.getInstance().getShakeUnlockLevel())));
|
||||
}
|
||||
else {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,305 +1,305 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class FishingManager extends SkillManager {
|
||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.FISHING);
|
||||
}
|
||||
|
||||
public boolean canShake(Entity target) {
|
||||
Player player = getPlayer();
|
||||
|
||||
return target instanceof LivingEntity && SkillTools.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Fisherman's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
|
||||
return SkillTools.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the results from a successful fishing trip
|
||||
*
|
||||
* @param fishingCatch The {@link Item} initially caught
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
|
||||
treasure = getFishingTreasure();
|
||||
}
|
||||
|
||||
if (treasure != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
|
||||
treasureXp = treasure.getXp();
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (Permissions.magicHunter(player) && ItemChecks.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||
}
|
||||
|
||||
// Drop the original catch at the feet of the player and set the treasure as the real catch
|
||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
}
|
||||
|
||||
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the vanilla XP boost for Fishing
|
||||
*
|
||||
* @param experience The amount of experience initially awarded by the event
|
||||
* @return the modified event damage
|
||||
*/
|
||||
public int handleVanillaXpBoost(int experience) {
|
||||
return experience * getVanillaXpMultiplier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Shake ability
|
||||
*
|
||||
* @param mob The {@link LivingEntity} affected by the ability
|
||||
*/
|
||||
public void shakeCheck(LivingEntity target) {
|
||||
if (SkillTools.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
|
||||
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
||||
|
||||
Fishing.findPossibleDrops(target, possibleDrops);
|
||||
|
||||
if (possibleDrops.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack drop = Fishing.chooseDrop(possibleDrops);
|
||||
|
||||
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
|
||||
if (drop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extra processing depending on the mob and drop type
|
||||
switch (target.getType()) {
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) target;
|
||||
|
||||
if (drop.getType() == Material.WOOL) {
|
||||
if (sheep.isSheared()) {
|
||||
return;
|
||||
}
|
||||
|
||||
drop.setDurability(sheep.getColor().getWoolData());
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) target;
|
||||
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER) {
|
||||
switch (drop.getType()) {
|
||||
case SKULL_ITEM:
|
||||
drop.setDurability((short) 1);
|
||||
break;
|
||||
|
||||
case ARROW:
|
||||
drop.setType(Material.COAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Misc.dropItem(target.getLocation(), drop);
|
||||
CombatTools.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Treasure Hunter ability for Fishing
|
||||
*
|
||||
* @return The {@link FishingTreasure} found, or null if no treasure was found.
|
||||
*/
|
||||
private FishingTreasure getFishingTreasure() {
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
|
||||
int maxLevel = treasure.getMaxLevel();
|
||||
|
||||
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
|
||||
rewards.add(treasure);
|
||||
}
|
||||
}
|
||||
|
||||
if (rewards.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (!SkillTools.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
|
||||
}
|
||||
|
||||
return treasure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Magic Hunter ability
|
||||
*
|
||||
* @param treasureDrop The {@link ItemStack} to enchant
|
||||
* @return true if the item has been enchanted
|
||||
*/
|
||||
private boolean handleMagicHunter(ItemStack treasureDrop) {
|
||||
Player player = getPlayer();
|
||||
int activationChance = this.activationChance;
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
activationChance *= Fishing.STORM_MODIFIER;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
|
||||
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
if (enchantment.canEnchantItem(treasureDrop)) {
|
||||
possibleEnchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
||||
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
||||
|
||||
boolean enchanted = false;
|
||||
int specificChance = 1;
|
||||
|
||||
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
||||
boolean conflicts = false;
|
||||
|
||||
for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) {
|
||||
conflicts = currentEnchantment.conflictsWith(possibleEnchantment);
|
||||
|
||||
if (conflicts) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) {
|
||||
treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
|
||||
|
||||
specificChance++;
|
||||
enchanted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return enchanted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loot tier
|
||||
*
|
||||
* @return the loot tier
|
||||
*/
|
||||
public int getLootTier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Shake Mob probability
|
||||
*
|
||||
* @return Shake Mob probability
|
||||
*/
|
||||
public int getShakeProbability() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getShakeChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vanilla XP multiplier
|
||||
*
|
||||
* @return the vanilla XP multiplier
|
||||
*/
|
||||
private int getVanillaXpMultiplier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getVanillaXPBoostModifier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class FishingManager extends SkillManager {
|
||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.FISHING);
|
||||
}
|
||||
|
||||
public boolean canShake(Entity target) {
|
||||
Player player = getPlayer();
|
||||
|
||||
return target instanceof LivingEntity && SkillUtils.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loot tier
|
||||
*
|
||||
* @return the loot tier
|
||||
*/
|
||||
public int getLootTier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Shake Mob probability
|
||||
*
|
||||
* @return Shake Mob probability
|
||||
*/
|
||||
public int getShakeProbability() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getShakeChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Fisherman's Diet ability
|
||||
*
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param eventFoodLevel The initial change in hunger from the event
|
||||
* @return the modified change in hunger for the event
|
||||
*/
|
||||
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
|
||||
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the results from a successful fishing trip
|
||||
*
|
||||
* @param fishingCatch The {@link Item} initially caught
|
||||
*/
|
||||
public void handleFishing(Item fishingCatch) {
|
||||
int treasureXp = 0;
|
||||
Player player = getPlayer();
|
||||
FishingTreasure treasure = null;
|
||||
|
||||
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
|
||||
treasure = getFishingTreasure();
|
||||
}
|
||||
|
||||
if (treasure != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
|
||||
treasureXp = treasure.getXp();
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||
}
|
||||
|
||||
// Drop the original catch at the feet of the player and set the treasure as the real catch
|
||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||
fishingCatch.setItemStack(treasureDrop);
|
||||
}
|
||||
|
||||
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the vanilla XP boost for Fishing
|
||||
*
|
||||
* @param experience The amount of experience initially awarded by the event
|
||||
* @return the modified event damage
|
||||
*/
|
||||
public int handleVanillaXpBoost(int experience) {
|
||||
return experience * getVanillaXpMultiplier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Shake ability
|
||||
*
|
||||
* @param mob The {@link LivingEntity} affected by the ability
|
||||
*/
|
||||
public void shakeCheck(LivingEntity target) {
|
||||
if (SkillUtils.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
|
||||
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
|
||||
|
||||
Fishing.findPossibleDrops(target, possibleDrops);
|
||||
|
||||
if (possibleDrops.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack drop = Fishing.chooseDrop(possibleDrops);
|
||||
|
||||
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
|
||||
if (drop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Extra processing depending on the mob and drop type
|
||||
switch (target.getType()) {
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) target;
|
||||
|
||||
if (drop.getType() == Material.WOOL) {
|
||||
if (sheep.isSheared()) {
|
||||
return;
|
||||
}
|
||||
|
||||
drop.setDurability(sheep.getColor().getWoolData());
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SKELETON:
|
||||
Skeleton skeleton = (Skeleton) target;
|
||||
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER) {
|
||||
switch (drop.getType()) {
|
||||
case SKULL_ITEM:
|
||||
drop.setDurability((short) 1);
|
||||
break;
|
||||
|
||||
case ARROW:
|
||||
drop.setType(Material.COAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Misc.dropItem(target.getLocation(), drop);
|
||||
CombatUtils.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Treasure Hunter ability for Fishing
|
||||
*
|
||||
* @return The {@link FishingTreasure} found, or null if no treasure was found.
|
||||
*/
|
||||
private FishingTreasure getFishingTreasure() {
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (FishingTreasure treasure : TreasureConfig.getInstance().fishingRewards) {
|
||||
int maxLevel = treasure.getMaxLevel();
|
||||
|
||||
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
|
||||
rewards.add(treasure);
|
||||
}
|
||||
}
|
||||
|
||||
if (rewards.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||
ItemStack treasureDrop = treasure.getDrop();
|
||||
|
||||
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
short maxDurability = treasureDrop.getType().getMaxDurability();
|
||||
|
||||
if (maxDurability > 0) {
|
||||
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
|
||||
}
|
||||
|
||||
return treasure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the Magic Hunter ability
|
||||
*
|
||||
* @param treasureDrop The {@link ItemStack} to enchant
|
||||
* @return true if the item has been enchanted
|
||||
*/
|
||||
private boolean handleMagicHunter(ItemStack treasureDrop) {
|
||||
Player player = getPlayer();
|
||||
int activationChance = this.activationChance;
|
||||
|
||||
if (player.getWorld().hasStorm()) {
|
||||
activationChance *= Fishing.STORM_MODIFIER;
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
|
||||
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
if (enchantment.canEnchantItem(treasureDrop)) {
|
||||
possibleEnchantments.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
||||
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
||||
|
||||
boolean enchanted = false;
|
||||
int specificChance = 1;
|
||||
|
||||
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
||||
boolean conflicts = false;
|
||||
|
||||
for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) {
|
||||
conflicts = currentEnchantment.conflictsWith(possibleEnchantment);
|
||||
|
||||
if (conflicts) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) {
|
||||
treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
|
||||
|
||||
specificChance++;
|
||||
enchanted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return enchanted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vanilla XP multiplier
|
||||
*
|
||||
* @return the vanilla XP multiplier
|
||||
*/
|
||||
private int getVanillaXpMultiplier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getVanillaXPBoostModifier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user