mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 02fbcbc Add reobf mappings patch for LevelChunk#level (CraftBukkit changes type) (#6079) 2641b91 Also deobfuscate secondary stacktraces in crash reports (#6078) cc063e1 Fix incorrect variable usage in per-player mob spawning patch (#6077) Tuinity Changes: 4867bfb Use correct y value for snow/ice formation 361be02 Update paper
90 lines
5.1 KiB
Diff
90 lines
5.1 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 dbf9d73027320efeed5fda3a610281fd737540df..42f6664ea6ddb3892b4549a78755efccd6f0f329 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -4,6 +4,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|
import co.aikar.timings.TimingHistory; // Paper
|
|
import com.google.common.collect.Lists;
|
|
import com.mojang.datafixers.DataFixer;
|
|
+import io.papermc.paper.adventure.PaperAdventure;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
|
@@ -34,6 +35,9 @@ import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nonnull;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
+import net.kyori.adventure.text.minimessage.Template;
|
|
import net.minecraft.CrashReport;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.DefaultedRegistry;
|
|
@@ -158,6 +162,7 @@ import net.minecraft.world.phys.Vec3;
|
|
import net.minecraft.world.phys.shapes.BooleanOp;
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
+import net.pl3x.purpur.PurpurConfig;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
@@ -1089,11 +1094,29 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
|
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 (PurpurConfig.sleepSkippingNight.isBlank()) {
|
|
+ return;
|
|
+ }
|
|
+ if (!PurpurConfig.sleepSkippingNight.equalsIgnoreCase("default")) {
|
|
+ chatmessage = PaperAdventure.asVanilla(MiniMessage.get().parse(PurpurConfig.sleepSkippingNight));
|
|
+ } else
|
|
+ // Purpur
|
|
chatmessage = new TranslatableComponent("sleep.skipping_night");
|
|
} else {
|
|
+ // Purpur start
|
|
+ if (PurpurConfig.sleepingPlayersPercent.isBlank()) {
|
|
+ return;
|
|
+ }
|
|
+ if (!PurpurConfig.sleepingPlayersPercent.equalsIgnoreCase("default")) {
|
|
+ chatmessage = PaperAdventure.asVanilla(MiniMessage.get().parse(PurpurConfig.sleepingPlayersPercent,
|
|
+ Template.of("count", Integer.toString(this.sleepStatus.amountSleeping())),
|
|
+ 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 b70a59e80c4861f8be6fd34b326140a6d3f917ed..209ddb614b98edcf340b49c1f12331bf169f8058 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -165,6 +165,8 @@ public class PurpurConfig {
|
|
public static String pingCommandOutput = "<green>%s's ping is %sms";
|
|
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);
|
|
@@ -176,6 +178,8 @@ public class PurpurConfig {
|
|
pingCommandOutput = getString("settings.messages.ping-command-output", pingCommandOutput);
|
|
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;
|