本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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);
}
}
示例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());
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}