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

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

import com.hypixel.hytale.server.core.universe.PlayerRef;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractTargetPlayerCommand;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.modules.entity.repulsion.Repulsion;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.types.EntityWrappedArg;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractWorldCommand;
import com.hypixel.hytale.server.core.command.system.AbstractCommand;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractCommandCollection;

public class RepulsionRemoveCommand extends AbstractCommandCollection
{
    @Nonnull
    private static final Message MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD;
    
    public RepulsionRemoveCommand() {
        super("remove", "server.commands.repulsion.remove.desc");
        this.addSubCommand(new RepulsionRemoveEntityCommand());
        this.addSubCommand(new RepulsionRemoveSelfCommand());
    }
    
    static {
        MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD = Message.translation("server.commands.errors.targetNotInWorld");
    }
    
    public static class RepulsionRemoveEntityCommand extends AbstractWorldCommand
    {
        @Nonnull
        private static final Message MESSAGE_COMMANDS_REPULSION_REMOVE_SUCCESS;
        @Nonnull
        private final EntityWrappedArg entityArg;
        
        public RepulsionRemoveEntityCommand() {
            super("entity", "server.commands.repulsion.remove.entity.desc");
            this.entityArg = this.withRequiredArg("entity", "server.commands.repulsion.remove.entity.desc", ArgTypes.ENTITY_ID);
        }
        
        @Override
        protected void execute(@Nonnull final CommandContext context, @Nonnull final World world, @Nonnull final Store<EntityStore> store) {
            final Ref<EntityStore> entityRef = this.entityArg.get(store, context);
            if (entityRef == null || !entityRef.isValid()) {
                context.sendMessage(RepulsionRemoveCommand.MESSAGE_COMMANDS_ERRORS_TARGET_NOT_IN_WORLD);
                return;
            }
            store.tryRemoveComponent(entityRef, Repulsion.getComponentType());
            context.sendMessage(RepulsionRemoveEntityCommand.MESSAGE_COMMANDS_REPULSION_REMOVE_SUCCESS);
        }
        
        static {
            MESSAGE_COMMANDS_REPULSION_REMOVE_SUCCESS = Message.translation("server.commands.repulsion.remove.success");
        }
    }
    
    public static class RepulsionRemoveSelfCommand extends AbstractTargetPlayerCommand
    {
        @Nonnull
        private static final Message MESSAGE_COMMANDS_REPULSION_REMOVE_SUCCESS;
        
        public RepulsionRemoveSelfCommand() {
            super("self", "server.commands.repulsion.remove.self.desc");
        }
        
        @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) {
            store.tryRemoveComponent(ref, Repulsion.getComponentType());
            context.sendMessage(RepulsionRemoveSelfCommand.MESSAGE_COMMANDS_REPULSION_REMOVE_SUCCESS);
        }
        
        static {
            MESSAGE_COMMANDS_REPULSION_REMOVE_SUCCESS = Message.translation("server.commands.repulsion.remove.success");
        }
    }
}
