mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Cleanup of the AddLevels command.
This commit is contained in:
parent
a1283bfc0f
commit
c9db9566cb
@ -10,7 +10,7 @@ import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
@ -23,59 +23,71 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
Player sendingPlayer;
|
||||
Player modifiedPlayer;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
sendingPlayer = (Player) sender;
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
||||
sender.sendMessage("This command requires permissions."); //TODO: Needs more locale.
|
||||
if (sendingPlayer != null && !mcPermissions.getInstance().mmoedit(sendingPlayer)) {
|
||||
sendingPlayer.sendMessage(mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
return true;
|
||||
} else if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int levels = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels);
|
||||
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
||||
}
|
||||
} else {
|
||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int levels = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels);
|
||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified."); //TODO: Needs more locale.
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
int levels = Integer.valueOf(args[1]);
|
||||
PP.addLevels(Skills.getSkillType(args[0]), levels);
|
||||
player.sendMessage(ChatColor.RED + args[0] + " has been modified."); //TODO: Needs more locale.
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname newvalue"); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
|
||||
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
levels = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
modifiedPlayer.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
System.out.println(m.getCapitalized(skill.toString()) + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ mcPlayerListener.GreenThumb=[[GREEN]]**GREEN THUMB**
|
||||
mcPlayerListener.GreenThumbFail=[[RED]]**GREEN THUMB FAIL**
|
||||
mcPlayerListener.HerbalismSkill=Herbalism:
|
||||
mcPlayerListener.MiningSkill=Mining:
|
||||
mcPlayerListener.NoPermission=Insufficient mcPermissions.
|
||||
mcPlayerListener.NoPermission=[[DARK_RED]]Insufficient permissions.
|
||||
mcPlayerListener.NoSkillNote=[[DARK_GRAY]]If you don't have access to a skill it will not be shown here.
|
||||
mcPlayerListener.NotInParty=[[RED]]You are not in a party.
|
||||
mcPlayerListener.InviteSuccess=[[GREEN]]Invite sent successfully.
|
||||
|
Loading…
Reference in New Issue
Block a user