From 87b00eb838aaf07fffb47feb7f17354edf7747a1 Mon Sep 17 00:00:00 2001 From: DevMiner Date: Fri, 17 Mar 2023 23:36:16 +0100 Subject: [PATCH 1/3] cancel sculk detection events --- .../org/kitteh/vanish/listeners/ListenEntity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java b/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java index 01ca895..72eee6c 100644 --- a/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java +++ b/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java @@ -22,6 +22,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockReceiveGameEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; @@ -85,4 +86,15 @@ public void onVehicleEntityCollision(@NonNull VehicleEntityCollisionEvent event) event.setCancelled(true); } } + + @EventHandler(ignoreCancelled = true) + public void onBlockReceiveGameEvent(@NonNull BlockReceiveGameEvent event) { + if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + + if (this.plugin.getManager().isVanished(player)) { + event.setCancelled(true); + } + } + } } From efbfc00de70997657925834c45734366373fb098 Mon Sep 17 00:00:00 2001 From: TheDevMinerTV Date: Tue, 28 Mar 2023 21:18:51 +0200 Subject: [PATCH 2/3] fix: use java 14's pattern matching for casting in sculk sensor event cancelling Co-authored-by: Aleksander Jagiello --- src/main/java/org/kitteh/vanish/listeners/ListenEntity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java b/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java index 72eee6c..39847d7 100644 --- a/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java +++ b/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java @@ -89,8 +89,7 @@ public void onVehicleEntityCollision(@NonNull VehicleEntityCollisionEvent event) @EventHandler(ignoreCancelled = true) public void onBlockReceiveGameEvent(@NonNull BlockReceiveGameEvent event) { - if (event.getEntity() instanceof Player) { - Player player = (Player) event.getEntity(); + if (event.getEntity() instanceof Player player) { if (this.plugin.getManager().isVanished(player)) { event.setCancelled(true); From 716b041541a001da4e0de1cca57c573ab3b78123 Mon Sep 17 00:00:00 2001 From: TheDevMinerTV Date: Tue, 28 Mar 2023 21:19:14 +0200 Subject: [PATCH 3/3] style: fix formatting --- src/main/java/org/kitteh/vanish/listeners/ListenEntity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java b/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java index 39847d7..d364b0d 100644 --- a/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java +++ b/src/main/java/org/kitteh/vanish/listeners/ListenEntity.java @@ -90,7 +90,6 @@ public void onVehicleEntityCollision(@NonNull VehicleEntityCollisionEvent event) @EventHandler(ignoreCancelled = true) public void onBlockReceiveGameEvent(@NonNull BlockReceiveGameEvent event) { if (event.getEntity() instanceof Player player) { - if (this.plugin.getManager().isVanished(player)) { event.setCancelled(true); }