Package dev.boze.api.option
Class BindOption
- All Implemented Interfaces:
Serializable<Bind>
An option for keyboard/mouse bindings
BindOption provides a way to store and modify key or mouse button bindings
Can be bound to either a keyboard key or mouse button
-
Field Summary
Fields inherited from class dev.boze.api.option.Option
description, name, owner
-
Constructor Summary
ConstructorsConstructorDescriptionBindOption
(AddonModule owner, String name, String description) Creates a new bind option with no default bindingBindOption
(AddonModule owner, String name, String description, int bind, boolean isButton) Creates a new bind option with a specified default binding -
Method Summary
Modifier and TypeMethodDescriptionfromJson
(com.google.gson.JsonObject object) int
getBind()
Gets the current key/button codegetValue()
Gets the current value of this optionboolean
isButton()
Checks if this bind is for a mouse buttonreset()
Resets this option to its default valuevoid
setBind
(int bind, boolean isButton) Sets the binding using a key/button code and typevoid
Sets the binding using a Bind objectSets the value of this optioncom.google.gson.JsonObject
toJson()
-
Constructor Details
-
BindOption
Creates a new bind option with no default binding- Parameters:
owner
- The module that owns this optionname
- The name of this optiondescription
- The description of this option
-
BindOption
Creates a new bind option with a specified default binding- Parameters:
owner
- The module that owns this optionname
- The name of this optiondescription
- The description of this optionbind
- The key/button code to bind toisButton
- Whether this is a mouse button (true) or keyboard key (false)
-
-
Method Details
-
getValue
Description copied from class:Option
Gets the current value of this option -
setValue
Description copied from class:Option
Sets the value of this option -
reset
Description copied from class:Option
Resets this option to its default value -
getBind
public int getBind()Gets the current key/button code- Returns:
- The key/button code
-
isButton
public boolean isButton()Checks if this bind is for a mouse button- Returns:
- true if this is a mouse button bind, false if it's a keyboard key
-
setBind
Sets the binding using a Bind object- Parameters:
bind
- The new binding
-
setBind
public void setBind(int bind, boolean isButton) Sets the binding using a key/button code and type- Parameters:
bind
- The key/button codeisButton
- Whether this is a mouse button (true) or keyboard key (false)
-
toJson
public com.google.gson.JsonObject toJson()- Returns:
- The object as a JsonObject
-
fromJson
- Parameters:
object
- The JsonObject to deserialize- Returns:
- The deserialized object
-