Class GameStartEvent
java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.ZentrixGameEvent
dev.itsharshxd.zentrix.api.events.game.GameStartEvent
Called when a Zentrix game starts (transitions to PLAYING state).
This event is fired after all players have been teleported to the arena and the game officially begins. At this point:
- All players are in the game world
- Teams have been assigned
- The first phase is about to start
- Players are in survival mode
This event is NOT cancellable.
Example Usage
@EventHandler
public void onGameStart(GameStartEvent event) {
ZentrixGame game = event.getGame();
int players = event.getStartingPlayerCount();
int teams = event.getStartingTeamCount();
getLogger().info("Game started in " + event.getArenaName() +
" with " + players + " players in " + teams + " teams!");
// Give all players a starting bonus
for (ZentrixPlayer player : game.getPlayers()) {
player.getBukkitPlayer().ifPresent(p -> {
p.sendMessage("Good luck!");
});
}
}
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull org.bukkit.event.HandlerListGets the static handler list for this event type.@NotNull org.bukkit.event.HandlerListGets the handler list for this event.intGets the maximum players allowed in this game.intGets the number of players when the game started.intGets the number of teams when the game started.@NotNull Collection<ZentrixTeam> getTeams()Gets all teams in the game at start.intGets the team size for this game type.booleanChecks if this is a solo game (team size of 1).booleanChecks if this is a team game (team size greater than 1).Methods inherited from class dev.itsharshxd.zentrix.api.events.ZentrixGameEvent
getArenaName, getGame, getGameId, getGameState, getGameTypeName, getPlayerCountMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
GameStartEvent
Constructs a new GameStartEvent.- Parameters:
game- The game that is starting
-
-
Method Details
-
getStartingPlayerCount
public int getStartingPlayerCount()Gets the number of players when the game started.This is the initial player count at game start, which may be different from the current count if players leave during the event.
- Returns:
- The starting player count
-
getStartingTeamCount
public int getStartingTeamCount()Gets the number of teams when the game started.For solo games, this will equal the player count. For team games, this will be the number of formed teams.
- Returns:
- The starting team count
-
getTeams
Gets all teams in the game at start.Convenience method equivalent to
getGame().getTeams().- Returns:
- An unmodifiable collection of teams
-
getMaxPlayers
public int getMaxPlayers()Gets the maximum players allowed in this game.- Returns:
- The maximum player count
-
getTeamSize
public int getTeamSize()Gets the team size for this game type.- Returns:
- The team size (1 for solo games)
-
isSoloGame
public boolean isSoloGame()Checks if this is a solo game (team size of 1).- Returns:
trueif this is a solo game
-
isTeamGame
public boolean isTeamGame()Checks if this is a team game (team size greater than 1).- Returns:
trueif this is a team game
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Gets the handler list for this event.- Overrides:
getHandlersin classZentrixGameEvent- Returns:
- The handler list
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Gets the static handler list for this event type.- Returns:
- The handler list
-