
Utilities to simplify plugin development
| Module | Description |
|---|---|
xlib-all |
Contains all the functions from the modules listed below. |
xlib-adventure |
Contains functions for working with Kyori Adventure Components. |
xlib-config |
(COMING SOON) Contains functions for working with configurations. |
xlib-plugin |
Contains functions that interact with JavaPlugin. |
build.gradle.ktsrepositories {
maven("https://jitpack.io")
}
// If you have installed the XLIB plugin on your server, use 'compileOnly'.
dependencies {
implementation("com.github.alexthegoood.xlib:{module}:{version}")
}
Note: If you want to learn more about the functions and contents of the modules, check the source code.
class ExamplePlugin : JavaPlugin() {
override fun onEnable() {
registerListeners(
MyListener1(),
MyListener2()
)
}
}
class MyListener1 : Listener { /* EventHandlers here */ }
class MyListener2 : Listener { /* EventHandlers here */ }
isFolia
class ExamplePlugin : JavaPlugin() {
override fun onEnable() {
val foliaServer = isFolia() // True if the server work on Folia, otherwise false
}
}
replacePattern
fun myFunction() {
var mycomponent = Component.text("This is #000000")
mycomponent = mycomponent.replacePattern("#([0-9a-fA-F]{6})", "hex color") // Component.text("This is hex color")
}
replaceLiteral
fun myFunction() {
var mycomponent = Component.text("Hello world")
mycomponent = mycomponent.replacePattern("world", "minecraft") // Component.text("Hello minecraft")
}
serialization and deserialization
/*
You can use Serializers enum (Serializers.{PLAIN, LEGACY, MINI, GSON, JSON}).
Example: serialize(Serializers.MINI); deserialize(Serializers.JSON).
By default: Serializers.PLAIN
*/
fun mySerialization() {
val mycomponent = Component.text("Hello world")
val mystring = mycomponent.serialize() // "Hello world"
}
fun myDeserialization() {
val mystring = "Hello world"
val mycomponent = mystring.deserialize() // Component.text("Hello world")
}