001package net.tnemc.item.platform.check;
002
003/*
004 * The New Item Library
005 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar
006 *
007 * This program is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 3 of the License, or (at your option) any later version.
011 *
012 * This program is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public License
018 * along with this program; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
020 */
021
022import net.tnemc.item.AbstractItemStack;
023import net.tnemc.item.platform.Identifiable;
024
025/**
026 * Represents a check to be performed on an item. Implementations should provide logic to determine if the check applies for a specific version,
027 * as well as perform the actual check on the item stack.
028 *
029 * @param <T> the type of item stack being checked
030 *
031 * @author creatorfromhell
032 * @since 0.2.0.0
033 */
034public interface ItemCheck<T> extends Identifiable {
035
036  /**
037   * @return true if the checks after this one should be skipped.
038   * @since 0.2.0.0
039   * @since 0.2.0.0
040   */
041  default boolean skipRest() {
042
043    return false;
044  }
045
046  /**
047   * @param version the version being used when this check is called.
048   *
049   * @return true if this check is enabled for the version, otherwise false
050   * @since 0.2.0.0
051   * @since 0.2.0.0
052   */
053  boolean enabled(final String version);
054
055  /**
056   * Determines if a given check should be applied to an original item stack for a specific version.
057   *
058   * @param original the original item stack to check against
059   * @param check the item stack to use for the check
060   * @return true if the check applies, false otherwise
061   * @since 0.2.0.0
062   * @since 0.2.0.0
063   */
064  boolean applies(final AbstractItemStack<T> original, final AbstractItemStack<T> check);
065
066  /**
067   * @param original the original stack
068   * @param check    the stack to use for the check
069   *
070   * @return True if the check passes, otherwise false.
071   * @since 0.2.0.0
072   * @since 0.2.0.0
073   */
074  boolean check(final AbstractItemStack<T> original, final AbstractItemStack<T> check);
075}