Trigger blockplace/break events?

Discussion in 'Plugin Development' started by darkhelmet, Aug 16, 2012.

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

    darkhelmet

    I have a plugin that changes blocks near a player when they do something, but I want to trigger BlockPlace/BlockBreak events so that other plugins think the player did this (like Hawkeye)

    How can I do that?
     
  2. Offline

    Timr

    First you need to create a new instance of the event. For a blockplace:

    Code:
    BlockPlaceEvent event = new BlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild);
    getServer().getPluginManager().callEvent(event);
    Any plugin that listens for that event will now receive the event and deny events or modify them as they would if a player actually placed the block.
     
  3. Offline

    darkhelmet

    Where can I find all of those arguments though? I already have placed block I suppose, but where do I get or how do I determine the other values.
     
  4. Offline

    Coelho

    They are as they are named..
     
  5. Offline

    Timr

  6. Offline

    devilquak

    For a block place, you can use .breakNaturally. I'm not sure about placing blocks though.
     
Thread Status:
Not open for further replies.

Share This Page