Register custom animations
To create an animation class, we will use the Animation interface
TestAnimation class
Pay attention to the methods: Case#animationPreEnd and Case#animationEnd
- Case#animationPreEnd is called to grant a group, send a message, and more.
- Case#animationEnd is called to completely end the animation.
import com.jodexindustries.donatecase.api.Case;
import com.jodexindustries.donatecase.api.data.Animation;
import com.jodexindustries.donatecase.api.data.CaseData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.UUID;
public class TestAnimation implements Animation {
@Override
public void start(Player player, Location location, UUID uuid, CaseData caseData, CaseData.Item item) {
Case.animationPreEnd(caseData, player, true, item);
Bukkit.getScheduler().runTaskLater(Case.getInstance(), () -> Case.animationEnd(caseData, player, uuid, item),20L);
}
}
Main class
@Override
public void onEnable() {
// getting CaseManager for addon
CaseManager api = new CaseManager(this);
// register animation
AnimationManager animationManager = api.getAnimationManager();
animationManager.registerAnimation("test", new TestAnimation());
}