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

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

import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
import com.hypixel.hytale.server.core.command.system.CommandSender;
import com.hypixel.hytale.component.ComponentAccessor;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection;

public class BlockSelectionSnapshot implements SelectionSnapshot<BlockSelectionSnapshot>
{
    private final BlockSelection selection;
    
    public BlockSelectionSnapshot(final BlockSelection snapshot) {
        this.selection = snapshot;
    }
    
    public BlockSelection getBlockSelection() {
        return this.selection;
    }
    
    @Override
    public BlockSelectionSnapshot restore(final Ref<EntityStore> ref, final Player player, @Nonnull final World world, final ComponentAccessor<EntityStore> componentAccessor) {
        final BlockSelection before = this.selection.place(player, world);
        BuilderToolsPlugin.invalidateWorldMapForSelection(before, world);
        return new BlockSelectionSnapshot(before);
    }
    
    @Nonnull
    public static BlockSelectionSnapshot copyOf(@Nonnull final BlockSelection selection) {
        return new BlockSelectionSnapshot(selection.cloneSelection());
    }
}
