Solved Duplicated Entry (database) + mysterious event handler

Discussion in 'Plugin Development' started by RcExtract, Sep 27, 2017.

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

    RcExtract

    This is real.
    So i was fixing an error. When i save my data from the plugin to the database, it keeps saying "duplicated entry" (cuz the column is set to every entry must have a unique value). I looked through the entire initialization and i dont find anything that creates a duplicated object (only 1 object is created). I did not do anything. Then when i save the data, it prints that there are two objects. Then i just realized that i did not check about the event handlers. When i reloaded a new version, the plugin prints ONE event handler (the event handler handles event about the creation of the object) is registered, and i was freaked out. Then when i reloaded without modifying anything, it prints zero. Then the duplicated entry error disappeared forever.

    According to my estimation, the duplicated object should be created inside the event handler. But that was the only plugin, and there is no any event handlers handling that event in the plugin. There is no way that spigot has a bug and creates an object of that class for me. Can someone explain this?
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    RcExtract

    Do u mean if I restart I maybe able to view the mysterious event handler?
     
  4. Online

    timtower Administrator Administrator Moderator

    @RcExtract No, reloads are not very good for the server, restart the server, check if the same effect occurs.
     
  5. Offline

    RcExtract

    Well i think the error disappeared, cuz it works fine when i restarted it, and there is no more "duplicated entry" error. But can the situation mentioned in the main post be explained?
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    RcExtract

    I think i should think more about the mysterious event handler than two objects created, cuz probably i really created two objects in my code, but i am sure that i only wrote "Bukkit.getPluginManager().registerEvents(Listener)" once in the entire plugin cuz the method call is pretty long. And inside the listener i registered in the plugin, there is no method handling the object creation event.
     
  8. Online

    timtower Administrator Administrator Moderator

  9. Offline

    RcExtract

    No

    So the mysterious event handler is still a mystery, but i realized why there are duplicated objects, and i fixed the bug.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Sep 27, 2017
Thread Status:
Not open for further replies.

Share This Page