LSE TypeScript 模板是一个用于创建 LeviLamina LSE 的现代化 TypeScript 开发模板。它提供了完整的开发工具链,支持最新的 TypeScript 语法和 ES 模块,让您能够快速开发高性能的 Minecraft 服务器插件。
GitHub 仓库: https://github.com/dmblpck/lse-typescript-template
- 🚀 现代化开发体验:使用 TypeScript 5.9+ 和 ES 模块
- ⚡ 快速构建:基于 Rolldown 的高性能构建工具
- 🔧 完整类型支持:内置
@levimc-lse/types类型定义 - 📦 自动打包:将多个模块自动打包为单个文件
- 🔄 热重载开发:支持开发模式下的文件监听和自动重建
- 🎯 代码提示:完整的 IntelliSense 和自动补全支持
- 📁 模块化结构:清晰的目录结构和模块分离
- Node.js 18+ 或更高版本
- pnpm 10.23.0+(推荐)或 npm / yarn
- LeviLamina 服务器环境
-
克隆仓库
git clone https://github.com/dmblpck/lse-typescript-template.git cd lse-typescript-template -
安装依赖
pnpm install
或使用 npm:
npm install
-
开发模式
pnpm dev
这将启动开发服务器,监听文件变化并自动重建。
-
构建项目
pnpm build
构建产物将输出到
dist/bundle.js。
lse-typescript-template/
├── src/
│ ├── index.ts # 主入口文件
│ └── config.ts # 配置文件(可选)
├── dist/ # 构建输出目录
├── rolldown.config.ts # 构建配置
├── tsconfig.json # TypeScript 配置
├── package.json # 项目依赖和脚本
└── README.md # 项目文档
在 src/index.ts 中,您可以直接使用 mc、ll 等全局模块,完全支持 TypeScript 类型提示:
// 监听玩家加入事件
mc.listen('onJoin', (player) => {
log(`${player.name} 加入了服务器!`)
player.sendToast(`欢迎来到服务器,${player.name}!`, '玩得开心!')
})您可以使用 ES 模块语法导入其他文件:
import { config } from './config'
// 使用导入的配置
log(`服务器名称: ${config.serverName}`)- TypeScript 配置 (
tsconfig.json):已配置为支持 LeviLamina LSE 开发,目标为 ES2024,使用 CommonJS 模块 - 构建配置 (
rolldown.config.ts):使用 Rolldown 打包,输入为src/index.ts,输出为dist/bundle.js(CommonJS 格式) - 环境变量:支持
.env文件(通过 dotenv 依赖)
- 开始开发:运行
pnpm dev进入开发模式 - 编写代码:在
src/目录下创建新的 TypeScript 文件 - 测试代码:将构建后的
dist/bundle.js复制到 LeviLamina 服务器的插件目录 - 调试:查看服务器日志以调试您的插件
- 构建发布:运行
pnpm build生成最终版本
pnpm dev- 启动开发模式,监听文件变化并自动重建pnpm build- 构建生产版本到dist/bundle.jspnpm install- 安装项目依赖
pnpm add <package-name>项目已包含 @levimc-lse/types,提供了完整的 Minecraft 服务器 API 类型定义。您可以在代码中直接使用这些类型,获得完整的代码提示。
如果需要修改构建配置,可以编辑 rolldown.config.ts 文件:
import { defineConfig } from 'rolldown'
export default defineConfig({
input: 'src/index.ts',
output: {
file: 'dist/bundle.js',
format: 'cjs',
sourcemap: true, // 启用源映射以方便调试
},
external: ['ll', 'mc'],
platform: 'node',
tsconfig: './tsconfig.json',
})创建 .env 文件来配置环境变量:
SERVER_NAME=My Minecraft Server
DEBUG_MODE=true然后在代码中使用:
import 'dotenv/config'
console.log(process.env.SERVER_NAME)我们欢迎任何形式的贡献!请遵循以下步骤:
- Fork 本仓库
- 创建功能分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 开启一个 Pull Request
- 遵循现有的代码风格
- 添加适当的注释和文档
- 确保代码通过 TypeScript 编译
- 更新相关文档(包括本 README)
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
LSE TypeScript Template is a modern TypeScript development template for creating LeviLamina LSE (LiteLoaderBDS Extension). It provides a complete development toolchain, supporting the latest TypeScript syntax and ES modules, enabling you to quickly develop high-performance Minecraft server plugins.
GitHub Repository: https://github.com/dmblpck/lse-typescript-template
- 🚀 Modern Development Experience: TypeScript 5.9+ and ES modules
- ⚡ Fast Building: High-performance build tool based on Rolldown
- 🔧 Full Type Support: Built-in
@levimc-lse/typestype definitions - 📦 Auto Packaging: Automatically packages multiple modules into a single file
- 🔄 Hot Reload Development: File watching and auto-rebuild in development mode
- 🎯 Code Intelligence: Complete IntelliSense and auto-completion support
- 📁 Modular Structure: Clear directory structure and module separation
- Node.js 18+ or higher
- pnpm 10.23.0+ (recommended) or npm / yarn
- LeviLamina server environment
-
Clone the repository
git clone https://github.com/dmblpck/lse-typescript-template.git cd lse-typescript-template -
Install dependencies
pnpm install
or using npm:
npm install
-
Development mode
pnpm dev
This will start the development server, watching for file changes and auto-rebuilding.
-
Build the project
pnpm build
The build output will be in
dist/bundle.js.
lse-typescript-template/
├── src/
│ ├── index.ts # Main entry file
│ └── config.ts # Configuration file (optional)
├── dist/ # Build output directory
├── rolldown.config.ts # Build configuration
├── tsconfig.json # TypeScript configuration
├── package.json # Project dependencies and scripts
└── README.md # Project documentation
In src/index.ts, you can directly use global modules like mc, ll with full TypeScript type hints:
// Listen to player join event
mc.listen('onJoin', (player) => {
log(`${player.name} has joined the server!`)
player.sendToast(`Welcome to the server, ${player.name}!`, 'Enjoy playing!')
})You can use ES module syntax to import other files:
import { config } from './config'
// Use imported configuration
log(`Server name: ${config.serverName}`)- TypeScript Configuration (
tsconfig.json): Configured for LeviLamina LSE development, targeting ES2024, using CommonJS modules - Build Configuration (
rolldown.config.ts): Uses Rolldown bundler, input issrc/index.ts, output isdist/bundle.js(CommonJS format) - Environment Variables: Supports
.envfiles (via dotenv dependency)
- Start Development: Run
pnpm devto enter development mode - Write Code: Create new TypeScript files in the
src/directory - Test Code: Copy the built
dist/bundle.jsto your LeviLamina server's plugin directory - Debugging: Check server logs to debug your plugin
- Build for Release: Run
pnpm buildto generate the final version
pnpm dev- Start development mode with file watching and auto-rebuildpnpm build- Build production version todist/bundle.jspnpm install- Install project dependencies
pnpm add <package-name>The project includes @levimc-lse/types, providing complete Minecraft server API type definitions. You can use these types directly in your code for full code intelligence.
If you need to modify the build configuration, edit the rolldown.config.ts file:
import { defineConfig } from 'rolldown'
export default defineConfig({
input: 'src/index.ts',
output: {
file: 'dist/bundle.js',
format: 'cjs',
sourcemap: true, // Enable source maps for easier debugging
},
external: ['ll', 'mc'],
platform: 'node',
tsconfig: './tsconfig.json',
})Create a .env file to configure environment variables:
SERVER_NAME=My Minecraft Server
DEBUG_MODE=trueThen use in your code:
import 'dotenv/config'
console.log(process.env.SERVER_NAME)We welcome contributions of all kinds! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Add appropriate comments and documentation
- Ensure code passes TypeScript compilation
- Update relevant documentation (including this README)
This project is licensed under the MIT License - see the LICENSE file for details.
- Submit an Issue to report problems or request features
- Check the Discussions to join conversations
- Contact the maintainer directly via the GitHub repository
Happy Coding! 🚀