SPIGOT-4722: Cannot get title of player's inventory

This commit is contained in:
md_5 2019-04-24 10:23:12 +10:00
parent 6d504c2d4c
commit 3ddaf665e2
2 changed files with 6 additions and 5 deletions

View File

@ -34,11 +34,11 @@
+ ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); + ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player);
+ } + }
+ private IChatBaseComponent title; + private IChatBaseComponent title;
+ public IChatBaseComponent getTitle() { + public final IChatBaseComponent getTitle() {
+ Preconditions.checkState(this.title != null, "Title not set"); + Preconditions.checkState(this.title != null, "Title not set");
+ return this.title; + return this.title;
+ } + }
+ public void setTitle(IChatBaseComponent title) { + public final void setTitle(IChatBaseComponent title) {
+ Preconditions.checkState(this.title == null, "Title already set"); + Preconditions.checkState(this.title == null, "Title already set");
+ this.title = title; + this.title = title;
+ } + }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerPlayer.java --- a/net/minecraft/server/ContainerPlayer.java
+++ b/net/minecraft/server/ContainerPlayer.java +++ b/net/minecraft/server/ContainerPlayer.java
@@ -1,18 +1,35 @@ @@ -1,18 +1,36 @@
package net.minecraft.server; package net.minecraft.server;
+// CraftBukkit start +// CraftBukkit start
@ -34,11 +34,12 @@
+ this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player + this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
+ this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot + this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot
+ this.player = playerinventory; // CraftBukkit - save player + this.player = playerinventory; // CraftBukkit - save player
+ setTitle(new ChatMessage("container.crafting")); // SPIGOT-4722: Allocate title for player inventory
+ // CraftBukkit end + // CraftBukkit end
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28))); this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28)));
int i; int i;
@@ -79,7 +96,7 @@ @@ -79,7 +97,7 @@
@Override @Override
public void a(IInventory iinventory) { public void a(IInventory iinventory) {
@ -47,7 +48,7 @@
} }
@Override @Override
@@ -182,4 +199,17 @@ @@ -182,4 +200,17 @@
public int h() { public int h() {
return this.craftInventory.f(); return this.craftInventory.f();
} }