-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Nlkomaru/features/change-config
Features/change config
- Loading branch information
Showing
73 changed files
with
1,752 additions
and
1,596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# suppress inspection "UnusedProperty" for whole file | ||
# suppress inspection "UnusedProperty" for whole file | ||
kotlin.code.style=official | ||
exposedVersion=0.37.3 | ||
cloudVersion=1.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
@@ -15,17 +16,20 @@ | |
*/ | ||
package dev.nikomaru.raceassist | ||
|
||
import cloud.commandframework.annotations.AnnotationParser | ||
import cloud.commandframework.bukkit.CloudBukkitCapabilities | ||
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator | ||
import cloud.commandframework.kotlin.coroutines.annotations.installCoroutineSupport | ||
import cloud.commandframework.meta.SimpleCommandMeta | ||
import cloud.commandframework.paper.PaperCommandManager | ||
import com.github.shynixn.mccoroutine.bukkit.SuspendingJavaPlugin | ||
import com.github.shynixn.mccoroutine.bukkit.registerSuspendingEvents | ||
import dev.nikomaru.raceassist.api.VaultAPI | ||
import dev.nikomaru.raceassist.bet.commands.* | ||
import dev.nikomaru.raceassist.bet.event.BetGuiClickEvent | ||
import dev.nikomaru.raceassist.database.* | ||
import dev.nikomaru.raceassist.data.database.BetList | ||
import dev.nikomaru.raceassist.files.Config | ||
import dev.nikomaru.raceassist.horse.event.HorseBreedEvent | ||
import dev.nikomaru.raceassist.race.commands.HelpCommand | ||
import dev.nikomaru.raceassist.race.commands.audience.* | ||
import dev.nikomaru.raceassist.race.commands.place.* | ||
|
@@ -37,20 +41,19 @@ import dev.nikomaru.raceassist.utils.CommandSuggestions | |
import dev.nikomaru.raceassist.utils.Lang | ||
import dev.nikomaru.raceassist.utils.coroutines.minecraft | ||
import kotlinx.coroutines.withContext | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.configuration.file.YamlConfiguration | ||
import org.jetbrains.exposed.sql.SchemaUtils | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
import java.io.File | ||
|
||
class RaceAssist : SuspendingJavaPlugin() { | ||
|
||
@OptIn(ExperimentalSerializationApi::class) | ||
override suspend fun onEnableAsync() { | ||
// Plugin startup logic | ||
plugin = this | ||
Lang.load() | ||
saveDefaultConfig() | ||
Config.config = YamlConfiguration.loadConfiguration(File(dataFolder, "config.yml")) | ||
Config.load() | ||
settingDatabase() | ||
setCommand() | ||
|
@@ -63,7 +66,7 @@ class RaceAssist : SuspendingJavaPlugin() { | |
private fun settingDatabase() { | ||
org.jetbrains.exposed.sql.Database.connect(url = "jdbc:sqlite:${plugin.dataFolder}${File.separator}RaceAssist.db", driver = "org.sqlite.JDBC") | ||
transaction { | ||
SchemaUtils.create(CircuitPoint, PlayerList, RaceList, BetList, BetSetting, RaceStaff) | ||
SchemaUtils.create(BetList) | ||
} | ||
} | ||
|
||
|
@@ -74,18 +77,18 @@ class RaceAssist : SuspendingJavaPlugin() { | |
private fun setCommand() { | ||
|
||
val commandManager: PaperCommandManager<CommandSender> = PaperCommandManager(this, | ||
AsynchronousCommandExecutionCoordinator.simpleCoordinator(), | ||
AsynchronousCommandExecutionCoordinator.newBuilder<CommandSender>().build(), | ||
java.util.function.Function.identity(), | ||
java.util.function.Function.identity()) | ||
|
||
|
||
if (commandManager.queryCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) { | ||
commandManager.registerAsynchronousCompletions() | ||
} | ||
val annotationParser: cloud.commandframework.annotations.AnnotationParser<CommandSender> = | ||
cloud.commandframework.annotations.AnnotationParser(commandManager, CommandSender::class.java) { | ||
SimpleCommandMeta.empty() | ||
} | ||
|
||
val annotationParser = AnnotationParser(commandManager, CommandSender::class.java) { | ||
SimpleCommandMeta.empty() | ||
}.installCoroutineSupport() | ||
|
||
annotationParser.parse(CommandSuggestions()) | ||
|
||
|
@@ -118,7 +121,6 @@ class RaceAssist : SuspendingJavaPlugin() { | |
annotationParser.parse(BetSheetCommand()) | ||
annotationParser.parse(BetRemoveCommand()) | ||
annotationParser.parse(BetReturnCommand()) | ||
annotationParser.parse(BetTransfarCommand()) | ||
|
||
annotationParser.parse(SettingCreateCommand()) | ||
annotationParser.parse(SettingDeleteCommand()) | ||
|
@@ -133,6 +135,7 @@ class RaceAssist : SuspendingJavaPlugin() { | |
server.pluginManager.registerSuspendingEvents(SetOutsideCircuitEvent(), this) | ||
server.pluginManager.registerSuspendingEvents(SetCentralPointEvent(), this) | ||
server.pluginManager.registerSuspendingEvents(BetGuiClickEvent(), this) | ||
server.pluginManager.registerSuspendingEvents(HorseBreedEvent(), this) | ||
} | ||
|
||
companion object { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
5 changes: 3 additions & 2 deletions
5
src/main/kotlin/dev/nikomaru/raceassist/api/sheet/GoogleAuthorizeUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
5 changes: 3 additions & 2 deletions
5
src/main/kotlin/dev/nikomaru/raceassist/api/sheet/SheetsServiceUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
@@ -14,8 +15,6 @@ | |
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package dev.nikomaru.raceassist.utils | ||
|
||
import java.util.* | ||
package dev.nikomaru.raceassist.bet | ||
|
||
data class TempBetData(val raceId: String, val uuid: UUID, val jockey: UUID, var bet: Int) | ||
object BetUtils {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
@@ -16,7 +17,7 @@ | |
|
||
package dev.nikomaru.raceassist.bet | ||
|
||
import dev.nikomaru.raceassist.files.Config.betUnit | ||
import dev.nikomaru.raceassist.data.files.BetSettingData | ||
import dev.nikomaru.raceassist.utils.Lang | ||
import net.kyori.adventure.text.Component | ||
import org.bukkit.Material | ||
|
@@ -30,34 +31,34 @@ object GuiComponent { | |
return Component.text("レース賭け自販機") | ||
} | ||
|
||
fun onceUp(locale: Locale): ItemStack { | ||
suspend 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, betUnit)) | ||
onceUpMeta.displayName(Lang.getComponent("to-bet-one-unit", locale, BetSettingData.getBetUnit(raceId))) | ||
onceUp.itemMeta = onceUpMeta | ||
return onceUp | ||
} | ||
|
||
fun onceDown(locale: Locale): ItemStack { | ||
suspend 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, betUnit)) | ||
onceDownMeta.displayName(Lang.getComponent("to-cancel-bet-one-unit", locale, BetSettingData.getBetUnit(raceId))) | ||
onceDown.itemMeta = onceDownMeta | ||
return onceDown | ||
} | ||
|
||
fun tenTimesUp(locale: Locale): ItemStack { | ||
suspend 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, betUnit * 10)) | ||
tenTimesUpMeta.displayName(Lang.getComponent("to-bet-ten-unit", locale, BetSettingData.getBetUnit(raceId) * 10)) | ||
tenTimesUp.itemMeta = tenTimesUpMeta | ||
return tenTimesUp | ||
} | ||
|
||
fun tenTimesDown(locale: Locale): ItemStack { | ||
suspend 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, betUnit * 10)) | ||
tenTimesDownMeta.displayName(Lang.getComponent("to-cancel-bet-ten-unit", locale, BetSettingData.getBetUnit(raceId) * 10)) | ||
tenTimesDown.itemMeta = tenTimesDownMeta | ||
return tenTimesDown | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* This program is free software: you can redistribute it and/or modify | ||
* Copyright © 2021-2022 Nikomaru <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
|
@@ -17,52 +18,38 @@ | |
package dev.nikomaru.raceassist.bet.commands | ||
|
||
import cloud.commandframework.annotations.* | ||
import com.github.shynixn.mccoroutine.bukkit.launch | ||
import dev.nikomaru.raceassist.RaceAssist.Companion.plugin | ||
import dev.nikomaru.raceassist.database.BetSetting | ||
import dev.nikomaru.raceassist.data.files.BetSettingData | ||
import dev.nikomaru.raceassist.utils.CommandUtils | ||
import dev.nikomaru.raceassist.utils.Lang | ||
import kotlinx.coroutines.Dispatchers | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.entity.Player | ||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction | ||
import org.jetbrains.exposed.sql.update | ||
import java.util.* | ||
|
||
@CommandMethod("ra|RaceAssist bet") | ||
class BetCanCommand { | ||
@CommandPermission("RaceAssist.commands.bet.can") | ||
@CommandMethod("can <raceId> <type>") | ||
fun setCanBet(sender: CommandSender, | ||
suspend fun setCanBet(sender: CommandSender, | ||
@Argument(value = "raceId", suggestions = "raceId") raceId: String, | ||
@Argument(value = "type", suggestions = "betType") type: String) { | ||
plugin.launch { | ||
if (CommandUtils.returnRaceSetting(raceId, sender)) return@launch | ||
if (type == "on") { | ||
setCanBet(raceId, sender) | ||
} else if (type == "off") { | ||
setCannotBet(raceId, sender) | ||
} | ||
if (CommandUtils.returnRaceSetting(raceId, sender)) return | ||
if (type == "on") { | ||
setCanBet(raceId, sender) | ||
} else if (type == "off") { | ||
setCannotBet(raceId, sender) | ||
} | ||
|
||
} | ||
|
||
private suspend fun setCanBet(raceId: String, sender: CommandSender) { | ||
newSuspendedTransaction(Dispatchers.IO) { | ||
BetSetting.update({ BetSetting.raceId eq raceId }) { | ||
it[canBet] = true | ||
} | ||
} | ||
BetSettingData.setAvailable(raceId, true) | ||
val locale = if (sender is Player) sender.locale() else Locale.getDefault() | ||
sender.sendMessage(Lang.getComponent("can-bet-this-raceid", locale, raceId)) | ||
} | ||
|
||
companion object { | ||
suspend fun setCannotBet(raceId: String, sender: CommandSender) { | ||
newSuspendedTransaction(Dispatchers.IO) { | ||
BetSetting.update({ BetSetting.raceId eq raceId }) { | ||
it[canBet] = false | ||
} | ||
} | ||
BetSettingData.setAvailable(raceId, false) | ||
|
||
val locale = if (sender is Player) sender.locale() else Locale.getDefault() | ||
sender.sendMessage(Lang.getComponent("cannot-bet-this-raceid", locale, raceId)) | ||
|
Oops, something went wrong.