mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
Customizable sleeping actionbar messages
This commit is contained in:
committed by
granny
parent
d2a3e02533
commit
19a65e8dcf
@@ -1,88 +0,0 @@
|
|||||||
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/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
||||||
index 9ff7fb18e52bea06b02ebf0d1b97647df6b304dc..361885b28305e1c3e314b3b9f9807cf3c5ab843a 100644
|
|
||||||
--- a/net/minecraft/server/level/ServerLevel.java
|
|
||||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
||||||
@@ -1122,11 +1122,27 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
||||||
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/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
||||||
index 4c69fa830a216c189f97ddfb62f0008b891455da..16fba60c063d059ee069821041d1ee55fe7cc62b 100644
|
|
||||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
||||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
||||||
@@ -1830,7 +1830,19 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
|
||||||
});
|
|
||||||
|
|
||||||
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 e6079b44bd1364bd6be93d584634bab3553d5edb..01aad39f65bd9c38e470139b1b80a26f3af9c922 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
@@ -189,6 +189,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);
|
|
||||||
@@ -203,6 +206,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";
|
|
||||||
@@ -118,3 +118,30 @@
|
|||||||
PoiManager.Occupancy.ANY
|
PoiManager.Occupancy.ANY
|
||||||
);
|
);
|
||||||
return optional.map(blockPos -> blockPos.above(1));
|
return optional.map(blockPos -> blockPos.above(1));
|
||||||
|
@@ -1057,8 +_,26 @@
|
||||||
|
int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
|
||||||
|
Component component;
|
||||||
|
if (this.sleepStatus.areEnoughSleeping(_int)) {
|
||||||
|
+ // Purpur start - Customizable sleeping actionbar messages
|
||||||
|
+ if (org.purpurmc.purpur.PurpurConfig.sleepSkippingNight.isBlank()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if (!org.purpurmc.purpur.PurpurConfig.sleepSkippingNight.equalsIgnoreCase("default")) {
|
||||||
|
+ component = io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.purpurmc.purpur.PurpurConfig.sleepSkippingNight));
|
||||||
|
+ } else
|
||||||
|
+ // Purpur end - Customizable sleeping actionbar messages
|
||||||
|
component = Component.translatable("sleep.skipping_night");
|
||||||
|
} else {
|
||||||
|
+ // Purpur start - Customizable sleeping actionbar messages
|
||||||
|
+ if (org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent.isBlank()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if (!org.purpurmc.purpur.PurpurConfig.sleepingPlayersPercent.equalsIgnoreCase("default")) {
|
||||||
|
+ component = 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(_int)))));
|
||||||
|
+ } else
|
||||||
|
+ // Purpur end - Customizable sleeping actionbar messages
|
||||||
|
component = Component.translatable("sleep.players_sleeping", this.sleepStatus.amountSleeping(), this.sleepStatus.sleepersNeeded(_int));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,27 @@
|
|||||||
return Either.left(Player.BedSleepingProblem.NOT_SAFE);
|
return Either.left(Player.BedSleepingProblem.NOT_SAFE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1601,7 +_,19 @@
|
||||||
|
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
|
||||||
|
});
|
||||||
|
if (!this.serverLevel().canSleepThroughNights()) {
|
||||||
|
- this.displayClientMessage(Component.translatable("sleep.not_possible"), true);
|
||||||
|
+ // Purpur start - Customizable sleeping actionbar messages
|
||||||
|
+ 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 - Customizable sleeping actionbar messages
|
||||||
|
}
|
||||||
|
|
||||||
|
((ServerLevel)this.level()).updateSleepingPlayerList();
|
||||||
@@ -2014,6 +_,26 @@
|
@@ -2014,6 +_,26 @@
|
||||||
this.lastSentExp = -1; // CraftBukkit - Added to reset
|
this.lastSentExp = -1; // CraftBukkit - Added to reset
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,9 @@ public class PurpurConfig {
|
|||||||
public static String dontRunWithScissors = "<red><italic>Don't run with scissors!";
|
public static String dontRunWithScissors = "<red><italic>Don't run with scissors!";
|
||||||
public static String uptimeCommandOutput = "<green>Server uptime is <uptime>";
|
public static String uptimeCommandOutput = "<green>Server uptime is <uptime>";
|
||||||
public static String unverifiedUsername = "default";
|
public static String unverifiedUsername = "default";
|
||||||
|
public static String sleepSkippingNight = "default";
|
||||||
|
public static String sleepingPlayersPercent = "default";
|
||||||
|
public static String sleepNotPossible = "default";
|
||||||
private static void messages() {
|
private static void messages() {
|
||||||
cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
|
cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
|
||||||
afkBroadcastAway = getString("settings.messages.afk-broadcast-away", afkBroadcastAway);
|
afkBroadcastAway = getString("settings.messages.afk-broadcast-away", afkBroadcastAway);
|
||||||
@@ -188,6 +191,9 @@ public class PurpurConfig {
|
|||||||
dontRunWithScissors = getString("settings.messages.dont-run-with-scissors", dontRunWithScissors);
|
dontRunWithScissors = getString("settings.messages.dont-run-with-scissors", dontRunWithScissors);
|
||||||
uptimeCommandOutput = getString("settings.messages.uptime-command-output", uptimeCommandOutput);
|
uptimeCommandOutput = getString("settings.messages.uptime-command-output", uptimeCommandOutput);
|
||||||
unverifiedUsername = getString("settings.messages.unverified-username", unverifiedUsername);
|
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";
|
public static String deathMsgRunWithScissors = "<player> slipped and fell on their shears";
|
||||||
|
|||||||
Reference in New Issue
Block a user