Class BattleBuilder

java.lang.Object
com.pixelmonmod.pixelmon.battles.api.BattleBuilder

public class BattleBuilder extends Object
Used for creating battles with a bunch of different settings
  • Field Details

    • teamOne

      protected BattleParticipant[] teamOne
    • teamTwo

      protected BattleParticipant[] teamTwo
    • rules

      protected BattleRules rules
    • eventHandlers

      protected Map<Class<? extends BattleEvent>,BiConsumer<? extends BattleEvent,BattleController>> eventHandlers
    • setupHandler

      protected Consumer<BattleController> setupHandler
    • random

      protected BattleRandomSource random
    • seed

      protected Long seed
    • disableExp

      protected boolean disableExp
    • allowSpectators

      protected boolean allowSpectators
    • teamSelection

      protected boolean teamSelection
    • selectionBuilder

      protected TeamSelectionRegistry.Builder 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
  • Method Details

    • teamOne

      public BattleBuilder teamOne(BattleParticipant... teamOne)
      Sets the first team
      Parameters:
      teamOne - The first team
      Returns:
      The builder
    • teamTwo

      public BattleBuilder teamTwo(BattleParticipant... teamTwo)
      Sets the second team
      Parameters:
      teamTwo - The second team
      Returns:
      The builder
    • rules

      public BattleBuilder rules(BattleRules rules)
      Sets the battle rules
      Parameters:
      rules - The battle rules
      Returns:
      The builder
    • clause

      public BattleBuilder clause(BattleClause clause)
      Sets the battle clause
      Parameters:
      clause - The battle clause to add
      Returns:
      The builder
    • endHandler

      public BattleBuilder endHandler(BiConsumer<BattleEndEvent,BattleController> endConsumer)
      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

      public BattleBuilder setupHandler(Consumer<BattleController> 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 class
      eventHandler - The handler to run for the given event
      Returns:
      The builder
    • random

      public BattleBuilder random(BattleRandomSource random)
      Sets the random source for the battle to use.
      Parameters:
      random - The random source
      Returns:
      The builder
    • seed

      public BattleBuilder seed(long seed)
      Sets the seed the random source for the battle will use.
      Parameters:
      seed - The seed
      Returns:
      The builder
    • testSeed

      public BattleBuilder testSeed()
      Sets the seed the random source the battle will use to 1. Designed for use in testing only.
      Returns:
      The builder
    • disableExp

      public BattleBuilder disableExp()
      Disables exp gain during the battle
      Returns:
      The builder
    • expEnabled

      public BattleBuilder expEnabled()
      Enables exp gain during the battle (defaults to true)
      Returns:
      The builder
    • allowSpectators

      public BattleBuilder allowSpectators()
      Allows spectators for the battle
      Returns:
      The builder
    • disallowSpectators

      public BattleBuilder disallowSpectators()
      Prevents players from spectating the battle
      Returns:
      The builder
    • allowSpectators

      public BattleBuilder allowSpectators(boolean allowSpectators)
      Sets if spectating the battle is allowed
      Parameters:
      allowSpectators - if spectating is allowed
      Returns:
      The builder
    • teamSelection

      public BattleBuilder teamSelection()
      Enables the team selection screen before the battle begins
      Returns:
      The builder
    • noSelection

      public BattleBuilder noSelection()
      Disables the team selection screen before the battle begins (default false)
      Returns:
      The builder
    • teamSelection

      public BattleBuilder teamSelection(boolean teamSelection)
      Sets if the team selection screen will show before battle
      Parameters:
      teamSelection - If selection should occur
      Returns:
      The builder
    • teamSelectionBuilder

      public BattleBuilder teamSelectionBuilder(TeamSelectionRegistry.Builder selectionBuilder)
      Sets the builder, and settings, for the team selection screen
      Parameters:
      selectionBuilder - The selection screen settings builder
      Returns:
      The builder
    • startDelay

      public BattleBuilder startDelay(long startDelay, TimeUnit timeUnit)
      Adds a delay in the specified unit before the battle will begin
      Parameters:
      startDelay - The delay
      timeUnit - The unit for the delay
      Returns:
      The builder
    • startSync

      public BattleBuilder startSync()
      Sets the start battle logic to run on the Minecraft server's main thread
      Returns:
      The builder
    • startAsync

      public BattleBuilder startAsync()
      Sets the start battle logic to run off the Minecraft server's main thread
      Returns:
      The builder
    • removeFromTempParty

      public BattleBuilder 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

      public BattleBuilder 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

      public BattleBuilder 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

      public BattleBuilder notFrozen()
      This sets the battle to not be frozen when it is created (default)
      Returns:
      The builder
    • forceChance

      public BattleBuilder 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

      public BattleBuilder logResult()
      Sets this battle to create a battle log when the battle is over
      Returns:
      The builder
    • noLogResult

      public BattleBuilder noLogResult()
      Sets this battle to not create a battle log when the battle is over
      Returns:
      The builder
    • logResult

      public BattleBuilder logResult(boolean 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

      public BattleBuilder noCrits()
      This sets the battle to disable the ability for critical hits to occur
      Returns:
      The builder
    • start

      Starts the battle
      Returns:
      A completable future that will return the battle controller when the battle has begun
    • startBattle

      protected CompletableFuture<BattleController> startBattle()
    • setupController

      protected void setupController(BattleController controller)
    • handleClearingTemporaryMode

      protected void handleClearingTemporaryMode(BattleEndEvent event, BattleController battleController)
    • addTask

      protected <A extends BattleEvent> void addTask(BattleController controller, Class<? extends BattleEvent> eventClass, BiConsumer<? extends BattleEvent,BattleController> task)
    • builder

      public static BattleBuilder builder()
      Gets a new instance of the builder
      Returns:
      A new instance of the battle builder