Skip to content

Commit 8927c40

Browse files
feat: implement hashCode method in BukkitNpc for improved object comparison and hashing consistency
1 parent 0c64f7d commit 8927c40

File tree

1 file changed

+14
-0
lines changed
  • surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/npc

1 file changed

+14
-0
lines changed

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/npc/BukkitNpc.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,18 @@ class BukkitNpc(
357357

358358
return propertyValue as T
359359
}
360+
361+
override fun hashCode(): Int {
362+
var result = id
363+
result = 31 * result + nameTagId
364+
result = 31 * result + npcSittingId
365+
result = 31 * result + npcUuid.hashCode()
366+
result = 31 * result + nameTagUuid.hashCode()
367+
result = 31 * result + properties.hashCode()
368+
result = 31 * result + (viewers?.hashCode() ?: 0)
369+
result = 31 * result + uniqueName.hashCode()
370+
result = 31 * result + npcSittingUuid.hashCode()
371+
result = 31 * result + eventHandlers.hashCode()
372+
return result
373+
}
360374
}

0 commit comments

Comments
 (0)