Class Shortcuts

  • All Implemented Interfaces:
    java.lang.Iterable<Shortcut>

    public class Shortcuts
    extends java.lang.Object
    implements java.lang.Iterable<Shortcut>
    Manages a list of Shortcuts.
    • Constructor Detail

      • Shortcuts

        public Shortcuts​(@NotNull
                         @NotNull CommandQueue commandQueue,
                         @NotNull
                         @NotNull SpellsManager spellsManager)
        Creates a new instance.
        Parameters:
        commandQueue - the command queue for executing commands
        spellsManager - the instance to watch
    • Method Detail

      • clearShortcuts

        public void clearShortcuts()
        Clears all defined shortcuts.
      • setShortcut

        public void setShortcut​(int index,
                                @Nullable
                                @Nullable Shortcut shortcut)
        Sets a Shortcut.
        Parameters:
        index - the shortcut index
        shortcut - the shortcut to set or null to unset
      • unsetShortcut

        public void unsetShortcut​(int index)
        Unsets a Shortcut.
        Parameters:
        index - the shortcut index
      • setSpellShortcut

        public void setSpellShortcut​(int index,
                                     @NotNull
                                     @NotNull java.lang.String spellName,
                                     boolean cast)
        Sets a Shortcut to a spell.
        Parameters:
        index - the shortcut index
        spellName - the spell name to cast or invoke
        cast - whether the spell should be cast (true) or invoked (false)
      • setSpellShortcut

        public void setSpellShortcut​(int index,
                                     @NotNull
                                     @NotNull Spell spell,
                                     boolean cast)
        Sets a Shortcut to a spell.
        Parameters:
        index - the shortcut index
        spell - the spell to cast or invoke
        cast - whether the spell should be cast (true) or invoked (false)
      • setCommandShortcut

        public void setCommandShortcut​(int index,
                                       @NotNull
                                       @NotNull java.lang.String command)
        Sets a Shortcut to a command.
        Parameters:
        index - the shortcut index
        command - the command to execute
      • executeShortcut

        public void executeShortcut​(int index)
        Executes a shortcut. Does nothing if the shortcut is unset.
        Parameters:
        index - the shortcut index
      • addShortcutsListener

        public void addShortcutsListener​(@NotNull
                                         @NotNull ShortcutsListener listener)
        Parameters:
        listener - the listener to add
      • removeShortcutsListener

        public void removeShortcutsListener​(@NotNull
                                            @NotNull ShortcutsListener listener)
        Parameters:
        listener - the listener to remove
      • isModified

        public boolean isModified()
        Returns whether the shortcuts have been modified since creation or last call to resetModified().
        Returns:
        whether anything was modified
      • resetModified

        public void resetModified()
        Resets the modified state.
      • getFile

        @Nullable
        public @Nullable java.nio.file.Path getFile()
        Returns the backing file.
        Returns:
        the backing file or null if unknown
      • setFile

        public void setFile​(@Nullable
                            @Nullable java.nio.file.Path file)
        Sets the backing file.
        Parameters:
        file - the backing file or null if unknown
      • iterator

        @NotNull
        public @NotNull java.util.Iterator<Shortcut> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Shortcut>