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

Trouble with leaderboards callbacks on steamworks4j-1.9.0 #134

Open
andrei-voia opened this issue Oct 16, 2023 · 0 comments
Open

Trouble with leaderboards callbacks on steamworks4j-1.9.0 #134

andrei-voia opened this issue Oct 16, 2023 · 0 comments

Comments

@andrei-voia
Copy link

Hello, great work with this steamworks4j so far, it is a life savior. This being said, i m new here and i needed a way to access the steam leaderboards and i was looking in your tests to find how to call what i need. This being said, i copied all the callbacks from the SteamClientAPITest.java and the problem is that the attribute currentLeaderboard, defined as private SteamLeaderboardHandle is always null, even after reading the leaderboard

The method registerInterfaces() is copied from your test too, together with all the callbacks and the console informations are correct

This is my code:

//initialize and connect to steam
public boolean initAndConnect() 
{
	try {
		SteamAPI.loadLibraries("./steam");
	}
	catch (SteamException e1) {
		System.out.println("Load libraries error");
	}

	//initiation of a connection with the steam client
	try {
		if (!SteamAPI.init()) 
		{
			System.out.println("Initialization failed");
			System.out.println("Steam running: " + SteamAPI.isSteamRunning());
			
			isOnline = false;
			return false;
		}
	} catch (SteamException e) {
		e.printStackTrace();
	}
	
	System.out.println("Steam running: " + SteamAPI.isSteamRunning());
	
	registerInterfaces();
	
	isOnline = true;
	return true;
};


public boolean setLeaderboard() 
{
	if(isOnline == false)
	{
		System.out.println("Steam is not online, oops problem");
		return false;
	}
	
	System.out.println("We are doing some leaderboard searching here..");

	System.out.println(currentLeaderboard);
	
	//1
	String name = "leaderboard_test";
	userStats.findLeaderboard(name);
	
	System.out.println(currentLeaderboard);
	
	//2
	if(currentLeaderboard != null) {
	userStats.downloadLeaderboardEntries(currentLeaderboard,
			SteamUserStats.LeaderboardDataRequest.Global,
			100, 420);
	}
	
	//4
	int score = 2200;
	if (currentLeaderboard != null) {
		System.out.println("uploading score " + score + " to leaderboard " + currentLeaderboard.toString());
		userStats.uploadLeaderboardScore(currentLeaderboard,
				SteamUserStats.LeaderboardUploadScoreMethod.KeepBest, score, new int[] {});
	}
	
	return false;
}


public void disconnect()
{
	userStats.dispose();
	utils.dispose();
	friends.dispose();
	
	SteamAPI.shutdown();
};

What i call from my test method is this:

	sl.initAndConnect();
	sl.setLeaderboard();

This being said, in the method setLeaderboard(), i print System.out.println(currentLeaderboard); in 2 locations, before and after i call this:
String name = "leaderboard_test";
userStats.findLeaderboard(name);

The name of the leaderboard is correct, i copied and pasted it from my steam admin, but the currentLeaderboard attribute is always null. And after i read the steam documentation, i heart that it should call "onLeaderboardFindResult", but nothing inside it is printed in the console, so it is not called at all, i think, hence the " currentLeaderboard = leaderboard;" is never set, so it is null

I attached the files that i am using for the test. The MainTestStart is the class where i call the actual leaderboard steam implementation from
MainTestStart.txt
SteamLeaderboard.txt

Thank you in advance for your help and keep up the good work XD

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

1 participant