mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-21 14:46:25 -04:00
Allows PlayerPartyStore's to have their own unique storage id, separate from the player uuid.
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ open class JSONStoreAdapter(
|
||||
val br = BufferedReader(FileReader(file))
|
||||
val json = gson.fromJson<JsonObject>(br)
|
||||
br.close()
|
||||
val store = storeClass.getConstructor(UUID::class.java).newInstance(uuid)
|
||||
val store = storeClass.getConstructor(UUID::class.java, UUID::class.java).newInstance(uuid, uuid)
|
||||
store.loadFromJSON(json)
|
||||
store
|
||||
} catch (e: Exception) {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ open class NBTStoreAdapter(
|
||||
override fun <E : StorePosition, T : PokemonStore<E>> serialize(store: T) = store.saveToNBT(NbtCompound())
|
||||
override fun save(file: File, serialized: NbtCompound) = NbtIo.writeCompressed(serialized, file)
|
||||
override fun <E, T : PokemonStore<E>> load(file: File, storeClass: Class<out T>, uuid: UUID): T? {
|
||||
val store = storeClass.getConstructor(UUID::class.java).newInstance(uuid)
|
||||
val store = storeClass.getConstructor(UUID::class.java, UUID::class.java).newInstance(uuid, uuid)
|
||||
return try {
|
||||
val nbt = NbtIo.readCompressed(file)
|
||||
store.loadFromNBT(nbt)
|
||||
|
||||
+4
-2
@@ -38,8 +38,10 @@ import kotlin.random.Random
|
||||
*/
|
||||
open class PlayerPartyStore(
|
||||
/** The UUID of the player this store is for. */
|
||||
val playerUUID: UUID
|
||||
) : PartyStore(playerUUID) {
|
||||
val playerUUID: UUID,
|
||||
/** The UUID of the store. This is the same as [playerUUID] by default, but can be changed to allow for multiple parties. */
|
||||
storageUUID: UUID = playerUUID
|
||||
) : PartyStore(storageUUID) {
|
||||
|
||||
private var secondsSinceFriendshipUpdate = 0
|
||||
|
||||
|
||||
@@ -928,7 +928,14 @@ open class Pokemon : ShowdownIdentifiable {
|
||||
|
||||
fun getOwnerUUID() : UUID? {
|
||||
storeCoordinates.get().let {
|
||||
if (isPlayerOwned()) return it!!.store.uuid
|
||||
if (!isPlayerOwned()) {
|
||||
return@let
|
||||
}
|
||||
|
||||
if (it!!.store is PlayerPartyStore) {
|
||||
return (it.store as PlayerPartyStore).playerUUID
|
||||
}
|
||||
return it.store.uuid
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user