From 78922ea3379b8653a6e64dcdcf4e0f9d6e20d389 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Mon, 29 May 2023 22:58:24 +0200 Subject: [PATCH 1/3] Fix blast mining bonus drops option not working (#4895) --- .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 31131316c..5b6336149 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -275,7 +275,7 @@ public class MiningManager extends SkillManager { * @return the Blast Mining tier */ public int getDropMultiplier() { - if (mcMMO.p.getAdvancedConfig().isBlastMiningBonusDropsEnabled()) { + if (!mcMMO.p.getAdvancedConfig().isBlastMiningBonusDropsEnabled()) { return 0; } From 44ab8d93ab81e597ba467749ed55df618a1947b8 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 29 May 2023 14:15:04 -0700 Subject: [PATCH 2/3] Dev mode --- Changelog.txt | 3 +++ pom.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 2bae603ab..6e073a49d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.221 + Fixed blast mining bonus drops not working (Thanks warriiorrrr) + Version 2.1.220 (API) Added TreeFellerBlockBreakEvent class which extends FakeBlockBreakEvent (see notes), this is sent out during Tree Feller processing to allow other plugins to differentiate between Tree Feller and other fake block break events Config files update automatically again diff --git a/pom.xml b/pom.xml index 57739f082..1cb45e652 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.220 + 2.1.221-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO From e9a020565f46f94e7779ec779eb3db791ed29b47 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 29 May 2023 14:34:47 -0700 Subject: [PATCH 3/3] Added fail safes against bonus drop meta not being cleaned up --- Changelog.txt | 1 + .../nossr50/listeners/BlockListener.java | 23 ++++++++++--------- .../nossr50/listeners/EntityListener.java | 2 +- .../nossr50/runnables/PistonTrackerTask.java | 2 +- .../runnables/StickyPistonTrackerTask.java | 2 +- .../com/gmail/nossr50/util/BlockUtils.java | 12 ++++++++++ 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 6e073a49d..60488b325 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Version 2.1.221 Fixed blast mining bonus drops not working (Thanks warriiorrrr) + Added fail safes to prevent bonus drops metadata from lingering on blocks Version 2.1.220 (API) Added TreeFellerBlockBreakEvent class which extends FakeBlockBreakEvent (see notes), this is sent out during Tree Feller processing to allow other plugins to differentiate between Tree Feller and other fake block break events diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index d17b4ad85..71b062ba1 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -140,7 +140,7 @@ public class BlockListener implements Listener { movedBlock = block.getRelative(direction); if(BlockUtils.isWithinWorldBounds(movedBlock)) { - mcMMO.getPlaceStore().setTrue(movedBlock); + BlockUtils.setUnnaturalBlock(block); } } } @@ -166,12 +166,13 @@ public class BlockListener implements Listener { //Spigot makes bad things happen in its API if(BlockUtils.isWithinWorldBounds(movedBlock)) { - mcMMO.getPlaceStore().setTrue(movedBlock); + BlockUtils.setUnnaturalBlock(movedBlock); } for (Block block : event.getBlocks()) { - if(BlockUtils.isWithinWorldBounds(block)) { - mcMMO.getPlaceStore().setTrue(block.getRelative(direction)); + if(BlockUtils.isWithinWorldBounds(block) && BlockUtils.isWithinWorldBounds(block.getRelative(direction))) { + Block relativeBlock = block.getRelative(direction); + BlockUtils.setUnnaturalBlock(relativeBlock); } } } @@ -189,14 +190,13 @@ public class BlockListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) return; - BlockState blockState = event.getNewState(); if(ExperienceConfig.getInstance().isSnowExploitPrevented() && BlockUtils.shouldBeWatched(blockState)) { Block block = blockState.getBlock(); if(BlockUtils.isWithinWorldBounds(block)) { - mcMMO.getPlaceStore().setTrue(block); + BlockUtils.setUnnaturalBlock(block); } } } @@ -217,8 +217,9 @@ public class BlockListener implements Listener { BlockState newState = event.getNewState(); if(newState.getType() != Material.OBSIDIAN && ExperienceConfig.getInstance().doesBlockGiveSkillXP(PrimarySkillType.MINING, newState.getBlockData())) { - if(BlockUtils.isWithinWorldBounds(newState.getBlock())) { - mcMMO.getPlaceStore().setTrue(newState); + Block block = newState.getBlock(); + if(BlockUtils.isWithinWorldBounds(block)) { + BlockUtils.setUnnaturalBlock(block); } } } @@ -245,7 +246,7 @@ public class BlockListener implements Listener { if(BlockUtils.isWithinWorldBounds(block)) { //NOTE: BlockMultiPlace has its own logic so don't handle anything that would overlap if (!(event instanceof BlockMultiPlaceEvent)) { - mcMMO.getPlaceStore().setTrue(blockState); + BlockUtils.setUnnaturalBlock(block); } } @@ -289,8 +290,8 @@ public class BlockListener implements Listener { } //Track unnatural blocks - for(BlockState replacedStates : event.getReplacedBlockStates()) { - mcMMO.getPlaceStore().setTrue(replacedStates); + for(BlockState replacedState : event.getReplacedBlockStates()) { + BlockUtils.setUnnaturalBlock(replacedState.getBlock()); } } } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index d795a84eb..50df709e8 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -245,7 +245,7 @@ public class EntityListener implements Listener { metaCleanupTask.runTaskTimer(pluginRef, 20, 20*60); //6000 ticks is 5 minutes } else if (isTracked) { - mcMMO.getPlaceStore().setTrue(block); + BlockUtils.setUnnaturalBlock(block); entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef); } } else if ((block.getType() == Material.REDSTONE_ORE || block.getType().getKey().getKey().equalsIgnoreCase("deepslate_redstone_ore"))) { diff --git a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java index efe0dcc5b..1dc0d4ea6 100644 --- a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java @@ -35,7 +35,7 @@ public class PistonTrackerTask extends BukkitRunnable { Block nextBlock = b.getRelative(direction); if (nextBlock.hasMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING)) { - mcMMO.getPlaceStore().setTrue(nextBlock); + BlockUtils.setUnnaturalBlock(nextBlock); nextBlock.removeMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING, mcMMO.p); } else if (mcMMO.getPlaceStore().isTrue(nextBlock)) { diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java index d90da3b31..40e21b71b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java @@ -30,6 +30,6 @@ public class StickyPistonTrackerTask extends BukkitRunnable { // The sticky piston actually pulled the block so move the PlaceStore data mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction)); - mcMMO.getPlaceStore().setTrue(movedBlock); + BlockUtils.setUnnaturalBlock(movedBlock); } } diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 06b0ef31b..d9df151f6 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -38,6 +38,18 @@ public final class BlockUtils { blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p)); } + /** + * Set up the state for a block to be seen as unnatural and cleanup any unwanted metadata from the block + * @param block target block + */ + public static void setUnnaturalBlock(@NotNull Block block) { + mcMMO.getPlaceStore().setTrue(block); + + // Failsafe against lingering metadata + if(block.hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS)) + block.removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, mcMMO.p); + } + /** * Cleans up some block metadata when a block breaks and the metadata is no longer needed * This also sets the blocks coords to false in our chunk store