#886: Add new Causes for LightningStrikeEvent

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2021-07-13 19:16:36 +10:00
parent 18a453f567
commit e797fdd58a
2 changed files with 19 additions and 3 deletions

View File

@@ -594,7 +594,22 @@ public class CraftEventFactory {
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Vehicle) {
event = CraftEventFactory.callVehicleCreateEvent(entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.LightningStrike) {
LightningStrikeEvent.Cause cause = (spawnReason == SpawnReason.COMMAND ? LightningStrikeEvent.Cause.COMMAND : LightningStrikeEvent.Cause.UNKNOWN);
LightningStrikeEvent.Cause cause = LightningStrikeEvent.Cause.UNKNOWN;
switch (spawnReason) {
case COMMAND:
cause = LightningStrikeEvent.Cause.COMMAND;
break;
case CUSTOM:
cause = LightningStrikeEvent.Cause.CUSTOM;
break;
case SPAWNER:
cause = LightningStrikeEvent.Cause.SPAWNER;
break;
}
// This event is called in nms-patches for common causes like Weather, Trap or Trident (SpawnReason.DEFAULT) then can ignore this cases for avoid two calls to this event
if (cause == LightningStrikeEvent.Cause.UNKNOWN && spawnReason == SpawnReason.DEFAULT) {
return true;
}
event = CraftEventFactory.callLightningStrikeEvent((LightningStrike) entity.getBukkitEntity(), cause);
} else if (!(entity instanceof EntityPlayer)) {
event = CraftEventFactory.callEntitySpawnEvent(entity);