Skip to content

Commit a3de295

Browse files
committed
Cleanup
1 parent 43a81f9 commit a3de295

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

common/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object ReplayCommand : LambdaCommand {
2525
// 7. Set replay speed
2626
required(string("replay name")) { replayName ->
2727
suggests { _, builder ->
28-
FolderRegister.replays.listFiles()?.map {
28+
FolderRegister.replay.listFiles()?.map {
2929
it.nameWithoutExtension
3030
}?.forEach {
3131
builder.suggest(it)
@@ -34,7 +34,7 @@ object ReplayCommand : LambdaCommand {
3434
}
3535

3636
executeWithResult {
37-
val replayFile = FolderRegister.replays.resolve("${this[replayName].value()}.json")
37+
val replayFile = FolderRegister.replay.resolve("${this[replayName].value()}.json")
3838

3939
if (!replayFile.exists()) {
4040
return@executeWithResult CommandResult.failure("Replay file does not exist")

common/src/main/kotlin/com/lambda/module/modules/player/Replay.kt

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import kotlin.time.toDuration
3434

3535
// ToDo:
3636
// - Use a custom binary format to store the data (Protobuf / DB?)
37-
// - Actually store the data in a file
38-
// - Implement a way to save and load the data (Commands?)
3937
// - Record other types of inputs: (Interactions, etc.)
4038
object Replay : Module(
4139
name = "Replay",
@@ -107,6 +105,7 @@ object Replay : Module(
107105
}
108106
State.PLAYING, State.PLAYING_CHECKPOINTS -> {
109107
replay?.let {
108+
it.input.removeFirstOrNull()?.update(event.input)
110109
it.position.removeFirstOrNull()?.let a@{ pos ->
111110
val diff = pos.subtract(player.pos).length()
112111
if (diff < 0.001) return@a
@@ -118,7 +117,6 @@ object Replay : Module(
118117
return@listener
119118
}
120119
}
121-
it.input.removeFirstOrNull()?.update(event.input)
122120
}
123121
}
124122
else -> {}
@@ -131,10 +129,8 @@ object Replay : Module(
131129
recording?.rotation?.add(player.rotation)
132130
}
133131
State.PLAYING, State.PLAYING_CHECKPOINTS -> {
134-
replay?.let {
135-
it.rotation.removeFirstOrNull()?.let { rot ->
136-
event.context = RotationContext(rot, rotationConfig)
137-
}
132+
replay?.rotation?.removeFirstOrNull()?.let { rot ->
133+
event.context = RotationContext(rot, rotationConfig)
138134
}
139135
}
140136
else -> {}
@@ -147,11 +143,9 @@ object Replay : Module(
147143
recording?.sprint?.add(player.isSprinting)
148144
}
149145
State.PLAYING, State.PLAYING_CHECKPOINTS -> {
150-
replay?.let {
151-
it.sprint.removeFirstOrNull()?.let { sprint ->
152-
event.sprint = sprint
153-
player.isSprinting = sprint // ToDo: Find out why
154-
}
146+
replay?.sprint?.removeFirstOrNull()?.let { sprint ->
147+
event.sprint = sprint
148+
player.isSprinting = sprint
155149
}
156150
}
157151
else -> {}
@@ -255,8 +249,8 @@ object Replay : Module(
255249

256250
checkpoint = recording?.duplicate()
257251
lambdaScope.launch(Dispatchers.IO) {
258-
FolderRegister.replays.mkdirs()
259-
FolderRegister.replays.resolve("checkpoint-${
252+
FolderRegister.replay.mkdirs()
253+
FolderRegister.replay.resolve("checkpoint-${
260254
mc.currentServerEntry?.address?.replace(":", "_")
261255
}-${
262256
world.dimensionKey?.value?.path?.replace("/", "_")
@@ -361,21 +355,13 @@ object Replay : Module(
361355
}
362356

363357
data class InputAction(
364-
@SerializedName("s")
365358
val movementSideways: Float,
366-
@SerializedName("f")
367359
val movementForward: Float,
368-
@SerializedName("pf")
369360
val pressingForward: Boolean,
370-
@SerializedName("pb")
371361
val pressingBack: Boolean,
372-
@SerializedName("pl")
373362
val pressingLeft: Boolean,
374-
@SerializedName("pr")
375363
val pressingRight: Boolean,
376-
@SerializedName("j")
377364
val jumping: Boolean,
378-
@SerializedName("sn")
379365
val sneaking: Boolean
380366
) {
381367
fun update(input: Input) {

common/src/main/kotlin/com/lambda/util/FolderRegister.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ object FolderRegister {
1818
val lambda: File = File(minecraft, "lambda")
1919
val config: File = File(lambda, "config")
2020
val packetLogs: File = File(lambda, "packet-log")
21-
val replays: File = File(lambda, "replays")
21+
val replay: File = File(lambda, "replay")
2222
}

0 commit comments

Comments
 (0)