Java Code Examples for org.bukkit.Material#BOW

The following examples show how to use org.bukkit.Material#BOW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InteractItemEvent.java    From Hawk with GNU General Public License v3.0 7 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: KitMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@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());
      }
    }
  }
}
 
Example 3
Source File: GrenadeListener.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@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());
            }
        }
    }
}
 
Example 4
Source File: SentinelItemHelper.java    From Sentinel with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: TierSetSpawner.java    From EliteMobs with GNU General Public License v3.0 5 votes vote down vote up
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;

    }
 
Example 6
Source File: GrapplingHook.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@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());
        }
    };
}
 
Example 7
Source File: BowShootHandler.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@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();
}
 
Example 8
Source File: ExprShinyItem.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example 9
Source File: Archer.java    From AnnihilationPro with MIT License 4 votes vote down vote up
@Override
protected ItemStack getIcon()
{
	return new ItemStack(Material.BOW);
}
 
Example 10
Source File: CustomBow.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
protected CustomBow(String slug, String name) {
	super(slug, name, Material.BOW);
}
 
Example 11
Source File: CustomBow.java    From AdditionsAPI with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: CustomBow.java    From AdditionsAPI with MIT License 2 votes vote down vote up
/**
 * 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);
}