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

package com.hypixel.hytale.builtin.portals.integrations;

import com.hypixel.hytale.math.vector.Transform;
import com.hypixel.hytale.server.core.universe.world.spawn.ISpawnProvider;
import com.hypixel.hytale.protocol.packets.worldmap.ContextMenuItem;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.util.PositionUtil;
import com.hypixel.hytale.server.core.universe.world.spawn.IndividualSpawnProvider;
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;

public class PortalMarkerProvider implements WorldMapManager.MarkerProvider
{
    public static final PortalMarkerProvider INSTANCE;
    
    @Override
    public void update(final World world, final MapMarkerTracker tracker, final int chunkViewRadius, final int playerChunkX, final int playerChunkZ) {
        final ISpawnProvider spawnProvider = world.getWorldConfig().getSpawnProvider();
        if (!(spawnProvider instanceof IndividualSpawnProvider)) {
            return;
        }
        final IndividualSpawnProvider individualSpawnProvider = (IndividualSpawnProvider)spawnProvider;
        final Transform spawnPoint = individualSpawnProvider.getFirstSpawnPoint();
        if (spawnPoint == null) {
            return;
        }
        tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, spawnPoint.getPosition(), spawnPoint.getRotation().getYaw(), "Portal", "Fragment Exit", spawnPoint, (id, name, sp) -> new MapMarker(id, name, "Portal.png", PositionUtil.toTransformPacket(sp), null));
    }
    
    static {
        INSTANCE = new PortalMarkerProvider();
    }
}
