<commit_before>package me.calebbfmv.blacksmithgui.listeners;

import me.calebbfmv.blacksmithgui.gui.Button;
import me.calebbfmv.blacksmithgui.gui.GUI;
import me.calebbfmv.blacksmithgui.gui.menus.EnchantsGUI;
import me.calebbfmv.blacksmithgui.utils.EPlayer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;

/**
 * Created by Tim [calebbfmv] on 10/6/2014.
 */
public class InventoryListener implements Listener {

    @EventHandler
    public void onClick(InventoryClickEvent event){
        GUI gui = GUI.get(event.getInventory().getName());
        if(gui == null){
            return;
        }
        Player player = (Player) event.getWhoClicked();
        InventoryView view = event.getView();
        Button button = gui.getButton(event.getRawSlot());
        EPlayer ePlayer = EPlayer.get(player);
        if(ePlayer == null){
            ePlayer = new EPlayer(player);
        }
        if(button == null){
            if(ePlayer.isPromptedForItem()){
                event.setCancelled(true);
                event.setResult(Event.Result.DENY);
                if(gui instanceof EnchantsGUI) {
                    if (gui.getSize(player) < event.getRawSlot()) {
                        ItemStack clicked = event.getCurrentItem();
                        if (clicked == null || clicked.getType() == Material.AIR) {
                            return;
                        }
                        player.getInventory().setItem(event.getSlot(), null);
                        ePlayer.setChosenItem(clicked);
                        ePlayer.setPromptedForItem(false);
                        event.getInventory().setItem(16, clicked);
                    }
                }
                return;
            }
            return;
        }
        event.setCancelled(true);
        event.setResult(Event.Result.DENY);
        button.onClick(player);
    }
}
<commit_msg>Fixed NPE with InventoryListener<commit_after>package me.calebbfmv.blacksmithgui.listeners;

import me.calebbfmv.blacksmithgui.gui.Button;
import me.calebbfmv.blacksmithgui.gui.GUI;
import me.calebbfmv.blacksmithgui.gui.menus.EnchantsGUI;
import me.calebbfmv.blacksmithgui.utils.EPlayer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;

/**
 * Created by Tim [calebbfmv] on 10/6/2014.
 */
public class InventoryListener implements Listener {

    @EventHandler
    public void onClick(InventoryClickEvent event){
        GUI gui = GUI.get(event.getInventory().getName());
        if(gui == null){
            return;
        }
        Player player = (Player) event.getWhoClicked();
        InventoryView view = event.getView();
        Button button = gui.getButton(event.getRawSlot());
        EPlayer ePlayer = EPlayer.get(player);
        if(ePlayer == null){
            ePlayer = new EPlayer(player);
        }
        if(button == null){
            if(ePlayer.isPromptedForItem()){
                event.setCancelled(true);
                event.setResult(Event.Result.DENY);
                if(gui instanceof EnchantsGUI) {
                    if (gui.getSize(player) < event.getRawSlot()) {
                        ItemStack clicked = event.getCurrentItem();
                        if (clicked == null || clicked.getType() == Material.AIR) {
                            return;
                        }
                        player.getInventory().setItem(event.getSlot(), null);
                        ePlayer.setChosenItem(clicked);
                        ePlayer.setPromptedForItem(false);
                        event.getInventory().setItem(16, clicked);
                    }
                }
                return;
            }
            return;
        }
        event.setCancelled(true);
        event.setResult(Event.Result.DENY);
        button.onClick(player);
    }

    @EventHandler
    public void onClose(InventoryCloseEvent event){
        Player player = (Player) event.getPlayer();
        ItemStack item = EPlayer.get(player).getChosenItem();
        if(item == null){
            return;
        }
        if(player.getOpenInventory() != null){
            return;
        }
        player.getInventory().addItem(item);
    }
}

{'fraction_non_alphanumeric': 0.10884786760025461, 'fraction_numerical': 0.0038192234245703373, 'mean_word_length': 2.0276172125883107, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7489557', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1323, 'n_words': 218}