Minecraft 1.16] can't be cast to org.bukkit.entity.Arrow / Trident?

Ba
1

OnDeath: (error line 22/42)

Error message:

^ The error occurs when you are killed by a trident or an entity.

Error Message - Occurs when killed by an arrow. In addition, it doesn't say shot, but slain:

an

Well, it's very simple, you cast

lastDamageCause.getDamager ();

to an Arrow and a Trident. Without even knowing whether the damage came from an Arrow or a Trident.

Before casting, do an instanceof check to see if you can cast it at all.

if (killer instanceof Trident) {
Trident trident = (Trident) killer;
//.
} else if (killer instanceof Arrow) {
Arrow arrow = (Arrow) killer;
//.
}