mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16: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.m;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.mcPermissions;
|
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.locale.mcLocale;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
|
|
||||||
public class AddlevelsCommand implements CommandExecutor{
|
public class AddlevelsCommand implements CommandExecutor{
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
public AddlevelsCommand(mcMMO instance) {
|
public AddlevelsCommand(mcMMO instance) {
|
||||||
this.plugin = 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) {
|
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)) {
|
switch (args.length) {
|
||||||
sender.sendMessage("This command requires permissions."); //TODO: Needs more locale.
|
case 2:
|
||||||
return true;
|
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)) {
|
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||||
if (args.length < 2) {
|
sender.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
||||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
}
|
||||||
return true;
|
}
|
||||||
} else if (args.length == 3) {
|
else {
|
||||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||||
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;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
case 3:
|
||||||
|
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||||
|
String playerName = modifiedPlayer.getName();
|
||||||
|
|
||||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
levels = Integer.valueOf(args[2]);
|
||||||
return true;
|
skill = Skills.getSkillType(args[1]);
|
||||||
}
|
skillName = m.getCapitalized(skill.toString());
|
||||||
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.
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GreenThumbFail=[[RED]]**GREEN THUMB FAIL**
|
||||||
mcPlayerListener.HerbalismSkill=Herbalism:
|
mcPlayerListener.HerbalismSkill=Herbalism:
|
||||||
mcPlayerListener.MiningSkill=Mining:
|
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.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.NotInParty=[[RED]]You are not in a party.
|
||||||
mcPlayerListener.InviteSuccess=[[GREEN]]Invite sent successfully.
|
mcPlayerListener.InviteSuccess=[[GREEN]]Invite sent successfully.
|
||||||
|
Loading…
Reference in New Issue
Block a user