mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Cleanup of AddXP command
This commit is contained in:
parent
c8b30b6714
commit
00e5e75092
@ -45,10 +45,16 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
modifiedPlayer = (Player) sender;
|
modifiedPlayer = (Player) sender;
|
||||||
levels = Integer.valueOf(args[1]);
|
levels = Integer.valueOf(args[1]);
|
||||||
skill = Skills.getSkillType(args[0]);
|
skill = Skills.getSkillType(args[0]);
|
||||||
skillName = m.getCapitalized(skill.toString());
|
|
||||||
|
if (skill.equals(SkillType.ALL)) {
|
||||||
|
skillName = "all skills";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skillName = m.getCapitalized(skill.toString());
|
||||||
|
}
|
||||||
|
|
||||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -64,17 +70,24 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||||
levels = Integer.valueOf(args[2]);
|
levels = Integer.valueOf(args[2]);
|
||||||
skill = Skills.getSkillType(args[1]);
|
skill = Skills.getSkillType(args[1]);
|
||||||
skillName = m.getCapitalized(skill.toString());
|
|
||||||
|
if (skill.equals(SkillType.ALL)) {
|
||||||
|
skillName = "all skills";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skillName = m.getCapitalized(skill.toString());
|
||||||
|
}
|
||||||
|
|
||||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
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 {
|
else {
|
||||||
System.out.println(m.getCapitalized(skill.toString()) + " has been modified for " + playerName + "."); //TODO: Use locale
|
System.out.println(skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -10,76 +10,112 @@ 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.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 AddxpCommand implements CommandExecutor {
|
public class AddxpCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
public AddxpCommand(mcMMO instance) {
|
public AddxpCommand(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 xp;
|
||||||
|
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)) {
|
|
||||||
sender.sendMessage("This command requires permissions."); //TODO: Needs more locale.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
switch (args.length) {
|
||||||
if (args.length < 2) {
|
case 2:
|
||||||
// No console aliasing yet
|
if (sender instanceof Player) {
|
||||||
// System.out.println("Usage is /"+LoadProperties.addxp+" playername skillname xp");
|
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||||
System.out.println("Usage is /addxp playername skillname xp");
|
modifiedPlayer = (Player) sender;
|
||||||
return true;
|
xp = Integer.valueOf(args[1]);
|
||||||
} else if (args.length == 3) {
|
skill = Skills.getSkillType(args[0]);
|
||||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
|
||||||
int newvalue = Integer.valueOf(args[2]);
|
|
||||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXPOverride(Skills.getSkillType(args[1]), newvalue);
|
|
||||||
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!"); //TODO: Needs more locale.
|
|
||||||
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
|
||||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No console aliasing yet
|
|
||||||
// System.out.println("Usage is /"+LoadProperties.addxp+" playername skillname xp");
|
|
||||||
System.out.println("Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
|
||||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 2) {
|
|
||||||
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp"); //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 newvalue = Integer.valueOf(args[2]);
|
|
||||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXP(Skills.getSkillType(args[1]), newvalue);
|
|
||||||
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!"); //TODO: Needs more locale.
|
|
||||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified."); //TODO: Needs more locale.
|
|
||||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
|
||||||
}
|
|
||||||
} else if (args.length == 2 && m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
|
||||||
int newvalue = Integer.valueOf(args[1]);
|
|
||||||
Users.getProfile(player).addXP(Skills.getSkillType(args[0]), newvalue);
|
|
||||||
player.sendMessage(ChatColor.GREEN + "Experience granted!"); //TODO: Needs more locale.
|
|
||||||
player.sendMessage(ChatColor.RED + args[0] + " has been modified."); //TODO: Needs more locale.
|
|
||||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if (skill.equals(SkillType.ALL)) {
|
||||||
}
|
skillName = "all skills";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skillName = m.getCapitalized(skill.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||||
|
|
||||||
|
if (skill.equals(SkillType.ALL)) {
|
||||||
|
Skills.XpCheckAll(modifiedPlayer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Usage is /addxp playername skillname xp"); //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])) {
|
||||||
|
xp = Integer.valueOf(args[2]);
|
||||||
|
skill = Skills.getSkillType(args[1]);
|
||||||
|
|
||||||
|
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
|
||||||
|
|
||||||
|
if (skill.equals(SkillType.ALL)) {
|
||||||
|
skillName = "all skills";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skillName = m.getCapitalized(skill.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println(skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||||
|
|
||||||
|
if (skill.equals(SkillType.ALL)) {
|
||||||
|
Skills.XpCheckAll(modifiedPlayer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user