Developer API

As of update of version 1.1.7, Phantom Lootboxes now has a built-in public API for external developers to integrate their own custom animations. Below is an example of how to utilize the ILootboxAnimation interface which MUST be implemented, otherwise it will not work.

Example TestAnimationImpl class

public class TestLootboxImpl extends AbstractLootbox implements ILootboxAnimation {
    private final Lootbox lootbox;
    private final Player player;
    private final Location location;
    private boolean isRunning = false;

    public TestLootboxImpl(Lootbox lootbox, Player player, Location location) {
        this.lootbox = lootbox;
        this.player = player;
        this.location = location;
    }

    @Override
    public void startAnimation() {
        /*
         * Do your main animation logic here.
         */
        System.out.println("Starting test animation for lootbox: " + lootbox.getLootboxID());
    }

    @Override public void stopAnimation() { /* ... */ }
    @Override public boolean isAnimationRunning() {
        return isRunning;
    }
    @Override public String getAnimationName() { return "TEST"; }
    @Override public boolean supportsBonusItems() { return false; }
    @Override public boolean isPlaceOnlyAnimation() { return true; }
}

Registering your custom animation class to the internal register

You would typically put this in your onEnable()

AnimationRegistry.get().registerClass("TEST", TestLootboxImpl.class);

Last updated