player.hasPermission - Eclipse cannot resolve player?

Discussion in 'Plugin Development' started by MC_Crinkle, Jun 24, 2013.

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


    Hi guys, i'm trying to test a simple plugin and have used the player.hasPermission argument in a if statement. But eclipse has redlined it and doesnt have a helpful suggestion of what i have to "import" to make it know what that is. Does anyone know?
  2. Offline


    Did you declare the player?
  3. Offline


    Not yet because the tutorial page didnt say i had to, how and where do i put whatever I'm supposed to put?
  4. Offline


    In on onCommand parentheses add CommandSender sender and import CommandSender and use sender.hasPermission


    Above the code add Player player = (Player) sender
  5. Offline


    You cannot refer to a variable which has not been created yet.
  6. Offline


    Oh wait i may have solved it, by accidentally thinking about it!

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            if(cmd.getName().equalsIgnoreCase("basic")){ // If the player typed /basic then do the following...
                // doSomething
                sender.sendMessage("Command usage successful!");
                } else {
                return true;
            } //If this has happened the function will return true.
                // If this hasn't happened the a value of false will be returned.
            return false;
    I was using player.hasPermission, but noticed that the method already has a reference to the "sender" which is the player typing the code. I changed this to sender.hasPermission above and it seems to like it. Is that correct?
  7. Offline


  8. Offline


    Now to try and figure out grabbing variables from other plugins, and making it write config files! ERG! XD
Thread Status:
Not open for further replies.

Share This Page