File tree 1 file changed +18
-0
lines changed
src/main/java/world/bentobox/bentobox/listeners/flags/protection
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
package world .bentobox .bentobox .listeners .flags .protection ;
2
2
3
+ import org .bukkit .entity .Egg ;
4
+ import org .bukkit .entity .Player ;
3
5
import org .bukkit .event .EventHandler ;
4
6
import org .bukkit .event .EventPriority ;
7
+ import org .bukkit .event .entity .ProjectileHitEvent ;
5
8
import org .bukkit .event .player .PlayerEggThrowEvent ;
6
9
7
10
import world .bentobox .bentobox .api .flags .FlagListener ;
@@ -24,4 +27,19 @@ public void onEggThrow(PlayerEggThrowEvent e) {
24
27
e .setHatching (false );
25
28
}
26
29
}
30
+
31
+ /**
32
+ * Handle visitor chicken egg hitting
33
+ * @param e - event
34
+ */
35
+ @ EventHandler (priority = EventPriority .LOW , ignoreCancelled = true )
36
+ public void onEggHit (ProjectileHitEvent e ) {
37
+ if (e .getEntity () instanceof Egg egg ) {
38
+ if (egg .getShooter () instanceof Player player ) {
39
+ if (!checkIsland (e , player , egg .getLocation (), Flags .EGGS )) {
40
+ e .setCancelled (true );
41
+ }
42
+ }
43
+ }
44
+ }
27
45
}
You can’t perform that action at this time.
0 commit comments