Question How can i make this event only apply to an itemmeta and not any bow.

Discussion in 'Bukkit Help' started by BenXII, Apr 1, 2020.

Thread Status:
Not open for further replies.
  1. Offline


    I am trying to make a plugin where the bow that teleports the player to where the arrrow is shot only applys to the itemMeta bow that i made. If that makes sense.

    public class TeleportBow implements Listener {

    public void onProjectileHit(ProjectileHitEvent e) {
    if (e.getEntity().getShooter() instanceof Player) {
    Player player = (Player) e.getEntity().getShooter();
    if(player.getInventory().getItemInMainHand().getType().equals(Material.BOW)) {
    if (e.getHitBlock() == null) {
    } else if (e.getHitEntity() == null) {




    This is a different class in the same package:

    import java.util.ArrayList;

    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemFlag;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;

    import net.md_5.bungee.api.ChatColor;

    public class teleportbow implements CommandExecutor {

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (sender instanceof Player) {
    Player player = (Player) sender;
    ItemStack teleportbow = new ItemStack(Material.BOW);

    ItemMeta bowMeta = teleportbow.getItemMeta();

    bowMeta.setDisplayName(ChatColor.BOLD + "Teleportation Bow");

    ArrayList<String> lore = new ArrayList<String>();
    lore.add("This bow allows you to teleport to where your arrow lands!");
    lore.add("Custom Item Only On CrabMC!");

    bowMeta.addEnchant(Enchantment.ARROW_INFINITE, 1, false);


    player.sendMessage("You have been given the teleport bow!");

    return true;



    This is the Main Class

    public class TeleportationBow extends JavaPlugin{

    public static boolean onCommand() =

    public static void main(String[] args) {


    public void onEnable() {
    getCommand("teleportbow").setExecutor(new teleportbow());


Thread Status:
Not open for further replies.

Share This Page