开发者接入
从 Maven 仓库引入 Xerr API,并声明插件运行依赖
公共 API 入口是 com.hiusers.xerr.api.XerrAPI。不要依赖内部 Container、Loader 或 Service。
引入依赖
通过 API 仓库选择与服务器 Xerr 一致的版本。以下以 2.3.0 为例:
repositories {
maven("https://repo.hiusers.com/releases")
}
dependencies {
compileOnly("com.hiusers.xerr:xerr-api:2.3.0")
}构建工具使用的仓库地址是 https://repo.hiusers.com/releases,不是带 #/releases/... 的浏览页面地址。
API JAR 仅用于开发编译,不能替代服务器上的 Xerr 插件。使用 compileOnly 或 provided,不要将 Xerr 打入自己的插件。
声明插件依赖
必须依赖 Xerr 才能运行:
depend:
- Xerr仅在 Xerr 存在时启用集成功能:
softdepend:
- Xerr使用 softdepend 时,调用 API 前自行确认 Xerr 已启用。
Kotlin 最小示例
import com.hiusers.xerr.api.XerrAPI
import org.bukkit.entity.Player
fun notify(player: Player) {
XerrAPI.popups.show(
player,
"notice",
mapOf(
"title" to "任务完成",
"message" to "获得钻石 ×3"
)
)
}Java 最小示例
import com.hiusers.xerr.api.XerrAPI;
import org.bukkit.entity.Player;
import java.util.Map;
public void notify(Player player) {
XerrAPI.get().popups().show(
player,
"notice",
Map.of("title", "任务完成", "message", "获得钻石 ×3")
);
}如果要用本节之外的 ComponentText 或 @SubscribeEvent 类型,项目还需拥有对应 TabooLib 编译依赖。不要把 Xerr 的显示 API 依赖当作所有 TabooLib 模块已自动引入。
线程规则
- Bukkit 玩家、世界和实体操作放在主线程。
- Popup 与 Compass 的修改方法通常返回
CompletableFuture。 - 不要在主线程对 Future 调用
get()或join()。 - 异步数据库结果通过 Future、Provider 或 Storage 交给 Xerr。
接下来阅读XerrAPI、事件和Compass 扩展。