Skip to content

Commit

Permalink
GunshellDeathEvent fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazzkuh committed May 3, 2024
1 parent 78b288d commit 5d86678
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
import com.jazzkuh.gunshell.api.interfaces.GunshellWeaponImpl;
import com.jazzkuh.gunshell.api.objects.GunshellFireable;
import lombok.Getter;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class GunshellDeathEvent extends Event {
private final @Getter Player player;
@Getter
private final LivingEntity entity;

@Getter
private final LivingEntity killer;

private static final HandlerList handlers = new HandlerList();

public GunshellDeathEvent(Player player) {
this.player = player;
public GunshellDeathEvent(LivingEntity entity, LivingEntity killer) {
this.entity = entity;
this.killer = killer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void fireAction(Player player, GunshellRayTraceResult rayTraceResult, Con
if (damage > livingEntity.getHealth()) {
livingEntity.setHealth(0D);

GunshellDeathEvent gunshellDeathEvent = new GunshellDeathEvent(player);
GunshellDeathEvent gunshellDeathEvent = new GunshellDeathEvent(player, livingEntity);
Bukkit.getPluginManager().callEvent(gunshellDeathEvent);
} else {
EntityDamageByEntityEvent entityDamageByEntityEvent = new EntityDamageByEntityEvent(player, livingEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void fireAction(LivingEntity entity, Player player, ConfigurationSection
if (damage > entity.getHealth()) {
entity.setHealth(0D);

GunshellDeathEvent gunshellDeathEvent = new GunshellDeathEvent(player);
GunshellDeathEvent gunshellDeathEvent = new GunshellDeathEvent(player, entity);
Bukkit.getPluginManager().callEvent(gunshellDeathEvent);
} else {
EntityDamageByEntityEvent entityDamageByEntityEvent = new EntityDamageByEntityEvent(player, entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void fireAction(Player player, Location location, ConfigurationSection co
if (damage > livingEntity.getHealth()) {
livingEntity.setHealth(0D);

GunshellDeathEvent gunshellDeathEvent = new GunshellDeathEvent(player);
GunshellDeathEvent gunshellDeathEvent = new GunshellDeathEvent(player, livingEntity);
Bukkit.getPluginManager().callEvent(gunshellDeathEvent);
} else {
EntityDamageByEntityEvent entityDamageByEntityEvent = new EntityDamageByEntityEvent(player, livingEntity,
Expand Down

0 comments on commit 5d86678

Please sign in to comment.