Skip to content

Commit

Permalink
stop replaymod from automatically recording
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jul 4, 2024
1 parent eeba7ee commit d5c9aac
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ dependencies {
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
if (platform.isLegacyForge) {
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta17")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod_id=skyclientcosmetics
mod_name=SkyClientCosmetics
mod_version=1.1.16
mod_version=1.1.17
mod_archives_name=SkyClientCosmetics

# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
Expand Down
10 changes: 10 additions & 0 deletions src/dummy/java/com/replaymod/core/ReplayMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.replaymod.core;

public class ReplayMod {

public static ReplayMod instance;

public SettingsRegistry getSettingsRegistry() {
return new SettingsRegistry();
}
}
53 changes: 53 additions & 0 deletions src/dummy/java/com/replaymod/core/SettingsRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.replaymod.core;

public class SettingsRegistry {

public <T> void set(SettingKey<T> key, T value) {
// dummy
}

public void save() {
// dummy
}

public interface SettingKey<T> {
String getCategory();
String getKey();
String getDisplayString();
T getDefault();
}

public static class SettingKeys<T> implements SettingKey<T> {
private final String category;
private final String key;
private final String displayString;
private final T defaultValue;

public SettingKeys(String category, String key, String displayString, T defaultValue) {
this.category = category;
this.key = key;
this.displayString = displayString;
this.defaultValue = defaultValue;
}

@Override
public String getCategory() {
return category;
}

@Override
public String getKey() {
return key;
}

@Override
public String getDisplayString() {
return displayString;
}

@Override
public T getDefault() {
return defaultValue;
}
}
}
15 changes: 15 additions & 0 deletions src/dummy/java/com/replaymod/recording/Setting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.replaymod.recording;

import com.replaymod.core.SettingsRegistry;

public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
public static final Setting<Boolean> AUTO_START_RECORDING = make("autoStartRecording", "autostartrecording", true);

private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
return new Setting<>(key, displayName, defaultValue);
}

public Setting(String key, String displayString, T defaultValue) {
super("recording", key, displayString == null ? null : "replaymod.gui.settings." + displayString, defaultValue);
}
}
28 changes: 27 additions & 1 deletion src/main/java/co/skyclient/scc/SkyclientCosmetics.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import co.skyclient.scc.mixins.ServerListAccessor;
import co.skyclient.scc.rpc.RPC;
import co.skyclient.scc.utils.Files;
import com.replaymod.core.ReplayMod;
import com.replaymod.recording.Setting;
import de.jcm.discordgamesdk.Core;
import me.partlysanestudios.partlysaneskies.config.OneConfigScreen;
import net.minecraft.client.Minecraft;
Expand All @@ -47,7 +49,6 @@
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class SkyclientCosmetics {

public static boolean isPatcher;
public static boolean isEssential;
public static boolean isReplayMod;
public static Object scuConfig = null;
//private static boolean hasFailed;

Expand Down Expand Up @@ -174,6 +176,30 @@ public void onPostInit(FMLPostInitializationEvent event) {
} catch (Exception e) {
e.printStackTrace();
}
} else if ("replaymod".equals(mod.getModId())) {
isReplayMod = true;
try {
Class<?> replayMod = Class.forName("com.replaymod.core.ReplayMod");
replayMod.getDeclaredField("instance");
replayMod.getDeclaredMethod("getSettingsRegistry");
Class<?> settingsRegistry = Class.forName("com.replaymod.core.SettingsRegistry");
settingsRegistry.getDeclaredMethod("set", settingsRegistry.getDeclaredClasses()[0], Object.class);
settingsRegistry.getDeclaredMethod("save");
Class<?> settings = Class.forName("com.replaymod.recording.Setting");
settings.getDeclaredField("RECORD_SINGLEPLAYER");
settings.getDeclaredField("RECORD_SERVER");
} catch (Exception e) {
e.printStackTrace();
isReplayMod = false;
}
if (isReplayMod) {
if (!Settings.hasWipedOutReplayModAutoRecording) {
ReplayMod.instance.getSettingsRegistry().set(Setting.AUTO_START_RECORDING, false);
ReplayMod.instance.getSettingsRegistry().save();
Settings.hasWipedOutReplayModAutoRecording = true;
config.save();
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/co/skyclient/scc/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static void reloadTags() {
public static boolean displayTags = false;

public static boolean hasWipedOutPSS = false;
public static boolean hasWipedOutReplayModAutoRecording = false;

public Settings() {
super(new Mod("SkyClientCosmetics", ModType.UTIL_QOL, "/assets/scc/SkyClient.png", new VigilanceMigrator("./SkyclientCosmetics/skyclientcosmetics.toml")), "skyclientcosmetics.json");
Expand Down

0 comments on commit d5c9aac

Please sign in to comment.