1.15.2 Multiple Instances Of 1 Minigame

Discussion in 'Spigot Plugin Development' started by Jdoobi3, Mar 13, 2020.

  1. Hey, let's say I created a minigame and I wait for 10 players to type in the command which puts them in a queue. Once there are 10 players the minigame teleports the players to the minigame area.

    Now that works fine if there are only 10 players on the server. Now, what happens if there are 20 players on the server and 10 players are already playing that minigame. They would have to wait until that game finishes in order to play.

    How would I go about creating another instance of that minigame so more players can play? Would I have to build out an exact copy of the current minigame and if the first location game has 10 players then teleport the users to the copy of that location?

    Not really sure how all this works and if someone could point me in the right direction, it would be much appreciated.
  2. Show the code of how your handling the minigame,are you using "raw coding" to manage everything,or class based objects that hold it?(wich is the answer to your question)
  3. Hey so there's no code yet, I have a general idea on how to write a minigame but I don't know how to run multiple instances of it. I imagine id have a minigame class that implements some said interface but idk. IE: PuzzleMiniGame implements MiniGame and then PuzzleMiniGame would be composed of subclasses probably. Where I'm more so confused is I get how to make a minigame for 1 instance, but then being able to run multiple is where it doesn't make sense. Like how would I duplicate the build of the minigame over and over with each instance.
  4. SteelPhoenix


    Just use objects for your games, java is object-oriented anyways

    Code (Java):
    IGame myFirstGame = new SomeGame();
    IGame mySecondGame = new SomeGame();
  5. Gotcha and thanks but what about the custom arena that was built for example? It's only in one location in the world, so how would I create another copy of the map for the next game?
  6. A example of class+constructor
    Code (Text):
    package main;

    import org.bukkit.Location;

    public class PuzzleGame {
        //This instance's arenaName
        private String arenaName;
        private Location spawn;
        //Constructor requiring a name
        public PuzzleGame(String arenaName) {
        //Set it's spawn
        public void setSpawn(Location loc) {
            this.spawn = loc;
      public String returnName(){
    return arenaName;

    Based on how you go around it...
    I would have a list of all the minigames in the main(or some utility class that keeps track)
    Code (Text):
    List<PuzzleGame> gameInstances = new ArrayList<PuzzleGame>();
    Creating that instance
    Code (Text):
    onCommand().... <-pseudo code

    if(args[0] = "create"){
    PuzzleGame game = new PuzzleGame(args[1][<-arenaName]);
    Util to return a specific game
    Code (Text):
    public PuzzleGame returnGame(String arenaName){
    for(PuzzleGame pG : gameInstances){
    return pG;
    Code (Text):

    PuzzleGame targetGame = returnGame(args[1]);
    This is very brief and its meant to be a quick look on how would you handle these sort of things
    #6 Stellrow, Mar 13, 2020
    Last edited: Mar 13, 2020
  7. Basically just use everything as an object. Don't use static stuff. (static stuff can be some methods and functions but nothing which is instance based).
  8. make a void world with like 10 copies of the arena floating in it, have portals at every entrance to the original so that when they enter they get teleported to whichever arena isn't being used in the void world