mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Customizable sleeping actionbar messages
This commit is contained in:
committed by
granny
parent
d2a3e02533
commit
19a65e8dcf
@@ -118,3 +118,30 @@
|
||||
PoiManager.Occupancy.ANY
|
||||
);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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 @@
|
||||
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 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);
|
||||
@@ -188,6 +191,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