From cf9117097d0955f023f1bd206ab1d42259018a95 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 25 Jan 2019 17:54:02 -0800 Subject: [PATCH] MMOInfo command makes better wiki links --- .../commands/skills/MmoInfoCommand.java | 8 +++++ .../datatypes/skills/SubSkillType.java | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java index 76630e4d8..06c2647ea 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java @@ -1,10 +1,12 @@ 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.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.TextComponentFactory; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -88,6 +90,12 @@ public class MmoInfoCommand implements TabExecutor { player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill")); } + for(SubSkillType subSkillType : SubSkillType.values()) + { + if(subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName)) + subSkillName = subSkillType.getWikiName(subSkillType.toString()); + } + //Send Player Wiki Link TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillName); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index c0706865a..7a07adfab 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -196,6 +196,37 @@ public enum SubSkillType { return endResult; } + public String getWikiName(String subSkillName) { + /* + * Find where to begin our substring (after the prefix) + */ + String endResult = ""; + int subStringIndex = getSubStringIndex(subSkillName); + + /* + * Split the string up so we can capitalize each part + */ + String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex); + if(subskillNameWithoutPrefix.contains("_")) + { + String splitStrings[] = subskillNameWithoutPrefix.split("_"); + + for(int i = 0; i < splitStrings.length; i++) + { + if(i+1 >= splitStrings.length) + endResult+=StringUtils.getCapitalized(splitStrings[i]); + else { + endResult += StringUtils.getCapitalized(splitStrings[i]); + endResult += "_"; + } + } + } else { + endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix); + } + + return endResult; + } + /** * Returns the name of the parent skill from the Locale file * @return The parent skill as defined in the locale