Skip to content

Commit

Permalink
feat: new placeholders %bedwars_all_games_players% and %bedwars_all_g…
Browse files Browse the repository at this point in the history
…ames_maxplayers%
  • Loading branch information
Misat11 committed Jan 25, 2024
1 parent 0bf4221 commit cf18063
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.screamingsandals.bedwars.game.Game;
import org.screamingsandals.bedwars.game.GamePlayer;

import java.util.Locale;

public class BedwarsExpansion extends PlaceholderExpansion {

@Override
Expand Down Expand Up @@ -89,6 +91,16 @@ public String onPlaceholderRequest(Player player, String identifier) {
}
}

if (identifier.startsWith("all_games_")) {
String operation = identifier.substring(10).toLowerCase(Locale.ROOT);
switch (operation) {
case "players":
return Integer.toString(Main.getGameNames().stream().map(Main::getGame).mapToInt(Game::countConnectedPlayers).sum());
case "maxplayers":
return Integer.toString(Main.getGameNames().stream().map(Main::getGame).mapToInt(Game::getMaxPlayers).sum());
}
}

// other player stats

if (identifier.startsWith("otherstats_")) {
Expand Down

0 comments on commit cf18063

Please sign in to comment.