From 18fd9bbf9baf0376faca9819c7ad1d78730a8e52 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 17 Jun 2019 14:01:44 -0700 Subject: [PATCH] Repair rewrite pt 1 - WIP --- .../gmail/nossr50/config/ConfigManager.java | 4 + .../serializers/ItemStackSerializer.java | 65 +++++++++++++ .../serializers/RepairWildcardSerializer.java | 22 ++++- .../serializers/RepairableSerializer.java | 95 +++++-------------- .../hocon/skills/repair/ConfigRepair.java | 22 +++-- .../hocon/skills/repair/RepairWildcard.java | 21 ++-- .../skills/repair/repairables/Repairable.java | 80 +++++++--------- .../com/gmail/nossr50/util/nbt/NBTUtils.java | 6 ++ .../com/gmail/nossr50/util/nbt/RawNBT.java | 18 ++++ 9 files changed, 197 insertions(+), 136 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java create mode 100644 src/main/java/com/gmail/nossr50/util/nbt/NBTUtils.java create mode 100644 src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 87741fa85..48494036c 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -37,6 +37,7 @@ import com.gmail.nossr50.config.hocon.skills.mining.ConfigMining; import com.gmail.nossr50.config.hocon.skills.ranks.ConfigRanks; import com.gmail.nossr50.config.hocon.skills.ranks.SkillRankProperty; import com.gmail.nossr50.config.hocon.skills.repair.ConfigRepair; +import com.gmail.nossr50.config.hocon.skills.repair.RepairWildcard; import com.gmail.nossr50.config.hocon.skills.salvage.ConfigSalvage; import com.gmail.nossr50.config.hocon.skills.smelting.ConfigSmelting; import com.gmail.nossr50.config.hocon.skills.swords.ConfigSwords; @@ -64,6 +65,7 @@ import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; import java.io.File; import java.util.ArrayList; @@ -275,6 +277,8 @@ public final class ConfigManager { customSerializers.registerType(TypeToken.of(MaxBonusLevel.class), new MaxBonusLevelSerializer()); customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer()); customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer()); + customSerializers.registerType(TypeToken.of(ItemStack.class), new ItemStackSerializer()); + customSerializers.registerType(TypeToken.of(RepairWildcard.class), new RepairWildcardSerializer()); } /** diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java new file mode 100644 index 000000000..d6c828675 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java @@ -0,0 +1,65 @@ +package com.gmail.nossr50.config.hocon.serializers; + +import com.gmail.nossr50.mcMMO; +import com.google.common.reflect.TypeToken; +import ninja.leaping.configurate.ConfigurationNode; +import ninja.leaping.configurate.ValueType; +import ninja.leaping.configurate.objectmapping.ObjectMappingException; +import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.List; + +public class ItemStackSerializer implements TypeSerializer { + + private static final String ITEM_MINECRAFT_NAME = "Item-Minecraft-Name"; + private static final String AMOUNT = "Amount"; + private static final String ITEM_LORE = "Item-Lore"; + + @Nullable + @Override + public ItemStack deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { + ItemStack itemStack; + + String itemIdentifier = value.getNode(ITEM_MINECRAFT_NAME).getValue(TypeToken.of(String.class)); + + Material itemMatch = Material.matchMaterial(itemIdentifier); + + if(itemMatch == null) { + mcMMO.p.getLogger().info("Could not find a match for "+itemIdentifier); + return null; + } + + ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); + + //Get the amount of items in the stack + if(itemNode.getNode(AMOUNT).getValueType() != ValueType.NULL) { + Integer amount = itemNode.getNode(AMOUNT).getValue(TypeToken.of(Integer.class)); + itemStack = new ItemStack(itemMatch, amount); + } else { + itemStack = new ItemStack(itemMatch, 1); + } + + //Init default item meta + itemStack.setItemMeta(Bukkit.getItemFactory().getItemMeta(itemMatch)); + + //Set Lore if it exists + if(itemNode.getNode(ITEM_LORE).getValueType() != ValueType.NULL) { + List lore = itemNode.getNode(ITEM_LORE).getValue(new TypeToken>() {}); + itemStack.getItemMeta().setLore(lore); + } + + + return null; + } + + @Override + public void serialize(@NonNull TypeToken type, @Nullable ItemStack obj, @NonNull ConfigurationNode value) throws ObjectMappingException { + + } + +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairWildcardSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairWildcardSerializer.java index d9a5e4004..c32acab3b 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairWildcardSerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairWildcardSerializer.java @@ -3,20 +3,40 @@ package com.gmail.nossr50.config.hocon.serializers; import com.gmail.nossr50.config.hocon.skills.repair.RepairWildcard; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.ConfigurationNode; +import ninja.leaping.configurate.ValueType; import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; +import org.bukkit.inventory.ItemStack; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import java.util.ArrayList; +import java.util.Set; + public class RepairWildcardSerializer implements TypeSerializer { + + private static final String WILDCARD_IDENTIFIER_NAME = "Wildcard-Identifier-Name"; + private static final String MATCHING_ITEMS = "Matching-Items"; + @Nullable @Override public RepairWildcard deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { + + String wildCardName = value.getNode(WILDCARD_IDENTIFIER_NAME).getValue(TypeToken.of(String.class)); + + if(value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValueType() != ValueType.NULL) { + Set matchCandidates = value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValue(new TypeToken>() {}); + + return new RepairWildcard(wildCardName, matchCandidates); + } + return null; } @Override public void serialize(@NonNull TypeToken type, @Nullable RepairWildcard obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - + value.getNode(WILDCARD_IDENTIFIER_NAME).setValue(obj.getWildcardName()); + value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).setValue(obj.getMatchingItems()); } + } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairableSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairableSerializer.java index de8a52e0a..211937cd9 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairableSerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairableSerializer.java @@ -1,95 +1,48 @@ package com.gmail.nossr50.config.hocon.serializers; import com.gmail.nossr50.skills.repair.repairables.Repairable; +import com.gmail.nossr50.util.nbt.RawNBT; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; import ninja.leaping.configurate.util.EnumLookup; +import org.bukkit.inventory.ItemStack; -import java.util.List; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; public class RepairableSerializer implements TypeSerializer { - public static final String ITEM = "Item"; - public static final String ITEMS_USED_TO_REPAIR = "Items-Used-To-Repair"; - public static final String MINIMUM_QUANTITY_USED_TO_REPAIR = "Minimum-Quantity-Used-To-Repair"; - public static final String OVERRIDE_LEVEL_REQUIREMENT = "Override-Level-Requirement"; - public static final String XP_MULTIPLIER = "XP-Multiplier"; - - /* - TypeTokens are obtained in two ways - - For Raw basic classes: - - TypeToken stringTok = TypeToken.of(String.class); - TypeToken intTok = TypeToken.of(Integer.class); - - For Generics: - - TypeToken> stringListTok = new TypeToken>() {}; - - Wildcard example: - - TypeToken> wildMapTok = new TypeToken>() {}; - - */ - + private static final String ITEM = "Item"; + private static final String ITEMS_USED_TO_REPAIR = "Items-Used-To-Repair"; + private static final String OVERRIDE_LEVEL_REQUIREMENT = "Level-Requirement"; + private static final String BASE_XP = "XP-Per-Repair"; + private static final String FULL_REPAIR_TRANSACTIONS = "Repair-Count"; + private static final String STRICT_MATCHING = "Use-Strict-Matching"; + private static final String RAW_NBT = "Raw-NBT"; @Override public Repairable deserialize(TypeToken type, ConfigurationNode value) throws ObjectMappingException { + String itemMaterial = value.getNode(ITEM).getValue(TypeToken.of(String.class)); + HashSet repairItems = new HashSet(value.getNode(ITEMS_USED_TO_REPAIR).getValue(new TypeToken>() {})); + Integer minimumLevel = value.getNode(OVERRIDE_LEVEL_REQUIREMENT).getValue(TypeToken.of(Integer.class)); + Integer baseXP = value.getNode(BASE_XP).getValue(TypeToken.of(Integer.class)); + Integer minRepairs = value.getNode(FULL_REPAIR_TRANSACTIONS).getValue(TypeToken.of(Integer.class)); + Boolean strictMatching = value.getNode(STRICT_MATCHING).getValue(TypeToken.of(Boolean.class)); + String rawNBT = value.getNode(RAW_NBT).getValue(TypeToken.of(String.class)); - /* - CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SWORD, OAK_PLANKS, 1, 0, .25D)); - */ - - /* Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) */ - - String item = value.getNode(ITEM).getValue(TypeToken.of(String.class)); - List repairItems = value.getNode(ITEMS_USED_TO_REPAIR).getValue(new TypeToken>() { - }); - - - /*String itemConstant = HOCONUtil.deserializeENUMName(value.getNode("Item").getString()); - String repairConstant = HOCONUtil.deserializeENUMName(value.getNode("Item-Used-To-Repair").getString()); - - Material item = (Material) getEnum(itemConstant, 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)); - - if(minimumQuantity == 0) - minimumQuantity = -1; - - int minimumLevel = value.getNode(OVERRIDE_LEVEL_REQUIREMENT).getValue(TypeToken.of(Integer.class)); - double xpMultiplier = value.getNode(XP_MULTIPLIER).getValue(TypeToken.of(Double.class)); - - return new Repairable(item, repairItems, minimumQuantity, minimumLevel, xpMultiplier); + return new Repairable(itemMaterial, repairItems, minimumLevel, minRepairs, baseXP, strictMatching, new RawNBT(rawNBT)); } @Override public void serialize(TypeToken type, Repairable obj, ConfigurationNode value) { - - /*value.getNode("Item").setValue(HOCONUtil.serializeENUMName(obj.getItemMaterial().getKey().getKey())); - value.getNode("Item-Used-To-Repair").setValue(HOCONUtil.serializeENUMName(obj.getRepairMaterials().getKey().getKey()));*/ value.getNode(ITEM).setValue(obj.getItemMaterial().getKey().toString()); - value.getNode(ITEMS_USED_TO_REPAIR).setValue(obj.getRepairMaterialsRegistryKeys()); - value.getNode(MINIMUM_QUANTITY_USED_TO_REPAIR).setValue(obj.getMinimumQuantity()); - value.getNode(OVERRIDE_LEVEL_REQUIREMENT).setValue(obj.getMinimumLevel()); - value.getNode(XP_MULTIPLIER).setValue(obj.getXpMultiplier()); - } - - private Enum getEnum(String enumConstant, TypeToken type) throws ObjectMappingException { - //noinspection RedundantCast - Optional ret = (Optional) EnumLookup.lookupEnum(type.getRawType().asSubclass(Enum.class), - enumConstant); // XXX: intellij says this cast is optional but it isnt - - if (!ret.isPresent()) { - throw new ObjectMappingException("Invalid enum constant provided for " + enumConstant + ": " + - "Expected a value of enum " + type + ", got " + enumConstant); - } - - return ret.get(); + value.getNode(ITEMS_USED_TO_REPAIR).setValue(obj.getRepairTransaction()); + value.getNode(BASE_XP).setValue(obj.getBaseXP()); + value.getNode(FULL_REPAIR_TRANSACTIONS).setValue(obj.getRepairCount()); + value.getNode(STRICT_MATCHING).setValue(obj.useStrictMatching()); + value.getNode(RAW_NBT).setValue(obj.getRawNBT().getNbtContents()); } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java index 67a47ab3b..fc15a6c54 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.skills.repair.repairables.Repairable; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; import java.util.*; @@ -18,12 +19,21 @@ public class ConfigRepair { public static final ArrayList CONFIG_REPAIRABLES_DEFAULTS; public static final HashSet REPAIR_WILDCARDS_DEFAULTS; - public static final Material[] PLANKS = new Material[]{OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS}; +// public static final Material[] PLANKS = new Material[]{OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS}; static { + REPAIR_WILDCARDS_DEFAULTS = new HashSet<>(); + + List planksList = Arrays.asList(new ItemStack[]{new ItemStack(OAK_PLANKS, 1), + new ItemStack(BIRCH_PLANKS, 1), new ItemStack(DARK_OAK_PLANKS, 1), + new ItemStack(ACACIA_PLANKS, 1), new ItemStack(JUNGLE_PLANKS, 1), + new ItemStack(SPRUCE_PLANKS, 1)}); + RepairWildcard planksWildCard = new RepairWildcard("Planks", new HashSet<>(planksList)); + REPAIR_WILDCARDS_DEFAULTS.add(planksWildCard); + CONFIG_REPAIRABLES_DEFAULTS = new ArrayList<>(); - CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SWORD, Arrays.asList(PLANKS), 1, 0, .25D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SHOVEL, Arrays.asList(PLANKS), 1, 0, .15D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SWORD, planksWildCard, 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SHOVEL, planksWildCard, 1, 0, .15D)); CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_PICKAXE, Arrays.asList(PLANKS), 1, 0, .5D)); CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_AXE, Arrays.asList(PLANKS), 1, 0, .5D)); CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_HOE, Arrays.asList(PLANKS), 1, 0, .25D)); @@ -70,13 +80,7 @@ public class ConfigRepair { CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_LEGGINGS, DIAMOND, 1, 0, 2D)); CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_BOOTS, DIAMOND, 1, 0, 2D)); - REPAIR_WILDCARDS_DEFAULTS = new HashSet<>(); - RepairWildcard repairWildcardPlanks = new RepairWildcard("Planks"); - List planksList = Arrays.asList(new String[]{OAK_PLANKS.getKey().toString(), - BIRCH_PLANKS.getKey().toString(), DARK_OAK_PLANKS.getKey().toString(), ACACIA_PLANKS.getKey().toString(), JUNGLE_PLANKS.getKey().toString(), SPRUCE_PLANKS.getKey().toString()}); - repairWildcardPlanks.addMatchCandidates(planksList); - REPAIR_WILDCARDS_DEFAULTS.add(repairWildcardPlanks); } @Setting(value = "General") diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/RepairWildcard.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/RepairWildcard.java index 092c791c2..1aa153f06 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/RepairWildcard.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/RepairWildcard.java @@ -1,25 +1,28 @@ package com.gmail.nossr50.config.hocon.skills.repair; +import org.bukkit.inventory.ItemStack; + import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Set; public class RepairWildcard { private String wildcardName; - private ArrayList matchCandidates; + private Set matchingItems; - public RepairWildcard(String wildcardName) { + public RepairWildcard(String wildcardName, Set matchingItems) { this.wildcardName = wildcardName; - matchCandidates = new ArrayList<>(); + this.matchingItems = matchingItems; } - public void addMatchCandidates(List arrayList) { - matchCandidates.addAll(arrayList); + public Set getMatchingItems() { + return matchingItems; } - public ArrayList getMatchCandidates() { - return matchCandidates; + public void setMatchingItems(Set matchingItems) { + this.matchingItems = matchingItems; } public String getWildcardName() { @@ -32,11 +35,11 @@ public class RepairWildcard { if (!(o instanceof RepairWildcard)) return false; RepairWildcard that = (RepairWildcard) o; return getWildcardName().equals(that.getWildcardName()) && - Objects.equals(getMatchCandidates(), that.getMatchCandidates()); + getMatchingItems().equals(that.getMatchingItems()); } @Override public int hashCode() { - return Objects.hash(getWildcardName(), getMatchCandidates()); + return Objects.hash(getWildcardName(), getMatchingItems()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index 6d5cb72fd..80104f11a 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -1,71 +1,63 @@ package com.gmail.nossr50.skills.repair.repairables; -import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; -import com.gmail.nossr50.datatypes.skills.ItemType; -import com.gmail.nossr50.util.ItemUtils; -import com.gmail.nossr50.util.skills.SkillUtils; +import com.gmail.nossr50.util.nbt.RawNBT; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; -import java.util.Collections; -import java.util.List; +import java.util.HashSet; public class Repairable { private final Material itemMaterial; - private final List repairMaterials; - private final int minimumQuantity, minimumLevel; - private final short maximumDurability, baseRepairDurability; - private final ItemType repairItemType; - private final ItemMaterialCategory repairItemMaterialCategory; - private final double xpMultiplier; + private final int minimumLevel; + private final short maximumDurability; + private HashSet repairTransaction; + private boolean strictMatching; + private int baseXP; + private RawNBT rawNBT; + private int repairCount; - public Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) { - this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Collections.singletonList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier); + public Repairable(Material itemMaterial, HashSet repairTransaction, int minimumLevel, int repairCount, int baseXP, RawNBT rawNBT) { + this(itemMaterial.getKey().getKey(), repairTransaction, minimumLevel, repairCount, baseXP, false, rawNBT); } - public Repairable(Material itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { - this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(repairMaterials), minimumQuantity, minimumLevel, xpMultiplier); + public Repairable(Material itemMaterial, HashSet repairTransaction, int minimumLevel, int repairCount, int baseXP) { + this(itemMaterial.getKey().getKey(), repairTransaction, minimumLevel, repairCount, baseXP, false, null); } - public Repairable(String itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { + public Repairable(String itemMaterial, HashSet repairTransaction, int minimumLevel, int repairCount, int baseXP, boolean strictMatching, RawNBT rawNBT) { this.itemMaterial = Material.matchMaterial(itemMaterial); - this.repairMaterials = ItemUtils.matchMaterials(repairMaterials); - this.minimumQuantity = Math.max(1, minimumQuantity); this.minimumLevel = Math.max(0, minimumLevel); - this.xpMultiplier = Math.max(0, xpMultiplier); this.maximumDurability = this.itemMaterial.getMaxDurability(); - this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); + this.repairCount = repairCount; + this.repairTransaction = repairTransaction; + this.strictMatching = strictMatching; + this.baseXP = baseXP; + this.rawNBT = rawNBT; + } - this.repairItemType = ItemUtils.determineItemType(this.itemMaterial); - this.repairItemMaterialCategory = ItemUtils.determineMaterialType(this.repairMaterials.get(0)); + public RawNBT getRawNBT() { + return rawNBT; + } + + public int getRepairCount() { + return repairCount; } public Material getItemMaterial() { return itemMaterial; } - public List getRepairMaterials() { - return repairMaterials; + public HashSet getRepairTransaction() { + return repairTransaction; } - public List getRepairMaterialsRegistryKeys() { - return ItemUtils.getRepairItemMaterials(repairMaterials); + public boolean useStrictMatching() { + return strictMatching; } - - public ItemType getRepairItemType() { - return repairItemType; - } - - public ItemMaterialCategory getRepairItemMaterialCategory() { - return repairItemMaterialCategory; - } - - public int getMinimumQuantity() { - if(minimumQuantity == -1) - return Math.max(SkillUtils.getRepairAndSalvageQuantities(itemMaterial, repairMaterials), 1); - else - return minimumQuantity; + public int getBaseXP() { + return baseXP; } public short getMaximumDurability() { @@ -73,14 +65,10 @@ public class Repairable { } public short getBaseRepairDurability() { - return baseRepairDurability; + return (short) (maximumDurability / repairCount); } public int getMinimumLevel() { return minimumLevel; } - - public double getXpMultiplier() { - return xpMultiplier; - } } diff --git a/src/main/java/com/gmail/nossr50/util/nbt/NBTUtils.java b/src/main/java/com/gmail/nossr50/util/nbt/NBTUtils.java new file mode 100644 index 000000000..b942a73e3 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/nbt/NBTUtils.java @@ -0,0 +1,6 @@ +package com.gmail.nossr50.util.nbt; + +public class NBTUtils { + + +} diff --git a/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java b/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java new file mode 100644 index 000000000..22cee492b --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java @@ -0,0 +1,18 @@ +package com.gmail.nossr50.util.nbt; + +public class RawNBT { + String nbtContents; + + public RawNBT(String nbtContents) { + this.nbtContents = nbtContents; + } + + public String getNbtContents() { + return nbtContents; + } + + public void setNbtContents(String nbtContents) { + this.nbtContents = nbtContents; + } + +}