import { PolusBuffer } from "../../../../util/polusBuffer" ; import { PacketHandler } from "../../../packet" ; export interface SetTasksPacket { PlayerID : number ; TaskCount ? : number ; Tasks : number [ ] ; } export const SetTasks = { parse ( packet ) { const playerId = packet . readU8 ( ) ; const taskCount = packet . readVarInt ( ) ; let returnData = { PlayerID : playerId , TaskCount : taskCount , Tasks : [ ] , } ; for ( let i = 0 ; i < taskCount ; i ++ ) { returnData . Tasks [ i ] = packet . readU8 ( ) ; } return returnData ; } , serialize ( packet ) { let buf = new PolusBuffer ( ) ; buf . writeU8 ( packet . PlayerID ) ; buf . writeVarInt ( packet . Tasks . length ) ; for ( let i = 0 ; i < packet . Tasks . length ; i ++ ) { buf . writeU8 ( packet . Tasks [ i ] ) ; } return buf ; } , } ;