From 5c31bdbd4974a921739d5056b4486cc739303632 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 22 Jun 2019 13:05:28 -0700 Subject: [PATCH] Lets generify some of this stuff --- .../gmail/nossr50/config/ConfigManager.java | 6 +-- .../CustomItemTargetSerializer.java | 43 +++++++++++++++++++ .../serializers/ItemWildcardSerializer.java | 5 +-- .../serializers/RepairCostSerializer.java | 17 +++++--- .../serializers/RepairableSerializer.java | 11 ++--- .../datatypes/items/CustomItemMatching.java | 13 ------ .../nossr50/datatypes/items/DefinedMatch.java | 19 ++++++++ .../{CustomItemTarget.java => ItemMatch.java} | 20 ++++----- .../datatypes/items/ItemWildcards.java | 13 +++--- .../nossr50/skills/repair/RepairCost.java | 1 + .../skills/repair/RepairTransaction.java | 4 +- .../skills/repair/SimpleRepairCost.java | 31 ++++++++++--- .../skills/repair/repairables/Repairable.java | 18 ++++---- .../repair/repairables/RepairableBuilder.java | 12 +++--- 14 files changed, 139 insertions(+), 74 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/serializers/CustomItemTargetSerializer.java delete mode 100644 src/main/java/com/gmail/nossr50/datatypes/items/CustomItemMatching.java create mode 100644 src/main/java/com/gmail/nossr50/datatypes/items/DefinedMatch.java rename src/main/java/com/gmail/nossr50/datatypes/items/{CustomItemTarget.java => ItemMatch.java} (87%) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index bf107f147..90beb157f 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -52,7 +52,7 @@ import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig; import com.gmail.nossr50.datatypes.experience.CustomXPPerk; import com.gmail.nossr50.datatypes.experience.FormulaType; -import com.gmail.nossr50.datatypes.items.BukkitMMOItem; +import com.gmail.nossr50.datatypes.items.ItemMatch; import com.gmail.nossr50.datatypes.items.ItemWildcards; import com.gmail.nossr50.datatypes.items.MMOItem; import com.gmail.nossr50.datatypes.party.PartyFeature; @@ -70,7 +70,6 @@ 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; @@ -284,9 +283,10 @@ public final class ConfigManager { customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer()); customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer()); customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer()); - customSerializers.registerType(TypeToken.of(RepairCost.class), new RepairCostSerializer()); + customSerializers.registerType(TypeToken.of(ItemMatch.class), new CustomItemTargetSerializer()); customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer()); customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer()); + customSerializers.registerType(TypeToken.of(RepairCost.class), new RepairCostSerializer()); } /** diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/CustomItemTargetSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/CustomItemTargetSerializer.java new file mode 100644 index 000000000..218e112d5 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/CustomItemTargetSerializer.java @@ -0,0 +1,43 @@ +package com.gmail.nossr50.config.hocon.serializers; + +import com.gmail.nossr50.datatypes.items.ItemMatch; +import com.gmail.nossr50.datatypes.items.ItemMatchProperty; +import com.gmail.nossr50.datatypes.items.MMOItem; +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.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.HashSet; + +public class CustomItemTargetSerializer implements TypeSerializer { + + private static final String ITEM_CONSUMED_FOR_REPAIR = "Item-Consumed-For-Repair"; + private static final String NBT_REQUIREMENTS = "NBT-Requirements"; + + @Nullable + @Override + public ItemMatch deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { + MMOItem mmoItem = value.getNode(ITEM_CONSUMED_FOR_REPAIR).getValue(new TypeToken>() {}); + if(value.getNode(NBT_REQUIREMENTS).getValueType() != ValueType.NULL) + { + HashSet itemMatchProperties = value.getNode(NBT_REQUIREMENTS).getValue(new TypeToken>() {}); + return new ItemMatch(mmoItem, itemMatchProperties); + } + + return new ItemMatch(mmoItem, null); + } + + @Override + public void serialize(@NonNull TypeToken type, @Nullable ItemMatch obj, @NonNull ConfigurationNode value) throws ObjectMappingException { + value.getNode(ITEM_CONSUMED_FOR_REPAIR).setValue(obj.getItem()); + + if(obj.getItemMatchProperties().size() > 0) { + value.getNode(NBT_REQUIREMENTS).setValue(obj.getItemMatchProperties()); + SerializerUtil.addCommentIfCompatible(value.getNode(NBT_REQUIREMENTS), "List optional NBT that is required here, you write it the same way you do in vanilla commands."); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemWildcardSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemWildcardSerializer.java index 65c330acf..f785795f0 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemWildcardSerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemWildcardSerializer.java @@ -1,13 +1,12 @@ package com.gmail.nossr50.config.hocon.serializers; -import com.gmail.nossr50.datatypes.items.CustomItemTarget; +import com.gmail.nossr50.datatypes.items.ItemMatch; import com.gmail.nossr50.datatypes.items.ItemWildcards; 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; @@ -26,7 +25,7 @@ public class ItemWildcardSerializer implements TypeSerializer { 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>() {}); + Set matchCandidates = value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValue(new TypeToken>() {}); return new ItemWildcards(wildCardName, new HashSet<>(matchCandidates)); } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairCostSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairCostSerializer.java index 66393c1e5..b218d7300 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairCostSerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/RepairCostSerializer.java @@ -1,22 +1,27 @@ package com.gmail.nossr50.config.hocon.serializers; +import com.gmail.nossr50.datatypes.items.ItemMatch; import com.gmail.nossr50.skills.repair.RepairCost; +import com.gmail.nossr50.skills.repair.SimpleRepairCost; 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 org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -public class RepairCostSerializer implements TypeSerializer { +public class RepairCostSerializer implements TypeSerializer> { + + private static final String TARGET_ITEM = "Target-Item"; + @Nullable @Override - public RepairCost deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { - return null; + public RepairCost deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { + ItemMatch itemMatch = value.getNode(TARGET_ITEM).getValue(TypeToken.of(ItemMatch.class)); + return new SimpleRepairCost(itemMatch); } @Override - public void serialize(@NonNull TypeToken type, @Nullable RepairCost obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - + public void serialize(@NonNull TypeToken type, @Nullable RepairCost obj, @NonNull ConfigurationNode value) throws ObjectMappingException { + value.getNode(TARGET_ITEM).setValue(obj.getRepairCosts()); } } 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 22acf8c24..1e3c1a372 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,6 +1,6 @@ package com.gmail.nossr50.config.hocon.serializers; -import com.gmail.nossr50.datatypes.items.CustomItemTarget; +import com.gmail.nossr50.datatypes.items.ItemMatch; import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; import com.gmail.nossr50.skills.repair.RepairTransaction; import com.gmail.nossr50.skills.repair.repairables.Repairable; @@ -8,11 +8,8 @@ import com.gmail.nossr50.skills.repair.repairables.RepairableBuilder; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.ValueType; -import ninja.leaping.configurate.commented.CommentedConfigurationNode; -import ninja.leaping.configurate.commented.SimpleCommentedConfigurationNode; import ninja.leaping.configurate.objectmapping.ObjectMappingException; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; -import org.bukkit.inventory.ItemStack; public class RepairableSerializer implements TypeSerializer { private static final String REPAIRABLE_ITEM = "Repairable-Item"; @@ -26,11 +23,11 @@ public class RepairableSerializer implements TypeSerializer { @Override public Repairable deserialize(TypeToken type, ConfigurationNode value) throws ObjectMappingException { /* Necessary fields */ - CustomItemTarget customItemTarget = value.getNode(REPAIRABLE_ITEM).getValue(TypeToken.of(CustomItemTarget.class)); + ItemMatch itemMatch = value.getNode(REPAIRABLE_ITEM).getValue(TypeToken.of(ItemMatch.class)); Short maximumDurability = value.getNode(MAXIMUM_DURABILITY).getValue(TypeToken.of(Short.class)); RepairTransaction repairTransaction = value.getNode(ITEMS_REQUIRED_TO_REPAIR).getValue(TypeToken.of(RepairTransaction.class)); - RepairableBuilder repairableBuilder = new RepairableBuilder(customItemTarget, maximumDurability, repairTransaction); + RepairableBuilder repairableBuilder = new RepairableBuilder(itemMatch, maximumDurability, repairTransaction); if(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getValueType() != ValueType.NULL) { repairableBuilder.addMinLevel(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getInt()); @@ -53,7 +50,7 @@ public class RepairableSerializer implements TypeSerializer { @Override public void serialize(TypeToken type, Repairable obj, ConfigurationNode value) { - value.getNode(REPAIRABLE_ITEM).setValue(obj.getCustomItemTarget()); + value.getNode(REPAIRABLE_ITEM).setValue(obj.getItemMatch()); value.getNode(MAXIMUM_DURABILITY).setValue(obj.getMaximumDurability()); value.getNode(ITEMS_REQUIRED_TO_REPAIR).setValue(obj.getRepairTransaction()); diff --git a/src/main/java/com/gmail/nossr50/datatypes/items/CustomItemMatching.java b/src/main/java/com/gmail/nossr50/datatypes/items/CustomItemMatching.java deleted file mode 100644 index 827894b89..000000000 --- a/src/main/java/com/gmail/nossr50/datatypes/items/CustomItemMatching.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gmail.nossr50.datatypes.items; - -public interface CustomItemMatching { - - /** - * Determines whether or not an item matches this one - * Behaviours for matching can vary based on the implementation - * @param otherItem target item to compare itself to - * @return true if this item matches the target item - */ - boolean isMatch(MMOItem otherItem); - -} diff --git a/src/main/java/com/gmail/nossr50/datatypes/items/DefinedMatch.java b/src/main/java/com/gmail/nossr50/datatypes/items/DefinedMatch.java new file mode 100644 index 000000000..3186b20ef --- /dev/null +++ b/src/main/java/com/gmail/nossr50/datatypes/items/DefinedMatch.java @@ -0,0 +1,19 @@ +package com.gmail.nossr50.datatypes.items; + +/** + * The interface Defined match. + * + * @param the type parameter + */ +public interface DefinedMatch { + + /** + * Determines whether or not this object of type T matches certain criteria of another object of type T + * Behaviours for matching depend solely on the implementation of DefinedMatch + * + * @param other target item to compare itself to + * @return true if this item matches the target item + */ + boolean isMatch(T other); + +} diff --git a/src/main/java/com/gmail/nossr50/datatypes/items/CustomItemTarget.java b/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java similarity index 87% rename from src/main/java/com/gmail/nossr50/datatypes/items/CustomItemTarget.java rename to src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java index e36f198bf..223414ab8 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/items/CustomItemTarget.java +++ b/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java @@ -26,17 +26,17 @@ import java.util.Objects; * 1) Abstract away platform specific implementations of MC Items * 2) Contain information about an item and which properties of said item that are considered important and thus will be used to equate equivalency to another item when doing comparisons */ -public class CustomItemTarget implements CustomItemMatching { +public class ItemMatch> implements DefinedMatch { - private MMOItem item; //Abstract representation of the item + private T item; //Abstract representation of the item private HashSet itemMatchProperties; //Item properties used for matching - public CustomItemTarget(MMOItem item) { + public ItemMatch(T item) { this.item = item; itemMatchProperties = new HashSet<>(); } - public CustomItemTarget(MMOItem item, HashSet itemMatchProperties) { + public ItemMatch(T item, HashSet itemMatchProperties) { this.item = item; this.itemMatchProperties = itemMatchProperties; } @@ -56,7 +56,7 @@ public class CustomItemTarget implements CustomItemMatching { * @return true if this item matches the target item */ @Override - public boolean isMatch(MMOItem otherItem) { + public boolean isMatch(T otherItem) { if(hasStrictMatching()) { return isStrictMatch(otherItem); } else { @@ -69,7 +69,7 @@ public class CustomItemTarget implements CustomItemMatching { * @param otherItem item to strictly match * @return true if the items are considered a match */ - private boolean isStrictMatch(MMOItem otherItem) { + private boolean isStrictMatch(T otherItem) { for(ItemMatchProperty itemMatchProperty : itemMatchProperties) { if(!mcMMO.getNbtManager().hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) { return false; @@ -106,10 +106,10 @@ public class CustomItemTarget implements CustomItemMatching { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof CustomItemTarget)) return false; - CustomItemTarget that = (CustomItemTarget) o; - return getItem().equals(that.getItem()) && - getItemMatchProperties().equals(that.getItemMatchProperties()); + if (!(o instanceof ItemMatch)) return false; + ItemMatch itemMatch = (ItemMatch) o; + return getItem().equals(itemMatch.getItem()) && + getItemMatchProperties().equals(itemMatch.getItemMatchProperties()); } @Override diff --git a/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java b/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java index 87087e414..51985c956 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java +++ b/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.datatypes.items; -import org.bukkit.inventory.ItemStack; - import java.util.HashSet; import java.util.Objects; @@ -19,12 +17,13 @@ import java.util.Objects; * to solve a problem with Repair. Given its flexible nature it can be used for many purposes. * */ -public class ItemWildcards { +public class ItemWildcards> { private String wildcardName; - private HashSet itemTargets; + private HashSet> itemTargets; - public ItemWildcards(String wildcardName, HashSet itemTargets) { + public ItemWildcards(String wildcardName, HashSet> itemTargets) { + super(); this.wildcardName = wildcardName; this.itemTargets = itemTargets; } @@ -33,11 +32,11 @@ public class ItemWildcards { return itemTargets.size(); } - public HashSet getItemTargets() { + public HashSet> getItemTargets() { return itemTargets; } - public void setItemTargets(HashSet itemTargets) { + public void setItemTargets(HashSet> itemTargets) { this.itemTargets = itemTargets; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java index f04a08cf7..7b3ca983d 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.PlayerInventory; */ public interface RepairCost { + /** * Searches a player inventory for a matching ItemStack that can be used to pay for the repair transaction * @param playerInventory inventory of player attempting to pay the cost diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java index afb217611..e3ecc6f6c 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java @@ -22,8 +22,8 @@ import java.util.HashSet; public class RepairTransaction { private HashSet repairCosts; - public RepairTransaction() { - repairCosts = new HashSet<>(); + public RepairTransaction(HashSet repairCosts) { + this.repairCosts = repairCosts; } public void addRepairCost(RepairCost repairCost) { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java index aea366f0b..4f9e07dac 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java @@ -1,11 +1,13 @@ package com.gmail.nossr50.skills.repair; import com.gmail.nossr50.datatypes.items.BukkitMMOItem; -import com.gmail.nossr50.datatypes.items.CustomItemTarget; +import com.gmail.nossr50.datatypes.items.ItemMatch; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import java.util.List; + /** * Implementation of RepairCost * @@ -15,12 +17,12 @@ import org.bukkit.inventory.PlayerInventory; * This type is strictly for use with RepairTransaction, which represents the full cost of a Repair. * @see com.gmail.nossr50.skills.repair.RepairTransaction for more details */ -public class SimpleRepairCost implements RepairCost { +public class SimpleRepairCost implements RepairCost { - private CustomItemTarget desiredItemTarget; + private T itemMatch; - public SimpleRepairCost(CustomItemTarget customItemTarget) { - this.desiredItemTarget = customItemTarget; + public SimpleRepairCost(T customItemTarget) { + this.itemMatch = customItemTarget; } @Override @@ -31,14 +33,31 @@ public class SimpleRepairCost implements RepairCost { BukkitMMOItem playerInventoryItem = new BukkitMMOItem(itemStack); + //TODO: + //TODO: + //TODO: + //TODO: + //TODO: Write the code that compares playerInventoryItem with the + //TODO: + //TODO: + //TODO: + //TODO: + //TODO: + //TODO: + //TODO: + //If the item matches return it - if(desiredItemTarget.isMatch(playerInventoryItem)) + if(itemMatch.isMatch(playerInventoryItem)) return itemStack; } return null; } + public ItemMatch getItemMatch() { + return itemMatch; + } + @Override public boolean hasPayment(PlayerInventory playerInventory) { return findPayment(playerInventory) != null; 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 cc06c3ca6..823e2be09 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,27 +1,25 @@ package com.gmail.nossr50.skills.repair.repairables; -import com.gmail.nossr50.datatypes.items.CustomItemTarget; +import com.gmail.nossr50.datatypes.items.ItemMatch; import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; import com.gmail.nossr50.skills.repair.RepairTransaction; -import com.gmail.nossr50.util.nbt.RawNBT; -import org.bukkit.inventory.ItemStack; public class Repairable { private int minimumLevel; private short maximumDurability; private RepairTransaction repairTransaction; private int baseXP; - private CustomItemTarget customItemTarget; + private ItemMatch itemMatch; private int repairCount; private PermissionWrapper permissionWrapper; private boolean hasPermission = false; - public Repairable(CustomItemTarget customItemTarget, int minimumLevel, short maximumDurability, RepairTransaction repairTransaction, int baseXP, int repairCount, PermissionWrapper permissionWrapper) { + public Repairable(ItemMatch itemMatch, int minimumLevel, short maximumDurability, RepairTransaction repairTransaction, int baseXP, int repairCount, PermissionWrapper permissionWrapper) { this.minimumLevel = minimumLevel; this.maximumDurability = maximumDurability; this.repairTransaction = repairTransaction; this.baseXP = baseXP; - this.customItemTarget = customItemTarget; + this.itemMatch = itemMatch; this.repairCount = repairCount; this.permissionWrapper = permissionWrapper; @@ -61,12 +59,12 @@ public class Repairable { this.baseXP = baseXP; } - public CustomItemTarget getCustomItemTarget() { - return customItemTarget; + public ItemMatch getItemMatch() { + return itemMatch; } - public void setCustomItemTarget(CustomItemTarget customItemTarget) { - this.customItemTarget = customItemTarget; + public void setItemMatch(ItemMatch itemMatch) { + this.itemMatch = itemMatch; } public int getRepairCount() { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java index c6a4a7c57..6be7fbc20 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java @@ -1,10 +1,8 @@ package com.gmail.nossr50.skills.repair.repairables; -import com.gmail.nossr50.datatypes.items.CustomItemTarget; +import com.gmail.nossr50.datatypes.items.ItemMatch; import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; import com.gmail.nossr50.skills.repair.RepairTransaction; -import com.gmail.nossr50.util.nbt.RawNBT; -import org.bukkit.inventory.ItemStack; public class RepairableBuilder { @@ -12,12 +10,12 @@ public class RepairableBuilder { private short maximumDurability; private RepairTransaction repairTransaction; private int baseXP; - private CustomItemTarget customItemTarget; + private ItemMatch itemMatch; private int repairCount; private PermissionWrapper permissionWrapper; - public RepairableBuilder(CustomItemTarget customItemTarget, Short maximumDurability, RepairTransaction repairTransaction) { - this.customItemTarget = customItemTarget; + public RepairableBuilder(ItemMatch itemMatch, Short maximumDurability, RepairTransaction repairTransaction) { + this.itemMatch = itemMatch; this.maximumDurability = maximumDurability; this.repairTransaction = repairTransaction; } @@ -57,7 +55,7 @@ public class RepairableBuilder { } private Repairable makeRepairable() { - Repairable repairable = new Repairable(customItemTarget, minimumLevel, maximumDurability, repairTransaction, + Repairable repairable = new Repairable(itemMatch, minimumLevel, maximumDurability, repairTransaction, baseXP, repairCount, permissionWrapper); return repairable;