diff --git a/src/main/java/com/github/steveplays28/realisticsleep/config/RealisticSleepConfig.java b/src/main/java/com/github/steveplays28/realisticsleep/config/RealisticSleepConfig.java index f3479a5..d3defcf 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/config/RealisticSleepConfig.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/config/RealisticSleepConfig.java @@ -6,11 +6,16 @@ @Config(name = "realisticsleep") public class RealisticSleepConfig implements ConfigData { + @ConfigEntry.Gui.Tooltip + public boolean sendDawnMessage = true; @ConfigEntry.Gui.Tooltip public String dawnMessage = "The sun rises."; + @ConfigEntry.Gui.Tooltip public boolean sendSleepingMessage = true; @ConfigEntry.Gui.Tooltip + public boolean showTimeUntilDawn = true; + @ConfigEntry.Gui.Tooltip public boolean sendNotEnoughPlayersSleepingMessage = true; @ConfigEntry.Gui.Tooltip diff --git a/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java b/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java index 2055f7e..b4fde10 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java @@ -38,6 +38,8 @@ public abstract class ServerWorldMixin extends World { public double nightTimeStepPerTick = 1; public int nightTimeStepPerTickRounded = 1; public long tickDelay; + public long lastFluidTick; + public String sleepMessage; @Shadow @Final @@ -149,18 +151,11 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { // Check if players are still supposed to be sleeping, and send a HUD message if so if (secondsUntilAwake >= 2) { if (config.sendSleepingMessage) { + sleepMessage = String.format("%d/%d players are sleeping through this %s", sleepingPlayerCount, playerCount, worldProperties.isThundering() ? "thunderstorm" : "night"); + if (config.showTimeUntilDawn) sleepMessage += String.format(" (Time until dawn: %d", secondsUntilAwake) + "s)"; + for (ServerPlayerEntity player : players) { - if (worldProperties.isThundering()) { - player.sendMessage( - Text.of(sleepingPlayerCount + "/" + playerCount + " players are sleeping through this thunderstorm (time until dawn: " + secondsUntilAwake + "s)"), - true - ); - } else { - player.sendMessage( - Text.of(sleepingPlayerCount + "/" + playerCount + " players are sleeping through this night (time until dawn: " + secondsUntilAwake + "s)"), - true - ); - } + player.sendMessage(Text.of(sleepMessage), true); } } } @@ -178,10 +173,9 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { // Wake up sleeping players wakeSleepingPlayers(); - // Check if dawn message isn't set to nothing - if (config.dawnMessage.equals("")) { - return; - } + // Return if we shouldn't send the dawn message + if (!config.sendDawnMessage || config.dawnMessage.equals("")) return; + // Send HUD message to all players for (ServerPlayerEntity player : players) { player.sendMessage(Text.of(config.dawnMessage), true);