Solved ProjectileLaunchEvent and getting a players name.

Discussion in 'Plugin Help/Development/Requests' started by oceantheskatr, Apr 1, 2015.

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

    oceantheskatr

    Hi, I'm creating a plugin that allows players with the correct permission node to run /fireball to switch arrows to fireballs. So far shooting fireballs from the bow works, I have a permission set up to run the command, and I have an arraylist which will hold playernames that run /fireball. I would like to make it so that when a player shoots an arrow it will check to see if the player name is on the arraylist, and if so then change to the arrow to a fireball.

    I guess the main issue is trying to get the player's name in this event. I know how to check if an arraylist contains a player's name.

    Here is my code for creating the fireball (My arraylist is called "fireball" by the way) :

    Code:
        @EventHandler
        public void onLaunch(ProjectileLaunchEvent e) {
            if (e.getEntity() instanceof Arrow) {
                Arrow a = (Arrow) e.getEntity();
                if(a.getShooter() instanceof Player) {
                    LivingEntity player = a.getShooter();
                    final CraftFireball fireball = (CraftFireball) player.getWorld().spawn(player.getEyeLocation().toVector().add(player.getLocation().getDirection().multiply(2)).toLocation(player.getWorld()), Fireball.class);
                    ((Fireball) fireball).setShooter(player);
                }
            }
        }
    Any help offered is greatly appreciated!
     
  2. Offline

    pie_flavor

    oceantheskatr likes this.
  3. Offline

    oceantheskatr

    *facepalm*

    I shouldn't post dev assistance threads when I'm sleep deprived! :p

    Thank you regardless though :)
     
Thread Status:
Not open for further replies.

Share This Page