mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-01 21:24:43 +02:00
Refactoring Salvageables/Repairables, removing Simple from the naming schemes
This commit is contained in:
@ -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