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 Main.java
as my Main Class. I registered the events in Hunger.java
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 Hunger.java
:
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();
player.setFoodLevel(20);
}
}
How do I make player.setFoodLevel work?
EDIT: I just forgot to add an EventHandler annotation. Stupid me
From what I gather from the documentation, you have not registered this event handler as an EventHandler
.
Something like:
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event) {
Player player = event.getPlayer();
player.setFoodLevel(20);
}