Solved PlayerJoinEvent

Discussion in 'Plugin Development' started by Nutowen, Mar 24, 2017.

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

    Nutowen

    Code:
    public class Join implements Listener {
        public void JoinEvent(PlayerJoinEvent e){
             if(e.getPlayer().getWorld().getName().equalsIgnoreCase("PriPlots")){
                 e.getPlayer().setFlying(true);
             }else{
               e.getPlayer().setFlying(false);
             }
         }
    }
    
    When you join the world you are meant to be able to fly but when you join nothing happens.
    No errors in console either.
    Anyone got a fix?
     
  2. Offline

    Zombie_Striker

    @Nutowen
    You forgot the @EventHandler tag.

    Also, a more efficient way of doing this would be to replace all those if statements with:
    Code:
       public void JoinEvent(PlayerJoinEvent e){
             e.getPlayer().setFlying(e.getPlayer().getWorld().getName().equalsIgnoreCase("PriPlots"));
         }
     
  3. Offline

    mehboss

    1. Make sure you registered your plugin in your onEnable().
    2. You forgot an @EventHandler annotation.

    ^ Beat me to it.. :)
     
  4. Offline

    Nutowen

    ...........Of course haha. Been a while since I done plugin creations. Thanks for the help
     
Thread Status:
Not open for further replies.

Share This Page