Get player who ignited TNT, when ignition is not direct

Discussion in 'Spigot Plugin Development' started by robertlit, Dec 28, 2019.

  1. Hello.
    How would I go about getting the player who ignited a TNT when it doesn't happen directly. (ex. By arrow, redstone etc.)

  2. Anybody, is this even possible?
  3. here is an EntityBlockFormEvent that you can use for checking when the TNT turns into the entity. Thats all i can really do to help. However, im not sure this is really possible.
  4. Hi, there no exists a specific way to get all kind of way to ignite a tnt, so you have to implement your own way to solve this for every different posibly case.
    • Agree Agree x 1
  5. You'd having to get very creative with it and implement it yourself. You'd actually have to use EntitySpawnEvent to listen to when the ignited TNT was spawned in. Using the spawned TNT's location, you can get surrounding blocks and their respective states to help in determining whether it was triggered by redstone. For arrows, you can use ProjectileHitEvent to test if a flaming arrow has hit a TNT block. From that, you can get the arrow's source pretty easily. If the source is a player, then you're done. If the source is a dispenser, then good luck.