mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: d985976 Add config for mobs immune to default effects (#4835) Tuinity Changes: ea43797 Fix portalling from the overworld above y 255
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 bfcd0def5ed81c8579f7fbbbb580797439c4cfc5..4d921ac4d064b02416e43bba93b70406ff0417eb 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 0d77130d4fbd12dbed5cce84a041a41db41351dd..f90256ef0806a61c434a0d062318267184177283 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -166,6 +166,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);
|
|
@@ -178,6 +180,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 boolean advancementOnlyBroadcastToAffectedPlayer = false;
|