SkillAgentSearch skills...

KotlinScript

Kotlin Scripting host for Minecraft plugins

Install / Use

/learn @DrZoddiak/KotlinScript
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

KotlinScript

KotlinScript is a Sponge plugin that acts as a scripting-host.

This means that Kotlin style scripts can make use of the Spongepowered API.

Wanting to get started? Read our wiki!

What does a script look like?

A script simply needs the file extension of .plugin.kts

You can find many example scripts here; however, a simple example:

import me.zodd.*
import net.kyori.adventure.text.Component

//Without context scripts will execute during construction
Logger.info("Hello Plugin Construction Event")

//Wrapper functions are provided to register events
onServerStarted {
    Logger.info("Hello Server Started Event")
}

//Sample first join message
onPlayerJoin {
    val player = player()
    if (!player.hasPlayedBefore()) {
        player.sendMessage(Component.text("Hello ${player.displayName()}"))
        /*
        Multi-line comments are supported
        
        Returns for events (if used) should use return flags as below
        */
        return@onPlayerJoin
    }
    Logger.info("${player.name()} - ${player.firstJoined()}")
}

How could I possibly script without any auto-completion!?

No need fear! While you can script with a simple text editor you may find that text completion and code suggestions is much easier!

All you need to do is copy the KotlinScriptingExampleRepo, create files with the proper file extension, and start scripting!

Related Skills

View on GitHub
GitHub Stars4
CategoryDevelopment
Updated1y ago
Forks0

Languages

Kotlin

Security Score

55/100

Audited on Nov 13, 2024

No findings