Finding out who placed tnt

Discussion in 'Plugin Development' started by matejdro, Dec 31, 2011.

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

    matejdro

    I'm trying to make a function that will detect who placed TNT that just blew up.

    However, I'm stuck at the part when TNT changes into entity. I can't seem to find event that will help me "link" new tnt entity with previous block and thus with player.

    Any idea, how could I do that?
     
  2. Offline

    bergerkiller

    @matejdro Use the BLOCK_PLACE event in the BlockListener and map the TNT blocks vs the player name that placed it there. Then when the TNT explodes, you can look up the placer in that map.

    On a sidenote: please don't release it, we've got more than enough block loggers already, unless you want to make something far more advanced of course...
     
  3. Offline

    matejdro

    Yes, I can map that. But what if TNT falls down? Then block will not be in the map anymore. I wan to somehow link tnt entity with player.

    Don't worry it's for private pvp plugin (so you can kill people with tnt and get points).
     
  4. Offline

    bergerkiller

    @matejdro There are multiple ways a TNT block turns into an entity, so afraid you'll have to monitor them all.
    - onBlockRedstoneChange
    - onBlockIgnite
    - onBlockPhysics (maybe useful)
    And then, after the event, you use a delayed scheduled sync task of 0 ticks (almost instantly after) and get the nearest TNT entity to that block. You add the TNT entity + the block owner in a separate map, where you can obtain it again when the TNT explodes.
     
Thread Status:
Not open for further replies.

Share This Page