Help writing a plugin

Discussion in 'Plugin Development' started by Tsurara, Jan 19, 2011.

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

    Tsurara

    So, yeah, first plugin, wooho.
    I'm trying to replace a block with the block in your hand, but I'm not sure how to do that. any help?
    Also, as to my understanding, it should be under the "BlockListener" , so how do you make it "react" to the command on "PlayerListener"? knowing this would help me a lot.

    Sorry for my irritating noobish question :3
    and Thanks!
     
  2. Offline

    apexearth

    You could use the onBlockRightClick event.

    The event parameter will give you the block that was right clicked on.

    You can update that block.

    I'm not sure if the functionality for updating blocks is working in Bukkit at the moment.
     
  3. Offline

    Tsurara

    I know about using the "onBlockRightClick" event, not sure how to use it though.
     
  4. Offline

    apexearth

    public void onBlockRightClick(BlockRightClickEvent event) {
    event.getBlock().setType(event.getItemInHand().getType());
    }

    That code makes perfect sense as to how you should do it...but I don't think it will work yet. I don't think they put the code in to actually change the block yet.

    Also, I was lazy and didn't make sure there really was an item in hand, you would want to do that.
     
  5. Offline

    Tsurara

    Thanks!
    will this activate with the command I've set in "PlayerListener"? :3
     
  6. Offline

    apexearth

    Negative... It will occur when a player right clicks on a block.

    To do it strictly through a user command, you'd have to use the event to get the player, get the item in that players hand, find the location of the player, and figure out what block the player is looking at in the world.

    I think there is a command out there in Bukkit to figure out what block a user is looking at. I can't remember it.
     
  7. Offline

    Tsurara

    Oh.
    Thanks a lot!
     
  8. Offline

    Fifteen

    onBlockRightClick hasn't been implemented yet according to the Javadoc.
     
  9. Offline

    apexearth

    I've used it so I know it works at least partially.
     
Thread Status:
Not open for further replies.

Share This Page