// Path: src/com/pie/tlatoani/Util/Collections/Streamable.java
// public interface Streamable<T> extends Iterable<T> {
// 
//     default Stream<T> stream() {
//         return Streams.stream(this);
//     }
// 
//     static <T> Streamable<T> empty() {
//         return of(Collections.<T>emptyList());
//     }
// 
//     static <T> Streamable<T> singleton(T element) {
//         return of(Collections.singleton(element));
//     }
// 
//     static <T> Streamable<T> of(T[] array) {
//         return of(Arrays.asList(array));
//     }
// 
//     static <T> Streamable<T> of(Collection<T> collection) {
//         return new StreamableCollection<>(collection);
//     }
// 
//     class StreamableCollection<T> implements Streamable<T> {
//         private final Collection<T> collection;
// 
//         private StreamableCollection(Collection<T> collection) {
//             this.collection = collection;
//         }
// 
//         @Override
//         public Iterator<T> iterator() {
//             return collection.iterator();
//         }
// 
//         @Override
//         public Stream<T> stream() {
//             return collection.stream();
//         }
//     }
// }
// 
// Path: src/com/pie/tlatoani/Core/Static/OptionalUtil.java
// public class OptionalUtil {
// 
//     public static <T> void consume(Optional<T> optional, Runnable runnable, Consumer<T> tConsumer) {
//         if (optional.isPresent()) {
//             optional.ifPresent(tConsumer);
//         } else {
//             runnable.run();
//         }
//     }
// 
//     /*public static <T, R> R map(Optional<T> optional, Supplier<R> supplier, Function<T, R> function) {
//         return optional.map(function).orElseGet(supplier);
//     }*/
// 
//     public static <T> Stream<T> stream(Optional<T> optional) {
//         return optional.map(Stream::of).orElseGet(Stream::empty);
//     }
// 
//     public static <S, T extends S> Optional<T> cast(S obj, Class<T> tClass) {
//         if (tClass.isInstance(obj)) {
//             return Optional.of((T) obj);
//         } else {
//             return Optional.empty();
//         }
//     }
// 
//     public static <T> boolean equal(@Nullable T t, Optional<T> optional) {
//         if (optional == null) {
//             throw new IllegalArgumentException("The optional argument should not be null");
//         } else if (t == null) {
//             return !optional.isPresent();
//         } else {
//             return optional.map(t::equals).orElse(false);
//         }
//     }
// 
//     public static <T> boolean referencesEqual(@Nullable T t, Optional<T> optional) {
//         if (optional == null) {
//             throw new IllegalArgumentException("The optional argument should not be null");
//         } else if (t == null) {
//             return !optional.isPresent();
//         } else {
//             return optional.map(val -> t == val).orElse(false);
//         }
//     }
// }


import ch.njol.skript.lang.Expression;
import com.pie.tlatoani.Core.Static.Utilities;
import com.pie.tlatoani.Tablist.Tablist;
import com.pie.tlatoani.Tablist.TablistManager;
import com.pie.tlatoani.Util.Collections.Streamable;
import com.pie.tlatoani.Core.Static.OptionalUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;

        @Override
        public String toString(String syntax) {
            return syntax
                    .replace("[", "")
                    .replace("%", toString())
                    .replace("]", "");
        }

        @Override
        public boolean check(Event event, Function<Tablist, Boolean> condition, boolean positive) {
            return Utilities.check(
                    expression,
                    event,
                    player -> player.isOnline() && condition.apply(TablistManager.getTablistOfPlayer(player)),
                    positive
            );
        }

        @Override
        public boolean isSingle() {
            return expression.isSingle();
        }
    }

    private static class TablistOfPlayerIterator implements Iterator<Tablist> {
        private final Iterator<? extends Player> playerIterator;
        private Player next = null;

        private TablistOfPlayerIterator(Iterator<? extends Player> playerIterator) {
// Path: src/com/pie/tlatoani/Util/Collections/Streamable.java
// public interface Streamable<T> extends Iterable<T> {
// 
//     default Stream<T> stream() {
//         return Streams.stream(this);
//     }
// 
//     static <T> Streamable<T> empty() {
//         return of(Collections.<T>emptyList());
//     }
// 
//     static <T> Streamable<T> singleton(T element) {
//         return of(Collections.singleton(element));
//     }
// 
//     static <T> Streamable<T> of(T[] array) {
//         return of(Arrays.asList(array));
//     }
// 
//     static <T> Streamable<T> of(Collection<T> collection) {
//         return new StreamableCollection<>(collection);
//     }
// 
//     class StreamableCollection<T> implements Streamable<T> {
//         private final Collection<T> collection;
// 
//         private StreamableCollection(Collection<T> collection) {
//             this.collection = collection;
//         }
// 
//         @Override
//         public Iterator<T> iterator() {
//             return collection.iterator();
//         }
// 
//         @Override
//         public Stream<T> stream() {
//             return collection.stream();
//         }
//     }
// }
// 
// Path: src/com/pie/tlatoani/Core/Static/OptionalUtil.java
// public class OptionalUtil {
// 
//     public static <T> void consume(Optional<T> optional, Runnable runnable, Consumer<T> tConsumer) {
//         if (optional.isPresent()) {
//             optional.ifPresent(tConsumer);
//         } else {
//             runnable.run();
//         }
//     }
// 
//     /*public static <T, R> R map(Optional<T> optional, Supplier<R> supplier, Function<T, R> function) {
//         return optional.map(function).orElseGet(supplier);
//     }*/
// 
//     public static <T> Stream<T> stream(Optional<T> optional) {
//         return optional.map(Stream::of).orElseGet(Stream::empty);
//     }
// 
//     public static <S, T extends S> Optional<T> cast(S obj, Class<T> tClass) {
//         if (tClass.isInstance(obj)) {
//             return Optional.of((T) obj);
//         } else {
//             return Optional.empty();
//         }
//     }
// 
//     public static <T> boolean equal(@Nullable T t, Optional<T> optional) {
//         if (optional == null) {
//             throw new IllegalArgumentException("The optional argument should not be null");
//         } else if (t == null) {
//             return !optional.isPresent();
//         } else {
//             return optional.map(t::equals).orElse(false);
//         }
//     }
// 
//     public static <T> boolean referencesEqual(@Nullable T t, Optional<T> optional) {
//         if (optional == null) {
//             throw new IllegalArgumentException("The optional argument should not be null");
//         } else if (t == null) {
//             return !optional.isPresent();
//         } else {
//             return optional.map(val -> t == val).orElse(false);
//         }
//     }
// }


// Path: src/com/pie/tlatoani/Tablist/Group/TablistProvider.java
import ch.njol.skript.lang.Expression;
import com.pie.tlatoani.Core.Static.Utilities;
import com.pie.tlatoani.Tablist.Tablist;
import com.pie.tlatoani.Tablist.TablistManager;
import com.pie.tlatoani.Util.Collections.Streamable;
import com.pie.tlatoani.Core.Static.OptionalUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;


        @Override
        public String toString(String syntax) {
            return syntax
                    .replace("[", "")
                    .replace("%", toString())
                    .replace("]", "");
        }

        @Override
        public boolean check(Event event, Function<Tablist, Boolean> condition, boolean positive) {
            return Utilities.check(
                    expression,
                    event,
                    player -> player.isOnline() && condition.apply(TablistManager.getTablistOfPlayer(player)),
                    positive
            );
        }

        @Override
        public boolean isSingle() {
            return expression.isSingle();
        }
    }

    private static class TablistOfPlayerIterator implements Iterator<Tablist> {
        private final Iterator<? extends Player> playerIterator;
        private Player next = null;

        private TablistOfPlayerIterator(Iterator<? extends Player> playerIterator) {
            this.playerIterator = playerIterator;