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

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

import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.builtin.buildertools.PrototypePlayerBuilderToolSettings;
import com.hypixel.hytale.server.core.entity.entities.Player;
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.protocol.GameMode;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;

public class RepairFillersCommand extends AbstractPlayerCommand
{
    @Nonnull
    private static final Message MESSAGE_BUILDER_TOOLS_REPAIR_FILLERS;
    
    public RepairFillersCommand() {
        super("repairfillers", "server.commands.repairfillers.desc");
        this.setPermissionGroup(GameMode.Creative);
    }
    
    @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 Player playerComponent = store.getComponent(ref, Player.getComponentType());
        assert playerComponent != null;
        if (!PrototypePlayerBuilderToolSettings.isOkayToDoCommandsOnSelection(ref, playerComponent, store)) {
            return;
        }
        BuilderToolsPlugin.addToQueue(playerComponent, playerRef, (r, s, c) -> s.repairFillers(r, c));
        context.sendMessage(RepairFillersCommand.MESSAGE_BUILDER_TOOLS_REPAIR_FILLERS);
    }
    
    static {
        MESSAGE_BUILDER_TOOLS_REPAIR_FILLERS = Message.translation("server.builderTools.repairFillers");
    }
}
