Applied kotlin style conventions
This commit is contained in:
@@ -6,27 +6,27 @@ import org.bukkit.command.CommandSender
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.print(text: String, plugin: Plugin? = KSpigotMainInstance)
|
||||
= printColoredPrefix(text, ChatColor.RESET, plugin?.name ?: "INFO", ChatColor.GRAY)
|
||||
fun CommandSender.print(text: String, plugin: Plugin? = KSpigotMainInstance) =
|
||||
printColoredPrefix(text, ChatColor.RESET, plugin?.name ?: "INFO", ChatColor.GRAY)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.info(text: String, plugin: Plugin? = KSpigotMainInstance)
|
||||
= printColoredPrefix(text, ChatColor.WHITE, plugin?.name ?: "INFO", ChatColor.DARK_AQUA)
|
||||
fun CommandSender.info(text: String, plugin: Plugin? = KSpigotMainInstance) =
|
||||
printColoredPrefix(text, ChatColor.WHITE, plugin?.name ?: "INFO", ChatColor.DARK_AQUA)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.success(text: String, plugin: Plugin? = KSpigotMainInstance)
|
||||
= printColoredPrefix(text, ChatColor.GREEN, plugin?.name ?: "SUCCESS", ChatColor.DARK_AQUA)
|
||||
fun CommandSender.success(text: String, plugin: Plugin? = KSpigotMainInstance) =
|
||||
printColoredPrefix(text, ChatColor.GREEN, plugin?.name ?: "SUCCESS", ChatColor.DARK_AQUA)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.warn(text: String, plugin: Plugin? = KSpigotMainInstance)
|
||||
= printColoredPrefix(text, ChatColor.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", ChatColor.YELLOW)
|
||||
fun CommandSender.warn(text: String, plugin: Plugin? = KSpigotMainInstance) =
|
||||
printColoredPrefix(text, ChatColor.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", ChatColor.YELLOW)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.error(text: String, plugin: Plugin? = KSpigotMainInstance)
|
||||
= printColoredPrefix(text, ChatColor.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", ChatColor.DARK_RED)
|
||||
fun CommandSender.error(text: String, plugin: Plugin? = KSpigotMainInstance) =
|
||||
printColoredPrefix(text, ChatColor.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", ChatColor.DARK_RED)
|
||||
|
||||
/**
|
||||
* Sends the given message and adds the given prefix with the given color to it.
|
||||
*/
|
||||
fun CommandSender.printColoredPrefix(text: String, textColor: ChatColor, prefix: String, prefixColor: ChatColor)
|
||||
= sendMessage("${prefixColor}[${prefix}]${textColor} $text")
|
||||
fun CommandSender.printColoredPrefix(text: String, textColor: ChatColor, prefix: String, prefixColor: ChatColor) =
|
||||
sendMessage("${prefixColor}[${prefix}]${textColor} $text")
|
@@ -43,7 +43,7 @@ fun Damageable.kill() {
|
||||
*/
|
||||
fun LivingEntity.heal() {
|
||||
health = getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value
|
||||
?: throw NullPointerException("The entity does not have a max health value!")
|
||||
?: throw NullPointerException("The entity does not have a max health value!")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,13 @@ fun Location.spawnCleanEntity(entityType: EntityType): Entity? {
|
||||
* @param stay time in ticks for titles to stay
|
||||
* @param fadeOut time in ticks for titles to fade out
|
||||
*/
|
||||
fun Player.title(mainText: String? = null, subText: String? = null, fadeIn: Int = 10, stay: Int = 70, fadeOut: Int = 20) {
|
||||
fun Player.title(
|
||||
mainText: String? = null,
|
||||
subText: String? = null,
|
||||
fadeIn: Int = 10,
|
||||
stay: Int = 70,
|
||||
fadeOut: Int = 20
|
||||
) {
|
||||
sendTitle(mainText, subText, fadeIn, stay, fadeOut)
|
||||
}
|
||||
|
||||
|
@@ -7,5 +7,6 @@ import org.bukkit.World
|
||||
* Assumes that this Location has world data.
|
||||
* If not, an exception will be thrown.
|
||||
*/
|
||||
val Location.worldOrException: World get() = world
|
||||
?: throw NullPointerException("The world of the location is null!")
|
||||
val Location.worldOrException: World
|
||||
get() = world
|
||||
?: throw NullPointerException("The world of the location is null!")
|
Reference in New Issue
Block a user