Problem with the 1.7.9 Bukkit

Discussion in 'Plugin Development' started by Freelix2000, May 24, 2014.

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

    Freelix2000

    I have added a clans feature to my server, and while it mostly works fine, I have found one very big issue that appears to be related to the Bukkit 1.7.9 updates. First the issue was that when a player tried to leave their clan it would kick them and throw an error. When I looked at the error, no part of the stacktrace pointed me to any classes or lines in my plugin, all just inside of craftbukkit and Minecraft. I added checkpoint messages inside the code to find what line it was, and I found that the error occurred on a "saveData()" method. There isn't anything wrong with this method because the plugin I am making is huge, and the "saveData()" method is literally used in about 100 other places that work just fine. Anyways, I fixed that issue by starting over on that part and finding another way to code it, but now the same problem occurs when I a player deletes their clan. It seems to save the data and successfully delete their clan, but it still throws an error at the end and kicks them. Here's my code for the delete clan method:
    Code:java
    1. String clan = "";
    2. for(String s : getData().getConfigurationSection("clans").getKeys(false)){
    3. if(getData().getConfigurationSection("clans").getString(s + ".leader").equals(p.getUniqueId().toString())){
    4. clan = s;
    5. break;
    6. }
    7. }
    8. if(clan == ""){
    9. p.sendMessage(ChatColor.RED + "You must own a clan to use this command.");
    10. return true;
    11. }
    12. getData().getConfigurationSection("clans").set(clan + ".leader", null);
    13. getData().getConfigurationSection("clans").set(clan + ".members", null);
    14. getData().getConfigurationSection("clans").set(clan + ".kills", null);
    15. getData().getConfigurationSection("clans").set(clan + ".deaths", null);
    16. getData().getConfigurationSection("clans").set(clan + ".color", null);
    17. getData().getConfigurationSection("clans").set(clan, null);
    18. saveData();//I believe this is where the error occurs, but again, it does successfully save.
    19. clans.put(p.getName(), null);
    20. hubboard.getTeam(clan).removePlayer(p);
    21. hubboard.getTeam(clan).unregister();
    22. hubboard.getTeam("noclan").addPlayer(p);
    23. p.sendMessage(ChatColor.GRAY + "You have deleted your clan.");
    24. for(Player pl : Bukkit.getOnlinePlayers()){
    25. if(clans.get(pl.getName()).equalsIgnoreCase(clan)){
    26. pl.sendMessage(ChatColor.GRAY + "Your clan has been deleted by " + ChatColor.BLUE + p.getName() + ChatColor.GRAY + ".");
    27. hubboard.getTeam("noclan").addPlayer(pl);
    28. clans.put(pl.getName(), null);
    29. }
    30. }
    31. return true;

    Here's my saveData() method (Again, I don't think there is anything wrong with it, but I know someone is going to ask...
    Code:java
    1. public void saveData(){
    2. try{
    3. getData().save(getDataFolder() + File.separator + "data.yml");
    4. }catch(IOException e){
    5. getLogger().severe("Could not save data!");
    6. }
    7. return;
    8. }

    And here is the error it throws.
    Code:
    [05:28:14] [Server thread/WARN]: Failed to handle packet for /<edit>:51232
    java.lang.NullPointerException
        at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:101) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.apache.logging.log4j.core.Logger.log(Logger.java:110) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:609) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at org.bukkit.craftbukkit.v1_7_R3.util.ForwardLogHandler.publish(ForwardLogHandler.java:33) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at java.util.logging.Logger.log(Logger.java:610) ~[?:1.7.0_40]
        at java.util.logging.Logger.doLog(Logger.java:631) ~[?:1.7.0_40]
        at java.util.logging.Logger.log(Logger.java:720) ~[?:1.7.0_40]
        at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:961) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-b3084jnks]
    [05:28:14] [Server thread/INFO]: Freelix2000 lost connection: Internal server error
    
    Since the error does say that it failed to send a packet, and the player who gets kicked is always only the player who tries to delete the clan, I would guess that the flaw in my code would have to be at some point in which the plugin messes with the former clan leader's scoreboard or clan data. Also, when the code throws the error, it never gets to the loop that sorts out each online clan member's data, so the error must occur before that. Thank you for reading, and if you know how to fix a flaw in this code or an alternative solution that might make it work better with Bukkit, please comment.
     
  2. Freelix2000
    I'm not a 100% sure, but I believe it's due to the logger you're using:
    Code:
    getLogger().severe("Could not save data!");
    If it's in your main class, you could try using
    Code:
    Bukkit.getLogger().severe("Could not save data!");
    instead of just getLogger(), but I doubt that may change the difference - it's worth a try though.
     
  3. Offline

    Freelix2000

    DJSkepter
    I don't think that's it because the logger does work for many other things, it still saves data, and that wouldn't kick the player for a bad packet. Thanks for the reply, though.
     
  4. Offline

    Giant

    If you comment out the call to "saveData()", and simply test if it works then, you will know if it is saveData() or not.
     
  5. Offline

    Freelix2000

    I actually have concluded that it is not a problem with saveData() because the same error now occurs for a command in the game for leaving arenas, which does not use saveData() and also worked perfectly fine prior to the update. I am beginning to think that I'll just have to wait for a new craftbukkit/Bukkit API update for my plugin to work again.
     
  6. Offline

    Jade

    Removed some personal informations in the OP.
     
  7. Offline

    Freelix2000

    Well, it seems that as I predicted, the problem was with Bukkit. I finally fixed it by switching to a dev 1.7.9 build instead of a beta build, and now everything seems to work fine. =)

    It seems I have forgotten how to change the thread prefix to Solved... perhaps I should post a help thread for that too. =P

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

Share This Page