From 680c7c50ba30b841d2ade3cee17a0571e098e0d1 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Fri, 25 Feb 2022 23:32:05 +0100 Subject: [PATCH] Fixes infinite exp bug --- .../Indyuce/mmocore/listener/BlockListener.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java b/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java index 227203b5..3553deca 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/BlockListener.java @@ -6,11 +6,12 @@ import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.block.BlockInfo; import net.Indyuce.mmocore.api.block.BlockInfo.BlockInfoOption; import net.Indyuce.mmocore.api.block.VanillaBlockType; -import net.Indyuce.mmocore.loot.droptable.condition.ConditionInstance; import net.Indyuce.mmocore.api.event.CustomBlockMineEvent; -import net.Indyuce.mmocore.loot.LootBuilder; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.util.MMOCoreUtils; +import net.Indyuce.mmocore.experience.source.MineBlockExperienceSource; +import net.Indyuce.mmocore.loot.LootBuilder; +import net.Indyuce.mmocore.loot.droptable.condition.ConditionInstance; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -139,14 +140,17 @@ public class BlockListener implements Listener { Schedulers.sync().runLater(() -> MMOCore.plugin.mineManager.initialize(info.startRegeneration(Bukkit.createBlockData(savedData), block.getLocation()), !temporaryBlock), 1); } - /* + /** * This is handled in a separate event because it * needs to happen AFTER it's already checked the tag + *

+ * Event priority is now set to {@link EventPriority#MONITOR} + * so that it does NOT interfere with the playerPlaced + * option from {@link MineBlockExperienceSource} */ - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void unregisterPlayerPlacedBlocksTag(BlockBreakEvent event) { - if (event.getBlock().hasMetadata("player_placed")) - event.getBlock().removeMetadata("player_placed", MMOCore.plugin); + event.getBlock().removeMetadata("player_placed", MMOCore.plugin); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)