moapi
Class ModOptions

java.lang.Object
  extended by moapi.ModOptions

public class ModOptions
extends java.lang.Object

An abstract representation of a set of options for a single mod

Since:
0.1

Constructor Summary
ModOptions(java.lang.String name)
          Create a new set of options with no parent.
ModOptions(java.lang.String name, ModOptions p)
          Create a sub options menu for a mod package
ModOptions(java.lang.String id, java.lang.String name)
          Create a sub option menu with no parent
 
Method Summary
 ModOption addKeyBinding(java.lang.String name)
          Adds a character binding which is unique and will not class with any other character binding.
 ModOption addKeyOption(java.lang.String name)
          Adds a character binding which is unique and will not class with any other character binding.
 ModOption addMappedOption(java.lang.String name, int[] keys, java.lang.String[] values)
          Adds a mapped option
 ModOption addMappedOption(java.lang.String name, java.lang.Integer[] keys, java.lang.String[] values)
          Adds a mapped option
 ModOption addMultiOption(java.lang.String name, java.lang.String[] values)
          Add a multiple selector
 ModOption addOption(ModOption option)
          Add a manually created option to this menu
 ModOptions addOptionFormatter(ModOption option, DisplayStringFormatter formatter)
          Add a formatter to the set of formatters for the given option
 ModOptions addOptionFormatter(java.lang.String id, DisplayStringFormatter formatter)
          Add a formatter to the set of formatters for the given option
 ModOption addSlider(java.lang.String name)
          Add a numeric slider ranging from 0 to 100
 ModOption addSlider(java.lang.String name, int low, int high)
          Add a numeric slider with a range
 ModOptions addSubOptions(ModOptions m)
          Add a sub menu of options
 ModOption addTextOption(java.lang.String name)
          Add a text option with infinite max length
 ModOption addTextOption(java.lang.String name, int maxlen)
          Add a text option with infinite max length
 ModOption addTextOption(java.lang.String name, java.lang.String value)
          Add a text option with infinite max length with a default value
 ModOption addTextOption(java.lang.String name, java.lang.String value, int maxlen)
          Add a text option with infinite max length with a default value
 ModOption addTextOption(java.lang.String name, java.lang.String value, java.lang.Integer maxlen)
          Add a text option with infinite max length with a default value
 ModOption addToggle(java.lang.String name)
          Add a toggle/boolean selector
 boolean containsSubOptions(java.lang.String id)
          Check if this mod options has a given sub options menu
 GuiController getGuiController()
          Return the GUI controller for this menu
 java.lang.String getID()
          Return the ID for this menu
 int getMappedValue(java.lang.String id)
          Returns a single named mapped option's value
 ModOptions[] getMultiplayerSubOptions()
          Get all sets of sub-options for this set for multiplayer return Array of all sub options for this set
 java.lang.String getName()
          Return name for this menu
 ModOption getOption(java.lang.String id)
          Return a single named option
 ModOption[] getOptions()
          Return all option selectors for this menu
 java.lang.String getOptionValue(java.lang.String id)
          Returns a single named option's internal value
 ModOptions getParent()
          Get parent for this menu
 ModOptions[] getSingleplayerSubOptions()
          Get all sets of sub-options for this set for singleplayer return Array of all sub options for this set
 float getSliderValue(java.lang.String id)
          Returns a single named slider option's value
 ModOptions getSubOption(java.lang.String id)
          Get a named set of sub-options
 ModOptions[] getSubOptions()
          Get all sets of sub-options for this set return Array of all sub options for this set
 java.lang.String getTextValue(java.lang.String id)
          Get the value of a text input field
 boolean getToggleValue(java.lang.String id)
          Returns a single named toggle value
 void globalReset(boolean global)
          Sets all values global values to the parameter
 boolean isMultiplayerMod()
          Checks if this mod is available in multiplayer server menus
 boolean isSingleplayerMod()
          Checks if this mod is available in single player world menus
 ModOptions loadValues()
          Loads global values from disk into memory for this and all sub-menus
 ModOptions loadValues(java.lang.String worldName, boolean multi)
          Loads values from disk into memory for this and all sub-menus
 ModOptions save()
          Saves options to disk
 ModOptions save(java.lang.String name, boolean multiplayer)
          Save options to disk for a particular world
 ModOptions setMultiplayerMode(boolean multi)
          Set multiplayer value
 ModOptions setOptionStringFormat(ModOption option, DisplayStringFormatter formatter)
          Set an option's string format, will remove any other formatters
 ModOptions setOptionStringFormat(java.lang.String id, DisplayStringFormatter formatter)
          Set an option's string format, will remove any other formatters
 ModOptions setOptionValue(java.lang.String id, boolean value)
          Set a single named boolean options global value
 ModOptions setOptionValue(java.lang.String id, int value)
          Set a single slider or mapped multi option's global value
 ModOptions setOptionValue(java.lang.String id, java.lang.Integer value)
          Set a single slider or mapped multi option's global value
 ModOptions setOptionValue(java.lang.String id, java.lang.String value)
          Set a single multi option's global value
 ModOptions setParent(ModOptions o)
          Set the parent for this menu
 ModOptions setSingleplayerMode(boolean single)
          Set singleplayer value
 ModOptions setWideOption(ModOption option)
          Set a given option to wide
 ModOptions setWideOption(java.lang.String id)
          Set a named Option to wide
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModOptions

public ModOptions(java.lang.String name)
Create a new set of options with no parent. A mod package

Parameters:
name - Name of option list (menu name). Valid folder names only.
Throws:
java.util.regex.PatternSyntaxException - When an invalid folder name is specified

ModOptions

public ModOptions(java.lang.String name,
                  ModOptions p)
Create a sub options menu for a mod package

Parameters:
name - Name of this option list
p - Parent of this option list
Throws:
java.util.regex.PatternSyntaxException - When an invalid folder name is specified

ModOptions

public ModOptions(java.lang.String id,
                  java.lang.String name)
Create a sub option menu with no parent

Parameters:
id - ID of this option list
name - Name of this option set
Throws:
java.util.regex.PatternSyntaxException - When an invalid folder name is specified
Since:
0.8
Method Detail

addOption

public ModOption addOption(ModOption option)
Add a manually created option to this menu

Parameters:
option - Option selector to add
Returns:
Returns the option just added for further operations

addTextOption

public ModOption addTextOption(java.lang.String name)
Add a text option with infinite max length

Parameters:
name - Name of text input
Returns:
Returns the option just added for further operations
Since:
0.7

addTextOption

public ModOption addTextOption(java.lang.String name,
                               java.lang.String value)
Add a text option with infinite max length with a default value

Parameters:
name - Name of text input
value - Default value of input
Returns:
Returns the option just added for further operations
Since:
0.7

addTextOption

public ModOption addTextOption(java.lang.String name,
                               int maxlen)
Add a text option with infinite max length

Parameters:
name - Name of text input
maxlen - Maximum length the user can input. 0 or less is infinite
Returns:
Returns the option just added for further operations
Since:
0.7

addTextOption

public ModOption addTextOption(java.lang.String name,
                               java.lang.String value,
                               int maxlen)
Add a text option with infinite max length with a default value

Parameters:
name - Name of text input
value - Default value for input
maxlen - Maximum length the user can input. 0 or less is infinite
Returns:
Returns the option just added for further operations
Since:
0.7

addTextOption

public ModOption addTextOption(java.lang.String name,
                               java.lang.String value,
                               java.lang.Integer maxlen)
Add a text option with infinite max length with a default value

Parameters:
name - Name of text input
value - Default value for input
maxlen - Maximum length the user can input. 0 or less is infinite
Returns:
Returns the option just added for further operations
Since:
0.7

addKeyBinding

public ModOption addKeyBinding(java.lang.String name)
Adds a character binding which is unique and will not class with any other character binding. This default will not set a binding. If a clash occurs during loading of your player's saved preferences then the later of the two mods will have their bindings undone. Please use this method and avoid setting a default vaue

Parameters:
name - Name of character binding
Returns:
Returns the option just added for further operations
Since:
0.7

addKeyOption

public ModOption addKeyOption(java.lang.String name)
Adds a character binding which is unique and will not class with any other character binding. This default will not set a binding. If a clash occurs during loading of your player's saved preferences then the later of the two mods will have their bindings undone. Please use this method and avoid setting a default vaue

Parameters:
name - Name of character binding
Returns:
Returns the option just added for further operations
Since:
0.7

addMultiOption

public ModOption addMultiOption(java.lang.String name,
                                java.lang.String[] values)
Add a multiple selector

Parameters:
name - Name of selector
values - Set of values to display
Returns:
Returns the option just added for further operations

addMappedOption

public ModOption addMappedOption(java.lang.String name,
                                 java.lang.Integer[] keys,
                                 java.lang.String[] values)
                          throws java.lang.IndexOutOfBoundsException
Adds a mapped option

Parameters:
name - Name of selector
keys - Keys for selector
values - Values for selector
Returns:
Returns the option just added for further operations
Throws:
java.lang.IndexOutOfBoundsException

addMappedOption

public ModOption addMappedOption(java.lang.String name,
                                 int[] keys,
                                 java.lang.String[] values)
                          throws java.lang.IndexOutOfBoundsException
Adds a mapped option

Parameters:
name - Name of selector
keys - Keys for selector
values - Values for selector
Returns:
Returns the option just added for further operations
Throws:
java.lang.IndexOutOfBoundsException

addToggle

public ModOption addToggle(java.lang.String name)
Add a toggle/boolean selector

Parameters:
name - Name of boolean selector
Returns:
Returns the option just added for further operations

addSlider

public ModOption addSlider(java.lang.String name)
Add a numeric slider ranging from 0 to 100

Parameters:
name - Name of slider
Returns:
Returns the option just added for further operations

addSlider

public ModOption addSlider(java.lang.String name,
                           int low,
                           int high)
Add a numeric slider with a range

Parameters:
name - Name of slider
low - Lowest value of slider
high - Highest value of slider
Returns:
Returns the option just added for further operations

addSubOptions

public ModOptions addSubOptions(ModOptions m)
Add a sub menu of options

Parameters:
m - Set of sub-options
Returns:
The current object, for building

containsSubOptions

public boolean containsSubOptions(java.lang.String id)
Check if this mod options has a given sub options menu

Parameters:
id - of sub options
Returns:
true if sub options exist in this menu

getSubOptions

public ModOptions[] getSubOptions()
Get all sets of sub-options for this set return Array of all sub options for this set


getMultiplayerSubOptions

public ModOptions[] getMultiplayerSubOptions()
Get all sets of sub-options for this set for multiplayer return Array of all sub options for this set


getSingleplayerSubOptions

public ModOptions[] getSingleplayerSubOptions()
Get all sets of sub-options for this set for singleplayer return Array of all sub options for this set


getSubOption

public ModOptions getSubOption(java.lang.String id)
Get a named set of sub-options

Parameters:
id - ID of sub-options
Returns:
A sub-set of options

globalReset

public void globalReset(boolean global)
Sets all values global values to the parameter

Parameters:
global - New value

getOption

public ModOption getOption(java.lang.String id)
Return a single named option

Parameters:
id - ID of option selector
Returns:
Option selector

getOptionValue

public java.lang.String getOptionValue(java.lang.String id)
Returns a single named option's internal value

Returns:
Value of option, as a string

getTextValue

public java.lang.String getTextValue(java.lang.String id)
                              throws NoSuchOptionException
Get the value of a text input field

Parameters:
id - ID of option
Returns:
Value of a toggle option
Throws:
NoSuchOptionException - When no option is present
IncompatibleOptionTypeException
Since:
0.7

getToggleValue

public boolean getToggleValue(java.lang.String id)
                       throws NoSuchOptionException
Returns a single named toggle value

Parameters:
id - ID of the option
Returns:
Value of a toggle option
Throws:
NoSuchOptionException - When no option is present
IncompatibleOptionTypeException
Since:
0.6.1

getSliderValue

public float getSliderValue(java.lang.String id)
                     throws NoSuchOptionException
Returns a single named slider option's value

Parameters:
id - ID of the option
Returns:
Value of a slider option
Throws:
NoSuchOptionException - When no option is present
IncompatibleOptionTypeException
Since:
0.6.1

getMappedValue

public int getMappedValue(java.lang.String id)
                   throws NoSuchOptionException
Returns a single named mapped option's value

Parameters:
id - ID of the option
Returns:
Value of a mapped multi option
Throws:
NoSuchOptionException - When no option is present
IncompatibleOptionTypeException
Since:
0.6.1

setOptionValue

public ModOptions setOptionValue(java.lang.String id,
                                 boolean value)
Set a single named boolean options global value

Parameters:
id - ID of boolean toggle to change
value - New value of toggle
Returns:
This object for building
Throws:
IncompatibleOptionTypeException
NoSuchOptionException - When the option doesn't already exist

setOptionValue

public ModOptions setOptionValue(java.lang.String id,
                                 java.lang.Integer value)
Set a single slider or mapped multi option's global value

Parameters:
id - ID of slider option to change
value - New value of toggle
Returns:
This object for building
Throws:
IncompatibleOptionTypeException
NoSuchOptionException - When the option doesn't already exist
Since:
0.7

setOptionValue

public ModOptions setOptionValue(java.lang.String id,
                                 int value)
Set a single slider or mapped multi option's global value

Parameters:
id - ID of slider option to change
value - New value of toggle
Returns:
This object for building
Throws:
IncompatibleOptionTypeException
NoSuchOptionException - When the option doesn't already exist

setOptionValue

public ModOptions setOptionValue(java.lang.String id,
                                 java.lang.String value)
Set a single multi option's global value

Parameters:
id - ID of multi toggle to change
value - New value of toggle
Returns:
This object for building
Throws:
IncompatibleOptionTypeException
NoSuchOptionException - When the option doesn't already exist

getOptions

public ModOption[] getOptions()
Return all option selectors for this menu

Returns:
Array of all option selectors for this menu

setWideOption

public ModOptions setWideOption(java.lang.String id)
Set a named Option to wide

Parameters:
id - ID of option to set wide
Returns:
This object for building

setWideOption

public ModOptions setWideOption(ModOption option)
Set a given option to wide

Parameters:
option - Option object
Returns:
This object for building
Since:
0.7

setOptionStringFormat

public ModOptions setOptionStringFormat(java.lang.String id,
                                        DisplayStringFormatter formatter)
Set an option's string format, will remove any other formatters

Parameters:
id - ID of option
formatter - Formatter
Returns:
This object for building

addOptionFormatter

public ModOptions addOptionFormatter(java.lang.String id,
                                     DisplayStringFormatter formatter)
Add a formatter to the set of formatters for the given option

Parameters:
id - ID of option
formatter - Formatter to add
Returns:
This object for building
Since:
0.6.1

setOptionStringFormat

public ModOptions setOptionStringFormat(ModOption option,
                                        DisplayStringFormatter formatter)
Set an option's string format, will remove any other formatters

Parameters:
option - Option to add formatter to
formatter - Formatter
Returns:
This object for building
Since:
0.8

addOptionFormatter

public ModOptions addOptionFormatter(ModOption option,
                                     DisplayStringFormatter formatter)
Add a formatter to the set of formatters for the given option

Parameters:
option - Option to add formatter to
formatter - Formatter to add
Returns:
This object for building
Since:
0.8

getID

public java.lang.String getID()
Return the ID for this menu

Returns:
ID of this menu

getName

public java.lang.String getName()
Return name for this menu

Returns:
Name of this options menu

getParent

public ModOptions getParent()
Get parent for this menu

Returns:
Parent for this menu (or null if no parent)

setParent

public ModOptions setParent(ModOptions o)
Set the parent for this menu

Parameters:
o - Parent menu
Returns:
This object for building

getGuiController

public GuiController getGuiController()
Return the GUI controller for this menu

Returns:
Gui controller

setMultiplayerMode

public ModOptions setMultiplayerMode(boolean multi)
Set multiplayer value

Parameters:
multi - True if visible in multiplayer
Returns:
This object for building

setSingleplayerMode

public ModOptions setSingleplayerMode(boolean single)
Set singleplayer value

Parameters:
single - True if visible in singleplayer
Returns:
This object for building

isSingleplayerMod

public boolean isSingleplayerMod()
Checks if this mod is available in single player world menus

Returns:
True if in single player world menus

isMultiplayerMod

public boolean isMultiplayerMod()
Checks if this mod is available in multiplayer server menus

Returns:
True if in a multiplayer world menu

loadValues

public ModOptions loadValues()
Loads global values from disk into memory for this and all sub-menus

Returns:
This object for building

loadValues

public ModOptions loadValues(java.lang.String worldName,
                             boolean multi)
Loads values from disk into memory for this and all sub-menus

Parameters:
worldName - Name of world/ server to load for
multi - True if multiplayer word
Returns:
This object for building

save

public ModOptions save(java.lang.String name,
                       boolean multiplayer)
Save options to disk for a particular world

Parameters:
name - worldname
multiplayer - Save to a multiplayer file if true
Returns:
This object for building

save

public ModOptions save()
Saves options to disk

Returns:
This object for building