Class Magic


  • public class Magic
    extends java.lang.Object
    A class that provides methods for magic-related actions.
    • Constructor Summary

      Constructors 
      Constructor Description
      Magic()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canCast​(Spell spell)
      Determines if a spell can be cast.
      static boolean castSpell​(Spell spell)
      Executes the given spell by creating a CastSpellEvent and returns a boolean indicating whether the spell was successfully cast.
      static boolean castSpell​(Spell spell, java.lang.String action)
      Casts the specified spell with the given action.
      static boolean castSpellOn​(Spell spell, Entity entity)
      Casts the specified spell on the given entity.
      static boolean castSpellOn​(Spell spell, Item item)
      Casts a specified spell on a given item.
      static boolean forceCastSpell​(Spell spell)
      Forces the casting of a specified spell, skipping the runes check.
      static boolean forceCastSpell​(Spell spell, java.lang.String action)
      Forces the casting of a specified spell with the given action, skipping the runes check.
      static Spell getSelectedSpell()
      Returns the selected spell based on the corresponding spell interface.
      static java.lang.String getSelectedSpellName()
      Retrieves the name of the selected spell.
      static SpellBook getSpellBook()
      Retrieves the active spell book.
      static Spell getSpellFromName​(java.lang.String spellName)
      Retrieves a spell based on its name.
      static int getWidgetOffset()  
      static boolean isAutoCasting()
      Returns whether the player is currently auto-casting a spell.
      static boolean isDefensiveAutoCasting()
      Checks if defensive auto-casting mode is enabled.
      static boolean isSpellSelected()
      Checks if a spell is currently selected by the player.
      static void setWidgetOffset​(int widgetOffset)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Magic

        public Magic()
    • Method Detail

      • getWidgetOffset

        public static int getWidgetOffset()
      • setWidgetOffset

        public static void setWidgetOffset​(int widgetOffset)
      • isSpellSelected

        public static boolean isSpellSelected()
        Checks if a spell is currently selected by the player.
        Returns:
        true if a spell is selected, false otherwise.
      • getSelectedSpellName

        public static java.lang.String getSelectedSpellName()
        Retrieves the name of the selected spell.
        Returns:
        the name of the selected spell, or an empty string if the name is null
      • getSelectedSpell

        public static Spell getSelectedSpell()
        Returns the selected spell based on the corresponding spell interface.
        Returns:
        the selected spell, or null if no spell is selected
      • canCast

        public static boolean canCast​(Spell spell)
        Determines if a spell can be cast.
        Parameters:
        spell - the spell to check
        Returns:
        true if the spell can be cast, false otherwise
      • castSpell

        public static boolean castSpell​(Spell spell)
        Executes the given spell by creating a CastSpellEvent and returns a boolean indicating whether the spell was successfully cast.
        Parameters:
        spell - the spell to be cast
        Returns:
        true if the spell was cast successfully, false otherwise
      • forceCastSpell

        public static boolean forceCastSpell​(Spell spell)
        Forces the casting of a specified spell, skipping the runes check.
        Parameters:
        spell - the spell to be cast
        Returns:
        true if the spell was successfully cast; false otherwise
      • castSpell

        public static boolean castSpell​(Spell spell,
                                        java.lang.String action)
        Casts the specified spell with the given action.
        Parameters:
        spell - the spell to be casted
        action - the action to be performed
        Returns:
        true if the spell was successfully casted, false otherwise
      • forceCastSpell

        public static boolean forceCastSpell​(Spell spell,
                                             java.lang.String action)
        Forces the casting of a specified spell with the given action, skipping the runes check.
        Parameters:
        spell - the spell to be casted
        action - the action to be performed
        Returns:
        true if the spell was successfully casted, false otherwise
      • castSpellOn

        public static boolean castSpellOn​(Spell spell,
                                          Entity entity)
        Casts the specified spell on the given entity.
        Parameters:
        spell - the spell to be casted
        entity - the entity targeted by the spell
        Returns:
        true if the spell was successfully casted, false otherwise
      • castSpellOn

        public static boolean castSpellOn​(Spell spell,
                                          Item item)
        Casts a specified spell on a given item.
        Parameters:
        spell - the spell to be cast
        item - the item to cast the spell on
        Returns:
        true if the spell was successfully cast on the item, false otherwise
      • isAutoCasting

        public static boolean isAutoCasting()
        Returns whether the player is currently auto-casting a spell.
        Returns:
        true if the player is auto-casting, false otherwise.
      • isDefensiveAutoCasting

        public static boolean isDefensiveAutoCasting()
        Checks if defensive auto-casting mode is enabled.
        Returns:
        true if defensive auto-casting mode is enabled, false otherwise.
      • getSpellFromName

        public static Spell getSpellFromName​(java.lang.String spellName)
        Retrieves a spell based on its name.
        Parameters:
        spellName - the name of the spell to retrieve
        Returns:
        the spell object corresponding to the given name, or null if not found
      • getSpellBook

        public static SpellBook getSpellBook()
        Retrieves the active spell book.
        Returns:
        the active spell book, or null if not found