Developer API
For plugin developers: react to stands being posed, locked and placed from copies, and pose or lock them from your own plugin.
Add the API
The API is a small jar of interfaces and events. Compile against it; BoxStand provides it at run time.
Gradle (Kotlin)
repositories {
maven("https://boxpixstudios.com/maven/")
}
dependencies {
compileOnly("com.lunggolfs:boxstand-api:1.0.0")
}
Maven
<repository>
<id>boxpix</id>
<url>https://boxpixstudios.com/maven/</url>
</repository>
<dependency>
<groupId>com.lunggolfs</groupId>
<artifactId>boxstand-api</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
In your plugin.yml, add depend: [BoxStand] (or softdepend).
Events
| Event | When | Cancel |
|---|---|---|
StandPoseChangeEvent |
A pose is about to change: pose editor step, reset, pasted copy, API (getCause()) |
Yes |
StandLockChangeEvent |
A stand is about to be locked or unlocked | Yes |
StandPlaceFromCopyEvent |
A stand was placed from a copy, the tick after it came into the world | No. Cancel Bukkit's EntityPlaceEvent instead |
The pose event gives getOldPose() and getNewPose(). The editor fires it on every step, so keep listeners quick. Turning the whole stand is not a pose change.
@EventHandler
public void onPose(StandPoseChangeEvent event) {
Player player = event.getPlayer(); // null when changed through the API
if (player != null && !canBuildHere(player, event.getEntity().getLocation())) {
event.setCancelled(true);
}
}
Events are in com.lunggolfs.boxstand.api.event.
The service
BoxStandApi api = BoxStandApi.get();
if (api.isStand(entity) && entity instanceof ArmorStand stand) {
StandPose pose = api.getPose(stand);
api.setPose(stand, pose.with(StandPart.HEAD, new EulerAngle(0.3, 0, 0)));
}
| Method | Does |
|---|---|
isStand(entity) |
Any armor stand, not BoxStand's own helper entities |
getPose(stand) / setPose(stand, pose) |
Reads or sets all six parts; the model and wearables follow |
isLocked(stand) / getLockOwner(stand) |
The lock and who set it |
lock(stand, owner) / unlock(stand) |
Locks in a player's name, or unlocks |
Angles are radians, as Bukkit's EulerAngle. Call it from the main thread.