pointers - Java Enum Returns Null -


i creating plugin minecraft using spigotapi. reason i'm posting here because believe java error. creating duels plugin inside code it'll loop through enum, , see if it's specific type. first time using around works, no problems. when try second time without restarting plugin/program/code it'll return enum null. here code, there fix this?

public duelarenas[] getarenaswithtype(dueltypes type) {     string suffix = "_normal";     list<duelarenas> arenasaslist = new arraylist<>();     switch (type) {         case normal:             suffix = "_normal";             break;     }     (duelarenas arena : duelarenastatus.keyset()) {         if (arena.tostring().endswith(suffix)) {             arenasaslist.add(arena);         }     }     duelarenas[] arenas = new duelarenas[arenasaslist.size()];     return arenasaslist.toarray(arenas); } 

stacktrace:

caused by: java.lang.nullpointerexception     @ me.nick.acore.duels.duelsapi.getarenaswithtype(duelsapi.java:97) ~[?:?] 

and yes i've checked see if enum null, , in fact null. line 97

if (arena.tostring().endswith(suffix)) { 

and here duelarena class

public enum duelarenas {  arena_1_normal, arena_2_normal, arena_3_normal, arena_4_normal, arena_5_normal, arena_6_normal, arena_7_normal, arena_8_normal, arena_9_normal, arena_10_normal, arena_11_normal, arena_12_normal } 

thanks!

your problem cannot directly convert custom duelarenas class string. when comparing see if .tostring() ends suffix, feel going wrong. ever use .tostring convert things numbers strings, , if converting number string there no way end in _normal.

if want me troubleshoot further please post duelarenas class, until best guess when arena.tostring looking pull sort of value class stored in it, , arena.variableinsidearenaname , work that.

edit:
after seeing class scratch that, error in going somewhere in line duelarenas arena : duelarenastatus.keyset()


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -