From 2170c6de24f205431c953784d74bd9cbf90d2df2 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 10 Apr 2019 03:32:49 -0700 Subject: [PATCH] Setup Fishing XP Methods --- .../config/experience/ExperienceConfig.java | 10 ----- .../hocon/experience/ConfigExperience.java | 12 ++++++ .../experience/ConfigExperienceArchery.java | 12 ++++++ .../experience/ConfigExperienceFishing.java | 28 +++++++++++++ .../gmail/nossr50/skills/archery/Archery.java | 39 +++++++++++++++---- .../skills/archery/ArcheryManager.java | 4 +- 6 files changed, 86 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index 832a7f738..667cc95bb 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -160,11 +160,6 @@ public class ExperienceConfig extends ConfigValidated { /* * XP SETTINGS */ - /* Archery */ - if (getArcheryDistanceMultiplier() < 0) { - reason.add(EXPERIENCE + "." + ARCHERY + "." + DISTANCE + MULTIPLIER + " should be at least 0!"); - } - /* Combat XP Multipliers */ if (getAnimalsXP() < 0) { reason.add(EXPERIENCE + "." + COMBAT + "." + MULTIPLIER + "." + ANIMALS + " should be at least 0!"); @@ -379,11 +374,6 @@ public class ExperienceConfig extends ConfigValidated { return BarStyle.SOLID; } - /* Archery */ - public double getArcheryDistanceMultiplier() { - return getDoubleValue(EXPERIENCE, ARCHERY, DISTANCE + MULTIPLIER); - } - public int getFishingShakeXP() { return getIntValue(EXPERIENCE, FISHING, SHAKE); } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java index 9d3337983..fb1b122b5 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java @@ -143,4 +143,16 @@ public class ConfigExperience { public boolean isPvpXPEnabled() { return experienceCombat.isPvpXPEnabled(); } + + public double getDistanceMultiplier() { + return experienceArchery.getDistanceMultiplier(); + } + + public HashMap getFishingXPMap() { + return experienceFishing.getFishingXPMap(); + } + + public int getShakeXP() { + return experienceFishing.getShakeXP(); + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceArchery.java b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceArchery.java index ee77a6f96..d8bce6619 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceArchery.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceArchery.java @@ -1,10 +1,22 @@ package com.gmail.nossr50.config.hocon.experience; +import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigExperienceArchery { + public static final double DISTANCE_MULTIPLIER_DEFAULT = 0.025D; + @Setting(value = "Distance-Multiplier", comment = "The distance multiplier is multiplied against the distance an " + + "arrow travels before hitting its target to determine final XP values awarded." + + "\nThe maximum distance bonus is 50, so expect this multiplier to peak at being multiplied against 50." + + "\nDistance is in blocks traveled." + + "\nThis value is added on to normal XP gains from damage for Archery." + + "\nDefault value: "+DISTANCE_MULTIPLIER_DEFAULT) + private double distanceMultiplier = DISTANCE_MULTIPLIER_DEFAULT; + public double getDistanceMultiplier() { + return distanceMultiplier; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceFishing.java b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceFishing.java index 734274db3..e548e10c6 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceFishing.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperienceFishing.java @@ -1,8 +1,36 @@ package com.gmail.nossr50.config.hocon.experience; +import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; +import org.bukkit.Material; + +import java.util.HashMap; @ConfigSerializable public class ConfigExperienceFishing { + private final static HashMap FISHING_DEFAULT_XP_MAP; + public static final int SHAKE_XP_DEFAULT = 50; + static { + FISHING_DEFAULT_XP_MAP = new HashMap<>(); + + FISHING_DEFAULT_XP_MAP.put(Material.COD.getKey().toString(), 100); + FISHING_DEFAULT_XP_MAP.put(Material.SALMON.getKey().toString(), 600); + FISHING_DEFAULT_XP_MAP.put(Material.TROPICAL_FISH.getKey().toString(), 10000); + FISHING_DEFAULT_XP_MAP.put(Material.PUFFERFISH.getKey().toString(), 2400); + } + + @Setting(value = "Fishing-Experience-Values", comment = "Experience values for Fishing.") + HashMap fishingXPMap = FISHING_DEFAULT_XP_MAP; + + @Setting(value = "Shake", comment = "XP Granted when shaking a mob") + private int shakeXP = SHAKE_XP_DEFAULT; + + public HashMap getFishingXPMap() { + return fishingXPMap; + } + + public int getShakeXP() { + return shakeXP; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 1c1adb380..1daa49d8e 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -1,8 +1,8 @@ package com.gmail.nossr50.skills.archery; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.RankUtils; import org.bukkit.Material; @@ -17,21 +17,30 @@ import java.util.List; public class Archery { private static List trackedEntities; - public static double skillShotMaxBonusDamage; + private static double skillShotDamageCap; - public static double dazeBonusDamage; + private static double dazeBonusDamage; - public static double DISTANCE_XP_MULTIPLIER; + private static double distanceXpMultiplier; + + private static Archery archery; + + public static Archery getInstance() { + if(archery == null) + archery = new Archery(); + + return archery; + } public Archery() { List trackedEntities = new ArrayList<>(); - skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax(); + skillShotDamageCap = AdvancedConfig.getInstance().getSkillShotDamageMax(); dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage(); - DISTANCE_XP_MULTIPLIER = ExperienceConfig.getInstance().getArcheryDistanceMultiplier(); + distanceXpMultiplier = mcMMO.getConfigManager().getConfigExperience().getDistanceMultiplier(); } protected static void incrementTrackerValue(LivingEntity livingEntity) { @@ -77,10 +86,26 @@ public class Archery { { double damageBonusPercent = getDamageBonusPercent(player); double newDamage = oldDamage + (oldDamage * damageBonusPercent); - return Math.min(newDamage, Archery.skillShotMaxBonusDamage); + return Math.min(newDamage, Archery.skillShotDamageCap); } public static double getDamageBonusPercent(Player player) { return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * AdvancedConfig.getInstance().getSkillShotRankDamageMultiplier()) / 100.0D; } + + public List getTrackedEntities() { + return trackedEntities; + } + + public double getSkillShotDamageCap() { + return skillShotDamageCap; + } + + public double getDazeBonusDamage() { + return dazeBonusDamage; + } + + public double getDistanceXpMultiplier() { + return distanceXpMultiplier; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 32e38190b..d09146639 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -60,7 +60,7 @@ public class ArcheryManager extends SkillManager { return 1; } - return 1 + Math.min(firedLocation.distance(targetLocation), 50) * Archery.DISTANCE_XP_MULTIPLIER; + return 1 + Math.min(firedLocation.distance(targetLocation), 50) * Archery.getInstance().getDistanceXpMultiplier(); } /** @@ -98,7 +98,7 @@ public class ArcheryManager extends SkillManager { NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.TargetDazed"); } - return Archery.dazeBonusDamage; + return Archery.getInstance().getDazeBonusDamage(); } /**