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

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

import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
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 javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractTargetPlayerCommand;

public class PlayerZoneCommand extends AbstractTargetPlayerCommand
{
    @Nonnull
    private static final Message MESSAGE_NO_DATA;
    
    public PlayerZoneCommand() {
        super("zone", "server.commands.player.zone.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 WorldMapTracker worldMapTracker = playerComponent.getWorldMapTracker();
        final WorldMapTracker.ZoneDiscoveryInfo currentZone = worldMapTracker.getCurrentZone();
        final String currentBiome = worldMapTracker.getCurrentBiomeName();
        if (currentZone == null || currentBiome == null) {
            context.sendMessage(PlayerZoneCommand.MESSAGE_NO_DATA);
            return;
        }
        context.sendMessage(Message.translation("server.commands.player.zone.currentZone").param("zone", Message.translation(String.format("server.map.region.%s", currentZone.regionName()))));
        context.sendMessage(Message.translation("server.commands.player.zone.currentBiome").param("biome", currentBiome));
    }
    
    static {
        MESSAGE_NO_DATA = Message.translation("server.commands.player.zone.noData");
    }
}
