Skip to content

Commit b442e26

Browse files
committed
re-add minimum players during match
1 parent 06c508f commit b442e26

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

core/src/main/java/tc/oc/pgm/PGMConfig.java

+7
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public final class PGMConfig implements Config {
9090

9191
// join.*
9292
private final long minPlayers;
93+
private final long minPlayersMaintain;
9394
private final boolean limitJoin;
9495
private final boolean priorityKick;
9596
private final boolean balanceJoin;
@@ -196,6 +197,7 @@ public final class PGMConfig implements Config {
196197
this.maxExtraVotes = parseInteger(config.getString("votes.max-extra-votes", "5"));
197198

198199
this.minPlayers = parseInteger(config.getString("join.min-players", "1"));
200+
this.minPlayersMaintain = parseInteger(config.getString("gameplay.min-players-maintain", "1"));
199201
this.limitJoin = parseBoolean(config.getString("join.limit", "true"));
200202
this.priorityKick = parseBoolean(config.getString("join.priority-kick", "true"));
201203
this.balanceJoin = parseBoolean(config.getString("join.balance", "true"));
@@ -583,6 +585,11 @@ public Duration getTimePenalty(TimePenalty penalty) {
583585
return timePenalties.get(penalty);
584586
}
585587

588+
@Override
589+
public long getMinimumPlayersMaintain() {
590+
return this.minPlayersMaintain;
591+
}
592+
586593
@Override
587594
public boolean showSideBar() {
588595
return showSideBar;

core/src/main/java/tc/oc/pgm/api/Config.java

+7
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ enum TimePenalty {
330330
SWITCH
331331
}
332332

333+
/**
334+
* Get the number of players needed to keep a match running.
335+
*
336+
* @return number of players
337+
*/
338+
long getMinimumPlayersMaintain();
339+
333340
/**
334341
* Gets if extra votes are allowed based on the "pgm.vote.extra.#" permission.
335342
*

core/src/main/java/tc/oc/pgm/cycle/CycleMatchModule.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ public void startCountdown(@Nullable Duration duration) {
4747
public void onPartyChange(PlayerPartyChangeEvent event) {
4848
if (event.wasParticipating()
4949
&& match.isRunning()
50-
&& match.getParticipants().isEmpty()) {
51-
match.getLogger().info("Cycling due to empty match");
50+
&& match.getParticipants().size()
51+
< PGM.get().getConfiguration().getMinimumPlayersMaintain()) {
52+
match
53+
.getLogger()
54+
.info("Ending match due to an insufficient number of players.");
5255
match.finish();
5356
startCountdown(null);
5457
}

core/src/main/resources/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ restart:
6666
# Changes behaviour when players try to /join a match.
6767
join:
6868
min-players: 1 # Minimum number of players before a match can start.
69+
min-players-maintain: 1 # Minimum number of players that a match should maintain before PGM ends the match
6970
anytime: true # Can players join after a match has started?
7071
balance: true # Can players be moved to make teams more balanced?
7172
queue: false # Should players be put in a queue before joining the match?

0 commit comments

Comments
 (0)