001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package net.tridentsdk.inventory;
019
020import javax.annotation.concurrent.ThreadSafe;
021
022/**
023 * Represents an inventory or inventory that is opened to players
024 *
025 * @author The TridentSDK Team
026 * @since 0.3-alpha-DP
027 */
028@ThreadSafe
029public interface Inventory {
030    /**
031     * Obtains the ID of the inventory
032     *
033     * @return the inventory ID of this inventory
034     */
035    int id();
036
037    /**
038     * The available slots (not the slots taken up) in this inventory
039     *
040     * @return the inventory slots available
041     */
042    int length();
043
044    /**
045     * Finds the item at the specified slot in the inventory
046     *
047     * @param slot the slot to find the item
048     * @return the item at that slot
049     */
050    Item itemAt(int slot);
051
052    /**
053     * Sets the item at the slot. If the index is outside the bound, the effects are unspecified.
054     *
055     * @param index the index which to set the item at
056     * @param value the item to set at the index
057     */
058    void setSlot(int index, Item value);
059
060    /**
061     * Places an item into the player's inventory, where there is room
062     *
063     * @param item the item to place
064     * @return True if managed to place an item, false if failed
065     */
066    boolean putItem(Item item);
067
068    /**
069     * The title of the inventory
070     *
071     * @return the name displayed at the top of the inventory
072     */
073    String name();
074
075    /**
076     * Obtains the contents of the inventory represented by this inventory
077     *
078     * @return the items in the inventory
079     */
080    Item[] items();
081}