1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Fix exp command when contains string instead of number, continue to next step

This commit is contained in:
montlikadani 2019-03-15 15:27:12 +01:00
parent c5935ccd6d
commit 9436fae564

View File

@ -24,51 +24,40 @@ public class exp implements Cmd {
return true;
}
Action action = Action.Add;
double amount = 0;
String playerName = null;
Job job = null;
for (String one : args) {
switch (one.toLowerCase()) {
case "add":
action = Action.Add;
continue;
case "set":
action = Action.Set;
continue;
case "take":
action = Action.Take;
continue;
}
try {
amount = Double.parseDouble(one);
continue;
} catch (NumberFormatException e) {
}
if (job == null && Jobs.getJob(one) != null) {
job = Jobs.getJob(one);
continue;
}
playerName = one;
}
if (playerName == null)
return false;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0]));
return true;
}
Job job = Jobs.getJob(args[1]);
if (job == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job"));
return true;
}
Action action = Action.Add;
switch (args[2].toLowerCase()) {
case "add":
action = Action.Add;
break;
case "set":
action = Action.Set;
break;
case "take":
action = Action.Take;
break;
}
double amount = 0.0;
try {
amount = Double.parseDouble(args[3]);
} catch (Throwable e) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error"));
return true;
}
try {
// check if player already has the job
if (jPlayer.isInJob(job)) {