Solved Need help with checking for custom item meta

Discussion in 'Plugin Development' started by gabe4356, Sep 1, 2014.

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

    gabe4356

    So I am making a plugin for my friend, where if he has a cake, it explodes when it is placed, but I don't want EVERY cake ever placed down to blow up, so I made a custom item meta, but how would I make it so that instead of the cake getting placed down and blowing up, the custom item meta cake gets placed down and blown up?
    my code:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteractBlock(PlayerInteractEvent event) {
    3. Player player = event.getPlayer();
    4. if (player.getItemInHand().getType() == Material.CAKE)
    5. player.getWorld().playSound(player.getLocation(), Sound.ENDERDRAGON_DEATH, 1F, 1F);
    6. player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Uh-oh! Someone has used an over powered birthday cake!");
    7. player.getWorld().createExplosion(player.getLocation(), 10.0F);
    8. }



    Creating the custom item meta:
    Code:
                    ItemStack gold = new ItemStack(Material.CAKE);
                    ItemMeta ca = gold.getItemMeta();
                    ca.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Birthday Cake");
                    List<String> lore = new ArrayList<String>();
                    lore.add(ChatColor.DARK_AQUA + "Happy Birthday Alex! Your 12! You managed to survive that long! Congrats!");
                    ca.setLore(lore);
                    gold.setItemMeta(ca);
    Any help?

    Woops, I pasted the code for my event after I tried something, let me fix that.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
Thread Status:
Not open for further replies.

Share This Page