diff --git a/Changelog.txt b/Changelog.txt index 49a25609c..23a3d372a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -147,6 +147,7 @@ Version 2.2.0 Config_Update_Overwrite, Tool_Mods_Enabled, Armor_Mods_Enabled, Block_Mods_Enabled, Entity_Mods_Enabled API Changes + SimpleRepairable/SimpleSalvageable renamed to just Repairable/Salvageable, and their unnecessary interface classes were removed Added API method to check if player parties are size capped Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition Added API method to check if a skill was being level capped diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 030fa22b3..f0d9739ba 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -8,7 +8,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.ArcaneForging; import com.gmail.nossr50.skills.repair.RepairManager; -import com.gmail.nossr50.skills.repair.repairables.SimpleRepairable; +import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.player.UserManager; @@ -50,10 +50,10 @@ public class RepairCommand extends SkillCommand { @Override protected void dataCalculations(Player player, float skillValue) { // We're using pickaxes here, not the best but it works - SimpleRepairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE); - SimpleRepairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE); - SimpleRepairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE); - SimpleRepairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE); + Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE); + Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE); + Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE); + Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE); // TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0 diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 49d237b20..f13295b15 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; @@ -26,7 +25,6 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; -import org.bukkit.scoreboard.Scoreboard; import java.text.DecimalFormat; import java.util.ArrayList; diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 2bada82d9..ff95df343 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -1,15 +1,12 @@ package com.gmail.nossr50.config; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.skills.woodcutting.Woodcutting; -import com.gmail.nossr50.util.StringUtils; import com.google.common.io.Files; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.hocon.HoconConfigurationLoader; import ninja.leaping.configurate.loader.ConfigurationLoader; import ninja.leaping.configurate.objectmapping.ObjectMappingException; -import org.bukkit.Material; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 69cc9b754..b3ddc7e19 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -46,10 +46,10 @@ import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig; 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.SimpleRepairable; -import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; +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.SimpleSalvageableManager; +import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; import com.gmail.nossr50.util.experience.ExperienceMapManager; import com.google.common.collect.Maps; import com.google.common.reflect.TypeToken; @@ -83,8 +83,8 @@ public final class ConfigManager { /* COLLECTION MANAGERS */ - private SimpleRepairableManager simpleRepairableManager; - private SimpleSalvageableManager simpleSalvageableManager; + private RepairableManager repairableManager; + private SalvageableManager salvageableManager; /* MOD MANAGERS */ @@ -155,7 +155,7 @@ public final class ConfigManager { private SoundConfig soundConfig; private RankConfig rankConfig; // private RepairConfig repairConfig; - private SalvageConfig salvageConfig; +// private SalvageConfig salvageConfig; private HashMap partyItemWeights; private HashMap partyFeatureUnlocks; @@ -215,7 +215,7 @@ public final class ConfigManager { TypeSerializers.getDefaultSerializers().registerType(new TypeToken() {}, new CustomEnumValueSerializer()); TypeSerializers.getDefaultSerializers().registerType(new TypeToken() {}, new CustomEnumValueSerializer()); - TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(SimpleRepairable.class), new RepairableSerializer()); + TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Repairable.class), new RepairableSerializer()); mcMMO.p.getLogger().info("Deserializing configs..."); //TODO: Not sure about the order of MainConfig @@ -287,7 +287,7 @@ public final class ConfigManager { // repairConfig = new RepairConfig(); - salvageConfig = new SalvageConfig(); +// salvageConfig = new SalvageConfig(); /* * Managers @@ -326,19 +326,19 @@ public final class ConfigManager { private void initCollectionManagers() { // Handles registration of repairables - simpleRepairableManager = new SimpleRepairableManager(getRepairables()); - unloadables.add(simpleRepairableManager); + repairableManager = new RepairableManager(getRepairables()); + unloadables.add(repairableManager); // Handles registration of salvageables - simpleSalvageableManager = new SimpleSalvageableManager(getSalvageables()); - unloadables.add(simpleSalvageableManager); + salvageableManager = new SalvageableManager(getSalvageables()); + unloadables.add(salvageableManager); } /** * Get all loaded repairables (loaded from all repairable configs) * @return the currently loaded repairables */ - public ArrayList getRepairables() + public ArrayList getRepairables() { return getConfigRepair().getConfigRepairablesList(); } @@ -349,7 +349,7 @@ public final class ConfigManager { */ public ArrayList getSalvageables() { - return (ArrayList) salvageConfig.genericCollection; + return getConfigSalvage().getConfigSalvageablesList(); } /** @@ -401,12 +401,12 @@ public final class ConfigManager { return userFiles; } - public SimpleRepairableManager getSimpleRepairableManager() { - return simpleRepairableManager; + public RepairableManager getRepairableManager() { + return repairableManager; } - public SimpleSalvageableManager getSimpleSalvageableManager() { - return simpleSalvageableManager; + public SalvageableManager getSalvageableManager() { + return salvageableManager; } public MainConfig getMainConfig() { diff --git a/src/main/java/com/gmail/nossr50/config/hocon/RepairableSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/RepairableSerializer.java index e12c84901..b0469f2be 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/RepairableSerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/RepairableSerializer.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.hocon; -import com.gmail.nossr50.skills.repair.repairables.SimpleRepairable; +import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.objectmapping.ObjectMappingException; @@ -10,7 +10,7 @@ import ninja.leaping.configurate.util.EnumLookup; import java.util.List; import java.util.Optional; -public class RepairableSerializer implements TypeSerializer { +public class RepairableSerializer implements TypeSerializer { /* TypeTokens are obtained in two ways @@ -32,13 +32,13 @@ public class RepairableSerializer implements TypeSerializer { @Override - public SimpleRepairable deserialize(TypeToken type, ConfigurationNode value) throws ObjectMappingException { + public Repairable deserialize(TypeToken type, ConfigurationNode value) throws ObjectMappingException { /* - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_SWORD, OAK_PLANKS, 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SWORD, OAK_PLANKS, 1, 0, .25D)); */ - /* SimpleRepairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) */ + /* Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) */ String item = value.getNode("Item").getValue(TypeToken.of(String.class)); List repairItems = value.getNode("Items-Used-To-Repair").getValue(new TypeToken>() {}); @@ -54,11 +54,11 @@ public class RepairableSerializer implements TypeSerializer { int minimumLevel = value.getNode("Override-Level-Requirement").getValue(TypeToken.of(Integer.class)); double xpMultiplier = value.getNode("XP-Multiplier").getValue(TypeToken.of(Double.class)); - return new SimpleRepairable(item, repairItems, minimumQuantity, minimumLevel, xpMultiplier); + return new Repairable(item, repairItems, minimumQuantity, minimumLevel, xpMultiplier); } @Override - public void serialize(TypeToken type, SimpleRepairable obj, ConfigurationNode value) throws ObjectMappingException { + public void serialize(TypeToken type, Repairable obj, ConfigurationNode value) throws ObjectMappingException { /*value.getNode("Item").setValue(HOCONUtil.serializeENUMName(obj.getItemMaterial().getKey().getKey())); value.getNode("Item-Used-To-Repair").setValue(HOCONUtil.serializeENUMName(obj.getRepairMaterials().getKey().getKey()));*/ 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 2510e0397..0eb0cb947 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 @@ -3,7 +3,7 @@ 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.config.hocon.skills.repair.subskills.ConfigRepairSubSkills; -import com.gmail.nossr50.skills.repair.repairables.SimpleRepairable; +import com.gmail.nossr50.skills.repair.repairables.Repairable; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import org.bukkit.Material; @@ -16,58 +16,58 @@ import static org.bukkit.Material.*; @ConfigSerializable public class ConfigRepair { - public static final ArrayList CONFIG_REPAIRABLES_DEFAULTS; + public static final ArrayList CONFIG_REPAIRABLES_DEFAULTS; public static final Material[] PLANKS = new Material[] { OAK_PLANKS, BIRCH_PLANKS, DARK_OAK_PLANKS, ACACIA_PLANKS, JUNGLE_PLANKS, SPRUCE_PLANKS}; static { CONFIG_REPAIRABLES_DEFAULTS = new ArrayList<>(); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_SWORD, Arrays.asList(PLANKS), 1, 0, .25D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_SHOVEL, Arrays.asList(PLANKS), 1, 0, .15D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_PICKAXE, Arrays.asList(PLANKS), 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_AXE, Arrays.asList(PLANKS), 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(WOODEN_HOE, Arrays.asList(PLANKS), 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SWORD, Arrays.asList(PLANKS), 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_SHOVEL, Arrays.asList(PLANKS), 1, 0, .15D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_PICKAXE, Arrays.asList(PLANKS), 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_AXE, Arrays.asList(PLANKS), 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(WOODEN_HOE, Arrays.asList(PLANKS), 1, 0, .25D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(STONE_SWORD, COBBLESTONE, 1, 0, .25D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(STONE_SHOVEL, COBBLESTONE, 1, 0, .15D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(STONE_PICKAXE, COBBLESTONE, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(STONE_AXE, COBBLESTONE, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(STONE_HOE, COBBLESTONE, 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(STONE_SWORD, COBBLESTONE, 1, 0, .25D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(STONE_SHOVEL, COBBLESTONE, 1, 0, .15D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(STONE_PICKAXE, COBBLESTONE, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(STONE_AXE, COBBLESTONE, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(STONE_HOE, COBBLESTONE, 1, 0, .25D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_SWORD, IRON_INGOT, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_SHOVEL, IRON_INGOT, 1, 0, .3D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_PICKAXE, IRON_INGOT, 1, 0, 1D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_AXE, IRON_INGOT, 1, 0, 1D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_HOE, IRON_INGOT, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_SWORD, IRON_INGOT, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_SHOVEL, IRON_INGOT, 1, 0, .3D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_PICKAXE, IRON_INGOT, 1, 0, 1D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_AXE, IRON_INGOT, 1, 0, 1D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_HOE, IRON_INGOT, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_HELMET, IRON_INGOT, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_CHESTPLATE, IRON_INGOT, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_LEGGINGS, IRON_INGOT, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(IRON_BOOTS, IRON_INGOT, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_HELMET, IRON_INGOT, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_CHESTPLATE, IRON_INGOT, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_LEGGINGS, IRON_INGOT, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(IRON_BOOTS, IRON_INGOT, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(SHEARS, IRON_INGOT, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(FLINT_AND_STEEL, IRON_INGOT, 1, 0, .3D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(SHEARS, IRON_INGOT, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(FLINT_AND_STEEL, IRON_INGOT, 1, 0, .3D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_SWORD, GOLD_INGOT, 1, 0, 4D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_SHOVEL, GOLD_INGOT, 1, 0, 2.6D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_PICKAXE, GOLD_INGOT, 1, 0, 8D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_AXE, GOLD_INGOT, 1, 0, 8D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_HOE, GOLD_INGOT, 1, 0, 4D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_SWORD, GOLD_INGOT, 1, 0, 4D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_SHOVEL, GOLD_INGOT, 1, 0, 2.6D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_PICKAXE, GOLD_INGOT, 1, 0, 8D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_AXE, GOLD_INGOT, 1, 0, 8D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_HOE, GOLD_INGOT, 1, 0, 4D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_HELMET, GOLD_INGOT, 1, 0, 4D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_CHESTPLATE, GOLD_INGOT, 1, 0, 4D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_LEGGINGS, GOLD_INGOT, 1, 0, 4D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(GOLDEN_BOOTS, GOLD_INGOT, 1, 0, 4D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_HELMET, GOLD_INGOT, 1, 0, 4D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_CHESTPLATE, GOLD_INGOT, 1, 0, 4D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_LEGGINGS, GOLD_INGOT, 1, 0, 4D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(GOLDEN_BOOTS, GOLD_INGOT, 1, 0, 4D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_SWORD, DIAMOND, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_SHOVEL, DIAMOND, 1, 0, .3D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_PICKAXE, DIAMOND, 1, 0, 1D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_AXE, DIAMOND, 1, 0, 1D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_HOE, DIAMOND, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_SWORD, DIAMOND, 1, 0, .5D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_SHOVEL, DIAMOND, 1, 0, .3D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_PICKAXE, DIAMOND, 1, 0, 1D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_AXE, DIAMOND, 1, 0, 1D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_HOE, DIAMOND, 1, 0, .5D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_HELMET, DIAMOND, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_CHESTPLATE, DIAMOND, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_LEGGINGS, DIAMOND, 1, 0, 2D)); - CONFIG_REPAIRABLES_DEFAULTS.add(new SimpleRepairable(DIAMOND_BOOTS, DIAMOND, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_HELMET, DIAMOND, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_CHESTPLATE, DIAMOND, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_LEGGINGS, DIAMOND, 1, 0, 2D)); + CONFIG_REPAIRABLES_DEFAULTS.add(new Repairable(DIAMOND_BOOTS, DIAMOND, 1, 0, 2D)); } @@ -87,7 +87,7 @@ public class ConfigRepair { "\nXP-Multiplier: When calculating how much XP to give the player for the repair, the end result will be multiplied by this value." + "\n\nName ID List: https://minecraft.gamepedia.com/Java_Edition_data_values" + "\nTIP: You can omit \"minecraft:\" from the Name ID if you want to, for example you can write \"red_wool\" instead of \"minecraft:red_wool\"") - private ArrayList configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS; + private ArrayList configRepairablesList = CONFIG_REPAIRABLES_DEFAULTS; public ConfigRepairGeneral getRepairGeneral() { return repairGeneral; @@ -109,7 +109,7 @@ public class ConfigRepair { return repairSubSkills.getArcaneForging(); } - public ArrayList getConfigRepairablesList() { + public ArrayList getConfigRepairablesList() { return configRepairablesList; } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigSalvage.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigSalvage.java index 7e60a1938..bb2c835e6 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigSalvage.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigSalvage.java @@ -1,12 +1,242 @@ package com.gmail.nossr50.config.hocon.skills.salvage; import com.gmail.nossr50.config.hocon.skills.salvage.general.ConfigSalvageGeneral; +import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; +import java.util.ArrayList; +import java.util.List; + @ConfigSerializable public class ConfigSalvage { + private final static List DEFAULT_SALVAGEABLES_LIST; + + static { + DEFAULT_SALVAGEABLES_LIST = new ArrayList<>(); + + + + /* + Salvageables: + # + # Wooden salvageables + ### + # Tools + WOODEN_SWORD: + MinimumLevel: 0 + XpMultiplier: .25 + MaximumQuantity: 2 + WOODEN_SHOVEL: + MinimumLevel: 0 + XpMultiplier: .16 + MaximumQuantity: 1 + WOODEN_PICKAXE: + MinimumLevel: 0 + XpMultiplier: .5 + MaximumQuantity: 3 + WOODEN_AXE: + MinimumLevel: 0 + XpMultiplier: .5 + MaximumQuantity: 2 + WOODEN_HOE: + MinimumLevel: 0 + XpMultiplier: .25 + MaximumQuantity: 2 + # + # Stone salvageables + ### + # Tools + STONE_SWORD: + MinimumLevel: 0 + XpMultiplier: .25 + MaximumQuantity: 2 + STONE_SHOVEL: + MinimumLevel: 0 + XpMultiplier: .16 + MaximumQuantity: 1 + STONE_PICKAXE: + MinimumLevel: 0 + XpMultiplier: .5 + MaximumQuantity: 3 + STONE_AXE: + MinimumLevel: 0 + XpMultiplier: .5 + MaximumQuantity: 2 + STONE_HOE: + MinimumLevel: 0 + XpMultiplier: .25 + MaximumQuantity: 2 + # + # Iron salvageables + ### + # Tools + IRON_SWORD: + MinimumLevel: 0 + XpMultiplier: .5 + MaximumQuantity: 2 + IRON_SHOVEL: + MinimumLevel: 0 + XpMultiplier: .3 + MaximumQuantity: 1 + IRON_PICKAXE: + MinimumLevel: 0 + XpMultiplier: 1 + MaximumQuantity: 3 + IRON_AXE: + MinimumLevel: 0 + XpMultiplier: 1 + MaximumQuantity: 2 + IRON_HOE: + MinimumLevel: 0 + XpMultiplier: .5 + MaximumQuantity: 2 + SHEARS: + MinimumLevel: 0 + XpMultiplier: .5 + FLINT_AND_STEEL: + MinimumLevel: 0 + XpMultiplier: .3 + # Armor + IRON_HELMET: + MinimumLevel: 0 + XpMultiplier: 2 + MaximumQuantity: 5 + IRON_CHESTPLATE: + MinimumLevel: 0 + XpMultiplier: 2 + MaximumQuantity: 8 + IRON_LEGGINGS: + MinimumLevel: 0 + XpMultiplier: 2 + MaximumQuantity: 7 + IRON_BOOTS: + MinimumLevel: 0 + XpMultiplier: 2 + MaximumQuantity: 4 + # + # Gold salvageables + ### + # Tools + GOLDEN_SWORD: + MinimumLevel: 0 + XpMultiplier: 4 + MaximumQuantity: 2 + GOLDEN_SHOVEL: + MinimumLevel: 0 + XpMultiplier: 2.6 + MaximumQuantity: 1 + GOLDEN_PICKAXE: + MinimumLevel: 0 + XpMultiplier: 8 + MaximumQuantity: 3 + GOLDEN_AXE: + MinimumLevel: 0 + XpMultiplier: 8 + MaximumQuantity: 2 + GOLDEN_HOE: + MinimumLevel: 0 + XpMultiplier: 4 + MaximumQuantity: 2 + # Armor + GOLDEN_HELMET: + MinimumLevel: 0 + XpMultiplier: 4 + MaximumQuantity: 5 + GOLDEN_CHESTPLATE: + MinimumLevel: 0 + XpMultiplier: 4 + MaximumQuantity: 8 + GOLDEN_LEGGINGS: + MinimumLevel: 0 + XpMultiplier: 4 + MaximumQuantity: 7 + GOLDEN_BOOTS: + MinimumLevel: 0 + XpMultiplier: 4 + MaximumQuantity: 4 + # + # Diamond salvageables + ### + # Tools + DIAMOND_SWORD: + MinimumLevel: 50 + XpMultiplier: .5 + MaximumQuantity: 2 + DIAMOND_SHOVEL: + MinimumLevel: 50 + XpMultiplier: .3 + MaximumQuantity: 1 + DIAMOND_PICKAXE: + MinimumLevel: 50 + XpMultiplier: 1 + MaximumQuantity: 3 + DIAMOND_AXE: + MinimumLevel: 50 + XpMultiplier: 1 + MaximumQuantity: 2 + DIAMOND_HOE: + MinimumLevel: 50 + XpMultiplier: .5 + MaximumQuantity: 2 + # Armor + DIAMOND_HELMET: + MinimumLevel: 50 + XpMultiplier: 6 + MaximumQuantity: 5 + DIAMOND_CHESTPLATE: + MinimumLevel: 50 + XpMultiplier: 6 + MaximumQuantity: 8 + DIAMOND_LEGGINGS: + MinimumLevel: 50 + XpMultiplier: 6 + MaximumQuantity: 7 + DIAMOND_BOOTS: + MinimumLevel: 50 + XpMultiplier: 6 + MaximumQuantity: 4 + # + # Leather salvageables + ### + # Armor + LEATHER_HELMET: + MinimumLevel: 0 + XpMultiplier: 1 + MaximumQuantity: 5 + LEATHER_CHESTPLATE: + MinimumLevel: 0 + XpMultiplier: 1 + MaximumQuantity: 8 + LEATHER_LEGGINGS: + MinimumLevel: 0 + XpMultiplier: 1 + MaximumQuantity: 7 + LEATHER_BOOTS: + MinimumLevel: 0 + XpMultiplier: 1 + MaximumQuantity: 4 + # + # String salvageables + ### + # Tools + FISHING_ROD: + MinimumLevel: 0 + XpMultiplier: .5 + BOW: + MinimumLevel: 0 + XpMultiplier: .5 + CARROT_ON_A_STICK: + MinimumLevel: 0 + XpMultiplier: .5 + */ + } + + @Setting() + List configSalvageablesList; + + @Setting(value = "Arcane-Salvage", comment = "Settings related to the Arcane Salvage Sub-Skill") ConfigArcaneSalvage configArcaneSalvage = new ConfigArcaneSalvage(); @@ -20,4 +250,8 @@ public class ConfigSalvage { public ConfigSalvageGeneral getGeneral() { return general; } + + public ArrayList getConfigSalvageablesList() { + return configSalvageablesList; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 12b3608dd..5280664fb 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -18,7 +18,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.scoreboard.Scoreboard; public class SelfListener implements Listener { //Used in task scheduling and other things diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index d6b34d073..9b4f92a68 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -26,7 +26,7 @@ import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.alchemy.Alchemy; -import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; +import com.gmail.nossr50.skills.repair.repairables.RepairableManager; import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; @@ -356,12 +356,12 @@ public class mcMMO extends JavaPlugin { return placeStore; } - public static SimpleRepairableManager getRepairableManager() { - return configManager.getSimpleRepairableManager(); + public static RepairableManager getRepairableManager() { + return configManager.getRepairableManager(); } public static SalvageableManager getSalvageableManager() { - return configManager.getSimpleSalvageableManager(); + return configManager.getSalvageableManager(); } public static DatabaseManager getDatabaseManager() { 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 10bf1c1eb..2b39ed183 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.repair.repairables.SimpleRepairable; +import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -65,7 +65,7 @@ public class RepairManager extends SkillManager { public void handleRepair(ItemStack item) { Player player = getPlayer(); - SimpleRepairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType()); + Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType()); if (item.getItemMeta().isUnbreakable()) { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable"); 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 b8800f897..1ef2386fb 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -1,95 +1,129 @@ -/* package com.gmail.nossr50.skills.repair.repairables; -import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; +import com.gmail.nossr50.datatypes.skills.ItemType; +import com.gmail.nossr50.util.ItemUtils; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; +import java.util.List; -public interface Repairable { - */ -/** - * Gets the type of this repairable item - * - * @return the type of this repairable - *//* +public class Repairable { + private final Material itemMaterial; + private final List repairMaterials; + private final int minimumQuantity, minimumLevel; + private final short maximumDurability, baseRepairDurability; + private final ItemType repairItemType; + private final ItemMaterialCategory repairItemMaterialCategory; + private final double xpMultiplier; - public Material getItemMaterial(); + public Repairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) { + this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Arrays.asList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier); + } - */ -/** - * Gets the id of the material used to repair this item - * - * @return the id of the repair material - *//* + public Repairable(Material itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { + this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(repairMaterials), minimumQuantity, minimumLevel, xpMultiplier); + } - public Material getRepairMaterials(); + public Repairable(String itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { + this.itemMaterial = Material.matchMaterial(itemMaterial); + this.repairMaterials = ItemUtils.matchMaterials(repairMaterials); + this.minimumQuantity = minimumQuantity; + this.minimumLevel = minimumLevel; + this.xpMultiplier = xpMultiplier; - */ -/** - * Gets the RepairItemType value for this repairable item - * - * @return the RepairItemType for this repairable - *//* + this.maximumDurability = this.itemMaterial.getMaxDurability(); + this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); - public ItemType getRepairItemType(); + this.repairItemType = determineItemType(this.itemMaterial); + this.repairItemMaterialCategory = determineMaterialType(this.repairMaterials.get(0)); + } - */ -/** - * Gets the RepairMaterialType value for this repairable item - * - * @return the RepairMaterialType for this repairable - *//* + public ItemMaterialCategory determineMaterialType(Material material) { + switch (material) { + case STRING: + return ItemMaterialCategory.STRING; - public ItemMaterialCategory getRepairItemMaterialCategory(); + case LEATHER: + return ItemMaterialCategory.LEATHER; - */ -/** - * Gets the minimum quantity of repair materials ignoring all other repair bonuses - * - * This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords - * - * @return the minimum number of items - *//* + case ACACIA_PLANKS: + case BIRCH_PLANKS: + case DARK_OAK_PLANKS: + case JUNGLE_PLANKS: + case OAK_PLANKS: + case SPRUCE_PLANKS: + return ItemMaterialCategory.WOOD; - public int getMinimumQuantity(); + case STONE: + return ItemMaterialCategory.STONE; - */ -/** - * Gets the maximum durability of this item before it breaks - * - * @return the maximum durability - *//* + case IRON_INGOT: + return ItemMaterialCategory.IRON; - public short getMaximumDurability(); + case GOLD_INGOT: + return ItemMaterialCategory.GOLD; - */ -/** - * Gets the base repair durability on which to calculate bonuses. - * - * This is actually the maximum durability divided by the minimum quantity - * - * @return the base repair durability - *//* + case DIAMOND: + return ItemMaterialCategory.DIAMOND; - public short getBaseRepairDurability(); + default: + return ItemMaterialCategory.OTHER; + } + } - */ -/** - * Gets the minimum repair level needed to repair this item - * - * @return the minimum level to repair this item, or 0 for no minimum - *//* + 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; + } + } - public int getMinimumLevel(); + public Material getItemMaterial() { + return itemMaterial; + } - */ -/** - * Gets the xpMultiplier for this repairable - * - * @return the xpMultiplier of this repairable - *//* + public List getRepairMaterials() { + return repairMaterials; + } - public double getXpMultiplier(); + public List getRepairMaterialsRegistryKeys() { + return ItemUtils.getRepairItemMaterials(repairMaterials); + } + + + public ItemType getRepairItemType() { + return repairItemType; + } + + public ItemMaterialCategory getRepairItemMaterialCategory() { + return repairItemMaterialCategory; + } + + public int getMinimumQuantity() { + return minimumQuantity; + } + + public short getMaximumDurability() { + return maximumDurability; + } + + public short getBaseRepairDurability() { + return baseRepairDurability; + } + + public int getMinimumLevel() { + return minimumLevel; + } + + public double getXpMultiplier() { + return xpMultiplier; + } } -*/ diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java similarity index 56% rename from src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java rename to src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java index 6992b1975..3963cc50e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java @@ -1,31 +1,32 @@ package com.gmail.nossr50.skills.repair.repairables; +import com.gmail.nossr50.config.Unload; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; -public class SimpleRepairableManager implements Unload { - private HashMap repairables; +public class RepairableManager implements Unload { + private HashMap repairables; @Override public void unload() { repairables.clear(); } - public SimpleRepairableManager(List repairablesCollection) { - this.repairables = new HashMap(repairablesCollection.size()); + public RepairableManager(List repairablesCollection) { + this.repairables = new HashMap(repairablesCollection.size()); registerRepairables(repairablesCollection); } - public void registerRepairable(SimpleRepairable repairable) { + public void registerRepairable(Repairable repairable) { Material item = repairable.getItemMaterial(); repairables.put(item, repairable); } - public void registerRepairables(List repairables) { - for (SimpleRepairable repairable : repairables) { + public void registerRepairables(List repairables) { + for (Repairable repairable : repairables) { registerRepairable(repairable); } } @@ -38,7 +39,7 @@ public class SimpleRepairableManager implements Unload { return isRepairable(itemStack.getType()); } - public SimpleRepairable getRepairable(Material type) { + public Repairable getRepairable(Material type) { return repairables.get(type); } } 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 deleted file mode 100644 index 9c4054edb..000000000 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.gmail.nossr50.skills.repair.repairables; - -import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; -import com.gmail.nossr50.datatypes.skills.ItemType; -import com.gmail.nossr50.util.ItemUtils; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; -import java.util.List; - - -public class SimpleRepairable { - private final Material itemMaterial; - private final List repairMaterials; - private final int minimumQuantity, minimumLevel; - private final short maximumDurability, baseRepairDurability; - private final ItemType repairItemType; - private final ItemMaterialCategory repairItemMaterialCategory; - private final double xpMultiplier; - - public SimpleRepairable(Material itemMaterial, Material repairMaterial, int minimumQuantity, int minimumLevel, double xpMultiplier) { - this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(Arrays.asList(repairMaterial)), minimumQuantity, minimumLevel, xpMultiplier); - } - - public SimpleRepairable(Material itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { - this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(repairMaterials), minimumQuantity, minimumLevel, xpMultiplier); - } - - public SimpleRepairable(String itemMaterial, List repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) { - this.itemMaterial = Material.matchMaterial(itemMaterial); - this.repairMaterials = ItemUtils.matchMaterials(repairMaterials); - this.minimumQuantity = minimumQuantity; - this.minimumLevel = minimumLevel; - this.xpMultiplier = xpMultiplier; - - this.maximumDurability = this.itemMaterial.getMaxDurability(); - this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); - - this.repairItemType = determineItemType(this.itemMaterial); - this.repairItemMaterialCategory = determineMaterialType(this.repairMaterials.get(0)); - } - - public ItemMaterialCategory determineMaterialType(Material material) { - switch (material) { - case STRING: - return ItemMaterialCategory.STRING; - - case LEATHER: - return ItemMaterialCategory.LEATHER; - - case ACACIA_PLANKS: - case BIRCH_PLANKS: - case DARK_OAK_PLANKS: - case JUNGLE_PLANKS: - case OAK_PLANKS: - case SPRUCE_PLANKS: - return ItemMaterialCategory.WOOD; - - case STONE: - return ItemMaterialCategory.STONE; - - case IRON_INGOT: - return ItemMaterialCategory.IRON; - - case GOLD_INGOT: - return ItemMaterialCategory.GOLD; - - case DIAMOND: - return ItemMaterialCategory.DIAMOND; - - default: - return ItemMaterialCategory.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; - } - } - - public Material getItemMaterial() { - return itemMaterial; - } - - public List getRepairMaterials() { - return repairMaterials; - } - - public List getRepairMaterialsRegistryKeys() { - return ItemUtils.getRepairItemMaterials(repairMaterials); - } - - - public ItemType getRepairItemType() { - return repairItemType; - } - - public ItemMaterialCategory getRepairItemMaterialCategory() { - return repairItemMaterialCategory; - } - - public int getMinimumQuantity() { - return minimumQuantity; - } - - public short getMaximumDurability() { - return maximumDurability; - } - - public short getBaseRepairDurability() { - return baseRepairDurability; - } - - public int getMinimumLevel() { - return minimumLevel; - } - - public double getXpMultiplier() { - return xpMultiplier; - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java index 70a1bf0e2..66d2a04aa 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java @@ -1,103 +1,89 @@ -/* package com.gmail.nossr50.skills.salvage.salvageables; import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; import com.gmail.nossr50.datatypes.skills.ItemType; import org.bukkit.Material; -public interface Salvageable { - */ -/** - * Gets the type of this salvageable item - * - * @return the type of this salvageable - *//* - public Material getItemMaterial(); +public class Salvageable { + private final Material itemMaterial, salvagedItemMaterial; + private final int maximumQuantity, minimumLevel; + private final short maximumDurability, baseSalvageDurability; + private final byte salvageMetadata; + private final ItemType salvageItemType; + private final ItemMaterialCategory salvageItemMaterialCategory; + private final double xpMultiplier; - */ -/** - * Gets the material of the items dropped when salvaging this item - * - * @return the material of the salvage drop - *//* + /*protected Salvageable(Material type, Material salvagedItemMaterial, byte salvageMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType salvageItemType, ItemMaterialCategory salvageItemMaterialCategory, double xpMultiplier) { + this.itemMaterial = type; + this.salvagedItemMaterial = salvagedItemMaterial; + this.salvageMetadata = salvageMetadata; + this.salvageItemType = salvageItemType; + this.salvageItemMaterialCategory = salvageItemMaterialCategory; + this.minimumLevel = minimumLevel; + this.maximumQuantity = maximumQuantity; + this.maximumDurability = maximumDurability; + this.baseSalvageDurability = (short) (maximumDurability / maximumQuantity); + this.xpMultiplier = xpMultiplier; + }*/ - public Material getSalvageMaterial(); + public Salvageable(String itemRegisterKey, String salvagedMaterialRegisterKey, int minimumLevel, int maximumQuantity) + { + this(Material.matchMaterial(itemRegisterKey), Material.matchMaterial(salvagedMaterialRegisterKey), minimumLevel, maximumQuantity); + } - */ -/** - * Gets the metadata byte value of the items dropped when salvaging this item - * - * @return the byte metadata of the salvage drop - *//* + public Salvageable(Material itemMaterial, Material salvagedItemMaterial, int minimumLevel, int maximumQuantity) + { - public byte getSalvageMaterialMetadata(); + this.itemMaterial = itemMaterial; + this.salvagedItemMaterial = salvagedItemMaterial; +// this.salvageMetadata = salvageMetadata; + this.salvageItemType = salvageItemType; + this.salvageItemMaterialCategory = salvageItemMaterialCategory; + this.minimumLevel = minimumLevel; + this.maximumQuantity = maximumQuantity; + this.maximumDurability = maximumDurability; + this.baseSalvageDurability = (short) (maximumDurability / maximumQuantity); + this.xpMultiplier = xpMultiplier; + } - */ -/** - * Gets the ItemType value for this salvageable item - * - * @return the ItemType for this salvageable - *//* + public Material getItemMaterial() { + return itemMaterial; + } - public ItemType getSalvageItemType(); + public Material getSalvagedItemMaterial() { + return salvagedItemMaterial; + } - */ -/** - * Gets the ItemMaterialCategory value for this salvageable item - * - * @return the ItemMaterialCategory for this salvageable - *//* + /*public byte getSalvageMaterialMetadata() { + return salvageMetadata; + }*/ - public ItemMaterialCategory getSalvageItemMaterialCategory(); + public ItemType getSalvageItemType() { + return salvageItemType; + } - */ -/** - * Gets the maximum quantity of salvage materials ignoring all other salvage bonuses - * - * This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords - * - * @return the maximum number of items - *//* + public ItemMaterialCategory getSalvageItemMaterialCategory() { + return salvageItemMaterialCategory; + } - public int getMaximumQuantity(); + public int getMaximumQuantity() { + return maximumQuantity; + } - */ -/** - * Gets the maximum durability of this item before it breaks - * - * @return the maximum durability - *//* + public short getMaximumDurability() { + return maximumDurability; + } - public short getMaximumDurability(); + public short getBaseSalvageDurability() { + return baseSalvageDurability; + } - */ -/** - * Gets the base salvage durability on which to calculate bonuses. - * - * This is actually the maximum durability divided by the minimum quantity - * - * @return the base salvage durability - *//* + public int getMinimumLevel() { + return minimumLevel; + } - public short getBaseSalvageDurability(); - - */ -/** - * Gets the minimum salvage level needed to salvage this item - * - * @return the minimum level to salvage this item, or 0 for no minimum - *//* - - public int getMinimumLevel(); - - */ -/** - * Gets the xpMultiplier for this salvageable - * - * @return the xpMultiplier of this salvageable - *//* - - public double getXpMultiplier(); + public double getXpMultiplier() { + return xpMultiplier; + } } -*/ diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java index aefa77714..b9417142b 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java @@ -11,6 +11,6 @@ public class SalvageableFactory { public static Salvageable getSalvageable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType repairItemType, ItemMaterialCategory repairItemMaterialCategory, double xpMultiplier) { // TODO: Add in loading from config what type of repairable we want. - return new SimpleSalvageable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, maximumQuantity, maximumDurability, repairItemType, repairItemMaterialCategory, xpMultiplier); + return new Salvageable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, maximumQuantity, maximumDurability, repairItemType, repairItemMaterialCategory, xpMultiplier); } } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java index b217813fd..bd3e944f3 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java @@ -1,62 +1,50 @@ -/* package com.gmail.nossr50.skills.salvage.salvageables; import com.gmail.nossr50.config.Unload; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import java.util.HashMap; import java.util.List; -public interface SalvageableManager extends Unload { - */ -/** - * Register a salvageable with the SalvageManager - * - * @param salvageable Salvageable to register - *//* - public void registerSalvageable(Salvageable salvageable); +public class SalvageableManager implements Unload { + private HashMap salvageables; - */ -/** - * Register a list of salvageables with the SalvageManager - * - * @param salvageables List to register - *//* + /*public SalvageableManager() { + this(55); + }*/ - public void registerSalvageables(List salvageables); + @Override + public void unload() { + salvageables.clear(); + } - */ -/** - * Checks if an item is salvageable - * - * @param type Material to check if salvageable - * - * @return true if salvageable, false if not - *//* + public SalvageableManager(List salvageablesCollection) { + this.salvageables = new HashMap(salvageablesCollection.size()); + registerSalvageables(salvageablesCollection); + } - public boolean isSalvageable(Material type); + public void registerSalvageable(Salvageable salvageable) { + Material item = salvageable.getItemMaterial(); + salvageables.put(item, salvageable); + } - */ -/** - * Checks if an item is salvageable - * - * @param itemStack Item to check if salvageable - * - * @return true if salvageable, false if not - *//* + public void registerSalvageables(List salvageables) { + for (Salvageable salvageable : salvageables) { + registerSalvageable(salvageable); + } + } - public boolean isSalvageable(ItemStack itemStack); + public boolean isSalvageable(Material type) { + return salvageables.containsKey(type); + } - */ -/** - * Gets the salvageable with this type - * - * @param type Material of the salvageable to look for - * - * @return the salvageable, can be null - *//* + public boolean isSalvageable(ItemStack itemStack) { + return isSalvageable(itemStack.getType()); + } - public Salvageable getSalvageable(Material type); + public Salvageable getSalvageable(Material type) { + return salvageables.get(type); + } } -*/ diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java deleted file mode 100644 index 66f1ef2a3..000000000 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.gmail.nossr50.skills.salvage.salvageables; - -import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; -import com.gmail.nossr50.datatypes.skills.ItemType; -import org.bukkit.Material; - - -public class SimpleSalvageable implements Salvageable { - private final Material itemMaterial, salvageMaterial; - private final int maximumQuantity, minimumLevel; - private final short maximumDurability, baseSalvageDurability; - private final byte salvageMetadata; - private final ItemType salvageItemType; - private final ItemMaterialCategory salvageItemMaterialCategory; - private final double xpMultiplier; - - protected SimpleSalvageable(Material type, Material salvageMaterial, byte salvageMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType salvageItemType, ItemMaterialCategory salvageItemMaterialCategory, double xpMultiplier) { - this.itemMaterial = type; - this.salvageMaterial = salvageMaterial; - this.salvageMetadata = salvageMetadata; - this.salvageItemType = salvageItemType; - this.salvageItemMaterialCategory = salvageItemMaterialCategory; - this.minimumLevel = minimumLevel; - this.maximumQuantity = maximumQuantity; - this.maximumDurability = maximumDurability; - this.baseSalvageDurability = (short) (maximumDurability / maximumQuantity); - this.xpMultiplier = xpMultiplier; - } - - @Override - public Material getItemMaterial() { - return itemMaterial; - } - - @Override - public Material getSalvageMaterial() { - return salvageMaterial; - } - - @Override - public byte getSalvageMaterialMetadata() { - return salvageMetadata; - } - - @Override - public ItemType getSalvageItemType() { - return salvageItemType; - } - - @Override - public ItemMaterialCategory getSalvageItemMaterialCategory() { - return salvageItemMaterialCategory; - } - - @Override - public int getMaximumQuantity() { - return maximumQuantity; - } - - @Override - public short getMaximumDurability() { - return maximumDurability; - } - - @Override - public short getBaseSalvageDurability() { - return baseSalvageDurability; - } - - @Override - public int getMinimumLevel() { - return minimumLevel; - } - - @Override - public double getXpMultiplier() { - return xpMultiplier; - } -} diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java deleted file mode 100644 index 48c2f6d39..000000000 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.gmail.nossr50.skills.salvage.salvageables; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.List; - - -public class SimpleSalvageableManager implements SalvageableManager { - private HashMap salvageables; - - /*public SimpleSalvageableManager() { - this(55); - }*/ - - @Override - public void unload() { - salvageables.clear(); - } - - public SimpleSalvageableManager(List salvageablesCollection) { - this.salvageables = new HashMap(salvageablesCollection.size()); - registerSalvageables(salvageablesCollection); - } - - @Override - public void registerSalvageable(Salvageable salvageable) { - Material item = salvageable.getItemMaterial(); - salvageables.put(item, salvageable); - } - - @Override - public void registerSalvageables(List salvageables) { - for (Salvageable salvageable : salvageables) { - registerSalvageable(salvageable); - } - } - - @Override - public boolean isSalvageable(Material type) { - return salvageables.containsKey(type); - } - - @Override - public boolean isSalvageable(ItemStack itemStack) { - return isSalvageable(itemStack.getType()); - } - - @Override - public Salvageable getSalvageable(Material type) { - return salvageables.get(type); - } -}