Enum Class SpellContext
- All Implemented Interfaces:
Serializable,Comparable<SpellContext>,Constable
Enum representing different contexts in which a spell can be used. Each context has a unique identifier key
that is used inside these spell data files.
This allows for fine-grained control over where spells can appear or be used, such as in spell books, scrolls, wands, NPC trades, treasure loot, etc.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionWhether the spell can appear in spell books (crafted or found)Whether the spell can be cast via commandsWhether the spell can be cast from dispensersWhether the spell can be obtained through lootingWhether NPCs can cast this spellWhether the spell can appear in spell scrollsWhether the spell can appear in villager/NPC tradesWhether the spell can appear in treasure/loot chestsWhether the spell can be used/bound to wands -
Method Summary
Modifier and TypeMethodDescriptionCreates a map with all contexts set to the default value (true)static SpellContextGets a SpellContext from its string keystatic String[]Gets an array of all context keysgetKey()Gets the string key used in spell data filesstatic booleanisValidKey(String key) Checks if a given string is a valid context keytoString()static SpellContextReturns the enum constant of this class with the specified name.static SpellContext[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BOOK
Whether the spell can appear in spell books (crafted or found) -
SCROLL
Whether the spell can appear in spell scrolls -
WANDS
Whether the spell can be used/bound to wands -
NPCS
Whether NPCs can cast this spell -
DISPENSERS
Whether the spell can be cast from dispensers -
COMMANDS
Whether the spell can be cast via commands -
TREASURE
Whether the spell can appear in treasure/loot chests -
TRADES
Whether the spell can appear in villager/NPC trades -
LOOTING
Whether the spell can be obtained through looting
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
fromKey
Gets a SpellContext from its string key- Parameters:
key- The string key- Returns:
- The corresponding SpellContext, or null if not found
-
createDefaultMap
Creates a map with all contexts set to the default value (true)- Returns:
- A map of all context keys to true
-
getAllKeys
Gets an array of all context keys- Returns:
- Array of all context key strings
-
isValidKey
Checks if a given string is a valid context key- Parameters:
key- The key to check- Returns:
- true if the key corresponds to a valid context
-
getKey
Gets the string key used in spell data files -
toString
- Overrides:
toStringin classEnum<SpellContext>
-