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

    MC_Crinkle

    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

    joehot2000

    Did you declare the player?
     
  3. Offline

    MC_Crinkle

    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

    themadman300

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

    OR

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

    joehot2000

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

    MC_Crinkle

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

    Code:
    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
                if(sender.hasPermission("crinkrpg.perm")){
                sender.sendMessage("Command usage successful!");
                } else {
                    sender.sendMessage("DENIED");
                }
                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

    ZeusAllMighty11

  8. Offline

    MC_Crinkle

    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