io.github.ZeronDev.OtherFunctions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ZeronLib Show documentation
Show all versions of ZeronLib Show documentation
Minecraft Plugin Developer
package io.github.ZeronDev
import net.kyori.adventure.text.Component.text
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.permissions.Permission
import org.bukkit.scoreboard.DisplaySlot
import org.bukkit.scoreboard.Scoreboard
object OtherFunctions {
fun registerPermission(permission: String) {
if (Bukkit.getPluginManager().getPermission(permission) == null) {
Bukkit.getPluginManager().addPermission(Permission(permission))
Bukkit.reloadPermissions()
}
}
fun newScoreboard(name: String, vararg score: Pair) : Scoreboard {
val scoreboard = Bukkit.getScoreboardManager().newScoreboard
val objective = scoreboard.registerNewObjective("scoreboard", "dummy", text(name))
objective.displaySlot = DisplaySlot.SIDEBAR
score.forEach {
objective.getScore(it.first).score = it.second
}
return scoreboard
}
fun Player.setScoreboard(name: String, vararg score: Pair) : Scoreboard {
val scoreboard = Bukkit.getScoreboardManager().newScoreboard
val objective = scoreboard.registerNewObjective("scoreboard", "dummy", text(name))
objective.displaySlot = DisplaySlot.SIDEBAR
score.forEach {
objective.getScore(it.first).score = it.second
}
return scoreboard
}
fun Player.removeScoreboard() {
this.scoreboard = Bukkit.getScoreboardManager().newScoreboard
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy