Listener allready Listening

Discussion in 'Plugin Development' started by andre111, Jun 9, 2013.

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


    I'm getting this error:
    09.06 09:52:37 [Server] INFO at
    09.06 09:52:37 [Server] INFO at
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.MinecraftServer.q(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.DedicatedServer.r(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.MinecraftServer.r(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:29)
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.DedicatedServerConnectionThread.a(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.PendingConnection.c(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.PendingConnection.d(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.PlayerList.a(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.EntityPlayer.syncInventory(
    09.06 09:52:37 [Server] INFO at net.minecraft.server.v1_5_R3.Container.addSlotListener(
    09.06 09:52:37 [Server] INFO java.lang.IllegalArgumentException: Listener already listening
    09.06 09:52:37 [Server] WARNING Failed to handle packet for mahmod741 [/]: java.lang.IllegalArgumentException: Listener already listening
    I have no idea what that means but I think it could be somehow related to this:
    package me.andre111.dvz.utils;
    import java.util.HashMap;
    import me.andre111.dvz.DvZ;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryCloseEvent;
    import org.bukkit.inventory.Inventory;
    public class WaitingMenu implements Listener {
        public boolean closed;
        private String name;
        private DvZ plugin;
        private static int DELAY = 1;
        public WaitingMenu(DvZ plugin, String add) {
            this.plugin = plugin;
            this.closed = false;
   = DvZ.getLanguage().getString("string_wait_release", "Waiting for release..."+add);
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        private HashMap<String, Boolean> selfOverride = new HashMap<String, Boolean>();
        public void onInventoryClose(InventoryCloseEvent event) {
            if (event.getInventory().getTitle().equals(name)) {
                final Player p = (Player) event.getPlayer();
                //safety for selfoveriding and infinite loops
                if(selfOverride.containsKey(p.getName())) {
                    if(selfOverride.get(p.getName())) {
                        selfOverride.put(p.getName(), false);
                if(!closed) {
                    Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                        public void run() {
                            selfOverride.put(p.getName(), true);
                    }, DELAY);
        public void close() {
            closed = false;
        public void open(Player player) {
            Inventory inventory = Bukkit.createInventory(player, 0, name);
        public void release(final Player player) {
            closed = true;
            if(player.getOpenInventory().getTitle().equals(name)) {
                Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                    public void run() {
                        //player.openInventory(Bukkit.createInventory(player, 0, "Start..."));
                }, 1);
                //player.sendMessage("WARNING: If your Inventory keeps reverting, please relog - thats a Bug in Bukkit with closeInventory()");
        //WARNING: Only for server reload, else use release(Player player)
        public void releaseAll() {
            for (Player p : Bukkit.getServer().getOnlinePlayers()) {
                closed = true;
                if(p.getOpenInventory().getTitle().equals(name)) {
  2. Offline


    That means that you are registering your listener twice.
  3. Offline


    But I don't do that I only create one WaitingMenu in the onEnable() method and then always use the same one. But it somehow has to do with this class as this is the only thing I added since it last worked.
  4. Offline


    I highly recommend you all listeners in the onEnable method in the main class. You'd avoid problems like this that way.
  5. Offline


    andre111 Register your events in the onEnable method of your main class.
  6. Offline


    Ok, I will try that.

    But I justed tested it further and it only seems to happen on one specific server. I tried setting up a testserver with the same plugins as the other server and I could not reproduce the problem. :confused:
  7. Offline


    andre111 Hey, I just recently ran into the same issue as you I've got a feeling it has something to do with just running a server on your ip maybe? I'm getting the same error on the inventorycloseevent which is fired from the client and I was trying to open an inventory off that event.

    I'm also making my own menu for something. Please respond if your issue was fixed by running a server not associated with your ip. Thanks!
Thread Status:
Not open for further replies.

Share This Page