mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Wire up Excavation, Fishing, and Herbalism behaviours
This commit is contained in:
parent
148a4fd555
commit
cf6d28a1bd
@ -1,6 +1,13 @@
|
|||||||
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 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
|
||||||
@ -16,4 +23,23 @@ public class ExcavationBehaviour {
|
|||||||
public ExcavationBehaviour(mcMMO pluginRef) {
|
public ExcavationBehaviour(mcMMO pluginRef) {
|
||||||
this.pluginRef = pluginRef;
|
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<ExcavationTreasure> 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());
|
||||||
|
|
||||||
|
return xp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.behaviours;
|
package com.gmail.nossr50.datatypes.skills.behaviours;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||||
|
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 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;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These behaviour classes are a band-aid fix for a larger problem
|
* These behaviour classes are a band-aid fix for a larger problem
|
||||||
@ -13,7 +26,105 @@ public class FishingBehaviour {
|
|||||||
|
|
||||||
private final mcMMO pluginRef;
|
private final mcMMO pluginRef;
|
||||||
|
|
||||||
|
private final long fishingRodCastCdMilliseconds;
|
||||||
|
private final int overfishLimit;
|
||||||
|
private final double boundingBoxSize;
|
||||||
|
private HashMap<Material, List<Enchantment>> enchantableCache = new HashMap<>();
|
||||||
|
private HashMap<Material, Integer> fishingXpRewardMap;
|
||||||
|
private Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
|
||||||
|
private Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
|
||||||
|
|
||||||
public FishingBehaviour(mcMMO pluginRef) {
|
public FishingBehaviour(mcMMO pluginRef) {
|
||||||
this.pluginRef = pluginRef;
|
this.pluginRef = pluginRef;
|
||||||
|
|
||||||
|
overfishLimit = pluginRef.getConfigManager().getConfigExploitPrevention().getOverfishingLimit() + 1;
|
||||||
|
fishingRodCastCdMilliseconds = pluginRef.getConfigManager().getConfigExploitPrevention().getFishingRodSpamMilliseconds();
|
||||||
|
boundingBoxSize = pluginRef.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize();
|
||||||
|
initFishingXPRewardMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the Fishing Catch -> XP Reward map
|
||||||
|
*/
|
||||||
|
private void initFishingXPRewardMap() {
|
||||||
|
fishingXpRewardMap = new HashMap<>();
|
||||||
|
HashMap<String, Integer> nameRegisterMap = pluginRef.getConfigManager().getConfigExperience().getFishingXPMap();
|
||||||
|
|
||||||
|
for (String qualifiedName : nameRegisterMap.keySet()) {
|
||||||
|
Material material = Material.matchMaterial(qualifiedName);
|
||||||
|
|
||||||
|
if (material == null) {
|
||||||
|
pluginRef.getLogger().info("Unable to match qualified name to item for fishing xp map: " + qualifiedName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fishingXpRewardMap.putIfAbsent(material, nameRegisterMap.get(qualifiedName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the possible drops of an entity
|
||||||
|
*
|
||||||
|
* @param target Targeted entity
|
||||||
|
* @return possibleDrops List of ItemStack that can be dropped
|
||||||
|
*/
|
||||||
|
public List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
||||||
|
if (FishingTreasureConfig.getInstance().shakeMap.containsKey(target.getType()))
|
||||||
|
return FishingTreasureConfig.getInstance().shakeMap.get(target.getType());
|
||||||
|
|
||||||
|
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<ShakeTreasure> 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<Material, List<Enchantment>> getEnchantableCache() {
|
||||||
|
return enchantableCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Material, Integer> getFishingXpRewardMap() {
|
||||||
|
return fishingXpRewardMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Biome> getMasterAnglerBiomes() {
|
||||||
|
return masterAnglerBiomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Biome> getIceFishingBiomes() {
|
||||||
|
return iceFishingBiomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFishXPValue(Material material) {
|
||||||
|
return fishingXpRewardMap.get(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFishingRodCastCdMilliseconds() {
|
||||||
|
return fishingRodCastCdMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOverfishLimit() {
|
||||||
|
return overfishLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getBoundingBoxSize() {
|
||||||
|
return boundingBoxSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class HerbalismBehaviour {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean convertGreenTerraBlocks(BlockState blockState) {
|
public boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case COBBLESTONE_WALL:
|
case COBBLESTONE_WALL:
|
||||||
blockState.setType(Material.MOSSY_COBBLESTONE_WALL);
|
blockState.setType(Material.MOSSY_COBBLESTONE_WALL);
|
||||||
@ -96,7 +96,7 @@ public class HerbalismBehaviour {
|
|||||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
* @param blockState The {@link BlockState} of the bottom block of the plant
|
||||||
* @return the number of bonus drops to award from the blocks in this plant
|
* @return the number of bonus drops to award from the blocks in this plant
|
||||||
*/
|
*/
|
||||||
protected int countAndMarkDoubleDropsMultiBlockPlant(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
|
public int countAndMarkDoubleDropsMultiBlockPlant(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
Material blockType = blockState.getType();
|
Material blockType = blockState.getType();
|
||||||
int dropAmount = 0;
|
int dropAmount = 0;
|
||||||
@ -152,7 +152,7 @@ public class HerbalismBehaviour {
|
|||||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
* @param blockState The {@link BlockState} of the bottom block of the plant
|
||||||
* @return the number of bonus drops to award from the blocks in this plant
|
* @return the number of bonus drops to award from the blocks in this plant
|
||||||
*/
|
*/
|
||||||
protected int countAndMarkDoubleDropsKelp(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
|
public int countAndMarkDoubleDropsKelp(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
|
|
||||||
int kelpMaxHeight = 255;
|
int kelpMaxHeight = 255;
|
||||||
@ -198,7 +198,7 @@ public class HerbalismBehaviour {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean convertShroomThumb(BlockState blockState) {
|
public boolean convertShroomThumb(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case DIRT:
|
case DIRT:
|
||||||
case GRASS_BLOCK:
|
case GRASS_BLOCK:
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
package com.gmail.nossr50.skills.excavation;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Excavation {
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
|
||||||
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
|
||||||
if (ExcavationTreasureConfig.getInstance().excavationMap.containsKey(friendly))
|
|
||||||
return ExcavationTreasureConfig.getInstance().excavationMap.get(friendly);
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static int getBlockXP(BlockState blockState) {
|
|
||||||
int xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getExcavationXp(blockState.getType());
|
|
||||||
|
|
||||||
return xp;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|||||||
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.ExcavationBehaviour;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
@ -21,8 +22,12 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ExcavationManager extends SkillManager {
|
public class ExcavationManager extends SkillManager {
|
||||||
|
|
||||||
|
private final ExcavationBehaviour excavationBehaviour;
|
||||||
|
|
||||||
public ExcavationManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
|
public ExcavationManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
|
||||||
super(pluginRef, mcMMOPlayer, PrimarySkillType.EXCAVATION);
|
super(pluginRef, mcMMOPlayer, PrimarySkillType.EXCAVATION);
|
||||||
|
this.excavationBehaviour = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getExcavationBehaviour();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,10 +36,10 @@ public class ExcavationManager extends SkillManager {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
*/
|
*/
|
||||||
public void excavationBlockCheck(BlockState blockState) {
|
public void excavationBlockCheck(BlockState blockState) {
|
||||||
int xp = Excavation.getBlockXP(blockState);
|
int xp = excavationBehaviour.getBlockXP(blockState);
|
||||||
|
|
||||||
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
||||||
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
|
List<ExcavationTreasure> treasures = excavationBehaviour.getTreasures(blockState);
|
||||||
|
|
||||||
if (!treasures.isEmpty()) {
|
if (!treasures.isEmpty()) {
|
||||||
int skillLevel = getSkillLevel();
|
int skillLevel = getSkillLevel();
|
||||||
@ -75,7 +80,7 @@ public class ExcavationManager extends SkillManager {
|
|||||||
public void printExcavationDebug(Player player, BlockState blockState)
|
public void printExcavationDebug(Player player, BlockState blockState)
|
||||||
{
|
{
|
||||||
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
||||||
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
|
List<ExcavationTreasure> treasures = excavationBehaviour.getTreasures(blockState);
|
||||||
|
|
||||||
if (!treasures.isEmpty()) {
|
if (!treasures.isEmpty()) {
|
||||||
for (ExcavationTreasure treasure : treasures) {
|
for (ExcavationTreasure treasure : treasures) {
|
||||||
|
@ -1,126 +0,0 @@
|
|||||||
package com.gmail.nossr50.skills.fishing;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
|
||||||
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;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public final class Fishing {
|
|
||||||
|
|
||||||
public static Fishing instance;
|
|
||||||
private final long fishingRodCastCdMilliseconds;
|
|
||||||
private final int overfishLimit;
|
|
||||||
private final double boundingBoxSize;
|
|
||||||
private HashMap<Material, List<Enchantment>> enchantableCache = new HashMap<>();
|
|
||||||
private HashMap<Material, Integer> fishingXpRewardMap;
|
|
||||||
private Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
|
|
||||||
private Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
|
|
||||||
|
|
||||||
public Fishing() {
|
|
||||||
overfishLimit = pluginRef.getConfigManager().getConfigExploitPrevention().getOverfishingLimit() + 1;
|
|
||||||
fishingRodCastCdMilliseconds = pluginRef.getConfigManager().getConfigExploitPrevention().getFishingRodSpamMilliseconds();
|
|
||||||
boundingBoxSize = pluginRef.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize();
|
|
||||||
initFishingXPRewardMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Fishing getInstance() {
|
|
||||||
if (instance == null)
|
|
||||||
instance = new Fishing();
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inits the Fishing Catch -> XP Reward map
|
|
||||||
*/
|
|
||||||
private void initFishingXPRewardMap() {
|
|
||||||
fishingXpRewardMap = new HashMap<>();
|
|
||||||
HashMap<String, Integer> nameRegisterMap = pluginRef.getConfigManager().getConfigExperience().getFishingXPMap();
|
|
||||||
|
|
||||||
for (String qualifiedName : nameRegisterMap.keySet()) {
|
|
||||||
Material material = Material.matchMaterial(qualifiedName);
|
|
||||||
|
|
||||||
if (material == null) {
|
|
||||||
pluginRef.getLogger().info("Unable to match qualified name to item for fishing xp map: " + qualifiedName);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
fishingXpRewardMap.putIfAbsent(material, nameRegisterMap.get(qualifiedName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the possible drops of an entity
|
|
||||||
*
|
|
||||||
* @param target Targeted entity
|
|
||||||
* @return possibleDrops List of ItemStack that can be dropped
|
|
||||||
*/
|
|
||||||
public List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
|
||||||
if (FishingTreasureConfig.getInstance().shakeMap.containsKey(target.getType()))
|
|
||||||
return FishingTreasureConfig.getInstance().shakeMap.get(target.getType());
|
|
||||||
|
|
||||||
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<ShakeTreasure> 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<Material, List<Enchantment>> getEnchantableCache() {
|
|
||||||
return enchantableCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Material, Integer> getFishingXpRewardMap() {
|
|
||||||
return fishingXpRewardMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Biome> getMasterAnglerBiomes() {
|
|
||||||
return masterAnglerBiomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Biome> getIceFishingBiomes() {
|
|
||||||
return iceFishingBiomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFishXPValue(Material material) {
|
|
||||||
return fishingXpRewardMap.get(material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getFishingRodCastCdMilliseconds() {
|
|
||||||
return fishingRodCastCdMilliseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOverfishLimit() {
|
|
||||||
return overfishLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getBoundingBoxSize() {
|
|
||||||
return boundingBoxSize;
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,7 @@ 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.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.datatypes.treasure.Rarity;
|
||||||
@ -57,9 +58,11 @@ public class FishingManager extends SkillManager {
|
|||||||
private Location hookLocation;
|
private Location hookLocation;
|
||||||
private int fishCaughtCounter;
|
private int fishCaughtCounter;
|
||||||
private int overFishCount;
|
private int overFishCount;
|
||||||
|
private FishingBehaviour fishingBehaviour;
|
||||||
|
|
||||||
public FishingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
|
public FishingManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
|
||||||
super(pluginRef, mcMMOPlayer, PrimarySkillType.FISHING);
|
super(pluginRef, mcMMOPlayer, PrimarySkillType.FISHING);
|
||||||
|
fishingBehaviour = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getFishingBehaviour();
|
||||||
|
|
||||||
fishCaughtCounter = 1;
|
fishCaughtCounter = 1;
|
||||||
}
|
}
|
||||||
@ -78,7 +81,7 @@ public class FishingManager extends SkillManager {
|
|||||||
if (currentTime > fishHookSpawnTimestamp + 1000)
|
if (currentTime > fishHookSpawnTimestamp + 1000)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (currentTime < fishingRodCastTimestamp + Fishing.getInstance().getFishingRodCastCdMilliseconds()) {
|
if (currentTime < fishingRodCastTimestamp + fishingBehaviour.getFishingRodCastCdMilliseconds()) {
|
||||||
getPlayer().setFoodLevel(Math.max(getPlayer().getFoodLevel() - 1, 0));
|
getPlayer().setFoodLevel(Math.max(getPlayer().getFoodLevel() - 1, 0));
|
||||||
getPlayer().getInventory().getItemInMainHand().setDurability((short) (getPlayer().getInventory().getItemInMainHand().getDurability() + 5));
|
getPlayer().getInventory().getItemInMainHand().setDurability((short) (getPlayer().getInventory().getItemInMainHand().getDurability() + 5));
|
||||||
getPlayer().updateInventory();
|
getPlayer().updateInventory();
|
||||||
@ -123,7 +126,7 @@ public class FishingManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
int overfishLimit = Fishing.getInstance().getOverfishLimit();
|
int overfishLimit = fishingBehaviour.getOverfishLimit();
|
||||||
|
|
||||||
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
|
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
|
||||||
|
|
||||||
@ -159,7 +162,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BoundingBox makeBoundingBox(Vector centerOfCastVector) {
|
public BoundingBox makeBoundingBox(Vector centerOfCastVector) {
|
||||||
double boundingBoxSize = Fishing.getInstance().getBoundingBoxSize();
|
double boundingBoxSize = fishingBehaviour.getBoundingBoxSize();
|
||||||
return BoundingBox.of(centerOfCastVector, boundingBoxSize, boundingBoxSize, boundingBoxSize);
|
return BoundingBox.of(centerOfCastVector, boundingBoxSize, boundingBoxSize, boundingBoxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +180,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure this is a body of water, not just a block of ice.
|
// Make sure this is a body of water, not just a block of ice.
|
||||||
if (!Fishing.getInstance().getIceFishingBiomes().contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.WATER)) {
|
if (!fishingBehaviour.getIceFishingBiomes().contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.WATER)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +254,7 @@ public class FishingManager extends SkillManager {
|
|||||||
|
|
||||||
hookLocation = location;
|
hookLocation = location;
|
||||||
|
|
||||||
if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) {
|
if (fishingBehaviour.getMasterAnglerBiomes().contains(location.getBlock().getBiome())) {
|
||||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +277,7 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param fishingCatch The {@link Item} initially caught
|
* @param fishingCatch The {@link Item} initially caught
|
||||||
*/
|
*/
|
||||||
public void handleFishing(Item fishingCatch) {
|
public void handleFishing(Item fishingCatch) {
|
||||||
int fishXp = Fishing.getInstance().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;
|
||||||
@ -349,13 +352,13 @@ public class FishingManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
public void shakeCheck(LivingEntity target) {
|
public void shakeCheck(LivingEntity target) {
|
||||||
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) {
|
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getShakeChance(), getPlayer(), SubSkillType.FISHING_SHAKE))) {
|
||||||
List<ShakeTreasure> possibleDrops = Fishing.getInstance().findPossibleDrops(target);
|
List<ShakeTreasure> possibleDrops = fishingBehaviour.findPossibleDrops(target);
|
||||||
|
|
||||||
if (possibleDrops == null || possibleDrops.isEmpty()) {
|
if (possibleDrops == null || possibleDrops.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack drop = Fishing.getInstance().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) {
|
||||||
@ -565,8 +568,8 @@ public class FishingManager extends SkillManager {
|
|||||||
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {
|
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {
|
||||||
Material dropType = treasureDrop.getType();
|
Material dropType = treasureDrop.getType();
|
||||||
|
|
||||||
if (Fishing.getInstance().getEnchantableCache().containsKey(dropType)) {
|
if (fishingBehaviour.getEnchantableCache().containsKey(dropType)) {
|
||||||
return Fishing.getInstance().getEnchantableCache().get(dropType);
|
return fishingBehaviour.getEnchantableCache().get(dropType);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Enchantment> possibleEnchantments = new ArrayList<>();
|
List<Enchantment> possibleEnchantments = new ArrayList<>();
|
||||||
@ -577,7 +580,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Fishing.getInstance().getEnchantableCache().put(dropType, possibleEnchantments);
|
fishingBehaviour.getEnchantableCache().put(dropType, possibleEnchantments);
|
||||||
return possibleEnchantments;
|
return possibleEnchantments;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,8 +22,6 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
|
|||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.data.Ageable;
|
import org.bukkit.block.data.Ageable;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -31,7 +29,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HerbalismManager extends SkillManager {
|
public class HerbalismManager extends SkillManager {
|
||||||
@ -40,6 +37,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
|
|
||||||
public HerbalismManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
|
public HerbalismManager(mcMMO pluginRef, McMMOPlayer mcMMOPlayer) {
|
||||||
super(pluginRef, mcMMOPlayer, PrimarySkillType.HERBALISM);
|
super(pluginRef, mcMMOPlayer, PrimarySkillType.HERBALISM);
|
||||||
|
herbalismBehaviour = pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getHerbalismBehaviour();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBlockCheck() {
|
public boolean canBlockCheck() {
|
||||||
@ -120,7 +118,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
playerInventory.removeItem(seed);
|
playerInventory.removeItem(seed);
|
||||||
player.updateInventory(); // Needed until replacement available
|
player.updateInventory(); // Needed until replacement available
|
||||||
|
|
||||||
return convertGreenTerraBlocks(blockState);
|
return herbalismBehaviour.convertGreenTerraBlocks(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,9 +156,9 @@ public class HerbalismManager extends SkillManager {
|
|||||||
if (!oneBlockPlant) {
|
if (!oneBlockPlant) {
|
||||||
//Kelp is actually two blocks mixed together
|
//Kelp is actually two blocks mixed together
|
||||||
if (material == Material.KELP_PLANT || material == Material.KELP) {
|
if (material == Material.KELP_PLANT || material == Material.KELP) {
|
||||||
amount = countAndMarkDoubleDropsKelp(blockState, greenTerra, this);
|
amount = herbalismBehaviour.countAndMarkDoubleDropsKelp(blockState, greenTerra, this);
|
||||||
} else {
|
} else {
|
||||||
amount = countAndMarkDoubleDropsMultiBlockPlant(blockState, greenTerra, this);
|
amount = herbalismBehaviour.countAndMarkDoubleDropsMultiBlockPlant(blockState, greenTerra, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp *= amount;
|
xp *= amount;
|
||||||
@ -204,7 +202,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertGreenTerraBlocks(blockState);
|
return herbalismBehaviour.convertGreenTerraBlocks(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,7 +273,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertShroomThumb(blockState);
|
return herbalismBehaviour.convertShroomThumb(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user