Record Class BedRule
java.lang.Object
java.lang.Record
fr.fidorial.world.environment.BedRule
public record BedRule(BedRule.AccessCondition sleepAllowed, BedRule.AccessCondition spawnAllowed, boolean destroysOnUse, boolean destroysOnLeave, Optional<Component> failureMessage)
extends Record
Controls whether beds can be used to sleep or set a spawn point in a dimension.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControls when a particular bed action is permitted. -
Constructor Summary
ConstructorsConstructorDescriptionBedRule(BedRule.AccessCondition sleepAllowed, BedRule.AccessCondition spawnAllowed, boolean destroysOnUse, boolean destroysOnLeave, Optional<Component> failureMessage) Creates an instance of aBedRulerecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic BedRuleAllows beds to only be used to sleep and set a spawn point when its nighttime.static BedRuleallowedAtNight(Component reason) Allows beds to only be used to sleep and set a spawn point when its nighttime.static BedRuleAllows beds to always be used to sleep and set a spawn point.static BedRuleAllows sleeping at night but never setting a spawn point; the bed is destroyed once the player leaves it (e.g.static BedRuledestroyedOnLeave(Component reason) Same asdestroyedOnLeave(), with a message shown when sleep is refused outside the allowed window.booleanReturns the value of thedestroysOnLeaverecord component.booleanReturns the value of thedestroysOnUserecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefailureMessagerecord component.final inthashCode()Returns a hash code value for this object.static BedRuleForbids beds from ever being used to sleep or set a spawn point; attempting to use one destroys it immediately.Returns the value of thesleepAllowedrecord component.Returns the value of thespawnAllowedrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BedRule
public BedRule(BedRule.AccessCondition sleepAllowed, BedRule.AccessCondition spawnAllowed, boolean destroysOnUse, boolean destroysOnLeave, Optional<Component> failureMessage) Creates an instance of aBedRulerecord class.- Parameters:
sleepAllowed- the value for thesleepAllowedrecord componentspawnAllowed- the value for thespawnAllowedrecord componentdestroysOnUse- the value for thedestroysOnUserecord componentdestroysOnLeave- the value for thedestroysOnLeaverecord componentfailureMessage- the value for thefailureMessagerecord component
-
-
Method Details
-
alwaysAllowed
Allows beds to always be used to sleep and set a spawn point.- Returns:
- bed rule
- Since:
- 0.1.0
-
allowedAtNight
Allows beds to only be used to sleep and set a spawn point when its nighttime.- Returns:
- bed rule
- Since:
- 0.1.0
-
allowedAtNight
-
neverAllowed
Forbids beds from ever being used to sleep or set a spawn point; attempting to use one destroys it immediately.- Returns:
- bed rule
- Since:
- 0.1.0
-
destroyedOnLeave
Allows sleeping at night but never setting a spawn point; the bed is destroyed once the player leaves it (e.g. straw beds).- Returns:
- bed rule
- Since:
- 0.1.0
-
destroyedOnLeave
Same asdestroyedOnLeave(), with a message shown when sleep is refused outside the allowed window.- Parameters:
reason- the reason shown to the player for why sleep is not allowed- Returns:
- bed 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. -
sleepAllowed
Returns the value of thesleepAllowedrecord component.- Returns:
- the value of the
sleepAllowedrecord component
-
spawnAllowed
Returns the value of thespawnAllowedrecord component.- Returns:
- the value of the
spawnAllowedrecord component
-
destroysOnUse
public boolean destroysOnUse()Returns the value of thedestroysOnUserecord component.- Returns:
- the value of the
destroysOnUserecord component
-
destroysOnLeave
public boolean destroysOnLeave()Returns the value of thedestroysOnLeaverecord component.- Returns:
- the value of the
destroysOnLeaverecord component
-
failureMessage
-