Leaf Decay

Discussion in 'Plugin Development' started by Joey Clover, Mar 14, 2011.

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

    Joey Clover

    I am trying to make a RANDOM item fall out of a decaying leaf. How would I go about this. I need to check, if the random number that is generated is equal to a valid item id and I NEED TO KNOW HOW TO DISPENSE ITEMS. I need to know how to make the items fall out of the leaves. Thanks a bunch!

  2. Offline


    Dropping items:
    Get the world and location of the leaf and drop an ItemStack there.
    Block block = event.getBlock();
    ItemStack drop = new ItemStack(Material.LEAVES, 1);
    block.getWorld().dropItem(block.getLocation(), drop);
  3. Offline

    Joey Clover

    Thanks! umm, I am trying to make an egg throw event but it does not work :O

    Here is my OnEnable:
        public void onEnable() {
            PluginDescriptionFile desc = getDescription();
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_EGG_THROW , (Listener)ESeventListener, Event.Priority.Normal, this);
            System.out.println("[INFO]" + desc.getName() + " - Version: "
                    + desc.getVersion() + " has been initialized!");
    and here is my event class:
    package com.eye.EggSpawner;
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerEggThrowEvent;
    import org.bukkit.event.player.PlayerListener;
    public class ESPlayerEventListener extends PlayerListener {
        private static EggSpawner plugin;
        public ESPlayerEventListener(EggSpawner ES){
            plugin = ES;
        public void onEggThrow(PlayerEggThrowEvent eggEvent){
            System.out.println("OMG, SOMEONE THREW AN EGG!!!!");
            Player player = eggEvent.getPlayer();
            player.sendMessage("YO DAWG, STOP THROWING THOSE EGGS!");
    and help appreciated!
  4. Offline


    Add @Override above your onEggThrow.
  5. Offline

    Joey Clover

    Thanks man, you are truly epicly awesome ;)

    But wait!
    Still does not work: must override a supertype method. I am guessing the PlayerListener does not have an onThrowEgg function :/

    NOTE: FIXED. IT WAS 'onPlayerEggThrow' ;)

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

Share This Page