Skip to content

Commit

Permalink
Fix the problem with not being able to limit the number of players pr…
Browse files Browse the repository at this point in the history
…operly and support up to 8 players.
  • Loading branch information
Nlkomaru committed Feb 25, 2022
1 parent 13f407e commit d98967c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bukkit {
permissions {
register("RaceAssist.admin") {
default = Default.OP
childrenMap = mapOf("RaceAssist.commands.*" to true)
children = listOf("RaceAssist.commands.*")
}
register("RaceAssist.user") {
default = Default.TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ class BetChestGui {

suspend fun getGUI(player: Player, raceId: String): Inventory {
val gui = Bukkit.createInventory(player, 45, GuiComponent.guiComponent())
val playerWools = ImmutableList.of(Material.RED_WOOL,
val playerWools = ImmutableList.of(
Material.RED_WOOL,
Material.BLUE_WOOL,
Material.YELLOW_WOOL,
Material.GREEN_WOOL,
Material.BROWN_WOOL,
Material.PINK_WOOL,
Material.WHITE_WOOL)
Material.WHITE_WOOL,
Material.ORANGE_WOOL,
)
val players: ArrayList<UUID> = ArrayList()
val odds: HashMap<UUID, Double> = HashMap()
var sum = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PlayerAddCommand {
sender.sendMessage(Lang.getComponent("already-exist-this-user", sender.locale()))
return@launch
}
if (getRacePlayerAmount() >= 8) {
if (getRacePlayerAmount(raceId) > 7) {
sender.sendMessage(Lang.getComponent("max-player-is-eight", sender.locale()))
return@launch
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/dev/nikomaru/raceassist/utils/CommandUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ object CommandUtils {
RaceList.select { RaceList.raceId eq raceId }.firstOrNull()?.get(RaceList.reverse)
}

suspend fun getRacePlayerAmount(): Long = newSuspendedTransaction {
suspend fun getRacePlayerAmount(raceId: String): Long = newSuspendedTransaction {
PlayerList.select {
PlayerList.raceId eq "raceId"
PlayerList.raceId eq raceId
}.count()
}

Expand Down

0 comments on commit d98967c

Please sign in to comment.