Scriptirc - 脚本编译器,将 Java 源代码直接编译为服务器插件并加载。
推荐在测试服务器或开发中的服务器上使用此插件,因为编译后的脚本无需依赖 Scriptirc 即可加载,您可以直接将编译好的插件脚本放入 plugins 目录。
? 简介
Scriptirc 是一款强大的 Bukkit/Spigot 插件,旨在简化插件管理和即时开发流程。如果您曾经希望能够在不重启服务器的情况下编译和修改脚本插件、加载、卸载或重新加载它们,或者想要快速开发和测试简单的功能,那么 Scriptirc 就是为您准备的。
✨ 主要特性
? 动态插件管理 - 在不重启服务器的情况下加载、卸载或重新加载插件
? 即时脚本编译 - 直接将 Java 脚本编译为功能完整的 Bukkit 插件
?️ 数据目录隔离 - 自动为插件脚本创建独立的数据目录
? 无缝集成 - 兼容现有的 Bukkit/Spigot/Paper 环境
? 资源释放 - 卸载插件脚本以完全释放插件资源,解锁 JAR 文件
? 安装说明
下载对应版本的 Scriptirc.jar
将 JAR 文件放置在服务器的 plugins 目录中
重启服务器或使用插件管理器加载插件
插件将自动创建必要的目录结构和配置文件
? 使用方法
Scriptirc 提供直观的命令行系统,让您能够轻松管理插件和脚本:
基本命令(所有命令均可缩写为 /si)
命令 描述
/scriptirc help
/scriptirc load <pulgin name>
/scriptirc unload <pulgin name>
/scriptirc reload <pulgin name>
/scriptirc list
/scriptirc compiler <pulgin name>
/scriptirc sync
/scriptirc profile
插件管理示例
加载名为 TestPlugin 的插件。
/si load TestPlugin
卸载插件
/si unload TestPlugin
重新加载插件(例如更新后)
/si reload TestPlugin
查看已加载的插件列表
/si list
脚本编译示例
编译位于 script_src 目录中的 HelloWorld.java 脚本。
/si compiler HelloWorld
然后加载编译好的插件。
/si load HelloWorld
? 目录结构
安装后,Scriptirc 将创建以下目录结构:
plugins/
└── Scriptirc/
├── config.yml # 插件配置文件
├── plugins/ # 外部插件存储目录
│ └── Data/ # 插件数据目录
├─ script_src/ # 脚本源代码目录 │ ├── script_src/ # 脚本源代码目录
│ ├── HelloWorld.java # 示例脚本
│ └── MathUtil.java # 示例脚本
└─ script_build/ # 临时脚本构建目录
?️ 开发教程 - 创建您的第一个脚本插件
Scriptirc 让插件开发变得极其简单。你只需创建一个 Java 源文件,编译它并加载即可立即使用。以下是开发步骤:
1. 创建脚本文件
在 plugins/Scriptirc/script_src 目录下新建一个 Java 文件,例如 MyFirstPlugin.java。
2. 编写插件代码
以下是一个简单的插件模板:
包名可自定义(尽量使其有意义)
package your.package.name;
```java
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
/**
- @pluginName <插件名称>
- @author <作者>
- @version <版本>
- @description <描述在此行完成所有描述>
- (命令和权限为可选添加)
- [command]<命令1>|描述1[/command]
- [command]<命令2>|描述2[/command]
- [Permission]<限制1>|描述1[/Permission]
- [Permission]<限制2>|描述2[/Permission]
*/
public class MyFirstPlugin extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("插件已启用!");
// 初始化代码
//
}
@Override
public void onDisable() {
getLogger().info("插件已禁用!");
// 卸载/监听器/命令的代码可以放在这里。
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("myfirstcmd")) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("§a你好,这是我的第一个插件命令!");
} else {
sender.sendMessage("此命令只能由玩家执行!");
}
return true;
}
return false;
}
}
强烈推荐使用官方 AI!官方网站
3. 编译并加载你的插件
使用以下命令来编译和加载你的插件:
/si compiler MyFirstPlugin
/si load MyFirstPlugin
就是这么简单!你的插件现在已经在服务器上运行了,无需重启服务器。
重要元数据字段
| 字段 | 必填 | 描述
| VERSION | 是 | 插件版本号
| DESCRIPTION | 是 | 插件描述
| AUTHOR | 是 | 插件作者
| COMMANDS | 否 | 以“命令名称”形式表示的插件命令定义。
| PERMISSIONS | 否 | 以“权限节点”形式表示的权限定义。
⚙️ 配置文件说明
Scriptirc 的配置文件 (config.yml) 允许你自定义插件的行为:
插件自动重载配置
auto-reload.
是否启用自动重载
enabled: true
检查间隔(秒)
check-interval: 5
verbose-logging: false
verbose-logging: false
插件管理设置
plugin-management.
外部插件目录,相对于插件数据文件夹
external-plugins-directory: “plugins”
是否在服务器启动时自动加载外部插件。
load-on-startup: true
是否将外部插件的数据文件夹重定向到 Scriptirc 目录。
redirect-data-folder: true
权限设置
permissions.
管理员权限节点
admin-permission: “scriptirc.admin”
是否仅允许 OP(管理员)使用
op-only: true
日志设置
logging.
日志输出级别:VERBOSE(输出所有日志)、NORMAL(标准输出)、MINIMAL(仅输出关键信息)
level: “MINIMAL”
(如果遇到编译失败,请尝试将日志模式切换为 VERBOSE)
? 常见问题
加载插件后玩家看不到命令怎么办?(存在一个小概率的 bug,将在后续修复)
服务器管理员可以运行命令 /si sync 以将所有命令同步给所有在线玩家。
或者让玩家重新登录服务器。
如果编译脚本时出错该怎么办?
请确保:
Java 代码语法正确无误
包含所有必需的元数据字段(VERSION、DESCRIPTION、AUTHOR)。
服务器正在运行 JDK 而非 JRE(编译需要 JDK)
如何移除动态加载的插件文件?
在使用 /si unload 命令卸载插件时,Scriptirc 会尝试完全释放 JAR 文件,以便将其删除或替换。如果仍然无法删除,可能需要重启服务器。
致谢
有关插件卸载和加载的代码参考了 PlugManX 项目
Scriptirc - script compiler, compiles java source code directly into a server plugin and loads it.
This plugin is recommended for test servers or servers under development because the compiled scripts do not need to rely on Scriptirc to load, you can put the compiled plugin scripts directly into plugins.
? Introduction
Scriptirc is a powerful Bukkit/Spigot plugin designed to simplify plugin management and on-the-fly development processes. If you've ever wanted to be able to compile and modify script plugins, load, unload or reload them without restarting the server, or want to quickly develop and test simple features, Scriptirc is for you.
✨ Key Features
? Dynamic plugin management - load, unload or reload plugins without restarting the server
? On-the-fly script compilation - Compile Java scripts directly into fully functional Bukkit plugins
?️ Data Directory Segregation - Automatically creates separate data directories for plugin scripts
? Seamless Integration - Compatible with existing Bukkit/Spigot/Paper environments
? Resource Release - Uninstall plugin scripts to completely release plugin resources, unlock JAR files
? Installation Instructions
Download the corresponding version of Scriptirc.jar
Place the JAR file in the plugins directory of the server
Restart the server or load the plugin using the plugin manager
The plugin will automatically create the necessary directory structure and configuration files
? Usage
Scriptirc provides an intuitive command system that allows you to easily manage plugins and scripts:
Basic commands (all commands can be abbreviated as /si)
Command Description
/scriptirc help
/scriptirc load <pulgin name>
/scriptirc unload <pulgin name>
/scriptirc reload <pulgin name>
/scriptirc list
/scriptirc compiler <pulgin name>
/scriptirc sync
/scriptirc profile
Plugin management example
Load a plugin named TestPlugin.
/si load TestPlugin
Uninstall the plugin
/si unload TestPlugin
Reload the plugin (e.g. after an update)
/si reload TestPlugin
View list of loaded plugins
/si list
Example of script compilation
Compile the HelloWorld.java script located in the script_src directory.
/si compiler HelloWorld
Then load the compiled plugin.
/si load HelloWorld
? Directory structure
After installation, Scriptirc will create the following directory structure:
plugins/
└── Scriptirc/
├── config.yml # Plugin configuration file
├── plugins/ # External plugin storage directory
│ └── Data/ # Plugin data directory
├─ script_src/ # Script source code directory │ ├── script_src/ # Script source code directory
│ ├── HelloWorld.java # Example scripts
│ └── MathUtil.java # Example Scripts
└─ script_build/ # Temporary script build directory
?️ Development Tutorial - Creating Your First Script Plugin
Scriptirc makes plugin development incredibly easy. All you need to do is create a Java source file, compile it and load it for use immediately. Here are the development steps:
1. Create the script file
Create a new Java file in the plugins/Scriptirc/script_src directory, e.g. MyFirstPlugin.java.
2. Write the plugin code
Below is a simple plugin template:
The package name is customizable (just try to make sense)
package your.package.name;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
/**
* @pluginName <Plugin Name>
* @author <author>
* @version <version>
* @description <Description Complete all descriptions in this line only>
* (Commands and permissions are added optionally)
* [command]<command1>|description1[/command]
* [command]<command2>|description2[/command]
* [Permission]<limit1>|description1[/Permission]
* [Permission]<limit2>|description2[/Permission]
*/
public class MyFirstPlugin extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("Plugin enabled!");
// Initializing Code
//
}
@Override
public void onDisable() {
getLogger().info("Plugin disabled!");
// The code for the unload / listener / command can be placed here.
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("myfirstcmd")) {
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendMessage("§aHello, this is my first plugin command!");
} else {
sender.sendMessage("This command can only be executed by the player!");
}
return true;
}
return false;
}
}
Official AI is recommended!!! Official Website
3. Compiling and loading your plugin
Use the following commands to compile and load your plugin:
/si compiler MyFirstPlugin
/si load MyFirstPlugin
It's as simple as that! Your plugin is now running on the server, no need to restart the server.
Important metadata fields
|Fields |Required |Description
|VERSION |YES |Plugin version number
|DESCRIPTION |YES |Plugin Description
|AUTHOR |YES |Plugin Author
|COMMANDS |No |Plugin command definitions in the form of “command name”.
|PERMISSIONS |No |Permission definitions in the form of “permission nodes”.
⚙️ Configuration file description
Scriptirc's configuration file (config.yml) allows you to customize the behavior of the plugin:
Plugin auto-reload configuration
auto-reload.
Whether to enable auto-reload
enabled: true
Check interval (seconds)
check-interval: 5
verbose-logging: false
verbose-logging: false
Plugin management settings
plugin-management.
External plugins directory, relative to the plugin data folder
external-plugins-directory: “plugins”
Whether to automatically load external plugins on server startup.
load-on-startup: true
Whether to redirect the data folder of external plugins to the Scriptirc directory.
redirect-data-folder: true
Permission settings
permissions.
Administrator permissions node
admin-permission: “scriptirc.admin”
Whether to allow OP use only
op-only: true
Logging settings
logging.
logging output level: VERBOSE (output all logs), NORMAL (standard output), MINIMAL (output only key information)
level: “MINIMAL”
(If you encounter a compilation failure, try switching the logging mode to VERBOSE)
? Frequently Asked Questions
What if the player can't see the commands after loading the plugin? (There is a slight possibility of a bug that will be fixed later)
The server administrator can run the command /si sync to synchronize commands to all online players.
Or have players log back into the server.
What should I do if I get an error compiling the script?
Make sure:
Java code is syntactically correct
All required metadata fields (VERSION, DESCRIPTION, AUTHOR) are included.
The server is running on JDK and not JRE (JDK is required for compilation)
How to remove dynamically loaded plugin files?
When unloading a plugin using the /si unload command, Scriptirc tries to completely free the JAR file so that it can be deleted or replaced. If it still cannot be deleted, it may be necessary to restart the server.
Recognize
There is code related to plugin unload loading I refer to the PlugManX project
评论 0
登录后参与评分
还没有评论,来抢沙发吧