-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a87feca
commit 4e0aab1
Showing
21 changed files
with
204 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
id ("com.gtnewhorizons.gtnhconvention") | ||
id ("org.jetbrains.kotlin.jvm") | ||
} | ||
|
||
tasks.register("copyJar") { | ||
group = "fardragi" | ||
dependsOn("build") | ||
doLast() { | ||
val target = File("C:\\Users\\mrvul\\Documents\\Minecraft\\FarDragiServer\\mods\\dragiutils.jar") | ||
val jar = File("./build/libs").walk().find { it.name.endsWith("dirty.jar") } | ||
|
||
jar?.copyTo(target, overwrite = true) | ||
} | ||
} | ||
|
||
tasks.register<Exec>("startServer") { | ||
group = "fardragi" | ||
standardInput = System.`in` | ||
dependsOn("copyJar") | ||
workingDir("C:\\Users\\mrvul\\Documents\\Minecraft\\FarDragiServer") | ||
commandLine("cmd", "/c", "startserver-java9.bat") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Add any additional repositories for your dependencies here. | ||
|
||
repositories { | ||
|
||
mavenCentral() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pluginManagement { | ||
repositories { | ||
maven("https://nexus.gtnewhorizons.com/repository/public/") { | ||
// RetroFuturaGradle | ||
name = "GTNH Maven" | ||
mavenContent { | ||
includeGroup("com.gtnewhorizons") | ||
includeGroupByRegex("com\\.gtnewhorizons\\..+") | ||
} | ||
} | ||
gradlePluginPortal() | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
plugins { | ||
id("org.jetbrains.kotlin.jvm") version "2.0.0" | ||
} | ||
} | ||
|
||
plugins { | ||
id("com.gtnewhorizons.gtnhsettingsconvention") version "1.0.25" | ||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/fardragi/dragiutils/client/ClientProxy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.fardragi.dragiutils.client | ||
|
||
import com.fardragi.dragiutils.server.ServerProxy | ||
|
||
class ClientProxy : ServerProxy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.fardragi.dragiutils.config | ||
|
||
import com.fardragi.dragiutils.utils.getWorkingDir | ||
import java.io.File | ||
import net.minecraftforge.common.config.Configuration | ||
|
||
object Config { | ||
var database: DatabaseConfig? = null | ||
|
||
fun synchronizeConfiguration() { | ||
val configuration = Configuration(File(getWorkingDir(), "config.cfg")) | ||
|
||
database = DatabaseConfig(configuration) | ||
|
||
if (configuration.hasChanged()) { | ||
configuration.save() | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/fardragi/dragiutils/config/DatabaseConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.fardragi.dragiutils.config | ||
|
||
import net.minecraftforge.common.config.Configuration | ||
|
||
private const val CATEGORY = "Database" | ||
|
||
class DatabaseConfig(configuration: Configuration) { | ||
val host: String = configuration.getString("host", CATEGORY, "localhost", "Database host") | ||
val port: Int = configuration.getInt("port", CATEGORY, 3306, 0, 65535, "Database port") | ||
val database: String = | ||
configuration.getString("database", CATEGORY, "dragi_utils", "Database name") | ||
val password: String = configuration.getString("password", CATEGORY, "root", "Database password") | ||
val user: String = configuration.getString("user", CATEGORY, "root", "Database user") | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/com/fardragi/dragiutils/database/DatabaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.fardragi.dragiutils.database | ||
|
||
import com.fardragi.dragiutils.config.DatabaseConfig | ||
import com.fardragi.dragiutils.database.models.User | ||
import cpw.mods.fml.common.FMLLog | ||
import org.jetbrains.exposed.sql.Database | ||
import org.jetbrains.exposed.sql.SchemaUtils | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
|
||
class DatabaseModule(databaseConfig: DatabaseConfig) { | ||
init { | ||
val connectionString = | ||
"jdbc:mariadb://${databaseConfig.host}:${databaseConfig.port}/${databaseConfig.database}" | ||
|
||
FMLLog.info("GAY:$connectionString") | ||
|
||
try { | ||
val db = | ||
Database.connect( | ||
connectionString, | ||
driver = "org.mariadb.jdbc.Driver", | ||
user = databaseConfig.user, | ||
password = databaseConfig.password, | ||
) | ||
} catch (ex: Exception) { | ||
FMLLog.severe(ex.message) | ||
} | ||
|
||
transaction { SchemaUtils.createMissingTablesAndColumns(User) } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/fardragi/dragiutils/database/models/User.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fardragi.dragiutils.database.models | ||
|
||
import org.jetbrains.exposed.dao.id.IntIdTable | ||
|
||
object User : IntIdTable() { | ||
val name = varchar("name", 255).uniqueIndex() | ||
val passwordHash = varchar("passwordHash", 255) | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/com/fardragi/dragiutils/exceptions/DragiUtilsException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.fardragi.dragiutils.exceptions | ||
|
||
class DragiUtilsException(msg: String) : RuntimeException(msg) {} |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/fardragi/dragiutils/server/ServerProxy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.fardragi.dragiutils.server | ||
|
||
import com.fardragi.dragiutils.DragiUtils | ||
import com.fardragi.dragiutils.Tags | ||
import com.fardragi.dragiutils.config.Config | ||
import com.fardragi.dragiutils.config.Config.synchronizeConfiguration | ||
import com.fardragi.dragiutils.database.DatabaseModule | ||
import cpw.mods.fml.common.event.FMLInitializationEvent | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent | ||
import cpw.mods.fml.common.event.FMLServerStartingEvent | ||
|
||
open class ServerProxy { | ||
fun preInit(event: FMLPreInitializationEvent) { | ||
synchronizeConfiguration() | ||
|
||
DragiUtils.LOG.info(Config.database?.host) | ||
DragiUtils.LOG.info("I am MyMod at version " + Tags.VERSION) | ||
} | ||
|
||
fun init(event: FMLInitializationEvent?) { | ||
Config.database?.let { DatabaseModule(it) } | ||
} | ||
|
||
fun postInit(event: FMLPostInitializationEvent?) {} | ||
|
||
fun serverStarting(event: FMLServerStartingEvent?) {} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/com/fardragi/dragiutils/utils/Minecraft.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.fardragi.dragiutils.utils | ||
|
||
import cpw.mods.fml.common.FMLCommonHandler | ||
import java.io.File | ||
import net.minecraft.client.Minecraft | ||
|
||
fun getWorkingDir(): File { | ||
val baseDir = | ||
if (FMLCommonHandler.instance().side.isClient) Minecraft.getMinecraft().mcDataDir | ||
else File(".") | ||
|
||
return File(baseDir, "/DragiUtils") | ||
} |
Oops, something went wrong.