I have a class called Manhunt
that inherits Minigame
. To keep the code and post brief, I'm only including the pertinent methods
public abstract class Minigame {
public abstract void startCountdown();
}
public class Manhunt extends Minigame {
@Override
public void startCountdown() {
}
}
And Minigame is handled by MinigameManager
public class MinigameManager {
public void startMinigame(String minigame, int gameKey) {
switch (minigame) {
case "manhunt":
UUID runner = this.playersQueued.remove(this.random.nextInt(this.playersQueued.size()));
this.minigame = new Manhunt(gameKey, runner, this.playersQueued);
this.minigame.startCountdown();
this.playersQueued.clear();
break;
case "tbr":
case "boatracer":
break;
default:
}
}
}
The problem is, Manhunt
and MinigameManager
are in two separate plugins meaning this current setup requires IntelliJ to add dependencies for both programs that reference each other, leading to a circular dependency problem. I want to keep them separated in case I add extra Minigames (I just have to drag and drop extra Minigames as opposed to coding them all in the same program), but how do I resolve this circular dependency issue?
It seems like the Dependency Inversion Principle should solve this problem, but I'm not sure how to incorporate that to my program. Would I need to create an interface for MinigameManager
or Minigame
? I would appreciate it if someone could walk me through making the code more modular.