001package net.tnemc.item; 002 003/* 004 * The New Item Library Minecraft Server Plugin 005 * 006 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar 007 * 008 * This program is free software; you can redistribute it and/or 009 * modify it under the terms of the GNU Lesser General Public 010 * License as published by the Free Software Foundation; either 011 * version 3 of the License, or (at your option) any later version. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 016 * Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public License 019 * along with this program; if not, write to the Free Software Foundation, 020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 021 */ 022 023import java.util.Optional; 024 025//not close to being done yet 026public interface AbstractInventory<T, I> { 027 028 /** 029 * Used to get the platform's inventory object. 030 * 031 * @return The platform's inventory object. 032 */ 033 T inventory(); 034 035 boolean canFit(AbstractItemStack<I> item); 036 037 /** 038 * Used to add an item to the inventory. 039 * 040 * @param item The item to add to the inventory. 041 * @param drop If the leftover items that won't fit in the inventory should be dropped or not. 042 * 043 * @return If drop is set to true this is an empty optional, or if drop is false then this is an 044 * optional containing the leftover items that wouldn't fit into the inventory. 045 */ 046 Optional<AbstractItemStack<I>> addItem(AbstractItemStack<I> item, boolean drop); 047 048 /** 049 * Used to set a specific slot as a specific item. 050 * 051 * @param slot The slot number to set the item in. 052 * @param item The item to set the slot as. 053 * @param drop If this is true if there is an item in the slot already it is dropped. 054 * 055 * @return If drop is set to true this is an empty optional, or if drop is false then this is an 056 * optional containing the item that was in the slot before if applicable. 057 */ 058 Optional<AbstractItemStack<I>> setSlot(int slot, AbstractItemStack<I> item, boolean drop); 059}