5454import org .bukkit .event .player .PlayerBucketFillEvent ;
5555import org .bukkit .event .player .PlayerCommandPreprocessEvent ;
5656import org .bukkit .event .player .PlayerDropItemEvent ;
57+ import org .bukkit .event .player .PlayerFishEvent ;
5758import org .bukkit .event .player .PlayerInteractAtEntityEvent ;
5859import org .bukkit .event .player .PlayerInteractEntityEvent ;
5960import org .bukkit .event .player .PlayerInteractEvent ;
6566import org .bukkit .potion .PotionEffect ;
6667import org .bukkit .potion .PotionEffectType ;
6768import org .bukkit .projectiles .ProjectileSource ;
69+ import org .bukkit .util .Vector ;
6870
6971import fr .xyness .SCS .SimpleClaimSystem ;
7072import fr .xyness .SCS .Types .CPlayer ;
@@ -362,6 +364,12 @@ public void onEntityExplode(EntityExplodeEvent event) {
362364 blockIterator .remove ();
363365 }
364366 }
367+ event .getEntity ().getNearbyEntities (5 , 5 , 5 ).forEach (entity -> {
368+ Chunk chunk = entity .getLocation ().getChunk ();
369+ if (instance .getMain ().checkIfClaimExists (chunk ) && !instance .getMain ().canPermCheck (chunk , "Explosions" , "Natural" )) {
370+ entity .setVelocity (new Vector (0 , 0 , 0 ));
371+ }
372+ });
365373 }
366374
367375 /**
@@ -384,6 +392,32 @@ public void onProjectileHit(ProjectileHitEvent event) {
384392 event .setCancelled (true );
385393 }
386394 }
395+ event .getEntity ().getNearbyEntities (5 , 5 , 5 ).forEach (entity -> {
396+ Chunk chunk = entity .getLocation ().getChunk ();
397+ if (instance .getMain ().checkIfClaimExists (chunk ) && !instance .getMain ().canPermCheck (chunk , "Explosions" , "Natural" )) {
398+ entity .setVelocity (new Vector (0 , 0 , 0 ));
399+ }
400+ });
401+ } else if (event .getEntityType () == EntityType .WIND_CHARGE ) {
402+ if (event .getHitBlock () != null ) {
403+ Block block = event .getHitBlock ();
404+ Chunk chunk = block .getLocation ().getChunk ();
405+ if (instance .getMain ().checkIfClaimExists (chunk ) && !instance .getMain ().canPermCheck (chunk , "Explosions" , "Natural" )) {
406+ event .setCancelled (true );
407+ }
408+ }
409+ if (event .getHitEntity () != null ) {
410+ Chunk chunk = event .getHitEntity ().getLocation ().getChunk ();
411+ if (instance .getMain ().checkIfClaimExists (chunk ) && !instance .getMain ().canPermCheck (chunk , "Explosions" , "Natural" )) {
412+ event .setCancelled (true );
413+ }
414+ }
415+ event .getEntity ().getNearbyEntities (5 , 5 , 5 ).forEach (entity -> {
416+ Chunk chunk = entity .getLocation ().getChunk ();
417+ if (instance .getMain ().checkIfClaimExists (chunk ) && !instance .getMain ().canPermCheck (chunk , "Explosions" , "Natural" )) {
418+ entity .setVelocity (new Vector (0 , 0 , 0 ));
419+ }
420+ });
387421 }
388422 }
389423
@@ -539,6 +573,8 @@ public void onHangingBreak(HangingBreakEvent event) {
539573 if (instance .getMain ().checkIfClaimExists (chunk )) {
540574 if (event .getCause () == HangingBreakEvent .RemoveCause .PHYSICS && !instance .getMain ().canPermCheck (chunk , "Destroy" , "Visitors" )) {
541575 event .setCancelled (true );
576+ } else if (event .getCause () == HangingBreakEvent .RemoveCause .EXPLOSION && !instance .getMain ().canPermCheck (chunk , "Explosions" , "Natural" )) {
577+ event .setCancelled (true );
542578 }
543579 }
544580 }
@@ -549,28 +585,9 @@ public void onHangingBreak(HangingBreakEvent event) {
549585 */
550586 @ EventHandler (priority = EventPriority .LOWEST )
551587 public void onHangingBreakByEntity (HangingBreakByEntityEvent event ) {
552- if (event .isCancelled ()) return ;
553- if (event .getEntity ().getType () == EntityType .PAINTING ) {
554- Chunk chunk = event .getEntity ().getLocation ().getChunk ();
555- if (event .getRemover () instanceof Player ) {
556- if (instance .getMain ().checkIfClaimExists (chunk )) {
557- Player player = (Player ) event .getRemover ();
558- if (instance .getPlayerMain ().checkPermPlayer (player , "scs.bypass" )) return ;
559- Claim claim = instance .getMain ().getClaim (chunk );
560- if (!claim .getPermissionForPlayer ("Destroy" , player )) {
561- event .setCancelled (true );
562- instance .getMain ().sendMessage (player ,instance .getLanguage ().getMessage ("destroy" ), instance .getSettings ().getSetting ("protection-message" ));
563- return ;
564- }
565- }
566- return ;
567- }
568- if (!instance .getMain ().canPermCheck (chunk , "Destroy" , "Visitors" )) {
569- event .setCancelled (true );
570- return ;
571- }
572- }
573- if (event .getEntity ().getType () == EntityType .ITEM_FRAME || event .getEntity ().getType () == EntityType .GLOW_ITEM_FRAME ) {
588+ if (event .getEntity ().getType () == EntityType .PAINTING
589+ || event .getEntity ().getType () == EntityType .ITEM_FRAME
590+ || event .getEntity ().getType () == EntityType .GLOW_ITEM_FRAME ) {
574591 Chunk chunk = event .getEntity ().getLocation ().getChunk ();
575592 if (event .getRemover () instanceof Player ) {
576593 if (instance .getMain ().checkIfClaimExists (chunk )) {
@@ -632,6 +649,31 @@ public void onBucketUse(PlayerBucketFillEvent event) {
632649 }
633650 }
634651
652+ /**
653+ * Handles the player fish event.
654+ *
655+ * @param event the player fish event.
656+ */
657+ @ EventHandler
658+ public void onPlayerFish (PlayerFishEvent event ) {
659+ Player player = event .getPlayer ();
660+ if (instance .getPlayerMain ().checkPermPlayer (player , "scs.bypass" )) return ;
661+ if (event .getCaught () instanceof Entity ) {
662+ Entity entity = event .getCaught ();
663+ if (entity != null ) {
664+ Chunk chunk = entity .getLocation ().getChunk ();
665+ if (instance .getMain ().checkIfClaimExists (chunk )) {
666+ Claim claim = instance .getMain ().getClaim (chunk );
667+ if (!claim .getPermissionForPlayer ("Entities" , player )) {
668+ event .setCancelled (true );
669+ instance .getMain ().sendMessage (player ,instance .getLanguage ().getMessage ("entities" ), instance .getSettings ().getSetting ("protection-message" ));
670+ return ;
671+ }
672+ }
673+ }
674+ }
675+ }
676+
635677 /**
636678 * Handles entity place events to prevent entity placement in claims.
637679 * @param event the entity place event.
@@ -991,7 +1033,7 @@ public void onBlockBurn(BlockBurnEvent event) {
9911033 * Handles entity damage by entity events to prevent damage to armor stands, item frames, and glow item frames in claims.
9921034 * @param event the entity damage by entity event.
9931035 */
994- @ EventHandler ( priority = EventPriority . LOWEST )
1036+ @ EventHandler
9951037 public void onEntityDamageByEntity2 (EntityDamageByEntityEvent event ) {
9961038 Entity entity = event .getEntity ();
9971039 if (entity instanceof ArmorStand || entity instanceof ItemFrame || entity instanceof GlowItemFrame ) {
@@ -1008,7 +1050,6 @@ public void onEntityDamageByEntity2(EntityDamageByEntityEvent event) {
10081050 }
10091051 return ;
10101052 }
1011-
10121053 if (!instance .getMain ().canPermCheck (chunk , "Destroy" , "Visitors" )) {
10131054 event .setCancelled (true );
10141055 }
@@ -1019,7 +1060,7 @@ public void onEntityDamageByEntity2(EntityDamageByEntityEvent event) {
10191060 * Handles entity damage by entity events to prevent damage to non-player, non-monster, non-armor stand, non-item frame entities in claims.
10201061 * @param event the entity damage by entity event.
10211062 */
1022- @ EventHandler ( priority = EventPriority . LOWEST )
1063+ @ EventHandler
10231064 public void onEntityDamageByEntity (EntityDamageByEntityEvent event ) {
10241065 Entity entity = event .getEntity ();
10251066 Chunk chunk = entity .getLocation ().getChunk ();
0 commit comments