From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 3 Jul 2021 21:52:15 -0500
Subject: [PATCH] Customizable sleeping actionbar messages


diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index e3e4dc544e4d2a2ae01c3f653d2f0de3ddbc5062..7bd74f7bdd23636f7d6c4f2325fd6430780fc95d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1060,11 +1060,29 @@ public class ServerLevel extends Level implements WorldGenLevel {
         if (this.canSleepThroughNights()) {
             if (!this.getServer().isSingleplayer() || this.getServer().isPublished()) {
                 int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
-                TranslatableComponent chatmessage;
+                Component chatmessage; // Purpur
 
                 if (this.sleepStatus.areEnoughSleeping(i)) {
+                    // Purpur start
+                    if (net.pl3x.purpur.PurpurConfig.sleepSkippingNight.isBlank()) {
+                        return;
+                    }
+                    if (!net.pl3x.purpur.PurpurConfig.sleepSkippingNight.equalsIgnoreCase("default")) {
+                        chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.get().parse(net.pl3x.purpur.PurpurConfig.sleepSkippingNight));
+                    } else
+                    // Purpur end
                     chatmessage = new TranslatableComponent("sleep.skipping_night");
                 } else {
+                    // Purpur start
+                    if (net.pl3x.purpur.PurpurConfig.sleepingPlayersPercent.isBlank()) {
+                        return;
+                    }
+                    if (!net.pl3x.purpur.PurpurConfig.sleepingPlayersPercent.equalsIgnoreCase("default")) {
+                        chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.get().parse(net.pl3x.purpur.PurpurConfig.sleepingPlayersPercent,
+                                net.kyori.adventure.text.minimessage.Template.of("count", Integer.toString(this.sleepStatus.amountSleeping())),
+                                net.kyori.adventure.text.minimessage.Template.of("total", Integer.toString(this.sleepStatus.sleepersNeeded(i)))));
+                    } else
+                    // Purpur end
                     chatmessage = new TranslatableComponent("sleep.players_sleeping", new Object[]{this.sleepStatus.amountSleeping(), this.sleepStatus.sleepersNeeded(i)});
                 }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index 60412d24201bbd61162662b3a2270eecab39fa3d..adfec9c94849b5371e9188eb0ce18565c2d17fc9 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -168,6 +168,8 @@ public class PurpurConfig {
     public static String dontRunWithScissors = "<red><italic>Don't run with scissors!";
     public static String uptimeCommandOutput = "<green>Server uptime is <uptime>";
     public static String unverifiedUsername = "default";
+    public static String sleepSkippingNight = "default";
+    public static String sleepingPlayersPercent = "default";
     private static void messages() {
         cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
         afkBroadcastAway = getString("settings.messages.afk-broadcast-away", afkBroadcastAway);
@@ -180,6 +182,8 @@ public class PurpurConfig {
         dontRunWithScissors = getString("settings.messages.dont-run-with-scissors", dontRunWithScissors);
         uptimeCommandOutput = getString("settings.messages.uptime-command-output", uptimeCommandOutput);
         unverifiedUsername = getString("settings.messages.unverified-username", unverifiedUsername);
+        sleepSkippingNight = getString("settings.messages.sleep-skipping-night", sleepSkippingNight);
+        sleepingPlayersPercent = getString("settings.messages.sleeping-players-percent", sleepingPlayersPercent);
     }
 
     public static boolean advancementOnlyBroadcastToAffectedPlayer = false;
