Replace metadata "planter" logic with TNT primed source.

Now that MobArena sets the TNTPrimed source on auto-ignited TNT, the
"planter" logic becomes _somewhat_ obsolete. This is due to the fact
that manually ignited TNT blocks produce a TNTPrimed entity with the
source property set to the player that ignited the block.

Because the "planter" logic in the BlockIgniteEvent handler didn't
actually work, this change shouldn't actually do anything in that
regard. That is, a TNT block ignited by a player would still have that
player as its source regardless of who the planter was, because the
procedure that would have otherwise set the planter of the TNTPrimed
entity never ran.
This commit is contained in:
Andreas Troelsen 2022-02-12 23:53:04 +01:00
parent 4470b60aaf
commit b9b4d0d204
1 changed files with 1 additions and 20 deletions

View File

@ -91,9 +91,6 @@ import org.bukkit.material.Attachable;
import org.bukkit.material.Bed;
import org.bukkit.material.Door;
import org.bukkit.material.Redstone;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.metadata.Metadatable;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
@ -287,10 +284,8 @@ public class ArenaListener
stack.setAmount(stack.getAmount() - 1);
TNTPrimed tnt = b.getWorld().spawn(b.getRelative(BlockFace.UP).getLocation(), TNTPrimed.class);
tnt.setSource(event.getPlayer());
setPlanter(tnt, event.getPlayer());
return;
}
setPlanter(b, event.getPlayer());
}
// Any other block we don't care about if we're not protecting
@ -307,20 +302,6 @@ public class ArenaListener
}
}
private void setPlanter(Metadatable tnt, Player planter) {
tnt.setMetadata("mobarena-planter", new FixedMetadataValue(plugin, planter));
}
private Player getPlanter(Metadatable tnt) {
List<MetadataValue> values = tnt.getMetadata("mobarena-planter");
for (MetadataValue value : values) {
if (value.getOwningPlugin().equals(plugin)) {
return (Player) value.value();
}
}
return null;
}
public void onBlockForm(BlockFormEvent event) {
// If the arena isn't protected, care
if (!protect) return;
@ -672,7 +653,7 @@ public class ArenaListener
}
if (damager instanceof TNTPrimed) {
damager = getPlanter(damager);
damager = ((TNTPrimed) damager).getSource();
}
}