Package net.glowstone.util
Class GameRuleManager
java.lang.Object
net.glowstone.util.GameRuleManager
- All Implemented Interfaces:
DynamicallyTypedMap<String>
Container for the game rule map for worlds.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getBoolean
(@NonNls String rule) Gets the game rule value as a boolean.int
Retrieves an entry as anint
.int
Gets the game rule value as an integer.String[]
getKeys()
Gets all of the game rules defined.Gets the game rule value as a string.boolean
isGameRule
(@NonNls String rule) Gets whether or not the supplied rule is defined.boolean
Sets the value of a game rule.
-
Constructor Details
-
GameRuleManager
public GameRuleManager()Creates an instance with the vanilla game rules.
-
-
Method Details
-
getKeys
Gets all of the game rules defined.- Returns:
- the game rules defined, may be empty
-
setValue
Sets the value of a game rule.
The actual object value is never stored, only the string value.
The helper methods provided in this class may be used to retrieve the value, such as
getBoolean(String)
.- Parameters:
rule
- the rule to set, cannot be nullvalue
- the value to set, cannot be null or be represented as null- Returns:
- true if set, false otherwise
-
isGameRule
Gets whether or not the supplied rule is defined.- Parameters:
rule
- the rule to lookup- Returns:
- true if defined, false otherwise
-
getString
Gets the game rule value as a string. If the value does not exist, then this will return null.- Specified by:
getString
in interfaceDynamicallyTypedMap<String>
- Parameters:
rule
- the rule to look up- Returns:
- the string value, or null if not defined
-
getBoolean
Gets the game rule value as a boolean. If the value cannot be parsed or does not exist, then this will return false.- Specified by:
getBoolean
in interfaceDynamicallyTypedMap<String>
- Parameters:
rule
- the rule to look up- Returns:
- the boolean value, or false
-
getInt
Description copied from interface:DynamicallyTypedMap
Retrieves an entry as anint
.- Specified by:
getInt
in interfaceDynamicallyTypedMap<String>
- Parameters:
key
- the key to look up- Returns:
- the value as an int
-
getInt
Gets the game rule value as an integer. If the value cannot be parsed or does not exist then the default will be returned.- Parameters:
rule
- the rule to look updef
- the default value- Returns:
- the integer value of the rule, or the default
-