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

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

import com.hypixel.hytale.builtin.mounts.MountedComponent;
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 javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractTargetPlayerCommand;

public class MountCheckCommand extends AbstractTargetPlayerCommand
{
    private static final Message MESSAGE_COMMANDS_CHECK_NO_COMPONENT;
    private static final Message MESSAGE_COMMANDS_CHECK_MOUNTED_TO_ENTITY;
    private static final Message MESSAGE_COMMANDS_CHECK_MOUNTED_TO_BLOCK;
    private static final Message MESSAGE_COMMANDS_CHECK_UNKNOWN_STATUS;
    
    public MountCheckCommand() {
        super("check", "server.commands.check.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) {
        final MountedComponent mountedComponent = store.getComponent(ref, MountedComponent.getComponentType());
        if (mountedComponent == null) {
            playerRef.sendMessage(MountCheckCommand.MESSAGE_COMMANDS_CHECK_NO_COMPONENT);
            return;
        }
        if (mountedComponent.getMountedToEntity() != null) {
            playerRef.sendMessage(MountCheckCommand.MESSAGE_COMMANDS_CHECK_MOUNTED_TO_ENTITY);
        }
        else if (mountedComponent.getMountedToBlock() != null) {
            playerRef.sendMessage(MountCheckCommand.MESSAGE_COMMANDS_CHECK_MOUNTED_TO_BLOCK);
        }
        else {
            playerRef.sendMessage(MountCheckCommand.MESSAGE_COMMANDS_CHECK_UNKNOWN_STATUS);
        }
    }
    
    static {
        MESSAGE_COMMANDS_CHECK_NO_COMPONENT = Message.translation("server.commands.check.noComponent");
        MESSAGE_COMMANDS_CHECK_MOUNTED_TO_ENTITY = Message.translation("server.commands.check.mountedToEntity");
        MESSAGE_COMMANDS_CHECK_MOUNTED_TO_BLOCK = Message.translation("server.commands.check.mountedToBlock");
        MESSAGE_COMMANDS_CHECK_UNKNOWN_STATUS = Message.translation("server.commands.check.unknownStatus");
    }
}
