Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getResourceById throwing an exception #8

Open
MrSpomg opened this issue Sep 13, 2018 · 2 comments
Open

getResourceById throwing an exception #8

MrSpomg opened this issue Sep 13, 2018 · 2 comments

Comments

@MrSpomg
Copy link

MrSpomg commented Sep 13, 2018

Hello! I am currently using your awesome api for Spigot for a project. However, when trying to get a resource (by ID) it gives me this error:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at be.maximvdw.spigotsite.jsoup.select.Elements.get(Elements.java:523) at be.maximvdw.spigotsite.resource.SpigotResourceManager.getResourceById(SpigotResourceManager.java:52) at be.maximvdw.spigotsite.resource.SpigotResourceManager.getResourceById(SpigotResourceManager.java:30) at me.spomg.system.bot.bridge.spigotsite.Spigot.getResources(Spigot.java:75) at me.spomg.system.bot.bridge.spigotsite.schedulers.NewBuyersScheduler.run(NewBuyersScheduler.java:36) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

The code used:
`public Set getResources() {
final Set value = new HashSet<>();

try {
    for (String id : bot.getConfigFetcher().getStrings("resources")) {
        value.add(getResourceManager().getResourceById(Integer.parseInt(id)));
    }
} catch (ConnectionFailedException ex) {
    LogHelper.logException("An error occurred while getting resources.", ex);
    return null;
}

return value;

}`
I also tryed by using the method with a normal ID (and not using the config).
How do I fix this? Thanks!

@MrSpomg
Copy link
Author

MrSpomg commented Sep 14, 2018

This gets bugged, but I made it work using getResourcesByUser

@JarFiles
Copy link

I have that problem too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants