garbagemule / MobArena

MobArena plugin for Minecraft
GNU General Public License v3.0
196 stars 151 forks source link

Use `TNTPrimed#setSource(Player)` #718

Closed molor closed 2 years ago

molor commented 2 years ago

Feature request

Please use TNTPrimed#setSource(Player) after player was placed a TNT block — we're running a custom plugin that uses MA events and it needs to know what player is ignited a TNT. Thanks!

garbagemule commented 2 years ago

Thanks for the feature request!

I don't see any particular reason why we couldn't add this in. However, MobArena already uses the Bukkit Metadata API to keep track of TNT blocks placed by arena players to prevent friendly fire when PvP is disabled. Could that be used instead? The metadata key is mobarena-planter, and it is placed on all planted TNT blocks as well as all TNTPrimed entities that either spawn from auto-ignite-tnt: true or from any player igniting a TNT block that was planted by any player.

There's also the option of reworking MobArena's inner workings, so that it uses the TNTPrimed source property instead of the metadata. The only problem with that is that we wouldn't be able to distinguish between TNT placed by players and TNT that is part of the arena or planted by other means. Perhaps that's okay? It would simplify MobArena's logic to just use the TNTPrimed source, but it would also mean that TNT blocks that weren't planted by an arena player can no longer deal player damage. Say someone has an arena with a TNT wall that the players are supposed to ignite, but they're also supposed to take damage from the explosions. That behavior would break with such a change. But perhaps it's too contrived an example to be realistic.

We can, of course, just add the source to auto-ignited TNT and not worry about the metadata stuff. We can do one, the other, or both. I would love some feedback on these thoughts :)

molor commented 2 years ago

In our case, we want it only on block place, but you're already added that. Thanks!