Skip to content

Commit 611c929

Browse files
committed
Merge remote-tracking branch 'origin/1.20.2' into 1.20.1
2 parents 53e5ed2 + 92c26c9 commit 611c929

File tree

5 files changed

+46
-15
lines changed

5 files changed

+46
-15
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ After you boot the server a new file will be generated in the path
180180
| `"pause_unloaded_chunks"` | <p> If an area of chunks is being recorded and the area is unloaded and this is set to `true` then the replay will pause the recording until the chunks are loaded again. </p> <p> If set to false the chunks will be recorded as if they were loaded. </p> |
181181
| `"pause_notify_players"` | <p> If `pause_unloaded_chunks` is enabled and this is enabled then when the recording for the chunk area is paused or resumed all online players will be notified. </p> |
182182
| `"restart_after_max_file_size"` | <p> If a max file size is set and this limit is reached then the replay recording will automatically restart creating a new replay file. </p> |
183+
| `"include_compressed_in_status"` | <p> Includes the compressed file size of the replays when you do `/replay status`, for long replays this may cause the status message to take a while to be displayed, so you can disable it. </p> |
183184
| `"fix_carpet_bot_view_distance"` | <p> If you are recording carpet bots you want to enable this as it sets the view distance to the server view distance. Otherwise it will only record a distance of 2 chunks around the bot. |
184185
| `"ignore_sound_packets"` | <p> If you are recording a large area for a timelapse it's unlikely you'll want to record any sounds, these can eat up significant storage space. </p> |
185186
| `"ignore_light_packets"` | <p> Light is calculated on the client as well as on the server so light packets are mostly redundant. </p> |

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ permissions_version=0.3-SNAPSHOT
1515
fabric_version=0.91.0+1.20.1
1616
carpet_version=1.4.112
1717

18-
mod_version=1.0.3
18+
mod_version=1.0.4
1919

2020
org.gradle.jvmargs=-Xmx4000m

src/main/kotlin/me/senseiwells/replay/commands/ReplayCommand.kt

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import net.minecraft.server.level.ServerLevel
2525
import net.minecraft.world.level.ChunkPos
2626
import org.apache.commons.lang3.builder.StandardToStringStyle
2727
import org.apache.commons.lang3.builder.ToStringBuilder
28+
import java.util.concurrent.CompletableFuture
2829

2930
object ReplayCommand {
3031
@JvmStatic
@@ -300,22 +301,44 @@ object ReplayCommand {
300301
.append(if (ServerReplay.config.enabled) "enabled" else "disabled")
301302
.append("\n")
302303

303-
this.appendRecorders(builder, "Players", PlayerRecorders.all(), style)
304-
this.appendRecorders(builder, "Chunks", ChunkRecorders.all(), style)
304+
val players = this.getStatusFuture("Players", PlayerRecorders.all(), style)
305+
val chunks = this.getStatusFuture("Chunks", ChunkRecorders.all(), style)
305306

306-
context.source.sendSystemMessage(Component.literal(builder.removeSuffix("\n").toString()))
307+
CompletableFuture.runAsync {
308+
for (player in players) {
309+
builder.append(player.join())
310+
}
311+
for (chunk in chunks) {
312+
builder.append(chunk.join())
313+
}
314+
315+
context.source.server.execute {
316+
context.source.sendSuccess(
317+
{ Component.literal(builder.removeSuffix("\n").toString()) },
318+
true
319+
)
320+
}
321+
}
322+
323+
context.source.sendSuccess({
324+
var message = "Generating replay status..."
325+
if (ServerReplay.config.includeCompressedReplaySizeInStatus) {
326+
message += "\nCalculating compressed sizes of replays (this may take a while)"
327+
}
328+
Component.literal(message)
329+
}, true)
307330
return 1
308331
}
309332

310-
private fun appendRecorders(
311-
builder: StringBuilder,
333+
private fun getStatusFuture(
312334
type: String,
313335
recorders: Collection<ReplayRecorder>,
314336
style: StandardToStringStyle,
315-
) {
337+
): List<CompletableFuture<String>> {
316338
if (recorders.isNotEmpty()) {
317-
builder.append("Currently Recording $type:").append("\n")
318-
for ((recorder, compressed) in recorders.map { it to it.getCompressedRecordingSize() }) {
339+
val futures = ArrayList<CompletableFuture<String>>()
340+
futures.add(CompletableFuture.completedFuture("Currently Recording $type:\n"))
341+
for (recorder in recorders) {
319342
val seconds = recorder.getTotalRecordingTime() / 1000
320343
val hours = seconds / 3600
321344
val minutes = seconds % 3600 / 60
@@ -326,15 +349,18 @@ object ReplayCommand {
326349
.append("name", recorder.getName())
327350
.append("time", time)
328351
.append("raw", FileUtils.formatSize(recorder.getRawRecordingSize()))
329-
.append("compressed", FileUtils.formatSize(compressed.join()))
330-
if (ServerReplay.config.debug) {
331-
sub.append("debug", recorder.getDebugPacketData())
352+
if (ServerReplay.config.includeCompressedReplaySizeInStatus) {
353+
val compressed = recorder.getCompressedRecordingSize()
354+
futures.add(compressed.thenApplyAsync {
355+
"${sub.append("compressed", FileUtils.formatSize(it))}\n"
356+
})
357+
} else {
358+
futures.add(CompletableFuture.completedFuture("$sub\n"))
332359
}
333-
builder.append(sub.toString()).append("\n")
334360
}
335-
} else {
336-
builder.append("Not Currently Recording $type").append("\n")
361+
return futures
337362
}
363+
return listOf(CompletableFuture.completedFuture("Not Currently Recording $type\n"))
338364
}
339365

340366
private fun suggestChunkX(): SuggestionProvider<CommandSourceStack> {

src/main/kotlin/me/senseiwells/replay/config/ReplayConfig.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class ReplayConfig {
5656
@SerialName("restart_after_max_file_size")
5757
var restartAfterMaxFileSize = false
5858

59+
@SerialName("include_compressed_in_status")
60+
var includeCompressedReplaySizeInStatus = true
61+
5962
@SerialName("pause_unloaded_chunks")
6063
var skipWhenChunksUnloaded = false
6164
@SerialName("pause_notify_players")

src/main/kotlin/me/senseiwells/replay/config/serialization/ResourceLocationSerializer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object ResourceLocationSerializer: KSerializer<ResourceLocation> {
1414
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dimension", PrimitiveKind.STRING)
1515

1616
override fun serialize(encoder: Encoder, value: ResourceLocation) {
17+
1718
encoder.encodeString(value.toString())
1819
}
1920

0 commit comments

Comments
 (0)