? GUIAPI - 终极基于组件的 GUI 框架
是否厌倦了为 Bukkit/Spigot/Paper 插件编写混乱、重复且难以维护的库存代码?
告别手动计算槽位和 spaghetti(一团糟)式的 InventoryClickEvent 监听器吧!
GUIAPI 是一个强大、现代且模块化的 UI 框架,专为 Minecraft 开发者设计。使用可复用组件,通过清晰、声明式的方法构建交互式、动态且响应灵敏的库存 GUI。
✨ 为什么选择 GUIAPI?
- ? 节省数百小时:几分钟内即可构建复杂的 UI,而非数天。
- ? 基于组件的架构:一切皆组件。像搭乐高积木一样使用按钮、面板、文本输入框和滚动条来构建您的 UI。
- ? 嵌套坐标系:将组件分组到
GuiPanel 中。移动整个面板时,其所有子组件会自动跟随移动!再也不用计算绝对库存槽位了。
- ? 实时更新:内置异步更新器让您能够创建实时时钟、实时状态指示器和动画菜单,并在玩家关闭库存时自动清理。
- ? 灵活的部署方式:既可以作为服务器插件使用,也可以直接 Shading(阴影化/打包)到您的 JAR 文件中——由您决定!
- ? 广泛的版本支持:兼容从 Minecraft 1.8 到最新版本的所有服务端,包括 Folia 服务器。
? 高级功能
- ? 聊天文本输入 (
GuiTextInput & GuiListTextInput):提示玩家在聊天中输入文本,内置验证功能和自定义错误消息。
- ? 物品选择器 (
GuiItemChooser):允许玩家点击其库存中的任意物品,将其用作表单的输入源。
- ? 真正的可编辑槽位 (
GuiEditableSlot):一个表现得像真实库存槽位的槽位。支持左键点击、右键点击、Shift+点击、堆叠、交换和拆分。您可以完全控制接受或拒绝物品!
- ? 分页与滚动:通过
GuiListPage、GuiScrollPane(垂直)和 GuiScrollBar(水平)即时处理海量数据,并自动提供上一页/下一页按钮。
- ⚙️ 可配置按钮 (
GuiConfigurableButton):自动生成子 GUI 的按钮,让玩家开箱即用即可编辑键值对!
- ? 现代化格式支持:完整支持十六进制颜色(
&#FF0000)、渐变(<gradient:#ff0000>Text<#00ff00>)以及旧版代码。
- ? NBT 元数据注入:直接从渲染引擎轻松向物品传递自定义数据,无需手动处理原始 NBT 标签。
? 代码自证
看看创建一个功能完整的 UI 有多简单:
// 1. 初始化 GUILibs
GUILibs guiLibs = GUILibs.init(this);
guiLibs.register();
// 2. 创建 GUI
GUI myGui = guiLibs.createGUI("<gradient:#FFD700>Premium Shop<#50C878>", 3);
// 3. 创建按钮
GuiButton button = new GuiButton(myGui, "buy-item", 13);
button.setDisplayItem(guiLibs.getItemBuilder(Material.DIAMOND, 1)
.setDisplayName("&bBuy Diamond")
.addLore("&7Price: $100")
.build());
// 4. 添加行为逻辑
button.addListener((id, event) -> {
event.getWhoClicked().sendMessage("§aPurchase successful!");
return true; // 自动取消点击事件!
});
// 5. 注册并打开
myGui.addComponent(button);
myGui.open(player);
? 安装
GUIAPI 支持两种安装方法。请选择适合您项目的方式:
选项 A:插件依赖(推荐)
将 GUIAPI 作为插件安装在服务器上,并依赖它。这能保持您的 JAR 包小巧。
添加 JitPack 仓库,然后添加依赖项:
Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.downnfalls.guiapi</groupId>
<artifactId>guiapi-plugin</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
Gradle (Groovy):
repositories {
mavenCentral()
maven { url 'https://jitpack.io/' }
}
dependencies {
compileOnly 'com.github.downnfalls.guiapi:guiapi-plugin:VERSION'
}
Gradle (Kotlin DSL):
repositories {
mavenCentral()
maven("https://jitpack.io/")
}
dependencies {
compileOnly("com.github.downnfalls.guiapi:guiapi-plugin:VERSION")
}
plugin.yml:
depend: [GUIAPI]
选项 B:Shade(打包到 JAR 中)
将 GUIAPI 捆绑在您自己的插件内部。无需额外的服务器插件,但您**必须重新定位(relocate)**该包。
使用 artifact com.github.downnfalls.guiapi:guiapi-core,作用域为 compile/implementation,并通过 Maven Shade Plugin 或 Gradle Shadow 配置包的重新定位。
有关详细的 Shading 说明,请参阅完整的 README。
请将 VERSION 替换为 JitPack 上的最新发行版标签。
? 要求
- 服务端: Spigot, Paper, Folia 或任何兼容 Bukkit 的分叉版本 (1.8.8 — 最新版)
- Java: 17+
? 示例与更多信息
没有陡峭的学习曲线!如需完整的代码示例以及如何使用每一项功能的详细指南,请查看我们 GitHub 仓库 中的 README。
? GUIAPI - The Ultimate Component-Based GUI Framework
Are you tired of writing messy, repetitive, and unmaintainable inventory code for your Bukkit/Spigot/Paper plugins?
Say goodbye to manual slot calculations and spaghetti InventoryClickEvent listeners!
GUIAPI is a powerful, modern, and modular UI framework designed specifically for Minecraft developers. Build interactive, dynamic, and responsive inventory GUIs with a clean, declarative approach using reusable components.
✨ Why Choose GUIAPI?
- ? Save Hundreds of Hours: Build complex UIs in minutes instead of days.
- ? Component-Based Architecture: Everything is a component. Build your UI like Lego blocks using buttons, panels, text inputs, and scrollbars.
- ? Nested Coordinate Systems: Group your components into
GuiPanels. Move a whole panel, and all its children move automatically! No more calculating absolute inventory slots.
- ? Live Updating: Built-in async updaters let you create live clocks, real-time status indicators, and animated menus that automatically clean up when the player closes the inventory.
- ? Flexible Distribution: Use it as a server plugin or shade it directly into your JAR — your choice!
- ? Wide Version Support: Works on Minecraft 1.8 through the latest, including Folia servers.
? Premium Features
- ? Chat Text Input (
GuiTextInput & GuiListTextInput): Prompt players to enter text in chat with built-in validation and custom error messages.
- ? Item Chooser (
GuiItemChooser): Let players click any item in their inventory to use as an input for your forms.
- ? True Editable Slots (
GuiEditableSlot): A slot that acts like a real inventory slot. Supports left-click, right-click, shift-click, stacking, swapping, and splitting. You have full control to accept or reject items!
- ? Pagination & Scrolling: Instantly handle massive amounts of data with
GuiListPage, GuiScrollPane (vertical), and GuiScrollBar (horizontal) with automatic next/previous buttons.
- ⚙️ Configurable Buttons (
GuiConfigurableButton): Buttons that automatically generate a sub-GUI allowing players to edit Key-Value pairs right out of the box!
- ? Modern Formatting: Full support for Hex colors (
&#FF0000), Gradients (<gradient:#ff0000>Text<#00ff00>), and Legacy codes.
- ? NBT Metadata Injection: Effortlessly pass custom data to your items directly from the rendering engine without messing with raw NBT tags.
? Code Speaks for Itself
Look how simple it is to create a fully functioning UI:
// 1. Initialize GUILibs
GUILibs guiLibs = GUILibs.init(this);
guiLibs.register();
// 2. Create a GUI
GUI myGui = guiLibs.createGUI("<gradient:#FFD700>Premium Shop<#50C878>", 3);
// 3. Create a Button
GuiButton button = new GuiButton(myGui, "buy-item", 13);
button.setDisplayItem(guiLibs.getItemBuilder(Material.DIAMOND, 1)
.setDisplayName("&bBuy Diamond")
.addLore("&7Price: $100")
.build());
// 4. Add behavior
button.addListener((id, event) -> {
event.getWhoClicked().sendMessage("§aPurchase successful!");
return true; // Auto-cancel the click event!
});
// 5. Register and Open
myGui.addComponent(button);
myGui.open(player);
? Installation
GUIAPI supports two installation methods. Choose what fits your project:
Option A: Plugin Dependency (Recommended)
Install GUIAPI as a plugin on the server and depend on it. Keeps your JAR small.
Add the JitPack repository, then add the dependency:
Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.downnfalls.guiapi</groupId>
<artifactId>guiapi-plugin</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
Gradle (Groovy):
repositories {
mavenCentral()
maven { url 'https://jitpack.io/' }
}
dependencies {
compileOnly 'com.github.downnfalls.guiapi:guiapi-plugin:VERSION'
}
Gradle (Kotlin DSL):
repositories {
mavenCentral()
maven("https://jitpack.io/")
}
dependencies {
compileOnly("com.github.downnfalls.guiapi:guiapi-plugin:VERSION")
}
plugin.yml:
depend: [GUIAPI]
Option B: Shade (Bundle into your JAR)
Bundle GUIAPI inside your plugin. No extra server plugins needed, but you must relocate the package.
Use artifact com.github.downnfalls.guiapi:guiapi-core with compile/implementation scope and configure relocation via Maven Shade Plugin or Gradle Shadow.
See the full README for detailed shading instructions.
Replace VERSION with the latest release tag from JitPack.
? Requirements
- Server: Spigot, Paper, Folia, or any Bukkit-compatible fork (1.8.8 — Latest)
- Java: 17+
? Examples & More Info
There is no steep learning curve! For full code examples and a detailed guide on how to use every single feature, please check out the README on our GitHub Repository.
评论 0
登录后参与评分
还没有评论,来抢沙发吧