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

package com.hypixel.hytale.server.core.command.commands.debug.stresstest;

import java.util.concurrent.CompletableFuture;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand;

public class StressTestStopCommand extends AbstractAsyncCommand
{
    @Nonnull
    private static final Message MESSAGE_COMMANDS_STRESS_TEST_NOT_STARTED;
    @Nonnull
    private static final Message MESSAGE_COMMANDS_STRESS_TEST_STOPPED;
    
    public StressTestStopCommand() {
        super("stop", "server.commands.stresstest.stop.desc");
    }
    
    @Nonnull
    @Override
    protected CompletableFuture<Void> executeAsync(@Nonnull final CommandContext context) {
        if (!StressTestStartCommand.STATE.compareAndSet(StressTestStartCommand.StressTestState.RUNNING, StressTestStartCommand.StressTestState.STOPPING)) {
            context.sendMessage(StressTestStopCommand.MESSAGE_COMMANDS_STRESS_TEST_NOT_STARTED);
            return CompletableFuture.completedFuture((Void)null);
        }
        StressTestStartCommand.stop();
        context.sendMessage(StressTestStopCommand.MESSAGE_COMMANDS_STRESS_TEST_STOPPED);
        return CompletableFuture.completedFuture((Void)null);
    }
    
    static {
        MESSAGE_COMMANDS_STRESS_TEST_NOT_STARTED = Message.translation("server.commands.stresstest.notStarted");
        MESSAGE_COMMANDS_STRESS_TEST_STOPPED = Message.translation("server.commands.stresstest.stopped");
    }
}
