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

Fixed Issues with recieving multiple rewards #930

Merged
merged 1 commit into from
Dec 28, 2024

Conversation

PeachesMLG
Copy link
Member

No description provided.

Comment on lines +782 to +784
CompletableFuture.runAsync(() -> IridiumSkyblock.getInstance().getDatabaseManager().getTeamRewardsTableManager().save(teamReward)).thenRun(() ->
IridiumSkyblock.getInstance().getDatabaseManager().getTeamRewardsTableManager().addEntry(teamReward)
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This saves the record to the database first, which will generate the Id field.

What was happening was the id wasnt set, so all defaulted to 0, and here https://github.com/Iridium-Development/IridiumSkyblock/blob/master/src/main/java/com/iridium/iridiumskyblock/managers/DatabaseManager.java#L85 You can see we are keying by the id.

So when we save, it actually does a save/update and will replace if the key is the same, but since we havent saved to the database yet, the key (Id) isnt set, so is 0, which means that it will override the other values

@PeachesMLG PeachesMLG merged commit 33381b1 into master Dec 28, 2024
1 check passed
@PeachesMLG PeachesMLG deleted the fix-recieving-multiple-rewards branch December 28, 2024 19:27
@PeachesMLG
Copy link
Member Author

This also patches the issue with being able to infinitly redeem rewards.

How we store the records is in a hashmap of key/value, as I mentioned above, we set the rewards key to the database id.

However, this will also be set to 0, which isnt itself an issue.

However, if you wait 5 minutes for the database to save, it will assign the id 0 to the next sequentual value, however it wont update the hashmap key, which means when we try to delete the value, we try to delete key, lets say 5, however no key exists under 5 in the hashmap (because its under 0)

This should also fix that

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

Successfully merging this pull request may close these issues.

1 participant