Prepare for 1.14
To continue providing renamed ender chests/player inventories we can no longer just provide an Inventory, a full InventoryView is required. To avoid confusion the old method has been removed entirely, leading to a major API revision bump.
This commit is contained in:
		@@ -16,16 +16,15 @@
 | 
			
		||||
 | 
			
		||||
package com.lishid.openinv;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
import com.lishid.openinv.internal.IAnySilentContainer;
 | 
			
		||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
import com.lishid.openinv.internal.ISpecialEnderChest;
 | 
			
		||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.plugin.Plugin;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Interface defining behavior for the OpenInv plugin.
 | 
			
		||||
@@ -45,49 +44,21 @@ public interface IOpenInv {
 | 
			
		||||
    boolean disableSaving();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the active ISilentContainer implementation. May return null if the server version is
 | 
			
		||||
     * unsupported.
 | 
			
		||||
     * Gets the active ISilentContainer implementation.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the ISilentContainer
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    IAnySilentContainer getAnySilentContainer();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an ISpecialEnderChest for the given Player. Returns null if the ISpecialEnderChest could
 | 
			
		||||
     * not be instantiated.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the Player
 | 
			
		||||
     * @param online true if the Player is currently online
 | 
			
		||||
     * @return the ISpecialEnderChest
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     * @deprecated Use {@link IOpenInv#getSpecialEnderChest(Player, boolean)}
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    @Nullable
 | 
			
		||||
    ISpecialEnderChest getEnderChest(Player player, boolean online);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an ISpecialPlayerInventory for the given Player. Returns null if the
 | 
			
		||||
     * ISpecialPlayerInventory could not be instantiated.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the Player
 | 
			
		||||
     * @param online true if the Player is currently online
 | 
			
		||||
     * @return the ISpecialPlayerInventory
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     * @deprecated Use {@link IOpenInv#getSpecialInventory(Player, boolean)}
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    @Nullable
 | 
			
		||||
    ISpecialPlayerInventory getInventory(Player player, boolean online);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the active IInventoryAccess implementation. May return null if the server version is
 | 
			
		||||
     * unsupported.
 | 
			
		||||
     * Gets the active IInventoryAccess implementation.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the IInventoryAccess
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    IInventoryAccess getInventoryAccess();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -97,7 +68,7 @@ public interface IOpenInv {
 | 
			
		||||
     * @return true if AnyChest is enabled
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    boolean getPlayerAnyChestStatus(OfflinePlayer player);
 | 
			
		||||
    boolean getPlayerAnyChestStatus(@NotNull OfflinePlayer player);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a unique identifier by which the OfflinePlayer can be referenced. Using the value
 | 
			
		||||
@@ -107,16 +78,17 @@ public interface IOpenInv {
 | 
			
		||||
     * @return the identifier
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    String getPlayerID(OfflinePlayer offline);
 | 
			
		||||
    @NotNull
 | 
			
		||||
    String getPlayerID(@NotNull OfflinePlayer offline);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets a player's SilentChest setting.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the OfflinePlayer
 | 
			
		||||
     * @param offline the OfflinePlayer
 | 
			
		||||
     * @return true if SilentChest is enabled
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    boolean getPlayerSilentChestStatus(OfflinePlayer player);
 | 
			
		||||
    boolean getPlayerSilentChestStatus(@NotNull OfflinePlayer offline);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an ISpecialEnderChest for the given Player.
 | 
			
		||||
@@ -127,7 +99,8 @@ public interface IOpenInv {
 | 
			
		||||
     * @throws IllegalStateException  if the server version is unsupported
 | 
			
		||||
     * @throws InstantiationException if the ISpecialEnderChest could not be instantiated
 | 
			
		||||
     */
 | 
			
		||||
    ISpecialEnderChest getSpecialEnderChest(Player player, boolean online) throws InstantiationException;
 | 
			
		||||
    @NotNull
 | 
			
		||||
    ISpecialEnderChest getSpecialEnderChest(@NotNull Player player, boolean online) throws InstantiationException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an ISpecialPlayerInventory for the given Player.
 | 
			
		||||
@@ -138,7 +111,8 @@ public interface IOpenInv {
 | 
			
		||||
     * @throws IllegalStateException  if the server version is unsupported
 | 
			
		||||
     * @throws InstantiationException if the ISpecialPlayerInventory could not be instantiated
 | 
			
		||||
     */
 | 
			
		||||
    ISpecialPlayerInventory getSpecialInventory(Player player, boolean online) throws InstantiationException;
 | 
			
		||||
    @NotNull
 | 
			
		||||
    ISpecialPlayerInventory getSpecialInventory(@NotNull Player player, boolean online) throws InstantiationException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks if the server version is supported by OpenInv.
 | 
			
		||||
@@ -155,7 +129,7 @@ public interface IOpenInv {
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    Player loadPlayer(final OfflinePlayer offline);
 | 
			
		||||
    Player loadPlayer(@NotNull final OfflinePlayer offline);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get an OfflinePlayer by name.
 | 
			
		||||
@@ -168,7 +142,7 @@ public interface IOpenInv {
 | 
			
		||||
     * @return the OfflinePlayer with the closest matching name or null if no players have ever logged in
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    OfflinePlayer matchPlayer(String name);
 | 
			
		||||
    OfflinePlayer matchPlayer(@NotNull String name);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check the configuration value for whether or not OpenInv displays a notification to the user
 | 
			
		||||
@@ -194,7 +168,7 @@ public interface IOpenInv {
 | 
			
		||||
     * @param plugin the Plugin no longer holding a reference to the Player
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    void releasePlayer(Player player, Plugin plugin);
 | 
			
		||||
    void releasePlayer(@NotNull Player player, @NotNull Plugin plugin);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Mark a Player as in use by a Plugin to prevent it from being removed from the cache. Used to
 | 
			
		||||
@@ -219,32 +193,32 @@ public interface IOpenInv {
 | 
			
		||||
     * @param plugin the Plugin holding the reference to the Player
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    void retainPlayer(Player player, Plugin plugin);
 | 
			
		||||
    void retainPlayer(@NotNull Player player, @NotNull Plugin plugin);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets a player's AnyChest setting.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the OfflinePlayer
 | 
			
		||||
     * @param offline the OfflinePlayer
 | 
			
		||||
     * @param status the status
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    void setPlayerAnyChestStatus(OfflinePlayer player, boolean status);
 | 
			
		||||
    void setPlayerAnyChestStatus(@NotNull OfflinePlayer offline, boolean status);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets a player's SilentChest setting.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the OfflinePlayer
 | 
			
		||||
     * @param offline the OfflinePlayer
 | 
			
		||||
     * @param status the status
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    void setPlayerSilentChestStatus(OfflinePlayer player, boolean status);
 | 
			
		||||
    void setPlayerSilentChestStatus(@NotNull OfflinePlayer offline, boolean status);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Forcibly unload a cached Player's data.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the OfflinePlayer to unload
 | 
			
		||||
     * @param offline the OfflinePlayer to unload
 | 
			
		||||
     * @throws IllegalStateException if the server version is unsupported
 | 
			
		||||
     */
 | 
			
		||||
    void unload(OfflinePlayer player);
 | 
			
		||||
    void unload(@NotNull OfflinePlayer offline);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
public interface IAnySilentContainer {
 | 
			
		||||
 | 
			
		||||
@@ -26,19 +27,19 @@ public interface IAnySilentContainer {
 | 
			
		||||
     * containers to open, be sure to check {@link #isAnyContainerNeeded(Player, Block)}
 | 
			
		||||
     * first.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player      the Player opening the container
 | 
			
		||||
     * @param silentchest whether the container's noise is to be silenced
 | 
			
		||||
     * @param block       the Block
 | 
			
		||||
     * @param player    the Player opening the container
 | 
			
		||||
     * @param silent    whether the container's noise is to be silenced
 | 
			
		||||
     * @param block     the Block
 | 
			
		||||
     * @return true if the container can be opened
 | 
			
		||||
     */
 | 
			
		||||
    boolean activateContainer(Player player, boolean silentchest, Block block);
 | 
			
		||||
    boolean activateContainer(@NotNull Player player, boolean silent, @NotNull Block block);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Closes the Player's currently open container silently, if necessary.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the Player closing a container
 | 
			
		||||
     */
 | 
			
		||||
    void deactivateContainer(Player player);
 | 
			
		||||
    void deactivateContainer(@NotNull Player player);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks if the container at the given coordinates is blocked.
 | 
			
		||||
@@ -47,7 +48,7 @@ public interface IAnySilentContainer {
 | 
			
		||||
     * @param block  the Block
 | 
			
		||||
     * @return true if the container is blocked
 | 
			
		||||
     */
 | 
			
		||||
    boolean isAnyContainerNeeded(Player player, Block block);
 | 
			
		||||
    boolean isAnyContainerNeeded(@NotNull Player player, @NotNull Block block);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Checks if the given block is a container which can be unblocked or silenced.
 | 
			
		||||
@@ -55,6 +56,6 @@ public interface IAnySilentContainer {
 | 
			
		||||
     * @param block the BlockState
 | 
			
		||||
     * @return true if the Block is a supported container
 | 
			
		||||
     */
 | 
			
		||||
    boolean isAnySilentContainer(Block block);
 | 
			
		||||
    boolean isAnySilentContainer(@NotNull Block block);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,9 +16,9 @@
 | 
			
		||||
 | 
			
		||||
package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Nullable;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
public interface IInventoryAccess {
 | 
			
		||||
 | 
			
		||||
@@ -30,7 +30,7 @@ public interface IInventoryAccess {
 | 
			
		||||
     * @return the ISpecialEnderChest or null
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    ISpecialEnderChest getSpecialEnderChest(Inventory inventory);
 | 
			
		||||
    ISpecialEnderChest getSpecialEnderChest(@NotNull Inventory inventory);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets an ISpecialPlayerInventory from an Inventory or null if the Inventory is not backed by
 | 
			
		||||
@@ -40,7 +40,7 @@ public interface IInventoryAccess {
 | 
			
		||||
     * @return the ISpecialPlayerInventory or null
 | 
			
		||||
     */
 | 
			
		||||
    @Nullable
 | 
			
		||||
    ISpecialPlayerInventory getSpecialPlayerInventory(Inventory inventory);
 | 
			
		||||
    ISpecialPlayerInventory getSpecialPlayerInventory(@NotNull Inventory inventory);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if an Inventory is an ISpecialEnderChest implementation.
 | 
			
		||||
@@ -48,7 +48,7 @@ public interface IInventoryAccess {
 | 
			
		||||
     * @param inventory the Inventory
 | 
			
		||||
     * @return true if the Inventory is backed by an ISpecialEnderChest
 | 
			
		||||
     */
 | 
			
		||||
    boolean isSpecialEnderChest(Inventory inventory);
 | 
			
		||||
    boolean isSpecialEnderChest(@NotNull Inventory inventory);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Check if an Inventory is an ISpecialPlayerInventory implementation.
 | 
			
		||||
@@ -56,6 +56,6 @@ public interface IInventoryAccess {
 | 
			
		||||
     * @param inventory the Inventory
 | 
			
		||||
     * @return true if the Inventory is backed by an ISpecialPlayerInventory
 | 
			
		||||
     */
 | 
			
		||||
    boolean isSpecialPlayerInventory(Inventory inventory);
 | 
			
		||||
    boolean isSpecialPlayerInventory(@NotNull Inventory inventory);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,23 +17,27 @@
 | 
			
		||||
package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
import org.bukkit.inventory.InventoryView;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
public interface ISpecialEnderChest {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the Inventory associated with this ISpecialEnderChest.
 | 
			
		||||
     * Gets the InventoryView associated with this ISpecialEnderChest.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the Inventory
 | 
			
		||||
     * @param viewer the Player opening the ISpecialEnderChest
 | 
			
		||||
     * @return the InventoryView
 | 
			
		||||
     */
 | 
			
		||||
    Inventory getBukkitInventory();
 | 
			
		||||
    @NotNull
 | 
			
		||||
    InventoryView getBukkitView(@Nullable Player viewer);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the Player associated with this ISpecialEnderChest online.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the Player coming online
 | 
			
		||||
     */
 | 
			
		||||
    void setPlayerOnline(Player player);
 | 
			
		||||
    void setPlayerOnline(@NotNull Player player);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the Player associated with this ISpecialEnderChest offline.
 | 
			
		||||
 
 | 
			
		||||
@@ -17,23 +17,27 @@
 | 
			
		||||
package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
import org.bukkit.inventory.InventoryView;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
public interface ISpecialPlayerInventory {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the Inventory associated with this ISpecialPlayerInventory.
 | 
			
		||||
     * Gets the InventoryView associated with this ISpecialPlayerInventory.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the Inventory
 | 
			
		||||
     * @param viewer the Player opening the ISpecialPlayerInventory
 | 
			
		||||
     * @return the InventoryView
 | 
			
		||||
     */
 | 
			
		||||
    Inventory getBukkitInventory();
 | 
			
		||||
    @NotNull
 | 
			
		||||
    InventoryView getBukkitView(@Nullable Player viewer);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the Player associated with this ISpecialPlayerInventory online.
 | 
			
		||||
     *
 | 
			
		||||
     * @param player the Player coming online
 | 
			
		||||
     */
 | 
			
		||||
    void setPlayerOnline(Player player);
 | 
			
		||||
    void setPlayerOnline(@NotNull Player player);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the Player associated with this ISpecialPlayerInventory offline.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user