RuneHive-Game
Loading...
Searching...
No Matches
LMSLobbyEvent.java
Go to the documentation of this file.
1package com.runehive.content.lms.lobby;
2
3import com.runehive.content.lms.LMSGame;
4import com.runehive.game.task.Task;
5
6import java.util.Objects;
7
8public class LMSLobbyEvent extends Task {
9
10 public static final int defaultLobbyTime = LMSLobby.DEVELOPMENT_MODE ? 15 : 300;
11 public static int lobbyTicks = defaultLobbyTime;
12
13 public LMSLobbyEvent() {
14 super(1);
15 }
16
17 @Override
18 protected void execute() {
19 if(LMSGame.gameInProgress) return;
20
21 if (lobbyTicks >= 0) {
22 if (lobbyTicks == 10) {
24 int playersStillRequired = LMSLobby.requiredPlayers - LMSLobby.lobbyMembers.size();
25 LMSLobby.lobbyMembers.stream().filter(Objects::nonNull).forEach(p -> p.message("@red@"+playersStillRequired+" more player"+(playersStillRequired > 1 ? "s are" : " is")+" required to start a game of LMS."));
26 } else LMSLobby.lobbyMembers.stream().filter(Objects::nonNull).forEach(p -> p.message("@red@The game will begin in 10 seconds."));
27 }
28 if (lobbyTicks == 0) {
31 } else {
32 LMSLobby.lobbyMembers.stream().filter(Objects::nonNull).forEach(p -> p.message("@red@The game will begin shortly."));
34 LMSLobby.lobbyMembers.clear();
35 }
36 }
37 lobbyTicks--;
38 }
39 }
40
41}
static void moveToGame(List< Player > players)
Handles moving all the players to the game.
Definition LMSGame.java:280
static boolean gameInProgress
Checks if there is currently a game in progress.
Definition LMSGame.java:48
void execute()
A function representing the unit of work that will be carried out.
static List< Player > lobbyMembers
A list with all the players in the lobby.
Definition LMSLobby.java:28
static int requiredPlayers
The amount of players in the lobby required.
Definition LMSLobby.java:33
Task(boolean instant, int delay)
Creates a new Task.
Definition Task.java:41