Files
Purpur/patches/server/0204-Customizable-sleeping-actionbar-messages.patch
BillyGalbreath ff8e329e9d Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@046466f Re-arrange most chunk system patches to front (#8338)
PaperMC/Paper@e8c2c3b Fix World#refreshChunk not working for chunks in no-tick range
2022-09-01 21:51:05 -05:00

62 lines
4.4 KiB
Diff

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 cf89dde659141a2a78e9b2d2b007b4c54db4b1ed..4b55a46033089e27462b7a8d87cc5631cbcee6a6 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -990,11 +990,27 @@ 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);
- MutableComponent ichatmutablecomponent;
+ Component ichatmutablecomponent;
if (this.sleepStatus.areEnoughSleeping(i)) {
+ // Purpur start
+ if (org.purpurmc.purpur.PurpurConfig.sleepSkippingNight.isBlank()) {
+ return;
+ }
+ if (!org.purpurmc.purpur.PurpurConfig.sleepSkippingNight.equalsIgnoreCase("default")) {
+ ichatmutablecomponent = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.sleepSkippingNight));
+ } else
ichatmutablecomponent = Component.translatable("sleep.skipping_night");
} else {
+ if (org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent.isBlank()) {
+ return;
+ }
+ if (!org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent.equalsIgnoreCase("default")) {
+ ichatmutablecomponent = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent,
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.parsed("count", Integer.toString(this.sleepStatus.amountSleeping())),
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.parsed("total", Integer.toString(this.sleepStatus.sleepersNeeded(i)))));
+ } else
+ // Purpur end
ichatmutablecomponent = Component.translatable("sleep.players_sleeping", this.sleepStatus.amountSleeping(), this.sleepStatus.sleepersNeeded(i));
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index ea6e701d5c76ec53faca03fe2891af9eeadefbf8..c1b7b01c7588cffed238143617dcf2f48a0b241a 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -180,6 +180,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);
@@ -193,6 +195,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 String deathMsgRunWithScissors = "<player> slipped and fell on their shears";