Class BattleBuilder
java.lang.Object
com.pixelmonmod.pixelmon.battles.api.BattleBuilder
Used for creating battles with a bunch of different settings
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected Map<Class<? extends BattleEvent>,
BiConsumer<? extends BattleEvent, BattleController>> protected boolean
protected boolean
protected boolean
protected boolean
protected BattleRandomSource
protected boolean
protected boolean
protected BattleRules
protected Long
protected TeamSelectionRegistry.Builder
protected Consumer<BattleController>
protected long
protected boolean
protected BattleParticipant[]
protected boolean
protected BattleParticipant[]
-
Method Summary
Modifier and TypeMethodDescriptionprotected <A extends BattleEvent>
voidaddTask
(BattleController controller, Class<? extends BattleEvent> eventClass, BiConsumer<? extends BattleEvent, BattleController> task) Allows spectators for the battleallowSpectators
(boolean allowSpectators) Sets if spectating the battle is allowedstatic BattleBuilder
builder()
Gets a new instance of the builderclause
(BattleClause clause) Sets the battle clausecrits()
This sets the battle to enable the ability for critical hits to occurDisables exp gain during the battlePrevents players from spectating the battleendHandler
(BiConsumer<BattleEndEvent, BattleController> endConsumer) Adds a consumer to run when the battle ends<E extends BattleEvent>
BattleBuildereventHandler
(Class<E> eventClass, BiConsumer<E, BattleController> eventHandler) Adds a consumer to run for any given battle eventEnables exp gain during the battle (defaults to true)This sets the battle to use the forceChance mechanic which means all damage will be 100% powerful and all status effects will have 100% chance to applyfrozen()
This sets the battle to be frozen when it is created meaning nothing will happen.protected void
handleClearingTemporaryMode
(BattleEndEvent event, BattleController battleController) The battle builder will not remove the player from temporary party mode if they are in it at the end of the battleSets this battle to create a battle log when the battle is overlogResult
(boolean logResult) Sets this battle to create a battle log when the battle is overnoCrits()
This sets the battle to disable the ability for critical hits to occurSets this battle to not create a battle log when the battle is overThis sets if the battle will be registered in theBattleRegistry
when it is started
This should be false for tests as the battle will not be cleaned up and will cause memory leaksDisables the team selection screen before the battle begins (default false)This sets the battle to not be frozen when it is created (default)random
(BattleRandomSource random) Sets the random source for the battle to use.This sets if the battle will be registered in theBattleRegistry
when it is started
This should be false for tests as the battle will not be cleaned up and will cause memory leaksregisterBattle
(boolean registerBattle) This sets if the battle will be registered in theBattleRegistry
when it is started
This should be false for tests as the battle will not be cleaned up and will cause memory leaksSets the battle builder to remove the player from the temporary party mode if they are in it at the end of the battlerules
(BattleRules rules) Sets the battle rulesseed
(long seed) Sets the seed the random source for the battle will use.protected void
setupController
(BattleController controller) setupHandler
(Consumer<BattleController> setupHandler) Adds a consumer to run after the battle builder has had it's properties setupstart()
Starts the battleSets the start battle logic to run off the Minecraft server's main threadprotected CompletableFuture<BattleController>
startDelay
(long startDelay, TimeUnit timeUnit) Adds a delay in the specified unit before the battle will beginstartHandler
(BiConsumer<BattleStartedEvent.Pre, BattleController> startConsumer) Adds a consumer to run when the battle beginsSets the start battle logic to run on the Minecraft server's main threadteamOne
(BattleParticipant... teamOne) Sets the first teamEnables the team selection screen before the battle beginsteamSelection
(boolean teamSelection) Sets if the team selection screen will show before battleteamSelectionBuilder
(TeamSelectionRegistry.Builder selectionBuilder) Sets the builder, and settings, for the team selection screenteamTwo
(BattleParticipant... teamTwo) Sets the second teamtestSeed()
Sets the seed the random source the battle will use to 1.
-
Field Details
-
teamOne
-
teamTwo
-
rules
-
eventHandlers
protected Map<Class<? extends BattleEvent>,BiConsumer<? extends BattleEvent, eventHandlersBattleController>> -
setupHandler
-
random
-
seed
-
disableExp
protected boolean disableExp -
allowSpectators
protected boolean allowSpectators -
teamSelection
protected boolean teamSelection -
selectionBuilder
-
startDelayMillis
protected long startDelayMillis -
startSync
protected boolean startSync -
removeFromTempParties
protected boolean removeFromTempParties -
freezeBattle
protected boolean freezeBattle -
forceChance
protected boolean forceChance -
noCrits
protected boolean noCrits -
logResult
protected boolean logResult -
registerBattle
protected boolean registerBattle
-
-
Method Details
-
teamOne
Sets the first team- Parameters:
teamOne
- The first team- Returns:
- The builder
-
teamTwo
Sets the second team- Parameters:
teamTwo
- The second team- Returns:
- The builder
-
rules
Sets the battle rules- Parameters:
rules
- The battle rules- Returns:
- The builder
-
clause
Sets the battle clause- Parameters:
clause
- The battle clause to add- Returns:
- The builder
-
endHandler
Adds a consumer to run when the battle ends- Parameters:
endConsumer
- The consumer to run- Returns:
- The builder
-
startHandler
public BattleBuilder startHandler(BiConsumer<BattleStartedEvent.Pre, BattleController> startConsumer) Adds a consumer to run when the battle begins- Parameters:
startConsumer
- The consumer to run- Returns:
- The builder
-
setupHandler
Adds a consumer to run after the battle builder has had it's properties setup- Parameters:
setupHandler
- The setup handler- Returns:
- The builder
-
eventHandler
public <E extends BattleEvent> BattleBuilder eventHandler(Class<E> eventClass, BiConsumer<E, BattleController> eventHandler) Adds a consumer to run for any given battle event- Type Parameters:
E
- The event type- Parameters:
eventClass
- The event classeventHandler
- The handler to run for the given event- Returns:
- The builder
-
random
Sets the random source for the battle to use.- Parameters:
random
- The random source- Returns:
- The builder
-
seed
Sets the seed the random source for the battle will use.- Parameters:
seed
- The seed- Returns:
- The builder
-
testSeed
Sets the seed the random source the battle will use to 1. Designed for use in testing only.- Returns:
- The builder
-
disableExp
Disables exp gain during the battle- Returns:
- The builder
-
expEnabled
Enables exp gain during the battle (defaults to true)- Returns:
- The builder
-
allowSpectators
Allows spectators for the battle- Returns:
- The builder
-
disallowSpectators
Prevents players from spectating the battle- Returns:
- The builder
-
allowSpectators
Sets if spectating the battle is allowed- Parameters:
allowSpectators
- if spectating is allowed- Returns:
- The builder
-
teamSelection
Enables the team selection screen before the battle begins- Returns:
- The builder
-
noSelection
Disables the team selection screen before the battle begins (default false)- Returns:
- The builder
-
teamSelection
Sets if the team selection screen will show before battle- Parameters:
teamSelection
- If selection should occur- Returns:
- The builder
-
teamSelectionBuilder
Sets the builder, and settings, for the team selection screen- Parameters:
selectionBuilder
- The selection screen settings builder- Returns:
- The builder
-
startDelay
Adds a delay in the specified unit before the battle will begin- Parameters:
startDelay
- The delaytimeUnit
- The unit for the delay- Returns:
- The builder
-
startSync
Sets the start battle logic to run on the Minecraft server's main thread- Returns:
- The builder
-
startAsync
Sets the start battle logic to run off the Minecraft server's main thread- Returns:
- The builder
-
removeFromTempParty
Sets the battle builder to remove the player from the temporary party mode if they are in it at the end of the battle- Returns:
- The builder
-
ignoreTempParties
The battle builder will not remove the player from temporary party mode if they are in it at the end of the battle- Returns:
- The builder
-
frozen
This sets the battle to be frozen when it is created meaning nothing will happen. This should ONLY really be used for testing as NOTHING will happen at all in the battle- Returns:
- The builder
-
notFrozen
This sets the battle to not be frozen when it is created (default)- Returns:
- The builder
-
forceChance
This sets the battle to use the forceChance mechanic which means all damage will be 100% powerful and all status effects will have 100% chance to apply- Returns:
- The builder
-
logResult
Sets this battle to create a battle log when the battle is over- Returns:
- The builder
-
noLogResult
Sets this battle to not create a battle log when the battle is over- Returns:
- The builder
-
logResult
Sets this battle to create a battle log when the battle is over- Parameters:
logResult
- If the battle should log the result- Returns:
- The builder
-
noCrits
This sets the battle to disable the ability for critical hits to occur- Returns:
- The builder
-
crits
This sets the battle to enable the ability for critical hits to occur- Returns:
- The builder
-
registerBattle
This sets if the battle will be registered in theBattleRegistry
when it is started
This should be false for tests as the battle will not be cleaned up and will cause memory leaks- Parameters:
registerBattle
- If the battle should be registered- Returns:
- The builder
-
registerBattle
This sets if the battle will be registered in theBattleRegistry
when it is started
This should be false for tests as the battle will not be cleaned up and will cause memory leaks- Returns:
- The builder
-
noRegisterBattle
This sets if the battle will be registered in theBattleRegistry
when it is started
This should be false for tests as the battle will not be cleaned up and will cause memory leaks- Returns:
- The builder
-
start
Starts the battle- Returns:
- A completable future that will return the battle controller when the battle has begun
-
startBattle
-
setupController
-
handleClearingTemporaryMode
-
addTask
protected <A extends BattleEvent> void addTask(BattleController controller, Class<? extends BattleEvent> eventClass, BiConsumer<? extends BattleEvent, BattleController> task) -
builder
Gets a new instance of the builder- Returns:
- A new instance of the battle builder
-