All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.projecttl.kuma.mc.api.utils.perm.Perm.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0-beta.8
Show newest version
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]()
        }
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy