Package net.craftions.api.game
Class Game
- java.lang.Object
-
- net.craftions.api.game.Game
-
public class Game extends Object
This class is used for round-based team games.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTeam(Team team)
static boolean
canLoadFromConfig(String gameName)
Checks if a game can be loaded from a configvoid
end()
Ends the game after the given time.protected void
endFinal()
Ends the final game (after countdown)static Game
fromConfigFile(String gameName)
Creates a Game Instance from a Config FileString
getColorCode()
org.bukkit.inventory.Inventory
getDefaultInventory()
Integer
getEndTime()
String
getLanguageCode()
Integer
getMinPlayers()
String
getName()
Team
getPlayerTeam(org.bukkit.entity.Player p)
Boolean
getRunning()
org.bukkit.Location
getSpawn()
Boolean
getStarting()
Integer
getStartTime()
ArrayList<Team>
getTeams()
org.bukkit.Location
getWaitingLobby()
protected void
initialize()
protected void
processTeams()
Used for choosing the teamsvoid
saveToConfig()
Saves the current Game options (name, color code, ...) to the configurationvoid
setDefaultInventory(org.bukkit.inventory.Inventory defaultInventory)
void
setSpawn(org.bukkit.Location spawn)
void
setTeamSize(Integer teamSize)
void
setUseTeams(boolean useTeams)
void
setUseTeamSpawns(boolean useTeamsSpawns)
void
setWaitingLobby(org.bukkit.Location waitingLobby)
void
start()
Start the game with its default valuesvoid
start(int time)
Start the game with a specific start time (used for /start)protected void
startFinal()
Starts the final game (after countdown)
-
-
-
Constructor Detail
-
Game
public Game(String name, String colorCode, Integer minPlayers, Integer startTime, Integer endTime, String languageCode)
- Parameters:
name
- The name of the gamecolorCode
- The color code used for the prefixminPlayers
- The minimum number of playersstartTime
- The time after the game starts when enough players joinedendTime
- 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
-
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.
-
-