Skip to content

Commit

Permalink
Make MinecraftVersion serializable for Gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Jun 18, 2024
1 parent afbbab8 commit 1f56524
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/kotlin/dev/deftu/gradle/utils/MinecraftVersion.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package dev.deftu.gradle.utils

import org.gradle.api.JavaVersion
import java.io.Serializable

/**
* A class representing a version of Minecraft.
*/
class MinecraftVersion private constructor(val rawVersion: Int) : Comparable<MinecraftVersion> {
class MinecraftVersion private constructor(val rawVersion: Int) : Comparable<MinecraftVersion>, Serializable {

val major: Int
get() = rawVersion / 10000
Expand Down Expand Up @@ -54,6 +55,13 @@ class MinecraftVersion private constructor(val rawVersion: Int) : Comparable<Min
return false
}

override fun hashCode(): Int {
var result = major.hashCode()
result = 31 * result + minor.hashCode()
result = 31 * result + patch.hashCode()
return result
}

override fun toString(): String {
return "$major.$minor" + if (patch != 0) ".$patch" else ""
}
Expand Down

0 comments on commit 1f56524

Please sign in to comment.