meraki-analytics / orianna

A Java framework for the Riot Games League of Legends API (http://developer.riotgames.com/).
MIT License
182 stars 56 forks source link

config.json doesnt work #128

Closed JustinSGD closed 3 years ago

JustinSGD commented 3 years ago

Hey, I want to change something in config.json. This is in my resources folder. However, it doesn't work as soon as I start the plugin. As soon as I hide it in my code it works. I hope you can help me. https://prnt.sc/x60fk0

robrua commented 3 years ago

Hey, can you clarify a little bit about what you're expecting to happen and what's not working?

At first glance, your project looks like a standard Maven project structure, so w/the config.json in src/main/resources you should be able to load it with Orianna.loadConfiguration("config.json");. If that's not working, I'd open up the .jar you're producing and make sure config.json is getting packaged in the root of the jar.

If you'd prefer that the configuration get picked up automatically, rather than needing to add the loadConfiguration line of code, you can set the ORIANNA_CONFIGURATION_PATH environment variable to point at your config.json and Orianna will pick it up automatically when initializing.

In the screenshot you sent, it looks like you're configuring your API key, region, and locale, then loading a configuration after. Keep in mind that loadConfiguration fully overwrites any existing configuration of Orianna, so the programmatic settings you've changed before loading the config.json won't be kept. The configuration system isn't designed to mix both programmatic and JSON based configuration, so I'd suggest sticking with just one of them.

On a side note, you should regenerate your API key on the Riot developer portal, as it's visible in the screenshot for anyone to steal.

Let me know if this info helps with your issue, or if not can you add more details about what you're doing and why the results aren't what you expect?

JustinSGD commented 3 years ago

I have compiled the jar. The file is also included. However, the bot then no longer works as it should. That means your API is not working. https://prntscr.com/xa1sm6

JustinSGD commented 3 years ago

Added Season 10 in your API pls :D

robrua commented 3 years ago

Can you send me the region and match ID for a match that returns Season 10? It looks to me like the API's still giving Season 9 back for everything rn. Can add it if I have an example match.

For the config problem, it does look like you've got things set up correctly based what I can tell from the screenshot, but I still need you to tell me what exactly is going wrong so I can help. Is it not loading your config at all and just using the default config?

JustinSGD commented 3 years ago

The default config is not loading. After that, nothing works anymore.

robrua commented 3 years ago

Is there an error message getting dumped associated with it & do you have logging enabled?

JustinSGD commented 3 years ago

There is no error message when starting the bot. https://prntscr.com/xbc0to If I then do something with the API, nothing happens and there is no error or other message.

robrua commented 3 years ago

Could you try adding an SLF4J logging implementation to your dependencies and see if there's any log output from Ori that might help track down the problem?

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.25</version>
</dependency>

is quick & easy to add

JustinSGD commented 3 years ago

How I can debug?

robrua commented 3 years ago

Try adding that dependency and running again to see if we can get any logs out of Ori - if it gives any output it'll help us get to the bottom of it. Otherwise if you can share the code for your project or create a minimal example that replicates the error I can take a look locally.

JustinSGD commented 3 years ago

I am add you to project on GitHub.

JustinSGD commented 3 years ago

Thank you it works!

robrua commented 3 years ago

For those keeping score at home the issue was loading the config using Orianna.loadConfiguration after doing some programmatic configuration (setting the API key). This overwrites the programmatic configuration, so the API key was empty.