Completely disable all Repair code pending rewrite

Repair code will be handled in a sep branch, this is being done so the
configurable branch can compile and be semi-playable for testing
important in development features.
This commit is contained in:
nossr50 2019-09-30 15:10:59 -07:00
parent 9e01a07542
commit 154d0a8d50
27 changed files with 1117 additions and 1139 deletions

View File

@ -1,26 +1,26 @@
package com.gmail.nossr50.bukkit; //package com.gmail.nossr50.bukkit;
//
import com.gmail.nossr50.datatypes.items.BukkitMMOItem; //import com.gmail.nossr50.datatypes.items.BukkitMMOItem;
import com.gmail.nossr50.datatypes.items.MMOItem; //import com.gmail.nossr50.datatypes.items.MMOItem;
import com.gmail.nossr50.util.nbt.NBTManager; //import com.gmail.nossr50.util.nbt.NBTManager;
import com.gmail.nossr50.util.nbt.RawNBT; //import com.gmail.nossr50.util.nbt.RawNBT;
import org.bukkit.inventory.ItemStack; //import org.bukkit.inventory.ItemStack;
//
/** ///**
* Used to convert or construct platform independent types into Bukkit types // * Used to convert or construct platform independent types into Bukkit types
*/ // */
public class BukkitFactory { //public class BukkitFactory {
//
/** // /**
* Creates a BukkitMMOItem which contains Bukkit implementations for the type MMOItem // * Creates a BukkitMMOItem which contains Bukkit implementations for the type MMOItem
* @return a new BukkitMMOItem // * @return a new BukkitMMOItem
*/ // */
public static MMOItem<?> createItem(String namespaceKey, int amount, RawNBT rawNBT) { // public static MMOItem<?> createItem(String namespaceKey, int amount, RawNBT rawNBT) {
return new BukkitMMOItem(namespaceKey, amount, rawNBT); // return new BukkitMMOItem(namespaceKey, amount, rawNBT);
} // }
//
public static MMOItem<?> createItem(ItemStack itemStack) { // public static MMOItem<?> createItem(ItemStack itemStack) {
return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(NBTManager.getNBT(itemStack).toString())); // return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(NBTManager.getNBT(itemStack).toString()));
} // }
//
} //}

View File

@ -48,20 +48,13 @@ import com.gmail.nossr50.config.superabilities.ConfigSuperAbilities;
import com.gmail.nossr50.config.worldblacklist.ConfigWorldBlacklist; import com.gmail.nossr50.config.worldblacklist.ConfigWorldBlacklist;
import com.gmail.nossr50.datatypes.experience.CustomXPPerk; import com.gmail.nossr50.datatypes.experience.CustomXPPerk;
import com.gmail.nossr50.datatypes.experience.FormulaType; 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.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.properties.DamageProperty; import com.gmail.nossr50.datatypes.skills.properties.DamageProperty;
import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel; import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon; import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.gmail.nossr50.mcMMO; 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.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.nbt.RawNBT;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection; import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection;
@ -258,14 +251,14 @@ public final class ConfigManager {
customSerializers.registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken<FormulaType>() {}, new CustomEnumValueSerializer());
customSerializers.registerType(new TypeToken<MMOItem<?>>() {}, new ItemStackSerializer()); // customSerializers.registerType(new TypeToken<MMOItem<?>>() {}, new ItemStackSerializer());
customSerializers.registerType(new TypeToken<Set<?>>() {}, new SetSerializer()); customSerializers.registerType(new TypeToken<Set<?>>() {}, new SetSerializer());
customSerializers.registerType(new TypeToken<ItemMatch<?>>() {}, new CustomItemTargetSerializer()); // customSerializers.registerType(new TypeToken<ItemMatch<?>>() {}, new CustomItemTargetSerializer());
customSerializers.registerType(new TypeToken<SimpleRepairCost>() {}, new SimpleRepairCostSerializer()); // customSerializers.registerType(new TypeToken<SimpleRepairCost>() {}, new SimpleRepairCostSerializer());
customSerializers.registerType(TypeToken.of(TamingSummon.class), new TamingSummonSerializer()); 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(Salvageable.class), new SalvageableSerializer());
customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer()); customSerializers.registerType(TypeToken.of(MinecraftMaterialWrapper.class), new MinecraftMaterialWrapperSerializer());
customSerializers.registerType(TypeToken.of(CustomXPPerk.class), new CustomXPPerkSerializer()); 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(MaxBonusLevel.class), new MaxBonusLevelSerializer());
customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer()); customSerializers.registerType(TypeToken.of(PlayerNotificationSettings.class), new PlayerNotificationSerializer());
customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer()); customSerializers.registerType(TypeToken.of(SoundSetting.class), new SoundSettingSerializer());
customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer()); // customSerializers.registerType(TypeToken.of(ItemWildcards.class), new ItemWildcardSerializer());
customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer()); // customSerializers.registerType(TypeToken.of(RepairTransaction.class), new RepairTransactionSerializer());
customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer()); // customSerializers.registerType(TypeToken.of(RawNBT.class), new RawNBTSerializer());
} }
/** /**

View File

@ -1,43 +1,43 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.items.ItemMatchProperty; //import com.gmail.nossr50.datatypes.items.ItemMatchProperty;
import com.gmail.nossr50.datatypes.items.MMOItem; //import com.gmail.nossr50.datatypes.items.MMOItem;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.ValueType; //import ninja.leaping.configurate.ValueType;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.checkerframework.checker.nullness.qual.NonNull; //import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; //import org.checkerframework.checker.nullness.qual.Nullable;
//
import java.util.HashSet; //import java.util.HashSet;
//
public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch<?>> { //public class CustomItemTargetSerializer implements TypeSerializer<ItemMatch<?>> {
//
private static final String ITEM_CONSUMED_FOR_REPAIR = "Target-Item"; // private static final String ITEM_CONSUMED_FOR_REPAIR = "Target-Item";
private static final String NBT_REQUIREMENTS = "NBT-Requirements"; // private static final String NBT_REQUIREMENTS = "NBT-Requirements";
//
@Nullable // @Nullable
@Override // @Override
public ItemMatch deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { // public ItemMatch deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
MMOItem<?> mmoItem = value.getNode(ITEM_CONSUMED_FOR_REPAIR).getValue(new TypeToken<MMOItem<?>>() {}); // MMOItem<?> mmoItem = value.getNode(ITEM_CONSUMED_FOR_REPAIR).getValue(new TypeToken<MMOItem<?>>() {});
if(value.getNode(NBT_REQUIREMENTS).getValueType() != ValueType.NULL) // if(value.getNode(NBT_REQUIREMENTS).getValueType() != ValueType.NULL)
{ // {
HashSet<ItemMatchProperty> itemMatchProperties = value.getNode(NBT_REQUIREMENTS).getValue(new TypeToken<HashSet<ItemMatchProperty>>() {}); // HashSet<ItemMatchProperty> itemMatchProperties = value.getNode(NBT_REQUIREMENTS).getValue(new TypeToken<HashSet<ItemMatchProperty>>() {});
return new ItemMatch(mmoItem, itemMatchProperties); // return new ItemMatch(mmoItem, itemMatchProperties);
} // }
//
return new ItemMatch(mmoItem, null); // return new ItemMatch(mmoItem, null);
} // }
//
@Override // @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable ItemMatch<?> obj, @NonNull ConfigurationNode value) throws ObjectMappingException { // public void serialize(@NonNull TypeToken<?> type, @Nullable ItemMatch<?> obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
value.getNode(ITEM_CONSUMED_FOR_REPAIR).setValue(obj.getItem()); // value.getNode(ITEM_CONSUMED_FOR_REPAIR).setValue(obj.getItem());
//
if(obj.getItemMatchProperties().size() > 0) { // if(obj.getItemMatchProperties().size() > 0) {
value.getNode(NBT_REQUIREMENTS).setValue(obj.getItemMatchProperties()); // 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."); // SerializerUtil.addCommentIfCompatible(value.getNode(NBT_REQUIREMENTS), "List optional NBT that is required here, you write it the same way you do in vanilla commands.");
} // }
} // }
} //}

View File

@ -1,60 +1,60 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.datatypes.items.BukkitMMOItem; //import com.gmail.nossr50.datatypes.items.BukkitMMOItem;
import com.gmail.nossr50.datatypes.items.MMOItem; //import com.gmail.nossr50.datatypes.items.MMOItem;
import com.gmail.nossr50.util.nbt.RawNBT; //import com.gmail.nossr50.util.nbt.RawNBT;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.ValueType; //import ninja.leaping.configurate.ValueType;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.bukkit.Material; //import org.bukkit.Material;
import org.checkerframework.checker.nullness.qual.NonNull; //import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; //import org.checkerframework.checker.nullness.qual.Nullable;
//
public class ItemStackSerializer implements TypeSerializer<MMOItem<?>> { //public class ItemStackSerializer implements TypeSerializer<MMOItem<?>> {
//
private static final String ITEM_MINECRAFT_NAME = "Item-Name"; // private static final String ITEM_MINECRAFT_NAME = "Item-Name";
private static final String AMOUNT = "Amount"; // private static final String AMOUNT = "Amount";
private static final String NBT = "NBT"; // private static final String NBT = "NBT";
//
@Nullable // @Nullable
@Override // @Override
public MMOItem<?> deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { // public MMOItem<?> deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
String itemIdentifier = value.getNode(ITEM_MINECRAFT_NAME).getValue(TypeToken.of(String.class)); // String itemIdentifier = value.getNode(ITEM_MINECRAFT_NAME).getValue(TypeToken.of(String.class));
//
Material itemMatch = Material.matchMaterial(itemIdentifier); // Material itemMatch = Material.matchMaterial(itemIdentifier);
//
if(itemMatch == null) { // if(itemMatch == null) {
System.out.println("[mcMMO Deserializer Debug] Could not find a match for "+itemIdentifier); // System.out.println("[mcMMO Deserializer Debug] Could not find a match for "+itemIdentifier);
return null; // return null;
} // }
//
ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); // ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME);
//
Integer amount; // Integer amount;
//Get the amount of items in the stack // //Get the amount of items in the stack
if(itemNode.getNode(AMOUNT).getValueType() != ValueType.NULL) { // if(itemNode.getNode(AMOUNT).getValueType() != ValueType.NULL) {
amount = itemNode.getNode(AMOUNT).getValue(TypeToken.of(Integer.class)); // amount = itemNode.getNode(AMOUNT).getValue(TypeToken.of(Integer.class));
} else { // } else {
amount = 1; // amount = 1;
} // }
//
RawNBT rawNBT = null; // RawNBT rawNBT = null;
//
if(itemNode.getNode(NBT).getValueType() != ValueType.NULL) { // if(itemNode.getNode(NBT).getValueType() != ValueType.NULL) {
rawNBT = value.getNode(NBT).getValue(TypeToken.of(RawNBT.class)); // rawNBT = value.getNode(NBT).getValue(TypeToken.of(RawNBT.class));
} // }
//
return new BukkitMMOItem(itemIdentifier, amount, rawNBT); // return new BukkitMMOItem(itemIdentifier, amount, rawNBT);
} // }
//
@Override // @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable MMOItem<?> obj, @NonNull ConfigurationNode value) throws ObjectMappingException { // public void serialize(@NonNull TypeToken<?> type, @Nullable MMOItem<?> obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME); // ConfigurationNode itemNode = value.getNode(ITEM_MINECRAFT_NAME);
value.getNode(ITEM_MINECRAFT_NAME).setValue(obj.getNamespaceKey()); // value.getNode(ITEM_MINECRAFT_NAME).setValue(obj.getNamespaceKey());
itemNode.getNode(AMOUNT).setValue(obj.getItemAmount()); // itemNode.getNode(AMOUNT).setValue(obj.getItemAmount());
itemNode.getNode(NBT).setValue(obj.getRawNBT()); // itemNode.getNode(NBT).setValue(obj.getRawNBT());
} // }
//
} //}

View File

@ -1,42 +1,42 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.items.ItemWildcards; //import com.gmail.nossr50.datatypes.items.ItemWildcards;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.ValueType; //import ninja.leaping.configurate.ValueType;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.checkerframework.checker.nullness.qual.NonNull; //import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; //import org.checkerframework.checker.nullness.qual.Nullable;
//
import java.util.HashSet; //import java.util.HashSet;
import java.util.Set; //import java.util.Set;
//
public class ItemWildcardSerializer implements TypeSerializer<ItemWildcards> { //public class ItemWildcardSerializer implements TypeSerializer<ItemWildcards> {
//
private static final String WILDCARD_IDENTIFIER_NAME = "Wildcard-Identifier-Name"; // private static final String WILDCARD_IDENTIFIER_NAME = "Wildcard-Identifier-Name";
private static final String MATCHING_ITEMS = "Matching-Items"; // private static final String MATCHING_ITEMS = "Matching-Items";
//
@Nullable // @Nullable
@Override // @Override
public ItemWildcards deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { // public ItemWildcards deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
//
String wildCardName = value.getNode(WILDCARD_IDENTIFIER_NAME).getValue(TypeToken.of(String.class)); // String wildCardName = value.getNode(WILDCARD_IDENTIFIER_NAME).getValue(TypeToken.of(String.class));
//
if(value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValueType() != ValueType.NULL) { // if(value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValueType() != ValueType.NULL) {
Set<ItemMatch> matchCandidates = value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValue(new TypeToken<Set<ItemMatch>>() {}); // Set<ItemMatch> matchCandidates = value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).getValue(new TypeToken<Set<ItemMatch>>() {});
//
return new ItemWildcards(wildCardName, new HashSet<>(matchCandidates)); // return new ItemWildcards(wildCardName, new HashSet<>(matchCandidates));
} // }
//
return null; // return null;
} // }
//
@Override // @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable ItemWildcards obj, @NonNull ConfigurationNode value) throws ObjectMappingException { // 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).setValue(obj.getWildcardName());
value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).setValue(obj.getItemTargets()); // value.getNode(WILDCARD_IDENTIFIER_NAME).getNode(MATCHING_ITEMS).setValue(obj.getItemTargets());
} // }
//
} //}

View File

@ -1,27 +1,27 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.util.nbt.RawNBT; //import com.gmail.nossr50.util.nbt.RawNBT;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.checkerframework.checker.nullness.qual.NonNull; //import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; //import org.checkerframework.checker.nullness.qual.Nullable;
//
public class RawNBTSerializer implements TypeSerializer<RawNBT> { //public class RawNBTSerializer implements TypeSerializer<RawNBT> {
//
private static final String NBT = "NBT"; // private static final String NBT = "NBT";
//
@Nullable // @Nullable
@Override // @Override
public RawNBT deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { // public RawNBT deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
String nbtString = value.getNode(NBT).getValue(TypeToken.of(String.class)); // String nbtString = value.getNode(NBT).getValue(TypeToken.of(String.class));
return new RawNBT(nbtString); // return new RawNBT(nbtString);
} // }
//
@Override // @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable RawNBT obj, @NonNull ConfigurationNode value) throws ObjectMappingException { // public void serialize(@NonNull TypeToken<?> type, @Nullable RawNBT obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
value.getNode(NBT).setValue(obj.getNbtContents()); // value.getNode(NBT).setValue(obj.getNbtContents());
} // }
//
} //}

View File

@ -1,22 +1,22 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.skills.repair.RepairTransaction; //import com.gmail.nossr50.skills.repair.RepairTransaction;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.checkerframework.checker.nullness.qual.NonNull; //import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; //import org.checkerframework.checker.nullness.qual.Nullable;
//
public class RepairTransactionSerializer implements TypeSerializer<RepairTransaction> { //public class RepairTransactionSerializer implements TypeSerializer<RepairTransaction> {
@Nullable // @Nullable
@Override // @Override
public RepairTransaction deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { // public RepairTransaction deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
return null; // return null;
} // }
//
@Override // @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable RepairTransaction obj, @NonNull ConfigurationNode value) throws ObjectMappingException { // public void serialize(@NonNull TypeToken<?> type, @Nullable RepairTransaction obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
//
} // }
} //}

View File

@ -1,79 +1,79 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; //import com.gmail.nossr50.datatypes.permissions.PermissionWrapper;
import com.gmail.nossr50.skills.repair.RepairTransaction; //import com.gmail.nossr50.skills.repair.RepairTransaction;
import com.gmail.nossr50.skills.repair.repairables.Repairable; //import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableBuilder; //import com.gmail.nossr50.skills.repair.repairables.RepairableBuilder;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.ValueType; //import ninja.leaping.configurate.ValueType;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
//
public class RepairableSerializer implements TypeSerializer<Repairable> { //public class RepairableSerializer implements TypeSerializer<Repairable> {
private static final String REPAIRABLE_ITEM = "Repairable-Item"; // private static final String REPAIRABLE_ITEM = "Repairable-Item";
private static final String MAXIMUM_DURABILITY = "Maximum-Durability"; // private static final String MAXIMUM_DURABILITY = "Maximum-Durability";
private static final String ITEMS_REQUIRED_TO_REPAIR = "Items-Required-To-Repair"; // 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 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_XP_REWARD = "Base-XP-Reward";
private static final String BASE_REPAIR_COUNT = "Base-Repair-Count"; // private static final String BASE_REPAIR_COUNT = "Base-Repair-Count";
private static final String REQUIRED_PERMISSION_NODE = "Required-Permission-Node"; // private static final String REQUIRED_PERMISSION_NODE = "Required-Permission-Node";
//
@Override // @Override
public Repairable deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException { // public Repairable deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
/* Necessary fields */ // /* Necessary fields */
ItemMatch itemMatch = value.getNode(REPAIRABLE_ITEM).getValue(TypeToken.of(ItemMatch.class)); // ItemMatch itemMatch = value.getNode(REPAIRABLE_ITEM).getValue(TypeToken.of(ItemMatch.class));
Short maximumDurability = value.getNode(MAXIMUM_DURABILITY).getValue(TypeToken.of(Short.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)); // RepairTransaction repairTransaction = value.getNode(ITEMS_REQUIRED_TO_REPAIR).getValue(TypeToken.of(RepairTransaction.class));
//
RepairableBuilder repairableBuilder = new RepairableBuilder(itemMatch, maximumDurability, repairTransaction); // RepairableBuilder repairableBuilder = new RepairableBuilder(itemMatch, maximumDurability, repairTransaction);
//
if(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getValueType() != ValueType.NULL) { // if(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getValueType() != ValueType.NULL) {
repairableBuilder.addMinLevel(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getInt()); // repairableBuilder.addMinLevel(value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).getInt());
} // }
//
if(value.getNode(BASE_XP_REWARD).getValueType() != ValueType.NULL) { // if(value.getNode(BASE_XP_REWARD).getValueType() != ValueType.NULL) {
repairableBuilder.setBaseXP(value.getNode(BASE_XP_REWARD).getInt()); // repairableBuilder.setBaseXP(value.getNode(BASE_XP_REWARD).getInt());
} // }
//
if(value.getNode(BASE_REPAIR_COUNT).getValueType() != ValueType.NULL) { // if(value.getNode(BASE_REPAIR_COUNT).getValueType() != ValueType.NULL) {
repairableBuilder.setRepairCount(value.getNode(BASE_REPAIR_COUNT).getInt()); // repairableBuilder.setRepairCount(value.getNode(BASE_REPAIR_COUNT).getInt());
} // }
//
if(value.getNode(REQUIRED_PERMISSION_NODE).getValueType() != ValueType.NULL) { // if(value.getNode(REQUIRED_PERMISSION_NODE).getValueType() != ValueType.NULL) {
repairableBuilder.addPermissionWrapper(value.getNode(REQUIRED_PERMISSION_NODE).getValue(TypeToken.of(PermissionWrapper.class))); // repairableBuilder.addPermissionWrapper(value.getNode(REQUIRED_PERMISSION_NODE).getValue(TypeToken.of(PermissionWrapper.class)));
} // }
//
return repairableBuilder.build(); // return repairableBuilder.build();
} // }
//
@Override // @Override
public void serialize(TypeToken<?> type, Repairable obj, ConfigurationNode value) { // public void serialize(TypeToken<?> type, Repairable obj, ConfigurationNode value) {
value.getNode(REPAIRABLE_ITEM).setValue(obj.getItemMatch()); // value.getNode(REPAIRABLE_ITEM).setValue(obj.getItemMatch());
value.getNode(MAXIMUM_DURABILITY).setValue(obj.getMaximumDurability()); // value.getNode(MAXIMUM_DURABILITY).setValue(obj.getMaximumDurability());
value.getNode(ITEMS_REQUIRED_TO_REPAIR).setValue(obj.getRepairTransaction()); // value.getNode(ITEMS_REQUIRED_TO_REPAIR).setValue(obj.getRepairTransaction());
//
if(obj.getMinimumLevel() > 0) { // if(obj.getMinimumLevel() > 0) {
value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).setValue(obj.getMinimumLevel()); // value.getNode(SKILL_LEVEL_REQUIRED_TO_REPAIR).setValue(obj.getMinimumLevel());
} // }
//
if(obj.getBaseXP() != 0) { // if(obj.getBaseXP() != 0) {
value.getNode(BASE_XP_REWARD).setValue(obj.getBaseXP()); // 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."); // 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) { // if(obj.getRepairCount() != 0) {
value.getNode(BASE_REPAIR_COUNT).setValue(obj.getRepairCount()); // 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." + // 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."); // "\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) { // if(obj.getPermissionWrapper() != null) {
value.getNode(REQUIRED_PERMISSION_NODE).setValue(obj.getPermissionWrapper()); // value.getNode(REQUIRED_PERMISSION_NODE).setValue(obj.getPermissionWrapper());
SerializerUtil.addCommentIfCompatible(value.getNode(REQUIRED_PERMISSION_NODE), "A custom permission node required to repair this item." + // SerializerUtil.addCommentIfCompatible(value.getNode(REQUIRED_PERMISSION_NODE), "A custom permission node required to repair this item." +
"\nThis setting is optional."); // "\nThis setting is optional.");
} // }
} // }
//
} //}

View File

@ -1,28 +1,28 @@
package com.gmail.nossr50.config.serializers; //package com.gmail.nossr50.config.serializers;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.skills.repair.SimpleRepairCost; //import com.gmail.nossr50.skills.repair.SimpleRepairCost;
import com.google.common.reflect.TypeToken; //import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationNode; //import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.objectmapping.ObjectMappingException; //import ninja.leaping.configurate.objectmapping.ObjectMappingException;
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; //import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
import org.checkerframework.checker.nullness.qual.NonNull; //import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; //import org.checkerframework.checker.nullness.qual.Nullable;
//
public class SimpleRepairCostSerializer implements TypeSerializer<SimpleRepairCost> { //public class SimpleRepairCostSerializer implements TypeSerializer<SimpleRepairCost> {
//
private static final String ITEM_MATCH = "Item-Match"; // private static final String ITEM_MATCH = "Item-Match";
//
@Nullable // @Nullable
@Override // @Override
public SimpleRepairCost deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException { // public SimpleRepairCost deserialize(@NonNull TypeToken<?> type, @NonNull ConfigurationNode value) throws ObjectMappingException {
ItemMatch<?> itemMatch = value.getNode(ITEM_MATCH).getValue(new TypeToken<ItemMatch<?>>() {}); // ItemMatch<?> itemMatch = value.getNode(ITEM_MATCH).getValue(new TypeToken<ItemMatch<?>>() {});
SimpleRepairCost<?> simpleRepairCost = new SimpleRepairCost<>(itemMatch); // SimpleRepairCost<?> simpleRepairCost = new SimpleRepairCost<>(itemMatch);
return simpleRepairCost; // return simpleRepairCost;
} // }
//
@Override // @Override
public void serialize(@NonNull TypeToken<?> type, @Nullable SimpleRepairCost obj, @NonNull ConfigurationNode value) throws ObjectMappingException { // public void serialize(@NonNull TypeToken<?> type, @Nullable SimpleRepairCost obj, @NonNull ConfigurationNode value) throws ObjectMappingException {
value.getNode(ITEM_MATCH).setValue(obj.getItemMatch()); // value.getNode(ITEM_MATCH).setValue(obj.getItemMatch());
} // }
} //}

View File

@ -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.general.ConfigRepairGeneral;
import com.gmail.nossr50.config.skills.repair.repairmastery.ConfigRepairRepairMastery; import com.gmail.nossr50.config.skills.repair.repairmastery.ConfigRepairRepairMastery;
import com.gmail.nossr50.config.skills.repair.subskills.ConfigRepairSubSkills; 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.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; 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 @ConfigSerializable
public class ConfigRepair { public class ConfigRepair {
public static final ArrayList<Repairable> CONFIG_REPAIRABLES_DEFAULTS; // public static final ArrayList<Repairable> CONFIG_REPAIRABLES_DEFAULTS;
public static final HashSet<ItemWildcards> REPAIR_WILDCARDS_DEFAULTS; // public static final HashSet<ItemWildcards> REPAIR_WILDCARDS_DEFAULTS;
// public static final Material[] PLANKS = new Material[]{OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS}; // public static final Material[] PLANKS = new Material[]{OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS};
static { static {
REPAIR_WILDCARDS_DEFAULTS = new HashSet<>(); // REPAIR_WILDCARDS_DEFAULTS = new HashSet<>();
//
// List<ItemStack> 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<ItemStack> planksList = Arrays.asList(new ItemStack[]{new ItemStack(OAK_PLANKS, 1), // CONFIG_REPAIRABLES_DEFAULTS = new ArrayList<>();
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<>();
//TODO: Make a builder //TODO: Make a builder
//TODO: Make a builder //TODO: Make a builder
@ -48,30 +33,30 @@ public class ConfigRepair {
//TODO: Make a builder //TODO: Make a builder
//Diamond chestplate //Diamond chestplate
ItemStack diamondArmorItemStack; // ItemStack diamondArmorItemStack;
BukkitMMOItem<ItemStack> diamondArmorMMOItem = new BukkitMMOItem<>(DIAMOND_CHESTPLATE.getKey().toString(), 1, null); // BukkitMMOItem<ItemStack> diamondArmorMMOItem = new BukkitMMOItem<>(DIAMOND_CHESTPLATE.getKey().toString(), 1, null);
ItemMatch<BukkitMMOItem<ItemStack>> diamondArmorItemMatch = new ItemMatch<>(diamondArmorMMOItem, null); // ItemMatch<BukkitMMOItem<ItemStack>> diamondArmorItemMatch = new ItemMatch<>(diamondArmorMMOItem, null);
//
//Diamond Ore // //Diamond Ore
BukkitMMOItem<ItemStack> diamondOre = new BukkitMMOItem<>(DIAMOND.getKey().toString(), 1, null); // BukkitMMOItem<ItemStack> diamondOre = new BukkitMMOItem<>(DIAMOND.getKey().toString(), 1, null);
ItemMatch<BukkitMMOItem<ItemStack>> diamondOreItemMatch = new ItemMatch<>(diamondArmorMMOItem, null); // ItemMatch<BukkitMMOItem<ItemStack>> diamondOreItemMatch = new ItemMatch<>(diamondArmorMMOItem, null);
//
//Repair Cost(s) // //Repair Cost(s)
SimpleRepairCost<ItemMatch> diamondArmorRepairCost = new SimpleRepairCost<ItemMatch>(diamondOreItemMatch); //Just diamonds // SimpleRepairCost<ItemMatch> diamondArmorRepairCost = new SimpleRepairCost<ItemMatch>(diamondOreItemMatch); //Just diamonds
//
//Repair Cost Hash Set // //Repair Cost Hash Set
HashSet<RepairCost> diamondArmorRepairCosts = new HashSet<>(); // HashSet<RepairCost> diamondArmorRepairCosts = new HashSet<>();
diamondArmorRepairCosts.add(diamondArmorRepairCost); //Only costs 1 item // diamondArmorRepairCosts.add(diamondArmorRepairCost); //Only costs 1 item
//
RepairTransaction repairTransaction = new RepairTransaction(diamondArmorRepairCosts); // RepairTransaction repairTransaction = new RepairTransaction(diamondArmorRepairCosts);
Repairable diamondArmor = new Repairable(diamondArmorItemMatch, 0, diamondArmorMMOItem.getItemImplementation().getType().getMaxDurability(), repairTransaction, 1000, 10, null); // 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
//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_SWORD, planksWildCard, 1, 0, .25D));
// CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SHOVEL, planksWildCard, 1, 0, .15D)); // CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SHOVEL, planksWildCard, 1, 0, .15D));
// CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_PICKAXE, Arrays.asList(PLANKS), 1, 0, .5D)); // CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_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") @Setting(value = ConfigConstants.SUB_SKILL_NODE, comment = "Settings for subskills stemming from Repair")
private ConfigRepairSubSkills repairSubSkills = new ConfigRepairSubSkills(); 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." + // @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." + // "\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 --" + // "\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" + // "\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" + // "\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." + // "\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." + // "\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." + // "\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" + // "\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\"") // "\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<Repairable> configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS; // private ArrayList<Repairable> configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS;
@Setting(value = "Z-Repairables-Wildcards", comment = "Used to define an alias that can be matched to several materials.") // @Setting(value = "Z-Repairables-Wildcards", comment = "Used to define an alias that can be matched to several materials.")
private HashSet<ItemWildcards> itemWildcards = new HashSet<>(); // private HashSet<ItemWildcards> itemWildcards = new HashSet<>();
public ConfigRepairGeneral getRepairGeneral() { public ConfigRepairGeneral getRepairGeneral() {
return repairGeneral; return repairGeneral;
@ -164,11 +149,11 @@ public class ConfigRepair {
return repairSubSkills.getArcaneForging(); return repairSubSkills.getArcaneForging();
} }
public ArrayList<Repairable> getConfigRepairablesList() { // public ArrayList<Repairable> getConfigRepairablesList() {
return configRepairablesList; // return configRepairablesList;
} // }
public HashSet<ItemWildcards> getItemWildcards() { // public HashSet<ItemWildcards> getItemWildcards() {
return itemWildcards; // return itemWildcards;
} // }
} }

View File

@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.behaviours.SkillBehaviourManager; import com.gmail.nossr50.datatypes.skills.behaviours.SkillBehaviourManager;
import com.gmail.nossr50.mcMMO; 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.Salvageable;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.util.experience.ExperienceManager; import com.gmail.nossr50.util.experience.ExperienceManager;
@ -31,7 +29,7 @@ public class DynamicSettingsManager {
private SkillPropertiesManager skillPropertiesManager; private SkillPropertiesManager skillPropertiesManager;
/* COLLECTION MANAGERS */ /* COLLECTION MANAGERS */
private RepairableManager repairableManager; // private RepairableManager repairableManager;
private SalvageableManager salvageableManager; private SalvageableManager salvageableManager;
/* Platform Ready Managers */ /* Platform Ready Managers */
@ -113,7 +111,7 @@ public class DynamicSettingsManager {
*/ */
private void initCollectionManagers() { private void initCollectionManagers() {
// Handles registration of repairables // Handles registration of repairables
repairableManager = new RepairableManager(getRepairables()); // repairableManager = new RepairableManager(getRepairables());
// Handles registration of salvageables // Handles registration of salvageables
salvageableManager = new SalvageableManager(getSalvageables()); salvageableManager = new SalvageableManager(getSalvageables());
@ -130,9 +128,9 @@ public class DynamicSettingsManager {
* *
* @return the currently loaded repairables * @return the currently loaded repairables
*/ */
public ArrayList<Repairable> getRepairables() { // public ArrayList<Repairable> getRepairables() {
return pluginRef.getConfigManager().getConfigRepair().getConfigRepairablesList(); // return pluginRef.getConfigManager().getConfigRepair().getConfigRepairablesList();
} // }
/** /**
* Get all loaded salvageables (loaded from all salvageable configs) * Get all loaded salvageables (loaded from all salvageable configs)
@ -152,9 +150,9 @@ public class DynamicSettingsManager {
// bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops()); // bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops());
} }
public RepairableManager getRepairableManager() { // public RepairableManager getRepairableManager() {
return repairableManager; // return repairableManager;
} // }
public SalvageableManager getSalvageableManager() { public SalvageableManager getSalvageableManager() {
return salvageableManager; return salvageableManager;

View File

@ -1,63 +1,63 @@
package com.gmail.nossr50.datatypes.items; //package com.gmail.nossr50.datatypes.items;
//
import com.gmail.nossr50.util.nbt.RawNBT; //import com.gmail.nossr50.util.nbt.RawNBT;
import org.bukkit.Bukkit; //import org.bukkit.Bukkit;
import org.bukkit.Material; //import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; //import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; //import org.bukkit.inventory.meta.ItemMeta;
//
public class BukkitMMOItem<T extends ItemStack> implements MMOItem<T> { //public class BukkitMMOItem<T extends ItemStack> implements MMOItem<T> {
//
private T itemImplementation; // private T itemImplementation;
private RawNBT rawNBT; // private RawNBT rawNBT;
//
//Suppressed because the type is always an ItemStack // //Suppressed because the type is always an ItemStack
@SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")
public BukkitMMOItem(String namespaceKey, int amount, RawNBT rawNBT) throws NullPointerException { // public BukkitMMOItem(String namespaceKey, int amount, RawNBT rawNBT) throws NullPointerException {
T itemStack; // T itemStack;
Material material = Material.matchMaterial(namespaceKey); // Material material = Material.matchMaterial(namespaceKey);
//
if(material == null) { // if(material == null) {
throw new NullPointerException("Material for user defined item could not be found in the server software."); // throw new NullPointerException("Material for user defined item could not be found in the server software.");
} // }
//
itemStack = (T) new ItemStack(material); // itemStack = (T) new ItemStack(material);
//
//Get default item meta // //Get default item meta
ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(itemStack.getType()); // ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(itemStack.getType());
//
//Set default item meta // //Set default item meta
itemStack.setItemMeta(itemMeta); // itemStack.setItemMeta(itemMeta);
//
//Set amount // //Set amount
itemStack.setAmount(amount); // itemStack.setAmount(amount);
//
this.itemImplementation = itemStack; // this.itemImplementation = itemStack;
this.rawNBT = rawNBT; // this.rawNBT = rawNBT;
} // }
//
public BukkitMMOItem(T itemStack) { // public BukkitMMOItem(T itemStack) {
this.itemImplementation = itemStack; // this.itemImplementation = itemStack;
} // }
//
@Override // @Override
public T getItemImplementation() { // public T getItemImplementation() {
return itemImplementation; // return itemImplementation;
} // }
//
@Override // @Override
public String getNamespaceKey() { // public String getNamespaceKey() {
return itemImplementation.getType().getKey().toString(); // return itemImplementation.getType().getKey().toString();
} // }
//
@Override // @Override
public int getItemAmount() { // public int getItemAmount() {
return itemImplementation.getAmount(); // return itemImplementation.getAmount();
} // }
//
@Override // @Override
public RawNBT getRawNBT() { // public RawNBT getRawNBT() {
return rawNBT; // return rawNBT;
} // }
//
} //}

View File

@ -1,128 +1,128 @@
package com.gmail.nossr50.datatypes.items; //package com.gmail.nossr50.datatypes.items;
//
import com.gmail.nossr50.util.nbt.NBTManager; //import com.gmail.nossr50.util.nbt.NBTManager;
//
import java.util.HashSet; //import java.util.HashSet;
import java.util.Objects; //import java.util.Objects;
import java.util.Set; //import java.util.Set;
//
/** ///**
* This type contains data and rules which govern equating equivalency between one item and another in Minecraft. // * 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 // * 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 // * 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. // * 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) // * 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. // * 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 // * 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 // * 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. // * 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, // * 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. // * 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... // * In summary, this type serves several purposes...
* 1) Abstract away platform specific implementations of MC Items // * 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 // * 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<T extends MMOItem<?>> implements DefinedMatch<MMOItem<T>> { //public class ItemMatch<T extends MMOItem<?>> implements DefinedMatch<MMOItem<T>> {
//
private T item; //Abstract representation of the item // private T item; //Abstract representation of the item
private Set<ItemMatchProperty> itemMatchProperties; //Item properties used for matching // private Set<ItemMatchProperty> itemMatchProperties; //Item properties used for matching
//
public ItemMatch(T item) { // public ItemMatch(T item) {
this.item = item; // this.item = item;
itemMatchProperties = new HashSet<>(); // itemMatchProperties = new HashSet<>();
} // }
//
public ItemMatch(T item, Set<ItemMatchProperty> itemMatchProperties) { // public ItemMatch(T item, Set<ItemMatchProperty> itemMatchProperties) {
this.item = item; // this.item = item;
this.itemMatchProperties = itemMatchProperties; // this.itemMatchProperties = itemMatchProperties;
} // }
//
/** // /**
* Gets the item held by this ItemMatch // * Gets the item held by this ItemMatch
* @return the item used for matching // * @return the item used for matching
*/ // */
public T getItem() { // public T getItem() {
return item; // return item;
} // }
//
/** // /**
* Get the item match properties of this ItemMatch // * Get the item match properties of this ItemMatch
* @return the item match properties // * @return the item match properties
*/ // */
public Set<ItemMatchProperty> getItemMatchProperties() { // public Set<ItemMatchProperty> getItemMatchProperties() {
return itemMatchProperties; // return itemMatchProperties;
} // }
//
/** // /**
* Determines whether or not an item matches this one // * Determines whether or not an item matches this one
* Behaviours for matching can vary based on the implementation // * Behaviours for matching can vary based on the implementation
* @param otherItem target item to compare itself to // * @param otherItem target item to compare itself to
* @return true if this item matches the target item // * @return true if this item matches the target item
*/ // */
@Override // @Override
public boolean isMatch(MMOItem<T> otherItem) { // public boolean isMatch(MMOItem<T> otherItem) {
if(hasStrictMatching()) { // if(hasStrictMatching()) {
return isStrictMatch(otherItem); // return isStrictMatch(otherItem);
} else { // } else {
return isUnstrictMatch(otherItem); // 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 // * 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 // * @param otherItem item to strictly match
* @return true if the items are considered a match // * @return true if the items are considered a match
*/ // */
private boolean isStrictMatch(MMOItem<T> otherItem) { // private boolean isStrictMatch(MMOItem<T> otherItem) {
for(ItemMatchProperty itemMatchProperty : itemMatchProperties) { // for(ItemMatchProperty itemMatchProperty : itemMatchProperties) {
if(!NBTManager.hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) { // if(!NBTManager.hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) {
return false; // return false;
} // }
} // }
//
//All item match properties were found and matched // //All item match properties were found and matched
return true; // return true;
} // }
//
/** // /**
* Compare this item to another only by namespace key // * Compare this item to another only by namespace key
* @param otherItem item to compare namespace keys with // * @param otherItem item to compare namespace keys with
* @return true if the items share namespace keys // * @return true if the items share namespace keys
*/ // */
private boolean isUnstrictMatch(MMOItem<T> otherItem) { // private boolean isUnstrictMatch(MMOItem<T> otherItem) {
if(otherItem.getNamespaceKey().equalsIgnoreCase(item.getNamespaceKey())) { // if(otherItem.getNamespaceKey().equalsIgnoreCase(item.getNamespaceKey())) {
return true; // return true;
} // }
//
//Namespace didn't match reject item // //Namespace didn't match reject item
return false; // return false;
} // }
//
/** // /**
* If this item has strict matching or loose match // * If this item has strict matching or loose match
* Solely determined by having any item match properties present // * Solely determined by having any item match properties present
* @return true if this item target has strict matching // * @return true if this item target has strict matching
*/ // */
public boolean hasStrictMatching() { // public boolean hasStrictMatching() {
return itemMatchProperties.size() > 1; // return itemMatchProperties.size() > 1;
} // }
//
@Override // @Override
public boolean equals(Object o) { // public boolean equals(Object o) {
if (this == o) return true; // if (this == o) return true;
if (!(o instanceof ItemMatch)) return false; // if (!(o instanceof ItemMatch)) return false;
ItemMatch<?> itemMatch = (ItemMatch<?>) o; // ItemMatch<?> itemMatch = (ItemMatch<?>) o;
return getItem().equals(itemMatch.getItem()) && // return getItem().equals(itemMatch.getItem()) &&
getItemMatchProperties().equals(itemMatch.getItemMatchProperties()); // getItemMatchProperties().equals(itemMatch.getItemMatchProperties());
} // }
//
@Override // @Override
public int hashCode() { // public int hashCode() {
return Objects.hash(getItem(), getItemMatchProperties()); // return Objects.hash(getItem(), getItemMatchProperties());
} // }
} //}

View File

@ -1,60 +1,60 @@
package com.gmail.nossr50.datatypes.items; //package com.gmail.nossr50.datatypes.items;
//
import java.util.HashSet; //import java.util.HashSet;
import java.util.Objects; //import java.util.Objects;
import java.util.Set; //import java.util.Set;
//
/** ///**
* Represents a series of items that are all acceptable inputs for a behaviour // * 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. // * 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. // * The name is important as it is used to identify the wildcard to the player.
* // *
* One example of the purpose of this Datatype: // * 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 // * 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 // * 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 // * 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. // * to solve a problem with Repair. Given its flexible nature it can be used for many purposes.
* // *
*/ // */
public class ItemWildcards<T extends MMOItem<?>> { //public class ItemWildcards<T extends MMOItem<?>> {
//
private String wildcardName; // private String wildcardName;
private Set<ItemMatch<T>> itemTargets; // private Set<ItemMatch<T>> itemTargets;
//
public ItemWildcards(String wildcardName, Set<ItemMatch<T>> itemTargets) { // public ItemWildcards(String wildcardName, Set<ItemMatch<T>> itemTargets) {
this.wildcardName = wildcardName; // this.wildcardName = wildcardName;
this.itemTargets = itemTargets; // this.itemTargets = itemTargets;
} // }
//
public int getItemCount() { // public int getItemCount() {
return itemTargets.size(); // return itemTargets.size();
} // }
//
public Set<ItemMatch<T>> getItemTargets() { // public Set<ItemMatch<T>> getItemTargets() {
return itemTargets; // return itemTargets;
} // }
//
public void setItemTargets(HashSet<ItemMatch<T>> itemTargets) { // public void setItemTargets(HashSet<ItemMatch<T>> itemTargets) {
this.itemTargets = itemTargets; // this.itemTargets = itemTargets;
} // }
//
public String getWildcardName() { // public String getWildcardName() {
return wildcardName; // return wildcardName;
} // }
//
@Override // @Override
public boolean equals(Object o) { // public boolean equals(Object o) {
if (this == o) return true; // if (this == o) return true;
if (!(o instanceof ItemWildcards)) return false; // if (!(o instanceof ItemWildcards)) return false;
ItemWildcards that = (ItemWildcards) o; // ItemWildcards that = (ItemWildcards) o;
return getWildcardName().equals(that.getWildcardName()) && // return getWildcardName().equals(that.getWildcardName()) &&
getItemTargets().equals(that.getItemTargets()); // getItemTargets().equals(that.getItemTargets());
} // }
//
@Override // @Override
public int hashCode() { // public int hashCode() {
return Objects.hash(getWildcardName(), getItemTargets()); // return Objects.hash(getWildcardName(), getItemTargets());
} // }
} //}

View File

@ -1,39 +1,39 @@
package com.gmail.nossr50.datatypes.items; //package com.gmail.nossr50.datatypes.items;
//
import com.gmail.nossr50.util.nbt.RawNBT; //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 // * 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 // * Return types of this object are not platform specific
* Only requires a namespace key to be defined, all other properties will be default initialized // * Only requires a namespace key to be defined, all other properties will be default initialized
*/ // */
public interface MMOItem<T> { //public interface MMOItem<T> {
//
/** // /**
* Gets the item implementation of this type for this object // * Gets the item implementation of this type for this object
* @return the item implementation // * @return the item implementation
*/ // */
T getItemImplementation(); // T getItemImplementation();
//
/** // /**
* Get the Minecraft fully qualified namespace (FQN) key for this item // * Get the Minecraft fully qualified namespace (FQN) key for this item
* Typically the FQN will read like this 'minecraft:name_here' // * Typically the FQN will read like this 'minecraft:name_here'
* @return the fully qualified namespace key for this item // * @return the fully qualified namespace key for this item
*/ // */
String getNamespaceKey(); // String getNamespaceKey();
//
/** // /**
* Get the amount of this Item // * Get the amount of this Item
* Items in Minecraft are technically stacks of items with the minimum amount being 1 in most cases // * 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 // * The amount is used for matching purposes, and should default to 1 if undefined
* @return the amount for this Item // * @return the amount for this Item
*/ // */
int getItemAmount(); // int getItemAmount();
//
/** // /**
* Get the RawNBT for this item if it has any // * Get the RawNBT for this item if it has any
* This can be null // * This can be null
* @return the raw NBT if it exists, null otherwise // * @return the raw NBT if it exists, null otherwise
*/ // */
RawNBT getRawNBT(); // RawNBT getRawNBT();
} //}

View File

@ -1,26 +1,26 @@
package com.gmail.nossr50.datatypes.nbt; //package com.gmail.nossr50.datatypes.nbt;
//
import com.gmail.nossr50.util.nbt.RawNBT; //import com.gmail.nossr50.util.nbt.RawNBT;
//
/** ///**
* Many things in Minecraft make use of the NBT System // * Many things in Minecraft make use of the NBT System
* You can read about the NBT System here - https://wiki.vg/NBT // * You can read about the NBT System here - https://wiki.vg/NBT
* // *
* Types that support NBT will implement this interface // * Types that support NBT will implement this interface
*/ // */
public interface NBTHolder { //public interface NBTHolder {
//
/** // /**
* Get the RawNBT for this object // * Get the RawNBT for this object
* @return the RawNBT for this object // * @return the RawNBT for this object
*/ // */
RawNBT getRawNBT(); // RawNBT getRawNBT();
//
/** // /**
* Determine whether or not this object has the specific NBT entry and matching value // * Determine whether or not this object has the specific NBT entry and matching value
* @param id the ID fof the NBT entry // * @param id the ID fof the NBT entry
* @param value the value of the NBT entry // * @param value the value of the NBT entry
* @return returns true if the NBT of id exists and its value matches // * @return returns true if the NBT of id exists and its value matches
*/ // */
boolean hasNBTValue(String id, Object value); // boolean hasNBTValue(String id, Object value);
} //}

View File

@ -13,8 +13,6 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; 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.skills.taming.TamingManager;
import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -599,40 +597,41 @@ public class PlayerListener implements Listener {
case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
Material type = block.getType(); Material type = block.getType();
if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { // if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) {
/* REPAIR CHECKS */ // /* REPAIR CHECKS */
if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial() // if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getRepairBehaviour().getAnvilMaterial()
&& pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player) // && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.REPAIR, player)
&& pluginRef.getRepairableManager().isRepairable(heldItem) // && pluginRef.getRepairableManager().isRepairable(heldItem)
&& heldItem.getAmount() <= 1) { // && heldItem.getAmount() <= 1) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); // RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true); // event.setCancelled(true);
//
// Make sure the player knows what he's doing when trying to repair an enchanted item // // Make sure the player knows what he's doing when trying to repair an enchanted item
if (repairManager.checkConfirmation(true)) { // if (repairManager.checkConfirmation(true)) {
repairManager.handleRepair(heldItem); // repairManager.handleRepair(heldItem);
player.updateInventory(); // player.updateInventory();
} // }
} // }
/* SALVAGE CHECKS */ // /* SALVAGE CHECKS */
else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial() // else if (type == pluginRef.getDynamicSettingsManager().getSkillBehaviourManager().getSalvageBehaviour().getAnvilMaterial()
&& pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player) // && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.SALVAGE, player)
&& pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) // && pluginRef.getRankTools().hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& pluginRef.getSalvageableManager().isSalvageable(heldItem) // && pluginRef.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) { // && heldItem.getAmount() <= 1) {
SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager(); // SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager();
event.setCancelled(true); // event.setCancelled(true);
//
// Make sure the player knows what he's doing when trying to salvage an enchanted item // // Make sure the player knows what he's doing when trying to salvage an enchanted item
if (salvageManager.checkConfirmation(true)) { // if (salvageManager.checkConfirmation(true)) {
pluginRef.getSkillTools().handleAbilitySpeedDecrease(player); // pluginRef.getSkillTools().handleAbilitySpeedDecrease(player);
salvageManager.handleSalvage(block.getLocation(), heldItem); // salvageManager.handleSalvage(block.getLocation(), heldItem);
player.updateInventory(); // player.updateInventory();
} // }
} // }
} // }
/* BLAST MINING CHECK */ /* 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) { if (type == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close event.setCancelled(true); // Don't detonate the TNT if they're too close
} else { } else {

View File

@ -26,7 +26,6 @@ import com.gmail.nossr50.runnables.player.ClearRegisteredXPGainTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask; import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask; 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.skills.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
@ -431,9 +430,9 @@ public class mcMMO extends JavaPlugin {
return placeStore; return placeStore;
} }
public RepairableManager getRepairableManager() { // public RepairableManager getRepairableManager() {
return dynamicSettingsManager.getRepairableManager(); // return dynamicSettingsManager.getRepairableManager();
} // }
public SalvageableManager getSalvageableManager() { public SalvageableManager getSalvageableManager() {
return dynamicSettingsManager.getSalvageableManager(); return dynamicSettingsManager.getSalvageableManager();

View File

@ -1,25 +1,25 @@
package com.gmail.nossr50.skills.repair; //package com.gmail.nossr50.skills.repair;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import org.bukkit.inventory.PlayerInventory; //import org.bukkit.inventory.PlayerInventory;
//
/** ///**
* Represents one item in a Repair Transaction // * Represents one item in a Repair Transaction
*/ // */
public interface RepairCost { //public interface RepairCost {
//
/** // /**
* Searches a player inventory for a matching ItemStack that can be used to pay for the repair transaction // * 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 // * @param playerInventory inventory of player attempting to pay the cost
* @return any compatible payment items if found, can be null // * @return any compatible payment items if found, can be null
*/ // */
ItemMatch<?> findPayment(PlayerInventory playerInventory); // ItemMatch<?> findPayment(PlayerInventory playerInventory);
//
/** // /**
* Whether or not there is an item that can be used for this repair cost in the player's inventory // * Whether or not there is an item that can be used for this repair cost in the player's inventory
* @param playerInventory target player // * @param playerInventory target player
* @return true if payment is found // * @return true if payment is found
*/ // */
boolean hasPayment(PlayerInventory playerInventory); // boolean hasPayment(PlayerInventory playerInventory);
//
} //}

View File

@ -1,50 +1,50 @@
package com.gmail.nossr50.skills.repair; //package com.gmail.nossr50.skills.repair;
//
//
import org.bukkit.inventory.PlayerInventory; //import org.bukkit.inventory.PlayerInventory;
//
import java.util.HashSet; //import java.util.HashSet;
//
/** ///**
* Represents a complete "repair transaction" // * Represents a complete "repair transaction"
* // *
* I will define a "repair transaction" as such // * 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 // * - 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 // * A single "RepairTransaction" is made up of a multiple RepairCost objects
* No two RepairCosts contained within this type can be exact duplicates // * 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 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 // * 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 // * to pay that part of the RepairTransaction
*/ // */
public class RepairTransaction { //public class RepairTransaction {
private HashSet<RepairCost> repairCosts; // private HashSet<RepairCost> repairCosts;
//
public RepairTransaction(HashSet<RepairCost> repairCosts) { // public RepairTransaction(HashSet<RepairCost> repairCosts) {
this.repairCosts = repairCosts; // this.repairCosts = repairCosts;
} // }
//
public void addRepairCost(RepairCost repairCost) { // public void addRepairCost(RepairCost repairCost) {
repairCosts.add(repairCost); // repairCosts.add(repairCost);
} // }
//
public HashSet<RepairCost> getRepairCosts() { // public HashSet<RepairCost> getRepairCosts() {
return repairCosts; // return repairCosts;
} // }
//
public void setRepairCosts(HashSet<RepairCost> repairItems) { // public void setRepairCosts(HashSet<RepairCost> repairItems) {
this.repairCosts = repairItems; // this.repairCosts = repairItems;
} // }
//
public boolean canPayRepairCosts(PlayerInventory playerInventory) { // public boolean canPayRepairCosts(PlayerInventory playerInventory) {
for(RepairCost repairCost : repairCosts) { // for(RepairCost repairCost : repairCosts) {
if(!repairCost.hasPayment(playerInventory)) { // if(!repairCost.hasPayment(playerInventory)) {
return false; // return false;
} // }
} // }
//
return true; // return true;
} // }
} //}

View File

@ -1,53 +1,53 @@
package com.gmail.nossr50.skills.repair; //package com.gmail.nossr50.skills.repair;
//
import com.gmail.nossr50.bukkit.BukkitFactory; //import com.gmail.nossr50.bukkit.BukkitFactory;
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.items.MMOItem; //import com.gmail.nossr50.datatypes.items.MMOItem;
import org.bukkit.Material; //import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; //import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; //import org.bukkit.inventory.PlayerInventory;
//
/** ///**
* Implementation of RepairCost // * Implementation of RepairCost
* // *
* A SimpleRepairCost can be one or more items, any one of which can be used to pay for a RepairTransaction // * 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. // * 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. // * 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 // * @see com.gmail.nossr50.skills.repair.RepairTransaction for more details
*/ // */
public class SimpleRepairCost<T extends ItemMatch> implements RepairCost { //public class SimpleRepairCost<T extends ItemMatch> implements RepairCost {
//
private T itemMatch; // private T itemMatch;
//
public SimpleRepairCost(T customItemTarget) { // public SimpleRepairCost(T customItemTarget) {
this.itemMatch = customItemTarget; // this.itemMatch = customItemTarget;
} // }
//
@Override // @Override
public T findPayment(PlayerInventory playerInventory) { // public T findPayment(PlayerInventory playerInventory) {
for(ItemStack itemStack : playerInventory.getContents()) { // for(ItemStack itemStack : playerInventory.getContents()) {
if(itemStack == null || itemStack.getType() == Material.AIR) // if(itemStack == null || itemStack.getType() == Material.AIR)
continue; // continue;
//
MMOItem<T> playerInventoryItem = (MMOItem<T>) BukkitFactory.createItem(itemStack); // MMOItem<T> playerInventoryItem = (MMOItem<T>) BukkitFactory.createItem(itemStack);
//
if(itemMatch.isMatch(playerInventoryItem)) { // if(itemMatch.isMatch(playerInventoryItem)) {
//Item is a match // //Item is a match
return (T) playerInventoryItem; // return (T) playerInventoryItem;
} // }
//
} // }
//
return null; // return null;
} // }
//
public T getItemMatch() { // public T getItemMatch() {
return itemMatch; // return itemMatch;
} // }
//
@Override // @Override
public boolean hasPayment(PlayerInventory playerInventory) { // public boolean hasPayment(PlayerInventory playerInventory) {
return findPayment(playerInventory) != null; // return findPayment(playerInventory) != null;
} // }
} //}

View File

@ -1,94 +1,94 @@
package com.gmail.nossr50.skills.repair.repairables; //package com.gmail.nossr50.skills.repair.repairables;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; //import com.gmail.nossr50.datatypes.permissions.PermissionWrapper;
import com.gmail.nossr50.skills.repair.RepairTransaction; //import com.gmail.nossr50.skills.repair.RepairTransaction;
//
public class Repairable { //public class Repairable {
private int minimumLevel; // private int minimumLevel;
private short maximumDurability; // private short maximumDurability;
private RepairTransaction repairTransaction; // private RepairTransaction repairTransaction;
private int baseXP; // private int baseXP;
private ItemMatch itemMatch; // private ItemMatch itemMatch;
private int repairCount; // private int repairCount;
private PermissionWrapper permissionWrapper; // private PermissionWrapper permissionWrapper;
private boolean hasPermission = false; // private boolean hasPermission = false;
//
public Repairable(ItemMatch itemMatch, int minimumLevel, short maximumDurability, RepairTransaction repairTransaction, int baseXP, int repairCount, PermissionWrapper permissionWrapper) { // public Repairable(ItemMatch itemMatch, int minimumLevel, short maximumDurability, RepairTransaction repairTransaction, int baseXP, int repairCount, PermissionWrapper permissionWrapper) {
this.minimumLevel = minimumLevel; // this.minimumLevel = minimumLevel;
this.maximumDurability = maximumDurability; // this.maximumDurability = maximumDurability;
this.repairTransaction = repairTransaction; // this.repairTransaction = repairTransaction;
this.baseXP = baseXP; // this.baseXP = baseXP;
this.itemMatch = itemMatch; // this.itemMatch = itemMatch;
this.repairCount = repairCount; // this.repairCount = repairCount;
this.permissionWrapper = permissionWrapper; // this.permissionWrapper = permissionWrapper;
//
if(permissionWrapper != null) // if(permissionWrapper != null)
hasPermission = true; // hasPermission = true;
} // }
//
public int getMinimumLevel() { // public int getMinimumLevel() {
return minimumLevel; // return minimumLevel;
} // }
//
public void setMinimumLevel(int minimumLevel) { // public void setMinimumLevel(int minimumLevel) {
this.minimumLevel = minimumLevel; // this.minimumLevel = minimumLevel;
} // }
//
public short getMaximumDurability() { // public short getMaximumDurability() {
return maximumDurability; // return maximumDurability;
} // }
//
public void setMaximumDurability(short maximumDurability) { // public void setMaximumDurability(short maximumDurability) {
this.maximumDurability = maximumDurability; // this.maximumDurability = maximumDurability;
} // }
//
public RepairTransaction getRepairTransaction() { // public RepairTransaction getRepairTransaction() {
return repairTransaction; // return repairTransaction;
} // }
//
public void setRepairTransaction(RepairTransaction repairTransaction) { // public void setRepairTransaction(RepairTransaction repairTransaction) {
this.repairTransaction = repairTransaction; // this.repairTransaction = repairTransaction;
} // }
//
public int getBaseXP() { // public int getBaseXP() {
return baseXP; // return baseXP;
} // }
//
public void setBaseXP(int baseXP) { // public void setBaseXP(int baseXP) {
this.baseXP = baseXP; // this.baseXP = baseXP;
} // }
//
public ItemMatch getItemMatch() { // public ItemMatch getItemMatch() {
return itemMatch; // return itemMatch;
} // }
//
public void setItemMatch(ItemMatch itemMatch) { // public void setItemMatch(ItemMatch itemMatch) {
this.itemMatch = itemMatch; // this.itemMatch = itemMatch;
} // }
//
public int getRepairCount() { // public int getRepairCount() {
return repairCount; // return repairCount;
} // }
//
public void setRepairCount(int repairCount) { // public void setRepairCount(int repairCount) {
this.repairCount = repairCount; // this.repairCount = repairCount;
} // }
//
public PermissionWrapper getPermissionWrapper() { // public PermissionWrapper getPermissionWrapper() {
return permissionWrapper; // return permissionWrapper;
} // }
//
public void setPermissionWrapper(PermissionWrapper permissionWrapper) { // public void setPermissionWrapper(PermissionWrapper permissionWrapper) {
this.permissionWrapper = permissionWrapper; // this.permissionWrapper = permissionWrapper;
} // }
//
public boolean hasPermissionNode() { // public boolean hasPermissionNode() {
return hasPermission; // return hasPermission;
} // }
//
public void setHasPermission(boolean hasPermission) { // public void setHasPermission(boolean hasPermission) {
this.hasPermission = hasPermission; // this.hasPermission = hasPermission;
} // }
//
} //}

View File

@ -1,64 +1,64 @@
package com.gmail.nossr50.skills.repair.repairables; //package com.gmail.nossr50.skills.repair.repairables;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import com.gmail.nossr50.datatypes.permissions.PermissionWrapper; //import com.gmail.nossr50.datatypes.permissions.PermissionWrapper;
import com.gmail.nossr50.skills.repair.RepairTransaction; //import com.gmail.nossr50.skills.repair.RepairTransaction;
//
public class RepairableBuilder { //public class RepairableBuilder {
//
private int minimumLevel; // private int minimumLevel;
private short maximumDurability; // private short maximumDurability;
private RepairTransaction repairTransaction; // private RepairTransaction repairTransaction;
private int baseXP; // private int baseXP;
private ItemMatch itemMatch; // private ItemMatch itemMatch;
private int repairCount; // private int repairCount;
private PermissionWrapper permissionWrapper; // private PermissionWrapper permissionWrapper;
//
public RepairableBuilder(ItemMatch itemMatch, Short maximumDurability, RepairTransaction repairTransaction) { // public RepairableBuilder(ItemMatch itemMatch, Short maximumDurability, RepairTransaction repairTransaction) {
this.itemMatch = itemMatch; // this.itemMatch = itemMatch;
this.maximumDurability = maximumDurability; // this.maximumDurability = maximumDurability;
this.repairTransaction = repairTransaction; // this.repairTransaction = repairTransaction;
} // }
//
public RepairableBuilder addMinLevel(Integer minimumLevel) { // public RepairableBuilder addMinLevel(Integer minimumLevel) {
this.minimumLevel = minimumLevel; // this.minimumLevel = minimumLevel;
return this; // return this;
} // }
//
public RepairableBuilder setMaximumDurability(Short maximumDurability) { // public RepairableBuilder setMaximumDurability(Short maximumDurability) {
this.maximumDurability = maximumDurability; // this.maximumDurability = maximumDurability;
return this; // return this;
} // }
//
public RepairableBuilder setRepairTransaction(RepairTransaction repairTransaction) { // public RepairableBuilder setRepairTransaction(RepairTransaction repairTransaction) {
this.repairTransaction = repairTransaction; // this.repairTransaction = repairTransaction;
return this; // return this;
} // }
//
public RepairableBuilder setBaseXP(Integer baseXP) { // public RepairableBuilder setBaseXP(Integer baseXP) {
this.baseXP = baseXP; // this.baseXP = baseXP;
return this; // return this;
} // }
//
public RepairableBuilder setRepairCount(Integer repairCount) { // public RepairableBuilder setRepairCount(Integer repairCount) {
this.repairCount = repairCount; // this.repairCount = repairCount;
return this; // return this;
} // }
//
public RepairableBuilder addPermissionWrapper(PermissionWrapper permissionWrapper) { // public RepairableBuilder addPermissionWrapper(PermissionWrapper permissionWrapper) {
this.permissionWrapper = permissionWrapper; // this.permissionWrapper = permissionWrapper;
return this; // return this;
} // }
//
public Repairable build() { // public Repairable build() {
return makeRepairable(); // return makeRepairable();
} // }
//
private Repairable makeRepairable() { // private Repairable makeRepairable() {
Repairable repairable = new Repairable(itemMatch, minimumLevel, maximumDurability, repairTransaction, // Repairable repairable = new Repairable(itemMatch, minimumLevel, maximumDurability, repairTransaction,
baseXP, repairCount, permissionWrapper); // baseXP, repairCount, permissionWrapper);
//
return repairable; // return repairable;
} // }
//
} //}

View File

@ -1,49 +1,49 @@
package com.gmail.nossr50.skills.repair.repairables; //package com.gmail.nossr50.skills.repair.repairables;
//
import com.gmail.nossr50.datatypes.items.ItemMatch; //import com.gmail.nossr50.datatypes.items.ItemMatch;
import org.bukkit.Material; //import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; //import org.bukkit.inventory.ItemStack;
//
import java.util.HashMap; //import java.util.HashMap;
import java.util.List; //import java.util.List;
//
public class RepairableManager { //public class RepairableManager {
private HashMap<ItemMatch<?>, Repairable> repairables; // private HashMap<ItemMatch<?>, Repairable> repairables;
//
public RepairableManager(List<Repairable> repairablesCollection) { // public RepairableManager(List<Repairable> repairablesCollection) {
this.repairables = new HashMap<>(repairablesCollection.size()); // this.repairables = new HashMap<>(repairablesCollection.size());
registerRepairables(repairablesCollection); // registerRepairables(repairablesCollection);
} // }
//
public void registerRepairable(Repairable repairable) { // public void registerRepairable(Repairable repairable) {
repairables.put(repairable.getItemMatch(), repairable); // repairables.put(repairable.getItemMatch(), repairable);
} // }
//
public void registerRepairables(List<Repairable> repairables) { // public void registerRepairables(List<Repairable> repairables) {
for (Repairable repairable : repairables) { // for (Repairable repairable : repairables) {
registerRepairable(repairable); // 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
//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) { // public boolean isRepairable(Material type) {
return repairables.containsKey(type); // return repairables.containsKey(type);
} // }
//
public boolean isRepairable(ItemStack itemStack) { // public boolean isRepairable(ItemStack itemStack) {
return isRepairable(itemStack.getType()); // return isRepairable(itemStack.getType());
} // }
//
public Repairable getRepairable(Material type) { // public Repairable getRepairable(Material type) {
return repairables.get(type); // return repairables.get(type);
} // }
} //}

View File

@ -199,7 +199,9 @@ public class WoodcuttingManager extends SkillManager {
} }
pluginRef.getSkillTools().handleDurabilityChange(inHand, durabilityLoss); 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());
} }
/** /**

View File

@ -1,33 +1,33 @@
package com.gmail.nossr50.util.nbt; //package com.gmail.nossr50.util.nbt;
//
import net.minecraft.server.v1_14_R1.NBTBase; //import net.minecraft.server.v1_14_R1.NBTBase;
//
/** ///**
* A simple class that acts as a container for raw NBT data // * 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 // * 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 // * 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 // * the transformed data can then be used to check NBT data of entities in Minecraft
* // *
* One use of this type is as follows // * One use of this type is as follows
* 1) Read partial or complete NBT from the config file for an item // * 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 // * 2) Check an items NBT tree for this NBT data during runtime once transformed
*/ // */
public class RawNBT { //public class RawNBT {
private String nbtContents; // private String nbtContents;
//
public RawNBT(String nbtContents) { // public RawNBT(String nbtContents) {
this.nbtContents = nbtContents; // this.nbtContents = nbtContents;
} // }
//
public String getNbtContents() { // public String getNbtContents() {
return nbtContents; // return nbtContents;
} // }
//
public void setNbtContents(String nbtContents) { // public void setNbtContents(String nbtContents) {
this.nbtContents = nbtContents; // this.nbtContents = nbtContents;
} // }
//
public NBTBase getNbtData() { // public NBTBase getNbtData() {
return NBTManager.constructNBT(nbtContents); // return NBTManager.constructNBT(nbtContents);
} // }
} //}

View File

@ -461,7 +461,9 @@ public class SkillTools {
} }
Material type = itemStack.getType(); 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); durabilityModifier = (int) Math.min(durabilityModifier / (itemStack.getEnchantmentLevel(Enchantment.DURABILITY) + 1), maxDurability * maxDamageModifier);
itemStack.setDurability((short) Math.min(itemStack.getDurability() + durabilityModifier, maxDurability)); itemStack.setDurability((short) Math.min(itemStack.getDurability() + durabilityModifier, maxDurability));