diff --git a/common/src/main/java/com/lishid/openinv/internal/PlayerManager.java b/common/src/main/java/com/lishid/openinv/internal/PlayerManager.java index d1d3c6c0..e999eda5 100644 --- a/common/src/main/java/com/lishid/openinv/internal/PlayerManager.java +++ b/common/src/main/java/com/lishid/openinv/internal/PlayerManager.java @@ -49,6 +49,6 @@ public interface PlayerManager { *` * @return the InventoryView opened */ - @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory); + @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory, boolean viewOnly); } diff --git a/internal/v1_20_R3/src/main/java/com/lishid/openinv/internal/v1_20_R3/PlayerManager.java b/internal/v1_20_R3/src/main/java/com/lishid/openinv/internal/v1_20_R3/PlayerManager.java index db93c97f..0df4c729 100644 --- a/internal/v1_20_R3/src/main/java/com/lishid/openinv/internal/v1_20_R3/PlayerManager.java +++ b/internal/v1_20_R3/src/main/java/com/lishid/openinv/internal/v1_20_R3/PlayerManager.java @@ -239,7 +239,7 @@ private void injectPlayer(ServerPlayer player) throws IllegalAccessException { } @Override - public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) { + public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory, boolean viewOnly) { ServerPlayer nmsPlayer = getHandle(player); diff --git a/internal/v1_20_R4/src/main/java/com/lishid/openinv/internal/v1_20_R4/PlayerManager.java b/internal/v1_20_R4/src/main/java/com/lishid/openinv/internal/v1_20_R4/PlayerManager.java index 1ff8b4e9..755500db 100644 --- a/internal/v1_20_R4/src/main/java/com/lishid/openinv/internal/v1_20_R4/PlayerManager.java +++ b/internal/v1_20_R4/src/main/java/com/lishid/openinv/internal/v1_20_R4/PlayerManager.java @@ -239,7 +239,7 @@ private void injectPlayer(ServerPlayer player) throws IllegalAccessException { } @Override - public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) { + public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory, boolean viewOnly) { ServerPlayer nmsPlayer = getHandle(player); diff --git a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenEnderChest.java b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenEnderChest.java index eefaf3ed..3d495735 100644 --- a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenEnderChest.java +++ b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenEnderChest.java @@ -9,8 +9,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.ContainerHelper; -import net.minecraft.world.MenuProvider; -import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.StackedContents; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -27,8 +25,8 @@ import java.util.ArrayList; import java.util.List; -public class OpenEnderChest implements Container, StackedContentsCompatible, MenuProvider, - InternalOwned, ISpecialEnderChest { +public class OpenEnderChest implements Container, StackedContentsCompatible, InternalOwned, + ISpecialEnderChest { private CraftInventory inventory; private @NotNull ServerPlayer owner; @@ -182,17 +180,15 @@ public void fillStackedContents(StackedContents stackedContents) { } } - @Override - public Component getDisplayName() { + public Component getTitle() { return Component.translatableWithFallback("openinv.container.enderchest.prefix", "", owner.getName()) .append(Component.translatable("container.enderchest")) .append(Component.translatableWithFallback("openinv.container.enderchest.suffix", " - %s", owner.getName())); } - @Override - public @Nullable AbstractContainerMenu createMenu(int i, Inventory inventory, Player player) { + public @Nullable AbstractContainerMenu createMenu(Player player, int i, boolean viewOnly) { if (player instanceof ServerPlayer serverPlayer) { - return new OpenEnderChestMenu(this, serverPlayer, i); + return new OpenEnderChestMenu(this, serverPlayer, i, viewOnly); } return null; } diff --git a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenInventory.java b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenInventory.java index 8461901c..748038a6 100644 --- a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenInventory.java +++ b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/OpenInventory.java @@ -4,7 +4,6 @@ import com.lishid.openinv.internal.InternalOwned; import com.lishid.openinv.internal.v1_21_R1.container.bukkit.OpenPlayerInventory; import com.lishid.openinv.internal.v1_21_R1.container.menu.OpenInventoryMenu; -import com.lishid.openinv.internal.v1_21_R1.player.PlayerManager; import com.lishid.openinv.internal.v1_21_R1.container.slot.Content; import com.lishid.openinv.internal.v1_21_R1.container.slot.ContentCrafting; import com.lishid.openinv.internal.v1_21_R1.container.slot.ContentCraftingResult; @@ -15,6 +14,7 @@ import com.lishid.openinv.internal.v1_21_R1.container.slot.ContentOffHand; import com.lishid.openinv.internal.v1_21_R1.container.slot.ContentViewOnly; import com.lishid.openinv.internal.v1_21_R1.container.slot.SlotViewOnly; +import com.lishid.openinv.internal.v1_21_R1.player.PlayerManager; import net.minecraft.ChatFormatting; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; @@ -22,7 +22,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; -import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -40,7 +39,7 @@ import java.util.ArrayList; import java.util.List; -public class OpenInventory implements Container, MenuProvider, InternalOwned, ISpecialPlayerInventory { +public class OpenInventory implements Container, InternalOwned, ISpecialPlayerInventory { private final List slots; private final int size; @@ -355,15 +354,9 @@ public void clearContent() { owner.containerMenu.setCarried(ItemStack.EMPTY); } - @Override - public Component getDisplayName() { - return getTitle(null); - } - - @Override - public @Nullable AbstractContainerMenu createMenu(int i, Inventory inventory, Player player) { + public @Nullable AbstractContainerMenu createMenu(Player player, int i, boolean viewOnly) { if (player instanceof ServerPlayer serverPlayer) { - return new OpenInventoryMenu(this, serverPlayer, i); + return new OpenInventoryMenu(this, serverPlayer, i, viewOnly); } return null; } diff --git a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenChestMenu.java b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenChestMenu.java index 9f42d07f..cf95822c 100644 --- a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenChestMenu.java +++ b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenChestMenu.java @@ -54,13 +54,18 @@ public abstract class OpenChestMenu type, int containerCounter, T container, ServerPlayer viewer) { + protected OpenChestMenu( + @NotNull MenuType type, + int containerCounter, + @NotNull T container, + @NotNull ServerPlayer viewer, + boolean viewOnly) { super(type, containerCounter); this.container = container; this.viewer = viewer; + this.viewOnly = viewOnly; ownContainer = container.getOwnerHandle().equals(viewer); topSize = getTopSize(viewer); - viewOnly = checkViewOnly(); preSlotSetup(); @@ -116,8 +121,6 @@ protected OpenChestMenu(MenuType type, int containerCounter, T contai }; } - protected abstract boolean checkViewOnly(); - protected void preSlotSetup() {} protected @NotNull Slot getUpperSlot(int index, int x, int y) { diff --git a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenEnderChestMenu.java b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenEnderChestMenu.java index 488909ed..172f42ea 100644 --- a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenEnderChestMenu.java +++ b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenEnderChestMenu.java @@ -1,22 +1,20 @@ package com.lishid.openinv.internal.v1_21_R1.container.menu; import com.lishid.openinv.internal.v1_21_R1.container.OpenEnderChest; -import com.lishid.openinv.util.Permissions; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; public class OpenEnderChestMenu extends OpenChestMenu { - public OpenEnderChestMenu(OpenEnderChest enderChest, ServerPlayer viewer, int containerId) { - super(getChestMenuType(enderChest.getContainerSize()), containerId, enderChest, viewer); - } - - @Override - protected boolean checkViewOnly() { - return !(ownContainer ? Permissions.ENDERCHEST_EDIT_SELF : Permissions.ENDERCHEST_OPEN_OTHER) - .hasPermission(viewer.getBukkitEntity()); + public OpenEnderChestMenu( + @NotNull OpenEnderChest enderChest, + @NotNull ServerPlayer viewer, + int containerId, + boolean viewOnly) { + super(getChestMenuType(enderChest.getContainerSize()), containerId, enderChest, viewer, viewOnly); } @Override diff --git a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenInventoryMenu.java b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenInventoryMenu.java index 3c11fe91..ffbea9d0 100644 --- a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenInventoryMenu.java +++ b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/container/menu/OpenInventoryMenu.java @@ -26,8 +26,8 @@ public class OpenInventoryMenu extends OpenChestMenu { private int offset; - public OpenInventoryMenu(OpenInventory inventory, ServerPlayer viewer, int i) { - super(getMenuType(inventory, viewer), i, inventory, viewer); + public OpenInventoryMenu(OpenInventory inventory, ServerPlayer viewer, int i, boolean viewOnly) { + super(getMenuType(inventory, viewer), i, inventory, viewer, viewOnly); } private static MenuType getMenuType(OpenInventory inventory, ServerPlayer viewer) { @@ -97,12 +97,6 @@ protected void preSlotSetup() { return slot; } - @Override - protected boolean checkViewOnly() { - return !(ownContainer ? Permissions.INVENTORY_EDIT_SELF : Permissions.INVENTORY_EDIT_OTHER) - .hasPermission(viewer.getBukkitEntity()); - } - @Override protected @NotNull CraftInventoryView> createBukkitEntity() { org.bukkit.inventory.Inventory bukkitInventory; diff --git a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/player/PlayerManager.java b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/player/PlayerManager.java index 64fe5bb6..1eae5f04 100644 --- a/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/player/PlayerManager.java +++ b/internal/v1_21_R1/src/main/java/com/lishid/openinv/internal/v1_21_R1/player/PlayerManager.java @@ -13,7 +13,6 @@ import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -219,35 +218,34 @@ private void injectPlayer(ServerPlayer player) throws IllegalAccessException { } @Override - public @Nullable InventoryView openInventory(@NotNull Player bukkitPlayer, @NotNull ISpecialInventory inventory) { + public @Nullable InventoryView openInventory(@NotNull Player bukkitPlayer, @NotNull ISpecialInventory inventory, boolean viewOnly) { ServerPlayer player = getHandle(bukkitPlayer); if (player.connection == null) { return null; } - MenuProvider provider; + // See net.minecraft.server.level.ServerPlayer#openMenu(MenuProvider) + AbstractContainerMenu menu; Component title; if (inventory instanceof OpenInventory playerInv) { - provider = playerInv; + menu = playerInv.createMenu(player, player.nextContainerCounter(), viewOnly); title = playerInv.getTitle(player); } else if (inventory instanceof OpenEnderChest enderChest) { - provider = enderChest; - title = enderChest.getDisplayName(); + menu = enderChest.createMenu(player, player.nextContainerCounter(), viewOnly); + title = enderChest.getTitle(); } else { return null; } - // See net.minecraft.server.level.ServerPlayer#openMenu(MenuProvider) - AbstractContainerMenu menu = provider.createMenu(player.nextContainerCounter(), player.getInventory(), player); - // Should never happen, player is a ServerPlayer with an active connection. if (menu == null) { return null; } - // Set up title (the whole reason we're not just using Player#openInventory(Inventory)). - // Title can only be set once for a menu, and is set during the open process. + // Set up title. Title can only be set once for a menu, and is set during the open process. + // Further title changes are a hack where the client is sent a "new" inventory with the same ID, + // resulting in a title change but no other state modifications (like cursor position). menu.setTitle(title); menu = CraftEventFactory.callInventoryOpenEvent(player, menu, false); diff --git a/plugin/src/main/java/com/lishid/openinv/OpenInv.java b/plugin/src/main/java/com/lishid/openinv/OpenInv.java index e8a0bee5..45a2129f 100644 --- a/plugin/src/main/java/com/lishid/openinv/OpenInv.java +++ b/plugin/src/main/java/com/lishid/openinv/OpenInv.java @@ -30,20 +30,23 @@ import com.lishid.openinv.listener.ContainerListener; import com.lishid.openinv.listener.LegacyInventoryListener; import com.lishid.openinv.listener.ToggleListener; -import com.lishid.openinv.util.config.Config; -import com.lishid.openinv.util.config.ConfigUpdater; +import com.lishid.openinv.util.AccessEqualMode; import com.lishid.openinv.util.InternalAccessor; import com.lishid.openinv.util.InventoryManager; -import com.lishid.openinv.util.lang.LangMigrator; +import com.lishid.openinv.util.Permissions; import com.lishid.openinv.util.PlayerLoader; +import com.lishid.openinv.util.config.Config; +import com.lishid.openinv.util.config.ConfigUpdater; +import com.lishid.openinv.util.lang.LangMigrator; +import com.lishid.openinv.util.lang.LanguageManager; import com.lishid.openinv.util.setting.PlayerToggle; import com.lishid.openinv.util.setting.PlayerToggles; -import com.lishid.openinv.util.lang.LanguageManager; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; import org.bukkit.plugin.PluginManager; @@ -143,7 +146,7 @@ private void registerEvents() { PluginManager pluginManager = this.getServer().getPluginManager(); // Legacy: extra listener for permission handling and self-view issue prevention. if (BukkitVersions.MINECRAFT.lessThan(Version.of(1, 21))) { - pluginManager.registerEvents(new LegacyInventoryListener(this), this); + pluginManager.registerEvents(new LegacyInventoryListener(this, config), this); } pluginManager.registerEvents(playerLoader, this); pluginManager.registerEvents(inventoryManager, this); @@ -248,7 +251,44 @@ public void setSilentContainerStatus(@NotNull final OfflinePlayer offline, final @Override public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) { - return this.accessor.openInventory(player, inventory); + Permissions edit = null; + HumanEntity target = inventory.getPlayer(); + boolean ownContainer = player.equals(target); + if (inventory instanceof ISpecialPlayerInventory) { + edit = ownContainer ? Permissions.INVENTORY_EDIT_SELF : Permissions.INVENTORY_EDIT_OTHER; + } else if (inventory instanceof ISpecialEnderChest) { + edit = ownContainer ? Permissions.ENDERCHEST_EDIT_SELF : Permissions.ENDERCHEST_OPEN_OTHER; + } + + boolean viewOnly = edit != null && !edit.hasPermission(player); + + if (!ownContainer && !viewOnly) { + for (int level = 4; level > 0; --level) { + String permission = "openinv.access.level." + level; + // If the target doesn't have this access level... + if (!target.hasPermission(permission)) { + // If the viewer does have the access level, all good. + if (player.hasPermission(permission)) { + break; + } + // Otherwise check next access level. + continue; + } + + // If the player doesn't have an equal access level or equal access is a denial, deny. + if (!player.hasPermission(permission) || config.getAccessEqualMode() == AccessEqualMode.DENY) { + return null; + } + + // Since this is a tie, setting decides view state. + if (config.getAccessEqualMode() == AccessEqualMode.VIEW) { + viewOnly = true; + } + break; + } + } + + return this.accessor.openInventory(player, inventory, viewOnly); } @Override diff --git a/plugin/src/main/java/com/lishid/openinv/listener/LegacyInventoryListener.java b/plugin/src/main/java/com/lishid/openinv/listener/LegacyInventoryListener.java index b503788a..38728dad 100644 --- a/plugin/src/main/java/com/lishid/openinv/listener/LegacyInventoryListener.java +++ b/plugin/src/main/java/com/lishid/openinv/listener/LegacyInventoryListener.java @@ -1,12 +1,13 @@ package com.lishid.openinv.listener; import com.google.errorprone.annotations.Keep; -import com.lishid.openinv.OpenInv; import com.lishid.openinv.internal.ISpecialEnderChest; import com.lishid.openinv.internal.ISpecialInventory; import com.lishid.openinv.internal.ISpecialPlayerInventory; +import com.lishid.openinv.util.AccessEqualMode; import com.lishid.openinv.util.InventoryAccess; import com.lishid.openinv.util.Permissions; +import com.lishid.openinv.util.config.Config; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -19,11 +20,11 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -32,10 +33,12 @@ */ public class LegacyInventoryListener implements Listener { - private final @NotNull OpenInv plugin; + private final @NotNull Plugin plugin; + private final @NotNull Config config; - public LegacyInventoryListener(@NotNull OpenInv plugin) { + public LegacyInventoryListener(@NotNull Plugin plugin, @NotNull Config config) { this.plugin = plugin; + this.config = config; } @Keep @@ -150,35 +153,55 @@ private int getCountDiff(@Nullable ItemStack original, @NotNull ItemStack result * @return true unless the top inventory is the holder's own inventory */ private boolean handleInventoryInteract(@NotNull final InventoryInteractEvent event) { - HumanEntity entity = event.getWhoClicked(); + HumanEntity viewer = event.getWhoClicked(); Inventory inventory = event.getView().getTopInventory(); ISpecialInventory backing = InventoryAccess.getInventory(inventory); - Permissions editSelf; - Permissions editOther; - if (backing instanceof ISpecialEnderChest) { - editSelf = Permissions.ENDERCHEST_EDIT_SELF; - editOther = Permissions.ENDERCHEST_EDIT_OTHER; - } else if (backing instanceof ISpecialPlayerInventory) { - editSelf = Permissions.INVENTORY_EDIT_SELF; - editOther = Permissions.INVENTORY_EDIT_OTHER; + + if (backing == null) { + return true; + } + + Permissions edit; + HumanEntity target = backing.getPlayer(); + boolean ownContainer = viewer.equals(target); + if (backing instanceof ISpecialPlayerInventory) { + edit = ownContainer ? Permissions.INVENTORY_EDIT_SELF : Permissions.INVENTORY_EDIT_OTHER; + } else if (backing instanceof ISpecialEnderChest) { + edit = ownContainer ? Permissions.ENDERCHEST_EDIT_SELF : Permissions.ENDERCHEST_OPEN_OTHER; } else { // Unknown implementation. return true; } - if (Objects.equals(entity, backing.getPlayer())) { - if (!editSelf.hasPermission(entity)) { - event.setCancelled(true); - return true; - } - return !(backing instanceof ISpecialPlayerInventory); - } else { - if (!editOther.hasPermission(entity)) { - event.setCancelled(true); + if (!edit.hasPermission(viewer)) { + event.setCancelled(true); + return true; + } + + // If access ties aren't view-only mode, don't bother with permission checks. + if (config.getAccessEqualMode() != AccessEqualMode.VIEW) { + return !ownContainer || !(backing instanceof ISpecialPlayerInventory); + } + + for (int level = 4; level > 0; --level) { + String permission = "openinv.access.level." + level; + // If the target doesn't have this access level... + if (!target.hasPermission(permission)) { + // If the viewer does have the access level, all good. + if (viewer.hasPermission(permission)) { + break; + } + // Otherwise check next access level. + continue; } + + // Either the viewer lacks access (which shouldn't be possible) or this is a tie. View-only. + event.setCancelled(true); return true; } + + return !ownContainer || !(backing instanceof ISpecialPlayerInventory); } private static int convertToPlayerSlot(InventoryView view, int rawSlot) { diff --git a/plugin/src/main/java/com/lishid/openinv/util/AccessEqualMode.java b/plugin/src/main/java/com/lishid/openinv/util/AccessEqualMode.java index 8d14d5d8..8d36652a 100644 --- a/plugin/src/main/java/com/lishid/openinv/util/AccessEqualMode.java +++ b/plugin/src/main/java/com/lishid/openinv/util/AccessEqualMode.java @@ -7,15 +7,16 @@ public enum AccessEqualMode { - DENY, ALLOW; + DENY, ALLOW, VIEW; public static @NotNull AccessEqualMode of(@Nullable String value) { if (value == null) { - return ALLOW; + return VIEW; } return switch (value.toLowerCase(Locale.ENGLISH)) { case "deny", "false" -> DENY; - default -> ALLOW; + case "allow", "true" -> ALLOW; + default -> VIEW; }; } diff --git a/plugin/src/main/java/com/lishid/openinv/util/InternalAccessor.java b/plugin/src/main/java/com/lishid/openinv/util/InternalAccessor.java index 1a207585..1e177d9b 100644 --- a/plugin/src/main/java/com/lishid/openinv/util/InternalAccessor.java +++ b/plugin/src/main/java/com/lishid/openinv/util/InternalAccessor.java @@ -163,11 +163,11 @@ public boolean isSupported() { return internal.getAnySilentContainer(); } - public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) { + public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory, boolean viewOnly) { if (internal == null) { throw new IllegalStateException(String.format("Unsupported server version %s!", BukkitVersions.MINECRAFT)); } - return internal.getPlayerManager().openInventory(player, inventory); + return internal.getPlayerManager().openInventory(player, inventory, viewOnly); } /** diff --git a/plugin/src/main/java/com/lishid/openinv/util/config/ConfigUpdater.java b/plugin/src/main/java/com/lishid/openinv/util/config/ConfigUpdater.java index 0f9237e6..a4b15147 100644 --- a/plugin/src/main/java/com/lishid/openinv/util/config/ConfigUpdater.java +++ b/plugin/src/main/java/com/lishid/openinv/util/config/ConfigUpdater.java @@ -71,7 +71,7 @@ public void checkForUpdates() { private void updateConfig7To8() { FileConfiguration config = plugin.getConfig(); - config.set("settings.equal-access", "allow"); + config.set("settings.equal-access", "view"); config.set("config-version", 8); } diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index a69d6d62..fb8b4b08 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -1,6 +1,6 @@ config-version: 8 settings: - equal-access: allow + equal-access: view command: open: no-args-opens-self: false