Record Class ResearchTrigger
java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.api.research.ResearchTrigger
- Record Components:
events
- The events that should trigger the researchcondition
- The condition that should be met for the research to startresearch
- The research that can be started
public record ResearchTrigger(Set<InteractionEvent> events, InteractionCondition condition, RewardPool<ConditionalResearch> research)
extends Record
A ResearchTrigger is a datapackable concept that dictates when a player should receive/start
a
This is done by passing all interaction events through all the registered triggers to check if the event is relevant to the trigger, and if the condition is met, then the trigger will start the desired number of research for the player.
To create a ResearchTrigger, you need to register it to the
Research
.
This is done by passing all interaction events through all the registered triggers to check if the event is relevant to the trigger, and if the condition is met, then the trigger will start the desired number of research for the player.
To create a ResearchTrigger, you need to register it to the
PixelmonRegistry.RESEARCH_TRIGGER_REGISTRY
but this should be done through a datapack.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for a ResearchTrigger -
Field Summary
-
Constructor Summary
ConstructorDescriptionResearchTrigger
(List<InteractionEvent> events, InteractionCondition condition, RewardPool<ConditionalResearch> research) An ease of use constructor for creating a ResearchTrigger that converts the List to a SetResearchTrigger
(Set<InteractionEvent> events, InteractionCondition condition, RewardPool<ConditionalResearch> research) Constructor that creates an immutable copy of the set of events. -
Method Summary
Modifier and TypeMethodDescriptionstatic ResearchTrigger.Builder
builder()
Creates a new builder for a ResearchTriggerReturns the value of thecondition
record component.final boolean
Indicates whether some other object is "equal to" this one.events()
Returns the value of theevents
record component.void
handleEvent
(InteractionEvent event, InteractionContext context) The logic to check that the event fired is relevant to this trigger, then to check that the condition is met, and then to start the desired number of research for the player in the context.final int
hashCode()
Returns a hash code value for this object.research()
Returns the value of theresearch
record component.void
saveToFile
(File file) Saves theResearchTrigger
to a file using thetoJson()
methodcom.google.gson.JsonElement
toJson()
final String
toString()
Returns a string representation of this record class.
-
Field Details
-
CODEC
-
-
Constructor Details
-
ResearchTrigger
public ResearchTrigger(List<InteractionEvent> events, InteractionCondition condition, RewardPool<ConditionalResearch> research) An ease of use constructor for creating a ResearchTrigger that converts the List to a Set- Parameters:
events
- The events that should trigger the researchcondition
- The condition that should be met for the research to startresearch
- The research that can be started
-
ResearchTrigger
public ResearchTrigger(Set<InteractionEvent> events, InteractionCondition condition, RewardPool<ConditionalResearch> research) Constructor that creates an immutable copy of the set of events.- Parameters:
events
- The events that should trigger the researchcondition
- The condition that should be met for the research to startresearch
- The research that can be started
-
-
Method Details
-
handleEvent
The logic to check that the event fired is relevant to this trigger, then to check that the condition is met, and then to start the desired number of research for the player in the context.- Parameters:
event
- The event that was firedcontext
- The context of the event
-
toJson
public com.google.gson.JsonElement toJson()- Returns:
- The
ResearchTrigger
as aJsonElement
-
saveToFile
Saves theResearchTrigger
to a file using thetoJson()
method- Parameters:
file
- The file to save theResearchTrigger
to- Throws:
IOException
- If an error occurs while saving the file
-
builder
Creates a new builder for a ResearchTrigger- Returns:
- The builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
events
Returns the value of theevents
record component.- Returns:
- the value of the
events
record component
-
condition
Returns the value of thecondition
record component.- Returns:
- the value of the
condition
record component
-
research
Returns the value of theresearch
record component.- Returns:
- the value of the
research
record component
-