org.bukkit.Material#BOW源码实例Demo

下面列出了org.bukkit.Material#BOW 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PGM   文件: KitMatchModule.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGrenadeLaunch(final ProjectileLaunchEvent event) {
  if (event.getEntity().getShooter() instanceof Player) {
    Player player = (Player) event.getEntity().getShooter();
    ItemStack stack = player.getItemInHand();

    if (stack != null) {
      // special case for grenade arrows
      if (stack.getType() == Material.BOW) {
        int arrows = player.getInventory().first(Material.ARROW);
        if (arrows == -1) return;
        stack = player.getInventory().getItem(arrows);
      }

      Grenade grenade = Grenade.ITEM_TAG.get(stack);
      if (grenade != null) {
        grenade.set(PGM.get(), event.getEntity());
      }
    }
  }
}
 
源代码2 项目: Hawk   文件: InteractItemEvent.java
@Override
public void postProcess() {
    Material mat = getItemStack().getType();
    boolean gapple = mat == Material.GOLDEN_APPLE;
    if(action == Action.START_USE_ITEM) {
        if((mat.isEdible() && (p.getFoodLevel() < 20 || gapple) && p.getGameMode() != GameMode.CREATIVE) ||
                (mat == Material.POTION && getItemStack().getDurability() == 0) || //water bottles
                (mat == Material.POTION && !Potion.fromItemStack(getItemStack()).isSplash())) {
            pp.setConsumingItem(true);
        }
        if(EnchantmentTarget.WEAPON.includes(mat)) {
            pp.setBlocking(true);
        }
        if(mat == Material.BOW && (p.getInventory().contains(Material.ARROW) || p.getGameMode() == GameMode.CREATIVE)) {
            pp.setPullingBow(true);
        }
    }
    else if(action == Action.RELEASE_USE_ITEM || action == Action.DROP_HELD_ITEM || action == Action.DROP_HELD_ITEM_STACK) {
        pp.setConsumingItem(false);
        pp.setBlocking(false);
        pp.setPullingBow(false);
    }
}
 
源代码3 项目: ProjectAres   文件: GrenadeListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGrenadeLaunch(final ProjectileLaunchEvent event) {
    if (event.getEntity().getShooter() instanceof Player) {
        Player player = (Player) event.getEntity().getShooter();
        ItemStack stack = player.getItemInHand();

        if(stack != null) {
            // special case for grenade arrows
            if (stack.getType() == Material.BOW) {
                int arrows = player.getInventory().first(Material.ARROW);
                if (arrows == -1) return;
                stack = player.getInventory().getItem(arrows);
            }

            Grenade grenade = Grenade.ITEM_TAG.get(stack);
            if(grenade != null) {
                grenade.set(plugin, event.getEntity());
            }
        }
    }
}
 
源代码4 项目: Sentinel   文件: SentinelItemHelper.java
/**
 * Returns whether the NPC is using a bow item.
 */
public boolean usesBow(ItemStack it) {
    if (it == null) {
        return false;
    }
    if (SentinelVersionCompat.v1_14) {
        if (it.getType() == Material.CROSSBOW && getArrow() != null) {
            return true;
        }
    }
    return it.getType() == Material.BOW && getArrow() != null;
}
 
源代码5 项目: EliteMobs   文件: TierSetSpawner.java
public static void spawnTierItem(int tierLevel, Player player) {

        ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
        ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
        ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
        ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
        ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
        ItemStack axe = new ItemStack(Material.DIAMOND_AXE);
        ItemStack bow = new ItemStack(Material.BOW);

        if (tierLevel > 1) {

            applyEnchantment(helmet, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(chestplate, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(leggings, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(boots, Enchantment.PROTECTION_ENVIRONMENTAL, tierLevel);
            applyEnchantment(sword, Enchantment.DAMAGE_ALL, tierLevel);
            applyEnchantment(axe, Enchantment.DAMAGE_ALL, tierLevel);
            applyEnchantment(bow, Enchantment.ARROW_DAMAGE, tierLevel);

        }

        player.getInventory().addItem(helmet);
        player.getInventory().addItem(chestplate);
        player.getInventory().addItem(leggings);
        player.getInventory().addItem(boots);
        player.getInventory().addItem(sword);
        player.getInventory().addItem(axe);
        player.getInventory().addItem(bow);

        return;

    }
 
源代码6 项目: Slimefun4   文件: GrapplingHook.java
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Player p = e.getPlayer();
        UUID uuid = p.getUniqueId();

        if (!e.getClickedBlock().isPresent() && !SlimefunPlugin.getGrapplingHookListener().isGrappling(uuid)) {
            e.cancel();

            if (p.getInventory().getItemInOffHand().getType() == Material.BOW) {
                // Cancel, to fix dupe #740
                return;
            }

            ItemStack item = e.getItem();

            if (item.getType() == Material.LEAD) {
                item.setAmount(item.getAmount() - 1);
            }

            Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
            Arrow arrow = p.getWorld().spawn(p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Arrow.class);
            arrow.setShooter(p);
            arrow.setVelocity(direction);

            Bat bat = (Bat) p.getWorld().spawnEntity(p.getLocation(), EntityType.BAT);
            bat.setCanPickupItems(false);
            bat.setAI(false);
            bat.setSilent(true);
            bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 100000));
            bat.setLeashHolder(arrow);

            boolean state = item.getType() != Material.SHEARS;
            SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue());
        }
    };
}
 
源代码7 项目: Slimefun4   文件: BowShootHandler.java
@Override
default Optional<IncompatibleItemHandlerException> validate(SlimefunItem item) {
    if (item.getItem().getType() != Material.BOW) {
        return Optional.of(new IncompatibleItemHandlerException("Only bows can have a BowShootHandler.", item, this));
    }

    return Optional.empty();
}
 
源代码8 项目: skRayFall   文件: ExprShinyItem.java
@Override
@Nullable
public ItemStack convert(ItemStack itemStack) {
    if (itemStack.getType() == Material.BOW) {
        itemStack.addUnsafeEnchantment(Enchantment.DIG_SPEED, 1);
    } else {
        itemStack.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1);
    }
    ItemMeta meta = itemStack.getItemMeta();
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    itemStack.setItemMeta(meta);
    return itemStack;
}
 
源代码9 项目: AnnihilationPro   文件: Archer.java
@Override
protected ItemStack getIcon()
{
	return new ItemStack(Material.BOW);
}
 
源代码10 项目: NBTEditor   文件: CustomBow.java
protected CustomBow(String slug, String name) {
	super(slug, name, Material.BOW);
}
 
源代码11 项目: AdditionsAPI   文件: CustomBow.java
/**
 * Creates a Custom Bow.
 * 
 * @param amount
 *            The amount that the Custom Bow will have. Recommended value is
 *            one as bows do not have a stackable size higher than 1 by
 *            default.
 * @param durability
 *            The durability of the Custom Bow.
 * @param idName
 *            the Custom Bow's ID Name. This MUST BE SIMILAR to
 *            "vanilla_additions:emerald_sword" and is saved in the
 *            ItemStack so you can easily detect which Custom Bow it is.
 * @param itemDurability
 *            The Bow's Item Durability. Recommended class is
 *            {@link BowDurability}
 */
public CustomBow(int amount, short durability, String idName, ItemDurability itemDurability) {
	super(Material.BOW, amount, durability, idName, itemDurability);
}
 
源代码12 项目: AdditionsAPI   文件: CustomBow.java
/**
 * Creates a Custom Bow.
 * 
 * @param amount
 *            The amount that the Custom Bow will have. Recommended value is
 *            one as bows do not have a stackable size higher than 1 by
 *            default.
 * @param durability
 *            The durability of the Custom Bow.
 * @param idName
 *            the Custom Bow's ID Name. This MUST BE SIMILAR to
 *            "vanilla_additions:emerald_sword" and is saved in the
 *            ItemStack so you can easily detect which Custom Bow it is.
 */
public CustomBow(int amount, short durability, String idName) {
	super(Material.BOW, amount, durability, idName);
}
 
 方法所在类
 同类方法