package me.km.snuviscript.commands;

import java.util.UUID;
import me.hammerle.snuviscript.code.ScriptManager;
import me.km.events.CustomEventCaller;
import me.km.events.PlayerMoveData;
import me.km.utils.Location;

public class EventCommands {
    public static void registerFunctions(ScriptManager sm, CustomEventCaller cec) {
        sm.registerFunction("event.addmovedata", (sc, in) -> {
            UUID uuid = in.length >= 5 ? CommandUtils.getUUID(in[4].get(sc)) : null;
            PlayerMoveData pmd = new PlayerMoveData(sc, (Location) in[0].get(sc), (Location) in[1].get(sc), in[2].getInt(sc), in[3].getInt(sc), uuid);
            return (double) cec.registerMoveData(pmd);
        });
        sm.registerConsumer("event.removemovedata", (sc, in) -> cec.removeMoveData(in[0].getInt(sc)));
    }
}
