Solved Check if a player's flight is enabled.

Discussion in 'Plugin Development' started by Kieraaaan, Oct 26, 2017.

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

    Kieraaaan

    Hello, I am wanting to make a plugin with many features and at the moment, my Flight feature is stopping me from continuing, I want to make a simple fly class where when you type /fly it enables it and disables it but when I enter an if statement, I cannot check if the player is allowed to fly. I want to use setAllowFlight(true/false) but I can't put that in an if statement, can someone help me to check if a player is allowed to fly.

    Here is my code:
    Code:
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
        if (!(sender instanceof Player)) {
    
            sender.sendMessage("§cOnly in-game players can use this command.");
    
        return true;
    
        }
    
        Player p = (Player) sender;
    
        if (!sender.hasPermission("staffmode.fly")) {
    
            sender.sendMessage("§cYou do not have permission to use this command.");
    
            return true;
    
        }
    
        if (cmd.getName().equalsIgnoreCase("fly")) {
    
            if() { // This is where I want to check if he is able to fly. NOT IF HE IS FLYING!
    
                p.setAllowFlight(true);
    
                p.sendMessage("§c§lStaff §r§8>> §aYour flight has been §lenabled§r§a.");
    
                return true;
    
        } else {
    
            p.setAllowFlight(false);
    
            p.sendMessage("§c§lStaff §r§8>> §cYour flight has been §ldisabled§r§c.");
    
            return true;
    
            }
    
        }
    
        return true;
    
        }
    
    }
    
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    Kieraaaan

Thread Status:
Not open for further replies.

Share This Page