From cb73da63e20c91b9206d5f371c2859e7ba75a7b2 Mon Sep 17 00:00:00 2001 From: GregHib Date: Fri, 10 Jan 2025 17:19:40 +0000 Subject: [PATCH] Replace Main.name with server.name setting --- game/src/main/kotlin/world/gregs/voidps/Main.kt | 13 +++++-------- .../world/activity/achievement/ExplorerJack.kts | 4 ++-- .../voidps/world/interact/entity/npc/Banker.kts | 4 ++-- .../world/map/varrock/BartenderBlueMoonInn.kts | 3 ++- .../world/gregs/voidps/world/script/WorldTest.kt | 1 - 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/game/src/main/kotlin/world/gregs/voidps/Main.kt b/game/src/main/kotlin/world/gregs/voidps/Main.kt index c38380b92..cea626b9c 100644 --- a/game/src/main/kotlin/world/gregs/voidps/Main.kt +++ b/game/src/main/kotlin/world/gregs/voidps/Main.kt @@ -23,7 +23,6 @@ import world.gregs.voidps.network.GameServer import world.gregs.voidps.network.LoginServer import world.gregs.voidps.network.login.protocol.decoders import world.gregs.voidps.script.loadScripts -import java.io.File import java.util.* import kotlin.coroutines.CoroutineContext @@ -34,19 +33,17 @@ import kotlin.coroutines.CoroutineContext object Main : CoroutineScope { override val coroutineContext: CoroutineContext = Contexts.Game - lateinit var name: String private val logger = InlineLogger() @OptIn(ExperimentalUnsignedTypes::class) @JvmStatic fun main(args: Array) { val startTime = System.currentTimeMillis() - val properties = settings() - name = Settings["server.name"] + val settings = settings() // File server - val cache = timed("cache") { Cache.load(properties) } - val server = GameServer.load(cache, properties) + val cache = timed("cache") { Cache.load(settings) } + val server = GameServer.load(cache, settings) val job = server.start(Settings["network.port"].toInt()) // Content @@ -60,7 +57,7 @@ object Main : CoroutineScope { // Login server val decoders = decoders(get()) val accountLoader: PlayerAccountLoader = get() - val loginServer = LoginServer.load(properties, decoders, accountLoader) + val loginServer = LoginServer.load(settings, decoders, accountLoader) // Game world val stages = getTickStages() @@ -68,7 +65,7 @@ object Main : CoroutineScope { val scope = CoroutineScope(Contexts.Game) val engine = GameLoop(stages).start(scope) server.loginServer = loginServer - logger.info { "$name loaded in ${System.currentTimeMillis() - startTime}ms" } + logger.info { "${Settings["server.name"]} loaded in ${System.currentTimeMillis() - startTime}ms" } runBlocking { try { job.join() diff --git a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts index 41e6b7692..807a2ea78 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/activity/achievement/ExplorerJack.kts @@ -3,8 +3,8 @@ package world.gregs.voidps.world.activity.achievement import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.sendScript import world.gregs.voidps.engine.client.variable.BitwiseValues +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.data.definition.VariableDefinitions -import world.gregs.voidps.Main.name import world.gregs.voidps.engine.entity.character.npc.NPCOption import world.gregs.voidps.engine.entity.character.npc.npcOperate import world.gregs.voidps.engine.entity.character.player.Player @@ -25,7 +25,7 @@ import world.gregs.voidps.world.interact.dialogue.type.player npcOperate("Talk-to", "explorer_jack") { if (player["introducing_explorer_jack_task", "uncompleted"] == "uncompleted") { - npc("Ah! Welcome to ${name}, lad. My name's Explorer jack. I'm an explorer by trade, and I'm one of the Taskmasters around these parts") + npc("Ah! Welcome to ${Settings["server.name"]}, lad. My name's Explorer jack. I'm an explorer by trade, and I'm one of the Taskmasters around these parts") player("Taskmaster? What Tasks are you Master of?") whatIsTaskSystem() } diff --git a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts index 1387955e7..ecca786eb 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/interact/entity/npc/Banker.kts @@ -1,8 +1,8 @@ package world.gregs.voidps.world.interact.entity.npc -import world.gregs.voidps.Main.name import world.gregs.voidps.engine.client.ui.dialogue.talkWith import world.gregs.voidps.engine.client.ui.open +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.CharacterContext import world.gregs.voidps.engine.entity.character.npc.NPCs import world.gregs.voidps.engine.entity.character.npc.npcApproach @@ -46,7 +46,7 @@ suspend fun CharacterContext.menu() { option("I'd like to see my collection box.", block = { player.open("collection_box") }) option("I'd like to see my Returned Items box.", block = { player.open("returned_items") }) option("What is this place?") { - npc("This is a branch of the Bank of $name. We have branches in many towns.") + npc("This is a branch of the Bank of ${Settings["server.name"]}. We have branches in many towns.") choice { option("And what do you do?") { npc("We will look after your items and money for you. Leave your valuables with us if you want to keep them safe.") diff --git a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts index 43a8fc060..6556ca1be 100644 --- a/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts +++ b/game/src/main/kotlin/world/gregs/voidps/world/map/varrock/BartenderBlueMoonInn.kts @@ -3,6 +3,7 @@ package world.gregs.voidps.world.map.varrock import world.gregs.voidps.Main import world.gregs.voidps.engine.client.message import world.gregs.voidps.engine.client.ui.interact.itemOnNPCApproach +import world.gregs.voidps.engine.data.Settings import world.gregs.voidps.engine.entity.character.forceChat import world.gregs.voidps.engine.entity.character.mode.interact.TargetNPCContext import world.gregs.voidps.engine.entity.character.npc.npcApproach @@ -38,7 +39,7 @@ npcApproach("Talk-to", "bartender_blue_moon_inn") { choice { option("Oh ah well...") option("Game? What are you talking about?") { - npc("This world around us... is an online game... called ${Main.name}.") + npc("This world around us... is an online game... called ${Settings["server.name"]}.") player("Nope, still don't understand what you are talking about. What does 'online' mean?") npc("It's a sort of connection between magic boxes across the world, big boxes on people's desktops and little ones people can carry. They can talk to each other to play games.") player("I give up. You're obviously completely mad!") diff --git a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt index 6d1734640..f4ae99940 100644 --- a/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt +++ b/game/src/test/kotlin/world/gregs/voidps/world/script/WorldTest.kt @@ -148,7 +148,6 @@ abstract class WorldTest : KoinTest { @BeforeAll fun beforeAll() { - Main.name = "test" properties = Properties() properties.load(WorldTest::class.java.getResourceAsStream("/test.properties")!!) settings = Settings.load(properties)