Add method to access owner

Makes handling ISpecialInventory ownership much more consistent with a lot less spaghetti.
This commit is contained in:
Jikoo
2021-03-28 11:12:49 -04:00
parent 5b18656485
commit 6c4818dfd9
5 changed files with 20 additions and 3 deletions

View File

@@ -17,7 +17,6 @@
package com.lishid.openinv.internal;
import com.lishid.openinv.OpenInv;
import java.util.Objects;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
@@ -63,7 +62,7 @@ public class OpenInventoryView extends InventoryView {
@Override
public @NotNull String getTitle() {
if (title == null) {
HumanEntity owner = (HumanEntity) Objects.requireNonNull(inventory.getBukkitInventory().getHolder());
HumanEntity owner = inventory.getPlayer();
String localTitle = OpenInv.getPlugin(OpenInv.class)
.getLocalizedMessage(

View File

@@ -199,7 +199,7 @@ public class InventoryListener implements Listener {
}
// Only specially handle actions in the player's own inventory.
return !event.getWhoClicked().equals(event.getView().getTopInventory().getHolder());
return !event.getWhoClicked().equals(playerInventory.getPlayer());
}
}