@@ -5,42 +5,46 @@ import dev.slne.surf.protect.paper.config
55import dev.slne.surf.protect.paper.math.Mth
66import dev.slne.surf.protect.paper.util.bukkitWorld
77import org.bukkit.World
8- import org.spongepowered.math.vector.Vector2i
8+ import org.spongepowered.math.vector.Vector2l
99
1010private val spawnPositionsByEnvironment = mapOf (
1111 World .Environment .NETHER to listOf (
12- Vector2i (0 , 0 ),
13- Vector2i (0 , - 3125 ),
14- Vector2i (3125 , - 3125 ),
15- Vector2i (- 3125 , - 3125 ),
16- Vector2i (0 , 3125 ),
17- Vector2i (3125 , 3125 ),
18- Vector2i (- 3125 , 3125 ),
19- Vector2i (3125 , 0 ),
20- Vector2i (- 3125 , 0 )
12+ Vector2l (0 , 0 ),
13+ Vector2l (0 , - 3125 ),
14+ Vector2l (3125 , - 3125 ),
15+ Vector2l (- 3125 , - 3125 ),
16+ Vector2l (0 , 3125 ),
17+ Vector2l (3125 , 3125 ),
18+ Vector2l (- 3125 , 3125 ),
19+ Vector2l (3125 , 0 ),
20+ Vector2l (- 3125 , 0 )
2121 ),
22- World .Environment .THE_END to listOf (Vector2i .ZERO ),
22+ World .Environment .THE_END to listOf (Vector2l .ZERO ),
2323 World .Environment .NORMAL to listOf (
24- Vector2i (0 , 0 ),
25- Vector2i (0 , - 25000 ),
26- Vector2i (25000 , - 25000 ),
27- Vector2i (- 25000 , - 25000 ),
28- Vector2i (0 , 25000 ),
29- Vector2i (25000 , 25000 ),
30- Vector2i (- 25000 , 25000 ),
31- Vector2i (25000 , 0 ),
32- Vector2i (- 25000 , 0 )
24+ Vector2l (0 , 0 ),
25+ Vector2l (0 , - 25000 ),
26+ Vector2l (25000 , - 25000 ),
27+ Vector2l (- 25000 , - 25000 ),
28+ Vector2l (0 , 25000 ),
29+ Vector2l (25000 , 25000 ),
30+ Vector2l (- 25000 , 25000 ),
31+ Vector2l (25000 , 0 ),
32+ Vector2l (- 25000 , 0 )
3333 )
3434)
3535
3636fun Location.getProtectionPricePerBlock (): PricePerBlockResult {
3737 val environment = this .bukkitWorld.environment
3838 val spawns = spawnPositionsByEnvironment[environment] ? : return PricePerBlockResult .EMPTY
39- val pos = Vector2i (blockX, blockZ)
39+ val pos = Vector2l (blockX.toLong() , blockZ.toLong() )
4040
4141 val nearestSpawn = spawns.minBy { pos.distanceSquared(it) }
4242 val distance = pos.distance(nearestSpawn)
4343
44+ if (! distance.isFinite()) {
45+ return PricePerBlockResult .EMPTY
46+ }
47+
4448 if (distance < config.pricing.spawnProtectionPerBlock) {
4549 return PricePerBlockResult (Double .MAX_VALUE , distance)
4650 }
@@ -55,9 +59,9 @@ fun Location.getProtectionPricePerBlock(): PricePerBlockResult {
5559
5660data class PricePerBlockResult (
5761 val pricePerBlock : Double ,
58- val spawnDistance : Float
62+ val spawnDistance : Double
5963) {
6064 companion object {
61- val EMPTY = PricePerBlockResult (Double .MAX_VALUE , Float .MAX_VALUE )
65+ val EMPTY = PricePerBlockResult (Double .MAX_VALUE , Double .MAX_VALUE )
6266 }
6367}
0 commit comments