From e7b3dd2802ea353c575b971fa507e027a53aebe8 Mon Sep 17 00:00:00 2001 From: Jeroen Date: Wed, 26 Jul 2023 16:47:43 +0200 Subject: [PATCH 1/3] deobfuscate blocks when gold panning --- .../integrations/OrebfuscatorIntegration.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java index 25da081b68..fe55beddcb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java @@ -2,6 +2,7 @@ import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.annotation.Nonnull; @@ -14,8 +15,10 @@ import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent; +import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import net.imprex.orebfuscator.api.OrebfuscatorService; @@ -61,4 +64,14 @@ public void onExplosiveToolBreakBlocks(ExplosiveToolBreakBlocksEvent event) { public void onReactorExplode(ReactorExplodeEvent event) { this.service.deobfuscate(Arrays.asList(event.getLocation().getBlock())); } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onGoldPanUse(PlayerRightClickEvent event) { + if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent()) { + String id = event.getSlimefunItem().get().getId(); + if (id.equals(SlimefunItems.GOLD_PAN.getItemId()) || id.equals(SlimefunItems.NETHER_GOLD_PAN.getItemId())) { + this.service.deobfuscate(List.of(event.getClickedBlock().get())); + } + } + } } From e41a87d5a1ebe708ed411df2bb49d7378d1c13cb Mon Sep 17 00:00:00 2001 From: Jeroen Date: Sat, 29 Jul 2023 19:57:03 +0200 Subject: [PATCH 2/3] replaced id check with instanceof check --- .../slimefun4/integrations/OrebfuscatorIntegration.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java index fe55beddcb..08579b83bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java @@ -18,7 +18,7 @@ import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; import net.imprex.orebfuscator.api.OrebfuscatorService; @@ -68,8 +68,7 @@ public void onReactorExplode(ReactorExplodeEvent event) { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onGoldPanUse(PlayerRightClickEvent event) { if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent()) { - String id = event.getSlimefunItem().get().getId(); - if (id.equals(SlimefunItems.GOLD_PAN.getItemId()) || id.equals(SlimefunItems.NETHER_GOLD_PAN.getItemId())) { + if (event.getSlimefunItem().get() instanceof GoldPan) { this.service.deobfuscate(List.of(event.getClickedBlock().get())); } } From d4eb8f0703d469433765c679104ab999b44911e9 Mon Sep 17 00:00:00 2001 From: Jeroen Date: Sat, 29 Jul 2023 20:18:38 +0200 Subject: [PATCH 3/3] merged if statements --- .../slimefun4/integrations/OrebfuscatorIntegration.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java index 08579b83bb..f9982fec2e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java @@ -67,10 +67,8 @@ public void onReactorExplode(ReactorExplodeEvent event) { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onGoldPanUse(PlayerRightClickEvent event) { - if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent()) { - if (event.getSlimefunItem().get() instanceof GoldPan) { - this.service.deobfuscate(List.of(event.getClickedBlock().get())); - } + if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent() && event.getSlimefunItem().get() instanceof GoldPan) { + this.service.deobfuscate(List.of(event.getClickedBlock().get())); } } }