|
@@ -1,23 +1,13 @@
|
|
package com.gmail.nossr50.skills.fishing;
|
|
package com.gmail.nossr50.skills.fishing;
|
|
|
|
|
|
-import com.gmail.nossr50.config.AdvancedConfig;
|
|
|
|
import com.gmail.nossr50.core.MetadataConstants;
|
|
import com.gmail.nossr50.core.MetadataConstants;
|
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|
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.player.McMMOPlayer;
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|
import com.gmail.nossr50.datatypes.skills.behaviours.FishingBehaviour;
|
|
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.mcMMO;
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
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.SoundManager;
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Bukkit;
|
|
@@ -27,14 +17,12 @@ import org.bukkit.block.Block;
|
|
import org.bukkit.block.BlockFace;
|
|
import org.bukkit.block.BlockFace;
|
|
import org.bukkit.enchantments.Enchantment;
|
|
import org.bukkit.enchantments.Enchantment;
|
|
import org.bukkit.entity.*;
|
|
import org.bukkit.entity.*;
|
|
-import org.bukkit.event.entity.EntityDamageEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
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.BoundingBox;
|
|
import org.bukkit.util.Vector;
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class FishingManager extends SkillManager {
|
|
public class FishingManager extends SkillManager {
|
|
|
|
|
|
@@ -194,12 +182,12 @@ public class FishingManager extends SkillManager {
|
|
return pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.FISHING_TREASURE_HUNTER);
|
|
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() {
|
|
public int getInnerPeaceMultiplier() {
|
|
return pluginRef.getConfigManager().getConfigFishing().getVanillaXPMultInnerPeace(pluginRef.getRankTools().getRank(getPlayer(), SubSkillType.FISHING_INNER_PEACE));
|
|
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
|
|
* @return Shake Mob probability
|
|
*/
|
|
*/
|
|
- public double getShakeProbability() {
|
|
|
|
- return getShakeChance();
|
|
|
|
- }
|
|
|
|
|
|
+// public double getShakeProbability() {
|
|
|
|
+// return getShakeChance();
|
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Handle the Fisherman's Diet ability
|
|
* Handle the Fisherman's Diet ability
|
|
@@ -249,13 +237,13 @@ public class FishingManager extends SkillManager {
|
|
|
|
|
|
hookLocation = location;
|
|
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));
|
|
hook.setBiteChance(Math.min(biteChance, 1.0));
|
|
}
|
|
}
|
|
@@ -275,53 +263,53 @@ public class FishingManager extends SkillManager {
|
|
int fishXp = fishingBehaviour.getFishXPValue(fishingCatch.getItemStack().getType());
|
|
int fishXp = fishingBehaviour.getFishXPValue(fishingCatch.getItemStack().getType());
|
|
int treasureXp = 0;
|
|
int treasureXp = 0;
|
|
Player player = getPlayer();
|
|
Player player = getPlayer();
|
|
- FishingTreasure treasure = null;
|
|
|
|
|
|
+// FishingTreasure treasure = null;
|
|
|
|
|
|
if (pluginRef.getConfigManager().getConfigFishing().isAllowCustomDrops()
|
|
if (pluginRef.getConfigManager().getConfigFishing().isAllowCustomDrops()
|
|
&& pluginRef.getPermissionTools().isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) {
|
|
&& 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<Enchantment, Integer> 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<Enchantment, Integer> 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);
|
|
applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
|
|
}
|
|
}
|
|
@@ -345,151 +333,151 @@ public class FishingManager extends SkillManager {
|
|
*
|
|
*
|
|
* @param target The {@link LivingEntity} affected by the ability
|
|
* @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<ShakeTreasure> 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<ShakeTreasure> 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
|
|
* Process the Treasure Hunter ability for Fishing
|
|
*
|
|
*
|
|
* @return The {@link FishingTreasure} found, or null if no treasure was found.
|
|
* @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<FishingTreasure> 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<FishingTreasure> 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
|
|
* Process the Magic Hunter ability
|
|
@@ -497,68 +485,68 @@ public class FishingManager extends SkillManager {
|
|
* @param treasureDrop The {@link ItemStack} to enchant
|
|
* @param treasureDrop The {@link ItemStack} to enchant
|
|
* @return true if the item has been enchanted
|
|
* @return true if the item has been enchanted
|
|
*/
|
|
*/
|
|
- private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
|
|
|
|
- Map<Enchantment, Integer> enchants = new HashMap<>();
|
|
|
|
- List<EnchantmentTreasure> 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<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop);
|
|
|
|
- List<EnchantmentTreasure> 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<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
|
|
|
|
+// Map<Enchantment, Integer> enchants = new HashMap<>();
|
|
|
|
+// List<EnchantmentTreasure> 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<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop);
|
|
|
|
+// List<EnchantmentTreasure> 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<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {
|
|
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {
|
|
Material dropType = treasureDrop.getType();
|
|
Material dropType = treasureDrop.getType();
|