mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-01 13:14:44 +02:00
Refactoring Salvageables/Repairables, removing Simple from the naming schemes
This commit is contained in:
@ -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");
|
||||
|
@ -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<Material> 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<Material> 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<String> 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<Material> getRepairMaterials() {
|
||||
return repairMaterials;
|
||||
}
|
||||
|
||||
public double getXpMultiplier();
|
||||
public List<String> 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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -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<Material, SimpleRepairable> repairables;
|
||||
public class RepairableManager implements Unload {
|
||||
private HashMap<Material, Repairable> repairables;
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
repairables.clear();
|
||||
}
|
||||
|
||||
public SimpleRepairableManager(List<SimpleRepairable> repairablesCollection) {
|
||||
this.repairables = new HashMap<Material, SimpleRepairable>(repairablesCollection.size());
|
||||
public RepairableManager(List<Repairable> repairablesCollection) {
|
||||
this.repairables = new HashMap<Material, Repairable>(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<SimpleRepairable> repairables) {
|
||||
for (SimpleRepairable repairable : repairables) {
|
||||
public void registerRepairables(List<Repairable> 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);
|
||||
}
|
||||
}
|
@ -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<Material> 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<Material> repairMaterials, int minimumQuantity, int minimumLevel, double xpMultiplier) {
|
||||
this(itemMaterial.getKey().getKey(), ItemUtils.getRepairItemMaterials(repairMaterials), minimumQuantity, minimumLevel, xpMultiplier);
|
||||
}
|
||||
|
||||
public SimpleRepairable(String itemMaterial, List<String> 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<Material> getRepairMaterials() {
|
||||
return repairMaterials;
|
||||
}
|
||||
|
||||
public List<String> 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<Material, Salvageable> salvageables;
|
||||
|
||||
*/
|
||||
/**
|
||||
* Register a list of salvageables with the SalvageManager
|
||||
*
|
||||
* @param salvageables List<Salvageable> to register
|
||||
*//*
|
||||
/*public SalvageableManager() {
|
||||
this(55);
|
||||
}*/
|
||||
|
||||
public void registerSalvageables(List<Salvageable> 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<Salvageable> salvageablesCollection) {
|
||||
this.salvageables = new HashMap<Material, Salvageable>(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<Salvageable> 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);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<Material, Salvageable> salvageables;
|
||||
|
||||
/*public SimpleSalvageableManager() {
|
||||
this(55);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
salvageables.clear();
|
||||
}
|
||||
|
||||
public SimpleSalvageableManager(List<Salvageable> salvageablesCollection) {
|
||||
this.salvageables = new HashMap<Material, Salvageable>(salvageablesCollection.size());
|
||||
registerSalvageables(salvageablesCollection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSalvageable(Salvageable salvageable) {
|
||||
Material item = salvageable.getItemMaterial();
|
||||
salvageables.put(item, salvageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSalvageables(List<Salvageable> 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user