Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/net/snackbag/tt20/command/MainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private static int executeStatus(CommandContext<ServerCommandSource> context) {
source.sendMessage(Text.literal("§7Time acceleration: " + (TT20.config.timeAcceleration() ? "§aON" : "§cOFF")));
source.sendMessage(Text.literal("§7Random tickspeed acceleration: " + (TT20.config.randomTickSpeedAcceleration() ? "§aON" : "§cOFF")));
source.sendMessage(Text.literal("§7Singleplayer warning: " + (TT20.config.singlePlayerWarning() ? "§aON" : "§cOFF")));
source.sendMessage(Text.literal("§7Singleplayer enabled: " + (TT20.config.singlePlayerEnabled() ? "§aON" : "§cOFF")));
source.sendMessage(Text.literal("§7Server watchdog: " + (TT20.config.serverWatchdog() ? "§aON" : "§cOFF")));
executeTps(context, false);
source.sendMessage(Text.literal("\n§8Version: §7" + TT20.VERSION));
Expand All @@ -56,6 +57,9 @@ private static int executeReload(CommandContext<ServerCommandSource> context) {
TT20.blockEntityMaskConfig.reload();
source.sendMessage(Text.literal("Reloaded block entity mask config"));

if (!source.getServer().isDedicated()) TT20.config.enabled(TT20.config.singlePlayerEnabled());
TT20.config.save();

return 1;
}

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/net/snackbag/tt20/config/MainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class MainConfig extends JSONConfiguration {
private boolean sleepingAcceleration = true;
private boolean timeAcceleration = true;
private boolean randomTickSpeedAcceleration = true;
private boolean singlePlayerEnabled = true;
private boolean serverWatchdog = true;

private boolean singlePlayerWarning = true;
private boolean automaticUpdater = true;

Expand All @@ -33,6 +33,7 @@ public MainConfig() {
putIfEmpty("singleplayer-warning", singlePlayerWarning);
putIfEmpty("time-acceleration", timeAcceleration);
putIfEmpty("random-tickspeed-acceleration", randomTickSpeedAcceleration);
putIfEmpty("singleplayer-enabled", singlePlayerEnabled);
putIfEmpty("automatic-updater", automaticUpdater);

save();
Expand All @@ -55,6 +56,7 @@ public void reload() {
this.singlePlayerWarning = getAsBooleanOrDefault("singleplayer-warning", singlePlayerWarning);
this.timeAcceleration = getAsBooleanOrDefault("time-acceleration", timeAcceleration);
this.randomTickSpeedAcceleration = getAsBooleanOrDefault("random-tickspeed-acceleration", randomTickSpeedAcceleration);
this.singlePlayerEnabled = getAsBooleanOrDefault("singleplayer-enabled", singlePlayerEnabled);
this.automaticUpdater = getAsBooleanOrDefault("automatic-updater", automaticUpdater);
}

Expand Down Expand Up @@ -166,6 +168,14 @@ public void randomTickSpeedAcceleration(boolean enabled) {
put("random-tickspeed-acceleration", enabled);
}

public boolean singlePlayerEnabled() {
return singlePlayerEnabled;
}

public void singlePlayerEnabled(boolean enabled) {
put("singleplayer-enabled", enabled);
}

public boolean singlePlayerWarning() {
return singlePlayerWarning;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//? if >=1.20.1
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.snackbag.tt20.TT20;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -26,8 +25,10 @@ public abstract class ChatHudMixin {
*///?} else {
private void onPlayerConnectWarn(DrawContext context, int currentTick, int mouseX, int mouseY, CallbackInfo ci) {
//?}
if (TT20.warned || !TT20.config.singlePlayerWarning()) return;
addMessage(Text.literal("§c§lCritical incompatibilities found!\n\n§c§6TT20 §cis not stable on singleplayer and you may find yourself having unwanted side effects. You can disable each feature in the config if it gets too annoying."));
if (TT20.config.singlePlayerEnabled() && TT20.config.singlePlayerWarning() && !TT20.warned) {
addMessage(Text.literal("§c§6TT20 §cis §lActive§r§c!"));
addMessage(Text.literal("§c§6TT20 §cis not stable on singleplayer and you may find yourself having unwanted side effects. You can disable each feature in the config."));
}
TT20.warned = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Environment(EnvType.CLIENT)
@Mixin(IntegratedServer.class)
public abstract class IntegratedServerMixin {
@Inject(method = "setupServer", at = @At("HEAD"))
private void disableTT20(CallbackInfoReturnable<Boolean> cir) {
TT20.config.reload();
TT20.config.enabled(TT20.config.singlePlayerEnabled());
TT20.config.save();
}

@Inject(method = "stop", at = @At("HEAD"))
private void resetWarn(boolean waitForShutdown, CallbackInfo ci) {
TT20.warned = false;
Expand Down