Skip to content

Commit

Permalink
Catch GUIMenu errors and close the menu if they occur
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 27, 2022
1 parent d1bc232 commit 79d7dd6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/main/java/net/citizensnpcs/api/gui/InventoryMenu.java
Expand Up @@ -324,7 +324,12 @@ public void onInventoryClick(InventoryClickEvent event) {
if (page == null || transitioning || closingViews)
return;
delayViewerChanges = true;
handleClick(event);
try {
handleClick(event);
} catch (Exception ex) {
ex.printStackTrace();
event.getWhoClicked().closeInventory();
}
delayViewerChanges = false;
}

Expand Down
8 changes: 1 addition & 7 deletions src/main/java/net/citizensnpcs/api/util/MemoryDataKey.java
Expand Up @@ -7,7 +7,6 @@
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;

import com.google.common.base.Function;
import com.google.common.collect.Iterables;

public class MemoryDataKey extends DataKey {
Expand Down Expand Up @@ -101,12 +100,7 @@ public Iterable<DataKey> getSubKeys() {
if (head == null)
return Collections.emptyList();
Set<String> keys = head.getKeys(false);
return Iterables.transform(keys, new Function<String, DataKey>() {
@Override
public DataKey apply(String input) {
return new MemoryDataKey(root, getKeyFor(input));
}
});
return Iterables.transform(keys, input -> new MemoryDataKey(root, getKeyFor(input)));
}

@Override
Expand Down
Expand Up @@ -210,6 +210,8 @@ public static class InferenceTest {
}

public static class ListTest {
@Persist
private List<Map> mapTest;
@Persist
private List<String> test;
}
Expand Down

0 comments on commit 79d7dd6

Please sign in to comment.