import * as mc from '@minecraft/server';

export default class entityManager {
    constructor() {
    };
    
    entitiesFromQuery(getEntity, options, dimension) {
        let entity = (options,dimension) => {
            switch (getEntity) {
                case "getPlayers":
                    return Array.from(mc.world[getEntity](options));
                    break;
                case "getEntities":
                    return Array.from(dimension[getEntity](options));
                    break;
            }
        }
        let get = () => {
            if (options !== undefined) {
                // let query = options;
                
                // let query = new mc.EntityQueryOpinions();
                let query = {};
                Object.keys(options).map((key,index) => {
                    query[key] = Object.values(options)[index];
                })
                
                return entity(query,dimension);
            } else {
                return entity();
            }
        }
        return get();
    }
    
}

