Solved Cannot make a static reference to non-static field

Discussion in 'Plugin Development' started by kacpicygan123, Jan 9, 2022.

  1. Offline


    I've been trying to execute this snippet of code:
    package quest;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    public class QuestManager implements Listener {
        private Player player;
        Quest1 quest1;
        QuestManager(Player p) {
            player = p;
            quest1 = new Quest1(player, "The beginning", "The description", "You've begun your first quest!", "Your first quest ends here. Good luck!");
        public static void onEntityDeath(EntityDeathEvent event) {
            if (quest1.checkIfActive() == true) {
                player.sendMessage("Quest is active!");
    However, there is an error telling me that:
    Cannot make a static reference to the non-static field quest1
    Cannot make a static reference to the non-static field player
    package quest;
    import org.bukkit.Material;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    public class Quest1 implements IQuest {
    private boolean isActive = false;
    //some code here
        public boolean checkIfActive() {
            return this.isActive;
    What might be the solution?
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline


    it worked, thank you!

Share This Page