mirror of
https://github.com/EpicEricEE/ShopChest.git
synced 2024-11-25 12:06:16 +01:00
Make ShopProduct abstract class
This commit is contained in:
parent
5c2f3022b5
commit
d2af5fb0ad
@ -7,7 +7,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
*
|
||||
* @since 1.13
|
||||
*/
|
||||
public interface ShopProduct {
|
||||
public abstract class ShopProduct implements Cloneable {
|
||||
private ItemStack itemStack;
|
||||
private int amount;
|
||||
|
||||
public ShopProduct(ItemStack itemStack, int amount) {
|
||||
this.itemStack = itemStack;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a copy of this product's {@link ItemStack} with an amount of one
|
||||
@ -15,7 +22,9 @@ public interface ShopProduct {
|
||||
* @return the item
|
||||
* @since 1.13
|
||||
*/
|
||||
ItemStack getItemStack();
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this product's {@link ItemStack}
|
||||
@ -25,7 +34,10 @@ public interface ShopProduct {
|
||||
* @param itemStack the item
|
||||
* @since 1.13
|
||||
*/
|
||||
void setItemStack(ItemStack itemStack);
|
||||
public void setItemStack(ItemStack itemStack) {
|
||||
this.itemStack = itemStack.clone();
|
||||
this.itemStack.setAmount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of items bought or sold in one transaction
|
||||
@ -33,7 +45,9 @@ public interface ShopProduct {
|
||||
* @return the amount
|
||||
* @since 1.13
|
||||
*/
|
||||
int getAmount();
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount of items bought or sold in one transaction
|
||||
@ -41,7 +55,9 @@ public interface ShopProduct {
|
||||
* @param amount the amount
|
||||
* @since 1.13
|
||||
*/
|
||||
void setAmount(int amount);
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the localized name of this product's item in the configured langauge file
|
||||
@ -49,6 +65,21 @@ public interface ShopProduct {
|
||||
* @return the localized name
|
||||
* @since 1.13
|
||||
*/
|
||||
String getLocalizedName();
|
||||
public abstract String getLocalizedName();
|
||||
|
||||
@Override
|
||||
public ShopProduct clone() {
|
||||
try {
|
||||
ShopProduct shopProduct = (ShopProduct) super.clone();
|
||||
|
||||
if (this.itemStack != null) {
|
||||
shopProduct.itemStack = this.itemStack.clone();
|
||||
}
|
||||
|
||||
return shopProduct;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user