mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-03 18:43:43 +01:00 
			
		
		
		
	Make /mctop [skillname] work for localized skillnames
This commit is contained in:
		@@ -37,6 +37,9 @@ public class MctopCommand implements CommandExecutor {
 | 
				
			|||||||
                else if (Skills.isSkill(args[0])) {
 | 
					                else if (Skills.isSkill(args[0])) {
 | 
				
			||||||
                    flatfileDisplay(1, args[0].toUpperCase(), sender);
 | 
					                    flatfileDisplay(1, args[0].toUpperCase(), sender);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                else if (Skills.isLocalizedSkill(args[0])) {
 | 
				
			||||||
 | 
					                    flatfileDisplay(1, Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                else {
 | 
					                else {
 | 
				
			||||||
                    sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
					                    sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -44,13 +47,16 @@ public class MctopCommand implements CommandExecutor {
 | 
				
			|||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            case 2:
 | 
					            case 2:
 | 
				
			||||||
                if (!Skills.isSkill(args[0])) {
 | 
					 | 
				
			||||||
                    sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
					 | 
				
			||||||
                    return true;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (Misc.isInt(args[1])) {
 | 
					                if (Misc.isInt(args[1])) {
 | 
				
			||||||
                    flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
 | 
					                    if (Skills.isSkill(args[0])) {
 | 
				
			||||||
 | 
					                        flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else if (Skills.isLocalizedSkill(args[0])) {
 | 
				
			||||||
 | 
					                        flatfileDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else {
 | 
				
			||||||
 | 
					                        sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else {
 | 
					                else {
 | 
				
			||||||
                    sender.sendMessage(usage);
 | 
					                    sender.sendMessage(usage);
 | 
				
			||||||
@@ -78,6 +84,9 @@ public class MctopCommand implements CommandExecutor {
 | 
				
			|||||||
            else if (Skills.isSkill(args[0])) {
 | 
					            else if (Skills.isSkill(args[0])) {
 | 
				
			||||||
                sqlDisplay(1, args[0].toLowerCase(), sender);
 | 
					                sqlDisplay(1, args[0].toLowerCase(), sender);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            else if (Skills.isLocalizedSkill(args[0])) {
 | 
				
			||||||
 | 
					                sqlDisplay(1, Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
					                sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -85,13 +94,16 @@ public class MctopCommand implements CommandExecutor {
 | 
				
			|||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case 2:
 | 
					        case 2:
 | 
				
			||||||
            if (!Skills.isSkill(args[0])) {
 | 
					 | 
				
			||||||
                sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
					 | 
				
			||||||
                return true;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (Misc.isInt(args[1])) {
 | 
					            if (Misc.isInt(args[1])) {
 | 
				
			||||||
                sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
 | 
					                if (Skills.isSkill(args[0])) {
 | 
				
			||||||
 | 
					                    sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else if (Skills.isLocalizedSkill(args[0])) {
 | 
				
			||||||
 | 
					                    sqlDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else {
 | 
				
			||||||
 | 
					                    sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else {
 | 
					            else {
 | 
				
			||||||
                sender.sendMessage(usage);
 | 
					                sender.sendMessage(usage);
 | 
				
			||||||
@@ -110,7 +122,7 @@ public class MctopCommand implements CommandExecutor {
 | 
				
			|||||||
    	SkillType skillType = SkillType.getSkill(skill);
 | 
					    	SkillType skillType = SkillType.getSkill(skill);
 | 
				
			||||||
        String[] info = Leaderboard.retrieveInfo(skillType, page);
 | 
					        String[] info = Leaderboard.retrieveInfo(skillType, page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (skill.equals("ALL")) {
 | 
					        if (skill.equalsIgnoreCase("ALL")) {
 | 
				
			||||||
            sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
 | 
					            sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,9 +13,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
 | 
				
			|||||||
import com.gmail.nossr50.config.Config;
 | 
					import com.gmail.nossr50.config.Config;
 | 
				
			||||||
import com.gmail.nossr50.config.SpoutConfig;
 | 
					import com.gmail.nossr50.config.SpoutConfig;
 | 
				
			||||||
import com.gmail.nossr50.datatypes.AbilityType;
 | 
					import com.gmail.nossr50.datatypes.AbilityType;
 | 
				
			||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
 | 
					 | 
				
			||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
 | 
					import com.gmail.nossr50.datatypes.PlayerProfile;
 | 
				
			||||||
import com.gmail.nossr50.datatypes.PlayerStat;
 | 
					 | 
				
			||||||
import com.gmail.nossr50.datatypes.SkillType;
 | 
					import com.gmail.nossr50.datatypes.SkillType;
 | 
				
			||||||
import com.gmail.nossr50.datatypes.ToolType;
 | 
					import com.gmail.nossr50.datatypes.ToolType;
 | 
				
			||||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
 | 
					import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
 | 
				
			||||||
@@ -296,6 +294,26 @@ public class Skills {
 | 
				
			|||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static boolean isLocalizedSkill(String skillName) {
 | 
				
			||||||
 | 
					        for (SkillType skill : SkillType.values()) {
 | 
				
			||||||
 | 
					            if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static String translateLocalizedSkill(String skillName) {
 | 
				
			||||||
 | 
					        for (SkillType skill : SkillType.values()) {
 | 
				
			||||||
 | 
					            if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) {
 | 
				
			||||||
 | 
					                return skill.toString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Check if the player has any combat skill permissions.
 | 
					     * Check if the player has any combat skill permissions.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user