1.8.8 Set specific player flying in survival?

Discussion in 'Spigot Plugin Development' started by notfoundname, Feb 19, 2020.

Thread Status:
Not open for further replies.
  1. I can't set player with permission nfn.fly flying in specific world.

    What I tried :
    (Class is registered and messages are working as they should)
    Code (Java):
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerChangedWorldEvent;

    public class LobbyJoin implements Listener
    {
        MainClass plugin;

        LobbyJoin(MainClass plugin)
        {
            this.plugin = plugin;
        }
     
        @EventHandler
        public void onJoin(PlayerJoinEvent e)
        {
            if((e.getPlayer().hasPermission("nfn.fly") || e.getPlayer().isOp()) && e.getPlayer().getWorld().getName().equals("lobby") && !e.getPlayer().isFlying())
            {
                e.getPlayer().setAllowFlight(true);
                e.getPlayer().sendMessage("set allow flight true");
                e.getPlayer().setFlying(true);
                e.getPlayer().sendMessage("set flying true");
            }
            else
            {
                e.getPlayer().setAllowFlight(false);
                e.getPlayer().sendMessage("set allow flight false");
                e.getPlayer().setFlying(false);
                e.getPlayer().sendMessage("set flying false");
            }
        }
        @EventHandler
        public void onChangeWorld(PlayerChangedWorldEvent e)
        {
            if(e.getPlayer().getWorld().getName().equals("lobby"))
            {
                e.getPlayer().setAllowFlight(true);
                e.getPlayer().sendMessage("set allow flight true");
                e.getPlayer().setFlying(true);
                e.getPlayer().sendMessage("set flying true");
            }
            else
            {
                e.getPlayer().setAllowFlight(false);
                e.getPlayer().sendMessage("set allow flight false");
                e.getPlayer().setFlying(false);
                e.getPlayer().sendMessage("set flying false");
            }
        }
    }
     
  2. Alright. Problem was with Multiverse ('allow-flight' was set to false in world 'lobby'). Code is working fine.
     
    • Useful Useful x 2
Thread Status:
Not open for further replies.