use of org.bukkit.event.inventory.InventoryType in project Essentials by drtshock.
the class EssentialsPlayerListener method onInventoryCloseEvent.
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event) {
Player refreshPlayer = null;
final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType();
if (type == InventoryType.PLAYER) {
final User user = ess.getUser((Player) event.getPlayer());
user.setInvSee(false);
refreshPlayer = user.getBase();
} else if (type == InventoryType.ENDER_CHEST) {
final User user = ess.getUser((Player) event.getPlayer());
user.setEnderSee(false);
refreshPlayer = user.getBase();
} else if (type == InventoryType.WORKBENCH) {
final User user = ess.getUser((Player) event.getPlayer());
if (user.isRecipeSee()) {
user.setRecipeSee(false);
event.getView().getTopInventory().clear();
refreshPlayer = user.getBase();
}
} else if (type == InventoryType.CHEST && top.getSize() == 9) {
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity) {
final User user = ess.getUser((Player) event.getPlayer());
user.setInvSee(false);
refreshPlayer = user.getBase();
}
}
if (refreshPlayer != null) {
final Player player = refreshPlayer;
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
player.updateInventory();
}
}, 1);
}
}
Aggregations