mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Fishing now actually grants XP for caught fish (values in the config did nothing before... lol )
This commit is contained in:
parent
1f734582d4
commit
856e6f0447
10
pom.xml
10
pom.xml
@ -172,8 +172,18 @@
|
|||||||
<id>sk89q-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>http://maven.sk89q.com/repo/</url>
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jetbrains</id>
|
||||||
|
<url>https://mvnrepository.com/artifact/org.jetbrains/annotations</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>17.0.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe</groupId>
|
<groupId>com.typesafe</groupId>
|
||||||
<artifactId>config</artifactId>
|
<artifactId>config</artifactId>
|
||||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.config.ConfigValidated;
|
|||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory;
|
import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.subskills.acrobatics;
|
package com.gmail.nossr50.datatypes.skills.subskills.acrobatics;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.LimitedSizeList;
|
import com.gmail.nossr50.datatypes.LimitedSizeList;
|
||||||
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.interactions.NotificationType;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.MainConfig;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public final class Acrobatics {
|
public final class Acrobatics {
|
||||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
|||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LightningStrike;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class AcrobaticsManager extends SkillManager {
|
public class AcrobaticsManager extends SkillManager {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.alchemy;
|
package com.gmail.nossr50.skills.alchemy;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||||
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.fishing;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Misc;
|
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;
|
||||||
@ -16,16 +17,45 @@ import java.util.Set;
|
|||||||
|
|
||||||
public final class Fishing {
|
public final class Fishing {
|
||||||
|
|
||||||
protected static final HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<>();
|
private static HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<>();
|
||||||
|
private HashMap<Material, Integer> fishingXpRewardMap;
|
||||||
|
private static Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
|
||||||
|
private static Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
|
||||||
|
|
||||||
/*public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
public static Fishing instance;
|
||||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
|
||||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;*/
|
|
||||||
|
|
||||||
public static Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
|
public static Fishing getInstance() {
|
||||||
public static Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
|
if(instance == null)
|
||||||
|
instance = new Fishing();
|
||||||
|
|
||||||
private Fishing() {}
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Fishing() {
|
||||||
|
initFishingXPRewardMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the Fishing Catch -> XP Reward map
|
||||||
|
*/
|
||||||
|
private void initFishingXPRewardMap()
|
||||||
|
{
|
||||||
|
fishingXpRewardMap = new HashMap<>();
|
||||||
|
HashMap<String, Integer> nameRegisterMap = mcMMO.getConfigManager().getConfigExperience().getFishingXPMap();
|
||||||
|
|
||||||
|
for(String qualifiedName : nameRegisterMap.keySet())
|
||||||
|
{
|
||||||
|
Material material = Material.matchMaterial(qualifiedName);
|
||||||
|
|
||||||
|
if(material == null)
|
||||||
|
{
|
||||||
|
mcMMO.p.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
|
* Finds the possible drops of an entity
|
||||||
@ -34,7 +64,7 @@ public final class Fishing {
|
|||||||
* Targeted entity
|
* Targeted entity
|
||||||
* @return possibleDrops List of ItemStack that can be dropped
|
* @return possibleDrops List of ItemStack that can be dropped
|
||||||
*/
|
*/
|
||||||
protected static 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());
|
||||||
|
|
||||||
@ -48,7 +78,7 @@ public final class Fishing {
|
|||||||
* List of ItemStack that can be dropped
|
* List of ItemStack that can be dropped
|
||||||
* @return Chosen ItemStack
|
* @return Chosen ItemStack
|
||||||
*/
|
*/
|
||||||
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
public ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
||||||
int dropProbability = Misc.getRandom().nextInt(100);
|
int dropProbability = Misc.getRandom().nextInt(100);
|
||||||
double cumulatedProbability = 0;
|
double cumulatedProbability = 0;
|
||||||
|
|
||||||
@ -62,4 +92,26 @@ public final class Fishing {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<Material, List<Enchantment>> getEnchantableCache() {
|
||||||
|
return ENCHANTABLE_CACHE;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,21 +48,22 @@ public class FishingManager extends SkillManager {
|
|||||||
public final long FISHING_ROD_CAST_CD_MILLISECONDS;
|
public final long FISHING_ROD_CAST_CD_MILLISECONDS;
|
||||||
public final int OVERFISH_LIMIT;
|
public final int OVERFISH_LIMIT;
|
||||||
|
|
||||||
private long fishingRodCastTimestamp = 0L;
|
private long fishingRodCastTimestamp;
|
||||||
private long fishHookSpawnTimestamp = 0L;
|
private long fishHookSpawnTimestamp;
|
||||||
private long lastWarned = 0L;
|
private long lastWarned;
|
||||||
private long lastWarnedExhaust = 0L;
|
private long lastWarnedExhaust;
|
||||||
private BoundingBox lastFishingBoundingBox;
|
private BoundingBox lastFishingBoundingBox;
|
||||||
private Location hookLocation;
|
private Location hookLocation;
|
||||||
private int fishCaughtCounter = 1;
|
private int fishCaughtCounter;
|
||||||
private final float boundingBoxSize;
|
private final float boundingBoxSize;
|
||||||
private int overFishCount = 0;
|
private int overFishCount;
|
||||||
|
|
||||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
super(mcMMOPlayer, PrimarySkillType.FISHING);
|
super(mcMMOPlayer, PrimarySkillType.FISHING);
|
||||||
OVERFISH_LIMIT = mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().getOverfishingLimit() + 1;
|
OVERFISH_LIMIT = mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().getOverfishingLimit() + 1;
|
||||||
FISHING_ROD_CAST_CD_MILLISECONDS = mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().getFishingRodSpamMilliseconds();
|
FISHING_ROD_CAST_CD_MILLISECONDS = mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().getFishingRodSpamMilliseconds();
|
||||||
boundingBoxSize = mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().getOverFishingAreaSize();
|
boundingBoxSize = mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().getOverFishingAreaSize();
|
||||||
|
fishCaughtCounter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canShake(Entity target) {
|
public boolean canShake(Entity target) {
|
||||||
@ -186,7 +187,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.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.WATER)) {
|
if (!Fishing.getInstance().getIceFishingBiomes().contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.WATER)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +262,7 @@ public class FishingManager extends SkillManager {
|
|||||||
|
|
||||||
hookLocation = location;
|
hookLocation = location;
|
||||||
|
|
||||||
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
|
if (Fishing.getInstance().getMasterAnglerBiomes().contains(location.getBlock().getBiome())) {
|
||||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,6 +330,8 @@ public class FishingManager extends SkillManager {
|
|||||||
|
|
||||||
if (mcMMO.getConfigManager().getConfigFishing().isAlwaysCatchFish()) {
|
if (mcMMO.getConfigManager().getConfigFishing().isAlwaysCatchFish()) {
|
||||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||||
|
//Add XP from Fish
|
||||||
|
fishXp+=Fishing.getInstance().getFishXPValue(fishingCatch.getItemStack().getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
fishingCatch.setItemStack(treasureDrop);
|
fishingCatch.setItemStack(treasureDrop);
|
||||||
@ -360,13 +363,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.findPossibleDrops(target);
|
List<ShakeTreasure> possibleDrops = Fishing.getInstance().findPossibleDrops(target);
|
||||||
|
|
||||||
if (possibleDrops == null || possibleDrops.isEmpty()) {
|
if (possibleDrops == null || possibleDrops.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack drop = Fishing.chooseDrop(possibleDrops);
|
ItemStack drop = Fishing.getInstance().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) {
|
||||||
@ -579,8 +582,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.ENCHANTABLE_CACHE.containsKey(dropType)) {
|
if (Fishing.getInstance().getEnchantableCache().containsKey(dropType)) {
|
||||||
return Fishing.ENCHANTABLE_CACHE.get(dropType);
|
return Fishing.getInstance().getEnchantableCache().get(dropType);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Enchantment> possibleEnchantments = new ArrayList<>();
|
List<Enchantment> possibleEnchantments = new ArrayList<>();
|
||||||
@ -591,7 +594,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Fishing.ENCHANTABLE_CACHE.put(dropType, possibleEnchantments);
|
Fishing.getInstance().getEnchantableCache().put(dropType, possibleEnchantments);
|
||||||
return possibleEnchantments;
|
return possibleEnchantments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user