package tc.oc.commons.bukkit.broadcast.model;

import java.util.List;
import java.util.stream.Stream;

import com.google.common.collect.ImmutableList;
import java.time.Duration;
import tc.oc.commons.core.inspect.Inspectable;
import tc.oc.commons.core.stream.Collectors;
import tc.oc.minecraft.server.ServerFilter;

/**
 * A periodic broadcast selected randomly from a set of localized messages
 */
public class BroadcastSchedule extends Inspectable.Impl {

    @Inspect private final Duration interval;
    @Inspect private final ImmutableList<BroadcastSet> messages;
    @Inspect private final ServerFilter serverFilter;

    public BroadcastSchedule(Duration interval, ServerFilter serverFilter, Stream<BroadcastSet> messages) {
        this.interval = interval;
        this.serverFilter = serverFilter;
        this.messages = messages.collect(Collectors.toImmutableList());
    }

    /**
     * Time between broadcasts
     */
    public Duration interval() {
        return interval;
    }

    /**
     * Relative path of the localized message list.
     *
     * This path is be relative to the localized root, and must NOT have an extension.
     */
    public List<BroadcastSet> messages() {
        return messages;
    }

    public ServerFilter serverFilter() {
        return serverFilter;
    }
}
