Removed needs for SkillType.ALL

Also apparently made /Skillreset work on offline players and fixed
missing permissions check
This commit is contained in:
bm01
2013-02-04 16:33:34 +01:00
parent 458f7f5f5b
commit 35cdcb62b7
17 changed files with 379 additions and 346 deletions

View File

@ -35,84 +35,82 @@ public final class CommandRegistrationHelper {
public static void registerSkillCommands() {
for (SkillType skill : SkillType.values()) {
if (skill != SkillType.ALL) {
String commandName = skill.toString().toLowerCase();
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
String commandName = skill.toString().toLowerCase();
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
List<String> aliasList = new ArrayList<String>();
aliasList.add(localizedName);
List<String> aliasList = new ArrayList<String>();
aliasList.add(localizedName);
PluginCommand command;
PluginCommand command;
// Make us play nice with Essentials
if (skill == SkillType.REPAIR && mcMMO.p.getServer().getPluginManager().isPluginEnabled("Essentials")) {
command = mcMMO.p.getCommand("mcrepair");
}
else {
command = mcMMO.p.getCommand(commandName);
}
// Make us play nice with Essentials
if (skill == SkillType.REPAIR && mcMMO.p.getServer().getPluginManager().isPluginEnabled("Essentials")) {
command = mcMMO.p.getCommand("mcrepair");
}
else {
command = mcMMO.p.getCommand(commandName);
}
command.setAliases(aliasList);
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
command.setPermission("mcmmo.commands." + commandName);
command.setPermissionMessage(permissionsMessage);
command.setAliases(aliasList);
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
command.setPermission("mcmmo.commands." + commandName);
command.setPermissionMessage(permissionsMessage);
switch (skill) {
case ACROBATICS:
command.setExecutor(new AcrobaticsCommand());
break;
switch (skill) {
case ACROBATICS:
command.setExecutor(new AcrobaticsCommand());
break;
case ARCHERY:
command.setExecutor(new ArcheryCommand());
break;
case ARCHERY:
command.setExecutor(new ArcheryCommand());
break;
case AXES:
command.setExecutor(new AxesCommand());
break;
case AXES:
command.setExecutor(new AxesCommand());
break;
case EXCAVATION:
command.setExecutor(new ExcavationCommand());
break;
case EXCAVATION:
command.setExecutor(new ExcavationCommand());
break;
case FISHING:
command.setExecutor(new FishingCommand());
break;
case FISHING:
command.setExecutor(new FishingCommand());
break;
case HERBALISM:
command.setExecutor(new HerbalismCommand());
break;
case HERBALISM:
command.setExecutor(new HerbalismCommand());
break;
case MINING:
command.setExecutor(new MiningCommand());
break;
case MINING:
command.setExecutor(new MiningCommand());
break;
case REPAIR:
command.setExecutor(new RepairCommand());
break;
case REPAIR:
command.setExecutor(new RepairCommand());
break;
case SMELTING:
command.setExecutor(new SmeltingCommand());
break;
case SMELTING:
command.setExecutor(new SmeltingCommand());
break;
case SWORDS:
command.setExecutor(new SwordsCommand());
break;
case SWORDS:
command.setExecutor(new SwordsCommand());
break;
case TAMING:
command.setExecutor(new TamingCommand());
break;
case TAMING:
command.setExecutor(new TamingCommand());
break;
case UNARMED:
command.setExecutor(new UnarmedCommand());
break;
case UNARMED:
command.setExecutor(new UnarmedCommand());
break;
case WOODCUTTING:
command.setExecutor(new WoodcuttingCommand());
break;
case WOODCUTTING:
command.setExecutor(new WoodcuttingCommand());
break;
default:
break;
}
default:
break;
}
}
}

View File

@ -19,7 +19,7 @@ public class AddlevelsCommand implements CommandExecutor{
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PlayerProfile profile;
int levels;
SkillType skill;
boolean allSkills = false;
switch (args.length) {
case 2:
@ -27,7 +27,10 @@ public class AddlevelsCommand implements CommandExecutor{
return false;
}
if (!SkillTools.isSkill(args[0])) {
if (args[0].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
@ -37,17 +40,28 @@ public class AddlevelsCommand implements CommandExecutor{
}
levels = Integer.valueOf(args[1]);
skill = SkillTools.getSkillType(args[0]);
profile = Users.getPlayer((Player) sender).getProfile();
if (skill.equals(SkillType.ALL)) {
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.addLevels(skillType, levels);
}
}
else {
profile.addLevels(SkillTools.getSkillType(args[0]), levels);
}
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(skill.toString())));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[0])));
}
profile.addLevels(skill, levels);
return true;
case 3:
@ -56,7 +70,10 @@ public class AddlevelsCommand implements CommandExecutor{
return true;
}
if (!SkillTools.isSkill(args[1])) {
if (args[1].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[1])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
@ -67,7 +84,6 @@ public class AddlevelsCommand implements CommandExecutor{
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
levels = Integer.valueOf(args[2]);
skill = SkillTools.getSkillType(args[1]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@ -78,31 +94,46 @@ public class AddlevelsCommand implements CommandExecutor{
return true;
}
profile.addLevels(skill, levels);
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.addLevels(skillType, levels);
}
}
else {
profile.addLevels(SkillTools.getSkillType(args[1]), levels);
}
profile.save(); // Since this is a temporary profile, we save it here.
}
else {
profile = mcMMOPlayer.getProfile();
Player player = mcMMOPlayer.getPlayer();
profile.addLevels(skill, levels);
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
// Check if the player is online before we try to send them a message.
if (player.isOnline()) {
if (skill.equals(SkillType.ALL)) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(skill.toString())));
profile.addLevels(skillType, levels);
}
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
}
else {
profile.addLevels(SkillTools.getSkillType(args[1]), levels);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[1])));
}
}
if (skill.equals(SkillType.ALL)) {
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(skill.toString()), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
}
return true;

View File

@ -17,11 +17,10 @@ import com.gmail.nossr50.util.Users;
public class AddxpCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player modifiedPlayer;
int xp;
SkillType skill;
McMMOPlayer mcMMOPlayer;
PlayerProfile profile;
boolean allSkills = false;
switch (args.length) {
case 2:
@ -29,7 +28,10 @@ public class AddxpCommand implements CommandExecutor {
return false;
}
if (!SkillTools.isSkill(args[0])) {
if (args[0].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
@ -39,25 +41,23 @@ public class AddxpCommand implements CommandExecutor {
}
xp = Integer.valueOf(args[1]);
skill = SkillTools.getSkillType(args[0]);
modifiedPlayer = (Player) sender;
mcMMOPlayer = Users.getPlayer(modifiedPlayer);
mcMMOPlayer = Users.getPlayer((Player) sender);
profile = mcMMOPlayer.getProfile();
if (skill.equals(SkillType.ALL)) {
for (SkillType type : SkillType.values()) {
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
mcMMOPlayer.applyXpGain(type, xp);
mcMMOPlayer.applyXpGain(skillType, xp);
}
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
}
else {
mcMMOPlayer.applyXpGain(skill, xp);
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(skill.toString())));
mcMMOPlayer.applyXpGain(SkillTools.getSkillType(args[0]), xp);
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[0])));
}
return true;
@ -68,7 +68,10 @@ public class AddxpCommand implements CommandExecutor {
return true;
}
if (!SkillTools.isSkill(args[1])) {
if (args[1].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[1])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
@ -79,7 +82,6 @@ public class AddxpCommand implements CommandExecutor {
mcMMOPlayer = Users.getPlayer(args[0]);
xp = Integer.valueOf(args[2]);
skill = SkillTools.getSkillType(args[1]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@ -91,53 +93,44 @@ public class AddxpCommand implements CommandExecutor {
}
// TODO: Currently the offline player doesn't level up automatically
if (skill.equals(SkillType.ALL)) {
for (SkillType type : SkillType.values()) {
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.setSkillXpLevel(type, profile.getSkillXpLevel(type) + xp);
profile.setSkillXpLevel(skillType, xp);
}
}
else {
profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + xp);
profile.setSkillXpLevel(SkillTools.getSkillType(args[1]), xp);
}
profile.save(); // Since this is a temporary profile, we save it here.
}
else {
if (skill.equals(SkillType.ALL)) {
for (SkillType type : SkillType.values()) {
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
mcMMOPlayer.applyXpGain(type, xp);
mcMMOPlayer.applyXpGain(skillType, xp);
}
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
}
else {
mcMMOPlayer.applyXpGain(skill, xp);
}
modifiedPlayer = mcMMOPlayer.getPlayer();
if (modifiedPlayer.isOnline()) {
if (skill.equals(SkillType.ALL)) {
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
}
else {
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(skill.toString())));
}
mcMMOPlayer.applyXpGain(SkillTools.getSkillType(args[1]), xp);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[1])));
}
}
if (skill.equals(SkillType.ALL)) {
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(skill.toString()), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
}
return true;

View File

@ -19,7 +19,7 @@ public class MmoeditCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PlayerProfile profile;
int newValue;
SkillType skill;
boolean allSkills = false;
switch (args.length) {
case 2:
@ -27,7 +27,10 @@ public class MmoeditCommand implements CommandExecutor {
return false;
}
if (!SkillTools.isSkill(args[0])) {
if (args[0].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
@ -37,26 +40,36 @@ public class MmoeditCommand implements CommandExecutor {
}
newValue = Integer.valueOf(args[1]);
skill = SkillTools.getSkillType(args[0]);
profile = Users.getPlayer((Player) sender).getProfile();
if (skill == SkillType.ALL) {
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.modifySkill(skillType, newValue);
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(skill.toString()), newValue));
profile.modifySkill(SkillTools.getSkillType(args[0]), newValue);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[0]), newValue));
}
profile.modifySkill(skill, newValue);
return true;
case 3:
if (Permissions.hasPermission(sender, "mcmmo.commands.mmoedit.others")) {
if (!Permissions.hasPermission(sender, "mcmmo.commands.mmoedit.others")) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!SkillTools.isSkill(args[1])) {
if (args[1].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[1])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
@ -66,43 +79,57 @@ public class MmoeditCommand implements CommandExecutor {
}
newValue = Integer.valueOf(args[2]);
skill = SkillTools.getSkillType(args[1]);
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
profile = new PlayerProfile(args[0], false); //Temporary Profile
profile = new PlayerProfile(args[0], false);
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
profile.modifySkill(skill, newValue);
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.modifySkill(skillType, newValue);
}
}
else {
profile.modifySkill(SkillTools.getSkillType(args[1]), newValue);
}
profile.save(); // Since this is a temporary profile, we save it here.
}
else {
profile = mcMMOPlayer.getProfile();
Player player = mcMMOPlayer.getPlayer();
profile.modifySkill(skill, newValue);
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
// Check if the player is online before we try to send them a message.
if (player.isOnline()) {
if (skill == SkillType.ALL) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(skill.toString()), newValue));
profile.modifySkill(skillType, newValue);
}
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
}
else {
profile.modifySkill(SkillTools.getSkillType(args[1]), newValue);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[1]), newValue));
}
}
if (skill == SkillType.ALL) {
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
}
return true;

View File

@ -18,7 +18,7 @@ public class SkillresetCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PlayerProfile profile;
SkillType skill;
boolean allSkills = false;
switch (args.length) {
case 1:
@ -26,48 +26,79 @@ public class SkillresetCommand implements CommandExecutor {
return false;
}
if (!SkillTools.isSkill(args[0])) {
if (args[0].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
skill = SkillTools.getSkillType(args[0]);
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
if (skill != SkillType.ALL && !Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
profile = Users.getPlayer((Player) sender).getProfile();
if (skill == SkillType.ALL) {
for (SkillType type : SkillType.values()) {
if (type != SkillType.ALL) {
if (Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + type.toString().toLowerCase())) {
profile.modifySkill(type, 0);
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(type.toString())));
}
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[0].toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
}
else {
profile.modifySkill(skill, 0);
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(skill.toString())));
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[0].toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
profile = Users.getPlayer((Player) sender).getProfile();
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.modifySkill(skillType, 0);
}
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
else {
profile.modifySkill(SkillTools.getSkillType(args[0]), 0);
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[0])));
}
return true;
case 2:
if (!SkillTools.isSkill(args[1])) {
if (args[1].equalsIgnoreCase("all")) {
allSkills = true;
}
else if (!SkillTools.isSkill(args[1])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
skill = SkillTools.getSkillType(args[1]);
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
if (skill != SkillType.ALL && !Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[1].toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
}
else {
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[1].toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
@ -81,45 +112,48 @@ public class SkillresetCommand implements CommandExecutor {
return true;
}
if (skill == SkillType.ALL) {
for (SkillType type : SkillType.values()) {
if (type != SkillType.ALL) {
if (Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others" + type.toString().toLowerCase())) {
profile.modifySkill(type, 0);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(type.toString()), args[0]));
}
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.modifySkill(skillType, 0);
}
}
else {
profile.modifySkill(skill, 0);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
profile.modifySkill(SkillTools.getSkillType(args[1]), 0);
}
profile.save(); // Since this is a temporary profile, we save it here.
}
else {
profile = mcMMOPlayer.getProfile();
Player player = mcMMOPlayer.getPlayer();
if (skill == SkillType.ALL) {
for (SkillType type : SkillType.values()) {
if (type != SkillType.ALL) {
if (Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others" + type.toString().toLowerCase())) {
profile.modifySkill(type, 0);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(type.toString()), args[0]));
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(type.toString())));
}
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
profile.modifySkill(skillType, 0);
}
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
else {
profile.modifySkill(skill, 0);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(skill.toString())));
profile.modifySkill(SkillTools.getSkillType(args[1]), 0);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[1])));
}
}
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
}
return true;
default:

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
@ -21,10 +22,9 @@ import com.gmail.nossr50.util.Users;
public class McrankCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//TODO: Better input handling, add usage string
// TODO: Better input handling, add usage string
if (!Config.getInstance().getUseMySQL()) {
Leaderboard.updateLeaderboards(); //Make sure the information is up to date
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
}
if (CommandHelper.noConsoleUsage(sender)) {
@ -37,6 +37,7 @@ public class McrankCommand implements CommandExecutor {
Player player = (Player) sender;
String playerName;
switch (args.length) {
case 0:
playerName = player.getName();
@ -48,7 +49,6 @@ public class McrankCommand implements CommandExecutor {
}
playerName = args[0];
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
if (mcmmoPlayer != null) {
@ -83,29 +83,27 @@ public class McrankCommand implements CommandExecutor {
public void flatfileDisplay(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skillType : SkillType.values()) {
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
if (skillType.isChildSkill()) {
continue;
}
if (skillType.equals(SkillType.ALL)) {
continue; // We want the overall ranking to be at the bottom
}
if (rankInts[1] == 0) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); //Don't bother showing ranking for players without skills
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])));
}
}
//Show the powerlevel ranking
int[] rankInts = Leaderboard.getPlayerRank(playerName, SkillType.ALL);
// Show the powerlevel ranking
int[] rankInts = Leaderboard.getPlayerRank(playerName);
if (rankInts[1] == 0) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", LocaleLoader.getString("Commands.mcrank.Unranked"))); //Don't bother showing ranking for players without skills
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", String.valueOf(rankInts[0])));
@ -113,6 +111,6 @@ public class McrankCommand implements CommandExecutor {
}
private void sqlDisplay(CommandSender sender, String playerName) {
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("mcMMO"), new McRankAsync(playerName, sender));
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McRankAsync(playerName, sender));
}
}

View File

@ -13,7 +13,6 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.Database;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Misc;
@ -125,10 +124,10 @@ public class MctopCommand implements CommandExecutor {
}
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
SkillType skillType = SkillType.getSkill(skill);
String[] info = Leaderboard.retrieveInfo(skillType, page);
if (skill.equalsIgnoreCase("ALL")) {
String[] info = Leaderboard.retrieveInfo(skill, page);
if (skill.equalsIgnoreCase("all")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {