BlockGrowEvent not working

Discussion in 'Plugin Development' started by Zach_1919, Mar 12, 2014.

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

    Zach_1919

    Hey everyone! So I want to be able to detect when sugar cane grows for a plugin I'm working on, and so I looked it up and I found the BlockGrowEvent. In order to test it out, I decided to just make a simple plugin where when sugar cane grows, whatever block gets returned by the event gets turned to gold. I loaded it up and it doesn't seem to be doing anything when sugar cane grows; it just grows like normal. Maybe there's some silly little nubbish mistake in my code? No errors in console, by the way.

    Code:
    Code:
    package me.zDev.frostydrugs;
     
    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockGrowEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin implements Listener
    {
        public void onEnable()
        {
            getServer().getPluginManager().registerEvents(this,this);
        }
       
        @EventHandler
        public void onBlockGrow(BlockGrowEvent event)
        {
            event.getBlock().setType(Material.GOLD_BLOCK);
            System.out.println("Swag");
        }
    }
    And this event does in fact work with sugar cane, as stated in the Bukkit JD:
    [​IMG]

    Thanks :)
     
  2. Offline

    adam753

    Hmm, there's no good reason why this simple bit of code shouldn't work. I'm going to assume the "swag" message doesn't get printed?
    Maybe you should try putting an output message in your onEnable. If that doesn't get printed, then your plugin isn't being loaded for whatever reason. That's the only reason I can think of that would stop this from working.
     
  3. Offline

    Zach_1919

    adam753 Well I don't think the message in onEnable is necessary because there is a default initialization message that gets printed every time a plugin is loaded automatically. This message does print when I reload the server.

    Also, you would be correct in thinking that the "swag" message does not show up.
     
  4. Offline

    adam753

    Well, I'm going to assume this is a Bukkit bug for now, but via google I just found this thread where I told someone to use StructureGrowEvent instead and they said it worked. Give that a try.
     
  5. Offline

    Zach_1919

  6. Offline

    Zach_1919

  7. Offline

    Barinade

    Does it say "Swag"?
     
  8. Offline

    Zach_1919

Thread Status:
Not open for further replies.

Share This Page