Fix spawn distance overflow and update version to 3.2.7#34
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request bumps the plugin version to 3.2.7 and refactors spawn-distance and pricing calculations to use wider numeric types (primarily Double and Long) to reduce overflow risk and improve numeric consistency.
Changes:
- Switched spawn-position math from
Vector2itoVector2land converted block coordinates toLongbefore distance calculations. - Standardized distance-related fields/APIs from
FloattoDouble(e.g.,calculatePricePerBlock,EffectiveCostResult,PricePerBlockResult, message formatting inputs). - Added a guard to return an empty pricing result when the computed spawn distance is non-finite.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/kotlin/dev/slne/surf/protect/paper/region/utils.kt | Uses Vector2l + Double distance, adds non-finite distance guard, updates PricePerBlockResult to Double. |
| src/main/kotlin/dev/slne/surf/protect/paper/message/Messages.kt | Updates offer message API to accept Double spawn distance and adjusts imports. |
| src/main/kotlin/dev/slne/surf/protect/paper/math/Mth.kt | Updates pricing/effective-cost APIs to use Double distances consistently. |
| gradle.properties | Bumps project version from 3.2.6 to 3.2.7. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| distanceToSpawn: Double, | ||
| discountFactor: Double = 1.0 | ||
| ) = buildText { | ||
| val distanceToSpawn = (distanceToSpawn * 100).roundToInt() / 100.0 |
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.
This pull request updates the project version and refactors the codebase to consistently use
Doublefor distance and coordinate calculations, improving numerical accuracy and consistency. It also changes vector types fromVector2i(integer) toVector2l(long) for spawn position calculations, and adds a check for non-finite distances to prevent errors.Consistency and Accuracy Improvements
Float/InttoDouble/Longfor increased precision and consistency (calculatePricePerBlock,EffectiveCostResult,PricePerBlockResult, and related usages). [1] [2] [3] [4]Vector2itoVector2lto support larger coordinate ranges and match the new numeric types.Code Robustness
Maintenance
3.2.6to3.2.7ingradle.properties.Messages.ktfor clarity.