Minecraft Spigot having problem with CloseInventory

 @EventHandler
    public void onInteraction(PlayerInteractEvent event) {
        Player player = (Player) event.getPlayer();
       int id = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(FriendsGUI.getInstance(), new Runnable() {

            @Override
            public void run() {
                player.sendMessage("Hello " + player.getName());
            }
        }, 0, 20);
    }
    public void onCloseInventory(InventoryCloseEvent event){
        Player player = (Player) event.getPlayer();
        player.sendMessage("lul");
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(FriendsGUI.getInstance(), new Runnable() {

            @Override
            public void run() {
                player.sendMessage("Goodbye  " + player.getName());
                Bukkit.getScheduler().cancelAllTasks();

            }
        }, 0);
    }

I got the problem that close inventory is not even quietly working. Anyone, who has a better solution or a fix?

Answer

Is onInteraction working? Try adding @EventHandler to the onCloseInventory method.

Leave a Reply

Your email address will not be published. Required fields are marked *