Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into configurable

This commit is contained in:
nossr50 2019-06-12 10:40:04 -07:00
commit 473e4586c9
5 changed files with 60 additions and 2 deletions

View File

@ -164,6 +164,10 @@ Version 2.2.0
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
Added API method to check if a skill was being level capped Added API method to check if a skill was being level capped
Added 'UndefinedSkillBehaviour' for trying to use a method that has no behaviour defined for the provided skill Added 'UndefinedSkillBehaviour' for trying to use a method that has no behaviour defined for the provided skill
Version 2.1.78
Shovels no longer take more than 1 diamond to repair
Tools with the unbreaking enchantment no longer take extra damage from ability usage, they are still subject to the normal durability damage from breaking blocks though.
Version 2.1.77 Version 2.1.77
Added minimum quantity back to Repair config Added minimum quantity back to Repair config

View File

@ -57,6 +57,10 @@ public class RepairableSerializer implements TypeSerializer<Repairable> {
Material repairItem = (Material) getEnum(repairConstant, TypeToken.of(Material.class));*/ Material repairItem = (Material) getEnum(repairConstant, TypeToken.of(Material.class));*/
int minimumQuantity = value.getNode(MINIMUM_QUANTITY_USED_TO_REPAIR).getValue(TypeToken.of(Integer.class)); int minimumQuantity = value.getNode(MINIMUM_QUANTITY_USED_TO_REPAIR).getValue(TypeToken.of(Integer.class));
if(minimumQuantity == 0)
minimumQuantity = -1;
int minimumLevel = value.getNode(OVERRIDE_LEVEL_REQUIREMENT).getValue(TypeToken.of(Integer.class)); int minimumLevel = value.getNode(OVERRIDE_LEVEL_REQUIREMENT).getValue(TypeToken.of(Integer.class));
double xpMultiplier = value.getNode(XP_MULTIPLIER).getValue(TypeToken.of(Double.class)); double xpMultiplier = value.getNode(XP_MULTIPLIER).getValue(TypeToken.of(Double.class));

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.repair.repairables;
import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory;
import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.ItemType;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material; import org.bukkit.Material;
import java.util.Collections; import java.util.Collections;
@ -61,7 +62,10 @@ public class Repairable {
} }
public int getMinimumQuantity() { public int getMinimumQuantity() {
return minimumQuantity; if(minimumQuantity == -1)
return Math.max(SkillUtils.getRepairAndSalvageQuantities(itemMaterial, repairMaterials), 1);
else
return minimumQuantity;
} }
public short getMaximumDurability() { public short getMaximumDurability() {

View File

@ -8,6 +8,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
@ -136,6 +137,11 @@ public final class Woodcutting {
* @return True if the tool can sustain the durability loss * @return True if the tool can sustain the durability loss
*/ */
protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) { protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
if(inHand.getItemMeta().getEnchants().get(Enchantment.DURABILITY) >= 1) {
return true;
}
short durabilityLoss = 0; short durabilityLoss = 0;
Material type = inHand.getType(); Material type = inHand.getType();

View File

@ -228,7 +228,7 @@ public class SkillUtils {
* @param maxDamageModifier the amount to adjust the max damage by * @param maxDamageModifier the amount to adjust the max damage by
*/ */
public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) { public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) {
if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { if (itemStack.getEnchantments().get(Enchantment.DURABILITY) != null && itemStack.getEnchantments().get(Enchantment.DURABILITY) >= 1) {
return; return;
} }
@ -303,4 +303,44 @@ public class SkillUtils {
return quantity; return quantity;
} }
public static int getRepairAndSalvageQuantities(Material itemMaterial, List<Material> recipeMaterials) {
int quantity = 0;
for(Iterator<? extends Recipe> recipeIterator = Bukkit.getServer().recipeIterator(); recipeIterator.hasNext();) {
Recipe bukkitRecipe = recipeIterator.next();
if(bukkitRecipe.getResult().getType() != itemMaterial)
continue;
boolean matchedIngredient = false;
for(Material recipeMaterial : recipeMaterials) {
if(matchedIngredient)
break;
if(bukkitRecipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) bukkitRecipe).getIngredientList()) {
if (ingredient != null
&& (recipeMaterial == null || ingredient.getType() == recipeMaterial)
&& (ingredient.getType() == recipeMaterial)) {
quantity += ingredient.getAmount();
matchedIngredient = true;
}
}
} else if(bukkitRecipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) bukkitRecipe).getIngredientMap().values()) {
if (ingredient != null
&& (recipeMaterial == null || ingredient.getType() == recipeMaterial)
&& (ingredient.getType() == recipeMaterial)) {
quantity += ingredient.getAmount();
matchedIngredient = true;
}
}
}
}
}
return quantity;
}
} }