From 7e8883b43075e61f8afd3f984bcdd7bf70fb54be Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 21 May 2021 19:58:28 +0100 Subject: [PATCH] Move Store/Js5MasterIndex providers to the game module This prevents the archive module from failing on a machine without the cache installed (like the archive.openrs2.org server). Signed-off-by: Graham --- .../main/kotlin/org/openrs2/cache/CacheModule.kt | 9 --------- game/src/main/kotlin/org/openrs2/game/GameModule.kt | 13 +++++++++++++ .../openrs2/game}/cache/Js5MasterIndexProvider.kt | 5 ++++- .../kotlin/org/openrs2/game}/cache/StoreProvider.kt | 3 ++- 4 files changed, 19 insertions(+), 11 deletions(-) rename {cache/src/main/kotlin/org/openrs2 => game/src/main/kotlin/org/openrs2/game}/cache/Js5MasterIndexProvider.kt (71%) rename {cache/src/main/kotlin/org/openrs2 => game/src/main/kotlin/org/openrs2/game}/cache/StoreProvider.kt (84%) diff --git a/cache/src/main/kotlin/org/openrs2/cache/CacheModule.kt b/cache/src/main/kotlin/org/openrs2/cache/CacheModule.kt index abf492cc..16691153 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/CacheModule.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/CacheModule.kt @@ -1,7 +1,6 @@ package org.openrs2.cache import com.google.inject.AbstractModule -import com.google.inject.Scopes import org.openrs2.buffer.BufferModule import org.openrs2.crypto.CryptoModule @@ -9,13 +8,5 @@ public object CacheModule : AbstractModule() { override fun configure() { install(BufferModule) install(CryptoModule) - - bind(Store::class.java) - .toProvider(StoreProvider::class.java) - .`in`(Scopes.SINGLETON) - - bind(Js5MasterIndex::class.java) - .toProvider(Js5MasterIndexProvider::class.java) - .`in`(Scopes.SINGLETON) } } diff --git a/game/src/main/kotlin/org/openrs2/game/GameModule.kt b/game/src/main/kotlin/org/openrs2/game/GameModule.kt index 68e65319..0aade2f6 100644 --- a/game/src/main/kotlin/org/openrs2/game/GameModule.kt +++ b/game/src/main/kotlin/org/openrs2/game/GameModule.kt @@ -2,10 +2,15 @@ package org.openrs2.game import com.google.common.util.concurrent.Service import com.google.inject.AbstractModule +import com.google.inject.Scopes import com.google.inject.multibindings.Multibinder import org.openrs2.buffer.BufferModule import org.openrs2.cache.CacheModule +import org.openrs2.cache.Js5MasterIndex +import org.openrs2.cache.Store import org.openrs2.conf.ConfigModule +import org.openrs2.game.cache.Js5MasterIndexProvider +import org.openrs2.game.cache.StoreProvider import org.openrs2.game.net.NetworkService import org.openrs2.game.net.js5.Js5Service import org.openrs2.net.NetworkModule @@ -20,5 +25,13 @@ public object GameModule : AbstractModule() { val binder = Multibinder.newSetBinder(binder(), Service::class.java) binder.addBinding().to(Js5Service::class.java) binder.addBinding().to(NetworkService::class.java) + + bind(Store::class.java) + .toProvider(StoreProvider::class.java) + .`in`(Scopes.SINGLETON) + + bind(Js5MasterIndex::class.java) + .toProvider(Js5MasterIndexProvider::class.java) + .`in`(Scopes.SINGLETON) } } diff --git a/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndexProvider.kt b/game/src/main/kotlin/org/openrs2/game/cache/Js5MasterIndexProvider.kt similarity index 71% rename from cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndexProvider.kt rename to game/src/main/kotlin/org/openrs2/game/cache/Js5MasterIndexProvider.kt index f0d66bc3..9165e004 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndexProvider.kt +++ b/game/src/main/kotlin/org/openrs2/game/cache/Js5MasterIndexProvider.kt @@ -1,5 +1,8 @@ -package org.openrs2.cache +package org.openrs2.game.cache +import org.openrs2.cache.Js5MasterIndex +import org.openrs2.cache.MasterIndexFormat +import org.openrs2.cache.Store import javax.inject.Inject import javax.inject.Provider diff --git a/cache/src/main/kotlin/org/openrs2/cache/StoreProvider.kt b/game/src/main/kotlin/org/openrs2/game/cache/StoreProvider.kt similarity index 84% rename from cache/src/main/kotlin/org/openrs2/cache/StoreProvider.kt rename to game/src/main/kotlin/org/openrs2/game/cache/StoreProvider.kt index 1643eb3d..e31bf20e 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/StoreProvider.kt +++ b/game/src/main/kotlin/org/openrs2/game/cache/StoreProvider.kt @@ -1,6 +1,7 @@ -package org.openrs2.cache +package org.openrs2.game.cache import io.netty.buffer.ByteBufAllocator +import org.openrs2.cache.Store import java.nio.file.Path import javax.inject.Inject import javax.inject.Provider