Package com.pixelmonmod.pixelmon.battles
Class BattleRegistry
java.lang.Object
com.pixelmonmod.pixelmon.battles.BattleRegistry
Keeps track of all active battles.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Removes a battle from the battle list.static BattleController
Finds a battle from its index.static BattleController
getBattle
(net.minecraft.world.entity.player.Player player) Finds the battle a player is in.static BattleController
getBattleExcludeSpectate
(net.minecraft.world.entity.player.Player player) Finds the battle a player is battling in.static BattleController
getSpectatedBattle
(net.minecraft.world.entity.player.Player player) Finds the battle a player is spectating.static void
Registers a battle in the battle list.static void
registerSpectator
(Spectator spectator, BattleController bc) Registers a spectator in a battle.static boolean
removeSpectator
(net.minecraft.server.level.ServerPlayer player) Removes the player from the battle being spectated.static BattleController
startBattle
(BattleParticipant[] team1, BattleParticipant[] team2, BattleType type) Sets up a singles battle between two participants.static BattleController
startBattle
(BattleParticipant[] team1, BattleParticipant[] team2, BattleRules rules) Sets up a battle with participants and registers it.static BattleController
startBattle
(BattleParticipant team1, BattleParticipant team2) Sets up a singles battle between two participants.static void
unregisterSpectator
(Spectator spectator) Unregisters a spectator from a battle.static void
Updates each battle in the battle list.
-
Method Details
-
startBattle
@Nullable public static BattleController startBattle(BattleParticipant[] team1, BattleParticipant[] team2, BattleRules rules) Sets up a battle with participants and registers it.- Parameters:
team1
- One side of the battle.team2
- The other side of the battle.rules
- The rules of the battle.- Returns:
- Returns a battle that has been started or null if the
BattleStartedEvent
was canceled.
-
startBattle
public static BattleController startBattle(BattleParticipant[] team1, BattleParticipant[] team2, BattleType type) Sets up a singles battle between two participants.- Parameters:
team1
- One participant in the battle.team2
- The other participant in the battle.type
- The type of battle to start.- Returns:
- Returns a battle that has been started or null if the
BattleStartedEvent
was canceled.
-
startBattle
Sets up a singles battle between two participants.- Parameters:
team1
- One participant in the battle.team2
- The other participant in the battle.- Returns:
- Returns a battle that has been started or null if the
BattleStartedEvent
was canceled.
-
registerBattle
Registers a battle in the battle list.- Parameters:
bc
- The battle to register.
-
getBattle
Finds a battle from its index.- Parameters:
index
- The index of the battle to find.- Returns:
- The battle with the given index, or null if none are found.
-
getBattle
Finds the battle a player is in.- Parameters:
player
- The player to find a battle for.- Returns:
- The battle the player is in, or null if the player is not in a battle.
-
getBattleExcludeSpectate
public static BattleController getBattleExcludeSpectate(net.minecraft.world.entity.player.Player player) Finds the battle a player is battling in. Does not include battles the player is spectating.- Parameters:
player
- The player to find a battle for.- Returns:
- The battle the player is battling in, or null if the player is not in a battle.
-
getSpectatedBattle
Finds the battle a player is spectating.- Parameters:
player
- The player to find a battle for.- Returns:
- The battle the player is spectating, or null if the player is not in a battle.
-
registerSpectator
Registers a spectator in a battle.- Parameters:
spectator
- The spectator to register.bc
- The battle to register the spectator to.
-
unregisterSpectator
Unregisters a spectator from a battle.- Parameters:
spectator
- The spectator to unregister.
-
removeSpectator
public static boolean removeSpectator(net.minecraft.server.level.ServerPlayer player) Removes the player from the battle being spectated.- Parameters:
player
- The player to remove from a battle.
-
deRegisterBattle
Removes a battle from the battle list.- Parameters:
bc
- The battle to remove.
-
updateBattles
public static void updateBattles()Updates each battle in the battle list.
-