Skip to content

Commit 36bc761

Browse files
committed
Fix NPE
1 parent 9c3f0b0 commit 36bc761

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/java/fr/xephi/authme/listener/GuiCaptchaHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public GuiCaptchaHandler(Plugin plugin) {
6161
public void onInventoryClick(InventoryClickEvent event) {
6262
if (event.getWhoClicked() instanceof Player) {
6363
Player player = (Player) event.getWhoClicked();
64-
// 获取点击事件的容器
64+
ItemStack currentItem = event.getCurrentItem();
6565
if (!authmeApi.isRegistered(player.getName()) && !closeReasonMap.containsKey(player)) {
6666
if (AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getWhoClicked().getUniqueId()) && (getServer().getPluginManager().isPluginEnabled("floodgate") || getServer().getPluginManager().getPlugin("floodgate") != null)) {
6767
if (!closeReasonMap.containsKey(player)) {
@@ -70,8 +70,7 @@ public void onInventoryClick(InventoryClickEvent event) {
7070
}
7171
return;
7272
}
73-
/* Line 74 may throw NullPointerException, we can't solve it for now.*/
74-
if (Objects.requireNonNull(event.getCurrentItem()).getType().equals(Material.REDSTONE_BLOCK)) {
73+
if (currentItem!=null && currentItem.getType().equals(Material.REDSTONE_BLOCK)){
7574
event.setCancelled(true);
7675
closeReasonMap.put(player, "verified");
7776
player.closeInventory();

0 commit comments

Comments
 (0)