mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Cleanup of the AddLevels command.
This commit is contained in:
parent
a1283bfc0f
commit
c9db9566cb
@ -10,72 +10,84 @@ 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;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
private final mcMMO plugin;
|
||||
private final mcMMO plugin;
|
||||
|
||||
public AddlevelsCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
public AddlevelsCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player sendingPlayer;
|
||||
Player modifiedPlayer;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
sendingPlayer = (Player) sender;
|
||||
|
||||
if (sendingPlayer != null && !mcPermissions.getInstance().mmoedit(sendingPlayer)) {
|
||||
sendingPlayer.sendMessage(mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
||||
sender.sendMessage("This command requires permissions."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
|
||||
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.
|
||||
}
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
|
||||
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) {
|
||||
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.
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname newvalue"); //TODO: Needs more locale.
|
||||
}
|
||||
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());
|
||||
|
||||
return true;
|
||||
}
|
||||
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