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

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

import com.hypixel.hytale.server.core.entity.entities.player.hud.HudManager;
import com.hypixel.hytale.protocol.packets.interface_.HudComponent;
import com.hypixel.hytale.server.core.entity.entities.Player;
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 com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.FlagArg;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractTargetPlayerCommand;

public class HudManagerTestCommand extends AbstractTargetPlayerCommand
{
    @Nonnull
    private static final Message MESSAGE_COMMANDS_HUD_TEST_SHOWN_SELF;
    @Nonnull
    private static final Message MESSAGE_COMMANDS_HUT_TEST_HIDDEN_SELF;
    @Nonnull
    private final FlagArg resetHudFlag;
    
    public HudManagerTestCommand() {
        super("hudtest", "server.commands.hudtest.desc");
        this.resetHudFlag = this.withFlagArg("reset", "server.commands.hudtest.reset.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 Player playerComponent = store.getComponent(ref, Player.getComponentType());
        assert playerComponent != null;
        final PlayerRef playerRefComponent = store.getComponent(ref, PlayerRef.getComponentType());
        assert playerRefComponent != null;
        final HudManager hudManager = playerComponent.getHudManager();
        final boolean isTargetingOther = !ref.equals(sourceRef);
        if (this.resetHudFlag.provided(context)) {
            hudManager.showHudComponents(playerRef, HudComponent.Hotbar);
            if (isTargetingOther) {
                context.sendMessage(Message.translation("server.commands.hudtest.shown.other").param("username", playerRefComponent.getUsername()));
            }
            else {
                context.sendMessage(HudManagerTestCommand.MESSAGE_COMMANDS_HUD_TEST_SHOWN_SELF);
            }
        }
        else {
            hudManager.hideHudComponents(playerRef, HudComponent.Hotbar);
            if (isTargetingOther) {
                context.sendMessage(Message.translation("server.commands.hudtest.hidden.other").param("username", playerRefComponent.getUsername()));
            }
            else {
                context.sendMessage(HudManagerTestCommand.MESSAGE_COMMANDS_HUT_TEST_HIDDEN_SELF);
            }
        }
    }
    
    static {
        MESSAGE_COMMANDS_HUD_TEST_SHOWN_SELF = Message.translation("server.commands.hudtest.shown.self");
        MESSAGE_COMMANDS_HUT_TEST_HIDDEN_SELF = Message.translation("server.commands.hudtest.hidden.self");
    }
}
