mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
Change some checks around in /addlevels for readability.
This commit is contained in:
parent
55b17e7d2b
commit
0b6e854520
@ -23,32 +23,33 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Misc.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = SkillTools.getSkillType(args[0]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", new Object[] {levels, Misc.getCapitalized(skill.toString())}));
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
@ -86,7 +87,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
// TODO: Is it even possible for the player to be offline at this point?
|
||||
if (player.isOnline()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
|
||||
|
Loading…
Reference in New Issue
Block a user