? MC-JS - Minecraft JavaScript 插件系统
使用 JavaScript 编写 Minecraft 服务器插件——无需 Java!
MC-JS 是一个强大的插件系统,允许你使用现代 JavaScript (ES6+) 而非 Java 来开发服务器插件。非常适合已经掌握 JavaScript 的开发者,或者希望在不学习 Java 的情况下快速创建插件的用户。
✨ 主要功能
? 核心能力
- ? 完整的 JavaScript 支持 - 使用 Rhino 引擎以现代 JavaScript 开发插件
- ⚡ 热重载 - 无需重启服务器即可重新加载插件 (
/jsreload)
- ? 完整的 API 访问 - 可访问几乎所有 Bukkit/Spigot/Paper API 功能
- ? 事件系统 - 注册监听器以响应任何 Minecraft 事件,并支持优先级设置
- ? 命令系统 - 创建自定义命令,完全支持 Tab 补全
- ⏰ 任务调度 - 同步和异步任务调度
- ? 库存管理 - 使用标准 Bukkit 库存(9-54 个槽位)创建和管理自定义 GUI 菜单,支持点击处理器
- ?️ 数据库支持 - 内置 SQLite 数据库操作(INSERT, UPDATE, DELETE, SELECT)
- ? HTTP 请求 - 发起 HTTP GET/POST 请求 (
api.network.httpGet / api.network.httpPost)
- ? 加密 - MD5、SHA256、Base64 编码/解码
- ? 文件 I/O - 支持 YAML、JSON 和文本文件
- ?️ 持久化数据 - 跨重启保留的玩家专属存储、套装、价格和冷却时间 (
api.systems)
- ⏱️ 冷却系统 - 内置玩家专属冷却时间 (
api.systems.claimCooldown / cooldownRemaining)
- ⚙️ 配置系统 - 每个插件独立的配置文件 (YAML)
- ? 世界管理 - 控制天气、时间、世界边界和爆炸效果
- ? 实体管理 - 生成、控制和自定义实体
- ? 玩家管理 - 封禁、踢出、传送、生命值、饥饿值和游戏模式
?️ 高级功能
- ? 粒子效果 - 通过字符串或枚举生成粒子效果
- ? 声音系统 - 在特定位置或向特定玩家播放声音
- ? 计分板系统 - 创建和管理计分板、队伍和目标
- ? 物品操作 - 创建、修改和管理带有自定义名称和描述的物品
- ? 权限系统 - 检查和管理玩家权限
- ? 颜色支持 - Minecraft 颜色代码和格式化实用工具
- ? HTTP 集成 - 进行外部 API 调用和网络请求
- ? 经济集成 - 支持 Vault 经济系统 (
api.vault)
? 安装
要求
- Minecraft Server: Paper 26.1 或更高版本(推荐:Paper)
- Java:25 或更高版本
- Minecraft Version:26.1
步骤
- 从 Releases 页面下载最新版本
- 将 JAR 文件放置在服务器的
plugins/ 文件夹中
- 启动或重启服务器
- 在
plugins/MC-JS/js-plugins/ 目录中创建 JS 插件
插件将在首次运行时自动创建 js-plugins 目录并复制一个示例插件。
? 快速开始
创建你的第一个插件
- 导航到
plugins/MC-JS/js-plugins/ 目录
- 创建一个新文件,扩展名为
.js(例如 myplugin.js)
- 添加以下代码:
var pluginInfo = {
name: "My First Plugin",
version: "1.0.0",
author: "YourName",
description: "My awesome plugin!"
};
function onEnable() {
logger.info("My plugin is enabled!");
// Register a command
api.registerCommand("hello", "Say hello", "/hello", function(sender, args) {
api.sendMessage(sender, "&aHello from JavaScript!");
return true;
});
```javascript
// 注册事件
api.registerEvent("player.PlayerJoinEvent", function(event) {
var player = event.getPlayer();
api.sendMessage(player, "&6欢迎加入服务器!");
});
}
function onDisable() {
logger.info("我的插件已禁用!");
}
this.onEnable = onEnable;
this.onDisable = onDisable;
this.pluginInfo = pluginInfo;
- 保存文件 - 插件将在服务器启动时自动加载,或者使用
/jsreload 进行重载
- 测试命令 - 在游戏中或控制台输入
/hello
- 检查控制台 - 查找 "My plugin is enabled!" 消息
? 提示: 使用 /jslist 查看所有已加载的 JavaScript 插件,使用 /jsreload <插件> 重载特定插件。
?️ Web Dashboard & Block Editor
MC-JS 自带一个完整的基于 Web 的 插件工作室 —— 无需单独的 Node 进程,所有编辑器资源(CodeMirror、Blockly)均从 JAR 包本地提供。
访问
在游戏中运行 /mjs dashboard(权限 mcjs.dashboard;默认情况下,操作员和拥有 mcjs.admin 权限的玩家具备此权限)以获取一次性登录链接。在浏览器中打开该链接,然后使用同一玩家执行显示的 /mjs dashboard <验证代码> 命令以授予访问权限。
默认监听地址为 127.0.0.1:8765——仅在服务器本地可达。如需远程访问,请在该端口前配置 HTTPS 反向代理,并将代理地址设置为 config.yml 中的 dashboard.public-url。链接默认 5 分钟后过期,会话 30 分钟后过期;登出、退出游戏或服务器重启时将撤销访问权限。
编辑器功能
- 在
plugins/MC-JS/js-plugins/ 中创建、搜索、打开、保存、启动、停止和删除插件
- JavaScript 编辑器,支持语法高亮、行号、搜索、缩进、撤销/重做、API 建议以及 Ctrl+S 快捷键
- 语法检查使用与服务器相同的 Rhino 版本——检查和保存操作不会执行您的代码
- 拖拽式积木编辑器 (Blockly),涵盖生命周期事件、玩家事件、命令与权限、消息、标题、物品、玩家数值、音效、传送、计时器、条件判断、循环、变量、函数、文本、列表及持久化配置值
- 开箱即用的完整可编辑积木系统:金币商店、每日礼包、挖矿任务和玩家家园,同时提供欢迎界面、命令和空白项目模板
- 支持积木搜索、流程导航器、自动排列、实时连接诊断以及分步构建指南
- 支持 JavaScript 和完整的
.mcjs.json 积木项目的导入/导出
构建完整系统
模板使用普通的可编辑积木——包括命令和可复用函数:
| 系统 |
命令 |
功能说明 |
| Coins shop |
/shop, /coins |
3 行菜单,显示欢迎余额,钻石购买需资金 + 背包检查 |
| Daily kit |
/kit, /kits |
可复用的礼包函数,24 小时重启安全冷却,完整背包处理 |
| Mining quest |
/quest |
侧边栏进度,挖掘 10 次石头 → 奖励钻石 + 任务金币,取消的挖掘不计入 |
| Player homes |
/sethome, /home |
保存世界、坐标和朝向,传送带有 10 秒冷却 |
玩家数据(按 UUID)和金币在重启后保留在 configs/<plugin-id>.yml 中。每个插件拥有独立的数据和货币——此存储机制不是 Vault 经济系统。菜单槽位从 0 开始,每行 9 个;按钮可以打开另一个菜单或调用任何可复用函数。
注意: 积木数据存储在 .dashboard/<name>.json 中,位于对应 .js 文件旁边。如果 JavaScript 文件被外部修改,仪表盘会将其作为源代码打开,以防止旧的积木静默覆盖您的更改。
? 可用对象
以下对象在所有 JavaScript 插件中自动可用:
| 对象 |
描述 |
用法 |
api |
完整的 JS API 包装器 - 所有操作的主要接口 |
api.registerCommand(...) |
server |
Minecraft 服务器实例 |
server.getOnlinePlayers() |
plugin |
主插件实例 |
plugin.getName() |
logger |
插件日志记录器 |
logger.info("Message") |
scheduler |
服务器调度器 |
scheduler.runTask(...) |
Bukkit |
直接 Bukkit API 访问 |
Bukkit.getServer() |
? 命令
| 命令 |
描述 |
权限 |
/mjs dashboard |
打开并验证 MC-JS 插件编辑器 |
mcjs.dashboard |
/jsreload |
重载所有 JS 插件 |
mcjs.admin |
/jsreload <plugin> |
重载特定插件 |
mcjs.admin |
/jslist |
列出所有已加载的 JS 插件 |
mcjs.admin |
/jsconfig |
查看或重载插件配置 |
mcjs.admin |
? 文档
? 完整文档:访问我们的完整文档网站以获取详细的 API 参考、示例和指南。
? 示例应用
- Welcome Plugins - 通过消息、标题和音效欢迎玩家
- Statistics Systems - 使用 SQLite 数据库跟踪玩家统计数据
- Custom GUI Menus - 使用标准 Bukkit 库存创建交互式菜单,支持自定义布局和点击处理程序
- Mini-Games - 通过事件处理开发简单游戏
- Utility Plugins - 创建有用的工具和命令
- Integration Plugins - 将服务器与外部 API 连接
?️ 技术细节
- JavaScript 引擎: Rhino (Mozilla)
- MC-JS 版本: 2.1.0
- API 版本: 26.1
- 兼容性: Paper(Vault 为可选依赖,软依赖)
- 许可证: MIT
? 支持
? 许可证
本项目遵循 MIT 许可证 - 详情请参阅 LICENSE 文件。
为 Minecraft 社区 ❤️ 打造
? MC-JS - JavaScript Plugin System for Minecraft
Write Minecraft Server Plugins in JavaScript - No Java Required!
MC-JS is a powerful plugin system that allows you to develop server plugins using modern JavaScript (ES6+) instead of Java. Perfect for developers who already know JavaScript or want to quickly create plugins without having to learn Java.
✨ Key Features
? Core Capabilities
- ? Full JavaScript Support - Develop plugins in modern JavaScript using the Rhino Engine
- ⚡ Hot Reload - Reload plugins without server restart (
/jsreload)
- ? Complete API Access - Access to virtually all Bukkit/Spigot/Paper API functions
- ? Event System - Register listeners for any Minecraft event with priority support
- ? Command System - Create custom commands with full tab completion support
- ⏰ Task Scheduling - Synchronous and asynchronous task scheduling
- ? Inventory Management - Create and manage custom GUI menus using standard Bukkit inventories (9-54 slots) with click handlers
- ?️ Database Support - Built-in SQLite database operations (INSERT, UPDATE, DELETE, SELECT)
- ? HTTP Requests - Make HTTP GET/POST requests (
api.network.httpGet / api.network.httpPost)
- ? Encryption - MD5, SHA256, Base64 encoding/decoding
- ? File I/O - YAML, JSON, and text file support
- ?️ Persistent Data - Per-player storage, kits, prices and cooldowns that survive restarts (
api.systems)
- ⏱️ Cooldown System - Built-in per-player cooldowns (
api.systems.claimCooldown / cooldownRemaining)
- ⚙️ Config System - Per-plugin configuration files (YAML)
- ? World Management - Control weather, time, world border, explosions
- ? Entity Management - Spawn, control, and customize entities
- ? Player Management - Ban, kick, teleport, health, food, gamemode
?️ Advanced Features
- ? Particle Effects - Spawn particles with string or enum support
- ? Sound System - Play sounds at locations or for players
- ? Scoreboard System - Create and manage scoreboards, teams, objectives
- ? Item Manipulation - Create, modify, and manage items with custom names and lore
- ? Permission System - Check and manage player permissions
- ? Color Support - Minecraft color codes and formatting utilities
- ? HTTP Integration - Make external API calls and web requests
- ? Economy Integration - Vault economy support for server economies (
api.vault)
? Installation
Requirements
- Minecraft Server: Paper 26.1 or higher (recommended: Paper)
- Java: Version 25 or higher
- Minecraft Version: 26.1
Steps
- Download the latest release from the Releases page
- Place the JAR file in your server's
plugins/ folder
- Start or restart your server
- Create JS plugins in
plugins/MC-JS/js-plugins/ directory
The plugin will automatically create the js-plugins directory and copy an example plugin on first run.
? Quick Start
Creating Your First Plugin
- Navigate to
plugins/MC-JS/js-plugins/ directory
- Create a new file with
.js extension (e.g., myplugin.js)
- Add the following code:
var pluginInfo = {
name: "My First Plugin",
version: "1.0.0",
author: "YourName",
description: "My awesome plugin!"
};
function onEnable() {
logger.info("My plugin is enabled!");
// Register a command
api.registerCommand("hello", "Say hello", "/hello", function(sender, args) {
api.sendMessage(sender, "&aHello from JavaScript!");
return true;
});
// Register an event
api.registerEvent("player.PlayerJoinEvent", function(event) {
var player = event.getPlayer();
api.sendMessage(player, "&6Welcome to the server!");
});
}
function onDisable() {
logger.info("My plugin is disabled!");
}
this.onEnable = onEnable;
this.onDisable = onDisable;
this.pluginInfo = pluginInfo;
- Save the file - The plugin will auto-load on server start, or use
/jsreload to reload
- Test your command - Type
/hello in-game or in console
- Check console - Look for "My plugin is enabled!" message
? Tip: Use /jslist to see all loaded JavaScript plugins and /jsreload <plugin> to reload a specific plugin.
?️ Web Dashboard & Block Editor
MC-JS ships with a full web-based Plugin Studio — no separate Node process needed, all editor assets (CodeMirror, Blockly) are served locally from the JAR.
Access
Run /mjs dashboard in-game (permission mcjs.dashboard; operators and mcjs.admin have it by default) to receive a one-time login link. Open that link in your browser, then run the shown /mjs dashboard <verify-code> command with the same player to grant access.
The default listener is 127.0.0.1:8765 — only reachable on the server computer. For remote access, put an HTTPS reverse proxy in front of that port and set its address as dashboard.public-url in config.yml. Links expire after 5 minutes by default, sessions after 30 minutes; access is revoked on sign-out, game quit, or server restart.
Editor Features
- Create, search, open, save, start, stop and delete plugins in
plugins/MC-JS/js-plugins/
- JavaScript editor with syntax highlighting, line numbers, search, indentation, undo/redo, API suggestions and Ctrl+S
- Syntax checking with the same Rhino version the server uses — checking and saving never execute your code
- Drag-and-drop block editor (Blockly) with lifecycle events, player events, commands and permissions, messages, titles, items, player values, sounds, teleportation, timers, conditions, loops, variables, functions, text, lists and persistent configuration values
- Complete, editable block systems out of the box: coins shop, daily kit, mining quest and player homes, plus welcome, command and empty projects
- Block search, flow navigator, auto-arrange, live connection diagnostics and a step-by-step builder guide
- Import/export for JavaScript and complete
.mcjs.json block projects
Building Complete Systems
Templates use normal editable blocks — commands and reusable functions included:
| System |
Commands |
What it shows |
| Coins shop |
/shop, /coins |
3-row menu, welcome balance, diamond purchase with funds + inventory checks |
| Daily kit |
/kit, /kits |
Reusable kit function, 24-hour restart-safe cooldown, full-inventory handling |
| Mining quest |
/quest |
Sidebar progress, 10 stone breaks → diamond + quest coins, cancelled breaks ignored |
| Player homes |
/sethome, /home |
Saved world, coordinates and facing, teleport with 10-second cooldown |
Player data (by UUID) and coins survive restarts in configs/<plugin-id>.yml. Each plugin has its own data and currency — this storage is not a Vault economy. Menu slots start at 0 with 9 per row; buttons can open another menu or call any reusable function.
Note: Block data lives in .dashboard/<name>.json next to each .js file. If the JavaScript changes externally, the dashboard opens it as source so stale blocks can't silently overwrite your changes.
? Available Objects
These objects are automatically available in all JavaScript plugins:
| Object |
Description |
Usage |
api |
Complete JS API wrapper - main interface for all operations |
api.registerCommand(...) |
server |
Minecraft server instance |
server.getOnlinePlayers() |
plugin |
Main plugin instance |
plugin.getName() |
logger |
Plugin logger |
logger.info("Message") |
scheduler |
Server scheduler |
scheduler.runTask(...) |
Bukkit |
Direct Bukkit API access |
Bukkit.getServer() |
? Commands
| Command |
Description |
Permission |
/mjs dashboard |
Open and verify the MC-JS plugin editor |
mcjs.dashboard |
/jsreload |
Reload all JS plugins |
mcjs.admin |
/jsreload <plugin> |
Reload specific plugin |
mcjs.admin |
/jslist |
List all loaded JS plugins |
mcjs.admin |
/jsconfig |
View or reload plugin configuration |
mcjs.admin |
? Documentation
? Full Documentation: Visit our complete documentation website for detailed API reference, examples, and guides.
? Example Applications
- Welcome Plugins - Greet players with messages, titles, and sounds
- Statistics Systems - Track player statistics with SQLite databases
- Custom GUI Menus - Create interactive menus using standard Bukkit inventories with custom layouts and click handlers
- Mini-Games - Develop simple games with event handling
- Utility Plugins - Create helpful tools and commands
- Integration Plugins - Connect your server with external APIs
?️ Technical Details
- JavaScript Engine: Rhino (Mozilla)
- MC-JS Version: 2.1.0
- API Version: 26.1
- Compatibility: Paper (Vault optional, soft-dependency)
- License: MIT
? Support
? License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the Minecraft Community
评论 0
登录后参与评分
还没有评论,来抢沙发吧