cleaned up code
This commit is contained in:
parent
18c8080951
commit
5570c06cdb
1 changed files with 23 additions and 18 deletions
|
@ -8,35 +8,40 @@ import alisolarflare.components.ModCommand;
|
||||||
import alisolarflare.components.insurance.Insurance.InsuranceType;
|
import alisolarflare.components.insurance.Insurance.InsuranceType;
|
||||||
|
|
||||||
public class getInsurance extends ModCommand {
|
public class getInsurance extends ModCommand {
|
||||||
|
private final int defaultAmount = 1;
|
||||||
|
private final InsuranceType defaultInsuranceType = InsuranceType.Block;
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args.length == 0){
|
|
||||||
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Block));
|
int amount = defaultAmount;
|
||||||
return true;
|
InsuranceType insuranceType = defaultInsuranceType;
|
||||||
}else if(args.length == 1){
|
|
||||||
|
switch(args.length){
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
if (StringUtils.isNumeric(args[0])){
|
if (StringUtils.isNumeric(args[0])){
|
||||||
int amount = Integer.parseInt(args[0]);
|
amount = Integer.parseInt(args[0]);
|
||||||
player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Block, amount));
|
break;
|
||||||
return true;
|
}else if (Insurance.isInsuranceType(args[0])){
|
||||||
}else{
|
insuranceType = InsuranceType.valueOf(args[0]);
|
||||||
if (Insurance.isInsuranceType(args[0])){
|
break;
|
||||||
player.getInventory().addItem((Insurance.getInsurance(InsuranceType.valueOf(args[0]))));
|
|
||||||
return true;
|
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
default:
|
||||||
}else if (args.length >=2){
|
|
||||||
if (StringUtils.isNumeric(args[0]) && Insurance.isInsuranceType(args[1])){
|
if (StringUtils.isNumeric(args[0]) && Insurance.isInsuranceType(args[1])){
|
||||||
player.getInventory().addItem((Insurance.getInsurance(InsuranceType.valueOf(args[1]), Integer.parseInt(args[0]))));
|
amount = Integer.parseInt(args[0]);
|
||||||
return true;
|
insuranceType = InsuranceType.valueOf(args[0]);
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
player.getInventory().addItem(Insurance.getInsurance(insuranceType, amount));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String[] GetHelpText(String alias){
|
public String[] GetHelpText(String alias){
|
||||||
|
|
Loading…
Reference in a new issue