Change some checks around in /addlevels for readability.

This commit is contained in:
GJ 2013-02-02 02:11:46 -05:00
parent 55b17e7d2b
commit 0b6e854520

View File

@ -23,13 +23,19 @@ public class AddlevelsCommand implements CommandExecutor{
switch (args.length) { switch (args.length) {
case 2: case 2:
if (sender instanceof Player) { if (!(sender instanceof Player)) {
return false;
}
if (!SkillTools.isSkill(args[0])) { if (!SkillTools.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true; return true;
} }
if (Misc.isInt(args[1])) { if (!Misc.isInt(args[1])) {
return false;
}
levels = Integer.valueOf(args[1]); levels = Integer.valueOf(args[1]);
skill = SkillTools.getSkillType(args[0]); skill = SkillTools.getSkillType(args[0]);
profile = Users.getPlayer((Player) sender).getProfile(); profile = Users.getPlayer((Player) sender).getProfile();
@ -43,11 +49,6 @@ public class AddlevelsCommand implements CommandExecutor{
profile.addLevels(skill, levels); profile.addLevels(skill, levels);
return true; return true;
}
}
else {
return false;
}
case 3: case 3:
if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) { if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) {
@ -86,7 +87,7 @@ public class AddlevelsCommand implements CommandExecutor{
profile.addLevels(skill, levels); 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 (player.isOnline()) {
if (skill.equals(SkillType.ALL)) { if (skill.equals(SkillType.ALL)) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels})); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));