diff options
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/storage/Storage.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/storage/Storage.kt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/storage/Storage.kt b/src/main/kotlin/io/dico/parcels2/storage/Storage.kt index 2116b46..a0e94e0 100644 --- a/src/main/kotlin/io/dico/parcels2/storage/Storage.kt +++ b/src/main/kotlin/io/dico/parcels2/storage/Storage.kt @@ -8,6 +8,7 @@ import kotlinx.coroutines.experimental.Job import kotlinx.coroutines.experimental.channels.ReceiveChannel import kotlinx.coroutines.experimental.channels.SendChannel import kotlinx.coroutines.experimental.launch +import org.joda.time.DateTime import java.util.UUID typealias DataPair = Pair<ParcelId, ParcelData?> @@ -22,8 +23,14 @@ interface Storage { fun shutdown(): Job + fun getWorldCreationTime(worldId: ParcelWorldId): Deferred<DateTime?> + + fun setWorldCreationTime(worldId: ParcelWorldId, time: DateTime): Job + fun getPlayerUuidForName(name: String): Deferred<UUID?> + fun updatePlayerName(uuid: UUID, name: String): Job + fun readParcelData(parcel: ParcelId): Deferred<ParcelData?> fun transmitParcelData(parcels: Sequence<ParcelId>): ReceiveChannel<DataPair> @@ -39,6 +46,8 @@ interface Storage { fun setParcelOwner(parcel: ParcelId, owner: PlayerProfile?): Job + fun setParcelOwnerSignOutdated(parcel: ParcelId, outdated: Boolean): Job + fun setParcelPlayerStatus(parcel: ParcelId, player: PlayerProfile, status: AddedStatus): Job fun setParcelAllowsInteractInventory(parcel: ParcelId, value: Boolean): Job @@ -65,8 +74,14 @@ class BackedStorage internal constructor(val b: Backing) : Storage { override fun shutdown() = launch(b.dispatcher) { b.shutdown() } + override fun getWorldCreationTime(worldId: ParcelWorldId): Deferred<DateTime?> = b.launchFuture { b.getWorldCreationTime(worldId) } + + override fun setWorldCreationTime(worldId: ParcelWorldId, time: DateTime): Job = b.launchJob { b.setWorldCreationTime(worldId, time) } + override fun getPlayerUuidForName(name: String): Deferred<UUID?> = b.launchFuture { b.getPlayerUuidForName(name) } + override fun updatePlayerName(uuid: UUID, name: String): Job = b.launchJob { b.updatePlayerName(uuid, name) } + override fun readParcelData(parcel: ParcelId) = b.launchFuture { b.readParcelData(parcel) } override fun transmitParcelData(parcels: Sequence<ParcelId>) = b.openChannel<DataPair> { b.transmitParcelData(it, parcels) } @@ -81,6 +96,8 @@ class BackedStorage internal constructor(val b: Backing) : Storage { override fun setParcelOwner(parcel: ParcelId, owner: PlayerProfile?) = b.launchJob { b.setParcelOwner(parcel, owner) } + override fun setParcelOwnerSignOutdated(parcel: ParcelId, outdated: Boolean): Job = b.launchJob { b.setParcelOwnerSignOutdated(parcel, outdated) } + override fun setParcelPlayerStatus(parcel: ParcelId, player: PlayerProfile, status: AddedStatus) = b.launchJob { b.setLocalPlayerStatus(parcel, player, status) } override fun setParcelAllowsInteractInventory(parcel: ParcelId, value: Boolean) = b.launchJob { b.setParcelAllowsInteractInventory(parcel, value) } |