Class BindOption

java.lang.Object
dev.boze.api.option.Option<Bind>
dev.boze.api.option.BindOption
All Implemented Interfaces:
Serializable<Bind>

public class BindOption extends Option<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
  • Constructor Details

    • BindOption

      public BindOption(AddonModule owner, String name, String description)
      Creates a new bind option with no default binding
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
    • BindOption

      public BindOption(AddonModule owner, String name, String description, int bind, boolean isButton)
      Creates a new bind option with a specified default binding
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      bind - The key/button code to bind to
      isButton - Whether this is a mouse button (true) or keyboard key (false)
  • Method Details

    • getValue

      public Bind getValue()
      Description copied from class: Option
      Gets the current value of this option
      Specified by:
      getValue in class Option<Bind>
      Returns:
      The current value
    • setValue

      public Bind setValue(Bind newValue)
      Description copied from class: Option
      Sets the value of this option
      Specified by:
      setValue in class Option<Bind>
      Parameters:
      newValue - The new value to set
      Returns:
      The value that was set (may be different from newValue if validation was performed)
    • reset

      public Bind reset()
      Description copied from class: Option
      Resets this option to its default value
      Specified by:
      reset in class Option<Bind>
      Returns:
      The 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

      public void setBind(Bind bind)
      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 code
      isButton - 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

      public Bind fromJson(com.google.gson.JsonObject object)
      Parameters:
      object - The JsonObject to deserialize
      Returns:
      The deserialized object