ButtonArchives/src/alisolarflare/components/insurance/Insurance.java

75 lines
2.4 KiB
Java
Raw Normal View History

2016-11-17 20:27:48 +00:00
package alisolarflare.components.insurance;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
2016-11-19 18:32:49 +00:00
import org.bukkit.inventory.meta.ItemMeta;
2016-11-17 20:27:48 +00:00
import alisolarflare.components.BaseCommand;
public abstract class Insurance {
2016-11-17 20:27:48 +00:00
public static enum InsuranceType{
Nugget, Ingot, Block
};
public static ItemStack getInsurance(InsuranceType insuranceType){
ItemStack insuranceItem;
List<String> lore;
switch(insuranceType){
case Nugget:
insuranceItem = new ItemStack(Material.GOLD_NUGGET);
lore = Arrays.asList(
"This insurance nugget will protect one inventory slot from death! Be careful"
+ "though, insurance is removed whenever you die, with each itemslot costing"
+ "one nugget."
);
break;
case Ingot:
insuranceItem = new ItemStack(Material.GOLD_INGOT);
lore = Arrays.asList(
"This insurance ingot will protect nine inventory slots from death! Be "
+ "careful though, insurance is removed whenever you die, with each "
+ "inventory row costing one ingot."
);
break;
case Block:
insuranceItem = new ItemStack(Material.GOLD_BLOCK);
lore = Arrays.asList(
"This insurance block will give your inventory full protection against death! "
+ "Be careful though, this block will split into ingots, and you'll lose 3"
+ "upon death."
);
break;
default:
lore = Arrays.asList(
"The InsuranceType " + insuranceType.toString() + " is not handled by the " +
"Insurance Class in" + Insurance.class.getPackage().getName() + ". Contact a "+
"developer with a screenshot of this message"
);
insuranceItem = BaseCommand.CreateDebugPotato(lore);
}
2016-11-19 17:24:22 +00:00
insuranceItem.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
2016-11-19 18:32:49 +00:00
ItemMeta meta = insuranceItem.getItemMeta();
meta.setLore(lore);
meta.setDisplayName("Insurance " + insuranceType.toString());
insuranceItem.setItemMeta(meta);
2016-11-17 20:27:48 +00:00
return insuranceItem;
}
public static ItemStack getInsurance(InsuranceType insuranceType, int amount){
ItemStack insurance = Insurance.getInsurance(insuranceType);
insurance.setAmount(amount);
return insurance;
}
public static boolean isInsuranceType(String string){
for (InsuranceType insuranceType : Insurance.InsuranceType.values()){
if (string.equalsIgnoreCase(insuranceType.toString())){
return true;
}
}
return false;
}
}