Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit 631a9b3

Browse files
author
u2g
committed
更新到 1.5.4: 修复关闭者 unregister 函数导致多次 closeInventory 报错的 bug.
1 parent 0a4b02f commit 631a9b3

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: MoonLakeGUI
22
main: com.minecraft.moonlake.gui.GUIPlugin
3-
version: 1.5.3
3+
version: 1.5.4
44
author: Month_Light
55
website: http://www.mcyszh.com
66

src/com/minecraft/moonlake/gui/api/GUI.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,4 +978,10 @@ public interface GUI {
978978
*/
979979
@Deprecated
980980
void unregister();
981+
982+
/**
983+
* 将次 GUI 对象从对象集合卸载
984+
* @param closer 关闭者
985+
*/
986+
void unregister(Player closer);
981987
}

src/com/minecraft/moonlake/gui/listeners/InventoryListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void onClose(InventoryCloseEvent event) {
9898
}
9999
if(gui.isCloseToUnregister()) {
100100

101-
gui.unregister();
101+
gui.unregister(target);
102102
}
103103
}
104104

src/com/minecraft/moonlake/gui/util/GUIReference.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,9 +1579,20 @@ public void register() {
15791579
@Deprecated
15801580
public void unregister() {
15811581

1582+
unregister(null);
1583+
}
1584+
1585+
/**
1586+
* 将次 GUI 对象从对象集合卸载
1587+
*
1588+
* @param closer 关闭者
1589+
*/
1590+
@Override
1591+
public void unregister(Player closer) {
1592+
15821593
for(final Player player : getViewers()) {
15831594

1584-
if(player != null) {
1595+
if(player != null && !player.equals(closer)) {
15851596

15861597
player.closeInventory();
15871598
}

0 commit comments

Comments
 (0)