本文整理汇总了Java中org.bukkit.event.inventory.InventoryOpenEvent类的典型用法代码示例。如果您正苦于以下问题:Java InventoryOpenEvent类的具体用法?Java InventoryOpenEvent怎么用?Java InventoryOpenEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InventoryOpenEvent类属于org.bukkit.event.inventory包,在下文中一共展示了InventoryOpenEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAnvilOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
if (e.getPlayer().equals(null)) {
return;
}
if (e.getInventory().equals(null)) {
return;
}
Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
.getGameManager().getGameOfPlayer((Player) e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
e.setCancelled(true);
}
}
示例2: onAnvilOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
if (e.getPlayer().equals(null)) {
return;
}
if (e.getInventory().equals(null)) {
return;
}
Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
.getGameOfPlayer((Player) e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
e.setCancelled(true);
}
}
示例3: onInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
Inventory inventory = event.getInventory();
HumanEntity player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
if (InventoryAPI.isRPGInventory(inventory)) {
PlayerWrapper playerWrapper = (PlayerWrapper) inventory.getHolder();
InventoryManager.syncQuickSlots(playerWrapper);
InventoryManager.syncInfoSlots(playerWrapper);
InventoryManager.syncShieldSlot(playerWrapper);
InventoryManager.syncArmor(playerWrapper);
}
}
示例4: onPetInventoryOpened
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPetInventoryOpened(InventoryOpenEvent event) {
Player player = (Player) event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
final PlayerWrapper playerWrapper = InventoryManager.get(player);
if (playerWrapper.hasPet() && event.getInventory().getHolder() == playerWrapper.getPet()) {
playerWrapper.openInventory();
event.setCancelled(true);
new BukkitRunnable() {
@Override
public void run() {
HorseInventory horseInv = ((Horse) playerWrapper.getPet()).getInventory();
horseInv.setSaddle(new ItemStack(Material.SADDLE));
}
}.runTaskLater(RPGInventory.getInstance(), 1);
}
}
示例5: onInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e)
{
if(maze != null)
{
//System.out.println("OpneInv");
if(maze.checkIfInMaze(e.getPlayer().getLocation()))
{
HashMap<String,Object> status = (HashMap<String, Object>) Anti_hanging.get(e.getPlayer().getUniqueId().toString());
status.put("interrupted",true);
}
}
}
示例6: checkWorth
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkWorth(InventoryOpenEvent event) {
// Do nothing if a player did not open the inventory or if chest events
// are disabled.
if (!(event.getPlayer() instanceof Player) || plugin.getSettings().isDisableChestEvents()) {
return;
}
Inventory inventory = event.getInventory();
// Set all default worth values for this chest.
if (inventory.getHolder() instanceof DoubleChest) {
DoubleChest chest = (DoubleChest) inventory.getHolder();
checkWorth((Chest) chest.getLeftSide());
checkWorth((Chest) chest.getRightSide());
}
if (inventory.getHolder() instanceof Chest) {
checkWorth((Chest) inventory.getHolder());
}
}
示例7: callInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId));
}
CraftServer server = player.world.getServer();
CraftPlayer craftPlayer = player.getBukkitEntity();
player.activeContainer.transferTo(container, craftPlayer);
InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
container.transferTo(player.activeContainer, craftPlayer);
return null;
}
return container;
}
示例8: callInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
public static Container callInventoryOpenEvent(EntityPlayer player, Container container, boolean cancelled) {
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId));
}
CraftServer server = player.world.getServer();
CraftPlayer craftPlayer = player.getBukkitEntity();
player.activeContainer.transferTo(container, craftPlayer);
InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
event.setCancelled(cancelled);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
container.transferTo(player.activeContainer, craftPlayer);
return null;
}
return container;
}
示例9: onVillagerTrade
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler
public void onVillagerTrade(InventoryOpenEvent event) {
if (!plugin.isSkyAssociatedWorld(event.getPlayer().getWorld())) {
return;
}
if (!(event.getPlayer() instanceof Player)) {
return;
}
if (villagerTradingEnabled
&& event.getPlayer() instanceof Player
&& !(hasPermission(event.getPlayer(), "usb.mod.bypassprotection"))
&& event.getInventory().getType() == InventoryType.MERCHANT
&& !plugin.playerIsOnIsland((Player)event.getPlayer())) {
event.setCancelled(true);
event.getPlayer().sendMessage(tr("\u00a7eTrading isn't allowed on other islands. Do it in spawn."));
return;
}
}
示例10: onInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
if (event.getInventory() instanceof DoubleChestInventory) {
DoubleChestInventory doubleInv = (DoubleChestInventory)event.getInventory();
Chest leftChest = (Chest)doubleInv.getHolder().getLeftSide();
/*Generate a new player 'switch' event for the left and right chests. */
PlayerInteractEvent interactLeft = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, leftChest.getBlock(), null);
BlockListener.OnPlayerSwitchEvent(interactLeft);
if (interactLeft.isCancelled()) {
event.setCancelled(true);
return;
}
Chest rightChest = (Chest)doubleInv.getHolder().getRightSide();
PlayerInteractEvent interactRight = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, rightChest.getBlock(), null);
BlockListener.OnPlayerSwitchEvent(interactRight);
if (interactRight.isCancelled()) {
event.setCancelled(true);
return;
}
}
}
示例11: callInventoryOpenEvent
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
player.playerConnection.handleContainerClose(new Packet101CloseWindow(player.activeContainer.windowId));
}
CraftServer server = player.world.getServer();
CraftPlayer craftPlayer = player.getBukkitEntity();
player.activeContainer.transferTo(container, craftPlayer);
InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
container.transferTo(player.activeContainer, craftPlayer);
return null;
}
return container;
}
示例12: onInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
return;
}
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
}
示例13: onInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event)
{
if (event.getPlayer() instanceof Player)
{
if (this.isActive(ItemInsert.class, event.getPlayer().getWorld())
|| this.isActive(ItemRemove.class, event.getPlayer().getWorld()))
{
/* TODO
ContainerType type = new ContainerType(event.getInventory().getHolder());
if (!config.container.CONTAINER_ignore.contains(type))
*/
this.inventoryChanges.put(event.getPlayer().getUniqueId(), new HashMap<ItemData, Integer>());
}
}
}
示例14: PlayerInventoryOpen
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void PlayerInventoryOpen(final InventoryOpenEvent event)
{
if (!(event.getPlayer() instanceof Player))
return;
final Player player = (Player) event.getPlayer();
if (plugin.isLoggedIn(player))
{
final LoginPlayerData playerdata = plugin.getPlayerData(player);
if (playerdata != null)
playerdata.notifyAction();
return;
}
event.setCancelled(true);
player.closeInventory();
plugin.sendAuthReminderMessage(player);
}
示例15: onInventoryOpening
import org.bukkit.event.inventory.InventoryOpenEvent; //导入依赖的package包/类
/**
* Controls chest ownership for carts.
*
* @param e The {@link InventoryMoveItemEvent} associated with the chest.
*/
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
Inventory inv = e.getInventory();
if (e.getPlayer() instanceof Player) {
Player p = (Player) e.getPlayer();
if (inv.getHolder() instanceof Minecart) {
Minecart cart = (Minecart) inv.getHolder();
MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
if (toCheck != null && !toCheck.isDerailed()) {
CartProperties cp = toCheck.getProperties();
if (!cp.getOwners().contains(p.getName().toLowerCase())) {
p.sendMessage(ChatColor.RED + "You do not own this chest!");
e.setCancelled(true);
}
}
}
}
}