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

82 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
2016-11-19 22:40:31 +00:00
import buttondevteam.lib.DebugPotatoAPI;
2016-11-17 20:27:48 +00:00
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(
2016-11-19 18:52:27 +00:00
"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."
2016-11-17 20:27:48 +00:00
);
break;
case Ingot:
insuranceItem = new ItemStack(Material.GOLD_INGOT);
lore = Arrays.asList(
2016-11-19 18:52:27 +00:00
"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."
2016-11-17 20:27:48 +00:00
);
break;
case Block:
insuranceItem = new ItemStack(Material.GOLD_BLOCK);
lore = Arrays.asList(
2016-11-19 18:52:27 +00:00
"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."
2016-11-17 20:27:48 +00:00
);
break;
default:
lore = Arrays.asList(
2016-11-19 18:52:27 +00:00
"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"
2016-11-17 20:27:48 +00:00
);
2016-11-19 19:47:14 +00:00
insuranceItem = DebugPotatoAPI.CreateDebugPotato(lore);
2016-11-17 20:27:48 +00:00
}
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;
}
}