From 9978c9281b7d067de2adf34c13c715760b36e652 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Thu, 13 Jun 2024 12:36:58 -0400 Subject: [PATCH] Add new InventoryView methods --- .../openinv/internal/OpenInventoryView.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/plugin/src/main/java/com/lishid/openinv/internal/OpenInventoryView.java b/plugin/src/main/java/com/lishid/openinv/internal/OpenInventoryView.java index ea7c438e..c5743a77 100644 --- a/plugin/src/main/java/com/lishid/openinv/internal/OpenInventoryView.java +++ b/plugin/src/main/java/com/lishid/openinv/internal/OpenInventoryView.java @@ -18,7 +18,6 @@ import com.lishid.openinv.OpenInv; import com.lishid.openinv.util.lang.Replacement; -import java.util.Objects; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; @@ -26,6 +25,8 @@ import org.bukkit.inventory.InventoryView; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + public class OpenInventoryView extends InventoryView { private final @NotNull Player player; @@ -68,17 +69,28 @@ public OpenInventoryView( @Override public @NotNull String getTitle() { if (title == null) { - HumanEntity owner = inventory.getPlayer(); - - String localTitle = OpenInv.getPlugin(OpenInv.class) - .getLocalizedMessage( - player, - titleKey, - new Replacement("%player%", owner.getName())); - title = Objects.requireNonNullElseGet(localTitle, () -> owner.getName() + titleDefaultSuffix); + title = getOriginalTitle(); } return title; } + @NotNull + @Override + public String getOriginalTitle() { + HumanEntity owner = inventory.getPlayer(); + + String localTitle = OpenInv.getPlugin(OpenInv.class) + .getLocalizedMessage( + player, + titleKey, + new Replacement("%player%", owner.getName())); + return Objects.requireNonNullElseGet(localTitle, () -> owner.getName() + titleDefaultSuffix); + } + + @Override + public void setTitle(@NotNull String title) { + this.title = title; + } + }