Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions patches/api/0006-Adventure.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4157,10 +4157,10 @@ index 5adbe0514129abf3cfbc4b29a213f522359fe2e1..72ebc29db42d08d1d0361dba462fc8a5

/**
diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java
index e12996492c1558fed9fab30de9f8018e0ed7fac3..002acfbdce1db10f7ba1b6a013e678f504ac6e69 100644
index e12996492c1558fed9fab30de9f8018e0ed7fac3..c97d81ed322eb568ed20372da3f310b9f9fe39e9 100644
--- a/src/main/java/org/bukkit/inventory/InventoryView.java
+++ b/src/main/java/org/bukkit/inventory/InventoryView.java
@@ -447,12 +447,26 @@ public abstract class InventoryView {
@@ -447,12 +447,45 @@ public abstract class InventoryView {
return getPlayer().setWindowProperty(prop, value);
}

Expand All @@ -4171,22 +4171,61 @@ index e12996492c1558fed9fab30de9f8018e0ed7fac3..002acfbdce1db10f7ba1b6a013e678f5
* @return The title.
*/
@NotNull
+ public /*abstract*/ net.kyori.adventure.text.Component title() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.getTitle());
+ }
+ public abstract net.kyori.adventure.text.Component title();
+
+ /**
+ * Get the original title of this inventory window, before any changes were
+ * made using {@link #setTitle(String)}.
+ *
+ * @return the original title
+ */
+ @NotNull
+ public abstract net.kyori.adventure.text.Component originalTitle();
+
+ /**
+ * Sets the title of this inventory window to the specified title if the
+ * inventory window supports it.
+ * <p>
+ * Note if the inventory does not support titles that can be changed (ie, it
+ * is not creatable or viewed by a player), then this method will throw an
+ * exception.
+ *
+ * @param title The new title.
+ */
+ public abstract void setTitle(@NotNull net.kyori.adventure.text.Component title);
+ // Paper end
+
+ /**
+ * Get the title of this inventory window.
+ *
+ * @return The title.
+ * @deprecated in favour of {@link #title()}
+ * @deprecated in favor of {@link #title()}
+ */
+ @Deprecated // Paper
+ @NotNull
public abstract String getTitle();

/**
@@ -460,8 +493,10 @@ public abstract class InventoryView {
* made using {@link #setTitle(String)}.
*
* @return the original title
+ * @deprecated in favor of {@link #originalTitle()}
*/
@NotNull
+ @Deprecated
public abstract String getOriginalTitle();

/**
@@ -473,6 +508,8 @@ public abstract class InventoryView {
* exception.
*
* @param title The new title.
+ * @deprecated in favor of {@link #setTitle(net.kyori.adventure.text.Component)}
*/
+ @Deprecated
public abstract void setTitle(@NotNull String title);
}
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
index 096e0d60c4542fec66898b6aa8ea9820a1ef483b..3e7f92dc0aea0ea555dd02c50a1102da46fe74c4 100644
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
Expand Down
136 changes: 120 additions & 16 deletions patches/server/0010-Adventure.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4726,23 +4726,62 @@ index 2496f4462b35a7297dd9320c35f109d3c2a9867f..6571adf5285ab3f84513c2f5b32ff052
return event;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
index d47b248535882bb58ae6c1b6ef756464a1989918..39be45585835eabc8d8bcae0158c094c3dcb1aa3 100644
index d47b248535882bb58ae6c1b6ef756464a1989918..850c2142b72340f9dc595d7340fc5a55a5ddb735 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
@@ -73,6 +73,13 @@ public class CraftContainer extends AbstractContainerMenu {
@@ -50,8 +50,8 @@ public class CraftContainer extends AbstractContainerMenu {
public CraftContainer(final Inventory inventory, final Player player, int id) {
this(new InventoryView() {

- private final String originalTitle = (inventory instanceof CraftInventoryCustom) ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle();
- private String title = this.originalTitle;
+ private final net.kyori.adventure.text.Component originalTitle = (inventory instanceof CraftInventoryCustom) ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).title() : net.kyori.adventure.text.Component.text(inventory.getType().getDefaultTitle()); // Paper
+ private net.kyori.adventure.text.Component title = this.originalTitle; // Paper

@Override
public Inventory getTopInventory() {
@@ -73,21 +73,38 @@ public class CraftContainer extends AbstractContainerMenu {
return inventory.getType();
}

+ // Paper start
+ @Override
@Override
- public String getTitle() {
+ public net.kyori.adventure.text.Component title() {
+ return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).title() : net.kyori.adventure.text.Component.text(inventory.getType().getDefaultTitle());
+ }
return this.title;
}

@Override
- public String getOriginalTitle() {
+ public net.kyori.adventure.text.Component originalTitle() {
return this.originalTitle;
}

@Override
- public void setTitle(String title) {
+ public void setTitle(final net.kyori.adventure.text.Component title) {
CraftInventoryView.sendInventoryTitleChange(this, title);
this.title = title;
}
+ // Paper end
+
@Override
public String getTitle() {
return this.title;
+ @Override
+ public String getTitle() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.title); // Paper
+ }
+
+ @Override
+ public String getOriginalTitle() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.originalTitle); // Paper
+ }
+
+ @Override
+ public void setTitle(String title) {
+ this.setTitle(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacyAmpersand().deserialize(title)); // Paper
+ }

}, player, id);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index c9cc23757a9fcc58d30b2915d4c5cfbc7d1c767a..fc0e1212022d1aa3506699b60ef338196eb54eba 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
Expand Down Expand Up @@ -4830,23 +4869,88 @@ index c9cc23757a9fcc58d30b2915d4c5cfbc7d1c767a..fc0e1212022d1aa3506699b60ef33819
return this.title;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java
index 4dd9a80af9901287ab6740b072f2b89678c3d0cb..b2586684295b295a3196a2a9cf724cec975b5a40 100644
index 4dd9a80af9901287ab6740b072f2b89678c3d0cb..c46e314153fc56839c9dcc3216de47afceefcb2b 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java
@@ -73,6 +73,13 @@ public class CraftInventoryView extends InventoryView {
@@ -19,15 +19,15 @@ public class CraftInventoryView extends InventoryView {
private final AbstractContainerMenu container;
private final CraftHumanEntity player;
private final CraftInventory viewing;
- private final String originalTitle;
- private String title;
+ private final net.kyori.adventure.text.Component originalTitle; // Paper
+ private net.kyori.adventure.text.Component title; // Paper

public CraftInventoryView(HumanEntity player, Inventory viewing, AbstractContainerMenu container) {
// TODO: Should we make sure it really IS a CraftHumanEntity first? And a CraftInventory?
this.player = (CraftHumanEntity) player;
this.viewing = (CraftInventory) viewing;
this.container = container;
- this.originalTitle = CraftChatMessage.fromComponent(container.getTitle());
+ this.originalTitle = io.papermc.paper.adventure.PaperAdventure.asAdventure(this.container.getTitle()); // Paper
this.title = this.originalTitle;
}

@@ -73,21 +73,38 @@ public class CraftInventoryView extends InventoryView {
return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem());
}

+ // Paper start
+ @Override
@Override
- public String getTitle() {
+ public net.kyori.adventure.text.Component title() {
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.container.getTitle());
+ }
return this.title;
}

@Override
- public String getOriginalTitle() {
+ public net.kyori.adventure.text.Component originalTitle() {
return this.originalTitle;
}

@Override
- public void setTitle(String title) {
+ public void setTitle(final net.kyori.adventure.text.Component title) {
CraftInventoryView.sendInventoryTitleChange(this, title);
this.title = title;
}
+ // Paper end
+
@Override
public String getTitle() {
return this.title;
+ @Override
+ public String getTitle() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.title); // Paper
+ }
+
+ @Override
+ public String getOriginalTitle() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.originalTitle); // Paper
+ }
+
+ @Override
+ public void setTitle(String title) {
+ this.setTitle(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(title)); // Paper
+ }

public boolean isInTop(int rawSlot) {
return rawSlot < this.viewing.getSize();
@@ -97,7 +114,7 @@ public class CraftInventoryView extends InventoryView {
return this.container;
}

- public static void sendInventoryTitleChange(InventoryView view, String title) {
+ public static void sendInventoryTitleChange(InventoryView view, net.kyori.adventure.text.Component title) { // Paper
Preconditions.checkArgument(view != null, "InventoryView cannot be null");
Preconditions.checkArgument(title != null, "Title cannot be null");
Preconditions.checkArgument(view.getPlayer() instanceof Player, "NPCs are not currently supported for this function");
@@ -106,7 +123,7 @@ public class CraftInventoryView extends InventoryView {
final ServerPlayer entityPlayer = (ServerPlayer) ((CraftHumanEntity) view.getPlayer()).getHandle();
final int containerId = entityPlayer.containerMenu.containerId;
final MenuType<?> windowType = CraftContainer.getNotchInventoryType(view.getTopInventory());
- entityPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, windowType, CraftChatMessage.fromString(title)[0]));
+ entityPlayer.connection.send(new ClientboundOpenScreenPacket(containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(title))); // Paper
((Player) view.getPlayer()).updateInventory();
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
index d2c54674711f5d4b0273de628cc6d244969de057..0875dfe89644f5f54d004488ed980092b31c6416 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
Expand Down
19 changes: 5 additions & 14 deletions patches/server/0269-Restore-custom-InventoryHolder-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -161,28 +161,19 @@ index 0000000000000000000000000000000000000000..224d4b2cc45b0d02230a76caee9c8857
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
index 39be45585835eabc8d8bcae0158c094c3dcb1aa3..977b77547f7ba62cef3640cf8d4f1c8e7cded53a 100644
index 850c2142b72340f9dc595d7340fc5a55a5ddb735..b552ecb37838da386929de27bc6f261ae00ca012 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
@@ -50,7 +50,7 @@ public class CraftContainer extends AbstractContainerMenu {
public CraftContainer(final Inventory inventory, final Player player, int id) {
this(new InventoryView() {

- private final String originalTitle = (inventory instanceof CraftInventoryCustom) ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle();
+ private final String originalTitle = inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom) inventory).getTitle() : inventory.getType().getDefaultTitle(); // Paper
private String title = this.originalTitle;
- private final net.kyori.adventure.text.Component originalTitle = (inventory instanceof CraftInventoryCustom) ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).title() : net.kyori.adventure.text.Component.text(inventory.getType().getDefaultTitle()); // Paper
+ private final net.kyori.adventure.text.Component originalTitle = (inventory instanceof CraftInventoryCustom) ? ((CraftInventoryCustom) inventory).title() : inventory.getType().defaultTitle(); // Paper
private net.kyori.adventure.text.Component title = this.originalTitle; // Paper

@Override
@@ -76,7 +76,7 @@ public class CraftContainer extends AbstractContainerMenu {
// Paper start
@Override
public net.kyori.adventure.text.Component title() {
- return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).title() : net.kyori.adventure.text.Component.text(inventory.getType().getDefaultTitle());
+ return inventory instanceof CraftInventoryCustom custom ? custom.title() : inventory.getType().defaultTitle(); // Paper
}
// Paper end

@@ -253,6 +253,10 @@ public class CraftContainer extends AbstractContainerMenu {
@@ -263,6 +263,10 @@ public class CraftContainer extends AbstractContainerMenu {
this.lastSlots = this.delegate.lastSlots;
this.slots = this.delegate.slots;
this.remoteSlots = this.delegate.remoteSlots;
Expand Down