EternalScript:用于 Minecraft Paper 服务器的 Kotlin 脚本插件
EternalScript 允许你在 Minecraft Paper 服务器上动态加载和管理代码,而无需重启服务器。它支持多种自定义功能,如脚本生命周期管理、事件处理和自定义命令。
命令
以下是 EternalScript 的可用命令:
/es compile:编译并加载配置脚本文件夹中的所有脚本。/es clear:卸载所有当前已加载的脚本。/es config:重新加载插件配置。/es call [script] [function]:调用指定脚本中的函数。/es load [script]:加载特定的脚本文件(例如/es load "/hello.kt")。/es unload [script]:卸载特定的脚本文件(例如/es unload "/hello.kt")。/es list:列出所有当前已加载的脚本。
脚本生命周期
控制脚本的行为,包括在加载时执行初始设置以及在卸载时清理资源。
enable {
// 此代码在脚本加载/启用时运行。
Bukkit.broadcastMessage("Eternal Script: Script loaded!")
}
disable {
// 此代码在脚本卸载/禁用时运行。
Bukkit.broadcastMessage("Eternal Script: Script unloaded!")
}
事件处理
直接在脚本中轻松注册和处理事件,以添加自定义逻辑。
import org.bukkit.Bukkit
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerQuitEvent
event<PlayerJoinEvent> { event ->
Bukkit.broadcastMessage("${event.player.name} joined the server!")
}
event<PlayerQuitEvent> { event ->
Bukkit.broadcastMessage("${event.player.name} left the server.")
}
自定义命令
直接从脚本中定义和注册你自己的游戏内命令。
import org.bukkit.Bukkit
command("test-command") {
// 玩家执行此命令需要此权限。
permission = "eternals.command.test"
executor = { sender, label, args ->
// 此代码在命令执行时运行。
Bukkit.broadcastMessage("Command executed by: ${sender.name}")
}
}
脚本包含/排除规则
控制插件处理哪些脚本。
*.kt | *.kts:包含所有 Kotlin 文件(.kt)和 Kotlin 脚本文件(.kts)。-*/ *.kt | -*.kt:忽略特定的文件夹或文件(例如,排除子文件夹中的脚本或特定文件)。!*/* .kt | !*.kt:同步加载特定的文件夹或文件(例如,在服务器启动时优先于其他脚本处理它们)。
安装
在你的服务器上快速轻松地运行 EternalScript:
- 从 Modrinth 下载 EternalScript 的最新版本。
- 将下载的文件上传到 Minecraft 服务器的
plugins文件夹。 - 启动或重启服务器以加载 EternalScript。
入门指南
通过编写和运行你的第一个 Kotlin 脚本来体验 EternalScript 的强大功能:
- 安装后,将创建一个
plugins/EternalScript/scripts/文件夹。 - 在此
scripts文件夹内编写扩展名为.kt的 Kotlin 脚本文件。 - 从服务器控制台,你可以使用
/es load "/[script].kt"命令加载特定脚本,或使用/es compile加载文件夹内的所有脚本。
简单的“Hello World”示例
在 plugins/EternalScript/scripts/ 文件夹中创建 hello.kt 文件,并输入以下内容:
// plugins/EternalScript/scripts/hello.kt
enable {
Bukkit.broadcastMessage("Hello, world!")
}
然后,从服务器控制台执行 /es load "/hello.kt",你将看到消息出现在游戏聊天中。
EternalScript: A Kotlin Scripting Plugin for Minecraft Paper Servers
EternalScript allows you to dynamically load and manage code at runtime on your Minecraft Paper server without requiring restarts. It supports diverse customization features like script lifecycle management, event handling, and custom commands.
Commands
Here are the available commands for EternalScript:
/es compile: Compiles and loads all scripts within the configured script folder./es clear: Unloads all currently loaded scripts./es config: Reloads the plugin configuration./es call [script] [function]: Calls a function within a specified script./es load [script]: Loads a specific script file (e.g.,/es load "/hello.kt")./es unload [script]: Unloads a specific script file (e.g.,/es unload "/hello.kt")./es list: Lists all currently loaded scripts.
Script Lifecycle
Control how your scripts behave, including performing initial setup when loaded and cleaning up resources when unloaded.
enable {
// This code runs when the script is loaded/enabled.
Bukkit.broadcastMessage("Eternal Script: Script loaded!")
}
disable {
// This code runs when the script is unloaded/disabled.
Bukkit.broadcastMessage("Eternal Script: Script unloaded!")
}
Event Handling
Easily register and handle events directly within your scripts to add custom logic.
import org.bukkit.Bukkit
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerQuitEvent
event<PlayerJoinEvent> { event ->
Bukkit.broadcastMessage("${event.player.name} joined the server!")
}
event<PlayerQuitEvent> { event ->
Bukkit.broadcastMessage("${event.player.name} left the server.")
}
Custom Commands
Define and register your own in-game commands directly from your scripts.
import org.bukkit.Bukkit
command("test-command") {
// Players need this permission to execute the command.
permission = "eternals.command.test"
executor = { sender, label, args ->
// This code runs when the command is executed.
Bukkit.broadcastMessage("Command executed by: ${sender.name}")
}
}
Script Inclusion/Exclusion Rules
Control which scripts the plugin processes.
*.kt | *.kts: Includes all Kotlin files (.kt) and Kotlin script files (.kts).-*/ *.kt | -*.kt: Ignores specific folders or files (e.g., excludes scripts in subfolders or specific files).!*/* .kt | !*.kt: Loads specific folders or files synchronously (e.g., processes them before other scripts at server startup).
Installation
It's quick and easy to get EternalScript up and running on your server:
- Download the latest version of EternalScript from Modrinth.
- Upload the downloaded file to your Minecraft server's
pluginsfolder. - Start or restart your server to load EternalScript.
Getting Started
Experience the power of EternalScript by writing and running your first Kotlin script:
- After installation, a
plugins/EternalScript/scripts/folder will be created. - Write your Kotlin script file with a
.ktextension inside thisscriptsfolder. - From the server console, you can use the
/es load "/[script].kt"command to load a specific script, or/es compileto load all scripts within the folder.
Simple "Hello World" Example
Create a hello.kt file in the plugins/EternalScript/scripts/ folder and enter the following content:
// plugins/EternalScript/scripts/hello.kt
enable {
Bukkit.broadcastMessage("Hello, world!")
}
Then, execute /es load "/hello.kt" from the server console, and you'll see the message appear in the game chat.
下载 EternalScript
下载 EternalScript
下载 EternalScript
下载 EternalScript
下载 EternalScript
下载 EternalScript
下载 EternalScript
下载 EternalScript
更新脚本缓存
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
通过对话框或铁砧界面帮助你的 Anthme
插件
重新定义服务器上的生物运输方式。使用高度可定制的口袋道具,安全地捕获、存储和释放任何实体。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
用于绘制游戏内地图或在浏览器中随探索实时进行地图绘制的实时地图。
评论 0
登录后参与评分
还没有评论,来抢沙发吧