Class Game


  • public class Game
    extends Object
    This class is used for round-based team games.
    • Constructor Detail

      • Game

        public Game​(String name,
                    String colorCode,
                    Integer minPlayers,
                    Integer startTime,
                    Integer endTime,
                    String languageCode)
        Parameters:
        name - The name of the game
        colorCode - The color code used for the prefix
        minPlayers - The minimum number of players
        startTime - The time after the game starts when enough players joined
        endTime - The time after the game ends
      • Game

        public Game​(String configName)
        Creates a Game Instance with values from the given config instance
        Parameters:
        configName - The name of the Configuration Instance
    • Method Detail

      • fromConfigFile

        public static Game fromConfigFile​(String gameName)
        Creates a Game Instance from a Config File
        Returns:
        The created game
      • canLoadFromConfig

        public static boolean canLoadFromConfig​(String gameName)
        Checks if a game can be loaded from a config
        Parameters:
        gameName - The name of the saved game
        Returns:
        true if the game can be loaded from a config
      • saveToConfig

        public void saveToConfig()
        Saves the current Game options (name, color code, ...) to the configuration
      • start

        public void start()
        Start the game with its default values
      • start

        public void start​(int time)
        Start the game with a specific start time (used for /start)
        Parameters:
        time - The time after the game starts.
      • processTeams

        protected void processTeams()
        Used for choosing the teams
      • getPlayerTeam

        public Team getPlayerTeam​(org.bukkit.entity.Player p)
        Parameters:
        p - The player
        Returns:
        The team of the player or null
      • startFinal

        protected void startFinal()
        Starts the final game (after countdown)
      • initialize

        protected void initialize()
      • end

        public void end()
        Ends the game after the given time.
      • endFinal

        protected void endFinal()
        Ends the final game (after countdown)
      • getStarting

        public Boolean getStarting()
        Returns:
        true if the game is currently starting
      • getRunning

        public Boolean getRunning()
        Returns:
        true if the game is currently running
      • getName

        public String getName()
        Returns:
        The name of the game
      • getColorCode

        public String getColorCode()
        Returns:
        The color code of the game
      • getMinPlayers

        public Integer getMinPlayers()
        Returns:
        The minimum number of players
      • getStartTime

        public Integer getStartTime()
        Returns:
        The time the game needs to start
      • getEndTime

        public Integer getEndTime()
        Returns:
        The time the game needs to end
      • getLanguageCode

        public String getLanguageCode()
        Returns:
      • setTeamSize

        public void setTeamSize​(Integer teamSize)
        Parameters:
        teamSize - The size of each team
      • addTeam

        public void addTeam​(Team team)
        Parameters:
        team - The team to be added to the game
      • setUseTeams

        public void setUseTeams​(boolean useTeams)
        Parameters:
        useTeams - True if the game should use teams
      • setUseTeamSpawns

        public void setUseTeamSpawns​(boolean useTeamsSpawns)
        Parameters:
        useTeamsSpawns - True if the game should use team spawns
      • getDefaultInventory

        public org.bukkit.inventory.Inventory getDefaultInventory()
        Returns:
        The inventory each player gets when the game starts
      • setDefaultInventory

        public void setDefaultInventory​(org.bukkit.inventory.Inventory defaultInventory)
        Parameters:
        defaultInventory - The inventory each player get when the game starts
      • getWaitingLobby

        public org.bukkit.Location getWaitingLobby()
        Returns:
        The place where each player will be teleported to while there aren't enough players on the server
      • setWaitingLobby

        public void setWaitingLobby​(org.bukkit.Location waitingLobby)
        Parameters:
        waitingLobby - The place where each player will be teleported to while there aren't enough players on the server
      • getTeams

        public ArrayList<Team> getTeams()
        Returns:
        All registered teams.
      • getSpawn

        public org.bukkit.Location getSpawn()
        Returns:
        The in game spawn or null if using team spawns.
      • setSpawn

        public void setSpawn​(org.bukkit.Location spawn)
        Parameters:
        spawn - The new spawn.