"Failed to handle packet for" while checking ip on join

Discussion in 'Plugin Development' started by adde, Dec 29, 2013.

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

    adde

    Hello! I just ran into a problem that I can solve somehow. It appear when I check the IP when a player join the server. It's in PlayerJoinEvent, here's my code:
    Code:java
    1.  
    2. if(Referral.ips.contains(player.getAddress().getHostString()))
    3. {
    4. System.out.println("asd");
    5. return;
    6. }
    7.  
    8. if(!player.hasPlayedBefore())
    9. {
    10. try{
    11. Inventory inv = Bukkit.createInventory(player, 9);
    12. inv.addItem(new ItemStack(Material.DIAMOND, 1));
    13. player.openInventory(inv);
    14.  
    15. Referral.ips.add(player.getAddress().getHostString());
    16. plugin.getConfig().set("IPs", Referral.ips);
    17. plugin.saveConfig();
    18. System.out.println(player.getAddress().getHostString());
    19. }catch(Exception ex)
    20. {
    21. ex.printStackTrace();
    22. }
    23. }else{
    24. System.out.println(player.getAddress().getHostString());
    25. System.out.println("Lel played before");
    26. }
    27.  

    It also appears when I try to add the ip to the config stringlist.
    Here's the complete error, I tried on not localhost too:
    Code:
    [10:40:20 WARN]: Failed to handle packet for /127.0.0.1:49768
    java.lang.IllegalArgumentException: Listener already listening
            at net.minecraft.server.v1_7_R1.Container.addSlotListener(Container.java
    :53) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.EntityPlayer.syncInventory(EntityPlayer.
    java:152) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.PlayerList.a(PlayerList.java:131) ~[craf
    tbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.LoginListener.c(LoginListener.java:78) ~
    [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.LoginListener.a(LoginListener.java:42) ~
    [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:149
    ) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    51) [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    41) [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :453) [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit-1.7.2.jar:git-Bukkit-1.6.4-R2.0-39-g68b702f-b2954jnks]
    [10:40:20 INFO]: addemod lost connection: Internal server error
    [10:40:20 INFO]: addemod left the game.
    
     
  2. Offline

    RawCode

    what about removing lines about inventory edit.
     
    adde likes this.
  3. Offline

    adde

    Really? That was the error? -_-
    I feel stupid now. But I can't see why I am not allowed to do that? It works in other plugins :s

    Edit, fixed. Just noticed that I can't do it while the player is connecting. Thanks btw. :3
    Used a timer to do it 2 seconds later.
     
Thread Status:
Not open for further replies.

Share This Page