aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-06 20:52:16 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-06 20:52:16 +0200
commit79fbb4e6f69df86e885464ddb84b163b90872eee (patch)
treee6d0ede3289a41b838d172a2ba394596ead2268b
parent12f7f03344decf77d96997bf2d4898c6b978bb3c (diff)
downloadLocalTransactionLedger-79fbb4e6f69df86e885464ddb84b163b90872eee.tar.gz
LocalTransactionLedger-79fbb4e6f69df86e885464ddb84b163b90872eee.tar.bz2
LocalTransactionLedger-79fbb4e6f69df86e885464ddb84b163b90872eee.zip
Add config gui
-rw-r--r--build.gradle.kts171
-rw-r--r--src/main/kotlin/moe/nea/ledger/DungeonChestDetection.kt (renamed from src/main/java/moe/nea/ledger/DungeonChestDetection.kt)0
-rw-r--r--src/main/kotlin/moe/nea/ledger/Ledger.kt190
-rw-r--r--src/main/kotlin/moe/nea/ledger/LedgerLogger.kt4
-rw-r--r--src/main/kotlin/moe/nea/ledger/config/LedgerConfig.kt27
-rw-r--r--src/main/kotlin/moe/nea/ledger/config/Synchronization.kt11
6 files changed, 236 insertions, 167 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 98f7efa..c29d146 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,16 +1,14 @@
import org.apache.commons.lang3.SystemUtils
plugins {
- idea
- java
- id("gg.essential.loom") version "0.10.0.+"
- id("dev.architectury.architectury-pack200") version "0.1.3"
- id("com.github.johnrengelman.shadow") version "8.1.1"
- kotlin("jvm") version "1.8.21"
+ idea
+ java
+ id("gg.essential.loom") version "0.10.0.+"
+ id("dev.architectury.architectury-pack200") version "0.1.3"
+ id("com.github.johnrengelman.shadow") version "8.1.1"
+ kotlin("jvm") version "1.8.21"
}
-//Constants:
-
val baseGroup: String by project
val mcVersion: String by project
val version: String by project
@@ -19,136 +17,123 @@ val modid: String by project
// Toolchains:
java {
- toolchain.languageVersion.set(JavaLanguageVersion.of(8))
+ toolchain.languageVersion.set(JavaLanguageVersion.of(8))
}
// Minecraft configuration:
loom {
- log4jConfigs.from(file("log4j2.xml"))
- launchConfigs {
- "client" {
- // If you don't want mixins, remove these lines
- property("mixin.debug", "true")
- property("asmhelper.verbose", "true")
- arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
- }
- }
- runConfigs {
- "client" {
- if (SystemUtils.IS_OS_MAC_OSX) {
- // This argument causes a crash on macOS
- vmArgs.remove("-XstartOnFirstThread")
- }
- }
- remove(getByName("server"))
- }
- forge {
- pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
- // If you don't want mixins, remove this lines
- mixinConfig("mixins.$modid.json")
- }
- // If you don't want mixins, remove these lines
- mixin {
- defaultRefmapName.set("mixins.$modid.refmap.json")
- }
+ log4jConfigs.from(file("log4j2.xml"))
+ launchConfigs {
+ "client" {
+ property("mixin.debug", "true")
+ arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
+ arg("--tweakClass", "io.github.notenoughupdates.moulconfig.tweaker.DevelopmentResourceTweaker")
+ }
+ }
+ runConfigs {
+ "client" {
+ if (SystemUtils.IS_OS_MAC_OSX) {
+ // This argument causes a crash on macOS
+ vmArgs.remove("-XstartOnFirstThread")
+ }
+ }
+ remove(getByName("server"))
+ }
+ forge {
+ pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
+ mixinConfig("mixins.$modid.json")
+ }
+ mixin {
+ defaultRefmapName.set("mixins.$modid.refmap.json")
+ }
}
tasks.compileJava {
- dependsOn(tasks.processResources)
+ dependsOn(tasks.processResources)
}
sourceSets.main {
- output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory })
- java.srcDir(layout.projectDirectory.dir("src/main/kotlin"))
- kotlin.destinationDirectory.set(java.destinationDirectory)
+ output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory })
+ java.srcDir(layout.projectDirectory.dir("src/main/kotlin"))
+ kotlin.destinationDirectory.set(java.destinationDirectory)
}
-// Dependencies:
-
repositories {
- mavenCentral()
- maven("https://repo.spongepowered.org/maven/")
- // If you don't want to log in with your real minecraft account, remove this line
- maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
+ mavenCentral()
+ maven("https://repo.spongepowered.org/maven/")
+ maven("https://maven.notenoughupdates.org/releases")
+ maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
}
val shadowImpl: Configuration by configurations.creating {
- configurations.implementation.get().extendsFrom(this)
+ configurations.implementation.get().extendsFrom(this)
}
dependencies {
- minecraft("com.mojang:minecraft:1.8.9")
- mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
- forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
-
- shadowImpl(kotlin("stdlib-jdk8"))
+ minecraft("com.mojang:minecraft:1.8.9")
+ mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
+ forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
- // If you don't want mixins, remove these lines
- shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
- isTransitive = false
- }
- annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
+ shadowImpl(kotlin("stdlib-jdk8"))
- // If you don't want to log in with your real minecraft account, remove this line
- runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.2")
+ shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
+ isTransitive = false
+ }
+ annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
+ shadowImpl("org.xerial:sqlite-jdbc:3.45.3.0")
+ shadowImpl("org.notenoughupdates.moulconfig:legacy:3.0.0-beta.9")
+ runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.2")
}
// Tasks:
tasks.withType(JavaCompile::class) {
- options.encoding = "UTF-8"
+ options.encoding = "UTF-8"
}
tasks.withType(Jar::class) {
- archiveBaseName.set(modid)
- manifest.attributes.run {
- this["FMLCorePluginContainsFMLMod"] = "true"
- this["ForceLoadAsMod"] = "true"
-
- // If you don't want mixins, remove these lines
- this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
- this["MixinConfigs"] = "mixins.$modid.json"
- }
+ archiveBaseName.set(modid)
+ manifest.attributes.run {
+ this["FMLCorePluginContainsFMLMod"] = "true"
+ this["ForceLoadAsMod"] = "true"
+
+ // If you don't want mixins, remove these lines
+ this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
+ this["MixinConfigs"] = "mixins.$modid.json"
+ }
}
tasks.processResources {
- inputs.property("version", project.version)
- inputs.property("mcversion", mcVersion)
- inputs.property("modid", modid)
- inputs.property("basePackage", baseGroup)
+ inputs.property("version", project.version)
+ inputs.property("mcversion", mcVersion)
+ inputs.property("modid", modid)
+ inputs.property("basePackage", baseGroup)
- filesMatching(listOf("mcmod.info", "mixins.$modid.json")) {
- expand(inputs.properties)
- }
+ filesMatching(listOf("mcmod.info", "mixins.$modid.json")) {
+ expand(inputs.properties)
+ }
- rename("(.+_at.cfg)", "META-INF/$1")
+ rename("(.+_at.cfg)", "META-INF/$1")
}
val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
- archiveClassifier.set("")
- from(tasks.shadowJar)
- input.set(tasks.shadowJar.get().archiveFile)
+ archiveClassifier.set("")
+ from(tasks.shadowJar)
+ input.set(tasks.shadowJar.get().archiveFile)
}
tasks.jar {
- archiveClassifier.set("without-deps")
- destinationDirectory.set(layout.buildDirectory.dir("badjars"))
+ archiveClassifier.set("without-deps")
+ destinationDirectory.set(layout.buildDirectory.dir("badjars"))
}
tasks.shadowJar {
- destinationDirectory.set(layout.buildDirectory.dir("badjars"))
- archiveClassifier.set("all-dev")
- configurations = listOf(shadowImpl)
- doLast {
- configurations.forEach {
- println("Copying jars into mod: ${it.files}")
- }
- }
-
- // If you want to include other dependencies and shadow them, you can relocate them in here
- fun relocate(name: String) = relocate(name, "$baseGroup.deps.$name")
+ destinationDirectory.set(layout.buildDirectory.dir("badjars"))
+ archiveClassifier.set("all-dev")
+ configurations = listOf(shadowImpl)
+ mergeServiceFiles()
}
tasks.assemble.get().dependsOn(tasks.remapJar)
diff --git a/src/main/java/moe/nea/ledger/DungeonChestDetection.kt b/src/main/kotlin/moe/nea/ledger/DungeonChestDetection.kt
index 2418354..2418354 100644
--- a/src/main/java/moe/nea/ledger/DungeonChestDetection.kt
+++ b/src/main/kotlin/moe/nea/ledger/DungeonChestDetection.kt
diff --git a/src/main/kotlin/moe/nea/ledger/Ledger.kt b/src/main/kotlin/moe/nea/ledger/Ledger.kt
index 3745f36..f27eba1 100644
--- a/src/main/kotlin/moe/nea/ledger/Ledger.kt
+++ b/src/main/kotlin/moe/nea/ledger/Ledger.kt
@@ -1,7 +1,11 @@
package moe.nea.ledger
+import io.github.notenoughupdates.moulconfig.common.IMinecraft
+import io.github.notenoughupdates.moulconfig.managed.ManagedConfig
+import moe.nea.ledger.config.LedgerConfig
import net.minecraft.client.Minecraft
import net.minecraft.command.CommandBase
+import net.minecraft.command.ICommandSender
import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.common.MinecraftForge
@@ -13,81 +17,119 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import org.apache.logging.log4j.LogManager
+import java.io.File
+import java.util.concurrent.ConcurrentLinkedQueue
@Mod(modid = "ledger", useMetadata = true)
class Ledger {
- /*
- You have withdrawn 1M coins! You now have 518M coins in your account!
- You have deposited 519M coins! You now have 519M coins in your account!
-
- // ORDERS:
-
- [Bazaar] Buy Order Setup! 160x Wheat for 720.0 coins.
- [Bazaar] Claimed 160x Wheat worth 720.0 coins bought for 4.5 each!
-
- [Bazaar] Sell Offer Setup! 160x Wheat for 933.4 coins.
- [Bazaar] Claimed 34,236,799 coins from selling 176x Hyper Catalyst at 196,741 each!
-
- // INSTABUY:
-
- [Bazaar] Bought 64x Wheat for 377.6 coins!
- [Bazaar] Sold 64x Wheat for 268.8 coins!
-
- // AUCTION HOUSE:
-
- You collected 8,712,000 coins from selling Ultimate Carrot Candy Upgrade to [VIP] kodokush in an auction!
- You purchased 2x Walnut for 69 coins!
- You purchased ◆ Ice Rune I for 4,000 coins!
-
- TODO: TRADING, FORGE, COOKIE_EATEN, NPC_SELL, NPC_BUY
- */
- companion object {
- val logger = LogManager.getLogger("MoneyLedger")
- }
-
- @Mod.EventHandler
- fun init(event: FMLInitializationEvent) {
- logger.info("Initializing ledger")
- val ledger = LedgerLogger()
- val ids = ItemIdProvider()
- listOf(
- this,
- ids,
- ledger,
- BankDetection(ledger),
- BazaarDetection(ledger, ids),
- DungeonChestDetection(ledger),
- BazaarOrderDetection(ledger, ids),
- AuctionHouseDetection(ledger, ids),
- BitsDetection(ledger),
- BitsShop(ledger),
- ).forEach(MinecraftForge.EVENT_BUS::register)
- }
-
- var lastJoin = -1L
-
- @SubscribeEvent
- fun worldSwitchEvent(event: EntityJoinWorldEvent) {
- if (event.entity == Minecraft.getMinecraft().thePlayer) {
- lastJoin = System.currentTimeMillis()
- }
- }
-
- @SubscribeEvent
- fun tickEvent(event: ClientTickEvent) {
- if (event.phase == TickEvent.Phase.END
- && lastJoin > 0
- && System.currentTimeMillis() - lastJoin > 10_000
- && Minecraft.getMinecraft().thePlayer != null
- ) {
- lastJoin = -1
- MinecraftForge.EVENT_BUS.post(LateWorldLoadEvent())
- }
- }
-
- @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST)
- fun onChat(event: ClientChatReceivedEvent) {
- if (event.type != 2.toByte())
- MinecraftForge.EVENT_BUS.post(ChatReceived(event))
- }
+ /*
+ You have withdrawn 1M coins! You now have 518M coins in your account!
+ You have deposited 519M coins! You now have 519M coins in your account!
+
+ // ORDERS:
+
+ [Bazaar] Buy Order Setup! 160x Wheat for 720.0 coins.
+ [Bazaar] Claimed 160x Wheat worth 720.0 coins bought for 4.5 each!
+
+ [Bazaar] Sell Offer Setup! 160x Wheat for 933.4 coins.
+ [Bazaar] Claimed 34,236,799 coins from selling 176x Hyper Catalyst at 196,741 each!
+
+ // INSTABUY:
+
+ [Bazaar] Bought 64x Wheat for 377.6 coins!
+ [Bazaar] Sold 64x Wheat for 268.8 coins!
+
+ // AUCTION HOUSE:
+
+ You collected 8,712,000 coins from selling Ultimate Carrot Candy Upgrade to [VIP] kodokush in an auction!
+ You purchased 2x Walnut for 69 coins!
+ You purchased ◆ Ice Rune I for 4,000 coins!
+
+ TODO: TRADING, FORGE, COOKIE_EATEN, NPC_SELL, NPC_BUY
+ */
+ companion object {
+ val logger = LogManager.getLogger("MoneyLedger")
+ val managedConfig = ManagedConfig.create(File("config/money-ledger/config.json"), LedgerConfig::class.java) {
+ checkExpose = false
+ }
+ private val tickQueue = ConcurrentLinkedQueue<Runnable>()
+ fun runLater(runnable: Runnable) {
+ tickQueue.add(runnable)
+ }
+ }
+
+ @Mod.EventHandler
+ fun init(event: FMLInitializationEvent) {
+ logger.info("Initializing ledger")
+ ClientCommandHandler.instance.registerCommand(object : CommandBase() {
+ override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean {
+ return true
+ }
+
+ override fun getCommandName(): String {
+ return "ledger"
+ }
+
+ override fun getCommandUsage(sender: ICommandSender?): String {
+ return ""
+ }
+
+ override fun processCommand(sender: ICommandSender?, args: Array<out String>) {
+ val editor = managedConfig.getEditor()
+ editor.search(args.joinToString(" "))
+ runLater {
+ IMinecraft.instance.openWrappedScreen(editor)
+ }
+ }
+
+ override fun getCommandAliases(): List<String> {
+ return listOf("moneyledger")
+ }
+ })
+ val ledger = LedgerLogger()
+ val ids = ItemIdProvider()
+ listOf(
+ this,
+ ids,
+ ledger,
+ BankDetection(ledger),
+ BazaarDetection(ledger, ids),
+ DungeonChestDetection(ledger),
+ BazaarOrderDetection(ledger, ids),
+ AuctionHouseDetection(ledger, ids),
+ BitsDetection(ledger),
+ BitsShop(ledger),
+ ).forEach(MinecraftForge.EVENT_BUS::register)
+ }
+
+ var lastJoin = -1L
+
+ @SubscribeEvent
+ fun worldSwitchEvent(event: EntityJoinWorldEvent) {
+ if (event.entity == Minecraft.getMinecraft().thePlayer) {
+ lastJoin = System.currentTimeMillis()
+ }
+ }
+
+ @SubscribeEvent
+ fun tickEvent(event: ClientTickEvent) {
+ if (event.phase == TickEvent.Phase.END
+ && lastJoin > 0
+ && System.currentTimeMillis() - lastJoin > 10_000
+ && Minecraft.getMinecraft().thePlayer != null
+ ) {
+ lastJoin = -1
+ MinecraftForge.EVENT_BUS.post(LateWorldLoadEvent())
+ }
+ while (true) {
+ val queued = tickQueue.poll() ?: break
+ queued.run()
+ }
+ }
+
+ @SubscribeEvent(receiveCanceled = true, priority = EventPriority.HIGHEST)
+ fun onChat(event: ClientChatReceivedEvent) {
+ if (event.type != 2.toByte())
+ MinecraftForge.EVENT_BUS.post(ChatReceived(event))
+ }
}
diff --git a/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt b/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
index 4d21e5d..c32caf4 100644
--- a/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
+++ b/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
@@ -11,6 +11,8 @@ import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import java.io.File
+import java.sql.Connection
+import java.sql.DriverManager
import java.text.SimpleDateFormat
import java.time.Instant
import java.util.*
@@ -20,6 +22,8 @@ class LedgerLogger {
Minecraft.getMinecraft().ingameGUI?.chatGUI?.printChatMessage(ChatComponentText(text))
}
+ val connection = DriverManager.getConnection("jdbc:sqlite:money-ledger/database.db")
+
val profileIdPattern =
"Profile ID: (?<profile>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})".toPattern()
diff --git a/src/main/kotlin/moe/nea/ledger/config/LedgerConfig.kt b/src/main/kotlin/moe/nea/ledger/config/LedgerConfig.kt
new file mode 100644
index 0000000..7ba5abf
--- /dev/null
+++ b/src/main/kotlin/moe/nea/ledger/config/LedgerConfig.kt
@@ -0,0 +1,27 @@
+package moe.nea.ledger.config
+
+import io.github.notenoughupdates.moulconfig.Config
+import io.github.notenoughupdates.moulconfig.DescriptionRendereringBehaviour
+import io.github.notenoughupdates.moulconfig.annotations.Category
+import io.github.notenoughupdates.moulconfig.processor.ProcessedOption
+import moe.nea.ledger.Ledger
+
+class LedgerConfig : Config() {
+ override fun getTitle(): String {
+ return "§6Ledger §7- §6Hypixel SkyBlock data logger §7by §anea89o"
+ }
+
+ override fun saveNow() {
+ super.saveNow()
+ Ledger.managedConfig.saveToFile()
+ }
+
+ override fun getDescriptionBehaviour(option: ProcessedOption?): DescriptionRendereringBehaviour {
+ return DescriptionRendereringBehaviour.EXPAND_PANEL
+ }
+
+ @Category(name = "Synchronization", desc = "")
+ @JvmField
+ val synchronization = Synchronization()
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/moe/nea/ledger/config/Synchronization.kt b/src/main/kotlin/moe/nea/ledger/config/Synchronization.kt
new file mode 100644
index 0000000..e8d5906
--- /dev/null
+++ b/src/main/kotlin/moe/nea/ledger/config/Synchronization.kt
@@ -0,0 +1,11 @@
+package moe.nea.ledger.config
+
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption
+
+class Synchronization {
+ @ConfigOption(name = "Test Option", desc = "Test Description")
+ @ConfigEditorBoolean
+ @JvmField
+ var testOption = false
+} \ No newline at end of file