From 66fdc58bb0bfe18ab0d07633cff9ee5386813fea Mon Sep 17 00:00:00 2001 From: Hadron67 <604700341@qq.com> Date: Thu, 13 Aug 2020 19:55:18 +0800 Subject: [PATCH] add pauseMarkers recording param --- src/main/java/com/hadroncfy/sreplay/SReplayMod.java | 2 +- .../sreplay/mixin/MixinThreadedAnvilChunkStorage.java | 3 --- .../com/hadroncfy/sreplay/recording/Photographer.java | 8 ++++---- .../java/com/hadroncfy/sreplay/recording/Recorder.java | 10 ++++++---- .../hadroncfy/sreplay/recording/RecordingParam.java | 3 +++ src/main/resources/lang/zh_cn.json | 3 ++- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hadroncfy/sreplay/SReplayMod.java b/src/main/java/com/hadroncfy/sreplay/SReplayMod.java index 0ef3f2e..5be8f58 100644 --- a/src/main/java/com/hadroncfy/sreplay/SReplayMod.java +++ b/src/main/java/com/hadroncfy/sreplay/SReplayMod.java @@ -83,7 +83,7 @@ public void onInitialize() { Lang.load("zh_cn"); LOGGER.info("SReplay: Initialzed"); } catch (Exception e) { - LOGGER.error("Exception initializing mod: {}", e); + LOGGER.error("Exception initializing mod", e); e.printStackTrace(); } diff --git a/src/main/java/com/hadroncfy/sreplay/mixin/MixinThreadedAnvilChunkStorage.java b/src/main/java/com/hadroncfy/sreplay/mixin/MixinThreadedAnvilChunkStorage.java index 1072346..5698867 100644 --- a/src/main/java/com/hadroncfy/sreplay/mixin/MixinThreadedAnvilChunkStorage.java +++ b/src/main/java/com/hadroncfy/sreplay/mixin/MixinThreadedAnvilChunkStorage.java @@ -5,7 +5,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.InjectionPoint; import org.spongepowered.asm.mixin.injection.Redirect; import net.minecraft.network.Packet; @@ -15,8 +14,6 @@ import static com.hadroncfy.sreplay.recording.Photographer.getRealViewDistance; -import com.hadroncfy.sreplay.asm.MultipleOrdinalFieldInjectionPoint; - @Mixin(ThreadedAnvilChunkStorage.class) public abstract class MixinThreadedAnvilChunkStorage { @Shadow private int watchDistance; diff --git a/src/main/java/com/hadroncfy/sreplay/recording/Photographer.java b/src/main/java/com/hadroncfy/sreplay/recording/Photographer.java index 881dea8..221dfaa 100644 --- a/src/main/java/com/hadroncfy/sreplay/recording/Photographer.java +++ b/src/main/java/com/hadroncfy/sreplay/recording/Photographer.java @@ -9,7 +9,6 @@ import com.hadroncfy.sreplay.SReplayMod; import com.hadroncfy.sreplay.config.TextRenderer; -import com.hadroncfy.sreplay.interfaces.IChunkSender; import com.hadroncfy.sreplay.mixin.PlayerManagerAccessor; import com.hadroncfy.sreplay.recording.param.ParamManager; import com.mojang.authlib.GameProfile; @@ -216,11 +215,11 @@ public void onStoppedTracking(Entity entity) { private void updatePause(){ if (recorder != null && rparam.autoPause){ final String name = getGameProfile().getName(); - if (trackedPlayers.size() == 0 && !recorder.isRecordingPaused()){ + if (trackedPlayers.isEmpty() && !recorder.isRecordingPaused()){ recorder.pauseRecording(); server.getPlayerManager().broadcastChatMessage(render(SReplayMod.getFormats().autoPaused, name), true); } - if (trackedPlayers.size() > 0 && recorder.isRecordingPaused()){ + if (!trackedPlayers.isEmpty() && recorder.isRecordingPaused()){ recorder.resumeRecording(); server.getPlayerManager().broadcastChatMessage(render(SReplayMod.getFormats().autoResumed, name), true); } @@ -282,6 +281,7 @@ public Recorder getRecorder(){ return recorder; } + @Override public void kill(){ kill(null, true); } @@ -368,7 +368,7 @@ public RecordingParam getRecordingParam(){ public static void killAllFakes(MinecraftServer server, boolean async) { // LOGGER.info("Killing all fakes"); - listFakes(server).forEach(p -> LOGGER.info("Fake: " + p.getGameProfile().getName())); + listFakes(server).forEach(p -> LOGGER.info("Fake: {}", p.getGameProfile().getName())); listFakes(server).forEach(p -> p.kill(null, async)); } diff --git a/src/main/java/com/hadroncfy/sreplay/recording/Recorder.java b/src/main/java/com/hadroncfy/sreplay/recording/Recorder.java index dd4b0e1..0f4f79f 100644 --- a/src/main/java/com/hadroncfy/sreplay/recording/Recorder.java +++ b/src/main/java/com/hadroncfy/sreplay/recording/Recorder.java @@ -159,7 +159,9 @@ private synchronized long getCurrentTimeAndUpdate(){ public void pauseRecording(){ gPaused = true; paused = true; - addMarker(MARKER_PAUSE); + if (param.pauseMarkers){ + addMarker(MARKER_PAUSE); + } } public boolean isRecordingPaused(){ @@ -205,12 +207,12 @@ private void savePacket(Packet packet) { packetSaveStream.write(pb); bytesRecorded += pb.length + 8; } catch (IOException e) { - LOGGER.error("Error saving packet: " + e); + LOGGER.error("Error saving packet", e); e.printStackTrace(); } }); } catch (Exception e) { - LOGGER.error("Error saving packet: " + e); + LOGGER.error("Error saving packet", e); e.printStackTrace(); } } @@ -255,7 +257,7 @@ private void saveMetadata(){ } private void saveMarkers(){ - if (markers.size() > 0){ + if (!markers.isEmpty()){ saveService.submit(() -> { Set m = new HashSet<>(); m.addAll(markers); diff --git a/src/main/java/com/hadroncfy/sreplay/recording/RecordingParam.java b/src/main/java/com/hadroncfy/sreplay/recording/RecordingParam.java index c7750ae..b3b37f7 100644 --- a/src/main/java/com/hadroncfy/sreplay/recording/RecordingParam.java +++ b/src/main/java/com/hadroncfy/sreplay/recording/RecordingParam.java @@ -43,6 +43,9 @@ public class RecordingParam { @Param(desc = "sreplay.param.forcedWeather.desc") public ForcedWeather forcedWeather = ForcedWeather.NONE; + @Param(desc = "sreplay.param.pauseMarkers.desc") + public boolean pauseMarkers = false; + public static RecordingParam createDefaultRecordingParam(Config config, int watchDistance) { RecordingParam p = new RecordingParam(); p.autoReconnect = config.autoReconnect; diff --git a/src/main/resources/lang/zh_cn.json b/src/main/resources/lang/zh_cn.json index 294a7c1..bdedf2e 100644 --- a/src/main/resources/lang/zh_cn.json +++ b/src/main/resources/lang/zh_cn.json @@ -9,5 +9,6 @@ "sreplay.param.autoReconnect.desc": "自动续录开关,如果为true就会在自动停止录制后自动开始新一轮的录制。", "sreplay.param.watchDistance.desc": "录像视距,单位为区块。增大该值不会增大录像假人的区块加载范围,因此还需要用假人加载区块。", "sreplay.param.dayTime.desc": "锁定录像的世界时间为该参数值,-1代表不锁定。锁定时间后可停止昼夜循环,在渲染长时间录像时能提高渲染的效果", - "sreplay.param.forcedWeather.desc": "锁定录像中的天气。" + "sreplay.param.forcedWeather.desc": "锁定录像中的天气。", + "sreplay.param.pauseMarkers.desc": "在时间轴上自动暂停的位置添加标记" } \ No newline at end of file