Introducing XLIB!

XLIB simplifies plugin development for Minecraft for beginner developers using Kotlin. The library is designed so that developers don't have to worry about certain functions and can create and implement their ideas.

Installation

Choose the module you need

(You will need to install the XLIB plugin on your server or implement it in your plugin.)
ModuleDescription
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.

Add to build.gradle.kts

repositories {
    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.

Examples

registerListeners
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")
}

Project members

AlexTheGoood

Member

Details

Licensed Apache-2.0
Published a month ago
Updated 16 days ago