Bouncing crack is now compatible with block breaking player restrictions

This commit is contained in:
Jules 2022-03-01 21:40:46 +01:00
parent 94e28f0543
commit 57e3ecee99

View File

@ -1,17 +1,14 @@
package net.Indyuce.mmoitems.api.interaction;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.comp.flags.CustomFlag;
import net.Indyuce.mmoitems.MMOItems;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@ -61,6 +58,13 @@ public class Tool extends UseItem {
if (block.getType() == Material.AIR || MMOItems.plugin.getLanguage().isBlacklisted(block.getType()))
return;
BlockBreakEvent breakEvent = new BlockBreakEvent(block, player);
Bukkit.getPluginManager().callEvent(breakEvent);
if (breakEvent.isCancelled()) {
cancel();
return;
}
block.breakNaturally(getItem());
loc.getWorld().playSound(loc, Sound.BLOCK_GRAVEL_BREAK, 1, 1);
}