From 815131a0131f917606d4c1375e5c5fc8357a5e4b Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 23 Sep 2019 19:20:09 -0700 Subject: [PATCH] Treasure code removed pending rewrite --- .../commands/skills/FishingCommand.java | 71 ++- .../behaviours/ExcavationBehaviour.java | 30 +- .../skills/behaviours/FishingBehaviour.java | 68 ++- .../treasure/EnchantmentTreasure.java | 29 - .../treasure/ExcavationTreasure.java | 9 - .../datatypes/treasure/FishingTreasure.java | 10 - .../datatypes/treasure/HylianTreasure.java | 9 - .../nossr50/datatypes/treasure/Rarity.java | 18 - .../datatypes/treasure/ShakeTreasure.java | 9 - .../nossr50/datatypes/treasure/Treasure.java | 53 -- .../nossr50/dumpster/EnchantmentTreasure.java | 29 + .../nossr50/dumpster/ExcavationTreasure.java | 9 + .../nossr50/dumpster/FishingTreasure.java | 10 + .../dumpster/FishingTreasureConfig.java | 2 +- .../nossr50/dumpster/HylianTreasure.java | 9 + .../com/gmail/nossr50/dumpster/Rarity.java | 18 + .../gmail/nossr50/dumpster/ShakeTreasure.java | 9 + .../com/gmail/nossr50/dumpster/Treasure.java | 53 ++ .../nossr50/listeners/PlayerListener.java | 10 +- .../skills/fishing/FishingManager.java | 534 +++++++++--------- 20 files changed, 485 insertions(+), 504 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/EnchantmentTreasure.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/Rarity.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/ShakeTreasure.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/EnchantmentTreasure.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/ExcavationTreasure.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/FishingTreasure.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/HylianTreasure.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/Rarity.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/ShakeTreasure.java create mode 100644 src/main/java/com/gmail/nossr50/dumpster/Treasure.java diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index 83c430e4d..f9f3d4f6c 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -1,16 +1,11 @@ package com.gmail.nossr50.commands.skills; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.datatypes.treasure.Rarity; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.FishingManager; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Location; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -54,34 +49,34 @@ public class FishingCommand extends SkillCommand { lootTier = fishingManager.getLootTier(); // Item drop rates - commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); - uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); - rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); - epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); - legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); - recordTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0); +// commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); +// uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); +// rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); +// epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); +// legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); +// recordTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0); +// +// // Magic hunter drop rates +// double totalEnchantChance = 0; +// +// for (Rarity rarity : Rarity.values()) { +// if (rarity != Rarity.RECORD) { +// totalEnchantChance += FishingTreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); +// } +// } - // Magic hunter drop rates - double totalEnchantChance = 0; - - for (Rarity rarity : Rarity.values()) { - if (rarity != Rarity.RECORD) { - totalEnchantChance += FishingTreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity); - } - } - - if (totalEnchantChance >= 1) - magicChance = percent.format(totalEnchantChance / 100.0); - else - magicChance = percent.format(0); +// if (totalEnchantChance >= 1) +// magicChance = percent.format(totalEnchantChance / 100.0); +// else +// magicChance = percent.format(0); } // FISHING_SHAKE - if (canShake) { - String[] shakeStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance()); - shakeChance = shakeStrings[0]; - shakeChanceLucky = shakeStrings[1]; - } +// if (canShake) { +// String[] shakeStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance()); +// shakeChance = shakeStrings[0]; +// shakeChanceLucky = shakeStrings[1]; +// } // FISHERMAN'S DIET if (canFishermansDiet) { @@ -98,13 +93,13 @@ public class FishingCommand extends SkillCommand { location = player.getLocation(); } - if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) { - rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); - } +// if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) { +// rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); +// } - if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { - rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); - } +// if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { +// rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); +// } double luckyModifier = pluginRef.getPermissionTools().lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D; @@ -135,9 +130,9 @@ public class FishingCommand extends SkillCommand { messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank))); } - if (canIceFish) { - messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription())); - } +// if (canIceFish) { +// messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription())); +// } if (canMagicHunt) { messages.add(getStatMessage(SubSkillType.FISHING_MAGIC_HUNTER, magicChance)); diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ExcavationBehaviour.java b/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ExcavationBehaviour.java index 4c6ecc519..231d55d60 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ExcavationBehaviour.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/ExcavationBehaviour.java @@ -1,14 +1,8 @@ package com.gmail.nossr50.datatypes.skills.behaviours; -import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; -import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.StringUtils; import org.bukkit.block.BlockState; -import java.util.ArrayList; -import java.util.List; - /** * These behaviour classes are a band-aid fix for a larger problem * Until the new skill system for mcMMO is finished/implemented, there is no good place to store the hardcoded behaviours for each skill @@ -24,18 +18,18 @@ public class ExcavationBehaviour { this.pluginRef = pluginRef; } - /** - * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. - * - * @param blockState The {@link BlockState} of the block to check. - * @return the list of treasures that could be found - */ - public List getTreasures(BlockState blockState) { - String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); - if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly)) - return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly); - return new ArrayList<>(); - } +// /** +// * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. +// * +// * @param blockState The {@link BlockState} of the block to check. +// * @return the list of treasures that could be found +// */ +// public List getTreasures(BlockState blockState) { +// String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); +// if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly)) +// return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly); +// return new ArrayList<>(); +// } public int getBlockXP(BlockState blockState) { int xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getExcavationXp(blockState.getType()); diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/FishingBehaviour.java b/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/FishingBehaviour.java index 7b1af1744..520990d9e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/FishingBehaviour.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/behaviours/FishingBehaviour.java @@ -1,14 +1,10 @@ package com.gmail.nossr50.datatypes.skills.behaviours; -import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.adapter.BiomeAdapter; import org.bukkit.Material; import org.bukkit.block.Biome; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; @@ -61,39 +57,39 @@ public class FishingBehaviour { } } - /** - * Finds the possible drops of an entity - * - * @param target Targeted entity - * @return possibleDrops List of ItemStack that can be dropped - */ - public List findPossibleDrops(LivingEntity target) { - if (FishingTreasureConfig.getInstance().shakeMap.containsKey(target.getType())) - return FishingTreasureConfig.getInstance().shakeMap.get(target.getType()); +// /** +// * Finds the possible drops of an entity +// * +// * @param target Targeted entity +// * @return possibleDrops List of ItemStack that can be dropped +// */ +// public List findPossibleDrops(LivingEntity target) { +// if (FishingTreasureConfig.getInstance().shakeMap.containsKey(target.getType())) +// return FishingTreasureConfig.getInstance().shakeMap.get(target.getType()); +// +// return null; +// } - return null; - } - - /** - * Randomly chooses a drop among the list - * - * @param possibleDrops List of ItemStack that can be dropped - * @return Chosen ItemStack - */ - public ItemStack chooseDrop(List possibleDrops) { - int dropProbability = Misc.getRandom().nextInt(100); - double cumulatedProbability = 0; - - for (ShakeTreasure treasure : possibleDrops) { - cumulatedProbability += treasure.getDropChance(); - - if (dropProbability < cumulatedProbability) { - return treasure.getDrop().clone(); - } - } - - return null; - } +// /** +// * Randomly chooses a drop among the list +// * +// * @param possibleDrops List of ItemStack that can be dropped +// * @return Chosen ItemStack +// */ +// public ItemStack chooseDrop(List possibleDrops) { +// int dropProbability = Misc.getRandom().nextInt(100); +// double cumulatedProbability = 0; +// +// for (ShakeTreasure treasure : possibleDrops) { +// cumulatedProbability += treasure.getDropChance(); +// +// if (dropProbability < cumulatedProbability) { +// return treasure.getDrop().clone(); +// } +// } +// +// return null; +// } public HashMap> getEnchantableCache() { return enchantableCache; diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/EnchantmentTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/EnchantmentTreasure.java deleted file mode 100644 index 2f9d2519d..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/EnchantmentTreasure.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.enchantments.Enchantment; - -public class EnchantmentTreasure { - private Enchantment enchantment; - private int level; - - public EnchantmentTreasure(Enchantment enchantment, int level) { - this.setEnchantment(enchantment); - this.setLevel(level); - } - - public Enchantment getEnchantment() { - return enchantment; - } - - public void setEnchantment(Enchantment enchantment) { - this.enchantment = enchantment; - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java deleted file mode 100644 index 0145e30eb..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.inventory.ItemStack; - -public class ExcavationTreasure extends Treasure { - public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { - super(drop, xp, dropChance, dropLevel); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java deleted file mode 100644 index b26975313..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/FishingTreasure.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.inventory.ItemStack; - -public class FishingTreasure extends Treasure { - - public FishingTreasure(ItemStack drop, int xp) { - super(drop, xp, 0, 0); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java deleted file mode 100644 index b465d42d7..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/HylianTreasure.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.inventory.ItemStack; - -public class HylianTreasure extends Treasure { - public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { - super(drop, xp, dropChance, dropLevel); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/Rarity.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/Rarity.java deleted file mode 100644 index 00390c442..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/Rarity.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -public enum Rarity { - RECORD, - LEGENDARY, - EPIC, - RARE, - UNCOMMON, - COMMON; - - public static Rarity getRarity(String string) { - try { - return valueOf(string); - } catch (IllegalArgumentException ex) { - return COMMON; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/ShakeTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/ShakeTreasure.java deleted file mode 100644 index 255acee82..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/ShakeTreasure.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.inventory.ItemStack; - -public class ShakeTreasure extends Treasure { - public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { - super(drop, xp, dropChance, dropLevel); - } -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java deleted file mode 100644 index a24d1934f..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.gmail.nossr50.datatypes.treasure; - -import org.bukkit.inventory.ItemStack; - -public abstract class Treasure { - private int xp; - private double dropChance; - private int dropLevel; - private ItemStack drop; - - public Treasure(ItemStack drop, int xp, double dropChance, int dropLevel) { - this.drop = drop; - this.xp = xp; - this.dropChance = dropChance; - this.dropLevel = dropLevel; - } - - public ItemStack getDrop() { - return drop; - } - - public void setDrop(ItemStack drop) { - this.drop = drop; - } - - public int getXp() { - return xp; - } - - public void setXp(int xp) { - this.xp = xp; - } - - public double getDropChance() { - return dropChance; - } - - public void setDropChance(Double dropChance) { - this.dropChance = dropChance; - } - - public int getDropLevel() { - //If they are in retro mode all requirements are scaled up by 10 - if (pluginRef.isRetroModeEnabled()) - return dropLevel * 10; - - return dropLevel; - } - - public void setDropLevel(int dropLevel) { - this.dropLevel = dropLevel; - } -} diff --git a/src/main/java/com/gmail/nossr50/dumpster/EnchantmentTreasure.java b/src/main/java/com/gmail/nossr50/dumpster/EnchantmentTreasure.java new file mode 100644 index 000000000..1010074f5 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/EnchantmentTreasure.java @@ -0,0 +1,29 @@ +//package com.gmail.nossr50.datatypes.treasure; +// +//import org.bukkit.enchantments.Enchantment; +// +//public class EnchantmentTreasure { +// private Enchantment enchantment; +// private int level; +// +// public EnchantmentTreasure(Enchantment enchantment, int level) { +// this.setEnchantment(enchantment); +// this.setLevel(level); +// } +// +// public Enchantment getEnchantment() { +// return enchantment; +// } +// +// public void setEnchantment(Enchantment enchantment) { +// this.enchantment = enchantment; +// } +// +// public int getLevel() { +// return level; +// } +// +// public void setLevel(int level) { +// this.level = level; +// } +//} diff --git a/src/main/java/com/gmail/nossr50/dumpster/ExcavationTreasure.java b/src/main/java/com/gmail/nossr50/dumpster/ExcavationTreasure.java new file mode 100644 index 000000000..8c6e01e90 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/ExcavationTreasure.java @@ -0,0 +1,9 @@ +//package com.gmail.nossr50.datatypes.treasure; +// +//import org.bukkit.inventory.ItemStack; +// +//public class ExcavationTreasure extends Treasure { +// public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { +// super(drop, xp, dropChance, dropLevel); +// } +//} diff --git a/src/main/java/com/gmail/nossr50/dumpster/FishingTreasure.java b/src/main/java/com/gmail/nossr50/dumpster/FishingTreasure.java new file mode 100644 index 000000000..6fd4e8b1c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/FishingTreasure.java @@ -0,0 +1,10 @@ +//package com.gmail.nossr50.datatypes.treasure; +// +//import org.bukkit.inventory.ItemStack; +// +//public class FishingTreasure extends Treasure { +// +// public FishingTreasure(ItemStack drop, int xp) { +// super(drop, xp, 0, 0); +// } +//} diff --git a/src/main/java/com/gmail/nossr50/dumpster/FishingTreasureConfig.java b/src/main/java/com/gmail/nossr50/dumpster/FishingTreasureConfig.java index 197d11560..5ed30ab57 100644 --- a/src/main/java/com/gmail/nossr50/dumpster/FishingTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/dumpster/FishingTreasureConfig.java @@ -5,7 +5,7 @@ //import com.gmail.nossr50.config.UnsafeValueValidation; //import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure; //import com.gmail.nossr50.datatypes.treasure.FishingTreasure; -//import com.gmail.nossr50.datatypes.treasure.Rarity; +//import com.gmail.nossr50.dumpster.Rarity; //import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; //import com.gmail.nossr50.mcMMO; //import com.gmail.nossr50.util.EnchantmentUtils; diff --git a/src/main/java/com/gmail/nossr50/dumpster/HylianTreasure.java b/src/main/java/com/gmail/nossr50/dumpster/HylianTreasure.java new file mode 100644 index 000000000..e5484f921 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/HylianTreasure.java @@ -0,0 +1,9 @@ +//package com.gmail.nossr50.datatypes.treasure; +// +//import org.bukkit.inventory.ItemStack; +// +//public class HylianTreasure extends Treasure { +// public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { +// super(drop, xp, dropChance, dropLevel); +// } +//} diff --git a/src/main/java/com/gmail/nossr50/dumpster/Rarity.java b/src/main/java/com/gmail/nossr50/dumpster/Rarity.java new file mode 100644 index 000000000..c92e2c9f1 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/Rarity.java @@ -0,0 +1,18 @@ +//package com.gmail.nossr50.dumpster; +// +//public enum Rarity { +// RECORD, +// LEGENDARY, +// EPIC, +// RARE, +// UNCOMMON, +// COMMON; +// +// public static Rarity getRarity(String string) { +// try { +// return valueOf(string); +// } catch (IllegalArgumentException ex) { +// return COMMON; +// } +// } +//} diff --git a/src/main/java/com/gmail/nossr50/dumpster/ShakeTreasure.java b/src/main/java/com/gmail/nossr50/dumpster/ShakeTreasure.java new file mode 100644 index 000000000..f938a6434 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/ShakeTreasure.java @@ -0,0 +1,9 @@ +//package com.gmail.nossr50.datatypes.treasure; +// +//import org.bukkit.inventory.ItemStack; +// +//public class ShakeTreasure extends Treasure { +// public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { +// super(drop, xp, dropChance, dropLevel); +// } +//} diff --git a/src/main/java/com/gmail/nossr50/dumpster/Treasure.java b/src/main/java/com/gmail/nossr50/dumpster/Treasure.java new file mode 100644 index 000000000..2aacd2133 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/dumpster/Treasure.java @@ -0,0 +1,53 @@ +//package com.gmail.nossr50.datatypes.treasure; +// +//import org.bukkit.inventory.ItemStack; +// +//public abstract class Treasure { +// private int xp; +// private double dropChance; +// private int dropLevel; +// private ItemStack drop; +// +// public Treasure(ItemStack drop, int xp, double dropChance, int dropLevel) { +// this.drop = drop; +// this.xp = xp; +// this.dropChance = dropChance; +// this.dropLevel = dropLevel; +// } +// +// public ItemStack getDrop() { +// return drop; +// } +// +// public void setDrop(ItemStack drop) { +// this.drop = drop; +// } +// +// public int getXp() { +// return xp; +// } +// +// public void setXp(int xp) { +// this.xp = xp; +// } +// +// public double getDropChance() { +// return dropChance; +// } +// +// public void setDropChance(Double dropChance) { +// this.dropChance = dropChance; +// } +// +// public int getDropLevel() { +// //If they are in retro mode all requirements are scaled up by 10 +// if (pluginRef.isRetroModeEnabled()) +// return dropLevel * 10; +// +// return dropLevel; +// } +// +// public void setDropLevel(int dropLevel) { +// this.dropLevel = dropLevel; +// } +//} diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 39fe9bfae..f211310b0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -387,7 +387,15 @@ public class PlayerListener implements Listener { return; case CAUGHT_ENTITY: if (fishingManager.canShake(caught)) { - fishingManager.shakeCheck((LivingEntity) caught); + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE + //TODO: SHAKE REWRITE +// fishingManager.shakeCheck((LivingEntity) caught); fishingManager.setFishingTarget(); } return; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index e85c780a5..88ffb833e 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -1,23 +1,13 @@ package com.gmail.nossr50.skills.fishing; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.experience.XPGainReason; -import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.behaviours.FishingBehaviour; -import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure; -import com.gmail.nossr50.datatypes.treasure.FishingTreasure; -import com.gmail.nossr50.datatypes.treasure.Rarity; -import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; -import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; -import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import org.bukkit.Bukkit; @@ -27,14 +17,12 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; -import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.util.BoundingBox; import org.bukkit.util.Vector; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class FishingManager extends SkillManager { @@ -194,12 +182,12 @@ public class FishingManager extends SkillManager { return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER); } - public double getShakeChance() { - return AdvancedConfig.getInstance().getShakeChance(getLootTier()); - } - public double getShakeChance() { - return pluginRef.getConfigManager().getFishingTreasureConfig().getShakeChance(getLootTier()); - } +// public double getShakeChance() { +// return AdvancedConfig.getInstance().getShakeChance(getLootTier()); +// } +// public double getShakeChance() { +// return pluginRef.getConfigManager().getFishingTreasureConfig().getShakeChance(getLootTier()); +// } public int getInnerPeaceMultiplier() { return pluginRef.getConfigManager().getConfigFishing().getVanillaXPMultInnerPeace(pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.FISHING_INNER_PEACE)); @@ -210,9 +198,9 @@ public class FishingManager extends SkillManager { * * @return Shake Mob probability */ - public double getShakeProbability() { - return getShakeChance(); - } +// public double getShakeProbability() { +// return getShakeChance(); +// } /** * Handle the Fisherman's Diet ability @@ -249,13 +237,13 @@ public class FishingManager extends SkillManager { hookLocation = location; - if (fishingBehaviour.getMasterAnglerBiomes().contains(location.getBlock().getBiome())) { - biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); - } - - if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { - biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); - } +// if (fishingBehaviour.getMasterAnglerBiomes().contains(location.getBlock().getBiome())) { +// biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); +// } +// +// if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { +// biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); +// } hook.setBiteChance(Math.min(biteChance, 1.0)); } @@ -275,53 +263,53 @@ public class FishingManager extends SkillManager { int fishXp = fishingBehaviour.getFishXPValue(fishingCatch.getItemStack().getType()); int treasureXp = 0; Player player = getPlayer(); - FishingTreasure treasure = null; +// FishingTreasure treasure = null; if (pluginRef.getConfigManager().getConfigFishing().isAllowCustomDrops() && pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) { - treasure = getFishingTreasure(); +// treasure = getFishingTreasure(); } - if (treasure != null) { - ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay? - Map enchants = new HashMap<>(); - - if (isMagicHunterEnabled() - && pluginRef.getItemTools().isEnchantable(treasureDrop)) { - enchants = handleMagicHunter(treasureDrop); - } - - McMMOPlayerFishingTreasureEvent event = pluginRef.getEventManager().callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants); - - if (!event.isCancelled()) { - treasureDrop = event.getTreasure(); - treasureXp = event.getXp(); - } else { - treasureDrop = null; - treasureXp = 0; - } - - // Drop the original catch at the feet of the player and set the treasure as the real catch - if (treasureDrop != null) { - boolean enchanted = false; - - if (!enchants.isEmpty()) { - treasureDrop.addUnsafeEnchantments(enchants); - enchanted = true; - } - - if (enchanted) { - pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Fishing.Ability.TH.MagicFound"); - } - - if (pluginRef.getConfigManager().getConfigFishing().isAlwaysCatchFish()) { - /*Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());*/ - Misc.dropItem(fishingCatch.getLocation(), fishingCatch.getItemStack()).setVelocity(fishingCatch.getVelocity()); - } - - fishingCatch.setItemStack(treasureDrop); - } - } +// if (treasure != null) { +// ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay? +// Map enchants = new HashMap<>(); +// +// if (isMagicHunterEnabled() +// && pluginRef.getItemTools().isEnchantable(treasureDrop)) { +// enchants = handleMagicHunter(treasureDrop); +// } +// +// McMMOPlayerFishingTreasureEvent event = pluginRef.getEventManager().callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants); +// +// if (!event.isCancelled()) { +// treasureDrop = event.getTreasure(); +// treasureXp = event.getXp(); +// } else { +// treasureDrop = null; +// treasureXp = 0; +// } +// +// // Drop the original catch at the feet of the player and set the treasure as the real catch +// if (treasureDrop != null) { +// boolean enchanted = false; +// +// if (!enchants.isEmpty()) { +// treasureDrop.addUnsafeEnchantments(enchants); +// enchanted = true; +// } +// +// if (enchanted) { +// pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Fishing.Ability.TH.MagicFound"); +// } +// +// if (pluginRef.getConfigManager().getConfigFishing().isAlwaysCatchFish()) { +// /*Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());*/ +// Misc.dropItem(fishingCatch.getLocation(), fishingCatch.getItemStack()).setVelocity(fishingCatch.getVelocity()); +// } +// +// fishingCatch.setItemStack(treasureDrop); +// } +// } applyXpGain(fishXp + treasureXp, XPGainReason.PVE); } @@ -345,151 +333,151 @@ public class FishingManager extends SkillManager { * * @param target The {@link LivingEntity} affected by the ability */ - public void shakeCheck(LivingEntity target) { - if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) { - List possibleDrops = fishingBehaviour.findPossibleDrops(target); - - if (possibleDrops == null || possibleDrops.isEmpty()) { - return; - } - - ItemStack drop = fishingBehaviour.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 PLAYER: - Player targetPlayer = (Player) target; - - switch (drop.getType()) { - case PLAYER_HEAD: - drop.setDurability((short) 3); - SkullMeta skullMeta = (SkullMeta) drop.getItemMeta(); - skullMeta.setOwningPlayer(targetPlayer); - drop.setItemMeta(skullMeta); - break; - - case BEDROCK: - if (FishingTreasureConfig.getInstance().getInventoryStealEnabled()) { - PlayerInventory inventory = targetPlayer.getInventory(); - int length = inventory.getContents().length; - int slot = Misc.getRandom().nextInt(length); - drop = inventory.getItem(slot); - - if (drop == null) { - break; - } - - if (FishingTreasureConfig.getInstance().getInventoryStealStacks()) { - inventory.setItem(slot, null); - } else { - inventory.setItem(slot, (drop.getAmount() > 1) ? new ItemStack(drop.getType(), drop.getAmount() - 1) : null); - drop.setAmount(1); - } - - targetPlayer.updateInventory(); - } - break; - - default: - break; - } - break; - - case SHEEP: - Sheep sheep = (Sheep) target; - - if (drop.getType().name().endsWith("WOOL")) { - if (sheep.isSheared()) { - return; - } - sheep.setSheared(true); - } - break; - default: - break; - } - - McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop); - - drop = shakeEvent.getDrop(); - - if (shakeEvent.isCancelled() || drop == null) { - return; - } - - Misc.dropItem(target.getLocation(), drop); - pluginRef.getCombatTools().dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times. - applyXpGain(pluginRef.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE); - } - } +// public void shakeCheck(LivingEntity target) { +// if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) { +// List possibleDrops = fishingBehaviour.findPossibleDrops(target); +// +// if (possibleDrops == null || possibleDrops.isEmpty()) { +// return; +// } +// +// ItemStack drop = fishingBehaviour.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 PLAYER: +// Player targetPlayer = (Player) target; +// +// switch (drop.getType()) { +// case PLAYER_HEAD: +// drop.setDurability((short) 3); +// SkullMeta skullMeta = (SkullMeta) drop.getItemMeta(); +// skullMeta.setOwningPlayer(targetPlayer); +// drop.setItemMeta(skullMeta); +// break; +// +// case BEDROCK: +// if (FishingTreasureConfig.getInstance().getInventoryStealEnabled()) { +// PlayerInventory inventory = targetPlayer.getInventory(); +// int length = inventory.getContents().length; +// int slot = Misc.getRandom().nextInt(length); +// drop = inventory.getItem(slot); +// +// if (drop == null) { +// break; +// } +// +// if (FishingTreasureConfig.getInstance().getInventoryStealStacks()) { +// inventory.setItem(slot, null); +// } else { +// inventory.setItem(slot, (drop.getAmount() > 1) ? new ItemStack(drop.getType(), drop.getAmount() - 1) : null); +// drop.setAmount(1); +// } +// +// targetPlayer.updateInventory(); +// } +// break; +// +// default: +// break; +// } +// break; +// +// case SHEEP: +// Sheep sheep = (Sheep) target; +// +// if (drop.getType().name().endsWith("WOOL")) { +// if (sheep.isSheared()) { +// return; +// } +// sheep.setSheared(true); +// } +// break; +// default: +// break; +// } +// +// McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop); +// +// drop = shakeEvent.getDrop(); +// +// if (shakeEvent.isCancelled() || drop == null) { +// return; +// } +// +// Misc.dropItem(target.getLocation(), drop); +// pluginRef.getCombatTools().dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times. +// applyXpGain(pluginRef.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE); +// } +// } /** * Process the Treasure Hunter ability for Fishing * * @return The {@link FishingTreasure} found, or null if no treasure was found. */ - private FishingTreasure getFishingTreasure() { - double diceRoll = Misc.getRandom().nextDouble() * 100; - int luck; - - if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) { - luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK); - } else { - // We know something was caught, so if the rod wasn't in the main hand it must be in the offhand - luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK); - } - - // Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck. - diceRoll *= (1.0 - luck * pluginRef.getConfigManager().getConfigFishing().getLureLuckModifier() / 100); - - FishingTreasure treasure = null; - - for (Rarity rarity : Rarity.values()) { - double dropRate = FishingTreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity); - - if (diceRoll <= dropRate) { - /*if (rarity == Rarity.TRAP) { - handleTraps(); - break; - }*/ - - List fishingTreasures = FishingTreasureConfig.getInstance().fishingRewards.get(rarity); - - if (fishingTreasures.isEmpty()) { - return null; - } - - treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size())); - break; - } - - diceRoll -= dropRate; - } - - if (treasure == null) { - return null; - } - - ItemStack treasureDrop = treasure.getDrop().clone(); - short maxDurability = treasureDrop.getType().getMaxDurability(); - - if (maxDurability > 0) { - treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); - } - - if (treasureDrop.getAmount() > 1) { - treasureDrop.setAmount(Misc.getRandom().nextInt(treasureDrop.getAmount()) + 1); - } - - treasure.setDrop(treasureDrop); - - return treasure; - } +// private FishingTreasure getFishingTreasure() { +// double diceRoll = Misc.getRandom().nextDouble() * 100; +// int luck; +// +// if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) { +// luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK); +// } else { +// // We know something was caught, so if the rod wasn't in the main hand it must be in the offhand +// luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK); +// } +// +// // Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck. +// diceRoll *= (1.0 - luck * pluginRef.getConfigManager().getConfigFishing().getLureLuckModifier() / 100); +// +// FishingTreasure treasure = null; +// +// for (Rarity rarity : Rarity.values()) { +// double dropRate = FishingTreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity); +// +// if (diceRoll <= dropRate) { +// /*if (rarity == Rarity.TRAP) { +// handleTraps(); +// break; +// }*/ +// +// List fishingTreasures = FishingTreasureConfig.getInstance().fishingRewards.get(rarity); +// +// if (fishingTreasures.isEmpty()) { +// return null; +// } +// +// treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size())); +// break; +// } +// +// diceRoll -= dropRate; +// } +// +// if (treasure == null) { +// return null; +// } +// +// ItemStack treasureDrop = treasure.getDrop().clone(); +// short maxDurability = treasureDrop.getType().getMaxDurability(); +// +// if (maxDurability > 0) { +// treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); +// } +// +// if (treasureDrop.getAmount() > 1) { +// treasureDrop.setAmount(Misc.getRandom().nextInt(treasureDrop.getAmount()) + 1); +// } +// +// treasure.setDrop(treasureDrop); +// +// return treasure; +// } /** * Process the Magic Hunter ability @@ -497,68 +485,68 @@ public class FishingManager extends SkillManager { * @param treasureDrop The {@link ItemStack} to enchant * @return true if the item has been enchanted */ - private Map handleMagicHunter(ItemStack treasureDrop) { - Map enchants = new HashMap<>(); - List fishingEnchantments = null; - - double diceRoll = Misc.getRandom().nextDouble() * 100; - - for (Rarity rarity : Rarity.values()) { - if (rarity == Rarity.RECORD) { - continue; - } - - double dropRate = FishingTreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity); - - if (diceRoll <= dropRate) { - // Make sure enchanted books always get some kind of enchantment. --hoorigan - if (treasureDrop.getType() == Material.ENCHANTED_BOOK) { - diceRoll = dropRate + 1; - continue; - } - fishingEnchantments = FishingTreasureConfig.getInstance().fishingEnchantments.get(rarity); - break; - } - - diceRoll -= dropRate; - } - - if (fishingEnchantments == null) { - return enchants; - } - - List validEnchantments = getPossibleEnchantments(treasureDrop); - List possibleEnchants = new ArrayList<>(); - - for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) { - if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) { - possibleEnchants.add(enchantmentTreasure); - } - } - - if (possibleEnchants.isEmpty()) { - return enchants; - } - - // 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(possibleEnchants, Misc.getRandom()); - - int specificChance = 1; - - for (EnchantmentTreasure enchantmentTreasure : possibleEnchants) { - Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment(); - - if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) { - continue; - } - - enchants.put(possibleEnchantment, enchantmentTreasure.getLevel()); - - specificChance *= 2; - } - - return enchants; - } +// private Map handleMagicHunter(ItemStack treasureDrop) { +// Map enchants = new HashMap<>(); +// List fishingEnchantments = null; +// +// double diceRoll = Misc.getRandom().nextDouble() * 100; +// +// for (Rarity rarity : Rarity.values()) { +// if (rarity == Rarity.RECORD) { +// continue; +// } +// +// double dropRate = FishingTreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity); +// +// if (diceRoll <= dropRate) { +// // Make sure enchanted books always get some kind of enchantment. --hoorigan +// if (treasureDrop.getType() == Material.ENCHANTED_BOOK) { +// diceRoll = dropRate + 1; +// continue; +// } +// fishingEnchantments = FishingTreasureConfig.getInstance().fishingEnchantments.get(rarity); +// break; +// } +// +// diceRoll -= dropRate; +// } +// +// if (fishingEnchantments == null) { +// return enchants; +// } +// +// List validEnchantments = getPossibleEnchantments(treasureDrop); +// List possibleEnchants = new ArrayList<>(); +// +// for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) { +// if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) { +// possibleEnchants.add(enchantmentTreasure); +// } +// } +// +// if (possibleEnchants.isEmpty()) { +// return enchants; +// } +// +// // 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(possibleEnchants, Misc.getRandom()); +// +// int specificChance = 1; +// +// for (EnchantmentTreasure enchantmentTreasure : possibleEnchants) { +// Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment(); +// +// if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) { +// continue; +// } +// +// enchants.put(possibleEnchantment, enchantmentTreasure.getLevel()); +// +// specificChance *= 2; +// } +// +// return enchants; +// } private List getPossibleEnchantments(ItemStack treasureDrop) { Material dropType = treasureDrop.getType();