diff --git a/plugin.yml b/plugin.yml index eb6d13d..d3fd034 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: MoonLakeGUI main: com.minecraft.moonlake.gui.GUIPlugin -version: 1.5.3 +version: 1.5.4 author: Month_Light website: http://www.mcyszh.com diff --git a/src/com/minecraft/moonlake/gui/api/GUI.java b/src/com/minecraft/moonlake/gui/api/GUI.java index 9d07aa1..fe6556d 100644 --- a/src/com/minecraft/moonlake/gui/api/GUI.java +++ b/src/com/minecraft/moonlake/gui/api/GUI.java @@ -978,4 +978,10 @@ public interface GUI { */ @Deprecated void unregister(); + + /** + * 将次 GUI 对象从对象集合卸载 + * @param closer 关闭者 + */ + void unregister(Player closer); } diff --git a/src/com/minecraft/moonlake/gui/listeners/InventoryListener.java b/src/com/minecraft/moonlake/gui/listeners/InventoryListener.java index 4911a29..99faa09 100644 --- a/src/com/minecraft/moonlake/gui/listeners/InventoryListener.java +++ b/src/com/minecraft/moonlake/gui/listeners/InventoryListener.java @@ -98,7 +98,7 @@ public void onClose(InventoryCloseEvent event) { } if(gui.isCloseToUnregister()) { - gui.unregister(); + gui.unregister(target); } } diff --git a/src/com/minecraft/moonlake/gui/util/GUIReference.java b/src/com/minecraft/moonlake/gui/util/GUIReference.java index 819818a..d701f48 100644 --- a/src/com/minecraft/moonlake/gui/util/GUIReference.java +++ b/src/com/minecraft/moonlake/gui/util/GUIReference.java @@ -1579,9 +1579,20 @@ public void register() { @Deprecated public void unregister() { + unregister(null); + } + + /** + * 将次 GUI 对象从对象集合卸载 + * + * @param closer 关闭者 + */ + @Override + public void unregister(Player closer) { + for(final Player player : getViewers()) { - if(player != null) { + if(player != null && !player.equals(closer)) { player.closeInventory(); }