Skip to content

Commit

Permalink
Merge pull request #2557 from Noogear/fix/eggHit
Browse files Browse the repository at this point in the history
Add the protection flag for eggHit.
  • Loading branch information
tastybento authored Nov 17, 2024
2 parents 01eaea9 + 0410ddb commit 1f822f2
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package world.bentobox.bentobox.listeners.flags.protection;

import org.bukkit.entity.Egg;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;

import world.bentobox.bentobox.api.flags.FlagListener;
Expand All @@ -24,4 +27,19 @@ public void onEggThrow(PlayerEggThrowEvent e) {
e.setHatching(false);
}
}

/**
* Handle visitor chicken egg hitting
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEggHit(ProjectileHitEvent e) {
if (e.getEntity() instanceof Egg egg) {
if (egg.getShooter() instanceof Player player) {
if (!checkIsland(e, player, egg.getLocation(), Flags.EGGS)) {
e.setCancelled(true);
}
}
}
}
}

0 comments on commit 1f822f2

Please sign in to comment.