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

package com.hypixel.hytale.server.core.command.commands.player.stats;

import com.hypixel.hytale.server.core.command.commands.world.entity.stats.EntityStatsSetCommand;
import java.util.Collections;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Ref;
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 javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractTargetPlayerCommand;

public class PlayerStatsSetCommand extends AbstractTargetPlayerCommand
{
    @Nonnull
    private final RequiredArg<String> entityStatNameArg;
    @Nonnull
    private final RequiredArg<Integer> statValueArg;
    
    public PlayerStatsSetCommand() {
        super("set", "server.commands.player.stats.set.desc");
        this.entityStatNameArg = this.withRequiredArg("statName", "server.commands.player.stats.set.statName.desc", ArgTypes.STRING);
        this.statValueArg = this.withRequiredArg("statValue", "server.commands.player.stats.set.statValue.desc", ArgTypes.INTEGER);
    }
    
    @Override
    protected void execute(@Nonnull final CommandContext context, @Nullable final Ref<EntityStore> sourceRef, @Nonnull final Ref<EntityStore> ref, @Nonnull final PlayerRef playerRef, @Nonnull final World world, @Nonnull final Store<EntityStore> store) {
        final int newStatValue = this.statValueArg.get(context);
        final String entityStat = this.entityStatNameArg.get(context);
        EntityStatsSetCommand.setEntityStat(context, Collections.singletonList(playerRef.getReference()), newStatValue, entityStat, store);
    }
}
