package com.hypixel.hytale.builtin.buildertools.snapshot; import com.hypixel.hytale.component.ComponentAccessor; import com.hypixel.hytale.component.Ref; import com.hypixel.hytale.component.RemoveReason; import com.hypixel.hytale.server.core.entity.entities.Player; import com.hypixel.hytale.server.core.universe.world.World; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import javax.annotation.Nonnull; public class EntityAddSnapshot implements EntitySnapshot { private final Ref entityRef; public EntityAddSnapshot(Ref entityRef) { this.entityRef = entityRef; } public Ref getEntityRef() { return this.entityRef; } public EntityRemoveSnapshot restoreEntity(@Nonnull Player player, @Nonnull World world, @Nonnull ComponentAccessor componentAccessor) { if (!this.entityRef.isValid()) { return null; } else { EntityRemoveSnapshot snapshot = new EntityRemoveSnapshot(this.entityRef); world.getEntityStore().getStore().removeEntity(this.entityRef, RemoveReason.UNLOAD); return snapshot; } } }