Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ abstract class CommonCloudPlayerImpl(uuid: UUID, override val name: String) :
protected val persistentDataView = object : PersistentPlayerDataContainerViewImpl() {
override fun toTagCompound() = ppdcReentrantLock.read { ppdc.tag }
override fun getTag(key: String) = ppdcReentrantLock.read { ppdc.getTag(key) }
override fun snapshotTag() = ppdcReentrantLock.read { super.snapshotTag() }
}

override val persistentData get() = persistentDataView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ open class PersistentPlayerDataContainerImpl(
}

override fun snapshot(): PersistentPlayerDataContainerImpl {
return PersistentPlayerDataContainerImpl(tag.fast())
return PersistentPlayerDataContainerImpl(snapshotTag().fast())
}

fun fromTagCompound(tag: CompoundBinaryTag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,27 @@ abstract class PersistentPlayerDataContainerViewImpl : PersistentPlayerDataConta
}

override fun snapshot(): PersistentPlayerDataContainerViewImpl {
val tag = deepCopy(toTagCompound())

val tagCopy = CompoundBinaryTag.builder()
.put(tag)
.build()
val tagCopy = snapshotTag()

return object : PersistentPlayerDataContainerViewImpl() {
override fun toTagCompound() = tagCopy
override fun getTag(key: String) = tagCopy.get(key)
override fun snapshotTag() = tagCopy
}
}

/**
* Creates a snapshot of the tag compound.
* Subclasses should override this method to ensure the snapshot is created
* while holding appropriate locks to prevent concurrent modifications.
*/
protected open fun snapshotTag(): CompoundBinaryTag {
val tag = deepCopy(toTagCompound())
return CompoundBinaryTag.builder()
.put(tag)
.build()
}


/**
* Creates a deep copy of the provided `CompoundBinaryTag` without using recursion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ open class TrackingPlayerPersistentDataContainerImpl(
}

override fun snapshot(): TrackingPlayerPersistentDataContainerImpl {
return TrackingPlayerPersistentDataContainerImpl(tag.fast())
return TrackingPlayerPersistentDataContainerImpl(snapshotTag().fast())
}
}
Loading