Creating Animations - Oribuin/EternalCrates GitHub Wiki

Getting Started

The plugin has several utilities to help create new animation effects for each different animation type, This page will cover each guide.

If none of the premade animation classes work for you, We recommend looking at using the CustomAnimations

Particle Animations

This is how you can use the API to spawn particles at the crate, This handles all the complicated particle spawning methods. If you would like a more advanced particle spawning method, I recommend using Custom Animations.

public class MyAnimation extends ParticleAnimation {

    public MyAnimation() {
        super("myanimation", "username", 1) ;// Here is where you define the animation name, author or speed.
    }

    // Here we're creating an animation to create a line from the crate to 5 blocks in the sky.
    @Override
    public List<Location> particleLocations(Location crateLocation) {
        final List<Location> locations = new ArrayList<>();
        
        for (double i = 0.0; i <= 10.0; i += 0.5) {
            locations.add(crateLocation.clone().add(0.0, i, 0));
        } 

        return locations;
    }

    @Override
    public void updateTimer() {
        // This is the function that will run in the timer before the plugin gets the particle locations, Use this for steps## 
    }
}

Spinning GUI Animations

The GUI Animation is meant to allow cycling of items through a gui, commonly seen in CSGO Crates.

public class MyAnimation extends GuiAnimation {
    // The winning slot will be the first slot that you input.
    public MyAnimation() {
        // this would rotate the items through the first 9 slots, 4 is first since that is the winning slot
        super("myanimation", "username", new int[]{4, 5, 6, 7, 1, 2, 3});
    }

    @Override
    public int getGuiSize() {
        return 9; // this is the size of the gui, make sure it fits the winning slots size
    }

    @Override
    public int getRotationCount() {
        return 3; // the amount of times you want them to cycle through items.
    }

    @Override
    public int getRotationSpeed() {
        return 3; // the ticks per second that each item rotates.
    }

    @Override
    public BiConsumer<Player, Gui> getSpinConsumer() {
        // this is for when you want to play sounds for example each time the items rotate.
        return (player, gui) -> player.playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 50f, 1f);
    }
}

Firework Animations

public class MyAnimation extends FireworkAnimation {

        public MyAnimation() {
                super("myanimation", "username", 3); // the last number is the time in ticks between each firework launch
        }

        @Override
        public void registerFireworks(Location location) {
                // Register all your fireworks here, The order you register them
                this.addFirework(location, FireworkEffect.builder().build());
        }
}

Custom Animations

Custom Animations allow free roam with crate animations, however, you'll need to define when the animation is over and run the rewards function, Use the defaults as references.

public class MyAnimation extends CustomAnimation {
        
        public MyAnimation() {
                super("myanimation", "username");
        }

        @Override
        public void spawn(Crate crate, Location location, Player player) {
                // This class comes with several methods
                this.setActive(true); // While this is true, A crate cannot be opened.
                player.sendMessage(ChatColor.RED + "Waiting for reward...");
                Bukkit.getScheduler().runTaskLater(() -> {                
                        List<Reward> rewards = crate.createRewards();
                        // Just for an example
                        rewards.forEach(reward -> finishFunction(player)
                        this.setActive(false);
                }, 60);
        }
}
⚠️ **GitHub.com Fallback** ⚠️