Skip to content

Commit

Permalink
🐛 Fix betting gui method(WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nlkomaru committed Jul 17, 2024
1 parent c2c7dcb commit 81458be
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 439 deletions.
6 changes: 1 addition & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ kotlinx-serialization-hocon = { group = "org.jetbrains.kotlinx", name = "kotlinx
kotlin-result = { group = "com.michael-bull.kotlin-result", name = "kotlin-result", version.ref = "kotlin-result" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin-core" }
mockBukkit = { module = "com.github.seeseemelk:MockBukkit-v1.20", version.ref = "mockBukkit" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
junitJupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junitJupiter" }
koinTest = { module = "io.insert-koin:koin-test", version.ref = "koinTest" }
koinTestJunit5 = { module = "io.insert-koin:koin-test-junit5", version.ref = "koinTestJunit5" }


[plugins]
run-paper = { id = "xyz.jpenilla.run-paper", version = "2.3.0" }
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import dev.nikomaru.raceassist.api.core.PlaceType
import dev.nikomaru.raceassist.api.core.RaceAssistAPI
import dev.nikomaru.raceassist.api.core.manager.*
import dev.nikomaru.raceassist.bet.commands.*
import dev.nikomaru.raceassist.bet.event.BetGuiClickEvent
import dev.nikomaru.raceassist.data.database.BetList
import dev.nikomaru.raceassist.data.database.UserAuthData
import dev.nikomaru.raceassist.data.files.RaceUtils
Expand Down Expand Up @@ -269,7 +268,6 @@ open class RaceAssist : SuspendingJavaPlugin(), RaceAssistAPI, KoinComponent {
injectServer.pluginManager.registerSuspendingEvents(SetInsideCircuitEvent(), plugin)
injectServer.pluginManager.registerSuspendingEvents(SetOutsideCircuitEvent(), plugin)
injectServer.pluginManager.registerSuspendingEvents(SetCentralPointEvent(), plugin)
injectServer.pluginManager.registerSuspendingEvents(BetGuiClickEvent(), plugin)
injectServer.pluginManager.registerSuspendingEvents(HorseBreedEvent(), plugin)
injectServer.pluginManager.registerSuspendingEvents(HorseKillEvent(), plugin)
injectServer.pluginManager.registerSuspendingEvents(HorseTamedEvent(), plugin)
Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/dev/nikomaru/raceassist/bet/BetUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package dev.nikomaru.raceassist.bet

import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.bet.data.TempBetData
import dev.nikomaru.raceassist.bet.gui.BetChestGui
import dev.nikomaru.raceassist.bet.gui.components.GuiItems.AllPlayers
import dev.nikomaru.raceassist.data.database.BetList
import dev.nikomaru.raceassist.data.database.BetListData
import dev.nikomaru.raceassist.utils.Lang
Expand Down Expand Up @@ -73,9 +73,12 @@ object BetUtils {
}

fun initializePlayerTempBetData(raceId: String, sender: Player) {
BetChestGui.AllPlayers[raceId]?.forEach { jockey ->
println(AllPlayers[raceId])
AllPlayers[raceId]?.forEach { jockey ->
tempBetDataList.add(TempBetData(raceId, sender, jockey, 0))
}
println(tempBetDataList)

}

suspend fun listBetData(raceId: String): ArrayList<BetListData> {
Expand Down
56 changes: 0 additions & 56 deletions src/main/kotlin/dev/nikomaru/raceassist/bet/GuiComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package dev.nikomaru.raceassist.bet

import com.github.stefvanschie.inventoryframework.gui.GuiItem
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.utils.Lang
import net.kyori.adventure.text.Component
import org.bukkit.Material
Expand All @@ -32,61 +31,6 @@ object GuiComponent {
return Component.text("レース賭け自販機")
}

fun onceUp(locale: Locale, raceId: String): ItemStack {
val onceUp = ItemStack(Material.PINK_STAINED_GLASS_PANE)
val onceUpMeta: ItemMeta = onceUp.itemMeta
onceUpMeta.displayName(
Lang.getComponent(
"to-bet-one-unit",
locale,
RaceAssist.api.getBetManager(raceId)!!.getBetUnit()
)
)
onceUp.itemMeta = onceUpMeta
return onceUp
}

fun onceDown(locale: Locale, raceId: String): ItemStack {
val onceDown = ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE)
val onceDownMeta: ItemMeta = onceDown.itemMeta
onceDownMeta.displayName(
Lang.getComponent(
"to-cancel-bet-one-unit",
locale,
RaceAssist.api.getBetManager(raceId)!!.getBetUnit()
)
)
onceDown.itemMeta = onceDownMeta
return onceDown
}

fun tenTimesUp(locale: Locale, raceId: String): ItemStack {
val tenTimesUp = ItemStack(Material.RED_STAINED_GLASS_PANE)
val tenTimesUpMeta: ItemMeta = tenTimesUp.itemMeta
tenTimesUpMeta.displayName(
Lang.getComponent(
"to-bet-ten-unit",
locale,
RaceAssist.api.getBetManager(raceId)!!.getBetUnit() * 10
)
)
tenTimesUp.itemMeta = tenTimesUpMeta
return tenTimesUp
}

fun tenTimesDown(locale: Locale, raceId: String): ItemStack {
val tenTimesDown = ItemStack(Material.BLUE_STAINED_GLASS_PANE)
val tenTimesDownMeta: ItemMeta = tenTimesDown.itemMeta
tenTimesDownMeta.displayName(
Lang.getComponent(
"to-cancel-bet-ten-unit",
locale,
RaceAssist.api.getBetManager(raceId)!!.getBetUnit() * 10
)
)
tenTimesDown.itemMeta = tenTimesDownMeta
return tenTimesDown
}

fun accept(locale: Locale): ItemStack {
val accept = ItemStack(Material.GREEN_WOOL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.bet.BetUtils
import dev.nikomaru.raceassist.bet.gui.BetChestGui
import dev.nikomaru.raceassist.bet.gui.BetGui
import dev.nikomaru.raceassist.utils.Lang
import dev.nikomaru.raceassist.utils.SuggestionId
import dev.nikomaru.raceassist.utils.coroutines.minecraft
Expand Down Expand Up @@ -53,9 +53,8 @@ class BetOpenCommand {
}
BetUtils.removePlayerTempBetData(sender)
withContext(Dispatchers.minecraft) {
sender.openInventory(BetChestGui().getGUI(sender, raceId))
BetGui().openGui(sender, raceId)
}
BetUtils.initializePlayerTempBetData(raceId, sender)
}

}
Loading

0 comments on commit 81458be

Please sign in to comment.