Skip to content

API Overview & Integration ​

Belongs to: Developer · Subpages: API Reference · Events · Action Handler Development

This chapter is for plugin developers: how to depend on QI, where the entry point is, and how the API is layered. For full method signatures, see API Reference.


1. Depending on QI ​

The QI runtime is already installed on the server; you only need a compile-time dependency (provided) — don't bundle it into your own jar.

Install to local Maven ​

bash
mvn install:install-file -Dfile=QinhItems-1.1.0.jar -DgroupId=com.qinhuai -DartifactId=QinhItems -Dversion=1.1.0 -Dpackaging=jar

pom.xml ​

xml
<dependency>
  <groupId>com.qinhuai</groupId>
  <artifactId>QinhItems</artifactId>
  <version>1.1.0</version>
  <scope>provided</scope>
</dependency>

plugin.yml ​

yaml
softdepend: [QinhItems]

If compilation reports com.qinhuai.corelib.* missing, also install-file + provided-reference QinhCoreLib (a few members of QI's API reference CoreLib types).


2. Entry Point: QinhItemsAPI ​

Package: com.qinhuai.items.api
Class:   QinhItemsAPI   (Kotlin object singleton)
  • Java calls with .INSTANCE: QinhItemsAPI.INSTANCE.isQinhItem(stack)
  • Kotlin directly: QinhItemsAPI.isQinhItem(stack)

API version constant: QinhItemsAPI.API_VERSION = 1.


3. Layered Facades ​

QI's API is split into several facades, accessed by responsibility:

FacadeHow to getWhat it manages
BaseQinhItemsAPI.xxxItem identification, definition lookup, soulbinding, canUse, fetching providers
AssemblyQinhItemsAPI.assembly()Building items, rebuilding, layer patches
VariablesQinhItemsAPI.variables()Get / set / lock variables, tracing, refresh
ActionsQinhItemsAPI.actions()Registering handlers, action tables, dispatch, payload schema
LayersQinhItemsAPI.layers()Reading layer state and values
BridgeQinhItemsAPI.bridge()Registering / querying Provider bridges
CombatQinhItemsAPI.combat()Combat / attribute refresh (= QinhCombatAPI)

For full signatures, see API Reference.


4. The Four Most Common Tasks ​

Build an item ​

java
ItemStack item = QinhItemsAPI.INSTANCE.assembly().build("itemId", count);
// Returns null if the ID doesn't exist

Check whether it's a QI item / get the ID ​

java
boolean isQi = QinhItemsAPI.INSTANCE.isQinhItem(stack);
String id    = QinhItemsAPI.INSTANCE.getItemId(stack);   // Returns null if not a QI item

Check soulbinding (a must for markets / mail) ​

java
boolean bound = QinhItemsAPI.INSTANCE.isSoulbound(stack);
java.util.UUID owner = QinhItemsAPI.INSTANCE.getSoulboundOwner(stack);

Register an action handler ​

kotlin
QinhItemsAPI.actions().registerHandler(object : QinhActionHandler {
    override val handlerId = "myplugin:hello"
    override fun dispatch(ctx: QinhActionContext): ActionDispatchResult {
        ctx.player.sendMessage("payload=${ctx.payload}")
        return ActionDispatchResult.HANDLED
    }
})

5. Availability & Null Values ​

  • All generation / reads return null when "the ID doesn't exist" or "it's not a QI item" — always null-check.
  • Don't call into QI when it isn't enabled: use Bukkit.getPluginManager().getPlugin("QinhItems") to check liveness, or rely on softdepend load ordering.
  • Item identification / reverse lookup (item → id) is only in QI's API; CoreLib doesn't have it.

6. Choosing an Integration Route ​

You want to…UseSection
Build items by ID, reverse-look-up item ownershipQI assembly() / isQinhItemAPI Reference
Resolve items via qi:id / qinhitems:id prefixesCoreLib ItemManagerAPI.getHookItem(ref)Integration
Attach external-system data to itemsProvider + BridgeProvider & Bridge
Custom logic after a triggerAction handlersAction Handler Development
Listen to item lifecycleEventsEvents
Socketing / inlay / enhancement (state after modifying an item)Layer APILayers & Assembly
Ready-made code for markets / mail / lotteries / enhancement, etc.—API Cookbook
Integrate AP / QinhSkills / gem backends—Integration in Practice

Next Steps ​