net.projecttl.kuma.mc.api.utils.perm.Perm.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kumamc-api Show documentation
Show all versions of kumamc-api Show documentation
This is custom minecraft minestom server Project Edition
package net.projecttl.kuma.mc.api.utils.perm
import net.minestom.server.entity.Player
import net.projecttl.kuma.mc.api.utils.perm.model.PermData
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.transactions.transaction
var Player.isPermed: Boolean
get() = transaction {
return@transaction !PermData.select { PermData.uuid eq uuid.toString() }.empty()
}
set(value) = transaction {
if (!value) {
PermData.deleteWhere { uuid eq [email protected]() }
return@transaction
}
if ([email protected]) {
return@transaction
}
PermData.insert {
it[uuid] = [email protected]()
}
}