
walkmc.hologram.api.TextLine.kt Maven / Gradle / Ivy
package walkmc.hologram.api
import org.bukkit.entity.*
import walkmc.collections.*
import walkmc.hologram.entity.*
/**
* Represents a text line of a hologram.
*/
interface TextLine : Line {
/**
* The NMS entity holding this line.
*/
override val holder: EntityHologram
/**
* The bukkit entity holding this line.
*/
override val holderEntity: ArmorStand
/**
* All text options that this line can display.
*/
var options: IndexList
/**
* Returns if this lines has a children line.
*/
override val hasOptions: Boolean
get() = options.isNotEmpty()
/**
* Changes the current line display of this hologram line by the specified [line].
*/
fun changeDisplay(line: String) {
holder.customName = line
}
/**
* Changes the current line display of this hologram line
* by the specified [line] for only [player].
*/
fun changeDisplayFor(player: Player, line: String) {
holder.setCustomNameTo(player, line)
}
/**
* Gets a option from this text line by the specified [index].
*/
fun getOption(index: Int): String = options[index]
/**
* Adds a [option] in the last position of this text line.
*/
fun addOption(option: String) = options.addLast(option)
/**
* Adds a [option] in the first position of this text line.
*/
fun addOptionFirst(option: String) = options.addFirst(option)
/**
* Removes a option from this text line in the specified [index].
*/
fun removeOption(index: Int) {
try {
options.removeAt(index)
} catch (ex: Exception) {
}
}
/**
* Sets a [option] in the specified [index] in this text line.
*/
fun setOption(index: Int, option: String) {
try {
options[index] = option
} catch (ex: Exception) {
}
}
/**
* Gets the current displaying option.
*/
fun currentOption() = options.current()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy