Probably fixed Insurance IllegalArgumentException

This commit is contained in:
alisolarflare 2016-12-17 07:22:56 -05:00
parent 812dd89ee0
commit 5801eaaddd
5 changed files with 12 additions and 12 deletions

View file

@ -12,13 +12,13 @@ import buttondevteam.lib.DebugPotato;
public abstract class Insurance { public abstract class Insurance {
public static enum InsuranceType{ public static enum InsuranceType{
Nugget, Ingot, Block nugget, ingot, block
}; };
public static ItemStack getInsurance(InsuranceType insuranceType){ public static ItemStack getInsurance(InsuranceType insuranceType){
ItemStack insuranceItem; ItemStack insuranceItem;
List<String> lore; List<String> lore;
switch(insuranceType){ switch(insuranceType){
case Nugget: case nugget:
insuranceItem = new ItemStack(Material.GOLD_NUGGET); insuranceItem = new ItemStack(Material.GOLD_NUGGET);
lore = Arrays.asList( lore = Arrays.asList(
"This insurance nugget will protect ", "This insurance nugget will protect ",
@ -28,7 +28,7 @@ public abstract class Insurance {
"one nugget." "one nugget."
); );
break; break;
case Ingot: case ingot:
insuranceItem = new ItemStack(Material.GOLD_INGOT); insuranceItem = new ItemStack(Material.GOLD_INGOT);
lore = Arrays.asList( lore = Arrays.asList(
"This insurance ingot will protect ", "This insurance ingot will protect ",
@ -38,7 +38,7 @@ public abstract class Insurance {
"row costing one ingot." "row costing one ingot."
); );
break; break;
case Block: case block:
insuranceItem = new ItemStack(Material.GOLD_BLOCK); insuranceItem = new ItemStack(Material.GOLD_BLOCK);
lore = Arrays.asList( lore = Arrays.asList(
"This insurance block will give your ", "This insurance block will give your ",
@ -74,7 +74,7 @@ public abstract class Insurance {
} }
public static boolean isInsuranceType(String string){ public static boolean isInsuranceType(String string){
for (InsuranceType insuranceType : Insurance.InsuranceType.values()){ for (InsuranceType insuranceType : Insurance.InsuranceType.values()){
if (string.equalsIgnoreCase(insuranceType.toString())){ if (string.equals(insuranceType.toString())){
return true; return true;
} }
} }

View file

@ -8,7 +8,7 @@ import buttondevteam.alipresents.components.insurance.Insurance.InsuranceType;
public class getInsurance extends ModCommand { public class getInsurance extends ModCommand {
private final int defaultAmount = 1; private final int defaultAmount = 1;
private final InsuranceType defaultInsuranceType = InsuranceType.Block; private final InsuranceType defaultInsuranceType = InsuranceType.block;
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
int amount = defaultAmount; int amount = defaultAmount;

View file

@ -11,9 +11,9 @@ public class getInsuranceBlock extends ModCommand {
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
if (args.length > 0 && StringUtils.isNumeric(args[0])){ if (args.length > 0 && StringUtils.isNumeric(args[0])){
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Block, Integer.parseInt(args[0]))); player.getInventory().addItem(Insurance.getInsurance(InsuranceType.block, Integer.parseInt(args[0])));
}else{ }else{
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Block)); player.getInventory().addItem(Insurance.getInsurance(InsuranceType.block));
} }
return true; return true;
} }

View file

@ -11,9 +11,9 @@ public class getInsuranceIngot extends ModCommand {
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
if (args.length > 0 && StringUtils.isNumeric(args[0])){ if (args.length > 0 && StringUtils.isNumeric(args[0])){
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Ingot, Integer.parseInt(args[0]))); player.getInventory().addItem(Insurance.getInsurance(InsuranceType.ingot, Integer.parseInt(args[0])));
}else{ }else{
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Ingot)); player.getInventory().addItem(Insurance.getInsurance(InsuranceType.ingot));
} }
return true; return true;
} }

View file

@ -11,9 +11,9 @@ public class getInsuranceNugget extends ModCommand {
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
if (args.length > 0 && StringUtils.isNumeric(args[0])){ if (args.length > 0 && StringUtils.isNumeric(args[0])){
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Nugget, Integer.parseInt(args[0]))); player.getInventory().addItem(Insurance.getInsurance(InsuranceType.nugget, Integer.parseInt(args[0])));
}else{ }else{
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Nugget)); player.getInventory().addItem(Insurance.getInsurance(InsuranceType.nugget));
} }
return true; return true;
} }