Class Hotkeys

java.lang.Object
dev.adlin.vts4j.hotkey.Hotkeys

public class Hotkeys extends Object
Manages hotkey operations by loading available hotkeys, triggering executions, and providing a fast-access thread-safe local cache for hotkey information.
  • Constructor Details

    • Hotkeys

      public Hotkeys()
  • Method Details

    • refresh

      public @NonNull CompletableFuture<Void> refresh()
      Refreshes the internal cache by fetching the latest hotkeys from VTube Studio.

      This operation performs an asynchronous network request. Once completed, it purges the existing cache and populates it with the fresh hotkey state. Call this method if hotkeys were modified manually inside the VTube Studio.

      Returns:
      a CompletableFuture that completes when the local cache is fully updated
    • trigger

      public @NonNull CompletableFuture<Void> trigger(@NonNull Hotkey hotkey)
      Triggers the specified hotkey execution on the remote server.
      Parameters:
      hotkey - the hotkey instance to be triggered, cannot be null
      Returns:
      a CompletableFuture that completes when the server acknowledges execution
    • trigger

      public @NonNull CompletableFuture<Void> trigger(@NonNull String hotkeyName)
      Triggers the hotkey that matches the specified human-readable name.
      Parameters:
      hotkeyName - the unique name of the hotkey to trigger, cannot be null
      Returns:
      a CompletableFuture that completes when the server acknowledges execution
      Throws:
      IllegalArgumentException - if no hotkey matches the provided name in the local cache
    • getHotkeys

      public @NonNull Map<String,Hotkey> getHotkeys()
      Returns an unmodifiable thread-safe view of the currently cached hotkeys.
      Returns:
      an unmodifiable Map pairing hotkey IDs with their respective Hotkey data
    • findByName

      public @NonNull Optional<Hotkey> findByName(@NonNull String hotkeyName)
      Searches the local cache for a hotkey with the specified human-readable name.
      Parameters:
      hotkeyName - the name of the hotkey to look up
      Returns:
      an Optional containing the matching Hotkey, or Optional.empty() if not found