Complete API reference for the OyasaiUtilities plugin utility functions.
String extensions
color()
Convert color codes to Minecraft color format.
Character to convert to § (section sign).
String with converted color codes.
val colored = "&aHello &bWorld".color()
// Result: "§aHello §bWorld"
val customChar = "#aHello #bWorld".color('#')
// Result: "§aHello §bWorld"
unColor()
Remove all color codes from a string.
String with color codes removed.
val plain = "§aColored §btext".unColor()
// Result: "Colored text"
ItemStack extensions
addText()
Add display name and lore to an ItemStack with automatic color code conversion.
Display name for the item (nullable).
List of lore lines to add to the item.
Modified ItemStack with display name and lore.
val item = ItemStack(Material.DIAMOND_SWORD)
.addText(
"&6Legendary Sword",
mutableListOf(
"&7A powerful weapon",
"&8Damage: +10",
"&8Forged in fire"
)
)
allHide()
Add all ItemFlag values to hide item attributes.
Modified ItemStack with all flags hidden.
val item = ItemStack(Material.DIAMOND_SWORD)
.allHide()
// Hides: enchantments, attributes, unbreakable, destroys, placed_on, potion_effects, dye
Plugin access
plugin
Lazy-initialized reference to the main plugin instance.
The OyasaiUtilities plugin instance.
import icu.oyasai.utilities.OyasaiUtilities
val pluginInstance = OyasaiUtilities.plugin
val logger = pluginInstance.logger
Usage example
Complete example using OyasaiUtilities in your plugin:
import icu.oyasai.utilities.OyasaiUtilities.color
import icu.oyasai.utilities.OyasaiUtilities.addText
import icu.oyasai.utilities.OyasaiUtilities.allHide
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
class MyPlugin : JavaPlugin() {
fun createCustomItem(): ItemStack {
return ItemStack(Material.DIAMOND_SWORD)
.addText(
"&6&lLegendary Sword",
mutableListOf(
"&7A sword of immense power",
"",
"&eAbilities:",
"&7• Lightning Strike",
"&7• Fire Aspect III",
"",
"&8Forged by ancient smiths"
)
)
.allHide()
}
fun sendColoredMessage(player: Player, message: String) {
player.sendMessage(message.color())
}
}
Dependencies
To use OyasaiUtilities in your plugin:
// build.gradle.kts
dependencies {
compileOnly(files("path/to/OyasaiUtilities.jar"))
}
# plugin.yml
depend:
- OyasaiUtilities