Home›Java›Mods›ScriptAgent4Bukkit
ModsJava

ScriptAgent4Bukkit

Java mod listed for Minecraft 1.13. Download on the author's site.

⬇ Download on Spigot
Below is copy from README_en.md(recommand see it in repository )

一个强大的脚本插件,基于kts定义的DSL(中文README见 这 )
A powerful script plugin for kts(for english README see me )
features
Install This Plugin
  1. Download the jar, see Download badge
  2. Install the plugin in server
  3. Install the scripts and place them (files and folders in /src) directly into the plugin configuration directory (plugins/ScriptAgent/)
Base Commands /ScriptAgent(/sa)
How to develop scripts
  1. Copy this repository (or configure gradle yourself, see build.gradle.kts)
  2. Import the project in IDEA (recommended to import as Project to avoid interference)
  3. Synchronous Gradle
Directory Structure
Script properties
Common properties
Features of both scripts
Code (Text):

@file:ImportByClass("org.bukkit.Bukkit") //Import a loaded library (often dependent on other plugins)
//Import Maven dependencies (automatic download when can't find the cache , the dependencies will not be resolved)
@file:MavenDepends("de.tr7zw:item-nbt-api:2.2.0","https://repo.codemc.org/repository/maven-public/")
@file:ImportScript("") //Import other source code (often refer to the library outside the module library, the same life cycle as the script)
//Some attributes
name.set("SuperItem 模块")//Set current script name (for display purposes only)
val enabled:Boolean
sourceFile.get()//Get the current script source file (not recommended for abuse)
//Life cycle
onEnable{}
onDisable{}
 
init.kts(Module definition script)
Mainly responsible for extending the definition of subscripts and providing custom DSL
Can be extended using extension functions (attributes) and DSLKey
Within the lifecycle function, register or clean up for subscripts
Code (Text):

import cf.wayzer.script_agent.bukkit.Helper.baseConfig
import cf.wayzer.script_agent.bukkit.Helper.exportClass
addLibraryByClass("de.tr7zw.changeme.nbtapi.NBTItem")//Similar to ImportByClass, targeted for subscripts
addLibrary(File("xxxx"))//Import library files for subscripts
addLibraryByName("xxxx")//Provide names to find dependent libraries, for example: kotlin-stdlib
addDefaultImport("superitem.lib.*")//Add default import, no need for subscript import(cooperate with extension functions)
exportClass(SuperItemEvent::class.java)//Exposing classes to the Bukkit shared classpath (not recommended for the time being)
baseConfig()//Some basic extensions for Bukkit
generateHelper()//Generate metadata (runtime)

children.get() //Get all subscript instances
//Lifecycle functions related to subscripts
onBeforeContentEnable{script-> }
onAfterContentEnable{script-> }
onBeforeContentDisable{script-> }
onAfterContentDisable{script-> }
 
content.kts(Module content script)
The main bearer of business logic
Code (Text):

module.get() //Get instance of module definition script (not recommended for abuse)
//interfaces for internals
import cf.wayzer.script_agent.bukkit.Manager
Manager.pluginMain //Get plugin class instance (required by some Bukkit interfaces)(not recommended for abuse)
Manager.scriptManager //Get Script Manager(not recommended for abuse)
//Bukkit basic extensions
this.logger
this.PlaceHoldApi //Useful for sharing variables or exposing function interfaces across the entire plugin(don't expose classes out of lifecycle)
command(name,description,usage="",aliases=emptyList(),sub=true){sender,arg->} //Register command (sub means subCommand which is registered under /sa)
listen<Event>{e-> } //listen to Event
registerAsyncTask(name){firstRun->} //Register asynchronous tasks, the plugin manages an independent thread to run, and it is not allowed to directly access the Bukkit interface
//Helper function
createBukkitTask{ "DoSomething" } //Create Bukkit Task, need to start manually
getScheduleTask(name).start(param) //Corresponds to registerAsyncTask
 
Precautions
  1. After reloading the script, the same class is not necessarily the same, pay attention to controlling the life cycle
    If you need similar operations, you can set up an abstract interface to store variables in a longer life cycle(less frequent reloading)
Existing modules
copyright
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

ScriptAgent4Bukkit is a free Minecraft Java mod. Compatible with Minecraft 1.13. Downloaded 123 times (via Spigot). Download it and open it directly in the game.

Explore more