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

Error Handle Rate Limit #20

Closed
ninijule opened this issue Mar 5, 2021 · 2 comments
Closed

Error Handle Rate Limit #20

ninijule opened this issue Mar 5, 2021 · 2 comments

Comments

@ninijule
Copy link

ninijule commented Mar 5, 2021

Hello i have a problem with the implementation of the API.
So this is my code
public void OnPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
IPInfo ipInfo = IPInfo.builder().setToken("***********").build();

	try {
		IPResponse response = ipInfo.lookupIP(player.getAddress().getAddress().getHostAddress());
		
		System.out.println(response.getOrg());
		int index = response.getOrg().toString().indexOf("Mobile");
		if (index == 1) {
			System.out.println("Vous venez de vous connecter avec une adresse IP mobile");
			player.kickPlayer("Veuillez vous rendre sur le teamspeak.");
		}

	} catch (RateLimitedException ex) {
		ex.getMessage();
		// Handle rate limits here.
	}

	System.out.println("Le joueur qui vient de se connecter avec l'ip suivante : " + player.getAddress());
}

I got the error

Caused by: java.lang.ClassNotFoundException: io.ipinfo.api.errors.RateLimitedException
I know i have to handler error after the try catch but i don't know how !
Please your help can be helpfull thank you

@UmanShahzad
Copy link
Contributor

Hey @ninijule.

Two things:

  1. The error is 'ClassNotFoundException', so this is an environmental error and there's not that much I can help you with - check that your classpath is correct, and search online for related errors.
  2. You're creating a brand new IPinfo client on every player join, and therefore not using the built-in caching systems which can help you not hit rate limits too quickly. You can create the client once outside of this function scope, and then use it in the function repeatedly.

@UmanShahzad
Copy link
Contributor

Closing as no response.

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