From d98967c782c76feca22272a37f2c281ce4922e75 Mon Sep 17 00:00:00 2001 From: Nikomaru Date: Fri, 25 Feb 2022 19:10:28 +0900 Subject: [PATCH] Fix the problem with not being able to limit the number of players properly and support up to 8 players. --- build.gradle.kts | 2 +- .../kotlin/dev/nikomaru/raceassist/bet/gui/BetChestGui.kt | 7 +++++-- .../raceassist/race/commands/player/PlayerAddCommand.kt | 2 +- .../kotlin/dev/nikomaru/raceassist/utils/CommandUtils.kt | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ef04a2d..b3b0dda 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 diff --git a/src/main/kotlin/dev/nikomaru/raceassist/bet/gui/BetChestGui.kt b/src/main/kotlin/dev/nikomaru/raceassist/bet/gui/BetChestGui.kt index 53e3aeb..caa4ca1 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/bet/gui/BetChestGui.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/bet/gui/BetChestGui.kt @@ -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 = ArrayList() val odds: HashMap = HashMap() var sum = 0 diff --git a/src/main/kotlin/dev/nikomaru/raceassist/race/commands/player/PlayerAddCommand.kt b/src/main/kotlin/dev/nikomaru/raceassist/race/commands/player/PlayerAddCommand.kt index d74d673..0712205 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/race/commands/player/PlayerAddCommand.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/race/commands/player/PlayerAddCommand.kt @@ -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 } diff --git a/src/main/kotlin/dev/nikomaru/raceassist/utils/CommandUtils.kt b/src/main/kotlin/dev/nikomaru/raceassist/utils/CommandUtils.kt index b5c1f52..d989210 100644 --- a/src/main/kotlin/dev/nikomaru/raceassist/utils/CommandUtils.kt +++ b/src/main/kotlin/dev/nikomaru/raceassist/utils/CommandUtils.kt @@ -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() }