mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Fixed errors with block-based skill experience (#3506)
* Updated configs * [WIP] Replacing MaterialData with Blockdata * Fixed most block based experience gain * Fixed most block based experience gain & updated wooden_tools * Removed debug prints
This commit is contained in:

committed by
t00thpick1

parent
210b418e44
commit
ee324c77a9
@ -134,7 +134,7 @@ public final class BlockUtils {
|
||||
* @return true if the block is an ore, false otherwise
|
||||
*/
|
||||
public static boolean isOre(BlockState blockState) {
|
||||
return MaterialUtils.isOre(blockState.getData());
|
||||
return MaterialUtils.isOre(blockState.getBlockData());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,8 +170,9 @@ public final class BlockUtils {
|
||||
* @return true if the block should affected by Green Terra, false otherwise
|
||||
*/
|
||||
public static boolean affectedByGreenTerra(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getBlockData())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
||||
}
|
||||
@ -185,7 +186,7 @@ public final class BlockUtils {
|
||||
* otherwise
|
||||
*/
|
||||
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.MINING, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.MINING, blockState.getBlockData()))
|
||||
return true;
|
||||
|
||||
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
|
||||
@ -200,7 +201,7 @@ public final class BlockUtils {
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.EXCAVATION, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.EXCAVATION, blockState.getBlockData()))
|
||||
return true;
|
||||
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
||||
}
|
||||
@ -213,7 +214,7 @@ public final class BlockUtils {
|
||||
* @return true if the block is a log, false otherwise
|
||||
*/
|
||||
public static boolean isLog(BlockState blockState) {
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.WOODCUTTING, blockState.getData()))
|
||||
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.WOODCUTTING, blockState.getBlockData()))
|
||||
return true;
|
||||
return mcMMO.getModManager().isCustomLog(blockState);
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isSmeltable(ItemStack item) {
|
||||
return item != null && MaterialUtils.isOre(item.getData());
|
||||
return item != null && MaterialUtils.isOre(item.getType().createBlockData());
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack item) {
|
||||
@ -520,7 +520,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) {
|
||||
if (recipe instanceof FurnaceRecipe && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getData())) {
|
||||
if (recipe instanceof FurnaceRecipe && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType().createBlockData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -681,18 +681,6 @@ public final class ItemUtils {
|
||||
case JUNGLE_LOG:
|
||||
case OAK_LOG:
|
||||
case SPRUCE_LOG:
|
||||
case OAK_WOOD:
|
||||
case ACACIA_WOOD:
|
||||
case BIRCH_WOOD:
|
||||
case DARK_OAK_WOOD:
|
||||
case STRIPPED_ACACIA_WOOD:
|
||||
case JUNGLE_WOOD:
|
||||
case SPRUCE_WOOD:
|
||||
case STRIPPED_BIRCH_WOOD:
|
||||
case STRIPPED_DARK_OAK_WOOD:
|
||||
case STRIPPED_JUNGLE_WOOD:
|
||||
case STRIPPED_OAK_WOOD:
|
||||
case STRIPPED_SPRUCE_WOOD:
|
||||
case STRIPPED_ACACIA_LOG:
|
||||
case STRIPPED_BIRCH_LOG:
|
||||
case STRIPPED_DARK_OAK_LOG:
|
||||
|
@ -1,13 +1,13 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public final class MaterialUtils {
|
||||
private MaterialUtils() {}
|
||||
|
||||
protected static boolean isOre(MaterialData data) {
|
||||
switch (data.getItemType()) {
|
||||
protected static boolean isOre(BlockData data) {
|
||||
switch (data.getMaterial()) {
|
||||
case COAL_ORE:
|
||||
case DIAMOND_ORE:
|
||||
case NETHER_QUARTZ_ORE:
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -33,14 +33,14 @@ public class ModManager {
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
// Block Mods
|
||||
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customOres = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
||||
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
||||
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
||||
private List<BlockData> customExcavationBlocks = new ArrayList<BlockData>();
|
||||
private List<BlockData> customHerbalismBlocks = new ArrayList<BlockData>();
|
||||
private List<BlockData> customMiningBlocks = new ArrayList<BlockData>();
|
||||
private List<BlockData> customOres = new ArrayList<BlockData>();
|
||||
private List<BlockData> customLogs = new ArrayList<BlockData>();
|
||||
private List<BlockData> customLeaves = new ArrayList<BlockData>();
|
||||
private List<BlockData> customAbilityBlocks = new ArrayList<BlockData>();
|
||||
private HashMap<BlockData, CustomBlock> customBlockMap = new HashMap<BlockData, CustomBlock>();
|
||||
|
||||
// Entity Mods
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
@ -130,7 +130,7 @@ public class ModManager {
|
||||
return Config.getInstance().getToolModsEnabled() && customSwords.contains(material);
|
||||
}
|
||||
|
||||
public boolean isCustomOre(MaterialData data) {
|
||||
public boolean isCustomOre(BlockData data) {
|
||||
return Config.getInstance().getBlockModsEnabled() && customOres.contains(data);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ public class ModManager {
|
||||
return customBlockMap.get(state.getData());
|
||||
}
|
||||
|
||||
public CustomBlock getBlock(MaterialData data) {
|
||||
public CustomBlock getBlock(BlockData data) {
|
||||
return customBlockMap.get(data);
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,9 @@ import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
@ -37,16 +38,32 @@ public class StringUtils {
|
||||
return createPrettyEnumString(species.toString());
|
||||
}
|
||||
|
||||
public static String getWildcardConfigMaterialDataString(MaterialData data) {
|
||||
return StringUtils.getPrettyItemString(data.getItemType()).replace(" ", "_") + "|*";
|
||||
public static String getWildcardConfigBlockDataString(BlockData data) {
|
||||
return StringUtils.getPrettyItemString(data.getMaterial()).replace(" ", "_") + "|*";
|
||||
}
|
||||
|
||||
public static String getFriendlyConfigMaterialDataString(MaterialData data) {
|
||||
return getPrettyItemString(data.getItemType()).replace(" ", "_");
|
||||
public static String getFriendlyConfigBlockDataString(BlockData data) {
|
||||
switch(data.getMaterial()){
|
||||
case COCOA:
|
||||
case WHEAT:
|
||||
case BEETROOTS:
|
||||
case CARROTS:
|
||||
case POTATOES:
|
||||
case NETHER_WART_BLOCK: {
|
||||
if (data instanceof Ageable) {
|
||||
Ageable ageData = (Ageable) data;
|
||||
if (ageData.getAge() == ageData.getMaximumAge()) {
|
||||
return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ripe";
|
||||
}
|
||||
}
|
||||
return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ungrown";
|
||||
}
|
||||
}
|
||||
return getPrettyItemString(data.getMaterial()).replace(" ", "_");
|
||||
}
|
||||
|
||||
public static String getExplicitConfigMaterialDataString(MaterialData data) {
|
||||
return StringUtils.getPrettyItemString(data.getItemType()).replace(" ", "_") + "|" + data.getData();
|
||||
public static String getExplicitConfigBlockDataString(BlockData data) {
|
||||
return StringUtils.getPrettyItemString(data.getMaterial()).replace(" ", "_");
|
||||
}
|
||||
|
||||
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
|
||||
|
@ -25,7 +25,7 @@ import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@ -255,7 +255,7 @@ public class SkillUtils {
|
||||
return Material.COBBLESTONE;
|
||||
}
|
||||
else if (ItemUtils.isWoodTool(inHand)) {
|
||||
return Material.OAK_PLANKS;
|
||||
return Material.OAK_WOOD;
|
||||
}
|
||||
else if (ItemUtils.isLeatherArmor(inHand)) {
|
||||
return Material.LEATHER;
|
||||
@ -278,7 +278,7 @@ public class SkillUtils {
|
||||
item.setDurability((short) 0);
|
||||
|
||||
int quantity = 0;
|
||||
MaterialData repairData = repairMaterial != null ? new MaterialData(repairMaterial, repairMetadata) : null;
|
||||
BlockData repairData = repairMaterial != null ? repairMaterial.createBlockData() : null;
|
||||
List<Recipe> recipes = mcMMO.p.getServer().getRecipesFor(item);
|
||||
|
||||
if (recipes.isEmpty()) {
|
||||
@ -289,14 +289,14 @@ public class SkillUtils {
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedRecipe) {
|
||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
|
||||
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairData))) {
|
||||
quantity += ingredient.getAmount();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user