Custom inventory titles for 1.14

This commit is contained in:
Jikoo 2019-05-05 15:15:17 -04:00
parent 185f037254
commit 0f266c8a64
34 changed files with 420 additions and 239 deletions

View file

@ -19,9 +19,11 @@ package com.lishid.openinv;
import com.lishid.openinv.internal.IAnySilentContainer;
import com.lishid.openinv.internal.IInventoryAccess;
import com.lishid.openinv.internal.ISpecialEnderChest;
import com.lishid.openinv.internal.ISpecialInventory;
import com.lishid.openinv.internal.ISpecialPlayerInventory;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -49,8 +51,7 @@ public interface IOpenInv {
* @return the ISilentContainer
* @throws IllegalStateException if the server version is unsupported
*/
@NotNull
IAnySilentContainer getAnySilentContainer();
@NotNull IAnySilentContainer getAnySilentContainer();
/**
* Gets the active IInventoryAccess implementation.
@ -58,8 +59,7 @@ public interface IOpenInv {
* @return the IInventoryAccess
* @throws IllegalStateException if the server version is unsupported
*/
@NotNull
IInventoryAccess getInventoryAccess();
@NotNull IInventoryAccess getInventoryAccess();
/**
* Gets the provided player's AnyChest setting.
@ -78,8 +78,7 @@ public interface IOpenInv {
* @return the identifier
* @throws IllegalStateException if the server version is unsupported
*/
@NotNull
String getPlayerID(@NotNull OfflinePlayer offline);
@NotNull String getPlayerID(@NotNull OfflinePlayer offline);
/**
* Gets a player's SilentChest setting.
@ -99,8 +98,7 @@ public interface IOpenInv {
* @throws IllegalStateException if the server version is unsupported
* @throws InstantiationException if the ISpecialEnderChest could not be instantiated
*/
@NotNull
ISpecialEnderChest getSpecialEnderChest(@NotNull Player player, boolean online) throws InstantiationException;
@NotNull ISpecialEnderChest getSpecialEnderChest(@NotNull Player player, boolean online) throws InstantiationException;
/**
* Gets an ISpecialPlayerInventory for the given Player.
@ -111,8 +109,7 @@ public interface IOpenInv {
* @throws IllegalStateException if the server version is unsupported
* @throws InstantiationException if the ISpecialPlayerInventory could not be instantiated
*/
@NotNull
ISpecialPlayerInventory getSpecialInventory(@NotNull 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.
@ -128,8 +125,7 @@ public interface IOpenInv {
* @return the Player, or null
* @throws IllegalStateException if the server version is unsupported
*/
@Nullable
Player loadPlayer(@NotNull final OfflinePlayer offline);
@Nullable Player loadPlayer(@NotNull final OfflinePlayer offline);
/**
* Get an OfflinePlayer by name.
@ -141,8 +137,16 @@ public interface IOpenInv {
* @param name the name of the Player
* @return the OfflinePlayer with the closest matching name or null if no players have ever logged in
*/
@Nullable
OfflinePlayer matchPlayer(@NotNull String name);
@Nullable OfflinePlayer matchPlayer(@NotNull String name);
/**
* Open an ISpecialInventory for a Player.
*
* @param player the Player
* @param inventory the ISpecialInventory
* @return the InventoryView for the opened ISpecialInventory
*/
@Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory);
/**
* Check the configuration value for whether or not OpenInv displays a notification to the user

View file

@ -29,8 +29,7 @@ public interface IInventoryAccess {
* @param inventory the Inventory
* @return the ISpecialEnderChest or null
*/
@Nullable
ISpecialEnderChest getSpecialEnderChest(@NotNull Inventory inventory);
@Nullable ISpecialEnderChest getSpecialEnderChest(@NotNull Inventory inventory);
/**
* Gets an ISpecialPlayerInventory from an Inventory or null if the Inventory is not backed by
@ -39,8 +38,7 @@ public interface IInventoryAccess {
* @param inventory the Inventory
* @return the ISpecialPlayerInventory or null
*/
@Nullable
ISpecialPlayerInventory getSpecialPlayerInventory(@NotNull Inventory inventory);
@Nullable ISpecialPlayerInventory getSpecialPlayerInventory(@NotNull Inventory inventory);
/**
* Check if an Inventory is an ISpecialEnderChest implementation.

View file

@ -16,37 +16,6 @@
package com.lishid.openinv.internal;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
public interface ISpecialEnderChest {
/**
* Gets the Inventory associated with this ISpecialEnderChest.
*
* @return the Inventory
*/
@NotNull
Inventory getBukkitInventory();
/**
* Sets the Player associated with this ISpecialEnderChest online.
*
* @param player the Player coming online
*/
void setPlayerOnline(@NotNull Player player);
/**
* Sets the Player associated with this ISpecialEnderChest offline.
*/
void setPlayerOffline();
/**
* Gets whether or not this ISpecialEnderChest is in use.
*
* @return true if the ISpecialEnderChest is in use
*/
boolean isInUse();
public interface ISpecialEnderChest extends ISpecialInventory {
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (C) 2011-2019 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
public interface ISpecialInventory {
/**
* Gets the Inventory associated with this ISpecialEnderChest.
*
* @return the Inventory
*/
@NotNull Inventory getBukkitInventory();
/**
* Sets the Player associated with this ISpecialEnderChest online.
*
* @param player the Player coming online
*/
void setPlayerOnline(@NotNull Player player);
/**
* Sets the Player associated with this ISpecialEnderChest offline.
*/
void setPlayerOffline();
/**
* Gets whether or not this ISpecialEnderChest is in use.
*
* @return true if the ISpecialEnderChest is in use
*/
boolean isInUse();
}

View file

@ -16,37 +16,6 @@
package com.lishid.openinv.internal;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
public interface ISpecialPlayerInventory {
/**
* Gets the Inventory associated with this ISpecialPlayerInventory.
*
* @return the Inventory
*/
@NotNull
Inventory getBukkitInventory();
/**
* Sets the Player associated with this ISpecialPlayerInventory online.
*
* @param player the Player coming online
*/
void setPlayerOnline(@NotNull Player player);
/**
* Sets the Player associated with this ISpecialPlayerInventory offline.
*/
void setPlayerOffline();
/**
* Gets whether or not this ISpecialPlayerInventory is in use.
*
* @return true if the ISpecialPlayerInventory is in use
*/
boolean isInUse();
public interface ISpecialPlayerInventory extends ISpecialInventory {
}

View file

@ -19,6 +19,7 @@ package com.lishid.openinv.internal;
import java.util.Collection;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -32,8 +33,7 @@ public interface IPlayerDataManager {
* @param offline the OfflinePlayer
* @return the Player loaded
*/
@Nullable
Player loadPlayer(@NotNull OfflinePlayer offline);
@Nullable Player loadPlayer(@NotNull OfflinePlayer offline);
/**
* Gets a unique identifying string for an OfflinePlayer.
@ -41,8 +41,7 @@ public interface IPlayerDataManager {
* @param offline the OfflinePlayer
* @return the unique identifier
*/
@NotNull
String getPlayerDataID(@NotNull OfflinePlayer offline);
@NotNull String getPlayerDataID(@NotNull OfflinePlayer offline);
/**
* Gets an OfflinePlayer by the given unique identifier.
@ -50,15 +49,23 @@ public interface IPlayerDataManager {
* @param identifier the unique identifier
* @return the OfflinePlayer, or null if no exact match was found
*/
@Nullable
OfflinePlayer getPlayerByID(@NotNull String identifier);
@Nullable OfflinePlayer getPlayerByID(@NotNull String identifier);
/**
* Gets a Collection of all Players currently online.
*
* @return the Collection of Players
*/
@NotNull
Collection<? extends Player> getOnlinePlayers();
@NotNull Collection<? extends Player> getOnlinePlayers();
/**
* Opens an ISpecialInventory for a Player.
*
* @param player the Player opening the ISpecialInventory
* @param inventory the Inventory
*`
* @return the InventoryView opened
*/
InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory);
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_4_5;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_4_5.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_4_5.CraftServer;
import org.bukkit.craftbukkit.v1_4_5.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_4_6;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_4_6.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_4_6.CraftServer;
import org.bukkit.craftbukkit.v1_4_6.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_10_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_11_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_12_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -54,9 +56,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -76,8 +77,7 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
@NotNull @Override
public String getPlayerDataID(@NotNull final OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -105,4 +105,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_13_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_13_R1.CraftServer;
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -53,9 +55,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -75,9 +76,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public String getPlayerDataID(@NotNull final OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull final OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_13_R2;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -30,6 +31,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -54,9 +56,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -76,9 +77,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public String getPlayerDataID(@NotNull final OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull final OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -105,4 +105,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,19 +17,32 @@
package com.lishid.openinv.internal.v1_14_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
import net.minecraft.server.v1_14_R1.ChatComponentText;
import net.minecraft.server.v1_14_R1.Container;
import net.minecraft.server.v1_14_R1.Containers;
import net.minecraft.server.v1_14_R1.DimensionManager;
import net.minecraft.server.v1_14_R1.EntityHuman;
import net.minecraft.server.v1_14_R1.EntityPlayer;
import net.minecraft.server.v1_14_R1.MinecraftServer;
import net.minecraft.server.v1_14_R1.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_14_R1.PlayerInteractManager;
import net.minecraft.server.v1_14_R1.PlayerInventory;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftContainer;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -54,9 +67,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -76,9 +88,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public String getPlayerDataID(@NotNull final OfflinePlayer offline) {
public @NotNull String getPlayerDataID(@NotNull final OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -105,4 +116,68 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
EntityPlayer nmsPlayer = getHandle(player);
if (nmsPlayer == null || nmsPlayer.playerConnection == null) {
return null;
}
String title;
if (inventory instanceof SpecialEnderChest) {
HumanEntity owner = (HumanEntity) ((SpecialEnderChest) inventory).getBukkitOwner();
title = (owner.getName() != null ? owner.getName() : owner.getUniqueId().toString()) + "'s Ender Chest";
} else if (inventory instanceof SpecialPlayerInventory) {
EntityHuman owner = ((PlayerInventory) inventory).player;
title = (owner.getName() != null ? owner.getName() : owner.getUniqueID().toString()) + "'s Inventory";
} else {
return player.openInventory(inventory.getBukkitInventory());
}
Container container = new CraftContainer(new InventoryView() {
@Override
public @NotNull Inventory getTopInventory() {
return inventory.getBukkitInventory();
}
@Override
public @NotNull Inventory getBottomInventory() {
return player.getInventory();
}
@Override
public @NotNull HumanEntity getPlayer() {
return player;
}
@Override
public @NotNull InventoryType getType() {
return inventory.getBukkitInventory().getType();
}
@Override
public @NotNull String getTitle() {
return title;
}
}, nmsPlayer, nmsPlayer.nextContainerCounter()) {
@Override
public Containers<?> getType() {
return inventory instanceof SpecialEnderChest ? Containers.GENERIC_9X3 : Containers.GENERIC_9X5;
}
};
container.setTitle(new ChatComponentText(title));
container = CraftEventFactory.callInventoryOpenEvent(nmsPlayer, container);
if (container == null) {
return null;
}
nmsPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(),
new ChatComponentText(container.getBukkitView().getTitle())));
nmsPlayer.activeContainer = container;
container.addSlotListener(nmsPlayer);
return container.getBukkitView();
}
}

View file

@ -31,7 +31,6 @@ import org.bukkit.craftbukkit.v1_14_R1.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventory;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
@ -51,7 +50,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
}
@Override
public @NotNull Inventory getBukkitInventory() {
public @NotNull CraftInventory getBukkitInventory() {
return inventory;
}

View file

@ -47,8 +47,6 @@ import org.bukkit.craftbukkit.v1_14_R1.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventory;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -63,13 +61,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
public SpecialPlayerInventory(final Player bukkitPlayer, final Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));
this.inventory = new CraftInventory(this) {
@NotNull
@Override
public InventoryType getType() {
return InventoryType.CHEST;
}
};
this.inventory = new CraftInventory(this);
this.playerOnline = online;
this.player = super.player;
this.items = this.player.inventory.items;
@ -98,7 +90,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
}
@Override
public @NotNull Inventory getBukkitInventory() {
public @NotNull CraftInventory getBukkitInventory() {
return this.inventory;
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_4_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_4_R1.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_4_R1.CraftServer;
import org.bukkit.craftbukkit.v1_4_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -72,9 +73,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -98,4 +98,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_5_R2;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_5_R2.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_5_R2.CraftServer;
import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_5_R3;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_5_R3.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_5_R3.CraftServer;
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_6_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_6_R1.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_6_R1.CraftServer;
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_6_R2;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_6_R2.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_6_R3;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_6_R3.EntityPlayer;
@ -28,6 +29,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -55,9 +57,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -71,9 +72,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -97,4 +97,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_7_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_7_R1.EntityPlayer;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -72,9 +73,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -98,4 +98,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_7_R2;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.server.v1_7_R2.EntityPlayer;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_7_R2.CraftServer;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("deprecation") // Deprecated methods are used properly and will not change.
@ -57,9 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getName();
}
@ -73,9 +74,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return player;
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -99,4 +99,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_7_R3;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Arrays;
import java.util.Collection;
import java.util.UUID;
@ -30,6 +31,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_7_R3.CraftServer;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -57,9 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -79,9 +80,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Arrays.asList(Bukkit.getOnlinePlayers());
}
@ -105,4 +105,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_7_R4;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import java.util.Collection;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.EntityPlayer;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_8_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_8_R2;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_8_R2.CraftServer;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_8_R3;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_9_R1;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -17,6 +17,7 @@
package com.lishid.openinv.internal.v1_9_R2;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.lishid.openinv.internal.ISpecialInventory;
import com.mojang.authlib.GameProfile;
import java.util.Collection;
import java.util.UUID;
@ -29,6 +30,7 @@ import org.bukkit.Server;
import org.bukkit.craftbukkit.v1_9_R2.CraftServer;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import org.jetbrains.annotations.NotNull;
public class PlayerDataManager implements IPlayerDataManager {
@ -56,9 +58,8 @@ public class PlayerDataManager implements IPlayerDataManager {
return target;
}
@NotNull
@Override
public String getPlayerDataID(@NotNull OfflinePlayer offline) {
@Override
public @NotNull String getPlayerDataID(@NotNull OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@ -78,9 +79,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
}
@NotNull
@Override
public Collection<? extends Player> getOnlinePlayers() {
@Override
public @NotNull Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@ -104,4 +104,9 @@ public class PlayerDataManager implements IPlayerDataManager {
return nmsPlayer;
}
@Override
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return player.openInventory(inventory.getBukkitInventory());
}
}

View file

@ -27,6 +27,7 @@ import com.lishid.openinv.commands.SilentChestPluginCommand;
import com.lishid.openinv.internal.IAnySilentContainer;
import com.lishid.openinv.internal.IInventoryAccess;
import com.lishid.openinv.internal.ISpecialEnderChest;
import com.lishid.openinv.internal.ISpecialInventory;
import com.lishid.openinv.internal.ISpecialPlayerInventory;
import com.lishid.openinv.listeners.InventoryClickListener;
import com.lishid.openinv.listeners.InventoryCloseListener;
@ -56,6 +57,7 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -458,6 +460,11 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
return player;
}
@Override
public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
return this.accessor.getPlayerDataManager().openInventory(player, inventory);
}
@Override
public boolean notifyAnyChest() {
return this.getConfig().getBoolean("notify.any-chest", true);

View file

@ -142,7 +142,7 @@ public class OpenEnderPluginCommand implements CommandExecutor {
}
// Open the inventory
player.openInventory(chest.getBukkitInventory());
plugin.openInventory(player, chest);
}
}

View file

@ -151,7 +151,7 @@ public class OpenInvPluginCommand implements CommandExecutor {
}
// Open the inventory
player.openInventory(inv.getBukkitInventory());
plugin.openInventory(player, inv);
}
}