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

Commit

Permalink
更新到 1.5.4: 修复关闭者 unregister 函数导致多次 closeInventory 报错的 bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
u2g committed Dec 17, 2016
1 parent 0a4b02f commit 631a9b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/com/minecraft/moonlake/gui/api/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -978,4 +978,10 @@ public interface GUI {
*/
@Deprecated
void unregister();

/**
* 将次 GUI 对象从对象集合卸载
* @param closer 关闭者
*/
void unregister(Player closer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void onClose(InventoryCloseEvent event) {
}
if(gui.isCloseToUnregister()) {

gui.unregister();
gui.unregister(target);
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/com/minecraft/moonlake/gui/util/GUIReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 631a9b3

Please sign in to comment.