Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #81 from Invvk/bug/entity-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Invvk authored May 3, 2022
2 parents 4d19c16 + a5d7909 commit 73c8022
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -15,6 +16,8 @@
import io.github.invvk.wgef.abstraction.WGEFUtils;
import io.github.invvk.wgef.abstraction.flags.WGEFlags;

import java.util.Objects;

public final class EntityBreakListener implements Listener {

private final WGEFPlugin plugin;
Expand All @@ -26,11 +29,15 @@ public EntityBreakListener(WGEFPlugin plugin) {

@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(DamageEntityEvent e) {
if (!(e.getOriginalEvent() instanceof EntityDamageByEntityEvent original) || !(original.getDamager() instanceof Player damager)) {
if (!(e.getOriginalEvent() instanceof EntityDamageByEntityEvent original)) {
return;
}

e.setResult(resolveBreakResult(damager, e.getEntity().getType(), e.getTarget(), WGEFlags.ALLOW_ENTITY_DAMAGE, WGEFlags.DENY_ENTITY_DAMAGE));
if (original.getDamager() instanceof Player player) {
e.setResult(resolveBreakResult(player, e.getEntity().getType(), e.getTarget(), WGEFlags.ALLOW_ENTITY_DAMAGE, WGEFlags.DENY_ENTITY_DAMAGE));
} else if (original.getDamager() instanceof Projectile projectile && projectile.getShooter() instanceof Player player) {
e.setResult(resolveBreakResult(player, e.getEntity().getType(), e.getTarget(), WGEFlags.ALLOW_ENTITY_DAMAGE, WGEFlags.DENY_ENTITY_DAMAGE));
}
}

@EventHandler(priority = EventPriority.LOWEST)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group 'io.github.invvk'
version '2.5-stable'
version '2.6-stable'

repositories {
mavenCentral()
Expand Down

0 comments on commit 73c8022

Please sign in to comment.