Shooting Item Projectiles

Discussion in 'Plugin Development' started by AgentJayCraft, Aug 30, 2013.

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

    AgentJayCraft

    Hi. I am trying to shoot Items as projectiles with an Item but this is not working here is my code.
    Code:java
    1. package me.ggames62.Exodus;
    2.  
    3. import org.bukkit.Material;
    4. import org.bukkit.entity.Item;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.block.Action;
    9. import org.bukkit.event.player.PlayerInteractEvent;
    10. import org.bukkit.inventory.ItemStack;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13.  
    14. class Exodus2 extends JavaPlugin implements Listener {
    15.  
    16. Exodus plugin;
    17.  
    18.  
    19. @EventHandler
    20. private void onPlayerInteract(PlayerInteractEvent e) {
    21. Player p = (Player)e;
    22. if (!(e.getAction() == Action.RIGHT_CLICK_AIR)) return;
    23.  
    24. if (!(e.getItem().getType() == Material.GOLD_HOE)) return;
    25.  
    26. p.getWorld().dropItem(p.getLocation(),new ItemStack(Material.GOLD_INGOT));
    27.  
    28. Item item = p.getWorld().dropItem(p.getLocation(),new ItemStack(Material.GOLD_INGOT));
    29.  
    30. item.setVelocity(p.getLocation().getDirection().multiply(1.75D));
    31. item.setPickupDelay(Integer.MAX_VALUE);
    32.  
    33.  
    34.  
    35. }
    36.  
    37.  
    38. }
     
  2. Offline

    MisterErwin

    a) Did you registred the listener? (In your onEnable())
    b) Why item.setPickupDelay(Integer.MAX_VALUE); You'll never pick that item up...
     
  3. Offline

    Ghilliedrone

    You must register the listener. Also put the 2nd if inside the first
     
  4. Offline

    AgentJayCraft

    Ghilliedrone this is a extension class from my main class and it didn't work
     
  5. Offline

    q8minecraft

    You dont have to extend JavaPlugin from the second class, JavaPlugin always extends from your main class.
    (correct me if Im wrong)
     
Thread Status:
Not open for further replies.

Share This Page