Arrow Sit Plugin... Not working

Discussion in 'Plugin Development' started by RossCoombs, Nov 25, 2013.

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


    Hey, I'm having an issue with a plugin I created and I'm not too sure why but it just doesn't work...

    What it does: Player fires arrow, if item in hand is the custom item Arrow Sit Bow, then it sets the passenger of the arrow to the player(Player sits on arrow) and when the arrow hits the ground it ejects the player.

    Here's the custom bow (In main class):
    1. ItemStack asbow = new ItemStack(Material.BOW, 1);
    2. ItemMeta asbowMeta = asbow.getItemMeta();
    3. asbowMeta.setDisplayName(ChatColor.RED + "Arrow Sit Bow");
    4. asbow.setItemMeta(asbowMeta);
    5. ShapelessRecipe asrecipebow = new ShapelessRecipe(asbow);
    6. asrecipebow.addIngredient(Material.BOW);
    7. asrecipebow.addIngredient(Material.SADDLE);
    8. this.getServer().addRecipe(asrecipebow);

    and here's the Listener:
    1. public void ProjectileLaunch(ProjectileLaunchEvent event){
    2. if (event.getEntity().getShooter() instanceof Player){
    3. Player p = ((Player) event.getEntity()).getPlayer();
    4. if((p.getItemInHand() != null) && (p.getItemInHand().getItemMeta() != null) && (ChatColor.RED + "Arrow Sit Bow").equals(p.getItemInHand().getItemMeta().getDisplayName())){
    5. Entity e = event.getEntity();
    6. e.setPassenger(p);
    8. }
    10. }
    12. }
    13. public void ProjectileHit(ProjectileHitEvent event){
    14. Entity e = event.getEntity();
    15. e.eject();
    16. }

    Many thanks if you can spot the issue! :p
  2. Offline


    * Why not listen to the EntityBowShootEvent, which is made explicity made for bow shooting?
    Player p = ((Player) event.getEntity()).getPlayer();
    What are you expecting to do here? You are casting the projectile of the event (the arrow) to Player. You have to cast the shooter.
  3. Offline


    Ah, thank you. Knew I did something wrong, not sure what it was. I'm pretty new to Bukkit, thanks for the help!
    Is it necessary for me to change the event to EntityBowShoot?
  4. Offline


    Player sits on the arrow? I wonder what that looks like 0.0
    RossCoombs likes this.
  5. Offline


    This sounds like it would be cool... :D
  6. Offline


    Blah1 Try to set the passenger of the player to itself. That looks funny and will cause some weird bugs ;D
    Blah1 likes this.
Thread Status:
Not open for further replies.

Share This Page