Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: ComputerTimeOffset Error #2998

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import org.lwjgl.input.Keyboard;
Expand Down Expand Up @@ -124,6 +125,14 @@ public class DevConfig {
@ConfigEditorBoolean
public boolean numberFormatOverride = false;

@Expose
@ConfigOption(
name = "NTP Server",
desc = "Change the NTP-Server Address. Default is \"time.google.com\".\n§cONLY CHANGE THIS IF YOU KNOW WHAT YOU'RE DOING!"
)
@ConfigEditorText
public String ntpServer = "time.google.com";

@Expose
@Category(name = "Minecraft Console", desc = "Minecraft Console Settings")
public MinecraftConsoleConfig minecraftConsoles = new MinecraftConsoleConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object ComputerTimeOffset {
private fun checkOffset() {
val wasOffsetBefore = (offsetMillis?.absoluteValue ?: 0.seconds) > 5.seconds
SkyHanniMod.coroutineScope.launch {
offsetMillis = getNtpOffset("time.google.com")
offsetMillis = getNtpOffset(SkyHanniMod.feature.dev.ntpServer)
offsetMillis?.let {
tryDisplayOffset(wasOffsetBefore)
}
Expand All @@ -56,6 +56,7 @@ object ComputerTimeOffset {
val client = NTPUDPClient()
val address = InetAddress.getByName(ntpServer)
val timeInfo = client.getTime(address)
client.close()
j10a1n15 marked this conversation as resolved.
Show resolved Hide resolved

timeInfo.computeDetails()
timeInfo.offset.milliseconds
Expand Down
Loading