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


Java ItemStack.equals方法代码示例

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


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

示例1: onClick

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = inventory.getItem(event.getSlot());
    if (button == null) {
        return;
    }
    Resource resource = getResource(gui);
    int current = faction.getConsumableResources().get(resource);
    if (button.equals(GUIButton.BACK)) {
        faction.getPopulationMenu().openDemands(player);
        return;
    } else if (button.equals(DENY_BUTTON)) {
        faction.getConsumableResources().put(resource, current - 1);
    } else if (button.equals(GRANT_BUTTON)) {
        faction.getConsumableResources().put(resource, current + 1);
    }
    update(resource);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:26,代码来源:SaturationMenu.java

示例2: onClick

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle()) || event.getSlot() >= 45) {
        return;
    }
    ItemStack button = inventory.getItem(event.getSlot());
    if (button == null || button.equals(DISABLED)) {
        return;
    }
    if (!faction.isPrivileged(event.getWhoClicked())) {
        return;
    }
    Resource resource = Resource.getByIcon(button);
    openResourceMenu(player, resource);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:18,代码来源:TradeMenu.java

示例3: onClick

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = inventory.getItem(event.getSlot());
    if (button == null) {
        return;
    }
    int current = faction.getImportValue(resource);
    if (button.equals(BACK)) {
        faction.getTradeMenu().open(player);
        return;
    } else if (button.equals(exportButton)) {
        faction.getGroceryList().put(resource, current - 1);
    } else if (button.equals(importButton)) {
        faction.getGroceryList().put(resource, current + 1);
    }
    update();
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:25,代码来源:ResourceMenu.java

示例4: playSound

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public static void playSound(InventoryClickEvent event) {
    if (event.getSlot() == -999) {
        return;
    }

    HumanEntity human = event.getWhoClicked();
    if (!(human instanceof Player)) {
        return;
    }

    ItemStack clicked = event.getCurrentItem();
    if (clicked == null || clicked.getType() == Material.AIR) {
        return;
    }

    if (clicked.getType() == Material.BARRIER) {
        ((Player) human).playSound(human.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1, 1);
    } else if (clicked != null && !clicked.equals(PLACEHOLDER)) {
        ((Player) human).playSound(human.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:22,代码来源:PageGUI.java

示例5: onIdeasClick

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private void onIdeasClick(InventoryClickEvent event) {
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (button == null) {
        return;
    }

    HumanEntity player = event.getWhoClicked();
    if (button.equals(BACK)) {
        openGroups(player);
        return;
    } else if (!faction.isPrivileged(player)) {
        return;
    }

    Idea idea = IdeaGroup.getIdeaByIcon(button);
    if (faction.getIdeaGroups().contains(idea.getGroup()) && !faction.getIdeas().contains(idea) && event.getClick() == ClickType.SHIFT_LEFT) {
        boolean purchased = idea.purchase(faction);
        MessageUtil.sendMessage(player, (purchased ? FMessage.MISC_PURCHASE_SUCCESS : FMessage.MISC_PURCHASE_FAIL).getMessage(idea.getName()));
    }
    openIdeas(player, idea.getGroup());
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:24,代码来源:IdeaMenu.java

示例6: isTrue

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public boolean isTrue(Inventory inv){
	short index=0;
	for(String s:shape)
		for(char c:s.toCharArray()){
			if(c==' ')
				if(inv.getItem(FireCraftTableGUI.mSlot.get(index++))==null)
					continue;
				else 
					return false;
			else{
				ItemStack is=inv.getItem(FireCraftTableGUI.mSlot.get(index++));
				if(is==null)return false;
				if(is.equals(materials.get(c)))
					continue;
				else 
					return false;
			}
		}
	return true;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:21,代码来源:FireCraftTableRecipe.java

示例7: onItemDisappeared

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private void onItemDisappeared(PlayerEvent event, ItemStack item) {
    final Player player = event.getPlayer();
    final PlayerInventory inventory = player.getInventory();
    final int slotId = inventory.getHeldItemSlot();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (ItemUtils.isEmpty(inventory.getItemInMainHand()) || item.equals(inventory.getItemInMainHand())) {
        final Slot slot = InventoryManager.getQuickSlot(slotId);
        if (slot != null) {
            new BukkitRunnable() {
                @Override
                public void run() {
                    InventoryUtils.heldFreeSlot(player, slotId, InventoryUtils.SearchType.NEXT);
                    inventory.setItem(slotId, slot.getCup());
                }
            }.runTaskLater(RPGInventory.getInstance(), 1);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:23,代码来源:InventoryListener.java

示例8: getTradingItem

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private VillagerTrade getTradingItem(MerchantCategory category,
		ItemStack stack, Game game, Player player) {
	for (VillagerTrade trade : category.getOffers()) {
		if ((trade.getItem1().getType() != Material.AIR)
				|| (trade.getRewardItem().getType() != Material.AIR)) {
			ItemStack iStack = toItemStack(trade, player, game);
			if ((iStack.getType() == Material.ENDER_CHEST)
					&& (stack.getType() == Material.ENDER_CHEST))
				return trade;
			if (((iStack.getType() == Material.POTION) || ((Main
					.getInstance().getCurrentVersion().startsWith("v1_9")) && ((iStack
					.getType().equals(Material.valueOf("TIPPED_ARROW")))
					|| (iStack.getType().equals(Material
							.valueOf("LINGERING_POTION"))) || (iStack
						.getType()
					.equals(Material.valueOf("SPLASH_POTION"))))))
					&& (((PotionMeta) iStack.getItemMeta())
							.getCustomEffects().equals(((PotionMeta) stack
							.getItemMeta()).getCustomEffects()))) {
				return trade;
			}
			if (iStack.equals(stack)) {
				return trade;
			}
		}
	}
	return null;
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:29,代码来源:XPItemShop.java

示例9: contains

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public boolean contains( ItemStack itemStack, int i ) {
    int j = 0;
    for ( ItemStack item : items ) {
        if( item != null && itemStack.equals( item ) ) {
            j += item.getAmount();
        }
    }
    return j >= i;
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:11,代码来源:FlexInventory.java

示例10: isIcon

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public boolean isIcon(ItemStack item) {
    for (ItemStack cache : items)
        if (cache != null) {
            if (cache.equals(item))
                return true;
        } else if (item == null)
            return true;
    return false;
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:10,代码来源:HotbarView.java

示例11: contains

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public boolean contains(ItemStack item) {
    if (item == null) {
        return false;
    }
    for (ItemStack i : getContents()) {
        if (item.equals(i)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:12,代码来源:CraftInventory.java

示例12: all

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public HashMap<Integer, ItemStack> all(ItemStack item) {
    HashMap<Integer, ItemStack> slots = new HashMap<Integer, ItemStack>();
    if (item != null) {
        ItemStack[] inventory = getContents();
        for (int i = 0; i < inventory.length; i++) {
            if (item.equals(inventory[i])) {
                slots.put(i, inventory[i]);
            }
        }
    }
    return slots;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:13,代码来源:CraftInventory.java

示例13: first

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private int first(ItemStack item, boolean withAmount) {
    if (item == null) {
        return -1;
    }
    ItemStack[] inventory = getContents();
    for (int i = 0; i < inventory.length; i++) {
        if (inventory[i] == null) continue;

        if (withAmount ? item.equals(inventory[i]) : item.isSimilar(inventory[i])) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:15,代码来源:CraftInventory.java

示例14: removeAmmo

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public void removeAmmo(TWDPlayer player, Weapon weapon, int bullets){
    for (ItemStack i : player.getPlayer().getInventory().getContents()){
        if (i == null || !(i.equals(weapon.getAmmo().toItemStack()))) return;
        if (i.getAmount() > bullets){
            i.setAmount(i.getAmount() - bullets);
            return;
        }
        if (i.getAmount() == bullets){
            player.getPlayer().getInventory().remove(weapon.getAmmo().toItemStack());
            return;
        }
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:14,代码来源:Ammo.java

示例15: all

import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
@Override
public HashMap<Integer, ? extends ItemStack> all( ItemStack itemStack ) {
    HashMap<Integer, ItemStack> results = new HashMap<>();
    for ( int index = 0; index < items.length; index++ ) {
        ItemStack item = items[ index ];
        if( itemStack != null && itemStack.equals( item ) ) {
            results.put( index, itemStack );
        }
    }
    return results;
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:12,代码来源:FlexInventory.java


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