當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。