WampyCakes WampyCakes - 1 year ago 121
Java Question

player.setFoodLevel doesn't work

I am making a KitPvP plugin for Bukkit. I have run across an error, and I was wondering if someone could help me.

So, I have a

as my Main Class. I use
for my extra class that my code won't work in. I registered the events in
but the code won't execute in Minecraft all the other aspects of the plugin work so far besides this. Here is the code for

package com.lobbyist.junk.kitpvp;

import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;

public class Hunger implements Listener{

public void onPlayerInteractEvent(PlayerInteractEvent event){
Player player = event.getPlayer();


How do I make Player.setFoodLevel work?

EDIT: I just forgot to add an EventHandler annotation.

Answer Source

From what I gather from the documentation, you have not registered this event handler as an EventHandler.

Something like:

public void onPlayerInteractEvent(PlayerInteractEvent event) {
    Player player = event.getPlayer();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download