-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for VoteStartModule
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: VoteStartModule | ||
--- | ||
`VoteStartModule` allows the players waiting in a game to choose when it starts. Upon joining, players' hotbars are automatically filled with items that, when interacted with, register the player's vote. Once at least half the players have voted, and the minimum player count is met, a countdown begins. If either of these conditions stops being met during the countdown, it is canceled. When the countdown reaches 0, the module will call `GameStartEvent`, change the game state to `INGAME`, and display a "GO!" title on the screen. | ||
|
||
:::caution | ||
This module is a replacement for [CountdownModule](../countdownmodule) and they should not be used together. | ||
::: | ||
|
||
## Usage | ||
Import the module: | ||
```kotlin | ||
import com.bluedragonmc.server.module.minigame.VoteStartModule | ||
``` | ||
Use the module in your game's `initialize` function: | ||
```kotlin | ||
use(VoteStartModule(minPlayers = 2, countdownSeconds = 5)) | ||
``` | ||
To check if a player has voted to start, use `hasVoted`: | ||
```kotlin | ||
if (getModule<VoteStartModule>().hasVoted(player)) { | ||
player.sendMessage("You have already voted for the game to start!") | ||
} | ||
``` |