// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.builtin.path.commands;

import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
import com.hypixel.hytale.server.core.entity.entities.Player;
import java.util.UUID;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgumentType;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;

public class PrefabPathNewCommand extends AbstractPlayerCommand
{
    @Nonnull
    private final RequiredArg<String> pathNameArg;
    @Nonnull
    private final DefaultArg<Double> pauseTimeArg;
    @Nonnull
    private final DefaultArg<Float> observationAngleArg;
    
    public PrefabPathNewCommand() {
        super("new", "server.commands.npcpath.new.desc");
        this.pathNameArg = this.withRequiredArg("pathName", "server.commands.npcpath.new.pathName.desc", ArgTypes.STRING);
        this.pauseTimeArg = this.withDefaultArg("pauseTime", "server.commands.npcpath.new.pauseTime.desc", ArgTypes.DOUBLE, 0.0, "0.0");
        this.observationAngleArg = this.withDefaultArg("observationAngleDegrees", "server.commands.npcpath.new.observationAngleDegrees.desc", ArgTypes.FLOAT, 0.0f, "0.0");
    }
    
    @Override
    protected void execute(@Nonnull final CommandContext context, @Nonnull final Store<EntityStore> store, @Nonnull final Ref<EntityStore> ref, @Nonnull final PlayerRef playerRef, @Nonnull final World world) {
        final String pathName = this.pathNameArg.get(context);
        final Double pauseTime = this.pauseTimeArg.get(context);
        final Float obsvAngle = this.observationAngleArg.get(context);
        final UUID uuid = UUID.randomUUID();
        final Player playerComponent = store.getComponent(ref, Player.getComponentType());
        assert playerComponent != null;
        PrefabPathHelper.addMarker(store, ref, uuid, pathName, pauseTime, obsvAngle, (short)(-1), 0);
        BuilderToolsPlugin.getState(playerComponent, playerRef).setActivePrefabPath(uuid);
        context.sendMessage(Message.translation("server.npc.npcpath.editingPath").param("path", pathName));
    }
}
