mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Rework armor.yml to take item names instead of IDs in advance of 1.7 changes.
** YOU WILL NEED TO REDO YOUR armor.yml FILE **
This commit is contained in:
parent
933b6f278b
commit
792ecd6aad
@ -1,15 +1,15 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||||
|
|
||||||
@ -18,14 +18,11 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
|
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
|
|
||||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
public List<Material> customBoots = new ArrayList<Material>();
|
||||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
public List<Material> customChestplates = new ArrayList<Material>();
|
||||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
public List<Material> customHelmets = new ArrayList<Material>();
|
||||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
public List<Material> customLeggings = new ArrayList<Material>();
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
public List<Material> customArmor = new ArrayList<Material>();
|
||||||
|
|
||||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
|
||||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
|
||||||
|
|
||||||
public CustomArmorConfig() {
|
public CustomArmorConfig() {
|
||||||
super("ModConfigs", "armor.yml");
|
super("ModConfigs", "armor.yml");
|
||||||
@ -52,13 +49,13 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadArmor("Boots", customBootIDs);
|
loadArmor("Boots", customBoots);
|
||||||
loadArmor("Chestplates", customChestplateIDs);
|
loadArmor("Chestplates", customChestplates);
|
||||||
loadArmor("Helmets", customHelmetIDs);
|
loadArmor("Helmets", customHelmets);
|
||||||
loadArmor("Leggings", customLeggingIDs);
|
loadArmor("Leggings", customLeggings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadArmor(String armorType, List<Integer> idList) {
|
private void loadArmor(String armorType, List<Material> materialList) {
|
||||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||||
|
|
||||||
if (armorSection == null) {
|
if (armorSection == null) {
|
||||||
@ -68,35 +65,40 @@ public class CustomArmorConfig extends ConfigLoader {
|
|||||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||||
|
|
||||||
for (String armorName : armorConfigSet) {
|
for (String armorName : armorConfigSet) {
|
||||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
Material armorMaterial = Material.matchMaterial(armorName);
|
||||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
|
||||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
|
||||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
|
||||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
|
||||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
|
||||||
|
|
||||||
if (id == 0) {
|
if (armorMaterial == null) {
|
||||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
plugin.getLogger().warning("Invalid material name. This item will be skipped.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||||
|
Material repairMaterial = Material.matchMaterial(config.getString(armorType + "." + armorName + ".Repair_Material", ""));
|
||||||
|
|
||||||
|
if (repairMaterial == null) {
|
||||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||||
repairable = false;
|
repairable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomItem armor;
|
|
||||||
|
|
||||||
if (repairable) {
|
if (repairable) {
|
||||||
repairables.add(RepairableFactory.getRepairable(Material.getMaterial(id), Material.getMaterial(repairID), repairData, repairQuantity, durability));
|
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1);
|
||||||
|
int repairQuantity = Repair.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData);
|
||||||
|
|
||||||
|
if (repairQuantity == 0) {
|
||||||
|
repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Quantity", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
armor = new CustomItem(id, durability);
|
short durability = armorMaterial.getMaxDurability();
|
||||||
|
|
||||||
idList.add(id);
|
if (durability == 0) {
|
||||||
customIDs.add(id);
|
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
|
||||||
customArmorList.add(armor);
|
}
|
||||||
customArmor.put(id, armor);
|
|
||||||
|
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, durability));
|
||||||
|
}
|
||||||
|
|
||||||
|
materialList.add(armorMaterial);
|
||||||
|
customArmor.add(armorMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class CustomToolConfig extends ConfigLoader {
|
|||||||
repairables.add(RepairableFactory.getRepairable(Material.getMaterial(id), Material.getMaterial(repairID), repairData, repairQuantity, durability));
|
repairables.add(RepairableFactory.getRepairable(Material.getMaterial(id), Material.getMaterial(repairID), repairData, repairQuantity, durability));
|
||||||
}
|
}
|
||||||
|
|
||||||
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
|
tool = new CustomTool(tier, abilityEnabled, multiplier, id);
|
||||||
|
|
||||||
idList.add(id);
|
idList.add(id);
|
||||||
customIDs.add(id);
|
customIDs.add(id);
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
|
||||||
|
|
||||||
public class CustomItem {
|
|
||||||
protected int itemID;
|
|
||||||
protected short durability;
|
|
||||||
|
|
||||||
public CustomItem(int itemID, short durability) {
|
|
||||||
this.itemID = itemID;
|
|
||||||
this.durability = durability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemID() {
|
|
||||||
return itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemID(int itemID) {
|
|
||||||
this.itemID = itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getDurability() {
|
|
||||||
return durability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDurability(short durability) {
|
|
||||||
this.durability = durability;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,28 @@
|
|||||||
package com.gmail.nossr50.datatypes.mods;
|
package com.gmail.nossr50.datatypes.mods;
|
||||||
|
|
||||||
public class CustomTool extends CustomItem {
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public class CustomTool {
|
||||||
|
private Material material;
|
||||||
private double xpMultiplier;
|
private double xpMultiplier;
|
||||||
private boolean abilityEnabled;
|
private boolean abilityEnabled;
|
||||||
private int tier;
|
private int tier;
|
||||||
|
|
||||||
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
|
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, int itemID) {
|
||||||
super(itemID, durability);
|
this.material = Material.getMaterial(itemID);
|
||||||
this.xpMultiplier = xpMultiplier;
|
this.xpMultiplier = xpMultiplier;
|
||||||
this.abilityEnabled = abilityEnabled;
|
this.abilityEnabled = abilityEnabled;
|
||||||
this.tier = tier;
|
this.tier = tier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material getType() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Material material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
public double getXpMultiplier() {
|
public double getXpMultiplier() {
|
||||||
return xpMultiplier;
|
return xpMultiplier;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModUtils;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
@ -99,7 +98,7 @@ public class AxesManager extends SkillManager {
|
|||||||
if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) {
|
if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
|
||||||
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
|
||||||
short maxDurability = ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability();
|
short maxDurability = armor.getType().getMaxDurability();
|
||||||
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
|
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
|
||||||
|
|
||||||
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.Recipe;
|
import org.bukkit.inventory.Recipe;
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
import org.bukkit.inventory.ShapelessRecipe;
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
@ -112,25 +113,29 @@ public class Repair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Recipe recipe = mcMMO.p.getServer().getRecipesFor(inHand).get(0);
|
return getRepairAndSalvageQuantities(inHand, getSalvagedItem(inHand), (byte) -1);
|
||||||
int salvageAmount = 0;
|
}
|
||||||
Material salvageMaterial = getSalvagedItem(inHand);
|
|
||||||
|
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
|
||||||
|
int quantity = 0;
|
||||||
|
MaterialData repairData = new MaterialData(repairMaterial, repairMetadata);
|
||||||
|
Recipe recipe = mcMMO.p.getServer().getRecipesFor(item).get(0);
|
||||||
|
|
||||||
if (recipe instanceof ShapelessRecipe) {
|
if (recipe instanceof ShapelessRecipe) {
|
||||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
||||||
if (ingredient != null && ingredient.getType() == salvageMaterial) {
|
if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) {
|
||||||
salvageAmount += ingredient.getAmount();
|
quantity += ingredient.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (recipe instanceof ShapedRecipe) {
|
else if (recipe instanceof ShapedRecipe) {
|
||||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
||||||
if (ingredient != null && ingredient.getType() == salvageMaterial) {
|
if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) {
|
||||||
salvageAmount += ingredient.getAmount();
|
quantity += ingredient.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return salvageAmount;
|
return quantity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ import java.util.Set;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.Recipe;
|
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
|
||||||
import org.bukkit.inventory.ShapelessRecipe;
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
@ -100,7 +96,7 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maximum Durability
|
// Maximum Durability
|
||||||
short maximumDurability = (config.contains("Repairables." + key + ".MaximumDurability") ? (short) config.getInt("Repairables." + key + ".MaximumDurability") : (itemMaterial != null ? itemMaterial.getMaxDurability() : 0));
|
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
|
||||||
|
|
||||||
if (maximumDurability <= 0) {
|
if (maximumDurability <= 0) {
|
||||||
reason.add("Maximum durability of " + key + " must be greater than 0!");
|
reason.add("Maximum durability of " + key + " must be greater than 0!");
|
||||||
@ -129,7 +125,7 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int repairMetadata = config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
|
byte repairMetadata = (byte) config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
|
||||||
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel");
|
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel");
|
||||||
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
|
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
|
||||||
|
|
||||||
@ -138,38 +134,14 @@ public class RepairConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Minimum Quantity
|
// Minimum Quantity
|
||||||
int minimumQuantity = 0;
|
int minimumQuantity = (itemMaterial != null ? Repair.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity"));
|
||||||
|
|
||||||
if (config.contains("Repairables." + key + ".MinimumQuantity")) {
|
|
||||||
minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity");
|
|
||||||
}
|
|
||||||
else if (itemMaterial != null) {
|
|
||||||
ItemStack item = new ItemStack(itemMaterial);
|
|
||||||
MaterialData repairData = new MaterialData(repairMaterial, (byte) repairMetadata);
|
|
||||||
Recipe recipe = mcMMO.p.getServer().getRecipesFor(item).get(0);
|
|
||||||
|
|
||||||
if (recipe instanceof ShapelessRecipe) {
|
|
||||||
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
|
|
||||||
if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) {
|
|
||||||
minimumQuantity += ingredient.getAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (recipe instanceof ShapedRecipe) {
|
|
||||||
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
|
|
||||||
if (ingredient != null && ingredient.getType() == repairMaterial && (repairMetadata == -1 || ingredient.getData() == repairData)) {
|
|
||||||
minimumQuantity += ingredient.getAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minimumQuantity <= 0) {
|
if (minimumQuantity <= 0) {
|
||||||
reason.add("Minimum quantity of " + key + " must be greater than 0!");
|
reason.add("Minimum quantity of " + key + " must be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noErrorsInRepairable(reason)) {
|
if (noErrorsInRepairable(reason)) {
|
||||||
Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, (byte) repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
|
||||||
repairables.add(repairable);
|
repairables.add(repairable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ public final class Woodcutting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
|
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
|
||||||
short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability();
|
short maxDurability = inHandMaterial.getMaxDurability();
|
||||||
boolean overMax = (finalDurability >= maxDurability);
|
boolean overMax = (finalDurability >= maxDurability);
|
||||||
|
|
||||||
inHand.setDurability(overMax ? maxDurability : finalDurability);
|
inHand.setDurability(overMax ? maxDurability : finalDurability);
|
||||||
|
@ -121,7 +121,9 @@ public class ItemUtils {
|
|||||||
* @return true if the item is a helmet, false otherwise
|
* @return true if the item is a helmet, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHelmet(ItemStack item) {
|
public static boolean isHelmet(ItemStack item) {
|
||||||
switch (item.getType()) {
|
Material type = item.getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case DIAMOND_HELMET:
|
case DIAMOND_HELMET:
|
||||||
case GOLD_HELMET:
|
case GOLD_HELMET:
|
||||||
case IRON_HELMET:
|
case IRON_HELMET:
|
||||||
@ -130,7 +132,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmetIDs.contains(item.getTypeId());
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmets.contains(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +143,9 @@ public class ItemUtils {
|
|||||||
* @return true if the item is a chestplate, false otherwise
|
* @return true if the item is a chestplate, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isChestplate(ItemStack item) {
|
public static boolean isChestplate(ItemStack item) {
|
||||||
switch (item.getType()) {
|
Material type = item.getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case DIAMOND_CHESTPLATE:
|
case DIAMOND_CHESTPLATE:
|
||||||
case GOLD_CHESTPLATE:
|
case GOLD_CHESTPLATE:
|
||||||
case IRON_CHESTPLATE:
|
case IRON_CHESTPLATE:
|
||||||
@ -150,7 +154,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplateIDs.contains(item.getTypeId());
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplates.contains(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +165,9 @@ public class ItemUtils {
|
|||||||
* @return true if the item is a pair of pants, false otherwise
|
* @return true if the item is a pair of pants, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeggings(ItemStack item) {
|
public static boolean isLeggings(ItemStack item) {
|
||||||
switch (item.getType()) {
|
Material type = item.getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case DIAMOND_LEGGINGS:
|
case DIAMOND_LEGGINGS:
|
||||||
case GOLD_LEGGINGS:
|
case GOLD_LEGGINGS:
|
||||||
case IRON_LEGGINGS:
|
case IRON_LEGGINGS:
|
||||||
@ -170,7 +176,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggingIDs.contains(item.getTypeId());
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggings.contains(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +187,9 @@ public class ItemUtils {
|
|||||||
* @return true if the item is a pair of boots, false otherwise
|
* @return true if the item is a pair of boots, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isBoots(ItemStack item) {
|
public static boolean isBoots(ItemStack item) {
|
||||||
switch (item.getType()) {
|
Material type = item.getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case DIAMOND_BOOTS:
|
case DIAMOND_BOOTS:
|
||||||
case GOLD_BOOTS:
|
case GOLD_BOOTS:
|
||||||
case IRON_BOOTS:
|
case IRON_BOOTS:
|
||||||
@ -190,7 +198,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBootIDs.contains(item.getTypeId());
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBoots.contains(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||||
@ -11,7 +12,6 @@ import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
|||||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
|
|
||||||
public final class ModUtils {
|
public final class ModUtils {
|
||||||
@ -24,16 +24,6 @@ public final class ModUtils {
|
|||||||
|
|
||||||
private ModUtils() {}
|
private ModUtils() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the custom armor associated with an item.
|
|
||||||
*
|
|
||||||
* @param item The item to check
|
|
||||||
* @return the armor if it exists, null otherwise
|
|
||||||
*/
|
|
||||||
public static CustomItem getArmorFromItemStack(ItemStack item) {
|
|
||||||
return CustomArmorConfig.getInstance().customArmor.get(item.getTypeId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the custom tool associated with an item.
|
* Get the custom tool associated with an item.
|
||||||
*
|
*
|
||||||
@ -56,7 +46,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
if (CustomBlockConfig.getInstance().customItems.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +82,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +104,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +126,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +148,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +170,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
if (CustomBlockConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +192,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
if (CustomBlockConfig.getInstance().customLeaves.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +214,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
if (CustomBlockConfig.getInstance().customLogs.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,7 +236,7 @@ public final class ModUtils {
|
|||||||
|
|
||||||
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
if (CustomBlockConfig.getInstance().customOres.contains(item)) {
|
||||||
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
for (CustomBlock block : CustomBlockConfig.getInstance().customBlocks) {
|
||||||
if ((block.getItemID() == blockState.getTypeId()) && (block.getDataValue() == blockState.getRawData())) {
|
if (new MaterialData(block.getItemID(), block.getDataValue()).equals(blockState.getData())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,7 +267,7 @@ public final class ModUtils {
|
|||||||
* @return true if the item is custom armor, false otherwise
|
* @return true if the item is custom armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isCustomArmor(ItemStack item) {
|
public static boolean isCustomArmor(ItemStack item) {
|
||||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.containsKey(item.getTypeId())) {
|
if (customArmorEnabled && CustomArmorConfig.getInstance().customArmor.contains(item.getType())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ public class SkillUtils {
|
|||||||
*/
|
*/
|
||||||
public static ItemStack handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
|
public static ItemStack handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
|
||||||
short finalDurability = (short) (itemStack.getDurability() + durabilityModifier);
|
short finalDurability = (short) (itemStack.getDurability() + durabilityModifier);
|
||||||
short maxDurability = ModUtils.isCustomTool(itemStack) ? ModUtils.getToolFromItemStack(itemStack).getDurability() : itemStack.getType().getMaxDurability();
|
short maxDurability = itemStack.getType().getMaxDurability();
|
||||||
boolean overMax = (finalDurability >= maxDurability);
|
boolean overMax = (finalDurability >= maxDurability);
|
||||||
|
|
||||||
itemStack.setDurability(overMax ? maxDurability : finalDurability);
|
itemStack.setDurability(overMax ? maxDurability : finalDurability);
|
||||||
|
@ -3,73 +3,62 @@
|
|||||||
###
|
###
|
||||||
Boots:
|
Boots:
|
||||||
Boot_1:
|
Boot_1:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
Boot_2:
|
Boot_2:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Chestplates
|
# Settings for Chestplates
|
||||||
###
|
###
|
||||||
Chestplates:
|
Chestplates:
|
||||||
Chestplate_1:
|
Chestplate_1:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
Chestplate_2:
|
Chestplate_2:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Helmets
|
# Settings for Helmets
|
||||||
###
|
###
|
||||||
Helmets:
|
Helmets:
|
||||||
Helmet_1:
|
Helmet_1:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
Helmet_2:
|
Helmet_2:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Leggings
|
# Settings for Leggings
|
||||||
###
|
###
|
||||||
Leggings:
|
Leggings:
|
||||||
Legging_1:
|
Legging_1:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
||||||
Legging_2:
|
Legging_2:
|
||||||
ID: 999
|
|
||||||
Repairable: true
|
Repairable: true
|
||||||
Repair_Material_ID: 99
|
Repair_Material: REPAIR_MATERIAL_NAME
|
||||||
Repair_Material_Data_Value: 0
|
Repair_Material_Data_Value: 0
|
||||||
Repair_Material_Quantity: 9
|
Repair_Material_Quantity: 9
|
||||||
Durability: 9999
|
Durability: 999
|
Loading…
Reference in New Issue
Block a user