"Listener already listening"

Discussion in 'Plugin Development' started by Y_U_NO_DIG, Sep 24, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Y_U_NO_DIG

    Whenever I Join My Server With this plugin enabled, I get a console error and get disconnected.

    Error:
    Code:
    [17:49:23 WARN]: Failed to handle packet for /127.0.0.1:51989
    
    java.lang.IllegalArgumentException: Listener already listening
    
        at net.minecraft.server.v1_8_R3.Container.addSlotListener(Container.java:55) ~[craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.EntityPlayer.syncInventory(EntityPlayer.java:159) ~[craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:159) ~[craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:115) ~[craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:53) ~[craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:222) ~[craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.ServerConnection.c(SourceFile:168) [craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:744) [craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:628) [craftbukkit.jar:git-Bukkit-880a532]
    
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:536) [craftbukkit.jar:git-Bukkit-880a532]
    
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]
    

    My Code:
    Code:
    package com.Y_U_NO_DIG
    
    
    
    import org.bukkit.Bukkit;
    
    import org.bukkit.ChatColor;
    
    import org.bukkit.Material;
    
    import org.bukkit.entity.Player;
    
    import org.bukkit.event.EventHandler;
    
    import org.bukkit.event.Listener;
    
    import org.bukkit.event.inventory.InventoryClickEvent;
    
    import org.bukkit.event.player.PlayerJoinEvent;
    
    import org.bukkit.inventory.Inventory;
    
    import org.bukkit.inventory.ItemStack;
    
    import org.bukkit.inventory.meta.ItemMeta;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    
    
    public class AgesClash extends JavaPlugin implements Listener{
    
     
    
        public static Inventory chooseClass = Bukkit.createInventory(null,27,"ChooseClass");
    
     
    
        public void onEnable(){
    
            getLogger().info("The Plugin Is Enabled!");
    
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
    
        }
    
     
    
     
    
     
    
     
    
        public static void createDisplay(Material material, Inventory inv, String name) {
    
         
    
            ItemStack ironBladeIcon = new ItemStack(Material.IRON_SWORD);
    
            ItemStack trembleHawkIcon = new ItemStack(Material.BOW);
    
            ItemStack nightCloakIcon = new ItemStack(Material.LEATHER_CHESTPLATE);
    
         
    
            ItemMeta ironBladeMeta = ironBladeIcon.getItemMeta();
    
            ironBladeMeta.setDisplayName(ChatColor.DARK_GRAY + "Iron" + ChatColor.DARK_RED + "Blade");
    
         
    
            ItemMeta trembleHawkMeta = trembleHawkIcon.getItemMeta();
    
            trembleHawkMeta.setDisplayName(ChatColor.GREEN + "Tremble" + ChatColor.GOLD + "Hawk");
    
         
    
            ItemMeta nightCloakMeta = nightCloakIcon.getItemMeta();
    
            nightCloakMeta.setDisplayName(ChatColor.DARK_BLUE + "Night" + ChatColor.DARK_GRAY + "Cloak");
    
         
    
         
    
            ironBladeIcon.setItemMeta(ironBladeMeta);
    
            trembleHawkIcon.setItemMeta(trembleHawkMeta);
    
            nightCloakIcon.setItemMeta(nightCloakMeta);
    
         
    
            chooseClass.setItem(2, ironBladeIcon);
    
            chooseClass.setItem(5, ironBladeIcon);
    
            chooseClass.setItem(7, ironBladeIcon);
    
        }
    
     
    
     
    
     
    
     
    
     
    
        @EventHandler
    
        public void onJoin(PlayerJoinEvent e){
    
            Player player = e.getPlayer();
    
            player.openInventory(chooseClass);
    
        }
    
     
    
     
    
        public void clickInv(InventoryClickEvent e){
    
            Player player =(Player) e.getWhoClicked();
    
            ItemStack clicked = e.getCurrentItem();
    
            Inventory currentInv = e.getInventory();
    
            if (currentInv.getName().equals(chooseClass.getName())) {
    
                if(clicked.getType() == Material.IRON_SWORD) {
    
                    e.setCancelled(true);
    
                player.closeInventory();
    
             
    
             
    
             
    
             
    
                }else{
    
                 
    
                    if(clicked.getType() == Material.BOW) {
    
                    e.setCancelled(true);
    
                    player.closeInventory();
    
             
    
                 
    
                     
    
                    }else {
    
                     
    
                        if(clicked.getType() == Material.LEATHER_CHESTPLATE) {
    
                            e.setCancelled(true);
    
                            player.closeInventory();
    
                     
    
                         
    
                     
    
                     
    
                    }
    
                 
    
            }
    
             
    
            }
    
         
    
         
    
        }
    
     
    
     
    
    }
    
    }
    
    
    
      

    Anyone know why? Thank You!
     
    Last edited: Sep 24, 2015
  2. Offline

    Lolmewn Retired Staff

    Your inventory has no InventoryHolder passed along to it? Is that even allowed?
     
  3. Offline

    Y_U_NO_DIG

    I am quite new to Bukkit, how would I pass an InventoryHolder?
     
  4. Offline

    RoboticPlayer

    Do you have basic knowledge of Java?
     
  5. Offline

    finalblade1234

    @Y_U_NO_DIG Setting an InventoryHolder to null is fine, Try making a BukkitRunnable and then executing the code, the players inventory may not be fully loaded in.
     
  6. Offline

    Tecno_Wizard

  7. Offline

    Y_U_NO_DIG

    Thanks for the help everyone, and sorry Tecno_Wizard I wasn't aware if that.
     
  8. Offline

    boomboompower

  9. Offline

    Tecno_Wizard

    @boomboompower, more often than not the copy and paste causes that, not because it is written like that.
     
  10. Offline

    teej107

    Yes, it's allowed.
     
    boomboompower likes this.
Thread Status:
Not open for further replies.

Share This Page