All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.event.inventory.InventoryOpenEvent Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
package net.minestom.server.event.inventory;

import net.minestom.server.entity.Player;
import net.minestom.server.event.trait.CancellableEvent;
import net.minestom.server.event.trait.InventoryEvent;
import net.minestom.server.event.trait.PlayerInstanceEvent;
import net.minestom.server.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Called when a player open an {@link Inventory}.
 * 

* Executed by {@link Player#openInventory(Inventory)}. */ public class InventoryOpenEvent implements InventoryEvent, PlayerInstanceEvent, CancellableEvent { private Inventory inventory; private final Player player; private boolean cancelled; public InventoryOpenEvent(@Nullable Inventory inventory, @NotNull Player player) { this.inventory = inventory; this.player = player; } /** * Gets the player who opens the inventory. * * @return the player who opens the inventory */ @NotNull public Player getPlayer() { return player; } /** * Gets the inventory to open, this could have been change by the {@link #setInventory(Inventory)}. * * @return the inventory to open, null to just close the current inventory if any */ @Nullable @Override public Inventory getInventory() { return inventory; } /** * Changes the inventory to open. *

* To do not open any inventory see {@link #setCancelled(boolean)}. * * @param inventory the inventory to open */ public void setInventory(@Nullable Inventory inventory) { this.inventory = inventory; } @Override public boolean isCancelled() { return cancelled; } @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy