Added sending messages to all online players

This commit is contained in:
5vl 2022-11-21 01:18:37 +01:00
parent adc71d269a
commit ce24441a8c
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package me.fivevl.betterspigot
/**
* @author 5vl
* @since 0.0.1
*/
object BetterData {
}

View File

@ -0,0 +1,24 @@
package me.fivevl.betterspigot
/**
* @author 5vl
* @since 0.0.1
*/
object BetterPlayers {
/**
* Send a message to all players on the server
* @param message The message to send to all players
* @sample BetterPlayers.sendAllMessage("Hello, world!")
*/
fun sendAllMessage(message: String) {
BetterSpigot.instance.server.onlinePlayers.forEach { it.sendMessage(message) }
}
/**
* Send a message to all players on the server that have a specified permission
* @param message The message to send to all players
* @param permission Checks if player has this permission
*/
fun sendAllMessage(message: String, permission: String) {
BetterSpigot.instance.server.onlinePlayers.forEach { if (it.hasPermission(permission)) it.sendMessage(message) }
}
}