Package dev.adlin.vts4j.hotkey
Class Hotkeys
java.lang.Object
dev.adlin.vts4j.hotkey.Hotkeys
Manages hotkey operations by loading available hotkeys, triggering executions,
and providing a fast-access thread-safe local cache for hotkey information.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindByName(@NonNull String hotkeyName) Searches the local cache for a hotkey with the specified human-readable name.Returns an unmodifiable thread-safe view of the currently cached hotkeys.@NonNull CompletableFuture<Void> refresh()Refreshes the internal cache by fetching the latest hotkeys from VTube Studio.@NonNull CompletableFuture<Void> Triggers the specified hotkey execution on the remote server.@NonNull CompletableFuture<Void> Triggers the hotkey that matches the specified human-readable name.
-
Constructor Details
-
Hotkeys
public Hotkeys()
-
-
Method Details
-
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
CompletableFuturethat completes when the local cache is fully updated
-
trigger
Triggers the specified hotkey execution on the remote server.- Parameters:
hotkey- the hotkey instance to be triggered, cannot be null- Returns:
- a
CompletableFuturethat completes when the server acknowledges execution
-
trigger
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
CompletableFuturethat completes when the server acknowledges execution - Throws:
IllegalArgumentException- if no hotkey matches the provided name in the local cache
-
getHotkeys
Returns an unmodifiable thread-safe view of the currently cached hotkeys. -
findByName
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
Optionalcontaining the matchingHotkey, orOptional.empty()if not found
-