#A is null
1 messages · Page 1 of 1 (latest)
Cannot read the array length because "a" is null
its when I run the command /minigames add <lobby/arena> <minigame> <worlds>
The error appears in the console
there is more to the error but that was the only bit that seemed relevant
You’re almost correct, cuz in the console it says where the error is
so you can see what you need to change
here is more of the console output but I cant see where it says where the error is:
Caused by: java.lang.NullPointerException: Cannot read the array length because "a" is null
at java.util.Arrays.fill(Arrays.java:3429) ~[?:?]
at com.nikolaipatrick.MinigamesManager.MinigamesManager.onCommand(MinigamesManager.java:54) ~[MinigamesManager-1.0.0-SNAPSHOT.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
its enough
see this bit:
com.nikolaipatrick.MinigamesManager.MinigamesManager.onCommand(MinigamesManager.java:54) ~[MinigamesManager-1.0.0-SNAPSHOT.jar:?]
is that your domain?
com.nikolaipatrick is
ok
so
MinigamesManager.onCommand(MinigamesManager.java:54) this bit says that the error is in your MinigamesManager class, on line 54
ahhh yes i see
ok I think i might have found the problem
on line 54: minigameName = args[2];
is args[2] in bounds?
to run the command properly, it should be but I see what i have done wrong
thanks! ill keep that in mind
ahh I got mixed up
i thought i found the problem cos i was thinking that minigameName was a string array
was meant to be a string array
but it should be a string which is what it is now
so I'm still not sure why there is a problem
you there, @silent arch ?
what is the problem rn?
i see
you dont implement CommandExecutor
you do need to import 2 things
ok I'll give that a try
does it work?
I still seem to be getting the "a" is null error
on the same line?
no its line 60 this time i think
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot read the array length because "a" is null
at java.util.Arrays.fill(Arrays.java:3429) ~[?:?]
at com.nikolaipatrick.MinigamesManager.MinigamesManager.onCommand(MinigamesManager.java:60) ~[MinigamesManager-1.0.0-SNAPSHOT.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
Arrays.fill(worldNames, null);
that was commented right?
its not commented at the moment
what do you use it for?
in case the user is running the command more than once, worldNames can be used more than once
the vars are not static right?
what do you mean?
did you declare worldNames static?
than its fine, and you do should not need that line
but say the user used the add command to add two worlds in the same command and then used the add command a second time but only added one world in the same command
there would be nothing to clear the second world from the previous command
i do not understand you, but do you mean that the command copies the old worlds and putrs them into a new one to add it
cuz rn, if soimone uses the command a second time, you haven't stored the worlds of the first command
but wouldnt the worlds from the first command still be in worldNames?
ohh i see
so I removed the array.fill and now I have this error again in my console:
Caused by: java.lang.NullPointerException: Cannot store to object array because "this.worldNames" is null
at com.nikolaipatrick.MinigamesManager.MinigamesManager.onCommand(MinigamesManager.java:62) ~[MinigamesManager-1.0.0-SNAPSHOT.jar:?]
heres my current code: https://paste.md-5.net/hukacucufo.java
but its getting late for me so I need to go
ok, gn
so I changed my code a bit so it only supports adding one world per command but i get this error in the console:
Caused by: java.lang.NullPointerException: Cannot store to object array because "this.worldName" is null
at com.nikolaipatrick.MinigamesManager.MinigamesManager.onCommand(MinigamesManager.java:57) ~[MinigamesManager-1.0.0-SNAPSHOT.jar:?]
here is my current code: https://paste.md-5.net/webalacuhi.java
Is that the only file?
@distant elbow
yes that is the only file
thank you
when do you get the error?
when I run /minigames add
I think I might have just fixed it
I added this line to make the array an object:
worldName = new String[1];
the compiler doesnt work if i do that but its solved the prblem
So it works now ?
Tell me
when I use this in my code:
existingWorlds[0] = getConfig().getList(minigameName + ".lobbies");
the compiler throws an error saying:
Incompatible types. Found: 'java.util.List<capture<?>>', required: 'java.lang.String'
Use getStringList() is it is a list of strings
At the same line?
yes
Could you send the entire error?
thats the entire error
In intellij or console
It said it on your dc
ooh right it does I must have turned that on
an error
this is the line with the error:
existingWorlds[0] = getConfig().getStringList(minigameName + ".lobbies");
but I'm only putting a 0 in existingWorlds to test if it works but I plan on making it into a for loop
without the [0] ?
Ye
it gives the same error
bye!
Much success btw