Projectile isn't launching

Discussion in 'Plugin Development' started by XKnucklesX, Jul 15, 2013.

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

    XKnucklesX

    t

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  2. Offline

    Scyntrus

    Try removing this if statement just to check if it works without it.
    Code:
    if(p.getItemInHand().getType() == Material.getMaterial(getConfig().getString("guns.gun1")))
    I have a feeling that the string might have not translated into a material properly.

    Also you shouldn't have to set the velocity after calling launchProjectile, as it's supposed to launch it with speed already.
     
  3. Offline

    XKnucklesX

    The velocity thing is fine I tried. But the if thing didn't work
     
  4. Offline

    xTrollxDudex

    XKnucklesX
    Instead of making an arrow as a player launching a projectile, cast arrow on a spawn Arrow.class at the player's eye location and set its velocity/shooter.
     
  5. Offline

    XKnucklesX

    I don't get what you said and im not really trying to change Im trying to make it shoot
     
  6. Offline

    xTrollxDudex

    XKnucklesX
    Exactly. The code your using to launch an arrow is wrong: which is why your not shooting. Translating my pseudo code, you would get
    PHP:
    private void Gun1(Player p){
    Arrow a = (Arrowp.getWorld().spawn(p.getEyeLocation(), Arrow.class);
    a.setShooter(((LivingEntityp));
    a.setVelocity(p.getLocation().getDirection().multiply(2));
    }
    Edit: I'm quite sure that config keys are case sensitive, change getString("guns.guns1") to getString("Guns.Guns1")
     
  7. Offline

    XKnucklesX

    ok thnx

    I think it was the config problem and your edit to my code is good.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  8. Offline

    xTrollxDudex

    XKnucklesX
    You need to do this.saveDefaultConfig() before you copyDefaults in your onEnable()
     
  9. Offline

    XKnucklesX

    ok noted
     
Thread Status:
Not open for further replies.

Share This Page