Chest Opening Animation

Discussion in 'Plugin Development' started by RealAstro, Sep 15, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    RealAstro

    I'm making a crate plugin but i need help adding a chest animation with the reward coming out of it when clicking the chest with a key

    Code:

    Code:
            if (e.getClickedBlock().getType() == Material.CHEST && is.getItemMeta().getDisplayName().equals(Utils.chat("&8[&d!&8] &eRank Crate &8[&d!&8]"))) {
                if (e.getPlayer().getItemInHand().getType() == Material.NETHER_STAR && is.getItemMeta().getDisplayName().equals(Utils.chat("&8[&a!&8] &aRank&7 Crate Key &8[&a!&8]"))) {
                    int  n = random.nextInt(100) + 1;
                    if (n<=1) {
                        for (ItemStack Demon : player.getInventory().getContents()) {
                            if (is.getType() == Material.PAPER && is.hasItemMeta() && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equalsIgnoreCase("&8&l[&4!&8] &r&4&lDemon&r&7 Rank &8&l[&4!&8]&r")) {
                                ItemStack item = Demon;
                                player.getInventory().addItem(Demon);
                            }
                        }
                    } 
                    for (ItemStack key : player.getInventory().getContents()) {
                        if (is.getType() == Material.NETHER_STAR && is.hasItemMeta() && is.getItemMeta().hasDisplayName() && is.getItemMeta().getDisplayName().equalsIgnoreCase("&8[&a!&8] &aRank&7 Crate Key &8[&a!&8]")) {
                            player.getInventory().remove(key);
    
                        }
                    }
                } else {
                    player.sendMessage(Utils.chat("&8[&d!&8]&e You need a Rank Key to open this Crate"));
                }
            }
     
Thread Status:
Not open for further replies.

Share This Page