use of gg.projecteden.nexus.models.scheduledjobs.jobs.BlockRegenJob in project Nexus by ProjectEdenGG.
the class Mining method breakBlock.
public static boolean breakBlock(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material type = block.getType();
if (!OreType.getOres().contains(type))
return false;
OreType oreType = OreType.ofOre(type);
if (oreType == null)
return false;
ItemStack tool = player.getInventory().getItemInMainHand();
if (!oreType.canBeMinedBy(tool.getType())) {
if (new CooldownService().check(player, "BF21_cantbreak_tool", TickTime.SECOND.x(15))) {
send(Errors.CANT_BREAK + " with this tool. Needs either: " + oreType.getCanBreak(), player);
Quests.sound_villagerNo(player);
}
return true;
}
Quests.giveExp(player);
new SoundBuilder(Sound.BLOCK_STONE_BREAK).location(player.getLocation()).category(SoundCategory.BLOCKS).play();
PlayerUtils.giveItem(player, oreType.getIngotItemStack(tool));
new BlockRegenJob(block.getLocation(), block.getType()).schedule(randomInt(3 * 60, 5 * 60));
block.setType(Material.STONE);
return true;
}
Aggregations