Skip to content

Commit

Permalink
add pauseMarkers recording param
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadron67 committed Aug 13, 2020
1 parent 0d373fe commit 66fdc58
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/hadroncfy/sreplay/SReplayMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -282,6 +281,7 @@ public Recorder getRecorder(){
return recorder;
}

@Override
public void kill(){
kill(null, true);
}
Expand Down Expand Up @@ -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));
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/hadroncfy/sreplay/recording/Recorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -255,7 +257,7 @@ private void saveMetadata(){
}

private void saveMarkers(){
if (markers.size() > 0){
if (!markers.isEmpty()){
saveService.submit(() -> {
Set<Marker> m = new HashSet<>();
m.addAll(markers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "在时间轴上自动暂停的位置添加标记"
}

0 comments on commit 66fdc58

Please sign in to comment.