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

package com.hypixel.hytale.builtin.buildertools.prefabeditor;

import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import java.util.Iterator;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;

public class PrefabMarkerProvider implements WorldMapManager.MarkerProvider
{
    public static final PrefabMarkerProvider INSTANCE;
    
    @Override
    public void update(@Nonnull final World world, @Nonnull final MapMarkerTracker tracker, final int chunkViewRadius, final int playerChunkX, final int playerChunkZ) {
        final PrefabEditSessionManager sessionManager = BuilderToolsPlugin.get().getPrefabEditSessionManager();
        final Player player = tracker.getPlayer();
        final PrefabEditSession session = sessionManager.getPrefabEditSession(player.getUuid());
        if (session == null || !session.getWorldName().equals(world.getName())) {
            return;
        }
        for (final PrefabEditingMetadata metadata : session.getLoadedPrefabMetadata().values()) {
            final MapMarker marker = PrefabEditSession.createPrefabMarker(metadata);
            tracker.trySendMarker(chunkViewRadius, playerChunkX, playerChunkZ, marker);
        }
    }
    
    static {
        INSTANCE = new PrefabMarkerProvider();
    }
}
