diff --git a/api/src/main/kotlin/com/artillexstudios/axminions/api/data/DataHandler.kt b/api/src/main/kotlin/com/artillexstudios/axminions/api/data/DataHandler.kt index b31f23a..e5ea956 100644 --- a/api/src/main/kotlin/com/artillexstudios/axminions/api/data/DataHandler.kt +++ b/api/src/main/kotlin/com/artillexstudios/axminions/api/data/DataHandler.kt @@ -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 diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/commands/AxMinionsCommand.kt b/common/src/main/kotlin/com/artillexstudios/axminions/commands/AxMinionsCommand.kt index dc2818d..e0863ec 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/commands/AxMinionsCommand.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/commands/AxMinionsCommand.kt @@ -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()))) diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt b/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt index 1ce31e9..ab7deed 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt @@ -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 ->