java - IllegalArgumentException: Bound must be positive -
i error saying bound must positive. here line on:
inv.setitem(i, items.get(r.nextint(items.size())));
as far know, comes part request random integer list of items. how defined list:
list<itemstack> items = getallitems(level);
where getallitems()
method looks like:
public list<itemstack> getallitems(int level) { list<itemstack> items = new arraylist<itemstack>(); (string item : settings.getchests().getstringlist("chestitems." + level)) { itemstack toadd = parseitem(item); items.add(toadd); } return items; }
i stacktrace:
[19:03:53 error]: error occurred while enabling kitpvp v0.5 (is date?) java.lang.illegalargumentexception: bound must positive @ java.util.random.nextint(unknown source) ~[?:1.8.0_51] @ me.iamguus.gamegetsiepunt.kitpvp.chests.chestsutil.randomlyfillinv(chestsutil.java:101) ~[?:?] @ me.iamguus.gamegetsiepunt.kitpvp.main.onenable(main.java:40) ~[?:?] @ org.bukkit.plugin.java.javaplugin.setenabled(javaplugin.java:321) ~[spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.plugin.java.javapluginloader.enableplugin(javapluginloader.java:335) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.plugin.simplepluginmanager.enableplugin(simplepluginmanager.java:405) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.craftbukkit.v1_8_r3.craftserver.loadplugin(craftserver.java:356) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.craftbukkit.v1_8_r3.craftserver.enableplugins(craftserver.java:316) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.craftbukkit.v1_8_r3.craftserver.reload(craftserver.java:746) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.bukkit.reload(bukkit.java:534) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.command.defaults.reloadcommand.execute(reloadcommand.java:25) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.command.simplecommandmap.dispatch(simplecommandmap.java:141) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.craftbukkit.v1_8_r3.craftserver.dispatchcommand(craftserver.java:646) [spigot.jar:git-spigot-5818108-a486600] @ org.bukkit.craftbukkit.v1_8_r3.craftserver.dispatchservercommand(craftserver.java:632) [spigot.jar:git-spigot-5818108-a486600] @ net.minecraft.server.v1_8_r3.dedicatedserver.ao(dedicatedserver.java:405) [spigot.jar:git-spigot-5818108-a486600] @ net.minecraft.server.v1_8_r3.dedicatedserver.b(dedicatedserver.java:369) [spigot.jar:git-spigot-5818108-a486600] @ net.minecraft.server.v1_8_r3.minecraftserver.a(minecraftserver.java:657) [spigot.jar:git-spigot-5818108-a486600] @ net.minecraft.server.v1_8_r3.minecraftserver.run(minecraftserver.java:560) [spigot.jar:git-spigot-5818108-a486600] @ java.lang.thread.run(unknown source) [?:1.8.0_51]
the issue calling random.nextint()
0 , doesn't that. happening because list
getallitems()
empty. prevent situation checking list has items before performing logic:
list<itemstack> items = getallitems(level); if(!items.isempty()) { inv.setitem(i, items.get(r.nextint(items.size()))); }
Comments
Post a Comment