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

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

import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.modules.entity.player.ChunkTracker;
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 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 StopNetworkChunkSendingCommand extends AbstractPlayerCommand
{
    @Nonnull
    private final RequiredArg<Boolean> sendNetworkChunksArg;
    
    public StopNetworkChunkSendingCommand() {
        super("networkChunkSending", "Stop sending chunks over the network");
        this.sendNetworkChunksArg = this.withRequiredArg("sendNetworkChunks", "Whether chunks should be sent over the network to yourself", ArgTypes.BOOLEAN);
    }
    
    @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 ChunkTracker chunkTrackerComponent = store.getComponent(ref, ChunkTracker.getComponentType());
        if (chunkTrackerComponent == null) {
            playerRef.sendMessage(Message.translation("server.commands.networkChunkSending.noComponent"));
            return;
        }
        final PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType());
        assert playerRefComponent != null;
        chunkTrackerComponent.setReadyForChunks(this.sendNetworkChunksArg.get(context));
        playerRef.sendMessage(Message.translation("server.commands.networkChunkSending.set").param("username", playerRefComponent.getUsername()).param("enabled", this.sendNetworkChunksArg.get(context)));
    }
}
