Help With Auto Feed

Discussion in 'Plugin Development' started by daniellekush, Dec 31, 2016.

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


    So I recently started to learn Java and how to make plugins. I started creating a lobby plugin which lets the player toggle night vision, jump boost and auto feed if they have permission. I managed to successfully create the night vision and jump boost part but unfortunately I cannot figure out how to make the auto feed work. If any of you guys could help, that would be great.
  2. Offline


    @daniellekush If you want to keep up auto feed, or just not make them loose hunger at all, there is a event called the "FoodLevelChangeEvent"

    Simply cancel the event each time it happens, or set their hunger back to 20
  3. Offline


    Listen for a FoodLevelChangeEvent.

    Edit: Ninja'd by @mine2012craft
  4. Offline


    I am trying to make it so that when a player types /ae autofeed is enabled and when they type /ae again then it is disabled (sending them a message that tells them both of those). They also have to have the permission ae.use.

    package com.daniellekush.lobbyefx.event;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.FoodLevelChangeEvent;
    public class Event implements Listener{
        public boolean isEat = false;
        public void onFoodChange(FoodLevelChangeEvent event){
            Player player = (Player) event.getEntity();
            if(player instanceof Player){
                if (player.hasPermission("ae.use"))
                    if(player.getFoodLevel() == 19){
                        isEat = true;
                        player.sendMessage(ChatColor.GREEN + "You have enabled auto eat");
                    }else if (isEat){
                        isEat = false;
                        player.sendMessage(ChatColor.DARK_RED + "You have disabled auto eat");
                    } else {
    EDIT: can someone please help?
    Last edited: Jan 1, 2017
  5. Online

    timtower Moderator Moderator

    Merged threads
Thread Status:
Not open for further replies.

Share This Page