Paper/patches/server/0604-Return-chat-component-with-empty-text-instead-of-thr.patch

34 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: CDFN <codefun@protonmail.com>
Date: Tue, 7 Jul 2020 17:53:23 +0200
Subject: [PATCH] Return chat component with empty text instead of throwing
exception
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
index 92681e56cea92a4600ef268b21c1b56e15fe3a03..b4c1e62c6ed1ea0319ebb268bf8032218a306e78 100644
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
@@ -20,6 +20,7 @@ import net.minecraft.ReportedException;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth;
@@ -82,7 +83,12 @@ public abstract class AbstractContainerMenu {
}
private Component title;
public final Component getTitle() {
- Preconditions.checkState(this.title != null, "Title not set");
+ // Paper start - return chat component with empty text instead of throwing error
+ // Preconditions.checkState(this.title != null, "Title not set");
+ if(this.title == null){
+ return new TextComponent("");
+ }
+ // Paper end
return this.title;
}
public final void setTitle(Component title) {