#Stuck on Initialization I think (minecraft)

4 messages · Page 1 of 1 (latest)

slow robin
#

This is my structure.
DuelAnywhere
managers > DuelManager
utils > OngoingDuel

In main class I have (DuelAnywhere)

public final class DuelAnywhere extends JavaPlugin {
private DuelManager duelManager;

@Override
public void onEnable() {
  this.duelManager = new DuelManager(this);
}

In DuelManager class I have

public class DuelManager {
  private final DuelAnywhere plugin;

  public DuelManager(DuelAnywhere plugin) {
    this.plugin = plugin;
  }

public OngoingDuel getOngoingDuelByPlayer(Player player) {
        for (OngoingDuel ongoingDuel : ongoingDuels) {
            if (ongoingDuel.player1().equals(player) || ongoingDuel.player2().equals(player)) {
                return ongoingDuel;
            }
        }
        return null; // Player is not part of any ongoing duel
    }
}

In OngoingDuel class I have (record)

public record OngoingDuel(Player player1, Player player2, double betAmount, Location arenaLocation) {
}

In my DuelManager class I can call this method and it returns the correct information with everything I need.

getOngoingDuelByPlayer(player);

However if I try to use this method in my main class it always returns null and I'm not really sure why.

vestal glenBOT
#

This post has been reserved for your question.

Hey @slow robin! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

slow robin
#

I received help from someone. I was creating two instance of my DuelManager.