Expand list of skill abbreviations for the !Lvl command
This commit is contained in:
@@ -148,7 +148,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
/**
|
/**
|
||||||
* Checks if the chat message is a command.
|
* Checks if the chat message is a command.
|
||||||
*
|
*
|
||||||
* @param setMessage The chat message
|
* @param setMessage The chat message.
|
||||||
*/
|
*/
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onSetMessage(SetMessage setMessage)
|
public void onSetMessage(SetMessage setMessage)
|
||||||
@@ -172,7 +172,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
String message = setMessage.getValue();
|
String message = setMessage.getValue();
|
||||||
MessageNode messageNode = setMessage.getMessageNode();
|
MessageNode messageNode = setMessage.getMessageNode();
|
||||||
|
|
||||||
// clear runelite formatted messsage as the message node is
|
// clear RuneLite formatted message as the message node is
|
||||||
// being reused
|
// being reused
|
||||||
messageNode.setRuneLiteFormatMessage(null);
|
messageNode.setRuneLiteFormatMessage(null);
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up the item price and changes the original message to the
|
* Looks up the item price and changes the original message to the
|
||||||
* reponse.
|
* response.
|
||||||
*
|
*
|
||||||
* @param messageNode The chat message containing the command.
|
* @param messageNode The chat message containing the command.
|
||||||
* @param search The item given with the command.
|
* @param search The item given with the command.
|
||||||
@@ -273,13 +273,15 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks up the player skill and changes the original message to the
|
* Looks up the player skill and changes the original message to the
|
||||||
* reponse.
|
* response.
|
||||||
*
|
*
|
||||||
* @param setMessage The chat message containing the command.
|
* @param setMessage The chat message containing the command.
|
||||||
* @param search The item given with the command.
|
* @param search The item given with the command.
|
||||||
*/
|
*/
|
||||||
private void playerSkillLookup(ChatMessageType type, SetMessage setMessage, String search)
|
private void playerSkillLookup(ChatMessageType type, SetMessage setMessage, String search)
|
||||||
{
|
{
|
||||||
|
search = SkillAbbreviations.getFullName(search);
|
||||||
|
|
||||||
String player;
|
String player;
|
||||||
if (type.equals(ChatMessageType.PRIVATE_MESSAGE_SENT))
|
if (type.equals(ChatMessageType.PRIVATE_MESSAGE_SENT))
|
||||||
{
|
{
|
||||||
@@ -289,13 +291,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
player = sanitize(setMessage.getName());
|
player = sanitize(setMessage.getName());
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
search = SkillAbbreviations.valueOf(search.toUpperCase()).getName();
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException i)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
HiscoreSkill skill;
|
HiscoreSkill skill;
|
||||||
try
|
try
|
||||||
@@ -341,7 +336,7 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the names of the items in the list with the original input.
|
* Compares the names of the items in the list with the original input.
|
||||||
* returns the item if its name is equal to the original input or null
|
* Returns the item if its name is equal to the original input or null
|
||||||
* if it can't find the item.
|
* if it can't find the item.
|
||||||
*
|
*
|
||||||
* @param items List of items.
|
* @param items List of items.
|
||||||
@@ -361,11 +356,11 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans the playername string from ironman status icon if present and
|
* Cleans the ironman status icon from playername string if present and
|
||||||
* corrects spaces
|
* corrects spaces.
|
||||||
*
|
*
|
||||||
* @param lookup Playername to lookup
|
* @param lookup Playername to lookup.
|
||||||
* @return Cleaned playername
|
* @return Cleaned playername.
|
||||||
*/
|
*/
|
||||||
private static String sanitize(String lookup)
|
private static String sanitize(String lookup)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,29 +24,67 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.chatcommands;
|
package net.runelite.client.plugins.chatcommands;
|
||||||
|
|
||||||
enum SkillAbbreviations
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import net.runelite.api.Skill;
|
||||||
|
|
||||||
|
class SkillAbbreviations
|
||||||
{
|
{
|
||||||
ATT("Attack"),
|
private static final Map<String, String> MAP = new HashMap<>();
|
||||||
DEF("Defence"),
|
|
||||||
STR("Strength"),
|
|
||||||
HP("Hitpoints"),
|
|
||||||
RANGE("Ranged"),
|
|
||||||
WC("Woodcutting"),
|
|
||||||
FM("Firemaking"),
|
|
||||||
RUNECRAFTING("Runecraft"),
|
|
||||||
RC("Runecraft"),
|
|
||||||
CON("Construction"),
|
|
||||||
TOTAL("Overall");
|
|
||||||
|
|
||||||
private final String name;
|
static
|
||||||
|
|
||||||
SkillAbbreviations(String name)
|
|
||||||
{
|
{
|
||||||
this.name = name;
|
MAP.put("ATK", Skill.ATTACK.getName());
|
||||||
|
MAP.put("ATT", Skill.ATTACK.getName());
|
||||||
|
MAP.put("DEF", Skill.DEFENCE.getName());
|
||||||
|
MAP.put("STR", Skill.STRENGTH.getName());
|
||||||
|
MAP.put("HEALTH", Skill.HITPOINTS.getName());
|
||||||
|
MAP.put("HIT", Skill.HITPOINTS.getName());
|
||||||
|
MAP.put("HITPOINT", Skill.HITPOINTS.getName());
|
||||||
|
MAP.put("HP", Skill.HITPOINTS.getName());
|
||||||
|
MAP.put("RANGE", Skill.RANGED.getName());
|
||||||
|
MAP.put("RANGING", Skill.RANGED.getName());
|
||||||
|
MAP.put("RNG", Skill.RANGED.getName());
|
||||||
|
MAP.put("PRAY", Skill.PRAYER.getName());
|
||||||
|
MAP.put("MAG", Skill.MAGIC.getName());
|
||||||
|
MAP.put("MAGE", Skill.MAGIC.getName());
|
||||||
|
MAP.put("COOK", Skill.COOKING.getName());
|
||||||
|
MAP.put("WC", Skill.WOODCUTTING.getName());
|
||||||
|
MAP.put("WOOD", Skill.WOODCUTTING.getName());
|
||||||
|
MAP.put("WOODCUT", Skill.WOODCUTTING.getName());
|
||||||
|
MAP.put("FLETCH", Skill.FLETCHING.getName());
|
||||||
|
MAP.put("FISH", Skill.FISHING.getName());
|
||||||
|
MAP.put("FM", Skill.FIREMAKING.getName());
|
||||||
|
MAP.put("FIRE", Skill.FIREMAKING.getName());
|
||||||
|
MAP.put("CRAFT", Skill.CRAFTING.getName());
|
||||||
|
MAP.put("SMITH", Skill.SMITHING.getName());
|
||||||
|
MAP.put("MINE", Skill.MINING.getName());
|
||||||
|
MAP.put("HL", Skill.HERBLORE.getName());
|
||||||
|
MAP.put("HERB", Skill.HERBLORE.getName());
|
||||||
|
MAP.put("AGI", Skill.AGILITY.getName());
|
||||||
|
MAP.put("AGIL", Skill.AGILITY.getName());
|
||||||
|
MAP.put("THIEF", Skill.THIEVING.getName());
|
||||||
|
MAP.put("SLAY", Skill.SLAYER.getName());
|
||||||
|
MAP.put("FARM", Skill.FARMING.getName());
|
||||||
|
MAP.put("RC", Skill.RUNECRAFT.getName());
|
||||||
|
MAP.put("RUNE", Skill.RUNECRAFT.getName());
|
||||||
|
MAP.put("RUNECRAFTING", Skill.RUNECRAFT.getName());
|
||||||
|
MAP.put("HUNT", Skill.HUNTER.getName());
|
||||||
|
MAP.put("CON", Skill.CONSTRUCTION.getName());
|
||||||
|
MAP.put("CONSTRUCT", Skill.CONSTRUCTION.getName());
|
||||||
|
MAP.put("ALL", Skill.OVERALL.getName());
|
||||||
|
MAP.put("TOTAL", Skill.OVERALL.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
/**
|
||||||
|
* Takes a string representing the name of a skill, and if abbreviated,
|
||||||
|
* expands it into its full canonical name. Case-insensitive.
|
||||||
|
*
|
||||||
|
* @param abbrev Skill name that may be abbreviated.
|
||||||
|
* @return Full skill name if recognized, else the original string.
|
||||||
|
*/
|
||||||
|
static String getFullName(String abbrev)
|
||||||
{
|
{
|
||||||
return name;
|
return MAP.getOrDefault(abbrev.toUpperCase(), abbrev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user