Treasure code removed pending rewrite

This commit is contained in:
nossr50 2019-09-23 19:20:09 -07:00
parent 3aead73d07
commit 815131a013
20 changed files with 485 additions and 504 deletions

View File

@ -1,16 +1,11 @@
package com.gmail.nossr50.commands.skills; 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.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,34 +49,34 @@ public class FishingCommand extends SkillCommand {
lootTier = fishingManager.getLootTier(); lootTier = fishingManager.getLootTier();
// Item drop rates // Item drop rates
commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0); // commonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0); // uncommonTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0); // rareTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0); // epicTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0); // legendaryTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = percent.format(FishingTreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 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 // if (totalEnchantChance >= 1)
double totalEnchantChance = 0; // magicChance = percent.format(totalEnchantChance / 100.0);
// else
for (Rarity rarity : Rarity.values()) { // magicChance = percent.format(0);
if (rarity != Rarity.RECORD) {
totalEnchantChance += FishingTreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
}
}
if (totalEnchantChance >= 1)
magicChance = percent.format(totalEnchantChance / 100.0);
else
magicChance = percent.format(0);
} }
// FISHING_SHAKE // FISHING_SHAKE
if (canShake) { // if (canShake) {
String[] shakeStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance()); // String[] shakeStrings = pluginRef.getRandomChanceTools().calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
shakeChance = shakeStrings[0]; // shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1]; // shakeChanceLucky = shakeStrings[1];
} // }
// FISHERMAN'S DIET // FISHERMAN'S DIET
if (canFishermansDiet) { if (canFishermansDiet) {
@ -98,13 +93,13 @@ public class FishingCommand extends SkillCommand {
location = player.getLocation(); location = player.getLocation();
} }
if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) { // if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); // rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
} // }
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { // if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); // rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
} // }
double luckyModifier = pluginRef.getPermissionTools().lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D; 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))); messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank)));
} }
if (canIceFish) { // if (canIceFish) {
messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription())); // messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription()));
} // }
if (canMagicHunt) { if (canMagicHunt) {
messages.add(getStatMessage(SubSkillType.FISHING_MAGIC_HUNTER, magicChance)); messages.add(getStatMessage(SubSkillType.FISHING_MAGIC_HUNTER, magicChance));

View File

@ -1,14 +1,8 @@
package com.gmail.nossr50.datatypes.skills.behaviours; 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.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.block.BlockState; 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 * 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 * 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; this.pluginRef = pluginRef;
} }
/** // /**
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block. // * Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
* // *
* @param blockState The {@link BlockState} of the block to check. // * @param blockState The {@link BlockState} of the block to check.
* @return the list of treasures that could be found // * @return the list of treasures that could be found
*/ // */
public List<ExcavationTreasure> getTreasures(BlockState blockState) { // public List<ExcavationTreasure> getTreasures(BlockState blockState) {
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); // String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly)) // if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly))
return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly); // return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly);
return new ArrayList<>(); // return new ArrayList<>();
} // }
public int getBlockXP(BlockState blockState) { public int getBlockXP(BlockState blockState) {
int xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getExcavationXp(blockState.getType()); int xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getExcavationXp(blockState.getType());

View File

@ -1,14 +1,10 @@
package com.gmail.nossr50.datatypes.skills.behaviours; package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.adapter.BiomeAdapter; import com.gmail.nossr50.util.adapter.BiomeAdapter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -61,39 +57,39 @@ public class FishingBehaviour {
} }
} }
/** // /**
* Finds the possible drops of an entity // * Finds the possible drops of an entity
* // *
* @param target Targeted entity // * @param target Targeted entity
* @return possibleDrops List of ItemStack that can be dropped // * @return possibleDrops List of ItemStack that can be dropped
*/ // */
public List<ShakeTreasure> findPossibleDrops(LivingEntity target) { // public List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
if (FishingTreasureConfig.getInstance().shakeMap.containsKey(target.getType())) // if (FishingTreasureConfig.getInstance().shakeMap.containsKey(target.getType()))
return FishingTreasureConfig.getInstance().shakeMap.get(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
* Randomly chooses a drop among the list // * @return Chosen ItemStack
* // */
* @param possibleDrops List of ItemStack that can be dropped // public ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
* @return Chosen ItemStack // int dropProbability = Misc.getRandom().nextInt(100);
*/ // double cumulatedProbability = 0;
public ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) { //
int dropProbability = Misc.getRandom().nextInt(100); // for (ShakeTreasure treasure : possibleDrops) {
double cumulatedProbability = 0; // cumulatedProbability += treasure.getDropChance();
//
for (ShakeTreasure treasure : possibleDrops) { // if (dropProbability < cumulatedProbability) {
cumulatedProbability += treasure.getDropChance(); // return treasure.getDrop().clone();
// }
if (dropProbability < cumulatedProbability) { // }
return treasure.getDrop().clone(); //
} // return null;
} // }
return null;
}
public HashMap<Material, List<Enchantment>> getEnchantableCache() { public HashMap<Material, List<Enchantment>> getEnchantableCache() {
return enchantableCache; return enchantableCache;

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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;
// }
//}

View File

@ -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);
// }
//}

View File

@ -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);
// }
//}

View File

@ -5,7 +5,7 @@
//import com.gmail.nossr50.config.UnsafeValueValidation; //import com.gmail.nossr50.config.UnsafeValueValidation;
//import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure; //import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
//import com.gmail.nossr50.datatypes.treasure.FishingTreasure; //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.datatypes.treasure.ShakeTreasure;
//import com.gmail.nossr50.mcMMO; //import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.EnchantmentUtils; //import com.gmail.nossr50.util.EnchantmentUtils;

View File

@ -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);
// }
//}

View File

@ -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;
// }
// }
//}

View File

@ -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);
// }
//}

View File

@ -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;
// }
//}

View File

@ -387,7 +387,15 @@ public class PlayerListener implements Listener {
return; return;
case CAUGHT_ENTITY: case CAUGHT_ENTITY:
if (fishingManager.canShake(caught)) { 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(); fishingManager.setFishingTarget();
} }
return; return;

View File

@ -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() { // public double getShakeChance() {
return AdvancedConfig.getInstance().getShakeChance(getLootTier()); // return AdvancedConfig.getInstance().getShakeChance(getLootTier());
} // }
public double getShakeChance() { // public double getShakeChance() {
return pluginRef.getConfigManager().getFishingTreasureConfig().getShakeChance(getLootTier()); // 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() { // public double getShakeProbability() {
return getShakeChance(); // 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())) { // if (fishingBehaviour.getMasterAnglerBiomes().contains(location.getBlock().getBiome())) {
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); // biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
} // }
//
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) { // if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); // 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) { // if (treasure != null) {
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay? // ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
Map<Enchantment, Integer> enchants = new HashMap<>(); // Map<Enchantment, Integer> enchants = new HashMap<>();
//
if (isMagicHunterEnabled() // if (isMagicHunterEnabled()
&& pluginRef.getItemTools().isEnchantable(treasureDrop)) { // && pluginRef.getItemTools().isEnchantable(treasureDrop)) {
enchants = handleMagicHunter(treasureDrop); // enchants = handleMagicHunter(treasureDrop);
} // }
//
McMMOPlayerFishingTreasureEvent event = pluginRef.getEventManager().callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants); // McMMOPlayerFishingTreasureEvent event = pluginRef.getEventManager().callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
//
if (!event.isCancelled()) { // if (!event.isCancelled()) {
treasureDrop = event.getTreasure(); // treasureDrop = event.getTreasure();
treasureXp = event.getXp(); // treasureXp = event.getXp();
} else { // } else {
treasureDrop = null; // treasureDrop = null;
treasureXp = 0; // treasureXp = 0;
} // }
//
// Drop the original catch at the feet of the player and set the treasure as the real catch // // Drop the original catch at the feet of the player and set the treasure as the real catch
if (treasureDrop != null) { // if (treasureDrop != null) {
boolean enchanted = false; // boolean enchanted = false;
//
if (!enchants.isEmpty()) { // if (!enchants.isEmpty()) {
treasureDrop.addUnsafeEnchantments(enchants); // treasureDrop.addUnsafeEnchantments(enchants);
enchanted = true; // enchanted = true;
} // }
//
if (enchanted) { // if (enchanted) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Fishing.Ability.TH.MagicFound"); // pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Fishing.Ability.TH.MagicFound");
} // }
//
if (pluginRef.getConfigManager().getConfigFishing().isAlwaysCatchFish()) { // if (pluginRef.getConfigManager().getConfigFishing().isAlwaysCatchFish()) {
/*Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());*/ // /*Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());*/
Misc.dropItem(fishingCatch.getLocation(), fishingCatch.getItemStack()).setVelocity(fishingCatch.getVelocity()); // Misc.dropItem(fishingCatch.getLocation(), fishingCatch.getItemStack()).setVelocity(fishingCatch.getVelocity());
} // }
//
fishingCatch.setItemStack(treasureDrop); // 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) { // public void shakeCheck(LivingEntity target) {
if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) { // if (pluginRef.getRandomChanceTools().checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) {
List<ShakeTreasure> possibleDrops = fishingBehaviour.findPossibleDrops(target); // List<ShakeTreasure> possibleDrops = fishingBehaviour.findPossibleDrops(target);
//
if (possibleDrops == null || possibleDrops.isEmpty()) { // if (possibleDrops == null || possibleDrops.isEmpty()) {
return; // return;
} // }
//
ItemStack drop = fishingBehaviour.chooseDrop(possibleDrops); // ItemStack drop = fishingBehaviour.chooseDrop(possibleDrops);
//
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100 // // It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
if (drop == null) { // if (drop == null) {
return; // return;
} // }
//
// Extra processing depending on the mob and drop type // // Extra processing depending on the mob and drop type
switch (target.getType()) { // switch (target.getType()) {
case PLAYER: // case PLAYER:
Player targetPlayer = (Player) target; // Player targetPlayer = (Player) target;
//
switch (drop.getType()) { // switch (drop.getType()) {
case PLAYER_HEAD: // case PLAYER_HEAD:
drop.setDurability((short) 3); // drop.setDurability((short) 3);
SkullMeta skullMeta = (SkullMeta) drop.getItemMeta(); // SkullMeta skullMeta = (SkullMeta) drop.getItemMeta();
skullMeta.setOwningPlayer(targetPlayer); // skullMeta.setOwningPlayer(targetPlayer);
drop.setItemMeta(skullMeta); // drop.setItemMeta(skullMeta);
break; // break;
//
case BEDROCK: // case BEDROCK:
if (FishingTreasureConfig.getInstance().getInventoryStealEnabled()) { // if (FishingTreasureConfig.getInstance().getInventoryStealEnabled()) {
PlayerInventory inventory = targetPlayer.getInventory(); // PlayerInventory inventory = targetPlayer.getInventory();
int length = inventory.getContents().length; // int length = inventory.getContents().length;
int slot = Misc.getRandom().nextInt(length); // int slot = Misc.getRandom().nextInt(length);
drop = inventory.getItem(slot); // drop = inventory.getItem(slot);
//
if (drop == null) { // if (drop == null) {
break; // break;
} // }
//
if (FishingTreasureConfig.getInstance().getInventoryStealStacks()) { // if (FishingTreasureConfig.getInstance().getInventoryStealStacks()) {
inventory.setItem(slot, null); // inventory.setItem(slot, null);
} else { // } else {
inventory.setItem(slot, (drop.getAmount() > 1) ? new ItemStack(drop.getType(), drop.getAmount() - 1) : null); // inventory.setItem(slot, (drop.getAmount() > 1) ? new ItemStack(drop.getType(), drop.getAmount() - 1) : null);
drop.setAmount(1); // drop.setAmount(1);
} // }
//
targetPlayer.updateInventory(); // targetPlayer.updateInventory();
} // }
break; // break;
//
default: // default:
break; // break;
} // }
break; // break;
//
case SHEEP: // case SHEEP:
Sheep sheep = (Sheep) target; // Sheep sheep = (Sheep) target;
//
if (drop.getType().name().endsWith("WOOL")) { // if (drop.getType().name().endsWith("WOOL")) {
if (sheep.isSheared()) { // if (sheep.isSheared()) {
return; // return;
} // }
sheep.setSheared(true); // sheep.setSheared(true);
} // }
break; // break;
default: // default:
break; // break;
} // }
//
McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop); // McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop);
//
drop = shakeEvent.getDrop(); // drop = shakeEvent.getDrop();
//
if (shakeEvent.isCancelled() || drop == null) { // if (shakeEvent.isCancelled() || drop == null) {
return; // return;
} // }
//
Misc.dropItem(target.getLocation(), drop); // 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. // 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); // 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() { // private FishingTreasure getFishingTreasure() {
double diceRoll = Misc.getRandom().nextDouble() * 100; // double diceRoll = Misc.getRandom().nextDouble() * 100;
int luck; // int luck;
//
if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) { // if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK); // luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
} else { // } else {
// We know something was caught, so if the rod wasn't in the main hand it must be in the offhand // // 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); // luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK);
} // }
//
// Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by 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); // diceRoll *= (1.0 - luck * pluginRef.getConfigManager().getConfigFishing().getLureLuckModifier() / 100);
//
FishingTreasure treasure = null; // FishingTreasure treasure = null;
//
for (Rarity rarity : Rarity.values()) { // for (Rarity rarity : Rarity.values()) {
double dropRate = FishingTreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity); // double dropRate = FishingTreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity);
//
if (diceRoll <= dropRate) { // if (diceRoll <= dropRate) {
/*if (rarity == Rarity.TRAP) { // /*if (rarity == Rarity.TRAP) {
handleTraps(); // handleTraps();
break; // break;
}*/ // }*/
//
List<FishingTreasure> fishingTreasures = FishingTreasureConfig.getInstance().fishingRewards.get(rarity); // List<FishingTreasure> fishingTreasures = FishingTreasureConfig.getInstance().fishingRewards.get(rarity);
//
if (fishingTreasures.isEmpty()) { // if (fishingTreasures.isEmpty()) {
return null; // return null;
} // }
//
treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size())); // treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size()));
break; // break;
} // }
//
diceRoll -= dropRate; // diceRoll -= dropRate;
} // }
//
if (treasure == null) { // if (treasure == null) {
return null; // return null;
} // }
//
ItemStack treasureDrop = treasure.getDrop().clone(); // ItemStack treasureDrop = treasure.getDrop().clone();
short maxDurability = treasureDrop.getType().getMaxDurability(); // short maxDurability = treasureDrop.getType().getMaxDurability();
//
if (maxDurability > 0) { // if (maxDurability > 0) {
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability))); // treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
} // }
//
if (treasureDrop.getAmount() > 1) { // if (treasureDrop.getAmount() > 1) {
treasureDrop.setAmount(Misc.getRandom().nextInt(treasureDrop.getAmount()) + 1); // treasureDrop.setAmount(Misc.getRandom().nextInt(treasureDrop.getAmount()) + 1);
} // }
//
treasure.setDrop(treasureDrop); // treasure.setDrop(treasureDrop);
//
return treasure; // 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) { // private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Map<Enchantment, Integer> enchants = new HashMap<>(); // Map<Enchantment, Integer> enchants = new HashMap<>();
List<EnchantmentTreasure> fishingEnchantments = null; // List<EnchantmentTreasure> fishingEnchantments = null;
//
double diceRoll = Misc.getRandom().nextDouble() * 100; // double diceRoll = Misc.getRandom().nextDouble() * 100;
//
for (Rarity rarity : Rarity.values()) { // for (Rarity rarity : Rarity.values()) {
if (rarity == Rarity.RECORD) { // if (rarity == Rarity.RECORD) {
continue; // continue;
} // }
//
double dropRate = FishingTreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity); // double dropRate = FishingTreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
//
if (diceRoll <= dropRate) { // if (diceRoll <= dropRate) {
// Make sure enchanted books always get some kind of enchantment. --hoorigan // // Make sure enchanted books always get some kind of enchantment. --hoorigan
if (treasureDrop.getType() == Material.ENCHANTED_BOOK) { // if (treasureDrop.getType() == Material.ENCHANTED_BOOK) {
diceRoll = dropRate + 1; // diceRoll = dropRate + 1;
continue; // continue;
} // }
fishingEnchantments = FishingTreasureConfig.getInstance().fishingEnchantments.get(rarity); // fishingEnchantments = FishingTreasureConfig.getInstance().fishingEnchantments.get(rarity);
break; // break;
} // }
//
diceRoll -= dropRate; // diceRoll -= dropRate;
} // }
//
if (fishingEnchantments == null) { // if (fishingEnchantments == null) {
return enchants; // return enchants;
} // }
//
List<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop); // List<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop);
List<EnchantmentTreasure> possibleEnchants = new ArrayList<>(); // List<EnchantmentTreasure> possibleEnchants = new ArrayList<>();
//
for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) { // for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) {
if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) { // if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) {
possibleEnchants.add(enchantmentTreasure); // possibleEnchants.add(enchantmentTreasure);
} // }
} // }
//
if (possibleEnchants.isEmpty()) { // if (possibleEnchants.isEmpty()) {
return enchants; // 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 // // 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()); // Collections.shuffle(possibleEnchants, Misc.getRandom());
//
int specificChance = 1; // int specificChance = 1;
//
for (EnchantmentTreasure enchantmentTreasure : possibleEnchants) { // for (EnchantmentTreasure enchantmentTreasure : possibleEnchants) {
Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment(); // Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment();
//
if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) { // if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) {
continue; // continue;
} // }
//
enchants.put(possibleEnchantment, enchantmentTreasure.getLevel()); // enchants.put(possibleEnchantment, enchantmentTreasure.getLevel());
//
specificChance *= 2; // specificChance *= 2;
} // }
//
return enchants; // return enchants;
} // }
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) { private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {
Material dropType = treasureDrop.getType(); Material dropType = treasureDrop.getType();