diff --git a/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt b/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt index ecb286e4a..e4ad85b4a 100644 --- a/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt +++ b/Server/src/main/kotlin/rs09/game/system/config/ServerConfigParser.kt @@ -10,6 +10,7 @@ import rs09.game.system.SystemLogger import rs09.game.world.GameSettings import rs09.game.world.GameWorld import java.io.File +import java.net.URL import kotlin.system.exitProcess /** @@ -23,8 +24,17 @@ object ServerConfigParser { fun parse(path: String){ confFile = File(parsePath(path)) + parseFromFile(confFile) + } + + fun parse(path: URL?) { + confFile = File(path!!.toURI()) + parseFromFile(confFile) + } + + private fun parseFromFile(confFile: File?) { if(!confFile!!.canonicalFile.exists()){ - SystemLogger.logErr("${confFile!!.canonicalFile} does not exist in the current working directory.") + SystemLogger.logErr("${confFile.canonicalFile} does not exist.") exitProcess(0) } else { try { @@ -32,7 +42,7 @@ object ServerConfigParser { parseServerSettings() parseGameSettings() } catch (e: java.lang.IllegalStateException) { - SystemLogger.logErr("Passed config file is not a TOML file. Path: ${confFile!!.canonicalPath}") + SystemLogger.logErr("Passed config file is not a TOML file. Path: ${confFile.canonicalPath}") SystemLogger.logErr("Exception received: $e") SystemLogger.logAlert("Shutting down...") exitProcess(0) diff --git a/Server/src/test/kotlin/TestUtils.kt b/Server/src/test/kotlin/TestUtils.kt index da820f5c6..79ccddbcc 100644 --- a/Server/src/test/kotlin/TestUtils.kt +++ b/Server/src/test/kotlin/TestUtils.kt @@ -28,7 +28,7 @@ object TestUtils { fun preTestSetup() { if(ServerConstants.DATA_PATH == null) { - ServerConfigParser.parse("worldprops/test.conf") + ServerConfigParser.parse(this::class.java.getResource("test.conf")) Cache.init(this::class.java.getResource("cache").path.toString()) ConfigParser().prePlugin() ConfigParser().postPlugin() diff --git a/Server/src/test/resources/test.conf b/Server/src/test/resources/test.conf new file mode 100644 index 000000000..64fee2d6f --- /dev/null +++ b/Server/src/test/resources/test.conf @@ -0,0 +1,71 @@ +[server] +#Secret key - this is sent by the client during login. +#Client/Server MUST match or connection is refused. +secret_key = "2009scape_development" +write_logs = true +msip = "127.0.0.1" + +[database] +database_name = "global" +database_username = "root" +database_password = "" +database_address = "127.0.0.1" +database_port = "3306" + + +[world] +name = "2009scape" +debug = true +dev = true +start_gui = false +daily_restart = true +#world number +world_id = "1" +country_id = "0" +members = true +#activity as displayed on the world list +activity = "2009scape classic." +pvp = false +default_xp_rate = 5.0 +allow_slayer_reroll = false +#enables a default clan for players to join automatically. Should be an account with the same name as @name, with a clan set up already. +enable_default_clan = true +enable_bots = true +#message of the week model ID, 0 for random +motw_identifier = "0" +#text shown for message of the week - @name will be replaced with the name property set above. +motw_text = "Welcome to @name!" +#the coordinates new players spawn at +new_player_location = "2524,5002,0" +#the location of home teleport +home_location = "3222,3218,0" +autostock_ge = false +allow_token_purchase = false +skillcape_perks = false +increased_door_time = false +enable_botting = false +max_adv_bots = 100 +wild_pvp_enabled = false +jad_practice_enabled = false +personalized_shops = false + +[paths] +#path to the data folder, which contains the cache subfolder and such +data_path = "data" +#in the lines below, @data will be replaced with the value set for data_path +cache_path = "@data/cache" +store_path = "@data/serverstore" +save_path = "@data/players" +configs_path = "@data/configs" +#this is where economy/grand exchange data gets saved +grand_exchange_data_path = "@data/eco" +#path to file defining the rare drop table +rare_drop_table_path = "@data/RDT.xml" +#path to file defining c.ele minor drop table +cele_drop_table_path = "@data/CELEDT.xml" +#path to file containing boot-time object changes +object_parser_path = "@data/ObjectParser.xml" +#path logs are written to +logs_path = "@data/logs" +bot_data = "@data/botdata" +eco_data = "@data/eco" \ No newline at end of file