Skip to content

Commit

Permalink
Set gradle's working directory to project root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomm0017 committed Mar 21, 2019
1 parent e48ac36 commit db75dc7
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 39 deletions.
10 changes: 5 additions & 5 deletions dev-settings.example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
debug-examines: true
debug-objects: true
debug-buttons: true
debug-items: true
debug-spells: true
debug-examines: false
debug-objects: false
debug-buttons: false
debug-items: false
debug-spells: false
15 changes: 4 additions & 11 deletions game.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,27 @@ privileges:
# Game services
# You can pick and choose which services you want to run.
services:
- class: gg.rsmod.game.service.GameService

- class: gg.rsmod.game.service.serializer.json.JsonPlayerSerializer
path: "../data/saves/"

- class: gg.rsmod.game.service.xtea.XteaKeyService
path: "../data/xteas/"

- class: gg.rsmod.game.service.game.NpcStatsService
path: "../data/cfg/npc-stats.json"

- class: gg.rsmod.game.service.game.ItemMetadataService
path: "../data/cfg/items.yml"

- class: gg.rsmod.game.service.game.EntityExamineService
path: "../data/cfg/examines"

- class: gg.rsmod.game.service.game.DumpEntityIdService
cache-path: "../data/cache/"
output-path: "../game/plugins/src/main/kotlin/gg/rsmod/plugins/osrs/api/cfg/"
cache-path: "./data/cache/"
output-path: "./game/plugins/src/main/kotlin/gg/rsmod/plugins/osrs/api/cfg/"
dump: false

- class: gg.rsmod.plugins.service.doors.DoorService

- class: gg.rsmod.plugins.service.gates.GateService

- class: gg.rsmod.game.service.rsa.RsaService
path: "../data/rsa/key.pem"
radix: 16

- class: gg.rsmod.game.service.GameService

- class: gg.rsmod.game.service.login.LoginService
19 changes: 13 additions & 6 deletions game/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ apply from: "$rootDir/gradle/kotlin.gradle"
description = 'RSMod Game'
mainClassName = 'gg.rsmod.game.Launcher'

run {
workingDir = rootProject.projectDir
}

dependencies {
compile project(':util')
compile project(':net')
Expand Down Expand Up @@ -43,20 +47,23 @@ sourceSets {
}

applicationDistribution.from("$rootDir/data/") {
into 'bin/data/'

include '**'

exclude 'saves/*'
exclude '*.example.yml'
into 'bin/data/'
exclude 'rsa/*'
}

applicationDistribution.from("$rootDir") {
into 'bin'

include 'plugins/*'

include 'game.example.yml'
into 'bin/'
rename 'game.example.yml', 'game.yml'
}

apply plugin: 'application'

task extractDependencies(type: Copy) {

from(zipTree("build/distributions/game-${project.version}.zip")) {
Expand Down Expand Up @@ -85,7 +92,7 @@ tasks.register("install") {
javaexec {
classpath = sourceSets.main.runtimeClasspath
main = "gg.rsmod.game.service.rsa.RsaService"
args = [ "16", "2048", "../data/rsa/key.pem" ] // radix, bitcount, rsa pem file
args = [ "16", "2048", "./data/rsa/key.pem" ] // radix, bitcount, rsa pem file
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class DoorService : Service() {
val doubleDoors = ObjectArrayList<DoubleDoorSet>()

override fun init(server: Server, world: World, serviceProperties: ServerProperties) {
val singleDoorFile = Paths.get(serviceProperties.get("single-doors") ?: "../data/cfg/doors/single-doors.json")
val doubleDoorsFile = Paths.get(serviceProperties.get("double-doors") ?: "../data/cfg/doors/double-doors.json")
val singleDoorFile = Paths.get(serviceProperties.get("single-doors") ?: "./data/cfg/doors/single-doors.json")
val doubleDoorsFile = Paths.get(serviceProperties.get("double-doors") ?: "./data/cfg/doors/double-doors.json")

Files.newBufferedReader(singleDoorFile).use { reader ->
val doors = Gson().fromJson<ObjectArrayList<Door>>(reader, object: TypeToken<ObjectArrayList<Door>>() {}.type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GateService : Service() {
val gates = ObjectArrayList<GateSet>()

override fun init(server: Server, world: World, serviceProperties: ServerProperties) {
val file = Paths.get(serviceProperties.get("gates") ?: "../data/cfg/gates/gates.json")
val file = Paths.get(serviceProperties.get("gates") ?: "./data/cfg/gates/gates.json")
Files.newBufferedReader(file).use { reader ->
val gates = Gson().fromJson<ObjectArrayList<GateSet>>(reader, object: TypeToken<ObjectArrayList<GateSet>>() {}.type)
this.gates.addAll(gates)
Expand Down
12 changes: 6 additions & 6 deletions game/src/main/kotlin/gg/rsmod/game/Launcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ object Launcher {
@JvmStatic
fun main(args: Array<String>) {
val server = Server()
server.startServer(apiProps = Paths.get("../data/api.yml"))
server.startServer(apiProps = Paths.get("./data/api.yml"))
server.startGame(
filestore = Paths.get("../data", "cache"),
gameProps = Paths.get("../game.yml"),
packets = Paths.get("../data", "packets.yml"),
blocks = Paths.get("../data", "blocks.yml"),
devProps = Paths.get("../dev-settings.yml"),
filestore = Paths.get("./data", "cache"),
gameProps = Paths.get("./game.yml"),
packets = Paths.get("./data", "packets.yml"),
blocks = Paths.get("./data", "blocks.yml"),
devProps = Paths.get("./dev-settings.yml"),
args = args)
}
}
4 changes: 2 additions & 2 deletions game/src/main/kotlin/gg/rsmod/game/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Server {
/**
* Load the game property file.
*/
val initialLaunch = Files.deleteIfExists(Paths.get("../first-launch"))
val initialLaunch = Files.deleteIfExists(Paths.get("./first-launch"))
val gameProperties = ServerProperties()
val devProperties = ServerProperties()
gameProperties.loadYaml(gameProps.toFile())
Expand Down Expand Up @@ -156,7 +156,7 @@ class Server {
*/
individualStopwatch.reset().start()
world.plugins.init(
jarPluginsDirectory = gameProperties.getOrDefault("plugin-packed-path", "../plugins"),
jarPluginsDirectory = gameProperties.getOrDefault("plugin-packed-path", "./plugins"),
analyzeMode = args.any { it == "-analyze" })
logger.info("Loaded {} plugins in {}ms.", DecimalFormat().format(world.plugins.getPluginCount()), individualStopwatch.elapsed(TimeUnit.MILLISECONDS))

Expand Down
20 changes: 16 additions & 4 deletions game/src/main/kotlin/gg/rsmod/game/service/rsa/RsaService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.security.Security
import java.security.interfaces.RSAPrivateKey
import java.security.interfaces.RSAPublicKey
import java.security.spec.PKCS8EncodedKeySpec
import java.util.*

/**
* @author Tom <[email protected]>
Expand Down Expand Up @@ -56,9 +57,20 @@ class RsaService : Service() {
radix = serviceProperties.getOrDefault("radix", 16)

if (!Files.exists(keyPath)) {
logger.info("Generating RSA key pair...")
createPair(bitCount = serviceProperties.getOrDefault("bit-count", 2048))
throw RuntimeException("Private RSA key was not found! Please follow the instructions on console.")
val scanner = Scanner(System.`in`)
println("Private RSA key was not found in path: $keyPath")
println("Would you like to create one? (y/n)")

val create = scanner.nextLine() in arrayOf("yes", "y", "true")
if (create) {
logger.info("Generating RSA key pair...")
createPair(bitCount = serviceProperties.getOrDefault("bit-count", 2048))
println("Please follow the instructions on console and restart the client & server.")
scanner.nextLine()
System.exit(0)
} else {
throw RuntimeException("Private RSA key was not found! Please follow the instructions on console.")
}
}

try {
Expand Down Expand Up @@ -102,7 +114,7 @@ class RsaService : Service() {
val publicKey = keyPair.public as RSAPublicKey

println("")
println("Place these keys in the client:")
println("Place these keys in the client (find BigInteger(\"10001\") in client code):")
println("--------------------")
println("public key: " + publicKey.publicExponent.toString(radix))
println("modulus: " + publicKey.modulus.toString(radix))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class JsonPlayerSerializer : PlayerSerializerService() {
private lateinit var path: Path

override fun initSerializer(server: Server, world: World, serviceProperties: ServerProperties) {
path = Paths.get(serviceProperties.get<String>("path")!!)
path = Paths.get(serviceProperties.getOrDefault("path", "./data/saves/"))
if (!Files.exists(path)) {
Files.createDirectory(path)
logger.info("Path does not exist: $path, creating directory...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class XteaKeyService : Service() {
private val keys = hashMapOf<Int, IntArray>()

override fun init(server: Server, world: World, serviceProperties: ServerProperties) {
val path = Paths.get(serviceProperties.get<String>("path")!!)
val path = Paths.get(serviceProperties.getOrDefault("path", "./data/xteas/"))
if (!Files.exists(path)) {
throw FileNotFoundException("Path does not exist. $path")
}
Expand Down

0 comments on commit db75dc7

Please sign in to comment.