Support for custom arithmetic operators#8065
Merged
Absolutionism merged 8 commits intoSkriptLang:dev/featurefrom Sep 17, 2025
Merged
Support for custom arithmetic operators#8065Absolutionism merged 8 commits intoSkriptLang:dev/featurefrom
Absolutionism merged 8 commits intoSkriptLang:dev/featurefrom
Conversation
sovdeeth
approved these changes
Jul 21, 2025
sovdeeth
requested changes
Jul 21, 2025
Member
sovdeeth
left a comment
There was a problem hiding this comment.
arithmetic simplification appears to have broken, maybe related to order of ops?
APickledWalrus
requested changes
Jul 24, 2025
Member
APickledWalrus
left a comment
There was a problem hiding this comment.
Really great work. Thanks for adding lots of javadocs too 🙂
src/main/java/ch/njol/skript/test/runner/CustomTestOperators.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java
Outdated
Show resolved
Hide resolved
src/main/java/org/skriptlang/skript/lang/arithmetic/Arithmetics.java
Outdated
Show resolved
Hide resolved
…o and OperationInfo
sovdeeth
approved these changes
Jul 28, 2025
APickledWalrus
approved these changes
Jul 30, 2025
Member
APickledWalrus
left a comment
There was a problem hiding this comment.
Looks good, great work!
Member
There was a problem hiding this comment.
I mean that old issue should be resolved from the sorting that happens from the method. I think if there isn't a reason within this class for it to be sorted then keeping it unsorted should be preferred
erenkarakal
pushed a commit
to erenkarakal/Skript
that referenced
this pull request
Nov 26, 2025
* javadocs and refactoring of the arithmetics api * added support for the registration of custom operators * preserve the registration order of operators for the pattern generation * added test for custom operators * styling, added back the removed methods from old API of DifferenceInfo and OperationInfo * added cache for converted operation info and small improvements * switched back to regular hash map for storing registered operations, expanded compare for operators
erenkarakal
pushed a commit
to erenkarakal/Skript
that referenced
this pull request
Nov 26, 2025
* javadocs and refactoring of the arithmetics api * added support for the registration of custom operators * preserve the registration order of operators for the pattern generation * added test for custom operators * styling, added back the removed methods from old API of DifferenceInfo and OperationInfo * added cache for converted operation info and small improvements * switched back to regular hash map for storing registered operations, expanded compare for operators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently, Skript's operator set is fixed and defined within an enum class. This PR expands on the arithmetic rework and adds the necessary API (and documentation) for the developers to register their own operators.
This PR also fixes the issue with operations caching system. If no suitable operation is found, that information is now stored in the cache.
This could be considered a breaking change becauseOperationInfoandDifferenceInfoare now record classes. The design choice makes sense and should be fine. As far as I know, no addons currently use these classes. All other API stays the same.The old methods are deprecated in favor of the record component access methods.
Solution
Operatoris now a record class that accepts custom sign (which could also be a String). After the arithmetic operations are registered, the arithmetic expression patterns are generated with all the operator signs.Testing Completed
built-in tests
src/test/skript/tests/misc/custom operators.sk
Completes: none
Related: none