Search in sources :

Example 1 with BlockRegenJob

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;
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Player(org.bukkit.entity.Player) BlockRegenJob(gg.projecteden.nexus.models.scheduledjobs.jobs.BlockRegenJob) Block(org.bukkit.block.Block) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)1 BlockRegenJob (gg.projecteden.nexus.models.scheduledjobs.jobs.BlockRegenJob)1 SoundBuilder (gg.projecteden.nexus.utils.SoundBuilder)1 Material (org.bukkit.Material)1 Block (org.bukkit.block.Block)1 Player (org.bukkit.entity.Player)1 ItemStack (org.bukkit.inventory.ItemStack)1