public class Round extends java.lang.Object implements Metadatable
Constructor and Description |
---|
Round(java.lang.String plugin,
java.lang.String arena)
Creates a new
Round with the given parameters. |
Modifier and Type | Method and Description |
---|---|
JoinResult |
addPlayer(java.lang.String name)
Adds a player by the given name to this
round . |
JoinResult |
addPlayer(java.lang.String name,
int spawn)
Adds a player by the given name to this
round . |
void |
addSign(org.bukkit.Location location,
LobbyType type,
int index)
Creates a new LobbySign to be managed.
|
void |
addTime(int t)
Adds
t seconds to the elapsed time in the round. |
void |
broadcast(Localizable message)
Broadcasts a message to all players in this round.
|
void |
broadcast(Localizable message,
Color color)
Broadcasts a message to all players in this round.
|
void |
broadcast(Localizable message,
Color color,
boolean broadcastToSpectators)
Broadcasts a message to all players in this round.
|
void |
broadcast(java.lang.String message)
Broadcasts a message to all players in this round.
|
void |
broadcast(java.lang.String message,
boolean broadcastToSpectators)
Broadcasts a message to all players in this round.
|
void |
destroy()
Destroys this
Round . |
void |
end()
Ends the round and resets its timer.
|
void |
end(boolean timeUp)
Ends the round and resets its timer.
|
boolean |
equals(java.lang.Object p) |
int |
getAlivePlayerCount()
|
java.util.List<MGPlayer> |
getAlivePlayerList()
Retrieves a list of non-spectating
MGPlayers in this
round. |
java.util.HashMap<java.lang.String,java.lang.Object> |
getAllMetadata()
Retrieves a
HashMap representing this object's complete metadata. |
java.lang.String |
getArena()
Gets the name of the arena associated with this
Round . |
ConfigManager |
getConfigManager()
Retrieves the
ConfigManager of the plugin owning this round. |
java.lang.String |
getDisplayName()
Retrieves the display name of the round's arena.
|
org.bukkit.Location |
getExitLocation()
Deprecated.
Depends on Bukkit
|
org.bukkit.Location |
getMaxBound()
Retrieves the location representing the maximum boundary on all three
axes of the arena this round takes place in.
|
int |
getMaxPlayers()
Retrieves the maximum number of players allowed in a round at once.
|
java.lang.Object |
getMetadata(java.lang.String key)
Retrieves a given value from this object's metadata by its key.
|
MGPlayer |
getMGPlayer(java.lang.String player)
Returns the
MGPlayer in this round associated with the given
username. |
org.bukkit.Location |
getMinBound()
Retrieves the location representing the minimum boundary on all three
axes of the arena this round takes place in.
|
Minigame |
getMinigame()
Gets the instance of the MGLib API registered by the plugin associated
with this
Round . |
int |
getMinPlayers()
Retrieves the minimum number of players required to automatically start
the round.
|
int |
getPlayerCount()
|
java.util.List<MGPlayer> |
getPlayerList()
Retrieves a list of
MGPlayers in this round. |
java.util.HashMap<java.lang.String,MGPlayer> |
getPlayers()
Retrieves a
HashMap of players in this round. |
int |
getPlayingTime()
Gets the round's playing time.
|
java.lang.String |
getPlugin()
Gets the name of the minigame plugin associated with this
Round . |
int |
getPreparationTime()
Gets the round's preparation time.
|
int |
getRemainingTime()
Gets the time remaining in this round.
|
RollbackManager |
getRollbackManager()
Retrieves the
RollbackManager of the plugin owning this round. |
java.util.List<org.bukkit.Location> |
getSpawns()
Retrieves a list of possible spawns for this round's arena.
|
int |
getSpectatingPlayerCount()
|
java.util.List<MGPlayer> |
getSpectatingPlayerList()
|
Stage |
getStage()
|
java.util.HashMap<java.lang.String,MGPlayer> |
getTeam(java.lang.String team)
Retrieves a
HashMap of all players on a given team. |
int |
getTime()
Gets the current time in seconds of this
Round , where 0
represents the first second of it. |
int |
getTimerHandle()
Gets the round's timer's task's handle, or -1 if a timer is not started.
|
java.lang.String |
getWorld()
Retrieves the world of this arena.
|
boolean |
hasEnded()
Deprecated.
Returns true only when
getStage() is equal to
Stage.RESETTING . This comparison should be used instead. |
int |
hashCode() |
boolean |
hasMetadata(java.lang.String key)
Checks whether a given key is present in this object's metadata.
|
boolean |
isDamageAllowed()
Retrieves whether players in rounds may receive damage.
|
boolean |
isPvPAllowed()
Retrieves whether PvP is allowed.
|
boolean |
isRollbackEnabled()
Retrieves whether rollback is enabled in this round.
|
boolean |
isTicking()
Returns whether this round's timer is currently ticking.
|
void |
removeMetadata(java.lang.String key)
Removes the given key from this object's metadata.
|
void |
removePlayer(java.lang.String name)
Removes a given player from this
round and teleports them
to the round or plugin's default exit location (defaults to the main
world's spawn point). |
void |
removePlayer(java.lang.String name,
org.bukkit.Location location)
Deprecated.
|
void |
removePlayer(java.lang.String name,
Location3D location)
Removes a given player from this
round and teleports them
to the given location. |
void |
setArena(java.lang.String arena)
Sets the associated arena of this
Round . |
void |
setDamageAllowed(boolean allowed)
Sets whether players in rounds may receive damage.
|
void |
setExitLocation(org.bukkit.Location location)
Deprecated.
Depends on Bukkit. Use
setExitLocation(Location3D) . |
void |
setExitLocation(Location3D location)
Sets this round's exit location.
|
void |
setMaxBound(double x,
double y,
double z)
Sets the maximum boundary on all three axes of this round object.
|
void |
setMaxPlayers(int players)
Sets the maximum number of players allowed in a round at once.
|
void |
setMetadata(java.lang.String key,
java.lang.Object value)
Adds a key-value pair to this object's metadata.
|
void |
setMinBound(double x,
double y,
double z)
Sets the minimum boundary on all three axes of this round object.
|
void |
setMinPlayers(int players)
Sets the minimum number of players required to automatically start the
round.
|
void |
setPlayingTime(int t)
Sets the round's playing time.
|
void |
setPreparationTime(int t)
Sets the round's preparation time.
|
void |
setPvPAllowed(boolean allowed)
Sets whether PvP is allowed.
|
void |
setRollbackEnabled(boolean enabled)
Sets whether rollback is enabled by default.
|
void |
setStage(Stage stage)
Sets the current stage of this
Round . |
void |
setStage(Stage stage,
boolean resetTimer)
Sets the current stage of this
Round . |
void |
setTime(int t)
Sets the remaining time of this
Round . |
void |
start()
Begins the round and starts its timer.
|
void |
subtractTime(int t)
Subtracts
t seconds from the elapsed time in the round. |
void |
tick()
Decrements the time remaining in the round by 1.
|
void |
updateSigns()
Updates all lobby signs linked to this round's arena.
|
public Round(java.lang.String plugin, java.lang.String arena) throws NoSuchArenaException
Round
with the given parameters.
Please use Minigame.createRound(String)
unless you
understand the implications of using this constructor.
plugin
- the plugin which this round should be associated witharena
- the name of the arena in which this round takes place inNoSuchArenaException
- if the specified arena does not existpublic java.lang.String getPlugin()
Round
.Round
public Minigame getMinigame()
Round
.Round
public java.lang.String getArena()
Round
.Round
public int getTime()
Round
, where 0
represents the first second of it.Round
, where 0
represents the first second of itpublic int getRemainingTime()
public int getPreparationTime()
public int getPlayingTime()
public int getTimerHandle()
public boolean isTicking()
This method simply checks whether getTimerHandle()
returns a number greater than or equal to 0
.
public void setArena(java.lang.String arena)
Round
.arena
- the arena to associate with this Round
public void setStage(Stage stage, boolean resetTimer)
Round
. Note that this will not
start or restart the round.stage
- the stage to set this Round
toresetTimer
- whether to reset the round timer (defaults to true if
omitted)public void setStage(Stage stage)
Round
.stage
- the stage to set this Round
topublic void setTime(int t)
Round
.t
- the time to set this Round
topublic void setPreparationTime(int t)
t
- the number of seconds to set the preparation time to. Use -1 for
no limit, or 0 for no preparation phase.public void setPlayingTime(int t)
t
- the number of seconds to set the preparation time to. Use -1 for
no limitpublic void tick()
Please do not call this method from your plugin unless you understand the implications. Let MGLib handle the timer.
public void subtractTime(int t)
t
seconds from the elapsed time in the round.t
- the number of seconds to subtractpublic void addTime(int t)
t
seconds to the elapsed time in the round.t
- the number of seconds to addpublic void destroy()
Round
.
Please do not call this method from your plugin unless you understand the implications.
public java.util.List<MGPlayer> getPlayerList()
MGPlayers
in this round.MGPlayers
in this roundpublic java.util.HashMap<java.lang.String,MGPlayer> getPlayers()
HashMap
of players in this round.HashMap
mapping the names of players in the round to
their respective MGPlayer
objectspublic java.util.HashMap<java.lang.String,MGPlayer> getTeam(java.lang.String team)
HashMap
of all players on a given team.team
- the team to retrieve players fromHashMap
mapping the names of players on a given team to
their respective MGPlayer
objects.public java.util.List<MGPlayer> getAlivePlayerList()
MGPlayers
in this
round.MGPlayers
in this roundpublic java.util.List<MGPlayer> getSpectatingPlayerList()
public int getPlayerCount()
public int getAlivePlayerCount()
public int getSpectatingPlayerCount()
public void start()
Stage.PREPARING
, it will be set to Stage.PLAYING
and the
timer will be reset when it reaches 0. Otherwise, its stage will be set
to Stage.PREPARING
and it will begins its preparation stage.
After it finishes its preparation, it will begin as it would if this method were called again (don't actually call it again though, or you'll trigger an exception).
java.lang.IllegalStateException
- if the stage is already Stage.PLAYING
public void end(boolean timeUp)
Stage.WAITING
.timeUp
- whether the round was ended due to its timer expiring. This
will default to false if omitted.java.lang.IllegalStateException
- if the timer has not been startedpublic void end()
Stage.WAITING
.java.lang.IllegalStateException
- if the timer has not been started@Deprecated public boolean hasEnded()
getStage()
is equal to
Stage.RESETTING
. This comparison should be used instead.public org.bukkit.Location getMinBound()
public org.bukkit.Location getMaxBound()
public void setMinBound(double x, double y, double z)
x
- the minimum x-valuey
- the minimum y-valuez
- the minimum z-valuepublic void setMaxBound(double x, double y, double z)
x
- the maximum x-valuey
- the maximum y-valuez
- the maximum z-valuepublic java.util.List<org.bukkit.Location> getSpawns()
public MGPlayer getMGPlayer(java.lang.String player)
MGPlayer
in this round associated with the given
username.player
- the username to search forMGPlayer
in this round associated with the given
username, or null
if none is foundpublic java.lang.String getWorld()
public JoinResult addPlayer(java.lang.String name) throws PlayerOfflineException, PlayerPresentException, RoundFullException
round
.name
- the player to add to this round
. (will default
to random/sequential (depending on configuration) if out of
bounds).result
of the player being added to the
roundPlayerOfflineException
- if the player is not onlinePlayerPresentException
- if the player is already in a roundRoundFullException
- if the round is fullpublic JoinResult addPlayer(java.lang.String name, int spawn) throws PlayerOfflineException, PlayerPresentException, RoundFullException
round
.name
- the player to add to this round
spawn
- the spawn number to teleport the player to (will default to
random/sequential (depending on configuration) if out of
bounds).result
of the player being added to the
roundPlayerOfflineException
- if the player is not onlinePlayerPresentException
- if the player is already in a roundRoundFullException
- if the round is fullpublic void removePlayer(java.lang.String name, Location3D location) throws PlayerOfflineException, NoSuchPlayerException
round
and teleports them
to the given location.name
- the player to remove from this round
location
- the location to teleport the player toPlayerOfflineException
- if the player is not onlineNoSuchPlayerException
- if the player are not in this round@Deprecated public void removePlayer(java.lang.String name, org.bukkit.Location location) throws PlayerOfflineException, NoSuchPlayerException
removePlayer(String, Location3D)
round
and teleports them
to the given location.name
- the player to remove from this round
location
- the location to teleport the player toPlayerOfflineException
- if the player is not onlineNoSuchPlayerException
- if the player are not in this roundpublic void removePlayer(java.lang.String name) throws PlayerOfflineException, NoSuchPlayerException
round
and teleports them
to the round or plugin's default exit location (defaults to the main
world's spawn point).name
- the player to remove from this round
NoSuchPlayerException
- if the given player is not in this roundPlayerOfflineException
- if the given player is offlinepublic int getMinPlayers()
public void setMinPlayers(int players)
players
- the minimum number of players required to automatically
start the roundpublic int getMaxPlayers()
public void setMaxPlayers(int players)
players
- the maximum number of players allowed in a round at oncepublic void addSign(org.bukkit.Location location, LobbyType type, int index) throws NoSuchArenaException, InvalidLocationException, java.lang.IndexOutOfBoundsException
location
- the location to create the sign attype
- the type of the sign ("status" or "players")index
- the number of the sign (applicable only for "players"
signs)NoSuchArenaException
- if the specified arena does not existInvalidLocationException
- if the specified location does not
contain a signjava.lang.IndexOutOfBoundsException
- if the specified index for a player
sign is less than 1public void updateSigns()
@Deprecated public org.bukkit.Location getExitLocation()
public void setExitLocation(Location3D location)
location
- the new exit location for this round@Deprecated public void setExitLocation(org.bukkit.Location location)
setExitLocation(Location3D)
.location
- the new exit location for this roundpublic boolean isPvPAllowed()
public void setPvPAllowed(boolean allowed)
allowed
- whether PvP is allowedpublic boolean isDamageAllowed()
true
)public void setDamageAllowed(boolean allowed)
false
)allowed
- whether players in rounds may receive damagepublic boolean isRollbackEnabled()
public void setRollbackEnabled(boolean enabled)
enabled
- whether rollback is enabled by defaultpublic ConfigManager getConfigManager()
ConfigManager
of the plugin owning this round.ConfigManager
of the plugin owning this roundpublic RollbackManager getRollbackManager()
RollbackManager
of the plugin owning this round.RollbackManager
of the plugin owning this roundpublic void broadcast(java.lang.String message, boolean broadcastToSpectators)
message
- the message to broadcastbroadcastToSpectators
- whether the message should be broadcast to
spectatorspublic void broadcast(Localizable message, Color color, boolean broadcastToSpectators)
message
- the message to broadcastcolor
- The color to broadcast with (pass null
for none)broadcastToSpectators
- whether the message should be broadcast to
spectatorspublic void broadcast(java.lang.String message)
message
- the message to broadcastpublic void broadcast(Localizable message, Color color)
message
- the message to broadcastcolor
- The color to broadcast withpublic void broadcast(Localizable message)
message
- the message to broadcastpublic java.lang.String getDisplayName()
public java.lang.Object getMetadata(java.lang.String key)
Metadatable
getMetadata
in interface Metadatable
key
- the key to retrieve.public void setMetadata(java.lang.String key, java.lang.Object value)
Metadatable
Note: This method consists of a single call to
HashMap.put(Object, Object)
, so existing keys will be overwritten.
setMetadata
in interface Metadatable
key
- the key to store in the round's metadata.value
- the value to assign to the given key.public void removeMetadata(java.lang.String key)
Metadatable
removeMetadata
in interface Metadatable
key
- the key to remove from this object's metadata.public boolean hasMetadata(java.lang.String key)
Metadatable
hasMetadata
in interface Metadatable
key
- the key to test for.public java.util.HashMap<java.lang.String,java.lang.Object> getAllMetadata()
Metadatable
HashMap
representing this object's complete metadata.getAllMetadata
in interface Metadatable
HashMap
.public boolean equals(java.lang.Object p)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object