diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java b/mcmmo-core/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java index 0669bf00e..61d41f0bd 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java @@ -1,26 +1,26 @@ -package com.gmail.nossr50.bukkit; - -import com.gmail.nossr50.datatypes.items.BukkitMMOItem; -import com.gmail.nossr50.datatypes.items.MMOItem; -import com.gmail.nossr50.util.nbt.NBTManager; -import com.gmail.nossr50.util.nbt.RawNBT; -import org.bukkit.inventory.ItemStack; - -/** - * Used to convert or construct platform independent types into Bukkit types - */ -public class BukkitFactory { - - /** - * Creates a BukkitMMOItem which contains Bukkit implementations for the type MMOItem - * @return a new BukkitMMOItem - */ - public static MMOItem createItem(String namespaceKey, int amount, RawNBT rawNBT) { - return new BukkitMMOItem(namespaceKey, amount, rawNBT); - } - - public static MMOItem createItem(ItemStack itemStack) { - return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(NBTManager.getNBT(itemStack).toString())); - } - -} +//package com.gmail.nossr50.bukkit; +// +//import com.gmail.nossr50.datatypes.items.BukkitMMOItem; +//import com.gmail.nossr50.datatypes.items.MMOItem; +//import com.gmail.nossr50.util.nbt.NBTManager; +//import com.gmail.nossr50.util.nbt.RawNBT; +//import org.bukkit.inventory.ItemStack; +// +///** +// * Used to convert or construct platform independent types into Bukkit types +// */ +//public class BukkitFactory { +// +// /** +// * Creates a BukkitMMOItem which contains Bukkit implementations for the type MMOItem +// * @return a new BukkitMMOItem +// */ +// public static MMOItem createItem(String namespaceKey, int amount, RawNBT rawNBT) { +// return new BukkitMMOItem(namespaceKey, amount, rawNBT); +// } +// +// public static MMOItem createItem(ItemStack itemStack) { +// return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(NBTManager.getNBT(itemStack).toString())); +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 8446ef64d..ff8cb0bb4 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -48,20 +48,13 @@ import com.gmail.nossr50.config.superabilities.ConfigSuperAbilities; import com.gmail.nossr50.config.worldblacklist.ConfigWorldBlacklist; import com.gmail.nossr50.datatypes.experience.CustomXPPerk; import com.gmail.nossr50.datatypes.experience.FormulaType; -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; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.properties.DamageProperty; import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel; import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.skills.repair.RepairTransaction; -import com.gmail.nossr50.skills.repair.SimpleRepairCost; -import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; -import com.gmail.nossr50.util.nbt.RawNBT; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection; @@ -258,14 +251,14 @@ public final class ConfigManager { customSerializers.registerType(new TypeToken() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken() {}, new CustomEnumValueSerializer()); - customSerializers.registerType(new TypeToken>() {}, new ItemStackSerializer()); +// customSerializers.registerType(new TypeToken>() {}, new ItemStackSerializer()); customSerializers.registerType(new TypeToken>() {}, new SetSerializer()); - customSerializers.registerType(new TypeToken>() {}, new CustomItemTargetSerializer()); - customSerializers.registerType(new TypeToken() {}, new SimpleRepairCostSerializer()); +// customSerializers.registerType(new TypeToken>() {}, new CustomItemTargetSerializer()); +// customSerializers.registerType(new TypeToken() {}, new SimpleRepairCostSerializer()); customSerializers.registerType(TypeToken.of(TamingSummon.class), new TamingSummonSerializer()); - customSerializers.registerType(TypeToken.of(Repairable.class), new RepairableSerializer()); +// customSerializers.registerType(TypeToken.of(Repairable.class), new RepairableSerializer()); customSerializers.registerType(TypeToken.of(Salvageable.class), new SalvageableSerializer()); customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer()); customSerializers.registerType(TypeToken.of(CustomXPPerk.class), new CustomXPPerkSerializer()); @@ -274,9 +267,9 @@ 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(ItemWildcards.class), new ItemWildcardSerializer()); - customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer()); - customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer()); +// customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer()); +// customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer()); +// customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer()); } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/CustomItemTargetSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/CustomItemTargetSerializer.java index 16f3d153d..cfc146c26 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/CustomItemTargetSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/CustomItemTargetSerializer.java @@ -1,43 +1,43 @@ -package com.gmail.nossr50.config.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 = "Target-Item"; - 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."); - } - } -} +//package com.gmail.nossr50.config.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 = "Target-Item"; +// 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/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemStackSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemStackSerializer.java index 259dc5366..44a9744f5 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemStackSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemStackSerializer.java @@ -1,60 +1,60 @@ -package com.gmail.nossr50.config.serializers; - -import com.gmail.nossr50.datatypes.items.BukkitMMOItem; -import com.gmail.nossr50.datatypes.items.MMOItem; -import com.gmail.nossr50.util.nbt.RawNBT; -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.Material; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -public class ItemStackSerializer implements TypeSerializer> { - - private static final String ITEM_MINECRAFT_NAME = "Item-Name"; - private static final String AMOUNT = "Amount"; - private static final String NBT = "NBT"; - - @Nullable - @Override - public MMOItem deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { - String itemIdentifier = value.getNode(ITEM_MINECRAFT_NAME).getValue(TypeToken.of(String.class)); - - Material itemMatch = Material.matchMaterial(itemIdentifier); - - if(itemMatch == null) { - System.out.println("[mcMMO Deserializer Debug] Could not find a match for "+itemIdentifier); - return null; - } - - ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); - - Integer amount; - //Get the amount of items in the stack - if(itemNode.getNode(AMOUNT).getValueType() != ValueType.NULL) { - amount = itemNode.getNode(AMOUNT).getValue(TypeToken.of(Integer.class)); - } else { - amount = 1; - } - - RawNBT rawNBT = null; - - if(itemNode.getNode(NBT).getValueType() != ValueType.NULL) { - rawNBT = value.getNode(NBT).getValue(TypeToken.of(RawNBT.class)); - } - - return new BukkitMMOItem(itemIdentifier, amount, rawNBT); - } - - @Override - public void serialize(@NonNull TypeToken type, @Nullable MMOItem obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); - value.getNode(ITEM_MINECRAFT_NAME).setValue(obj.getNamespaceKey()); - itemNode.getNode(AMOUNT).setValue(obj.getItemAmount()); - itemNode.getNode(NBT).setValue(obj.getRawNBT()); - } - -} +//package com.gmail.nossr50.config.serializers; +// +//import com.gmail.nossr50.datatypes.items.BukkitMMOItem; +//import com.gmail.nossr50.datatypes.items.MMOItem; +//import com.gmail.nossr50.util.nbt.RawNBT; +//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.Material; +//import org.checkerframework.checker.nullness.qual.NonNull; +//import org.checkerframework.checker.nullness.qual.Nullable; +// +//public class ItemStackSerializer implements TypeSerializer> { +// +// private static final String ITEM_MINECRAFT_NAME = "Item-Name"; +// private static final String AMOUNT = "Amount"; +// private static final String NBT = "NBT"; +// +// @Nullable +// @Override +// public MMOItem deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { +// String itemIdentifier = value.getNode(ITEM_MINECRAFT_NAME).getValue(TypeToken.of(String.class)); +// +// Material itemMatch = Material.matchMaterial(itemIdentifier); +// +// if(itemMatch == null) { +// System.out.println("[mcMMO Deserializer Debug] Could not find a match for "+itemIdentifier); +// return null; +// } +// +// ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); +// +// Integer amount; +// //Get the amount of items in the stack +// if(itemNode.getNode(AMOUNT).getValueType() != ValueType.NULL) { +// amount = itemNode.getNode(AMOUNT).getValue(TypeToken.of(Integer.class)); +// } else { +// amount = 1; +// } +// +// RawNBT rawNBT = null; +// +// if(itemNode.getNode(NBT).getValueType() != ValueType.NULL) { +// rawNBT = value.getNode(NBT).getValue(TypeToken.of(RawNBT.class)); +// } +// +// return new BukkitMMOItem(itemIdentifier, amount, rawNBT); +// } +// +// @Override +// public void serialize(@NonNull TypeToken type, @Nullable MMOItem obj, @NonNull ConfigurationNode value) throws ObjectMappingException { +// ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); +// value.getNode(ITEM_MINECRAFT_NAME).setValue(obj.getNamespaceKey()); +// itemNode.getNode(AMOUNT).setValue(obj.getItemAmount()); +// itemNode.getNode(NBT).setValue(obj.getRawNBT()); +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemWildcardSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemWildcardSerializer.java index 8a50cd8c8..a6c25be15 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemWildcardSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/ItemWildcardSerializer.java @@ -1,42 +1,42 @@ -package com.gmail.nossr50.config.serializers; - -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.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -import java.util.HashSet; -import java.util.Set; - -public class ItemWildcardSerializer implements TypeSerializer { - - private static final String WILDCARD_IDENTIFIER_NAME = "Wildcard-Identifier-Name"; - private static final String MATCHING_ITEMS = "Matching-Items"; - - @Nullable - @Override - public ItemWildcards 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 ItemWildcards(wildCardName, new HashSet<>(matchCandidates)); - } - - return null; - } - - @Override - public void serialize(@NonNull TypeToken type, @Nullable ItemWildcards obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - value.getNode(WILDCARD_IDENTIFIER_NAME).setValue(obj.getWildcardName()); - value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).setValue(obj.getItemTargets()); - } - -} +//package com.gmail.nossr50.config.serializers; +// +//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.checkerframework.checker.nullness.qual.NonNull; +//import org.checkerframework.checker.nullness.qual.Nullable; +// +//import java.util.HashSet; +//import java.util.Set; +// +//public class ItemWildcardSerializer implements TypeSerializer { +// +// private static final String WILDCARD_IDENTIFIER_NAME = "Wildcard-Identifier-Name"; +// private static final String MATCHING_ITEMS = "Matching-Items"; +// +// @Nullable +// @Override +// public ItemWildcards 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 ItemWildcards(wildCardName, new HashSet<>(matchCandidates)); +// } +// +// return null; +// } +// +// @Override +// public void serialize(@NonNull TypeToken type, @Nullable ItemWildcards obj, @NonNull ConfigurationNode value) throws ObjectMappingException { +// value.getNode(WILDCARD_IDENTIFIER_NAME).setValue(obj.getWildcardName()); +// value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).setValue(obj.getItemTargets()); +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RawNBTSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RawNBTSerializer.java index 1f94e1540..146893845 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RawNBTSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RawNBTSerializer.java @@ -1,27 +1,27 @@ -package com.gmail.nossr50.config.serializers; - -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 org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; - -public class RawNBTSerializer implements TypeSerializer { - - private static final String NBT = "NBT"; - - @Nullable - @Override - public RawNBT deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { - String nbtString = value.getNode(NBT).getValue(TypeToken.of(String.class)); - return new RawNBT(nbtString); - } - - @Override - public void serialize(@NonNull TypeToken type, @Nullable RawNBT obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - value.getNode(NBT).setValue(obj.getNbtContents()); - } - -} +//package com.gmail.nossr50.config.serializers; +// +//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 org.checkerframework.checker.nullness.qual.NonNull; +//import org.checkerframework.checker.nullness.qual.Nullable; +// +//public class RawNBTSerializer implements TypeSerializer { +// +// private static final String NBT = "NBT"; +// +// @Nullable +// @Override +// public RawNBT deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { +// String nbtString = value.getNode(NBT).getValue(TypeToken.of(String.class)); +// return new RawNBT(nbtString); +// } +// +// @Override +// public void serialize(@NonNull TypeToken type, @Nullable RawNBT obj, @NonNull ConfigurationNode value) throws ObjectMappingException { +// value.getNode(NBT).setValue(obj.getNbtContents()); +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairTransactionSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairTransactionSerializer.java index 3a5c16984..d0429e491 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairTransactionSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairTransactionSerializer.java @@ -1,22 +1,22 @@ -package com.gmail.nossr50.config.serializers; - -import com.gmail.nossr50.skills.repair.RepairTransaction; -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 RepairTransactionSerializer implements TypeSerializer { - @Nullable - @Override - public RepairTransaction deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { - return null; - } - - @Override - public void serialize(@NonNull TypeToken type, @Nullable RepairTransaction obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - - } -} +//package com.gmail.nossr50.config.serializers; +// +//import com.gmail.nossr50.skills.repair.RepairTransaction; +//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 RepairTransactionSerializer implements TypeSerializer { +// @Nullable +// @Override +// public RepairTransaction deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { +// return null; +// } +// +// @Override +// public void serialize(@NonNull TypeToken type, @Nullable RepairTransaction obj, @NonNull ConfigurationNode value) throws ObjectMappingException { +// +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairableSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairableSerializer.java index a72932b2d..11f554614 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairableSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/RepairableSerializer.java @@ -1,79 +1,79 @@ -package com.gmail.nossr50.config.serializers; - -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; -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.objectmapping.ObjectMappingException; -import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; - -public class RepairableSerializer implements TypeSerializer { - private static final String REPAIRABLE_ITEM = "Repairable-Item"; - private static final String MAXIMUM_DURABILITY = "Maximum-Durability"; - private static final String ITEMS_REQUIRED_TO_REPAIR = "Items-Required-To-Repair"; - private static final String SKILL_LEVEL_REQUIRED_TO_REPAIR = "Skill-Level-Required-To-Repair"; - private static final String BASE_XP_REWARD = "Base-XP-Reward"; - private static final String BASE_REPAIR_COUNT = "Base-Repair-Count"; - private static final String REQUIRED_PERMISSION_NODE = "Required-Permission-Node"; - - @Override - public Repairable deserialize(TypeToken type, ConfigurationNode value) throws ObjectMappingException { - /* Necessary fields */ - 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(itemMatch, maximumDurability, repairTransaction); - - if(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getValueType() != ValueType.NULL) { - repairableBuilder.addMinLevel(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getInt()); - } - - if(value.getNode(BASE_XP_REWARD).getValueType() != ValueType.NULL) { - repairableBuilder.setBaseXP(value.getNode(BASE_XP_REWARD).getInt()); - } - - if(value.getNode(BASE_REPAIR_COUNT).getValueType() != ValueType.NULL) { - repairableBuilder.setRepairCount(value.getNode(BASE_REPAIR_COUNT).getInt()); - } - - if(value.getNode(REQUIRED_PERMISSION_NODE).getValueType() != ValueType.NULL) { - repairableBuilder.addPermissionWrapper(value.getNode(REQUIRED_PERMISSION_NODE).getValue(TypeToken.of(PermissionWrapper.class))); - } - - return repairableBuilder.build(); - } - - @Override - public void serialize(TypeToken type, Repairable obj, ConfigurationNode value) { - value.getNode(REPAIRABLE_ITEM).setValue(obj.getItemMatch()); - value.getNode(MAXIMUM_DURABILITY).setValue(obj.getMaximumDurability()); - value.getNode(ITEMS_REQUIRED_TO_REPAIR).setValue(obj.getRepairTransaction()); - - if(obj.getMinimumLevel() > 0) { - value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).setValue(obj.getMinimumLevel()); - } - - if(obj.getBaseXP() != 0) { - value.getNode(BASE_XP_REWARD).setValue(obj.getBaseXP()); - SerializerUtil.addCommentIfCompatible(value.getNode(BASE_XP_REWARD), "The minimum amount of XP to reward a player when they repair this item."); - } - - if(obj.getRepairCount() != 0) { - value.getNode(BASE_REPAIR_COUNT).setValue(obj.getRepairCount()); - SerializerUtil.addCommentIfCompatible(value.getNode(BASE_REPAIR_COUNT), "How many times it should take a player to repair this item from fully damaged to brand new without any skill in Repair." + - "\nThis value is used in calculating how much damage to remove from an item, typically you want this to be at least equal to the number of mats used to craft the item."); - } - - if(obj.getPermissionWrapper() != null) { - value.getNode(REQUIRED_PERMISSION_NODE).setValue(obj.getPermissionWrapper()); - SerializerUtil.addCommentIfCompatible(value.getNode(REQUIRED_PERMISSION_NODE), "A custom permission node required to repair this item." + - "\nThis setting is optional."); - } - } - -} +//package com.gmail.nossr50.config.serializers; +// +//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; +//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.objectmapping.ObjectMappingException; +//import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; +// +//public class RepairableSerializer implements TypeSerializer { +// private static final String REPAIRABLE_ITEM = "Repairable-Item"; +// private static final String MAXIMUM_DURABILITY = "Maximum-Durability"; +// private static final String ITEMS_REQUIRED_TO_REPAIR = "Items-Required-To-Repair"; +// private static final String SKILL_LEVEL_REQUIRED_TO_REPAIR = "Skill-Level-Required-To-Repair"; +// private static final String BASE_XP_REWARD = "Base-XP-Reward"; +// private static final String BASE_REPAIR_COUNT = "Base-Repair-Count"; +// private static final String REQUIRED_PERMISSION_NODE = "Required-Permission-Node"; +// +// @Override +// public Repairable deserialize(TypeToken type, ConfigurationNode value) throws ObjectMappingException { +// /* Necessary fields */ +// 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(itemMatch, maximumDurability, repairTransaction); +// +// if(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getValueType() != ValueType.NULL) { +// repairableBuilder.addMinLevel(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getInt()); +// } +// +// if(value.getNode(BASE_XP_REWARD).getValueType() != ValueType.NULL) { +// repairableBuilder.setBaseXP(value.getNode(BASE_XP_REWARD).getInt()); +// } +// +// if(value.getNode(BASE_REPAIR_COUNT).getValueType() != ValueType.NULL) { +// repairableBuilder.setRepairCount(value.getNode(BASE_REPAIR_COUNT).getInt()); +// } +// +// if(value.getNode(REQUIRED_PERMISSION_NODE).getValueType() != ValueType.NULL) { +// repairableBuilder.addPermissionWrapper(value.getNode(REQUIRED_PERMISSION_NODE).getValue(TypeToken.of(PermissionWrapper.class))); +// } +// +// return repairableBuilder.build(); +// } +// +// @Override +// public void serialize(TypeToken type, Repairable obj, ConfigurationNode value) { +// value.getNode(REPAIRABLE_ITEM).setValue(obj.getItemMatch()); +// value.getNode(MAXIMUM_DURABILITY).setValue(obj.getMaximumDurability()); +// value.getNode(ITEMS_REQUIRED_TO_REPAIR).setValue(obj.getRepairTransaction()); +// +// if(obj.getMinimumLevel() > 0) { +// value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).setValue(obj.getMinimumLevel()); +// } +// +// if(obj.getBaseXP() != 0) { +// value.getNode(BASE_XP_REWARD).setValue(obj.getBaseXP()); +// SerializerUtil.addCommentIfCompatible(value.getNode(BASE_XP_REWARD), "The minimum amount of XP to reward a player when they repair this item."); +// } +// +// if(obj.getRepairCount() != 0) { +// value.getNode(BASE_REPAIR_COUNT).setValue(obj.getRepairCount()); +// SerializerUtil.addCommentIfCompatible(value.getNode(BASE_REPAIR_COUNT), "How many times it should take a player to repair this item from fully damaged to brand new without any skill in Repair." + +// "\nThis value is used in calculating how much damage to remove from an item, typically you want this to be at least equal to the number of mats used to craft the item."); +// } +// +// if(obj.getPermissionWrapper() != null) { +// value.getNode(REQUIRED_PERMISSION_NODE).setValue(obj.getPermissionWrapper()); +// SerializerUtil.addCommentIfCompatible(value.getNode(REQUIRED_PERMISSION_NODE), "A custom permission node required to repair this item." + +// "\nThis setting is optional."); +// } +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/SimpleRepairCostSerializer.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/SimpleRepairCostSerializer.java index 902eab9f2..a280b9b68 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/SimpleRepairCostSerializer.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/serializers/SimpleRepairCostSerializer.java @@ -1,28 +1,28 @@ -package com.gmail.nossr50.config.serializers; - -import com.gmail.nossr50.datatypes.items.ItemMatch; -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 SimpleRepairCostSerializer implements TypeSerializer { - - private static final String ITEM_MATCH = "Item-Match"; - - @Nullable - @Override - public SimpleRepairCost deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { - ItemMatch itemMatch = value.getNode(ITEM_MATCH).getValue(new TypeToken>() {}); - SimpleRepairCost simpleRepairCost = new SimpleRepairCost<>(itemMatch); - return simpleRepairCost; - } - - @Override - public void serialize(@NonNull TypeToken type, @Nullable SimpleRepairCost obj, @NonNull ConfigurationNode value) throws ObjectMappingException { - value.getNode(ITEM_MATCH).setValue(obj.getItemMatch()); - } -} +//package com.gmail.nossr50.config.serializers; +// +//import com.gmail.nossr50.datatypes.items.ItemMatch; +//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 SimpleRepairCostSerializer implements TypeSerializer { +// +// private static final String ITEM_MATCH = "Item-Match"; +// +// @Nullable +// @Override +// public SimpleRepairCost deserialize(@NonNull TypeToken type, @NonNull ConfigurationNode value) throws ObjectMappingException { +// ItemMatch itemMatch = value.getNode(ITEM_MATCH).getValue(new TypeToken>() {}); +// SimpleRepairCost simpleRepairCost = new SimpleRepairCost<>(itemMatch); +// return simpleRepairCost; +// } +// +// @Override +// public void serialize(@NonNull TypeToken type, @Nullable SimpleRepairCost obj, @NonNull ConfigurationNode value) throws ObjectMappingException { +// value.getNode(ITEM_MATCH).setValue(obj.getItemMatch()); +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/repair/ConfigRepair.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/repair/ConfigRepair.java index c308258fd..27b040abe 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/repair/ConfigRepair.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/repair/ConfigRepair.java @@ -4,42 +4,27 @@ import com.gmail.nossr50.config.ConfigConstants; import com.gmail.nossr50.config.skills.repair.general.ConfigRepairGeneral; import com.gmail.nossr50.config.skills.repair.repairmastery.ConfigRepairRepairMastery; import com.gmail.nossr50.config.skills.repair.subskills.ConfigRepairSubSkills; -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.skills.repair.RepairCost; -import com.gmail.nossr50.skills.repair.RepairTransaction; -import com.gmail.nossr50.skills.repair.SimpleRepairCost; -import com.gmail.nossr50.skills.repair.repairables.Repairable; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - -import static org.bukkit.Material.*; @ConfigSerializable public class ConfigRepair { - public static final ArrayList CONFIG_REPAIRABLES_DEFAULTS; - public static final HashSet REPAIR_WILDCARDS_DEFAULTS; +// 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}; static { - REPAIR_WILDCARDS_DEFAULTS = new HashSet<>(); +// 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)}); +// ItemWildcards planksWildCard = new ItemWildcards("Planks", new HashSet<>(planksList)); +// REPAIR_WILDCARDS_DEFAULTS.add(planksWildCard); - 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)}); - ItemWildcards planksWildCard = new ItemWildcards("Planks", new HashSet<>(planksList)); - REPAIR_WILDCARDS_DEFAULTS.add(planksWildCard); - - CONFIG_REPAIRABLES_DEFAULTS = new ArrayList<>(); +// CONFIG_REPAIRABLES_DEFAULTS = new ArrayList<>(); //TODO: Make a builder //TODO: Make a builder @@ -48,30 +33,30 @@ public class ConfigRepair { //TODO: Make a builder //Diamond chestplate - ItemStack diamondArmorItemStack; - BukkitMMOItem diamondArmorMMOItem = new BukkitMMOItem<>(DIAMOND_CHESTPLATE.getKey().toString(), 1, null); - ItemMatch> diamondArmorItemMatch = new ItemMatch<>(diamondArmorMMOItem, null); - - //Diamond Ore - BukkitMMOItem diamondOre = new BukkitMMOItem<>(DIAMOND.getKey().toString(), 1, null); - ItemMatch> diamondOreItemMatch = new ItemMatch<>(diamondArmorMMOItem, null); - - //Repair Cost(s) - SimpleRepairCost diamondArmorRepairCost = new SimpleRepairCost(diamondOreItemMatch); //Just diamonds - - //Repair Cost Hash Set - HashSet diamondArmorRepairCosts = new HashSet<>(); - diamondArmorRepairCosts.add(diamondArmorRepairCost); //Only costs 1 item - - RepairTransaction repairTransaction = new RepairTransaction(diamondArmorRepairCosts); - Repairable diamondArmor = new Repairable(diamondArmorItemMatch, 0, diamondArmorMMOItem.getItemImplementation().getType().getMaxDurability(), repairTransaction, 1000, 10, null); +// ItemStack diamondArmorItemStack; +// BukkitMMOItem diamondArmorMMOItem = new BukkitMMOItem<>(DIAMOND_CHESTPLATE.getKey().toString(), 1, null); +// ItemMatch> diamondArmorItemMatch = new ItemMatch<>(diamondArmorMMOItem, null); +// +// //Diamond Ore +// BukkitMMOItem diamondOre = new BukkitMMOItem<>(DIAMOND.getKey().toString(), 1, null); +// ItemMatch> diamondOreItemMatch = new ItemMatch<>(diamondArmorMMOItem, null); +// +// //Repair Cost(s) +// SimpleRepairCost diamondArmorRepairCost = new SimpleRepairCost(diamondOreItemMatch); //Just diamonds +// +// //Repair Cost Hash Set +// HashSet diamondArmorRepairCosts = new HashSet<>(); +// diamondArmorRepairCosts.add(diamondArmorRepairCost); //Only costs 1 item +// +// RepairTransaction repairTransaction = new RepairTransaction(diamondArmorRepairCosts); +// Repairable diamondArmor = new Repairable(diamondArmorItemMatch, 0, diamondArmorMMOItem.getItemImplementation().getType().getMaxDurability(), repairTransaction, 1000, 10, null); //TODO: ^ Make a builder //TODO: ^ Make a builder //TODO: ^ Make a builder //TODO: ^ Make a builder - CONFIG_REPAIRABLES_DEFAULTS.add(diamondArmor); +// CONFIG_REPAIRABLES_DEFAULTS.add(diamondArmor); // 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)); @@ -129,20 +114,20 @@ public class ConfigRepair { @Setting(value = ConfigConstants.SUB_SKILL_NODE, comment = "Settings for subskills stemming from Repair") private ConfigRepairSubSkills repairSubSkills = new ConfigRepairSubSkills(); - @Setting(value = "Z-Repairables", comment = "This is the list of what can be repaired in mcMMO by Anvils and their properties." + - "\nThe \"Z\" in this config keys name is literally just to place this at the bottom of the config since the serializer uses alphabetical sorting." + - "\n\n -- Explanation for Parameters --" + - "\nItem: The name of the item, this has to be equivalent to the internal registry key (Name ID) Minecraft uses for this item" + - "\nItems-Used-To-Repair: The name of the item consumed as part of repairing, this has to be equivalent to the internal registry key (Name ID) Minecraft uses for this item" + - "\nMinimum-Quantity-Used-To-Repair: The amount of this item that is required to repair this item at a minimum." + - "\nOverride-Level-Requirement: If you would like to specify a specific skill level required to repair an item, do it here. It should be noted that a lot of items will be given automatic level requirements if you leave this at zero." + - "\nXP-Multiplier: When calculating how much XP to give the player for the repair, the end result will be multiplied by this value." + - "\n\nName ID List: https://minecraft.gamepedia.com/Java_Edition_data_values" + - "\nTIP: You can omit \"minecraft:\" from the Name ID if you want to, for example you can write \"red_wool\" instead of \"minecraft:red_wool\"") - private ArrayList configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS; +// @Setting(value = "Z-Repairables", comment = "This is the list of what can be repaired in mcMMO by Anvils and their properties." + +// "\nThe \"Z\" in this config keys name is literally just to place this at the bottom of the config since the serializer uses alphabetical sorting." + +// "\n\n -- Explanation for Parameters --" + +// "\nItem: The name of the item, this has to be equivalent to the internal registry key (Name ID) Minecraft uses for this item" + +// "\nItems-Used-To-Repair: The name of the item consumed as part of repairing, this has to be equivalent to the internal registry key (Name ID) Minecraft uses for this item" + +// "\nMinimum-Quantity-Used-To-Repair: The amount of this item that is required to repair this item at a minimum." + +// "\nOverride-Level-Requirement: If you would like to specify a specific skill level required to repair an item, do it here. It should be noted that a lot of items will be given automatic level requirements if you leave this at zero." + +// "\nXP-Multiplier: When calculating how much XP to give the player for the repair, the end result will be multiplied by this value." + +// "\n\nName ID List: https://minecraft.gamepedia.com/Java_Edition_data_values" + +// "\nTIP: You can omit \"minecraft:\" from the Name ID if you want to, for example you can write \"red_wool\" instead of \"minecraft:red_wool\"") +// private ArrayList configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS; - @Setting(value = "Z-Repairables-Wildcards", comment = "Used to define an alias that can be matched to several materials.") - private HashSet itemWildcards = new HashSet<>(); +// @Setting(value = "Z-Repairables-Wildcards", comment = "Used to define an alias that can be matched to several materials.") +// private HashSet itemWildcards = new HashSet<>(); public ConfigRepairGeneral getRepairGeneral() { return repairGeneral; @@ -164,11 +149,11 @@ public class ConfigRepair { return repairSubSkills.getArcaneForging(); } - public ArrayList getConfigRepairablesList() { - return configRepairablesList; - } +// public ArrayList getConfigRepairablesList() { +// return configRepairablesList; +// } - public HashSet getItemWildcards() { - return itemWildcards; - } +// public HashSet getItemWildcards() { +// return itemWildcards; +// } } \ No newline at end of file diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java index 6b202df56..f1c5b04cb 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java @@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.behaviours.SkillBehaviourManager; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.skills.repair.repairables.Repairable; -import com.gmail.nossr50.skills.repair.repairables.RepairableManager; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; import com.gmail.nossr50.util.experience.ExperienceManager; @@ -31,7 +29,7 @@ public class DynamicSettingsManager { private SkillPropertiesManager skillPropertiesManager; /* COLLECTION MANAGERS */ - private RepairableManager repairableManager; +// private RepairableManager repairableManager; private SalvageableManager salvageableManager; /* Platform Ready Managers */ @@ -113,7 +111,7 @@ public class DynamicSettingsManager { */ private void initCollectionManagers() { // Handles registration of repairables - repairableManager = new RepairableManager(getRepairables()); +// repairableManager = new RepairableManager(getRepairables()); // Handles registration of salvageables salvageableManager = new SalvageableManager(getSalvageables()); @@ -130,9 +128,9 @@ public class DynamicSettingsManager { * * @return the currently loaded repairables */ - public ArrayList getRepairables() { - return pluginRef.getConfigManager().getConfigRepair().getConfigRepairablesList(); - } +// public ArrayList getRepairables() { +// return pluginRef.getConfigManager().getConfigRepair().getConfigRepairablesList(); +// } /** * Get all loaded salvageables (loaded from all salvageable configs) @@ -152,9 +150,9 @@ public class DynamicSettingsManager { // bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops()); } - public RepairableManager getRepairableManager() { - return repairableManager; - } +// public RepairableManager getRepairableManager() { +// return repairableManager; +// } public SalvageableManager getSalvageableManager() { return salvageableManager; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/BukkitMMOItem.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/BukkitMMOItem.java index 5fe411e8e..5ad6461c1 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/BukkitMMOItem.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/BukkitMMOItem.java @@ -1,63 +1,63 @@ -package com.gmail.nossr50.datatypes.items; - -import com.gmail.nossr50.util.nbt.RawNBT; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class BukkitMMOItem implements MMOItem { - - private T itemImplementation; - private RawNBT rawNBT; - - //Suppressed because the type is always an ItemStack - @SuppressWarnings("unchecked") - public BukkitMMOItem(String namespaceKey, int amount, RawNBT rawNBT) throws NullPointerException { - T itemStack; - Material material = Material.matchMaterial(namespaceKey); - - if(material == null) { - throw new NullPointerException("Material for user defined item could not be found in the server software."); - } - - itemStack = (T) new ItemStack(material); - - //Get default item meta - ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(itemStack.getType()); - - //Set default item meta - itemStack.setItemMeta(itemMeta); - - //Set amount - itemStack.setAmount(amount); - - this.itemImplementation = itemStack; - this.rawNBT = rawNBT; - } - - public BukkitMMOItem(T itemStack) { - this.itemImplementation = itemStack; - } - - @Override - public T getItemImplementation() { - return itemImplementation; - } - - @Override - public String getNamespaceKey() { - return itemImplementation.getType().getKey().toString(); - } - - @Override - public int getItemAmount() { - return itemImplementation.getAmount(); - } - - @Override - public RawNBT getRawNBT() { - return rawNBT; - } - -} +//package com.gmail.nossr50.datatypes.items; +// +//import com.gmail.nossr50.util.nbt.RawNBT; +//import org.bukkit.Bukkit; +//import org.bukkit.Material; +//import org.bukkit.inventory.ItemStack; +//import org.bukkit.inventory.meta.ItemMeta; +// +//public class BukkitMMOItem implements MMOItem { +// +// private T itemImplementation; +// private RawNBT rawNBT; +// +// //Suppressed because the type is always an ItemStack +// @SuppressWarnings("unchecked") +// public BukkitMMOItem(String namespaceKey, int amount, RawNBT rawNBT) throws NullPointerException { +// T itemStack; +// Material material = Material.matchMaterial(namespaceKey); +// +// if(material == null) { +// throw new NullPointerException("Material for user defined item could not be found in the server software."); +// } +// +// itemStack = (T) new ItemStack(material); +// +// //Get default item meta +// ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(itemStack.getType()); +// +// //Set default item meta +// itemStack.setItemMeta(itemMeta); +// +// //Set amount +// itemStack.setAmount(amount); +// +// this.itemImplementation = itemStack; +// this.rawNBT = rawNBT; +// } +// +// public BukkitMMOItem(T itemStack) { +// this.itemImplementation = itemStack; +// } +// +// @Override +// public T getItemImplementation() { +// return itemImplementation; +// } +// +// @Override +// public String getNamespaceKey() { +// return itemImplementation.getType().getKey().toString(); +// } +// +// @Override +// public int getItemAmount() { +// return itemImplementation.getAmount(); +// } +// +// @Override +// public RawNBT getRawNBT() { +// return rawNBT; +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java index c594cfcb8..e2a956a84 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java @@ -1,128 +1,128 @@ -package com.gmail.nossr50.datatypes.items; - -import com.gmail.nossr50.util.nbt.NBTManager; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * This type contains data and rules which govern equating equivalency between one item and another in Minecraft. - * - * In mcMMO it is sometimes needed to match one item to another, but items contain a lot of metadata - * Some of this metadata is important, some of it isn't, and whether something is important or not when - * considering two items to be similar enough to be considered matching items is not strictly defined and is in fact different from server to server. - * - * mcMMO employs a flexible system where users can define which properties of an items metadata (often its NBT) - * are important for matching and mcMMO will respect those properties when comparing one item to another. - * - * If a user does not define a property as being important for matching mcMMO will ignore that property when matching - * two or more items, even if that property is not equivalent between the items. This type will contain information - * on which properties are to be considered important for matching purposes. - * - * The main goal of this system is accommodate for the vast majority of custom item modifications a server can employ, - * these custom items are often defined in irregular ways server to server, thus why this type was made. - * - * In summary, this type serves several purposes... - * 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 ItemMatch> implements DefinedMatch> { - - private T item; //Abstract representation of the item - private Set itemMatchProperties; //Item properties used for matching - - public ItemMatch(T item) { - this.item = item; - itemMatchProperties = new HashSet<>(); - } - - public ItemMatch(T item, Set itemMatchProperties) { - this.item = item; - this.itemMatchProperties = itemMatchProperties; - } - - /** - * Gets the item held by this ItemMatch - * @return the item used for matching - */ - public T getItem() { - return item; - } - - /** - * Get the item match properties of this ItemMatch - * @return the item match properties - */ - public Set getItemMatchProperties() { - return itemMatchProperties; - } - - /** - * 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 - */ - @Override - public boolean isMatch(MMOItem otherItem) { - if(hasStrictMatching()) { - return isStrictMatch(otherItem); - } else { - return isUnstrictMatch(otherItem); - } - } - - /** - * Compare this item to another while comparing specific nbt tags for matching values, if all values are found and match it is considered a strict match - * @param otherItem item to strictly match - * @return true if the items are considered a match - */ - private boolean isStrictMatch(MMOItem otherItem) { - for(ItemMatchProperty itemMatchProperty : itemMatchProperties) { - if(!NBTManager.hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) { - return false; - } - } - - //All item match properties were found and matched - return true; - } - - /** - * Compare this item to another only by namespace key - * @param otherItem item to compare namespace keys with - * @return true if the items share namespace keys - */ - private boolean isUnstrictMatch(MMOItem otherItem) { - if(otherItem.getNamespaceKey().equalsIgnoreCase(item.getNamespaceKey())) { - return true; - } - - //Namespace didn't match reject item - return false; - } - - /** - * If this item has strict matching or loose match - * Solely determined by having any item match properties present - * @return true if this item target has strict matching - */ - public boolean hasStrictMatching() { - return itemMatchProperties.size() > 1; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ItemMatch)) return false; - ItemMatch itemMatch = (ItemMatch) o; - return getItem().equals(itemMatch.getItem()) && - getItemMatchProperties().equals(itemMatch.getItemMatchProperties()); - } - - @Override - public int hashCode() { - return Objects.hash(getItem(), getItemMatchProperties()); - } -} +//package com.gmail.nossr50.datatypes.items; +// +//import com.gmail.nossr50.util.nbt.NBTManager; +// +//import java.util.HashSet; +//import java.util.Objects; +//import java.util.Set; +// +///** +// * This type contains data and rules which govern equating equivalency between one item and another in Minecraft. +// * +// * In mcMMO it is sometimes needed to match one item to another, but items contain a lot of metadata +// * Some of this metadata is important, some of it isn't, and whether something is important or not when +// * considering two items to be similar enough to be considered matching items is not strictly defined and is in fact different from server to server. +// * +// * mcMMO employs a flexible system where users can define which properties of an items metadata (often its NBT) +// * are important for matching and mcMMO will respect those properties when comparing one item to another. +// * +// * If a user does not define a property as being important for matching mcMMO will ignore that property when matching +// * two or more items, even if that property is not equivalent between the items. This type will contain information +// * on which properties are to be considered important for matching purposes. +// * +// * The main goal of this system is accommodate for the vast majority of custom item modifications a server can employ, +// * these custom items are often defined in irregular ways server to server, thus why this type was made. +// * +// * In summary, this type serves several purposes... +// * 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 ItemMatch> implements DefinedMatch> { +// +// private T item; //Abstract representation of the item +// private Set itemMatchProperties; //Item properties used for matching +// +// public ItemMatch(T item) { +// this.item = item; +// itemMatchProperties = new HashSet<>(); +// } +// +// public ItemMatch(T item, Set itemMatchProperties) { +// this.item = item; +// this.itemMatchProperties = itemMatchProperties; +// } +// +// /** +// * Gets the item held by this ItemMatch +// * @return the item used for matching +// */ +// public T getItem() { +// return item; +// } +// +// /** +// * Get the item match properties of this ItemMatch +// * @return the item match properties +// */ +// public Set getItemMatchProperties() { +// return itemMatchProperties; +// } +// +// /** +// * 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 +// */ +// @Override +// public boolean isMatch(MMOItem otherItem) { +// if(hasStrictMatching()) { +// return isStrictMatch(otherItem); +// } else { +// return isUnstrictMatch(otherItem); +// } +// } +// +// /** +// * Compare this item to another while comparing specific nbt tags for matching values, if all values are found and match it is considered a strict match +// * @param otherItem item to strictly match +// * @return true if the items are considered a match +// */ +// private boolean isStrictMatch(MMOItem otherItem) { +// for(ItemMatchProperty itemMatchProperty : itemMatchProperties) { +// if(!NBTManager.hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) { +// return false; +// } +// } +// +// //All item match properties were found and matched +// return true; +// } +// +// /** +// * Compare this item to another only by namespace key +// * @param otherItem item to compare namespace keys with +// * @return true if the items share namespace keys +// */ +// private boolean isUnstrictMatch(MMOItem otherItem) { +// if(otherItem.getNamespaceKey().equalsIgnoreCase(item.getNamespaceKey())) { +// return true; +// } +// +// //Namespace didn't match reject item +// return false; +// } +// +// /** +// * If this item has strict matching or loose match +// * Solely determined by having any item match properties present +// * @return true if this item target has strict matching +// */ +// public boolean hasStrictMatching() { +// return itemMatchProperties.size() > 1; +// } +// +// @Override +// public boolean equals(Object o) { +// if (this == o) return true; +// if (!(o instanceof ItemMatch)) return false; +// ItemMatch itemMatch = (ItemMatch) o; +// return getItem().equals(itemMatch.getItem()) && +// getItemMatchProperties().equals(itemMatch.getItemMatchProperties()); +// } +// +// @Override +// public int hashCode() { +// return Objects.hash(getItem(), getItemMatchProperties()); +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java index b2942b801..53866784f 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/ItemWildcards.java @@ -1,60 +1,60 @@ -package com.gmail.nossr50.datatypes.items; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * Represents a series of items that are all acceptable inputs for a behaviour - * Wildcards have a unique name that defines them, no two wildcards should share the same name. - * The name is important as it is used to identify the wildcard to the player. - * - * One example of the purpose of this Datatype: - * - * As an example, in Repair users are allowed to define a repair cost that can specify wildcards - * One such example is wood planks, many variants exist in Minecraft and they can all be used to repair Wooden tools - * - * ItemWildcards is a flexible datatype and won't be used just for Repair, but at the time of writing it was created - * to solve a problem with Repair. Given its flexible nature it can be used for many purposes. - * - */ -public class ItemWildcards> { - - private String wildcardName; - private Set> itemTargets; - - public ItemWildcards(String wildcardName, Set> itemTargets) { - this.wildcardName = wildcardName; - this.itemTargets = itemTargets; - } - - public int getItemCount() { - return itemTargets.size(); - } - - public Set> getItemTargets() { - return itemTargets; - } - - public void setItemTargets(HashSet> itemTargets) { - this.itemTargets = itemTargets; - } - - public String getWildcardName() { - return wildcardName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ItemWildcards)) return false; - ItemWildcards that = (ItemWildcards) o; - return getWildcardName().equals(that.getWildcardName()) && - getItemTargets().equals(that.getItemTargets()); - } - - @Override - public int hashCode() { - return Objects.hash(getWildcardName(), getItemTargets()); - } -} +//package com.gmail.nossr50.datatypes.items; +// +//import java.util.HashSet; +//import java.util.Objects; +//import java.util.Set; +// +///** +// * Represents a series of items that are all acceptable inputs for a behaviour +// * Wildcards have a unique name that defines them, no two wildcards should share the same name. +// * The name is important as it is used to identify the wildcard to the player. +// * +// * One example of the purpose of this Datatype: +// * +// * As an example, in Repair users are allowed to define a repair cost that can specify wildcards +// * One such example is wood planks, many variants exist in Minecraft and they can all be used to repair Wooden tools +// * +// * ItemWildcards is a flexible datatype and won't be used just for Repair, but at the time of writing it was created +// * to solve a problem with Repair. Given its flexible nature it can be used for many purposes. +// * +// */ +//public class ItemWildcards> { +// +// private String wildcardName; +// private Set> itemTargets; +// +// public ItemWildcards(String wildcardName, Set> itemTargets) { +// this.wildcardName = wildcardName; +// this.itemTargets = itemTargets; +// } +// +// public int getItemCount() { +// return itemTargets.size(); +// } +// +// public Set> getItemTargets() { +// return itemTargets; +// } +// +// public void setItemTargets(HashSet> itemTargets) { +// this.itemTargets = itemTargets; +// } +// +// public String getWildcardName() { +// return wildcardName; +// } +// +// @Override +// public boolean equals(Object o) { +// if (this == o) return true; +// if (!(o instanceof ItemWildcards)) return false; +// ItemWildcards that = (ItemWildcards) o; +// return getWildcardName().equals(that.getWildcardName()) && +// getItemTargets().equals(that.getItemTargets()); +// } +// +// @Override +// public int hashCode() { +// return Objects.hash(getWildcardName(), getItemTargets()); +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/MMOItem.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/MMOItem.java index 513f9fb76..5326e79f9 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/MMOItem.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/items/MMOItem.java @@ -1,39 +1,39 @@ -package com.gmail.nossr50.datatypes.items; - -import com.gmail.nossr50.util.nbt.RawNBT; - -/** - * Represents the abstracted form of an item in Minecraft which can be used to construct an item implementation per platform - * Return types of this object are not platform specific - * Only requires a namespace key to be defined, all other properties will be default initialized - */ -public interface MMOItem { - - /** - * Gets the item implementation of this type for this object - * @return the item implementation - */ - T getItemImplementation(); - - /** - * Get the Minecraft fully qualified namespace (FQN) key for this item - * Typically the FQN will read like this 'minecraft:name_here' - * @return the fully qualified namespace key for this item - */ - String getNamespaceKey(); - - /** - * Get the amount of this Item - * Items in Minecraft are technically stacks of items with the minimum amount being 1 in most cases - * The amount is used for matching purposes, and should default to 1 if undefined - * @return the amount for this Item - */ - int getItemAmount(); - - /** - * Get the RawNBT for this item if it has any - * This can be null - * @return the raw NBT if it exists, null otherwise - */ - RawNBT getRawNBT(); -} +//package com.gmail.nossr50.datatypes.items; +// +//import com.gmail.nossr50.util.nbt.RawNBT; +// +///** +// * Represents the abstracted form of an item in Minecraft which can be used to construct an item implementation per platform +// * Return types of this object are not platform specific +// * Only requires a namespace key to be defined, all other properties will be default initialized +// */ +//public interface MMOItem { +// +// /** +// * Gets the item implementation of this type for this object +// * @return the item implementation +// */ +// T getItemImplementation(); +// +// /** +// * Get the Minecraft fully qualified namespace (FQN) key for this item +// * Typically the FQN will read like this 'minecraft:name_here' +// * @return the fully qualified namespace key for this item +// */ +// String getNamespaceKey(); +// +// /** +// * Get the amount of this Item +// * Items in Minecraft are technically stacks of items with the minimum amount being 1 in most cases +// * The amount is used for matching purposes, and should default to 1 if undefined +// * @return the amount for this Item +// */ +// int getItemAmount(); +// +// /** +// * Get the RawNBT for this item if it has any +// * This can be null +// * @return the raw NBT if it exists, null otherwise +// */ +// RawNBT getRawNBT(); +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/nbt/NBTHolder.java b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/nbt/NBTHolder.java index 5aba7ae30..ca38252b0 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/nbt/NBTHolder.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/datatypes/nbt/NBTHolder.java @@ -1,26 +1,26 @@ -package com.gmail.nossr50.datatypes.nbt; - -import com.gmail.nossr50.util.nbt.RawNBT; - -/** - * Many things in Minecraft make use of the NBT System - * You can read about the NBT System here - https://wiki.vg/NBT - * - * Types that support NBT will implement this interface - */ -public interface NBTHolder { - - /** - * Get the RawNBT for this object - * @return the RawNBT for this object - */ - RawNBT getRawNBT(); - - /** - * Determine whether or not this object has the specific NBT entry and matching value - * @param id the ID fof the NBT entry - * @param value the value of the NBT entry - * @return returns true if the NBT of id exists and its value matches - */ - boolean hasNBTValue(String id, Object value); -} +//package com.gmail.nossr50.datatypes.nbt; +// +//import com.gmail.nossr50.util.nbt.RawNBT; +// +///** +// * Many things in Minecraft make use of the NBT System +// * You can read about the NBT System here - https://wiki.vg/NBT +// * +// * Types that support NBT will implement this interface +// */ +//public interface NBTHolder { +// +// /** +// * Get the RawNBT for this object +// * @return the RawNBT for this object +// */ +// RawNBT getRawNBT(); +// +// /** +// * Determine whether or not this object has the specific NBT entry and matching value +// * @param id the ID fof the NBT entry +// * @param value the value of the NBT entry +// * @return returns true if the NBT of id exists and its value matches +// */ +// boolean hasNBTValue(String id, Object value); +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 4384175e5..43fe8a0bd 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -13,8 +13,6 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; -import com.gmail.nossr50.skills.repair.RepairManager; -import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.sounds.SoundType; @@ -599,40 +597,41 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_BLOCK: Material type = block.getType(); - if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { - /* REPAIR CHECKS */ - if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial() - && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player) - && pluginRef.getRepairableManager().isRepairable(heldItem) - && heldItem.getAmount() <= 1) { - RepairManager repairManager = mcMMOPlayer.getRepairManager(); - event.setCancelled(true); - - // Make sure the player knows what he's doing when trying to repair an enchanted item - if (repairManager.checkConfirmation(true)) { - repairManager.handleRepair(heldItem); - player.updateInventory(); - } - } - /* SALVAGE CHECKS */ - else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial() - && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player) - && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) - && pluginRef.getSalvageableManager().isSalvageable(heldItem) - && heldItem.getAmount() <= 1) { - SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager(); - event.setCancelled(true); - - // Make sure the player knows what he's doing when trying to salvage an enchanted item - if (salvageManager.checkConfirmation(true)) { - pluginRef.getSkillTools().handleAbilitySpeedDecrease(player); - salvageManager.handleSalvage(block.getLocation(), heldItem); - player.updateInventory(); - } - } - } +// if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { +// /* REPAIR CHECKS */ +// if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial() +// && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player) +// && pluginRef.getRepairableManager().isRepairable(heldItem) +// && heldItem.getAmount() <= 1) { +// RepairManager repairManager = mcMMOPlayer.getRepairManager(); +// event.setCancelled(true); +// +// // Make sure the player knows what he's doing when trying to repair an enchanted item +// if (repairManager.checkConfirmation(true)) { +// repairManager.handleRepair(heldItem); +// player.updateInventory(); +// } +// } +// /* SALVAGE CHECKS */ +// else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial() +// && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player) +// && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) +// && pluginRef.getSalvageableManager().isSalvageable(heldItem) +// && heldItem.getAmount() <= 1) { +// SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager(); +// event.setCancelled(true); +// +// // Make sure the player knows what he's doing when trying to salvage an enchanted item +// if (salvageManager.checkConfirmation(true)) { +// pluginRef.getSkillTools().handleAbilitySpeedDecrease(player); +// salvageManager.handleSalvage(block.getLocation(), heldItem); +// player.updateInventory(); +// } +// } +// } /* BLAST MINING CHECK */ - else if (miningManager.canDetonate()) { + //TODO: Turn to else if after repair/salvage rewrites (canDetonate check) + if (miningManager.canDetonate()) { if (type == Material.TNT) { event.setCancelled(true); // Don't detonate the TNT if they're too close } else { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java b/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java index cf512f20e..bbef38448 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/mcMMO.java @@ -26,7 +26,6 @@ import com.gmail.nossr50.runnables.player.ClearRegisteredXPGainTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask; -import com.gmail.nossr50.skills.repair.repairables.RepairableManager; import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; @@ -431,9 +430,9 @@ public class mcMMO extends JavaPlugin { return placeStore; } - public RepairableManager getRepairableManager() { - return dynamicSettingsManager.getRepairableManager(); - } +// public RepairableManager getRepairableManager() { +// return dynamicSettingsManager.getRepairableManager(); +// } public SalvageableManager getSalvageableManager() { return dynamicSettingsManager.getSalvageableManager(); diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java index 58c667502..447b0a261 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairCost.java @@ -1,25 +1,25 @@ -package com.gmail.nossr50.skills.repair; - -import com.gmail.nossr50.datatypes.items.ItemMatch; -import org.bukkit.inventory.PlayerInventory; - -/** - * Represents one item in a Repair Transaction - */ -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 - * @return any compatible payment items if found, can be null - */ - ItemMatch findPayment(PlayerInventory playerInventory); - - /** - * Whether or not there is an item that can be used for this repair cost in the player's inventory - * @param playerInventory target player - * @return true if payment is found - */ - boolean hasPayment(PlayerInventory playerInventory); - -} +//package com.gmail.nossr50.skills.repair; +// +//import com.gmail.nossr50.datatypes.items.ItemMatch; +//import org.bukkit.inventory.PlayerInventory; +// +///** +// * Represents one item in a Repair Transaction +// */ +//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 +// * @return any compatible payment items if found, can be null +// */ +// ItemMatch findPayment(PlayerInventory playerInventory); +// +// /** +// * Whether or not there is an item that can be used for this repair cost in the player's inventory +// * @param playerInventory target player +// * @return true if payment is found +// */ +// boolean hasPayment(PlayerInventory playerInventory); +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java index e3ecc6f6c..03cdd295e 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/RepairTransaction.java @@ -1,50 +1,50 @@ -package com.gmail.nossr50.skills.repair; - - -import org.bukkit.inventory.PlayerInventory; - -import java.util.HashSet; - -/** - * Represents a complete "repair transaction" - * - * I will define a "repair transaction" as such - * - The items used to pay the cost of repairing an item in mcMMO via the Repair Skill - * - * A single "RepairTransaction" is made up of a multiple RepairCost objects - * No two RepairCosts contained within this type can be exact duplicates - * - * A RepairCost is used to find a matching ItemStack in a players inventory if one exists to pay its cost - * - * A RepairCost can be a single item or it can be multiple items representing a range of compatible items - * to pay that part of the RepairTransaction - */ -public class RepairTransaction { - private HashSet repairCosts; - - public RepairTransaction(HashSet repairCosts) { - this.repairCosts = repairCosts; - } - - public void addRepairCost(RepairCost repairCost) { - repairCosts.add(repairCost); - } - - public HashSet getRepairCosts() { - return repairCosts; - } - - public void setRepairCosts(HashSet repairItems) { - this.repairCosts = repairItems; - } - - public boolean canPayRepairCosts(PlayerInventory playerInventory) { - for(RepairCost repairCost : repairCosts) { - if(!repairCost.hasPayment(playerInventory)) { - return false; - } - } - - return true; - } -} +//package com.gmail.nossr50.skills.repair; +// +// +//import org.bukkit.inventory.PlayerInventory; +// +//import java.util.HashSet; +// +///** +// * Represents a complete "repair transaction" +// * +// * I will define a "repair transaction" as such +// * - The items used to pay the cost of repairing an item in mcMMO via the Repair Skill +// * +// * A single "RepairTransaction" is made up of a multiple RepairCost objects +// * No two RepairCosts contained within this type can be exact duplicates +// * +// * A RepairCost is used to find a matching ItemStack in a players inventory if one exists to pay its cost +// * +// * A RepairCost can be a single item or it can be multiple items representing a range of compatible items +// * to pay that part of the RepairTransaction +// */ +//public class RepairTransaction { +// private HashSet repairCosts; +// +// public RepairTransaction(HashSet repairCosts) { +// this.repairCosts = repairCosts; +// } +// +// public void addRepairCost(RepairCost repairCost) { +// repairCosts.add(repairCost); +// } +// +// public HashSet getRepairCosts() { +// return repairCosts; +// } +// +// public void setRepairCosts(HashSet repairItems) { +// this.repairCosts = repairItems; +// } +// +// public boolean canPayRepairCosts(PlayerInventory playerInventory) { +// for(RepairCost repairCost : repairCosts) { +// if(!repairCost.hasPayment(playerInventory)) { +// return false; +// } +// } +// +// return true; +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java index baf5c93ee..3172e70b8 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairCost.java @@ -1,53 +1,53 @@ -package com.gmail.nossr50.skills.repair; - -import com.gmail.nossr50.bukkit.BukkitFactory; -import com.gmail.nossr50.datatypes.items.ItemMatch; -import com.gmail.nossr50.datatypes.items.MMOItem; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - -/** - * Implementation of RepairCost - * - * A SimpleRepairCost can be one or more items, any one of which can be used to pay for a RepairTransaction - * If a SimpleRepairCost is more than one item, then only one of the items are required to represent its cost. - * - * 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 { - - private T itemMatch; - - public SimpleRepairCost(T customItemTarget) { - this.itemMatch = customItemTarget; - } - - @Override - public T findPayment(PlayerInventory playerInventory) { - for(ItemStack itemStack : playerInventory.getContents()) { - if(itemStack == null || itemStack.getType() == Material.AIR) - continue; - - MMOItem playerInventoryItem = (MMOItem) BukkitFactory.createItem(itemStack); - - if(itemMatch.isMatch(playerInventoryItem)) { - //Item is a match - return (T) playerInventoryItem; - } - - } - - return null; - } - - public T getItemMatch() { - return itemMatch; - } - - @Override - public boolean hasPayment(PlayerInventory playerInventory) { - return findPayment(playerInventory) != null; - } -} +//package com.gmail.nossr50.skills.repair; +// +//import com.gmail.nossr50.bukkit.BukkitFactory; +//import com.gmail.nossr50.datatypes.items.ItemMatch; +//import com.gmail.nossr50.datatypes.items.MMOItem; +//import org.bukkit.Material; +//import org.bukkit.inventory.ItemStack; +//import org.bukkit.inventory.PlayerInventory; +// +///** +// * Implementation of RepairCost +// * +// * A SimpleRepairCost can be one or more items, any one of which can be used to pay for a RepairTransaction +// * If a SimpleRepairCost is more than one item, then only one of the items are required to represent its cost. +// * +// * 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 { +// +// private T itemMatch; +// +// public SimpleRepairCost(T customItemTarget) { +// this.itemMatch = customItemTarget; +// } +// +// @Override +// public T findPayment(PlayerInventory playerInventory) { +// for(ItemStack itemStack : playerInventory.getContents()) { +// if(itemStack == null || itemStack.getType() == Material.AIR) +// continue; +// +// MMOItem playerInventoryItem = (MMOItem) BukkitFactory.createItem(itemStack); +// +// if(itemMatch.isMatch(playerInventoryItem)) { +// //Item is a match +// return (T) playerInventoryItem; +// } +// +// } +// +// return null; +// } +// +// public T getItemMatch() { +// return itemMatch; +// } +// +// @Override +// public boolean hasPayment(PlayerInventory playerInventory) { +// return findPayment(playerInventory) != null; +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index 823e2be09..099042ee1 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -1,94 +1,94 @@ -package com.gmail.nossr50.skills.repair.repairables; - -import com.gmail.nossr50.datatypes.items.ItemMatch; -import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; -import com.gmail.nossr50.skills.repair.RepairTransaction; - -public class Repairable { - private int minimumLevel; - private short maximumDurability; - private RepairTransaction repairTransaction; - private int baseXP; - private ItemMatch itemMatch; - private int repairCount; - private PermissionWrapper permissionWrapper; - private boolean hasPermission = false; - - 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.itemMatch = itemMatch; - this.repairCount = repairCount; - this.permissionWrapper = permissionWrapper; - - if(permissionWrapper != null) - hasPermission = true; - } - - public int getMinimumLevel() { - return minimumLevel; - } - - public void setMinimumLevel(int minimumLevel) { - this.minimumLevel = minimumLevel; - } - - public short getMaximumDurability() { - return maximumDurability; - } - - public void setMaximumDurability(short maximumDurability) { - this.maximumDurability = maximumDurability; - } - - public RepairTransaction getRepairTransaction() { - return repairTransaction; - } - - public void setRepairTransaction(RepairTransaction repairTransaction) { - this.repairTransaction = repairTransaction; - } - - public int getBaseXP() { - return baseXP; - } - - public void setBaseXP(int baseXP) { - this.baseXP = baseXP; - } - - public ItemMatch getItemMatch() { - return itemMatch; - } - - public void setItemMatch(ItemMatch itemMatch) { - this.itemMatch = itemMatch; - } - - public int getRepairCount() { - return repairCount; - } - - public void setRepairCount(int repairCount) { - this.repairCount = repairCount; - } - - public PermissionWrapper getPermissionWrapper() { - return permissionWrapper; - } - - public void setPermissionWrapper(PermissionWrapper permissionWrapper) { - this.permissionWrapper = permissionWrapper; - } - - public boolean hasPermissionNode() { - return hasPermission; - } - - public void setHasPermission(boolean hasPermission) { - this.hasPermission = hasPermission; - } - -} +//package com.gmail.nossr50.skills.repair.repairables; +// +//import com.gmail.nossr50.datatypes.items.ItemMatch; +//import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; +//import com.gmail.nossr50.skills.repair.RepairTransaction; +// +//public class Repairable { +// private int minimumLevel; +// private short maximumDurability; +// private RepairTransaction repairTransaction; +// private int baseXP; +// private ItemMatch itemMatch; +// private int repairCount; +// private PermissionWrapper permissionWrapper; +// private boolean hasPermission = false; +// +// 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.itemMatch = itemMatch; +// this.repairCount = repairCount; +// this.permissionWrapper = permissionWrapper; +// +// if(permissionWrapper != null) +// hasPermission = true; +// } +// +// public int getMinimumLevel() { +// return minimumLevel; +// } +// +// public void setMinimumLevel(int minimumLevel) { +// this.minimumLevel = minimumLevel; +// } +// +// public short getMaximumDurability() { +// return maximumDurability; +// } +// +// public void setMaximumDurability(short maximumDurability) { +// this.maximumDurability = maximumDurability; +// } +// +// public RepairTransaction getRepairTransaction() { +// return repairTransaction; +// } +// +// public void setRepairTransaction(RepairTransaction repairTransaction) { +// this.repairTransaction = repairTransaction; +// } +// +// public int getBaseXP() { +// return baseXP; +// } +// +// public void setBaseXP(int baseXP) { +// this.baseXP = baseXP; +// } +// +// public ItemMatch getItemMatch() { +// return itemMatch; +// } +// +// public void setItemMatch(ItemMatch itemMatch) { +// this.itemMatch = itemMatch; +// } +// +// public int getRepairCount() { +// return repairCount; +// } +// +// public void setRepairCount(int repairCount) { +// this.repairCount = repairCount; +// } +// +// public PermissionWrapper getPermissionWrapper() { +// return permissionWrapper; +// } +// +// public void setPermissionWrapper(PermissionWrapper permissionWrapper) { +// this.permissionWrapper = permissionWrapper; +// } +// +// public boolean hasPermissionNode() { +// return hasPermission; +// } +// +// public void setHasPermission(boolean hasPermission) { +// this.hasPermission = hasPermission; +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java index 6be7fbc20..30b5d9356 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableBuilder.java @@ -1,64 +1,64 @@ -package com.gmail.nossr50.skills.repair.repairables; - -import com.gmail.nossr50.datatypes.items.ItemMatch; -import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; -import com.gmail.nossr50.skills.repair.RepairTransaction; - -public class RepairableBuilder { - - private int minimumLevel; - private short maximumDurability; - private RepairTransaction repairTransaction; - private int baseXP; - private ItemMatch itemMatch; - private int repairCount; - private PermissionWrapper permissionWrapper; - - public RepairableBuilder(ItemMatch itemMatch, Short maximumDurability, RepairTransaction repairTransaction) { - this.itemMatch = itemMatch; - this.maximumDurability = maximumDurability; - this.repairTransaction = repairTransaction; - } - - public RepairableBuilder addMinLevel(Integer minimumLevel) { - this.minimumLevel = minimumLevel; - return this; - } - - public RepairableBuilder setMaximumDurability(Short maximumDurability) { - this.maximumDurability = maximumDurability; - return this; - } - - public RepairableBuilder setRepairTransaction(RepairTransaction repairTransaction) { - this.repairTransaction = repairTransaction; - return this; - } - - public RepairableBuilder setBaseXP(Integer baseXP) { - this.baseXP = baseXP; - return this; - } - - public RepairableBuilder setRepairCount(Integer repairCount) { - this.repairCount = repairCount; - return this; - } - - public RepairableBuilder addPermissionWrapper(PermissionWrapper permissionWrapper) { - this.permissionWrapper = permissionWrapper; - return this; - } - - public Repairable build() { - return makeRepairable(); - } - - private Repairable makeRepairable() { - Repairable repairable = new Repairable(itemMatch, minimumLevel, maximumDurability, repairTransaction, - baseXP, repairCount, permissionWrapper); - - return repairable; - } - -} +//package com.gmail.nossr50.skills.repair.repairables; +// +//import com.gmail.nossr50.datatypes.items.ItemMatch; +//import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; +//import com.gmail.nossr50.skills.repair.RepairTransaction; +// +//public class RepairableBuilder { +// +// private int minimumLevel; +// private short maximumDurability; +// private RepairTransaction repairTransaction; +// private int baseXP; +// private ItemMatch itemMatch; +// private int repairCount; +// private PermissionWrapper permissionWrapper; +// +// public RepairableBuilder(ItemMatch itemMatch, Short maximumDurability, RepairTransaction repairTransaction) { +// this.itemMatch = itemMatch; +// this.maximumDurability = maximumDurability; +// this.repairTransaction = repairTransaction; +// } +// +// public RepairableBuilder addMinLevel(Integer minimumLevel) { +// this.minimumLevel = minimumLevel; +// return this; +// } +// +// public RepairableBuilder setMaximumDurability(Short maximumDurability) { +// this.maximumDurability = maximumDurability; +// return this; +// } +// +// public RepairableBuilder setRepairTransaction(RepairTransaction repairTransaction) { +// this.repairTransaction = repairTransaction; +// return this; +// } +// +// public RepairableBuilder setBaseXP(Integer baseXP) { +// this.baseXP = baseXP; +// return this; +// } +// +// public RepairableBuilder setRepairCount(Integer repairCount) { +// this.repairCount = repairCount; +// return this; +// } +// +// public RepairableBuilder addPermissionWrapper(PermissionWrapper permissionWrapper) { +// this.permissionWrapper = permissionWrapper; +// return this; +// } +// +// public Repairable build() { +// return makeRepairable(); +// } +// +// private Repairable makeRepairable() { +// Repairable repairable = new Repairable(itemMatch, minimumLevel, maximumDurability, repairTransaction, +// baseXP, repairCount, permissionWrapper); +// +// return repairable; +// } +// +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java index 8ba1fa74a..7830c5d6b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java @@ -1,49 +1,49 @@ -package com.gmail.nossr50.skills.repair.repairables; - -import com.gmail.nossr50.datatypes.items.ItemMatch; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.List; - -public class RepairableManager { - private HashMap, Repairable> repairables; - - public RepairableManager(List repairablesCollection) { - this.repairables = new HashMap<>(repairablesCollection.size()); - registerRepairables(repairablesCollection); - } - - public void registerRepairable(Repairable repairable) { - repairables.put(repairable.getItemMatch(), repairable); - } - - public void registerRepairables(List repairables) { - for (Repairable repairable : repairables) { - registerRepairable(repairable); - } - } - - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - //TODO: Make these use item matching - public boolean isRepairable(Material type) { - return repairables.containsKey(type); - } - - public boolean isRepairable(ItemStack itemStack) { - return isRepairable(itemStack.getType()); - } - - public Repairable getRepairable(Material type) { - return repairables.get(type); - } -} +//package com.gmail.nossr50.skills.repair.repairables; +// +//import com.gmail.nossr50.datatypes.items.ItemMatch; +//import org.bukkit.Material; +//import org.bukkit.inventory.ItemStack; +// +//import java.util.HashMap; +//import java.util.List; +// +//public class RepairableManager { +// private HashMap, Repairable> repairables; +// +// public RepairableManager(List repairablesCollection) { +// this.repairables = new HashMap<>(repairablesCollection.size()); +// registerRepairables(repairablesCollection); +// } +// +// public void registerRepairable(Repairable repairable) { +// repairables.put(repairable.getItemMatch(), repairable); +// } +// +// public void registerRepairables(List repairables) { +// for (Repairable repairable : repairables) { +// registerRepairable(repairable); +// } +// } +// +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// //TODO: Make these use item matching +// public boolean isRepairable(Material type) { +// return repairables.containsKey(type); +// } +// +// public boolean isRepairable(ItemStack itemStack) { +// return isRepairable(itemStack.getType()); +// } +// +// public Repairable getRepairable(Material type) { +// return repairables.get(type); +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index a16193153..7b32ae952 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -199,7 +199,9 @@ public class WoodcuttingManager extends SkillManager { } pluginRef.getSkillTools().handleDurabilityChange(inHand, durabilityLoss); - return (inHand.getDurability() < (pluginRef.getRepairableManager().isRepairable(type) ? pluginRef.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability())); + //TODO: Revert code back to its former implementation after the Repair rewrite? The implementation is strange so idk. + // (FORMER IMPLEMENTATION) return (inHand.getDurability() < (pluginRef.getRepairableManager().isRepairable(type) ? pluginRef.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability())); + return (inHand.getDurability() < type.getMaxDurability()); } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java index ddeeddf9b..7f1d2eb80 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java @@ -1,33 +1,33 @@ -package com.gmail.nossr50.util.nbt; - -import net.minecraft.server.v1_14_R1.NBTBase; - -/** - * A simple class that acts as a container for raw NBT data - * NBT data will be constructed from the raw NBT string using server internals - * This type is mostly used to take a raw string of NBT and transform it into the NBT data type used by internals - * the transformed data can then be used to check NBT data of entities in Minecraft - * - * One use of this type is as follows - * 1) Read partial or complete NBT from the config file for an item - * 2) Check an items NBT tree for this NBT data during runtime once transformed - */ -public class RawNBT { - private String nbtContents; - - public RawNBT(String nbtContents) { - this.nbtContents = nbtContents; - } - - public String getNbtContents() { - return nbtContents; - } - - public void setNbtContents(String nbtContents) { - this.nbtContents = nbtContents; - } - - public NBTBase getNbtData() { - return NBTManager.constructNBT(nbtContents); - } -} +//package com.gmail.nossr50.util.nbt; +// +//import net.minecraft.server.v1_14_R1.NBTBase; +// +///** +// * A simple class that acts as a container for raw NBT data +// * NBT data will be constructed from the raw NBT string using server internals +// * This type is mostly used to take a raw string of NBT and transform it into the NBT data type used by internals +// * the transformed data can then be used to check NBT data of entities in Minecraft +// * +// * One use of this type is as follows +// * 1) Read partial or complete NBT from the config file for an item +// * 2) Check an items NBT tree for this NBT data during runtime once transformed +// */ +//public class RawNBT { +// private String nbtContents; +// +// public RawNBT(String nbtContents) { +// this.nbtContents = nbtContents; +// } +// +// public String getNbtContents() { +// return nbtContents; +// } +// +// public void setNbtContents(String nbtContents) { +// this.nbtContents = nbtContents; +// } +// +// public NBTBase getNbtData() { +// return NBTManager.constructNBT(nbtContents); +// } +//} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/SkillTools.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/SkillTools.java index 267536f56..e7f8d6356 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/SkillTools.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/skills/SkillTools.java @@ -461,7 +461,9 @@ public class SkillTools { } Material type = itemStack.getType(); - short maxDurability = pluginRef.getRepairableManager().isRepairable(type) ? pluginRef.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); + //TODO: Return to former implementation after Repair rewrite? Implementation is strange... + //TODO: (FORMER IMPLEMENTATION) short maxDurability = pluginRef.getRepairableManager().isRepairable(type) ? pluginRef.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); + short maxDurability = type.getMaxDurability(); durabilityModifier = (int) Math.min(durabilityModifier / (itemStack.getEnchantmentLevel(Enchantment.DURABILITY) + 1), maxDurability * maxDamageModifier); itemStack.setDurability((short) Math.min(itemStack.getDurability() + durabilityModifier, maxDurability));