diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 7b763ede2..d92de184a 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -48,6 +48,7 @@ import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.repairables.Repairable; +import com.gmail.nossr50.skills.repair.repairables.SimpleRepairable; import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager; @@ -155,7 +156,7 @@ public final class ConfigManager { private CoreSkillsConfig coreSkillsConfig; private SoundConfig soundConfig; private RankConfig rankConfig; - private RepairConfig repairConfig; +// private RepairConfig repairConfig; private SalvageConfig salvageConfig; private HashMap partyItemWeights; @@ -283,7 +284,7 @@ public final class ConfigManager { rankConfig = new RankConfig(); - repairConfig = new RepairConfig(); +// repairConfig = new RepairConfig(); salvageConfig = new SalvageConfig(); @@ -336,9 +337,9 @@ public final class ConfigManager { * Get all loaded repairables (loaded from all repairable configs) * @return the currently loaded repairables */ - public ArrayList getRepairables() + public ArrayList getRepairables() { - return (ArrayList) repairConfig.genericCollection; + return getConfigRepair().getConfigRepairablesList(); } /** diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 3a7cdcae3..8a7055a3c 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -377,7 +377,7 @@ public class MainConfig extends ConfigValidated { reason.add(SKILLS + "." + MINING + "." + DETONATOR + "Item is invalid!"); } - if (getRepairAnvilMaterial() == null) { + /*if (getRepairAnvilMaterial() == null) { reason.add(SKILLS + "." + REPAIR + "." + ANVIL + "Type is invalid!!"); } @@ -387,7 +387,7 @@ public class MainConfig extends ConfigValidated { if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) { reason.add("Cannot use the same item for " + REPAIR + " and " + SALVAGE + " anvils!"); - } + }*/ if (getTamingCOTWMaterial(EntityType.WOLF) == null) { reason.add(SKILLS + "." + TAMING + "." + CALL_OF_THE_WILD1 + ".Wolf." + ITEM + "Material is invalid!!"); @@ -620,50 +620,6 @@ public class MainConfig extends ConfigValidated { return Material.matchMaterial(getStringValue(SKILLS, MINING, DETONATOR + NAME)); } - /* Repair */ - public boolean getRepairAnvilMessagesEnabled() { - return getBooleanValue(SKILLS, REPAIR, ANVIL + MESSAGES); - } - - public boolean getRepairAnvilPlaceSoundsEnabled() { - return getBooleanValue(SKILLS, REPAIR, ANVIL_PLACED + SOUNDS); - } - - public boolean getRepairAnvilUseSoundsEnabled() { - return getBooleanValue(SKILLS, REPAIR, ANVIL_USE + SOUNDS); - } - - public Material getRepairAnvilMaterial() { - //Iron block - return Material.matchMaterial(getStringValue(SKILLS, REPAIR, ANVIL_MATERIAL)); - } - - public boolean getRepairConfirmRequired() { - return getBooleanValue(SKILLS, REPAIR, CONFIRM_REQUIRED); - } - - /* Salvage */ - public boolean getSalvageAnvilMessagesEnabled() { - return getBooleanValue(SKILLS, SALVAGE, ANVIL + MESSAGES); - } - - public boolean getSalvageAnvilPlaceSoundsEnabled() { - return getBooleanValue(SKILLS, SALVAGE, ANVIL_PLACED + SOUNDS); - } - - public boolean getSalvageAnvilUseSoundsEnabled() { - return getBooleanValue(SKILLS, SALVAGE, ANVIL_USE + SOUNDS); - } - - public Material getSalvageAnvilMaterial() { - //Gold Block - return Material.matchMaterial(getStringValue(SKILLS, SALVAGE, ANVIL_MATERIAL)); - } - - public boolean getSalvageConfirmRequired() { - return getBooleanValue(SKILLS, SALVAGE, CONFIRM_REQUIRED); - } - /* Unarmed */ public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return getBooleanValue(SKILLS, UNARMED, BLOCK_CRACKER, SMOOTH_BRICK_TO_CRACKED_BRICK); diff --git a/src/main/java/com/gmail/nossr50/config/collectionconfigs/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/collectionconfigs/RepairConfig.java index 88c8c315c..8c3df991f 100644 --- a/src/main/java/com/gmail/nossr50/config/collectionconfigs/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/collectionconfigs/RepairConfig.java @@ -1,3 +1,4 @@ +/* package com.gmail.nossr50.config.collectionconfigs; import com.gmail.nossr50.config.ConfigCollection; @@ -17,9 +18,11 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; +*/ /** * This config - */ + *//* + @ConfigSerializable public class RepairConfig extends ConfigCollection { @@ -40,11 +43,13 @@ public class RepairConfig extends ConfigCollection { register(); } - /** + */ +/** * The version of this config * * @return - */ + *//* + @Override public double getConfigVersion() { return 1; @@ -65,9 +70,11 @@ public class RepairConfig extends ConfigCollection { // Validate all the things! List errorMessages = new ArrayList(); - /* + */ +/* * Match the name of the key to a Material constant definition - */ + *//* + String repairChildNodeName = repairNode.getString(); Material itemMaterial = Material.matchMaterial(repairChildNodeName); @@ -76,9 +83,11 @@ public class RepairConfig extends ConfigCollection { continue; } - /* + */ +/* * Determine Repair Material Type - */ + *//* + MaterialType repairMaterialType = MaterialType.OTHER; String repairMaterialTypeString = getRepairMaterialTypeString(repairChildNodeName); @@ -178,9 +187,6 @@ public class RepairConfig extends ConfigCollection { if(hasNode(REPAIRABLES, repairChildNodeName, XP_MULTIPLIER)) xpMultiplier = getDoubleValue(REPAIRABLES, repairChildNodeName, XP_MULTIPLIER); - - - // Minimum Quantity int minimumQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata); @@ -188,10 +194,12 @@ public class RepairConfig extends ConfigCollection { minimumQuantity = getIntValue(REPAIRABLES, repairChildNodeName, MINIMUM_QUANTITY); } - /* + */ +/* * VALIDATE * Just make sure the values we may have just grabbed from the config aren't below 0 - */ + *//* + //Validate min level if(minimumLevel < 0) @@ -225,12 +233,15 @@ public class RepairConfig extends ConfigCollection { return getShortValue(REPAIRABLES, key, MAXIMUM_DURABILITY); } - /** + */ +/** * Gets the Repair Material String Name defined in the config * @param key the key name of the repairable child node under the Repairables parent node * @return the Repair Material String Name defined in the config - */ + *//* + private String getRepairMaterialStringName(String key) { return getStringValue(REPAIRABLES, key, REPAIR_MATERIAL); } } +*/ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java index 416a8acea..99d7d6781 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java @@ -2,12 +2,203 @@ package com.gmail.nossr50.config.hocon.skills.repair; import com.gmail.nossr50.config.hocon.skills.repair.general.ConfigRepairGeneral; import com.gmail.nossr50.config.hocon.skills.repair.repairmastery.ConfigRepairMastery; +import com.gmail.nossr50.skills.repair.repairables.SimpleRepairable; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; +import java.util.ArrayList; + +import static org.bukkit.Material.*; + @ConfigSerializable public class ConfigRepair { + public static final ArrayList CONFIG_REPAIRABLES_DEFAULTS; + + static { + CONFIG_REPAIRABLES_DEFAULTS = new ArrayList<>(); + CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_SWORD, OAK_PLANKS, 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_SHOVEL, OAK_PLANKS, 1, 0, .15D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_PICKAXE, OAK_PLANKS, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_AXE, OAK_PLANKS, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_HOE, OAK_PLANKS, 1, 0, .25D)); + + /* + Repairables: + # + # Wooden repairables + ### + # Tools + WOODEN_SWORD: + MinimumLevel: 0 + XpMultiplier: .25 + WOODEN_SHOVEL: + MinimumLevel: 0 + XpMultiplier: .16 + WOODEN_PICKAXE: + MinimumLevel: 0 + XpMultiplier: .5 + WOODEN_AXE: + MinimumLevel: 0 + XpMultiplier: .5 + WOODEN_HOE: + MinimumLevel: 0 + XpMultiplier: .25 + # + # Stone repairables + ### + # Tools + STONE_SWORD: + MinimumLevel: 0 + XpMultiplier: .25 + STONE_SHOVEL: + MinimumLevel: 0 + XpMultiplier: .16 + STONE_PICKAXE: + MinimumLevel: 0 + XpMultiplier: .5 + STONE_AXE: + MinimumLevel: 0 + XpMultiplier: .5 + STONE_HOE: + MinimumLevel: 0 + XpMultiplier: .25 + # + # Iron repairables + ### + # Tools + IRON_SWORD: + MinimumLevel: 0 + XpMultiplier: .5 + IRON_SHOVEL: + MinimumLevel: 0 + XpMultiplier: .3 + IRON_PICKAXE: + MinimumLevel: 0 + XpMultiplier: 1 + IRON_AXE: + MinimumLevel: 0 + XpMultiplier: 1 + IRON_HOE: + MinimumLevel: 0 + XpMultiplier: .5 + SHEARS: + MinimumLevel: 0 + XpMultiplier: .5 + FLINT_AND_STEEL: + MinimumLevel: 0 + XpMultiplier: .3 + # Armor + IRON_HELMET: + MinimumLevel: 0 + XpMultiplier: 2 + IRON_CHESTPLATE: + MinimumLevel: 0 + XpMultiplier: 2 + IRON_LEGGINGS: + MinimumLevel: 0 + XpMultiplier: 2 + IRON_BOOTS: + MinimumLevel: 0 + XpMultiplier: 2 + # + # Gold repairables + ### + # Tools + GOLDEN_SWORD: + MinimumLevel: 0 + XpMultiplier: 4 + GOLDEN_SHOVEL: + MinimumLevel: 0 + XpMultiplier: 2.6 + GOLDEN_PICKAXE: + MinimumLevel: 0 + XpMultiplier: 8 + GOLDEN_AXE: + MinimumLevel: 0 + XpMultiplier: 8 + GOLDEN_HOE: + MinimumLevel: 0 + XpMultiplier: 4 + # Armor + GOLDEN_HELMET: + MinimumLevel: 0 + XpMultiplier: 4 + GOLDEN_CHESTPLATE: + MinimumLevel: 0 + XpMultiplier: 4 + GOLDEN_LEGGINGS: + MinimumLevel: 0 + XpMultiplier: 4 + GOLDEN_BOOTS: + MinimumLevel: 0 + XpMultiplier: 4 + # + # Diamond repairables + ### + # Tools + DIAMOND_SWORD: + MinimumLevel: 50 + XpMultiplier: .5 + DIAMOND_SHOVEL: + MinimumLevel: 50 + XpMultiplier: .3 + DIAMOND_PICKAXE: + MinimumLevel: 50 + XpMultiplier: 1 + DIAMOND_AXE: + MinimumLevel: 50 + XpMultiplier: 1 + DIAMOND_HOE: + MinimumLevel: 50 + XpMultiplier: .5 + # Armor + DIAMOND_HELMET: + MinimumLevel: 50 + XpMultiplier: 6 + DIAMOND_CHESTPLATE: + MinimumLevel: 50 + XpMultiplier: 6 + DIAMOND_LEGGINGS: + MinimumLevel: 50 + XpMultiplier: 6 + DIAMOND_BOOTS: + MinimumLevel: 50 + XpMultiplier: 6 + # + # Leather repairables + ### + # Armor + LEATHER_HELMET: + MinimumLevel: 0 + XpMultiplier: 1 + LEATHER_CHESTPLATE: + MinimumLevel: 0 + XpMultiplier: 1 + LEATHER_LEGGINGS: + MinimumLevel: 0 + XpMultiplier: 1 + LEATHER_BOOTS: + MinimumLevel: 0 + XpMultiplier: 1 + # + # String repairables + ### + # Tools + FISHING_ROD: + MinimumLevel: 0 + XpMultiplier: .5 + BOW: + MinimumLevel: 0 + XpMultiplier: .5 + CARROT_ON_A_STICK: + MinimumLevel: 0 + XpMultiplier: .5 + */ + } + + + @Setting(value = "Repair-Mastery", comment = "Settings related to the repair mastery subskill") private ConfigRepairMastery repairMastery = new ConfigRepairMastery(); @@ -20,6 +211,9 @@ public class ConfigRepair { @Setting(value = "General") private ConfigRepairGeneral repairGeneral = new ConfigRepairGeneral(); + @Setting(value = "Repairables") + private ArrayList configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS; + public ConfigRepairGeneral getRepairGeneral() { return repairGeneral; } @@ -35,4 +229,8 @@ public class ConfigRepair { public ConfigRepairArcaneForging getArcaneForging() { return arcaneForging; } + + public ArrayList getConfigRepairablesList() { + return configRepairablesList; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java index 83f9f04b0..49bbb2521 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java @@ -8,6 +8,9 @@ import java.util.HashMap; @ConfigSerializable public class ConfigRepairArcaneForging { + public static final boolean LOSE_ENCHANTS_DEFAULT = true; + public static final boolean DOWNGRADES_ENABLED_DEFAULT = true; + public static final HashMap KEEP_ENCHANT_MAP; public static final HashMap DOWNGRADE_MAP_DEFAULT; @@ -33,9 +36,6 @@ public class ConfigRepairArcaneForging { DOWNGRADE_MAP_DEFAULT.put(8, 10.0D); } - public static final boolean LOSE_ENCHANTS_DEFAULT = true; - public static final boolean DOWNGRADES_ENABLED_DEFAULT = true; - @Setting(value = "May-Lose-Enchants", comment = "With this on, players have a chance to have enchantments stripped from" + "\n their item when repairing." + "\nThe odds to lose your enchants decrease with higher levels of skill." + diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/general/ConfigRepairGeneral.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/general/ConfigRepairGeneral.java index cf5ab8180..f8d7e098c 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/general/ConfigRepairGeneral.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/general/ConfigRepairGeneral.java @@ -11,22 +11,6 @@ public class ConfigRepairGeneral { public static final boolean ANVIL_PLACED_SOUNDS_DEFAULT = true; public static final boolean ENCHANTED_ITEMS_REQUIRE_CONFIRM = true; - /* - public Material getRepairAnvilMaterial() { - //Iron block - return Material.matchMaterial(getStringValue(SKILLS, REPAIR, ANVIL_MATERIAL)); - } - - public boolean getRepairConfirmRequired() { - return getBooleanValue(SKILLS, REPAIR, CONFIRM_REQUIRED); - } - - public boolean getRepairAnvilMessagesEnabled() { - return getBooleanValue(SKILLS, REPAIR, ANVIL + MESSAGES); - } - */ - - @Setting(value = "Anvil-Block-Material", comment = "The block used for mcMMO repairs." + "Default value: "+"IRON_BLOCK") private Material repairAnvilMaterial = Material.IRON_BLOCK; diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairables/ConfigRepairables.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairables/ConfigRepairables.java new file mode 100644 index 000000000..17420af63 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairables/ConfigRepairables.java @@ -0,0 +1,30 @@ +/* +package com.gmail.nossr50.config.hocon.skills.repair.repairables; + +import com.gmail.nossr50.datatypes.skills.ItemType; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; +import org.bukkit.Material; + +@ConfigSerializable +public class ConfigRepairables { + + @Setting(value = "Item-Material") + private Material itemMaterial; + + @Setting(value = "Item-Used-To-Repair") + private Material repairMaterial; + + @Setting(value = "Minimum-Quantity-Required-For-Repair") + private int minimumQuantity; + + @Setting(value = "Minimum-Level-Required-For-Repair") + private int minimumLevel; + + @Setting(value = "Repair-Item-Category") + private ItemType repairItemType; + + @Setting(value = "XP-Multiplier") + private double xpMultiplier; + +}*/ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java index 78ef272c9..989f91825 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java @@ -7,6 +7,9 @@ import java.util.HashMap; @ConfigSerializable public class ConfigArcaneSalvage { + public static final boolean LOSE_ENCHANTS_DEFAULT = true; + public static final boolean DOWNGRADES_ENABLED_DEFAULT = true; + public static final HashMap FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; public static final HashMap PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; @@ -41,6 +44,24 @@ public class ConfigArcaneSalvage { "\nThis check happens if you fail to extract the full enchant from the item.") private HashMap extractPartialEnchantChance = PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + @Setting(value = "May-Lose-Enchants", comment = "With this on, players have a chance to not receive the enchantments from the item they are salvaging." + + "\nThe odds to lose your enchants decrease with higher levels of skill." + + "\nDefault value: "+LOSE_ENCHANTS_DEFAULT) + private boolean mayLoseEnchants = LOSE_ENCHANTS_DEFAULT; + + @Setting(value = "Chance-To-Downgrade-Enchants", comment = "With this on, players have a chance to have salvaged enchantments downgrade when salvaging." + + "\nThe chance to downgrade decreases with higher levels of skill." + + "\nDefault value: "+DOWNGRADES_ENABLED_DEFAULT) + private boolean downgradesEnabled = DOWNGRADES_ENABLED_DEFAULT; + + public boolean isMayLoseEnchants() { + return mayLoseEnchants; + } + + public boolean isDowngradesEnabled() { + return downgradesEnabled; + } + public HashMap getExtractFullEnchantChance() { return extractFullEnchantChance; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 7b57702b4..d62414159 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -1,11 +1,17 @@ package com.gmail.nossr50.skills.repair; -import com.gmail.nossr50.config.MainConfig; +import com.gmail.nossr50.mcMMO; import org.bukkit.Material; public class Repair { - //public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel(); - //public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus(); + public static Material anvilMaterial; - //public static Material anvilMaterial = MainConfig.getInstance().getRepairAnvilMaterial(); + public Repair() { + anvilMaterial = mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().getRepairAnvilMaterial(); + } + + public static Material getRepairAnvilMaterial() + { + return anvilMaterial; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 119ad2108..0c3c65f70 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.repair; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.interactions.NotificationType; @@ -51,11 +50,11 @@ public class RepairManager extends SkillManager { return; } - if (MainConfig.getInstance().getRepairAnvilMessagesEnabled()) { + if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilMessages()) { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Repair.Listener.Anvil"); } - if (MainConfig.getInstance().getRepairAnvilPlaceSoundsEnabled()) { + if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilPlacedSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); } @@ -94,7 +93,7 @@ public class RepairManager extends SkillManager { PlayerInventory inventory = player.getInventory(); Material repairMaterial = repairable.getRepairMaterial(); - byte repairMaterialMetadata = repairable.getRepairMaterialMetadata(); + //byte repairMaterialMetadata = repairable.getRepairMaterialMetadata(); ItemStack toRemove = new ItemStack(repairMaterial); short startDurability = item.getDurability(); @@ -106,7 +105,7 @@ public class RepairManager extends SkillManager { } // Check if they have the proper material to repair with - if (!inventory.contains(repairMaterial)) { + /*if (!inventory.contains(repairMaterial)) { String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName(); String materialsNeeded = ""; @@ -117,7 +116,7 @@ public class RepairManager extends SkillManager { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Skills.NeedMore.Extra", prettyName, materialsNeeded); return; - } + }*/ // Do not repair stacked items if (item.getAmount() != 1) { @@ -144,10 +143,10 @@ public class RepairManager extends SkillManager { } // Remove the item - if (repairMaterialMetadata == -1) { + /*if (repairMaterialMetadata == -1) { toRemove = inventory.getItem(inventory.first(repairMaterial)).clone(); toRemove.setAmount(1); - } + }*/ inventory.removeItem(toRemove); @@ -155,7 +154,7 @@ public class RepairManager extends SkillManager { applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE); // BWONG BWONG BWONG - if (MainConfig.getInstance().getRepairAnvilUseSoundsEnabled()) { + if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilUseSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); } @@ -177,7 +176,7 @@ public class RepairManager extends SkillManager { Player player = getPlayer(); long lastUse = getLastAnvilUse(); - if (!SkillUtils.cooldownExpired(lastUse, 3) || !MainConfig.getInstance().getRepairConfirmRequired()) { + if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isEnchantedItemsRequireConfirm()) { return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index d58fb0ed1..46be5d6e8 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -20,20 +20,6 @@ public interface Repairable { */ public Material getRepairMaterial(); - /** - * Gets the metadata byte value of the material used to repair this item - * - * @return the byte metadata of the repair material - */ - public byte getRepairMaterialMetadata(); - - /** - * Gets the pretty name of the material used to repair this item - * - * @return the pretty name of the repair material - */ - public String getRepairMaterialPrettyName(); - /** * Gets the RepairItemType value for this repairable item * diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java index adaa80ef8..7cfa2e0bc 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java @@ -1,3 +1,4 @@ +/* package com.gmail.nossr50.skills.repair.repairables; import com.gmail.nossr50.datatypes.skills.ItemType; @@ -19,3 +20,4 @@ public class RepairableFactory { return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, repairMaterialPrettyName, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } } +*/ diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java index 595a032cc..cea563d78 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java @@ -2,23 +2,23 @@ package com.gmail.nossr50.skills.repair.repairables; import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; +import com.gmail.nossr50.util.ItemUtils; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; public class SimpleRepairable implements Repairable { private final Material itemMaterial, repairMaterial; private final int minimumQuantity, minimumLevel; private final short maximumDurability, baseRepairDurability; - private final byte repairMetadata; - private String repairMaterialPrettyName; + /*private String repairMaterialPrettyName;*/ private final ItemType repairItemType; private final MaterialType repairMaterialType; private final double xpMultiplier; - protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { +/* protected SimpleRepairable(Material type, Material repairMaterial, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { this.itemMaterial = type; this.repairMaterial = repairMaterial; - this.repairMetadata = repairMetadata; this.repairMaterialPrettyName = repairMaterialPrettyName; this.repairItemType = repairItemType; this.repairMaterialType = repairMaterialType; @@ -27,6 +27,65 @@ public class SimpleRepairable implements Repairable { this.maximumDurability = maximumDurability; this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); this.xpMultiplier = xpMultiplier; + }*/ + + public SimpleRepairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) { + this.itemMaterial = itemMaterial; + this.repairMaterial = repairMaterial; + this.minimumQuantity = minimumQuantity; + this.minimumLevel = minimumLevel; + this.xpMultiplier = xpMultiplier; + + this.maximumDurability = itemMaterial.getMaxDurability(); + this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); + + this.repairItemType = determineItemType(itemMaterial); + this.repairMaterialType = determineMaterialType(repairMaterial); + } + + public MaterialType determineMaterialType(Material material) { + switch (material) { + case STRING: + return MaterialType.STRING; + + case LEATHER: + return MaterialType.LEATHER; + + case ACACIA_PLANKS: + case BIRCH_PLANKS: + case DARK_OAK_PLANKS: + case JUNGLE_PLANKS: + case OAK_PLANKS: + case SPRUCE_PLANKS: + return MaterialType.WOOD; + + case STONE: + return MaterialType.STONE; + + case IRON_INGOT: + return MaterialType.IRON; + + case GOLD_INGOT: + return MaterialType.GOLD; + + case DIAMOND: + return MaterialType.DIAMOND; + + default: + return MaterialType.OTHER; + } + } + + private ItemType determineItemType(Material material) + { + if (ItemUtils.isMinecraftTool(new ItemStack(material))) { + return ItemType.TOOL; + } + else if (ItemUtils.isArmor(new ItemStack((material)))) { + return ItemType.ARMOR; + } else { + return ItemType.OTHER; + } } @Override @@ -39,16 +98,6 @@ public class SimpleRepairable implements Repairable { return repairMaterial; } - @Override - public byte getRepairMaterialMetadata() { - return repairMetadata; - } - - @Override - public String getRepairMaterialPrettyName() { - return repairMaterialPrettyName; - } - @Override public ItemType getRepairItemType() { return repairItemType; diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java b/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java index 7ed038c5b..4e82a2f48 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java @@ -1,19 +1,18 @@ package com.gmail.nossr50.skills.salvage; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.MainConfig; +import com.gmail.nossr50.mcMMO; import org.bukkit.Material; public class Salvage { - public static Material anvilMaterial = MainConfig.getInstance().getSalvageAnvilMaterial(); - /*public static int salvageMaxPercentageLevel = AdvancedConfig.getInstance().getSalvageMaxPercentageLevel(); - public static double salvageMaxPercentage = AdvancedConfig.getInstance().getSalvageMaxPercentage(); - - public static int advancedSalvageUnlockLevel = RankUtils.getRankUnlockLevel(SubSkillType.SALVAGE_ADVANCED_SALVAGE, 1);*/ - - public static boolean arcaneSalvageDowngrades = AdvancedConfig.getInstance().getArcaneSalvageEnchantDowngradeEnabled(); - public static boolean arcaneSalvageEnchantLoss = AdvancedConfig.getInstance().getArcaneSalvageEnchantLossEnabled(); + public Salvage() { + anvilMaterial = mcMMO.getConfigManager().getConfigSalvage().getGeneral().getSalvageAnvilMaterial(); + arcaneSalvageDowngrades = mcMMO.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().isDowngradesEnabled(); + arcaneSalvageEnchantLoss = mcMMO.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().isMayLoseEnchants(); + } + public static Material anvilMaterial; + public static boolean arcaneSalvageDowngrades; + public static boolean arcaneSalvageEnchantLoss; protected static int calculateSalvageableAmount(short currentDurability, short maxDurability, int baseAmount) { double percentDamaged = (maxDurability <= 0) ? 1D : (double) (maxDurability - currentDurability) / maxDurability; diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 21c4c0351..82073eee2 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.salvage; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; @@ -49,11 +48,11 @@ public class SalvageManager extends SkillManager { return; } - if (MainConfig.getInstance().getSalvageAnvilMessagesEnabled()) { + if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilMessages()) { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Listener.Anvil"); } - if (MainConfig.getInstance().getSalvageAnvilPlaceSoundsEnabled()) { + if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilPlacedSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); } @@ -130,7 +129,7 @@ public class SalvageManager extends SkillManager { Misc.dropItems(location, salvageResults, 1); // BWONG BWONG BWONG - CLUNK! - if (MainConfig.getInstance().getSalvageAnvilUseSoundsEnabled()) { + if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); @@ -253,7 +252,7 @@ public class SalvageManager extends SkillManager { Player player = getPlayer(); long lastUse = getLastAnvilUse(); - if (!SkillUtils.cooldownExpired(lastUse, 3) || !MainConfig.getInstance().getSalvageConfirmRequired()) { + if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.getConfigManager().getConfigSalvage().getGeneral().isEnchantedItemsRequireConfirm()) { return true; } diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java index c0972d24b..7a520d3f9 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.random; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO;