mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-12 18:31:54 +01:00
#40: Don't start games if requirements are not satisfied
This commit is contained in:
parent
83b92e9a13
commit
4fb23b482b
@ -149,6 +149,7 @@ public class Announcer {
|
||||
this.maxPlayersPerGroup = maxPlayersPerGroup;
|
||||
}
|
||||
|
||||
/* Getters and setters */
|
||||
/**
|
||||
* @return the name of the announcer
|
||||
*/
|
||||
@ -297,6 +298,20 @@ public class Announcer {
|
||||
return startTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether enough players and groups joined the announced game to start
|
||||
*/
|
||||
public boolean areRequirementsFulfilled() {
|
||||
int i = 0;
|
||||
for (DGroup group : dGroups) {
|
||||
if (group != null && group.getPlayers().size() >= minPlayersPerGroup) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i >= minGroupsPerGame;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
/**
|
||||
* Cancels the start task and sets it to null.
|
||||
*/
|
||||
@ -383,14 +398,7 @@ public class Announcer {
|
||||
|
||||
showGUI(player);
|
||||
|
||||
int i = 0;
|
||||
for (DGroup group : dGroups) {
|
||||
if (group != null && group.getPlayers().size() >= minPlayersPerGroup) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= minGroupsPerGame) {
|
||||
if (areRequirementsFulfilled()) {
|
||||
if (startTask == null) {
|
||||
startTask = new AnnouncerStartGameTask(this);
|
||||
startTask.runTaskLater(plugin, 20 * 30L);
|
||||
|
@ -59,6 +59,11 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!announcer.areRequirementsFulfilled()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Game game = null;
|
||||
|
||||
for (DGroup dGroup : announcer.getDGroups()) {
|
||||
|
Loading…
Reference in New Issue
Block a user