NPE: Another plugin similar problem

Discussion in 'Plugin Development' started by TheA13X, May 27, 2013.

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

    TheA13X

    This time it's a NullPointerException in an if-loop. Code:
    Code:
    29    public boolean onCommand(CommandSender arg0, Command arg1, String arg2,
    30    String[] args) { 
    ...
    40       cnames=new String[cmdmap.getCommands().size()+cmdmap.getFallbackCommands().size()];
    41          for(Command c:cmdmap.getCommands()){
    42                       if((Player)arg0.hasPermission(c.getPermission())){
    43                        cnames[cnames.length]=c.getName();
    44                        }
    45         }
    
    Exception:
    Code:
    2013-05-26 17:06:23 [SEVERE] java.lang.NullPointerException
    2013-05-26 17:06:23 [SEVERE] at ru.tehkode.permissions.bukkit.superperms.PermissiblePEX.hasPermission(PermissiblePEX.java:105)
    2013-05-26 17:06:23 [SEVERE] at org.bukkit.craftbukkit.v1_5_R3.entity.CraftHumanEntity.hasPermission(CraftHumanEntity.java:111)
    2013-05-26 17:06:23 [SEVERE] at me.AllSeeingstar.Commands.HELPCommand.onCommand(HELPCommand.java:42)<--this is my class.
    2013-05-26 17:06:23 [SEVERE] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    2013-05-26 17:06:23 [SEVERE] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)
    ...
    what has PermissionsEx to do with it?
    weird:confused:
     
  2. Offline

    chasechocolate

    Change it to:
    Code:java
    1. if(((Player) arg0).hasPermission(c.getPermission())){
    2. //Do stuff
    3. }

    If that doesn't work, then what is your "commandmap" variable?
     
  3. Offline

    TheA13X

    Nope. Not working.
    cmdmap is a simple Command map. and c is a command, which is part of the commandmap, but if you look at the exception, you will see, that the problem is the PermissionsEx API. Although this hasPermission() command is a part of the CommandSender Class and not a part of PermissionsEx. Thats the part I can't understand.


    P.S. How did you get this pretty cool javacode box?
     
  4. Offline

    Ivan

    You get the box putting '[ syntax=java]' and '[/syntax]' around your code.

    OT: Are you using the right imports?
     
  5. Offline

    TheA13X

    Well I definitely didn't import "ru.tehkode.permissions.bukkit.superperms.PermissiblePEX"
     
Thread Status:
Not open for further replies.

Share This Page