mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
Add configurable "sleep.not_possible" actionbar message (#1414)
This commit is contained in:
@@ -37,25 +37,52 @@ index fea5481c98e4cbcaecb9f4adef35b7340ad0c9b8..df8efd93ad6ab30974e3025187cd234b
|
||||
ichatmutablecomponent = Component.translatable("sleep.players_sleeping", this.sleepStatus.amountSleeping(), this.sleepStatus.sleepersNeeded(i));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 784634596696521cfbd58e85392183dd96b843b0..b724a6fd90e6774db1f64090dc4854b6de4a9f44 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1472,7 +1472,19 @@ public class ServerPlayer extends Player {
|
||||
});
|
||||
|
||||
if (!this.serverLevel().canSleepThroughNights()) {
|
||||
- this.displayClientMessage(Component.translatable("sleep.not_possible"), true);
|
||||
+ // Purpur start
|
||||
+ Component clientMessage;
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.sleepNotPossible.isBlank()) {
|
||||
+ clientMessage = null;
|
||||
+ } else if (!org.purpurmc.purpur.PurpurConfig.sleepNotPossible.equalsIgnoreCase("default")) {
|
||||
+ clientMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.sleepNotPossible));
|
||||
+ } else {
|
||||
+ clientMessage = Component.translatable("sleep.not_possible");
|
||||
+ }
|
||||
+ if (clientMessage != null) {
|
||||
+ this.displayClientMessage(clientMessage, true);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
((ServerLevel) this.level()).updateSleepingPlayerList();
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index f5a5cc0f954f33f75b542c33d8385076a8aad163..34eae29ed89a32bed6777b514e6beed2cb3cd177 100644
|
||||
index f5a5cc0f954f33f75b542c33d8385076a8aad163..fe0f582291d61b1fd6f1916a39d62bfaf5abfa49 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -186,6 +186,8 @@ public class PurpurConfig {
|
||||
@@ -186,6 +186,9 @@ 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";
|
||||
+ public static String sleepNotPossible = "default";
|
||||
private static void messages() {
|
||||
cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
|
||||
afkBroadcastAway = getString("settings.messages.afk-broadcast-away", afkBroadcastAway);
|
||||
@@ -200,6 +202,8 @@ public class PurpurConfig {
|
||||
@@ -200,6 +203,9 @@ 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);
|
||||
+ sleepNotPossible = getString("settings.messages.sleep-not-possible", sleepNotPossible);
|
||||
}
|
||||
|
||||
public static String deathMsgRunWithScissors = "<player> slipped and fell on their shears";
|
||||
|
||||
Reference in New Issue
Block a user