if (usageItem.equals(getItemInHand())) { //todo: implement offhand if (--usageTime == 0) { ItemType item = ItemTable.instance().getItem(usageItem.getType());
ItemStack input = i.getItem(2); // Get the ItemStack at slot two if (input == null) { // If there is nothing in that slot player.sendMessage("There are no items to trade up!"); } else if (input.equals(chests)) { // If it contains the sword // Execute the trade } // Optionally send message if it is the wrong item
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DenominationKey that = (DenominationKey) o; return type.equals(that.type); }
@Override public boolean equals(Object obj) { return obj instanceof BukkitMCItemStack && is.equals(((BukkitMCItemStack) obj).asItemStack()); }
@Override public List<Recipe> getRecipesFor(ItemStack result) { assertMainThread(); return recipes.stream().filter(recipe -> recipe.getResult().equals(result)).collect(Collectors.toList()); }
public void unregister() { Iterator<Recipe> iter = Bukkit.recipeIterator(); while (iter.hasNext()) { Recipe r = iter.next(); if (r.getResult().equals(this.result)) { iter.remove(); this.register = false; } } }
ItemStack compass = new ItemStack(Material.COMPASS); ItemMeta compassMeta = compass.getItemMeta(); //No need to use ChatColor.RESET before the text has a color compassMeta.setDisplayName(ChatColor.AQUA + "Menu"); compass.setItemMeta(compassMeta); for(ItemStack item:e.getPlayer().getInventory().getContents()){ if(item != null){ if(item.equals(compass)){ p.sendMessage("found properly named compass"); return; } } }
@Override public void run() { if (player.getInventory().getItemInMainHand().equals(stack)) { burstTask.put(uuid, this.getTaskId()); if (count-- > 0) { fire(player, stack, direction); return; } } burstTask.invalidate(uuid); this.cancel(); } }).runTaskTimer(RPGItems.plugin, burstInterval, burstInterval);
@Override public boolean heldBy(Player player) { return super.getItemStack().equals(player.getInventory().getBoots()); } }
@Override public boolean heldBy(Player player) { return super.getItemStack().equals(player.getInventory().getChestplate()); } }
@Override public boolean heldBy(Player player) { return super.getItemStack().equals(player.getInventory().getLeggings()); } }
@Override public boolean heldBy(Player player) { return super.getItemStack().equals(player.getInventory().getHelmet()); } }
@Override public boolean heldBy(Player player) { return super.getItemStack().equals(player.getInventory().getItemInOffHand()); } }
public static void retrieveItems(Player p) { if (Variables.soulbound.containsKey(p.getUniqueId())) { for (ItemStack item: Variables.soulbound.get(p.getUniqueId())) { if (item.equals(p.getInventory().getHelmet())) continue; if (item.equals(p.getInventory().getChestplate())) continue; if (item.equals(p.getInventory().getLeggings())) continue; if (item.equals(p.getInventory().getBoots())) continue; if (item.equals(p.getInventory().getItemInOffHand())) continue; if(!p.getInventory().contains(item)) { p.getInventory().addItem(item); } } Variables.soulbound.remove(p.getUniqueId()); } }
@Override public void run() { if (player.getInventory().getItemInMainHand().equals(stack)) { burstTask.put(uuid, this.getTaskId()); if (count-- > 0) { fire(player, stack, player.getEyeLocation().getDirection()); return; } } burstTask.invalidate(uuid); this.cancel(); } }).runTaskTimer(RPGItems.plugin, burstInterval, burstInterval);
protected boolean findItem() { if (mage != null && item != null) { Player player = mage.getPlayer(); if (player != null) { ItemStack itemInHand = player.getInventory().getItemInMainHand(); if (itemInHand != null && !InventoryUtils.isSameInstance(itemInHand, item) && itemInHand.equals(item)) { item = itemInHand; isInOffhand = false; return true; } itemInHand = player.getInventory().getItemInOffHand(); if (itemInHand != null && !InventoryUtils.isSameInstance(itemInHand, item) && itemInHand.equals(item)) { item = itemInHand; isInOffhand = true; return true; } itemInHand = player.getInventory().getItem(heldSlot); if (itemInHand != null && !InventoryUtils.isSameInstance(itemInHand, item) && itemInHand.equals(item)) { item = itemInHand; isInOffhand = true; return true; } } } return false; }
static private boolean canStack(ItemStack a, ItemStack b) { if (a != null && a.getType() == Material.AIR) a = null; if (b != null && b.getType() == Material.AIR) b = null; if (a == null && b == null) return true; if (a != null && b != null) { ItemStack ap = a.clone(), bp = b.clone(); ap.setAmount(1); bp.setAmount(1); return ap.equals(bp); } else { return false; } }
@Nullable private Wand checkOffhandWand(ItemStack itemInHand) { Player player = getPlayer(); if (isLoading() || player == null) return null; ItemStack offhandWandItem = offhandWand != null ? offhandWand.getItem() : null; if (InventoryUtils.isSameInstance(offhandWandItem, itemInHand)) return offhandWand; if (!Wand.isWand(itemInHand)) itemInHand = null; if ((itemInHand != null && offhandWandItem == null) || (offhandWandItem != null && itemInHand == null) || (itemInHand != null && offhandWandItem != null && !itemInHand.equals(offhandWandItem)) ) { if (offhandWand != null) { offhandWand.deactivate(); } if (itemInHand != null && controller.hasWandPermission(player)) { Wand newActiveWand = controller.getWand(itemInHand); if (!newActiveWand.activateOffhand(this)) { setOffhandWand(null); } } } return offhandWand; }
private PowerResult<Void> attract(Player player, ItemStack stack) { if (!player.isOnline() || player.isDead()) { return PowerResult.noop(); } if (!triggers.contains(Trigger.TICK) && !stack.equals(player.getInventory().getItemInMainHand())) { return PowerResult.noop(); } double factor = Math.sqrt(radius - 1.0) / maxSpeed; List<Entity> entities = getNearbyEntities(this, player.getLocation(), player, radius); if (entities.isEmpty()) return null; if (!item.consumeDurability(stack, attractingTickCost)) return null; for (Entity e : entities) { if (e instanceof LivingEntity && (attractPlayer || !(e instanceof Player))) { if (!item.consumeDurability(stack, attractingEntityTickCost)) break; Location locTarget = e.getLocation(); Location locPlayer = player.getLocation(); double d = locTarget.distance(locPlayer); if (d < 1 || d > radius) continue; double newVelocity = Math.sqrt(d - 1) / factor; Vector direction = locPlayer.subtract(locTarget).toVector().normalize(); e.setVelocity(direction.multiply(newVelocity)); } } return PowerResult.ok(); }
@Nullable private Wand checkWand(ItemStack itemInHand) { Player player = getPlayer(); if (isLoading() || player == null) return null; ItemStack activeWandItem = activeWand != null ? activeWand.getItem() : null; if (InventoryUtils.isSameInstance(activeWandItem, itemInHand)) return activeWand; if (!Wand.isWand(itemInHand)) itemInHand = null; if ((itemInHand != null && activeWandItem == null) || (activeWandItem != null && itemInHand == null) || (activeWandItem != null && itemInHand != null && !itemInHand.equals(activeWandItem)) ) { if (activeWand != null) { activeWand.deactivate(); } if (itemInHand != null && controller.hasWandPermission(player)) { Wand newActiveWand = controller.getWand(itemInHand); if (!newActiveWand.activate(this)) { setActiveWand(null); } } } return activeWand; }