Record Class GameRuleDefinition
java.lang.Object
java.lang.Record
fr.fidorial.gamerule.GameRuleDefinition
- Record Components:
key- the registry key, for instanceminecraft:keep_inventorytype- the kind of value the rule holdsdefaultValue- the vanilla default (0/1for boolean rules)minValue- the smallest accepted value, inclusivemaxValue- the largest accepted value, inclusiveimplemented- whether the server wires this rule into its gameplay; rules that are not implemented are still stored and saved, but have no built-in effect and are not offered by/gamerule
public record GameRuleDefinition(TypedKey<GameRule> key, GameRuleType type, int defaultValue, int minValue, int maxValue, boolean implemented)
extends Record
Describes one entry of the
minecraft:game_rule registry: its type, its vanilla default and
the range of values it accepts.- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionGameRuleDefinition(TypedKey<GameRule> key, GameRuleType type, int defaultValue, int minValue, int maxValue, boolean implemented) Creates an instance of aGameRuleDefinitionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(int value) intReturns the value of thedefaultValuerecord component.final booleanIndicates whether some other object is "equal to" this one.format(int value) Formats a raw value the way the vanilla command prints it.final inthashCode()Returns a hash code value for this object.id()booleanReturns the value of theimplementedrecord component.booleankey()Returns the value of thekeyrecord component.intmaxValue()Returns the value of themaxValuerecord component.intminValue()Returns the value of theminValuerecord component.static GameRuleDefinitionCreates a boolean rule definition.static GameRuleDefinitionofInteger(TypedKey<GameRule> key, int defaultValue, int minValue, int maxValue, boolean implemented) Creates an integer rule definition.Parses a value typed by a player or read from a legacy save.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
GameRuleDefinition
public GameRuleDefinition(TypedKey<GameRule> key, GameRuleType type, int defaultValue, int minValue, int maxValue, boolean implemented) Creates an instance of aGameRuleDefinitionrecord class.- Parameters:
key- the value for thekeyrecord componenttype- the value for thetyperecord componentdefaultValue- the value for thedefaultValuerecord componentminValue- the value for theminValuerecord componentmaxValue- the value for themaxValuerecord componentimplemented- the value for theimplementedrecord component
-
-
Method Details
-
ofBoolean
public static GameRuleDefinition ofBoolean(TypedKey<GameRule> key, boolean defaultValue, boolean implemented) Creates a boolean rule definition.- Parameters:
key- the registry keydefaultValue- the vanilla defaultimplemented- whether the server wires the rule into its gameplay- Returns:
- the definition
- Since:
- 0.1.0
-
ofInteger
public static GameRuleDefinition ofInteger(TypedKey<GameRule> key, int defaultValue, int minValue, int maxValue, boolean implemented) Creates an integer rule definition.- Parameters:
key- the registry keydefaultValue- the vanilla defaultminValue- the smallest accepted value, inclusivemaxValue- the largest accepted value, inclusiveimplemented- whether the server wires the rule into its gameplay- Returns:
- the definition
- Since:
- 0.1.0
-
id
-
isBoolean
-
accepts
- Parameters:
value- a raw value- Returns:
trueifvaluelies withinminValue()andmaxValue()- Since:
- 0.1.0
-
format
-
parse
Parses a value typed by a player or read from a legacy save.Boolean rules accept
true/false(any case); integer rules accept a decimal number within range.- Parameters:
text- the text to parse- Returns:
- the raw value, or
nullif the text is not valid for this rule - Since:
- 0.1.0
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
key
-
type
-
defaultValue
public int defaultValue()Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-
minValue
-
maxValue
-
implemented
public boolean implemented()Returns the value of theimplementedrecord component.- Returns:
- the value of the
implementedrecord component
-