mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2025-01-05 18:37:44 +01:00
Extra slots fix
This commit is contained in:
parent
80d440c538
commit
d04eae11ac
@ -38,6 +38,8 @@ interface DataHandler {
|
||||
|
||||
fun getIsland(island: String): Int
|
||||
|
||||
fun addUser(uuid: UUID, name: String)
|
||||
|
||||
fun addExtraSlot(user: UUID, amount: Int)
|
||||
|
||||
fun getExtraSlots(user: UUID): Int
|
||||
|
@ -195,6 +195,7 @@ class AxMinionsCommand {
|
||||
fun extraSlot(commandSender: CommandSender, offlinePlayer: OfflinePlayer, amount: Int) {
|
||||
AxMinionsPlugin.dataQueue.submit {
|
||||
val original = AxMinionsPlugin.dataHandler.getExtraSlots(offlinePlayer.uniqueId)
|
||||
AxMinionsPlugin.dataHandler.addUser(offlinePlayer.uniqueId, offlinePlayer.name ?: "---")
|
||||
AxMinionsPlugin.dataHandler.addExtraSlot(offlinePlayer.uniqueId, amount)
|
||||
commandSender.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.SLOT_GIVE(), Placeholder.unparsed("player", offlinePlayer.name ?: "???"), Placeholder.unparsed("amount", amount.toString())))
|
||||
offlinePlayer.player?.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.SLOT_RECEIVE(), Placeholder.unparsed("amount", amount.toString()), Placeholder.unparsed("from", original.toString()), Placeholder.unparsed("to", (original + amount).toString())))
|
||||
|
@ -427,6 +427,17 @@ class H2DataHandler : DataHandler {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun addUser(uuid: UUID, name: String) {
|
||||
dataSource.connection.use { connection ->
|
||||
connection.prepareStatement("INSERT IGNORE INTO `axminions_users`(`uuid`, `name`, `island_slots`) VALUES (?,?,?);").use { statement ->
|
||||
statement.setObject(1, uuid)
|
||||
statement.setString(2, name)
|
||||
statement.setInt(3, 0)
|
||||
statement.executeUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun addExtraSlot(user: UUID, amount: Int) {
|
||||
dataSource.connection.use { connection ->
|
||||
connection.prepareStatement("UPDATE `axminions_users` SET `island_slots` = `island_slots` + ? WHERE `uuid` = ?;").use { statement ->
|
||||
|
Loading…
Reference in New Issue
Block a user