chore: init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.example.essentialsplus.helpers;
|
||||
|
||||
import java.awt.Color;
|
||||
import net.runelite.api.gameval.SpriteID;
|
||||
|
||||
/** Attack style of an NPC attack, with the protection prayer that blocks it. */
|
||||
public enum CombatStyle
|
||||
{
|
||||
MELEE("Melee", new Color(0xE05050), SpriteID.Prayeron.PROTECT_FROM_MELEE),
|
||||
RANGED("Range", new Color(0x6BD66B), SpriteID.Prayeron.PROTECT_FROM_MISSILES),
|
||||
MAGIC("Mage", new Color(0x5AA9FF), SpriteID.Prayeron.PROTECT_FROM_MAGIC);
|
||||
|
||||
public final String label;
|
||||
public final Color color;
|
||||
public final int prayerSprite;
|
||||
|
||||
CombatStyle(String label, Color color, int prayerSprite)
|
||||
{
|
||||
this.label = label;
|
||||
this.color = color;
|
||||
this.prayerSprite = prayerSprite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Style from a cache name such as {@code HUNLLEF_ATTACK_RANGED} or {@code ZEBAK_MAGE_PROJANIM_INITIAL};
|
||||
* null when the name mentions no style or more than one.
|
||||
*/
|
||||
static CombatStyle fromName(String name)
|
||||
{
|
||||
CombatStyle found = null;
|
||||
for (String token : name.toUpperCase(java.util.Locale.ROOT).split("_"))
|
||||
{
|
||||
CombatStyle s = fromToken(token);
|
||||
if (s == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (found != null && found != s)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
found = s;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private static CombatStyle fromToken(String token)
|
||||
{
|
||||
if (token.startsWith("MELEE"))
|
||||
{
|
||||
return MELEE;
|
||||
}
|
||||
if (token.startsWith("RANGE") || token.startsWith("ARROW") || token.startsWith("DART") || token.startsWith("JAVELIN"))
|
||||
{
|
||||
return RANGED;
|
||||
}
|
||||
if (token.startsWith("MAGIC") || token.startsWith("MAGE") && !token.startsWith("MAGENTA"))
|
||||
{
|
||||
return MAGIC;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user