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

Event value priority #4858

Closed

Conversation

TheLimeGlass
Copy link
Collaborator

@TheLimeGlass TheLimeGlass commented Jul 1, 2022

Description

Adds event value priority so that we can fix conflicts easily.

There was an issue where somehow addons could register duplicated event-values to those as Skript, and have the addons take priority. Adding a priority is a semi fix to the solution.

Adds new register methods to EventValues, priority and after which examines existing EventValueInfos.

I balanced the priority values to have everything work together.

I added a debug method that displays the sorted values after they're all registered. I think i'm the only one that uses debug verbose.


Target Minecraft Versions: any
Related Issues: There are a bunch of issues indirectly related, this is a tool to help aid them all.

@TheLimeGlass TheLimeGlass added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something. labels Jul 1, 2022
Copy link
Member

@AyhamAl-Ali AyhamAl-Ali left a comment

Choose a reason for hiding this comment

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

Amazing PR! 👏

Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

Very nice! Just a few things


@Override
public int compareTo(EventValueInfo<?, ?> other) {
return Integer.compare(Math.abs(priority), Math.abs(other.priority));
Copy link
Member

Choose a reason for hiding this comment

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

Instead of worrying about cleaning numbers here, maybe an IAE if the priority is below 0 during construction

Copy link
Collaborator Author

@TheLimeGlass TheLimeGlass Jul 12, 2022

Choose a reason for hiding this comment

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

Priority in the negatives can be used by addons to override Skript's priority as Skript never uses negative numbers.

Copy link
Member

Choose a reason for hiding this comment

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

If you take the absolute value though, then an addon can't really override Skript can it?

If Skript has a priority of 10 and my addon's is -20, Skript wins after absolute value calculations

Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

Really just some thoughts/questions

Also see: #4858 (comment)

Comment on lines +100 to 102
private final static List<EventValueInfo<?, ?>> defaultEventValues = new ArrayList<>();
private final static List<EventValueInfo<?, ?>> futureEventValues = new ArrayList<>();
private final static List<EventValueInfo<?, ?>> pastEventValues = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

If these need sorted and can't have duplicates perhaps it would be better to use a TreeSet?

Copy link
Collaborator Author

@TheLimeGlass TheLimeGlass Jul 13, 2022

Choose a reason for hiding this comment

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

I already tried that, it wasn't working and I tried everything. The sets ended up having only 4-6 values for some reason. I literally even made a custom class and everything to ensure the comparison wasn't being the issue, even down to the fields of the event value infos being compared, but no matter what I tried it never wanted to work with a tree set. This is also why the equals method there is over the top, that was me debugging why the hell it wasn't working. My only guess is because of the generics.

@TheLimeGlass
Copy link
Collaborator Author

TheLimeGlass commented Mar 10, 2023

Needs more testing after #5503 has fixed most the issues this in-tales to fix.
Keeping this open as it may solve an issue in 2.8

@TheLimeGlass TheLimeGlass changed the base branch from master to dev/feature October 17, 2023 06:34
@sovdeeth sovdeeth removed the 2.8 Targeting a 2.8.X version release label Dec 30, 2023
@sovdeeth
Copy link
Member

Do you still intend to work on this?

@sovdeeth
Copy link
Member

closing due to inactivity

@sovdeeth sovdeeth closed this Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants