Fix fishing in 1.13 (#3528)

* Fix fishing to use Material instead of BlockData (that was AIR)
This commit is contained in:
R4zorax 2018-08-03 02:27:15 +02:00 committed by t00thpick1
parent 7800e48f61
commit a39a77f89e
3 changed files with 31 additions and 8 deletions

View File

@ -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)
{

View File

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

View File

@ -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) {