当前位置: 首页>>代码示例>>Java>>正文


Java InventoryOpenEvent.getInventory方法代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryOpenEvent.getInventory方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryOpenEvent.getInventory方法的具体用法?Java InventoryOpenEvent.getInventory怎么用?Java InventoryOpenEvent.getInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.inventory.InventoryOpenEvent的用法示例。


在下文中一共展示了InventoryOpenEvent.getInventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:18,代码来源:InventoryListener.java

示例2: 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());
    }
}
 
开发者ID:novucs,项目名称:factions-top,代码行数:22,代码来源:WorthListener.java

示例3: 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;
		}			
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:26,代码来源:PlayerListener.java

示例4: 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);
                }
            }
        }
    }
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:24,代码来源:TrainStationLis.java

示例5: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(final InventoryOpenEvent event) {
    final Inventory inventory = event.getInventory();
    final InventoryHolder holder = inventory.getHolder();
    if (holder instanceof Chest || holder instanceof DoubleChest) {
        final BlockState chest = (BlockState)(holder instanceof Chest ? holder : ((DoubleChest)holder).getLeftSide());
        final Block block = chest.getBlock();
        final NLocation loc = new NLocation(block.getLocation());
        final List<Sign> signs = SignUtil.getSignsForChest(block);
        for (final Sign sign : signs) {
            if (sign.getLine(0).equals(ITEMNETWORK_EMITTER)) {
                this.feature.lock(loc);
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:17,代码来源:ItemNetworkListener.java

示例6: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(final InventoryOpenEvent e) {
    if (e.getView() instanceof LocaleInventory)
        return;
    if (e.getInventory().getType() != InventoryType.CHEST || !useLocaleInv) {
        Inventory in = e.getInventory();
        Iterator<ItemStack> it = in.iterator();
        String locale = Locale.getPlayerLocale((Player) e.getPlayer());
        try {
            while (it.hasNext()) {
                ItemStack item = it.next();
                if (ItemManager.toRPGItem(item) != null)
                    RPGItem.updateItem(item, locale);
            }
        } catch (ArrayIndexOutOfBoundsException ex) {
            // Fix for the bug with anvils in craftbukkit
        }
    } else if (useLocaleInv) {
        LocaleInventory localeInv = new LocaleInventory((Player) e.getPlayer(), e.getView());
        e.setCancelled(true);
        e.getPlayer().openInventory(localeInv);
        localeInventories.add(localeInv);
    }
}
 
开发者ID:Thinkofname,项目名称:RPG-Items,代码行数:25,代码来源:Events.java

示例7: onInventoryOpening

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
 * This will facilitate the need to update the {@link TrainFactory#ownerStorage} list, because if the inventory changes, the instance changes.
 * 
 * @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) {
				CartProperties cp = toCheck.getProperties();
				if(!cp.getOwners().contains(p.getName().toLowerCase())) {
					p.sendMessage(ChatColor.RED + "You do not own this chest!");
					e.setCancelled(true);
				}
			}
		}
	}
}
 
开发者ID:lexwebb,项目名称:GoldRushMC,代码行数:24,代码来源:TrainStationLis.java

示例8: onChestClick

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
 * This will be used to facilitate the permissions of chest minecarts.
 * 
 * @param event The {@link InventoryOpenEvent} associated with the chest.
 */
public void onChestClick(InventoryOpenEvent event) {

	event.setCancelled(true);

	Player p = (Player) event.getPlayer();
	Inventory i = event.getInventory();

	if(TrainFactory.ownerStorage.containsKey(p)) {
		for(MinecartMemberChest chest : TrainFactory.getInventoryList(p)) {
			if(chest.getEntity().getInventory() == i) {
				event.setCancelled(false);
				break;
			}
		}
	}
}
 
开发者ID:lexwebb,项目名称:GoldRushMC,代码行数:22,代码来源:TrainLis.java

示例9: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e)
{
	if(!(e.getPlayer() instanceof Player))
		return;
	
	Inventory inv = e.getInventory();
	InventoryHolder holder = inv.getHolder();
	if(holder != null && holder instanceof Menu)
	{
		Menu menu = (Menu) holder;
		menu.viewers.add((Player) e.getPlayer());
		openMenus.add(menu);
	}
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:16,代码来源:MenuManager.java

示例10: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
    final MatchPlayer opener = playerFinder.getParticipant(event.getActor());
    if(opener == null) return;

    final Inventory inventory = event.getInventory();
    final Predicate<Filter> passesFilter = passesFilter(inventory.getHolder());
    if(passesFilter == null) return;

    logger.fine(() -> opener.getName() + " opened a " + inventory.getHolder().getClass().getSimpleName());

    // Find all Fillers that apply to the holder of the opened inventory
    final List<Filler> fillers = this.fillers.stream()
                                             .filter(filler -> passesFilter.test(filler.filter()))
                                             .collect(Collectors.toImmutableList());
    if(fillers.isEmpty()) return;

    logger.fine(() -> "Found fillers " + fillers.stream()
                                                .map(Filler::identify)
                                                .collect(java.util.stream.Collectors.joining(", ")));

    // Find all Caches that the opened inventory is part of
    final List<Fillable> fillables = new ArrayList<>();
    for(Cache cache : caches) {
        if(passesFilter.test(cache.region()) && passesFilter.test(cache.filter())) {
            fillables.add(new FillableCache(cache));
        }
    }
    // If the inventory is not in any Cache, just fill it directly
    if(fillables.isEmpty()) {
        fillables.add(new FillableInventory(inventory));
    }

    fillables.forEach(fillable -> fillable.fill(opener, fillers));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:36,代码来源:FillListener.java

示例11: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event)
{
	Inventory inv = event.getInventory();
	String name = ChatColor.stripColor(inv.getName());
	
	if(name.startsWith("BREAKPOINT"))
		return;
	
	if(inv.getType() != InventoryType.PLAYER && !event.getPlayer().hasPermission("Breakpoint.admin"))
		event.setCancelled(true);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:13,代码来源:PlayerInteractListener.java

示例12: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
/**
 * Updates all pearls in an inventory when opened
 * @param e The event args
 */
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent e) {
	Inventory inv = e.getInventory();
	for (Entry<Integer, ? extends ItemStack> entry : inv.all(Material.ENDER_PEARL).entrySet()) {
		ItemStack newitem = validatePearl(entry.getValue());
		if (newitem != null) {
			inv.setItem(entry.getKey(), newitem);
		}
	}
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:15,代码来源:PlayerListener.java

示例13: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
	if (PlayerManager.getArena(event.getPlayer().getUniqueId()) != null) {
		if (allow) {
			return;
		}
		if (event.getPlayer().getInventory() != event.getInventory()) {
			event.setCancelled(true);
			GuiInventory.onInventoryClose(event.getPlayer().getUniqueId());
		}
	}
}
 
开发者ID:BtoBastian,项目名称:EpicSpleef,代码行数:13,代码来源:InventoryOpenListener.java

示例14: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(InventoryOpenEvent event) {
    if (event.getInventory() instanceof EnderChest) {
        event.setCancelled(true);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:7,代码来源:EnderChestRemovalListener.java

示例15: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryOpen(InventoryOpenEvent event) {
    if (event.getInventory() instanceof EnderChest) {
        event.setCancelled(true);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:7,代码来源:WorldListener.java


注:本文中的org.bukkit.event.inventory.InventoryOpenEvent.getInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。