Skip to content

Fix spawn distance overflow and update version to 3.2.7#34

Merged
twisti-dev merged 2 commits into
version/26.1from
fix/integer-overflow
Jun 5, 2026
Merged

Fix spawn distance overflow and update version to 3.2.7#34
twisti-dev merged 2 commits into
version/26.1from
fix/integer-overflow

Conversation

@twisti-dev

Copy link
Copy Markdown
Contributor

This pull request updates the project version and refactors the codebase to consistently use Double for distance and coordinate calculations, improving numerical accuracy and consistency. It also changes vector types from Vector2i (integer) to Vector2l (long) for spawn position calculations, and adds a check for non-finite distances to prevent errors.

Consistency and Accuracy Improvements

  • Changed all distance and coordinate calculations from Float/Int to Double/Long for increased precision and consistency (calculatePricePerBlock, EffectiveCostResult, PricePerBlockResult, and related usages). [1] [2] [3] [4]
  • Refactored spawn position vectors from Vector2i to Vector2l to support larger coordinate ranges and match the new numeric types.

Code Robustness

  • Added a check to return an empty result if the calculated distance is not finite, preventing potential runtime errors.

Maintenance

  • Updated project version from 3.2.6 to 3.2.7 in gradle.properties.
  • Cleaned up imports in Messages.kt for clarity.

@twisti-dev twisti-dev self-assigned this Jun 5, 2026
Copilot AI review requested due to automatic review settings June 5, 2026 11:50
@twisti-dev twisti-dev merged commit 8ef68f3 into version/26.1 Jun 5, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Vector2i to Vector2l and converted block coordinates to Long before distance calculations.
  • Standardized distance-related fields/APIs from Float to Double (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
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.

2 participants