From a39a77f89e9b3df854688efe4de40f99db4dcf09 Mon Sep 17 00:00:00 2001 From: R4zorax Date: Fri, 3 Aug 2018 02:27:15 +0200 Subject: [PATCH] Fix fishing in 1.13 (#3528) * Fix fishing to use Material instead of BlockData (that was AIR) --- .../config/experience/ExperienceConfig.java | 21 ++++++++++++++----- .../skills/fishing/FishingManager.java | 2 +- .../com/gmail/nossr50/util/StringUtils.java | 16 ++++++++++++-- 3 files changed, 31 insertions(+), 8 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 142485caa..32df534e2 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -3,15 +3,10 @@ package com.gmail.nossr50.config.experience; import java.util.ArrayList; import java.util.List; -import org.bukkit.GrassSpecies; import org.bukkit.Material; -import org.bukkit.TreeSpecies; import org.bukkit.entity.EntityType; -import org.bukkit.material.LongGrass; import org.bukkit.block.data.BlockData; -import org.bukkit.material.Tree; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AutoUpdateConfigLoader; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.skills.MaterialType; @@ -192,6 +187,22 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); } public boolean hasCombatXP(EntityType entity) {return config.contains("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); } + /* Materials */ + public int getXp(SkillType skill, Material data) + { + String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + "."; + String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data); + if (config.contains(explicitString)) + return config.getInt(explicitString); + String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data); + if (config.contains(friendlyString)) + return config.getInt(friendlyString); + String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data); + if (config.contains(wildcardString)) + return config.getInt(wildcardString); + return 0; + } + /* Materials */ public int getXp(SkillType skill, BlockData data) { diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index cdc97ca3a..40dafc6f2 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -279,7 +279,7 @@ public class FishingManager extends SkillManager { */ public void handleFishing(Item fishingCatch) { this.fishingCatch = fishingCatch; - int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getType().createBlockData()); + int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getType()); int treasureXp = 0; Player player = getPlayer(); FishingTreasure treasure = null; diff --git a/src/main/java/com/gmail/nossr50/util/StringUtils.java b/src/main/java/com/gmail/nossr50/util/StringUtils.java index bc656b926..e5f9f9d23 100644 --- a/src/main/java/com/gmail/nossr50/util/StringUtils.java +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -39,7 +39,11 @@ public class StringUtils { } public static String getWildcardConfigBlockDataString(BlockData data) { - return StringUtils.getPrettyItemString(data.getMaterial()).replace(" ", "_") + "|*"; + return getWildcardConfigMaterialString(data.getMaterial()); + } + + public static String getWildcardConfigMaterialString(Material data) { + return StringUtils.getPrettyItemString(data).replace(" ", "_") + "|*"; } public static String getFriendlyConfigBlockDataString(BlockData data) { @@ -62,8 +66,16 @@ public class StringUtils { return getPrettyItemString(data.getMaterial()).replace(" ", "_"); } + public static String getFriendlyConfigMaterialString(Material data) { + return getPrettyItemString(data).replace(" ", "_"); + } + public static String getExplicitConfigBlockDataString(BlockData data) { - return StringUtils.getPrettyItemString(data.getMaterial()).replace(" ", "_"); + return getExplicitConfigMaterialString(data.getMaterial()); + } + + public static String getExplicitConfigMaterialString(Material data) { + return StringUtils.getPrettyItemString(data).replace(" ", "_"); } public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {