"No value present" When attempting to fetch asset?

Despite my best attempts, every time I try to get a simple yml file from inside the jar using getAsset, I’m always met with “NoSuchElementException”. For reference this also happens when attempting to get a txt file.

My plugin variable is definitely not null, I’ve got the assets folder listed as being in the build path in Eclipse, yet still I get the same issue.

My only idea is that it’s not actually including the assets folder when it builds despite being added to the build path.

There’s not much we can do without the source. :confused:

Well this issue in particular only comes up when trying to fetch the Asset itself.

Sponge.getAssetManager().getAsset(plugin, "test.txt").get();

In eclipse itself I’ve added a folder called assets with another folder inside with my plugins id, then the test.txt inside of that.

Is there anything in particular I could be missing?

Are you using maven/ gradle or just plan ide build setup?

Good ol’ Gradle, which surprisingly wasn’t AS complicated to understand as expected

Is the assets folder inside src/main/resources folder?

Well it is now, and it now works perfectly. Much appreciated!

I read on one thread about someone placing theirs in the build folder to work, which is where I’d previous placed mine.

1 Like

Gald to help anytime :slight_smile:

It’s important to understand structure. src/main/java/ is where Java files go, src/main/scala/ would be where Scala files go, src/main/<languagename>/ is where <language> source code goes. With an exception for src/main/resources/, which is where non-code files go, such as configs. And then swap mainfortestfor anything related for testing.src/` should be only folder you ever have to modify to create the program itself.