PotionEffectType.values() "bug"?

Discussion in 'Plugin Development' started by NemesisMate, Oct 13, 2013.

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

    NemesisMate

    I'm trying to get a list of all effects with:

    Code:java
    1. for(PotionEffectType effect : PotionEffectType.values())
    2. effects.add(effect.toString()); // This throws a nullPointerException


    There are as many iterations as effects but if I try to get any information of that "effect" of each iteration I get a nullPointerException (effect.toString(), effect.getName(), etc).
     
  2. Offline

    Ultimate_n00b

    Looking on the github, and I see no reason for this. May I see the full stacktrace?
     
  3. Offline

    NemesisMate


    Of course:

    Code:
    2013-10-14 00:10:34 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'admin' in plugin CBPlugin v0.62
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:192)
        at org.bukkit.craftbukkit.v1_6_R3.CraftServer.dispatchCommand(CraftServer.java:523)
        at net.minecraft.server.v1_6_R3.PlayerConnection.handleCommand(PlayerConnection.java:959)
        at net.minecraft.server.v1_6_R3.PlayerConnection.chat(PlayerConnection.java:877)
        at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java:834)
        at net.minecraft.server.v1_6_R3.Packet3Chat.handle(SourceFile:49)
        at net.minecraft.server.v1_6_R3.NetworkManager.b(NetworkManager.java:296)
        at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java:116)
        at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
        at net.minecraft.server.v1_6_R3.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:592)
        at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:227)
        at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:488)
        at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:421)
        at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    Caused by: java.lang.NullPointerException
        at org.github.NemesisMate.CBPlugin.Commands.AdminCommand.onCommand(AdminCommand.java:255)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 15 more
    
    AdminCommand.java:255 is the one inside the for.
     
  4. Offline

    Ultimate_n00b

    I'm guessing effects is a list - is it defined. Like:

    Code:
    List<String>effects = new ArrayList<String>();
    Or is it like:

    Code:
    List<String>effects;
    The second one will return null.
     
  5. Offline

    NemesisMate

    Ultimate_n00b

    No, I have the first one. Is more, I use the exact code but with Horse.Color and many more and works pretty fine, is just with this one where is failing.
     
    Ultimate_n00b likes this.
  6. Offline

    Ultimate_n00b

    Try updating your version of bukkit - maybe it's an older error.
     
  7. Offline

    NemesisMate


    The stacktrace I pasted here is from the last 1.6.4-R0.1 development version.
     
    Ultimate_n00b likes this.
  8. try printing out the value of "String.valueOf(effect)" inside the loop, try to see anything that isn't correctly
     
  9. Offline

    NemesisMate

    :D Thanks, I didn't though on using that. If I use that it prints well all effects but the first one is "null" so I think it must be a bukkit error. A fast solution for me is removing the first element but this should be repaired.
     
Thread Status:
Not open for further replies.

Share This Page