Get player that primed a TNT

Discussion in 'Plugin Development' started by triarry, Feb 6, 2013.

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


    Hey guys! I'm currently working on a plugin that prevents players from losing their items when they die from PvP deaths. I've gotten my plugin to work for most scenarios... But I'm having trouble implementing the TNTPrimed event, so...

    How would I retrieve information about a player who primed a block of TnT?

    I know how to get information about a player who PLACED the TnT, but I'm stumped on how to get the player who actually primed it, that way I can count it as a "player related" death when someone else gets killed by a player who primed TnT.

    Thanks in advance!
  2. Offline


    You'll have to store all the ways a player can prime TnT (fire, redstone, lever, button) etc, storing who placed them and then checking how the TnT was primed or something. You'll definitely need to incorporate the redstone power event
  3. Offline


    I'm trying to think of a good way to do this. A hashmap seems unneeded here. Would this be more effective with a switch statement or an if/else statement? I'm a recursive function type of person and I'd just use if statements and go straight down the list of redstone events, but I feel like this is probably not as efficient in this situation.

  4. Offline


    Use the ExplosionPrimeEvent, get the entity and do something with it.
  5. Offline


    I'm pretty sure the entity of this event is the primed TNT and not a player.

    I think you may get the player if the tnt is primed by a single lever/button/fire next to it. But if redstone is involved than you would have to track the whole redstone circuit from a button/lever to the TNT in order to check if the player who pushed the button indirectly primed the TNT.
  6. Offline


    In this case I'll still need to check multiple instances. Would you recommend a switch statement or a recursive function?
  7. Offline


    If you just want to check for levers/buttons next to the TNT than I would use a switch statement or a for-loop. A recursive function would be too much for just checking a couple of blocks.
Thread Status:
Not open for further replies.

Share This Page