mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Fix mmoinfo command
This commit is contained in:
		@@ -1,6 +1,5 @@
 | 
				
			|||||||
package com.gmail.nossr50.commands.skills;
 | 
					package com.gmail.nossr50.commands.skills;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 | 
					 | 
				
			||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
 | 
					import com.gmail.nossr50.datatypes.skills.SubSkillType;
 | 
				
			||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
 | 
					import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
 | 
				
			||||||
import com.gmail.nossr50.listeners.InteractionManager;
 | 
					import com.gmail.nossr50.listeners.InteractionManager;
 | 
				
			||||||
@@ -46,7 +45,7 @@ public class MmoInfoCommand implements TabExecutor {
 | 
				
			|||||||
                    player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader"));
 | 
					                    player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader"));
 | 
				
			||||||
                    player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Mystery"));
 | 
					                    player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Mystery"));
 | 
				
			||||||
                    return true;
 | 
					                    return true;
 | 
				
			||||||
                } else if (InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) {
 | 
					                } else if (InteractionManager.getAbstractByName(args[0]) != null || pluginRef.getSkillTools().isSubSkillNameExact(args[0])) {
 | 
				
			||||||
                    displayInfo(player, args[0]);
 | 
					                    displayInfo(player, args[0]);
 | 
				
			||||||
                    return true;
 | 
					                    return true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -64,7 +63,7 @@ public class MmoInfoCommand implements TabExecutor {
 | 
				
			|||||||
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
 | 
					    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
 | 
				
			||||||
        switch (args.length) {
 | 
					        switch (args.length) {
 | 
				
			||||||
            case 1:
 | 
					            case 1:
 | 
				
			||||||
                return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList<>(PrimarySkillType.SUBSKILL_NAMES.size()));
 | 
					                return StringUtil.copyPartialMatches(args[0], pluginRef.getSkillTools().EXACT_SUBSKILL_NAMES, new ArrayList<>(pluginRef.getSkillTools().EXACT_SUBSKILL_NAMES.size()));
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                return ImmutableList.of();
 | 
					                return ImmutableList.of();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@ import com.gmail.nossr50.mcMMO;
 | 
				
			|||||||
import com.gmail.nossr50.util.Misc;
 | 
					import com.gmail.nossr50.util.Misc;
 | 
				
			||||||
import com.gmail.nossr50.util.StringUtils;
 | 
					import com.gmail.nossr50.util.StringUtils;
 | 
				
			||||||
import com.google.common.collect.ImmutableList;
 | 
					import com.google.common.collect.ImmutableList;
 | 
				
			||||||
 | 
					import com.google.common.collect.ImmutableSet;
 | 
				
			||||||
import org.bukkit.Bukkit;
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.Material;
 | 
					import org.bukkit.Material;
 | 
				
			||||||
@@ -38,8 +39,10 @@ public class SkillTools {
 | 
				
			|||||||
    private final mcMMO pluginRef;
 | 
					    private final mcMMO pluginRef;
 | 
				
			||||||
    private final int ENCHANT_SPEED_VAR;
 | 
					    private final int ENCHANT_SPEED_VAR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //TODO: Should these be hash sets instead of lists?
 | 
				
			||||||
    public final List<String> LOCALIZED_SKILL_NAMES;
 | 
					    public final List<String> LOCALIZED_SKILL_NAMES;
 | 
				
			||||||
    public final List<String> SUBSKILL_NAMES;
 | 
					    public final List<String> FORMATTED_SUBSKILL_NAMES;
 | 
				
			||||||
 | 
					    public final Set<String> EXACT_SUBSKILL_NAMES;
 | 
				
			||||||
    public final List<PrimarySkillType> CHILD_SKILLS;
 | 
					    public final List<PrimarySkillType> CHILD_SKILLS;
 | 
				
			||||||
    public final List<PrimarySkillType> NON_CHILD_SKILLS;
 | 
					    public final List<PrimarySkillType> NON_CHILD_SKILLS;
 | 
				
			||||||
    public final List<PrimarySkillType> COMBAT_SKILLS;
 | 
					    public final List<PrimarySkillType> COMBAT_SKILLS;
 | 
				
			||||||
@@ -63,7 +66,6 @@ public class SkillTools {
 | 
				
			|||||||
        initPrimaryChildMap();
 | 
					        initPrimaryChildMap();
 | 
				
			||||||
        initPrimaryToolMap();
 | 
					        initPrimaryToolMap();
 | 
				
			||||||
        initSuperAbilityParentRelationships();
 | 
					        initSuperAbilityParentRelationships();
 | 
				
			||||||
        buildSubSkillNameList();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<PrimarySkillType> childSkills = new ArrayList<>();
 | 
					        List<PrimarySkillType> childSkills = new ArrayList<>();
 | 
				
			||||||
        List<PrimarySkillType> nonChildSkills = new ArrayList<>();
 | 
					        List<PrimarySkillType> nonChildSkills = new ArrayList<>();
 | 
				
			||||||
@@ -81,7 +83,8 @@ public class SkillTools {
 | 
				
			|||||||
        MISC_SKILLS = ImmutableList.of(PrimarySkillType.ACROBATICS, PrimarySkillType.ALCHEMY, PrimarySkillType.REPAIR, PrimarySkillType.SALVAGE, PrimarySkillType.SMELTING);
 | 
					        MISC_SKILLS = ImmutableList.of(PrimarySkillType.ACROBATICS, PrimarySkillType.ALCHEMY, PrimarySkillType.REPAIR, PrimarySkillType.SALVAGE, PrimarySkillType.SMELTING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        LOCALIZED_SKILL_NAMES = ImmutableList.copyOf(buildLocalizedPrimarySkillNames());
 | 
					        LOCALIZED_SKILL_NAMES = ImmutableList.copyOf(buildLocalizedPrimarySkillNames());
 | 
				
			||||||
        SUBSKILL_NAMES = ImmutableList.copyOf(buildSubSkillNameList());
 | 
					        FORMATTED_SUBSKILL_NAMES = ImmutableList.copyOf(buildFormattedSubSkillNameList());
 | 
				
			||||||
 | 
					        EXACT_SUBSKILL_NAMES = ImmutableSet.copyOf(buildExactSubSkillNameList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CHILD_SKILLS = ImmutableList.copyOf(childSkills);
 | 
					        CHILD_SKILLS = ImmutableList.copyOf(childSkills);
 | 
				
			||||||
        NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
 | 
					        NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
 | 
				
			||||||
@@ -100,6 +103,15 @@ public class SkillTools {
 | 
				
			|||||||
        primarySkillToolMap.put(PrimarySkillType.MINING, ToolType.PICKAXE);
 | 
					        primarySkillToolMap.put(PrimarySkillType.MINING, ToolType.PICKAXE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * See if a skill enum exists
 | 
				
			||||||
 | 
					     * @param subSkillName
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public boolean isSubSkillNameExact(String subSkillName) {
 | 
				
			||||||
 | 
					        return EXACT_SUBSKILL_NAMES.contains(subSkillName);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void initSuperAbilityParentRelationships() {
 | 
					    private void initSuperAbilityParentRelationships() {
 | 
				
			||||||
        superAbilityParentRelationshipMap = new HashMap<>();
 | 
					        superAbilityParentRelationshipMap = new HashMap<>();
 | 
				
			||||||
        mainActivatedAbilityChildMap = new HashMap<>();
 | 
					        mainActivatedAbilityChildMap = new HashMap<>();
 | 
				
			||||||
@@ -183,7 +195,7 @@ public class SkillTools {
 | 
				
			|||||||
     * Used in tab completion mostly
 | 
					     * Used in tab completion mostly
 | 
				
			||||||
     * @return a list of formatted sub skill names
 | 
					     * @return a list of formatted sub skill names
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private ArrayList<String> buildSubSkillNameList() {
 | 
					    private ArrayList<String> buildFormattedSubSkillNameList() {
 | 
				
			||||||
        ArrayList<String> subSkillNameList = new ArrayList<>();
 | 
					        ArrayList<String> subSkillNameList = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for(SubSkillType subSkillType : SubSkillType.values()) {
 | 
					        for(SubSkillType subSkillType : SubSkillType.values()) {
 | 
				
			||||||
@@ -193,6 +205,16 @@ public class SkillTools {
 | 
				
			|||||||
        return subSkillNameList;
 | 
					        return subSkillNameList;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private HashSet<String> buildExactSubSkillNameList() {
 | 
				
			||||||
 | 
					        HashSet<String> subSkillNameExactSet = new HashSet<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for(SubSkillType subSkillType : SubSkillType.values()) {
 | 
				
			||||||
 | 
					            subSkillNameExactSet.add(subSkillType.toString());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return subSkillNameExactSet;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Builds a map containing the relationships of SubSkillTypes to PrimarySkillTypes
 | 
					     * Builds a map containing the relationships of SubSkillTypes to PrimarySkillTypes
 | 
				
			||||||
     * Disgusting Hacky Fix until the new skill system is in place
 | 
					     * Disgusting Hacky Fix until the new skill system is in place
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user