---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Robotex140.
--- DateTime: 28-Jan-22 15:56
---

if isClient() then return end

require "Beehive/SBeehiveSystem"

local Commands = {}

local function noise(message) SBeehiveSystem.instance:noise(message) end

local function getBeehiveAt(x, y, z)
    return SBeehiveSystem.instance:getLuaObjectAt(x, y, z)
end

function Commands.harvest(player, args)
    local beehive = getBeehiveAt(args.x, args.y, args.z)
    print('beehive harvest called')
    if beehive and beehive:canHarvest() then
        beehive:harvest(beehive, player)
    else
        noise('no beehive found at '..args.x..','..args.y..','..args.z)
    end
end

function Commands.syncAll(player, args)
    local beehive = getBeehiveAt(args.x, args.y, args.z)
    print('beehive syncAll called')
    if beehive then
        beehive:syncAll()
    else
        noise('no beehive found at '..args.x..','..args.y..','..args.z)
    end
end

function Commands.addPollen(player, args)
    local beehive = getBeehiveAt(args.x, args.y, args.z)
    print('beehive addPollen called')
    if beehive then
        beehive:addPollen(beehive, player)
    else
        noise('no beehive found at '..args.x..','..args.y..','..args.z)
    end
end

function Commands.query(player, args)
    local beehive = getBeehiveAt(args.x, args.y, args.z)

    if beehive and beehive:canHarvest() then
        noise('beehive found at '..args.x..','..args.y..','..args.z)
    else
        noise('no beehive found at '..args.x..','..args.y..','..args.z)
    end
end

function Commands.removebeehive(player, args)
    local beehive = getBeehiveAt(args.x, args.y, args.z)
    if beehive then
        SBeehiveSystem.instance:removebeehive(beehive)
    else
        noise('no beehive found at '..args.x..','..args.y..','..args.z)
    end
end

function Commands.cheat(player, args)
    local beehive = getBeehiveAt(args.x, args.y, args.z)
    if beehive then
        beehive[args.var] = beehive[args.var] + args.count
        if beehive[args.var] < 0 then beehive[args.var] = 0 end
        if beehive[args.var] > 100 then beehive[args.var] = 100 end
        beehive:saveData()
    else
        noise('no beehive found at '..args.x..','..args.y..','..args.z)
    end
end

SBeehiveSystemCommands = Commands

