本文整理了Java中org.bukkit.inventory.ItemStack.equals()
方法的一些代码示例,展示了ItemStack.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.equals()
方法的具体详情如下:
包路径:org.bukkit.inventory.ItemStack
类名称:ItemStack
方法名:equals
暂无
代码示例来源:origin: GlowstoneMC/Glowstone
if (usageItem.equals(getItemInHand())) { //todo: implement offhand
if (--usageTime == 0) {
ItemType item = ItemTable.instance().getItem(usageItem.getType());
代码示例来源:origin: stackoverflow.com
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
代码示例来源:origin: MinecraftWars/Gringotts
@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);
}
代码示例来源:origin: EngineHub/CommandHelper
@Override
public boolean equals(Object obj) {
return obj instanceof BukkitMCItemStack && is.equals(((BukkitMCItemStack) obj).asItemStack());
}
代码示例来源:origin: seeseemelk/MockBukkit
@Override
public List<Recipe> getRecipesFor(ItemStack result)
{
assertMainThread();
return recipes.stream().filter(recipe -> recipe.getResult().equals(result)).collect(Collectors.toList());
}
代码示例来源:origin: dzikoysk/WildSkript
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;
}
}
}
代码示例来源:origin: stackoverflow.com
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;
}
}
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
@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);
代码示例来源:origin: garbagemule/MobArena
@Override
public boolean heldBy(Player player) {
return super.getItemStack().equals(player.getInventory().getBoots());
}
}
代码示例来源:origin: garbagemule/MobArena
@Override
public boolean heldBy(Player player) {
return super.getItemStack().equals(player.getInventory().getChestplate());
}
}
代码示例来源:origin: garbagemule/MobArena
@Override
public boolean heldBy(Player player) {
return super.getItemStack().equals(player.getInventory().getLeggings());
}
}
代码示例来源:origin: garbagemule/MobArena
@Override
public boolean heldBy(Player player) {
return super.getItemStack().equals(player.getInventory().getHelmet());
}
}
代码示例来源:origin: garbagemule/MobArena
@Override
public boolean heldBy(Player player) {
return super.getItemStack().equals(player.getInventory().getItemInOffHand());
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
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());
}
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
@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);
代码示例来源:origin: elBukkit/MagicPlugin
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;
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
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;
}
}
代码示例来源:origin: elBukkit/MagicPlugin
@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;
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
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();
}
代码示例来源:origin: elBukkit/MagicPlugin
@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;
}
内容来源于网络,如有侵权,请联系作者删除!