đ API (Developers)
Overviewâ
Oraxen exposes a small public API surface for other plugins. Most integrations revolve around these classes.
io.th0rgal.oraxen.api.OraxenItemsio.th0rgal.oraxen.api.OraxenBlocksio.th0rgal.oraxen.api.OraxenFurnitureio.th0rgal.oraxen.api.OraxenPack
Oraxen is open source, allowing you to create a pull request with the needed changes for your integration. If you are unsure about how to contribute, refer to our Contributing Guide.
Setupâ
Add the Maven Repository + Dependencyâ
Oraxen is a server plugin, so in most cases you want compileOnly / provided.
repositories {
maven("https://repo.oraxen.com/releases")
}
dependencies {
compileOnly("io.th0rgal:oraxen:VERSION")
}
repositories {
maven { url "https://repo.oraxen.com/releases" }
}
dependencies {
compileOnly "io.th0rgal:oraxen:VERSION"
}
<repository>
<id>oraxen</id>
<url>https://repo.oraxen.com/releases</url>
</repository>
<dependency>
<groupId>io.th0rgal</groupId>
<artifactId>oraxen</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
Snapshot builds are also available at https://repo.oraxen.com/snapshots.
Add Oraxen to plugin.ymlâ
Use depend if your plugin cannot run without Oraxen, otherwise use softdepend.
name: MyPlugin
main: com.example.myplugin.MyPlugin
version: 1.0.0
softdepend: [Oraxen]
Use Events Instead of Guessing Load Orderâ
Items and mechanics are reloaded on /oraxen reload all. Prefer listening to Oraxen events (see below) rather than caching results forever.
Items (OraxenItems)â
Oraxen assigns an item id into the PersistentDataContainer using OraxenItems.ITEM_ID.
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.items.ItemBuilder;
import org.bukkit.inventory.ItemStack;
public class MyIntegration {
public ItemStack build(String itemId) {
ItemBuilder builder = OraxenItems.getItemById(itemId);
return builder != null ? builder.build() : null;
}
public boolean isOraxenItem(ItemStack stack) {
return OraxenItems.exists(stack);
}
public String getOraxenId(ItemStack stack) {
return OraxenItems.getIdByItem(stack); // null if not an Oraxen item
}
}
Useful helpers
OraxenItems.exists(String)/OraxenItems.exists(ItemStack)OraxenItems.getItemById(String)andOraxenItems.getOptionalItemById(String)OraxenItems.getBuilderByItem(ItemStack)OraxenItems.getNames()(all loaded ids) andOraxenItems.getItemNames()(filtered for commands)
Custom Blocks (OraxenBlocks)â
Oraxen custom blocks can be backed by different mechanics (note block / tripwire / chorus plant / shaped block). The API provides common queries and safe placement/removal methods.
import io.th0rgal.oraxen.api.OraxenBlocks;
import org.bukkit.Location;
import org.bukkit.block.Block;
public class MyBlocks {
public boolean isOraxen(Block block) {
return OraxenBlocks.isOraxenBlock(block);
}
public void place(String itemId, Location at) {
OraxenBlocks.place(itemId, at);
}
public boolean remove(Location at) {
return OraxenBlocks.remove(at, null); // player optional
}
}
Also available:
- ID lists -
getBlockIDs(),getNoteBlockIDs(),getStringBlockIDs(),getChorusBlockIDs() - Type checks -
isOraxenNoteBlock(...),isOraxenStringBlock(...),isOraxenChorusBlock(...) - Mechanic accessors -
getNoteBlockMechanic(...),getStringMechanic(...),getChorusMechanic(...),getShapedMechanic(...) - Block data creation -
getOraxenBlockData(itemId)
Furniture (OraxenFurniture)â
Furniture is entity-backed (and may optionally use barrier hitboxes). The API lets you detect furniture, place it with a rotation or yaw, and remove it while respecting drops.
import io.th0rgal.oraxen.api.OraxenFurniture;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.Rotation;
public class MyFurniture {
public Entity place(String itemId, Location at) {
return OraxenFurniture.place(itemId, at, Rotation.NONE, BlockFace.UP);
}
public boolean remove(Location at) {
return OraxenFurniture.remove(at, null); // player optional
}
}
The old boolean-returning OraxenFurniture.place(Location, String, Rotation, BlockFace) is deprecated. Use OraxenFurniture.place(String, Location, Rotation, BlockFace) instead.
Resource Pack (OraxenPack)â
Use OraxenPack when you need to trigger pack actions or inject additional files into the generated output.
import io.th0rgal.oraxen.api.OraxenPack;
import java.io.File;
public class MyPack {
public File getPackFile() {
return OraxenPack.getPack();
}
public void reload() {
OraxenPack.reloadPack();
}
public void upload() {
OraxenPack.uploadPack();
}
}
Add extra files to the generated packâ
import io.th0rgal.oraxen.api.OraxenPack;
import java.io.File;
OraxenPack.addFilesToPack(new File[] {
new File("plugins/MyPlugin/pack_overrides/pack.mcmeta")
});
Eventsâ
All events live under io.th0rgal.oraxen.api.events.* and can be listened to like any other Bukkit event.
import io.th0rgal.oraxen.api.events.OraxenItemsLoadedEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class MyListener implements Listener {
@EventHandler
public void onItemsLoaded(OraxenItemsLoadedEvent event) {
// Items were (re)parsed, rebuild your caches here
}
}
Common integration events
OraxenItemsLoadedEvent- items were parsed/reloadedOraxenNativeMechanicsRegisteredEvent- native mechanics registered; hook custom mechanics here (see Mechanics)OraxenPackGeneratedEvent- pack output list is availableOraxenPackPreUploadEvent- cancellable, fired async (avoid unsafe Bukkit calls)OraxenPackUploadEvent- pack got uploaded; provides theHostingProvider(URL, SHA1, UUID)- Block / furniture events:
events.noteblock.*,events.stringblock.*,events.chorusblock.*,events.shapedblock.*,events.furniture.* - Shaped blocks currently only fire a break event (
OraxenShapedBlockBreakEvent). There are no damage, interact or place variants yet.