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

Fix disabled items preventing research completion #3827

Conversation

test137E29B
Copy link
Contributor

Description

When a SlimefunItem bound to a Research is disabled, the Research is not disabled. This means that the Research becomes locked permanently and the user can never achieve 100% Research unlock completion. If a SlimefunItem is globally disabled, it should not be bindable to Research since it's never usable. If a Research has no bound SlimefunItems (because they're all globall disabled), the research should act as not enabled also. Disabled researches should be filtered out too from the Progress stat.

Proposed changes

Prevent disabled items being added to Research, filter out Researches with no Items bound when requested. This could also be triggered some other place that's more efficient than every time research is requested. Please suggest another place to perform this action if a better place exists.

Related Issues (if applicable)

Resolves #3782

Checklist

  • I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.19.*).
  • I followed the existing code standards and didn't mess up the formatting.
  • I did my best to add documentation to any public classes or methods I added.
  • I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • I added sufficient Unit Tests to cover my code.

@test137E29B test137E29B requested a review from a team as a code owner May 8, 2023 19:55
@JustAHuman-xD
Copy link
Contributor

This is not the method you should use to fix the bug, by changing the is enabled function you can affect A TON of things that you don't know of. Instead change how the stats are calculated

@JustAHuman-xD
Copy link
Contributor

For an example of this fix see: JustAHuman-xD@1807315

1 similar comment
@JustAHuman-xD
Copy link
Contributor

For an example of this fix see: JustAHuman-xD@1807315

@JustAHuman-xD
Copy link
Contributor

I didn't make the PR for some reason wether it was time or an issue I don't remember

@test137E29B
Copy link
Contributor Author

For an example of this fix see: JustAHuman-xD@1807315

But if you bind 2x researches to the same item, it unbinds the item from one of the researches (the first), thus leaving a research with NO items. This research is then NOT unlockable and again causes the same problem where you can't 100% research.

Researches with no items should be treated as not enabled because they are incomplete and cannot work correctly. This was conciously changed globally to prevent anywhere research is used from taking into account any research that is not set up correctly.

@JustAHuman-xD
Copy link
Contributor

Idk it still feels like an iffy change but others can give their opinion on it. I think that way because people could make dummy/marker researches with no items in it intentionally, or disabled items intentionally tho a reason for that I can't think of off the top of my head. And the change you made to getResearches is definitely an iffy change. I would suggest instead adding a method called getEnabledResearches. As getResearches implies all researches not just enabled ones.

@JustAHuman-xD
Copy link
Contributor

TLDR changing the behavior of old and crucial API is always scary

@test137E29B
Copy link
Contributor Author

NB adds new Placeholder researches_total_researches_enabled

@test137E29B test137E29B requested review from Sefiraat and J3fftw1 May 9, 2023 21:02
@@ -649,6 +649,11 @@ private void checkForDeprecations(@Nullable Class<?> c) {
* The new {@link Research} for this {@link SlimefunItem}, or null
*/
public void setResearch(@Nullable Research research) {
if (this.isDisabled()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this check is not here, we'd have to check every affected item when getting enabled researches.

I don't think this is a good solution anymore though tbh

@TheBusyBiscuit TheBusyBiscuit added the ✨ Fix This Pull Request fixes an issue. label Jun 7, 2023
@TheBusyBot TheBusyBot added the ⚡ Merge Conflicts This Pull Request has merged conflicts which need to be resolved! label Jul 31, 2023
@JustAHuman-xD
Copy link
Contributor

Superceded by #3917

@test137E29B test137E29B deleted the fix/disabled-items-research-stat branch December 2, 2023 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Fix This Pull Request fixes an issue. ⚡ Merge Conflicts This Pull Request has merged conflicts which need to be resolved!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sf stats counting disabled items in the list of unlocked items, making us unable to achieve 100%
6 participants