Getting Started with API
Getting Started with zItems API
This guide will help you get started developing with the zItems API to create custom effects, hooks, and integrations.
What Can You Build?
The zItems API allows you to:
Custom Effects: Create new effect handlers (like Hammer, Vein Mining, etc.)
Plugin Hooks: Integrate zItems with your own plugins
Event Listeners: React to zItems-specific events
Custom Block Providers: Add support for custom block plugins
Item Source Extractors: Extract items from custom events
Setting Up Your Development Environment
Step 1: Project Setup
Using Gradle (Kotlin DSL):
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
// Add zItems repository here when available
mavenLocal() // For now, install zItems API to local Maven
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
compileOnly(files("libs/zItems-api-1.0.0.jar")) // Path to zItems API
}Using Maven:
Step 2: Plugin Setup
plugin.yml:
Main Plugin Class:
API Structure
Core Packages
Quick Examples
Example 1: Simple Custom Effect
IMPORTANT: After creating your effect class, you MUST call scanPackages() in your plugin's onEnable():
Configuration (effects/hello_world.yml):
Example 2: Accessing Managers
Example 3: Listening to zItems Events
Example 4: Accessing Registries
Key Concepts
1. Registry Pattern
zItems uses a centralized registry system for all components:
2. Manager Pattern
Managers handle business logic:
3. Annotation-Driven Discovery
zItems automatically discovers and registers annotated classes ONLY IF you call scanPackages():
CRITICAL: You must call scanPackages() on each registry in your onEnable():
4. Effect Context
Effect handlers receive a context object with all necessary data:
Development Workflow
1. Create Your Effect
2. Register Your Package
3. Test Your Effect
Create a test configuration:
Create a test item:
Test in-game:
4. Add Custom Settings
Update your handler:
Update configuration:
Best Practices
1. Always Call scanPackages()
Without this, your @AutoEffect, @AutoHook, and @AutoExtractor annotations will be ignored!
2. Use Sealed Interfaces
zItems uses sealed interfaces for type safety:
3. Handle Errors Gracefully
4. Respect Permissions
5. Use Priority Correctly
6. Document Your Code
Complete Example Plugin
Here's a complete working example:
Main Class:
Effect Handler:
Settings Class:
plugin.yml:
Troubleshooting
Effect Not Registered
Problem: "Handler not found for effect type: MY_EFFECT"
Solution: Make sure you called scanPackages() in onEnable():
Wrong Package Scanned
Problem: Effects in subpackages not found
Solution: Scan the base package - it will scan all subpackages:
Settings Not Loading
Problem: Effect settings always null or default
Solution: Make sure your settings class:
Implements
EffectSettingsIs a
recordor has proper gettersHas field names matching YAML keys (snake_case → camelCase)
Resources
JavaDocs: (Coming soon)
Example Plugins: Check
/examplesin the GitHub repositoryGitHub: zItems Repository
Discord: Join for development support
Last updated