@@ -6,6 +6,7 @@ import com.lambda.client.module.Category
6
6
import com.lambda.client.module.Module
7
7
import com.lambda.client.module.modules.movement.AutoWalk
8
8
import com.lambda.client.util.BaritoneUtils
9
+ import com.lambda.client.util.FolderUtils
9
10
import com.lambda.client.util.TickTimer
10
11
import com.lambda.client.util.TimeUnit
11
12
import com.lambda.client.util.math.CoordinateConverter.asString
@@ -25,6 +26,9 @@ import net.minecraft.tileentity.*
25
26
import net.minecraft.util.math.BlockPos
26
27
import net.minecraft.util.math.ChunkPos
27
28
import net.minecraftforge.fml.common.gameevent.TickEvent
29
+ import org.json.JSONArray
30
+ import org.json.JSONObject
31
+ import java.io.File
28
32
import java.text.SimpleDateFormat
29
33
import java.util.*
30
34
import kotlin.math.roundToInt
@@ -36,6 +40,7 @@ object StashLogger : Module(
36
40
) {
37
41
private val saveToWaypoints by setting(" Save To Waypoints" , true )
38
42
private val logToChat by setting(" Log To Chat" , true )
43
+ private val logToFile by setting(" Log To File" , true , description = " Logs found stashes in \" .minecraft/lambda/stash_logger.json\" " )
39
44
private val playSound by setting(" Play Sound" , true )
40
45
private val logChests by setting(" Chests" , true )
41
46
private val chestDensity by setting(" Min Chests" , 5 , 1 .. 20 , 1 , { logChests })
@@ -96,10 +101,32 @@ object StashLogger : Module(
96
101
}
97
102
}
98
103
99
- if (logToChat) {
100
- val positionString = center.asString( )
101
- val timeStr = SimpleDateFormat .getDateTimeInstance().format( Calendar .getInstance().time )
104
+ val positionString = center.asString()
105
+ val timeStr = SimpleDateFormat .getDateTimeInstance().format( Calendar .getInstance().time )
106
+ if (logToChat )
102
107
MessageSendHelper .sendChatMessage(" $chatName Found $string at ($positionString ) [$timeStr ]" )
108
+ if (logToFile) {
109
+ val file = File (FolderUtils .lambdaFolder + " stash_logger.json" )
110
+ val json = when {
111
+ file.exists() -> {
112
+ val jsonString = file.readText(Charsets .UTF_8 )
113
+ JSONObject (jsonString)
114
+ }
115
+ else -> JSONObject ()
116
+ }
117
+ val stashesJson = when {
118
+ json.has(" stashes" ) -> json.getJSONArray(" stashes" )
119
+ else -> JSONArray ()
120
+ }
121
+
122
+ val stashJson = JSONObject ()
123
+ stashJson.put(" date" , timeStr)
124
+ stashJson.put(" location" , positionString)
125
+ stashJson.put(" info" , string)
126
+
127
+ stashesJson.put(stashJson)
128
+ json.put(" stashes" , stashesJson)
129
+ file.writeText(json.toString(4 ))
103
130
}
104
131
105
132
found = true
0 commit comments