From 445d4579b6c4746a682deb0bf89d79d755d5fd33 Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:46:11 -0600 Subject: [PATCH 1/2] Account for block placer --- .../listeners/MiningListener.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java b/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java index 868808a..c676309 100644 --- a/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java +++ b/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java @@ -1,5 +1,6 @@ package ne.fnfal113.relicsofcthonia.listeners; +import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; import lombok.Getter; import ne.fnfal113.relicsofcthonia.RelicsOfCthonia; import ne.fnfal113.relicsofcthonia.relics.abstracts.AbstractRelic; @@ -92,15 +93,25 @@ public void onBlockBreak(BlockBreakEvent event) { @EventHandler public void onBlockPlace(BlockPlaceEvent event){ - if(event.isCancelled()){ - return; + if(!event.isCancelled()){ + handlePlacedBlock(event.getBlockPlaced()); + } + } + + @EventHandler + public void onBlockPlacerPlaced(BlockPlacerPlaceEvent event) { + if(!event.isCancelled()){ + handlePlacedBlock(event.getBlock()); } + } + + public void handlePlacedBlock(Block block) { /* * Prevent players from block place farming any relics * This will be detected above in the block break event */ - event.getBlockPlaced().setMetadata("placed_block", new FixedMetadataValue(RelicsOfCthonia.getInstance(), "placed")); + block.setMetadata("placed_block", new FixedMetadataValue(RelicsOfCthonia.getInstance(), "placed")); } } From 3a0a29f6cfdc68da9c44bf9f66532fc6512f953e Mon Sep 17 00:00:00 2001 From: FN-FAL113 Date: Thu, 22 Feb 2024 12:59:55 +0800 Subject: [PATCH 2/2] formatting and bump pom version --- pom.xml | 6 +++--- .../relicsofcthonia/listeners/MiningListener.java | 10 +++++----- .../listeners/RelicPlaceBreakListener.java | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index a20ec83..121d595 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ne.fnfal113 RelicsOfCthonia - Unofficial-1.8.1 + Unofficial-1.8.2 jar RelicsOfCthonia @@ -119,14 +119,14 @@ com.github.baked-libs.dough dough-updater - c4231a4d1a + fcdbd45aa0 compile com.github.baked-libs.dough dough-common - c4231a4d1a + fcdbd45aa0 compile diff --git a/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java b/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java index c676309..8761c8b 100644 --- a/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java +++ b/src/main/java/ne/fnfal113/relicsofcthonia/listeners/MiningListener.java @@ -41,7 +41,7 @@ public void onBlockBreak(BlockBreakEvent event) { Material blockBrokeType = block.getType(); // only naturally generated blocks are accepted to prevent place and break farming - if(block.hasMetadata("placed_block")){ + if(block.hasMetadata("placed_block")) { block.removeMetadata("placed_block", RelicsOfCthonia.getInstance()); return; @@ -52,7 +52,7 @@ public void onBlockBreak(BlockBreakEvent event) { ThreadLocalRandom currentRandomThread = ThreadLocalRandom.current(); Utils.createAsyncTask(asyncTask -> { - Iterator>> dropIterator = getWhereToDropMaterialMap().entrySet().iterator(); + Iterator>> dropIterator = getWhereToDropMaterialMap().entrySet().iterator(); while (dropIterator.hasNext()) { Map.Entry> pair = dropIterator.next(); @@ -92,15 +92,15 @@ public void onBlockBreak(BlockBreakEvent event) { } @EventHandler - public void onBlockPlace(BlockPlaceEvent event){ - if(!event.isCancelled()){ + public void onBlockPlace(BlockPlaceEvent event) { + if(!event.isCancelled()) { handlePlacedBlock(event.getBlockPlaced()); } } @EventHandler public void onBlockPlacerPlaced(BlockPlacerPlaceEvent event) { - if(!event.isCancelled()){ + if(!event.isCancelled()) { handlePlacedBlock(event.getBlock()); } } diff --git a/src/main/java/ne/fnfal113/relicsofcthonia/listeners/RelicPlaceBreakListener.java b/src/main/java/ne/fnfal113/relicsofcthonia/listeners/RelicPlaceBreakListener.java index 5f03c76..5b6986f 100644 --- a/src/main/java/ne/fnfal113/relicsofcthonia/listeners/RelicPlaceBreakListener.java +++ b/src/main/java/ne/fnfal113/relicsofcthonia/listeners/RelicPlaceBreakListener.java @@ -79,7 +79,7 @@ public void onRelicPlace(BlockPlaceEvent event){ Optional relic = Optional.ofNullable(SlimefunItem.getByItem(itemInHand)); relic.ifPresent(item -> { - if(item instanceof AbstractRelic){ + if(item instanceof AbstractRelic) { Utils.sendRelicMessage("You placed a relic, it will not drop anything once broken!", event.getPlayer()); } }); @@ -87,7 +87,7 @@ public void onRelicPlace(BlockPlaceEvent event){ } @EventHandler - public void onRelicBreak(BlockBreakEvent event){ + public void onRelicBreak(BlockBreakEvent event) { if(event.isCancelled()){ return; } @@ -97,7 +97,7 @@ public void onRelicBreak(BlockBreakEvent event){ Optional relic = Optional.ofNullable(BlockStorage.check(blockBroken)); relic.ifPresent(item -> { - if(item instanceof AbstractRelic){ + if(item instanceof AbstractRelic) { event.setCancelled(true); BlockStorage.clearBlockInfo(blockBroken);