Solved Hunger

Discussion in 'Bukkit Help' started by Epixel, Oct 5, 2016.

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

    Epixel

    Hello, on my server, new players start with only 4/10 foodbars for some reason. I've even made a plugin to fix this but it still doesnt work. The server difficulty is at "1".
    Plugin:
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event)
    Player p = event.getPlayer();
    if(!p.hasPlayedBefore()){
    p.setFoodLevel(20);
    p.sendMessage("Welcome");
    }
    }
    Now before you start pointing out errors within the plugin, I know that it works since I do get the welcome message.

    Edit:
    Just realized that this isn't only for new players, every time you log in your hunger gets set to 4.
     
    Last edited: Oct 5, 2016
  2. Offline

    oceantheskatr

    For your first problem, you should schedule the "setFoodLevel" to happen after 5 ticks or so, as there's definitely something changing the hunger a tick or two after the player joins.

    From there, there are two options. Add on to your plugin to save the player's hunger when they leave, and then set their hunger to that when they join, or follow this:

    I'm not sure which plugin is causing it, but follow the video below and it'll show you how to troubleshoot your plugins, allowing you to quickly and efficiently figure out which plugin is causing the problem. After you figure out which plugin is causing the problem, you can either deal with it yourself or let us know in this thread and we'll try our best to help!

    Video:
     
  3. Offline

    Epixel

    Thank you very much, spotted the plugin.
     
    oceantheskatr likes this.
  4. Offline

    Zombie_Striker

    @Epixel
    If your problem has been solved, mark this thread as solved.
     
    Khriz likes this.
Thread Status:
Not open for further replies.

Share This Page