Package be.seeseemelk.mockbukkit
Class MockPlayerList
java.lang.Object
be.seeseemelk.mockbukkit.MockPlayerList
Replica of the Bukkit internal PlayerList and CraftPlayerList implementation
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOfflinePlayer
(@NotNull OfflinePlayer player) Adds an offline player to the offline players set.void
addOperator
(UUID operator) Adds a Player to the list of known Operators.void
addPlayer
(@NotNull PlayerMock player) Marks a player as on the server, and sets related data like hasPlayedBefore and lastLogin.void
Clears all offline players.void
Clears all online players.void
disconnectPlayer
(@NotNull PlayerMock player) Marks a player as disconnected, and sets related data like lastSeen.long
getFirstPlayed
(UUID uuid) Gets the first time that this player was seen on the server.@NotNull MockIpBanList
long
getLastLogin
(UUID uuid) Gets the last time a player was seen online.long
getLastSeen
(UUID uuid) Gets the last time a player was seen online.int
@NotNull OfflinePlayer
getOfflinePlayer
(@NotNull String name) Gets an offline, or online player by name.@Nullable OfflinePlayer
getOfflinePlayer
(@NotNull UUID id) Gets an offline, or online player by UUID.@NotNull OfflinePlayer @NotNull []
@NotNull Collection<PlayerMock>
@NotNull Set<OfflinePlayer>
@NotNull PlayerMock
getPlayer
(int index) Gets a player at the provided index.@Nullable Player
Finds the player with the closest matching name.@Nullable Player
@Nullable Player
getPlayerExact
(@NotNull String name) Matches a player by their exact name.@NotNull MockProfileBanList
boolean
hasPlayedBefore
(@NotNull UUID uuid) Checks if a player has played before.boolean
matchPlayer
(@NotNull String name) Matches a player by partial name.void
removeOperator
(UUID operator) Removes a Player from the list of known Operators.void
setFirstPlayed
(UUID uuid, long firstPlayed) Sets the return value ofgetFirstPlayed(UUID)
.void
setLastLogin
(UUID uuid, long lastLogin) Sets the return value ofgetLastLogin(UUID)
.void
setLastSeen
(UUID uuid, long lastSeen) Sets the return value ofgetLastLogin(UUID)
while the player is offline.void
setMaxPlayers
(int maxPlayers) Sets the maximum number of online players.
-
Constructor Details
-
MockPlayerList
public MockPlayerList()
-
-
Method Details
-
setMaxPlayers
public void setMaxPlayers(int maxPlayers) Sets the maximum number of online players. This is not currently enforced.- Parameters:
maxPlayers
- The maximum amount of players.
-
getMaxPlayers
public int getMaxPlayers()- Returns:
- The maximum number of online players.
-
getIPBans
- Returns:
- All IP bans.
-
getProfileBans
- Returns:
- All profile bans.
-
addPlayer
Marks a player as on the server, and sets related data like hasPlayedBefore and lastLogin.- Parameters:
player
- The player to add.
-
disconnectPlayer
Marks a player as disconnected, and sets related data like lastSeen.- Parameters:
player
- The player to disconnect.
-
hasPlayedBefore
Checks if a player has played before.- Parameters:
uuid
- The UUID of the player.- Returns:
- Whether the player has played before.
- See Also:
-
addOfflinePlayer
Adds an offline player to the offline players set.- Parameters:
player
- The player.
-
getFirstPlayed
Gets the first time that this player was seen on the server.- Parameters:
uuid
- The UUID of the player.- Returns:
- The time of first log-in, or 0.
- See Also:
-
setFirstPlayed
Sets the return value ofgetFirstPlayed(UUID)
.- Parameters:
uuid
- UUID of the player to set first played time for.firstPlayed
- The first played time. Must be non-negative.
-
getLastSeen
Gets the last time a player was seen online.- Parameters:
uuid
- The UUID of the player.- Returns:
- The last time the player was seen online.
- See Also:
-
setLastSeen
Sets the return value ofgetLastLogin(UUID)
while the player is offline. If the player is online, this will not have an effect.- Parameters:
uuid
- UUID of the player to set last seen time for.lastSeen
- The last seen time. Must be non-negative.
-
getLastLogin
Gets the last time a player was seen online.- Parameters:
uuid
- The UUID of the player.- Returns:
- The last time the player was seen online.
- See Also:
-
setLastLogin
Sets the return value ofgetLastLogin(UUID)
.- Parameters:
uuid
- UUID of the player to set last login time for.lastLogin
- The last login time. Must be non-negative.
-
getOperators
- Returns:
- All server operators.
-
getOnlinePlayers
- Returns:
- All online players.
-
getOfflinePlayers
- Returns:
- All offline and online players.
-
isSomeoneOnline
public boolean isSomeoneOnline()- Returns:
- Whether anyone is online.
-
matchPlayer
Matches a player by partial name.- Parameters:
name
- The name to match by.- Returns:
- All online players whose names start with the provided name.
-
getPlayerExact
Matches a player by their exact name.- Parameters:
name
- The name to match by.- Returns:
- The player with the exact name provided, or null.
-
getPlayer
Finds the player with the closest matching name.- Parameters:
name
- The name to search with.- Returns:
- The closest matching player.
-
getPlayer
- Parameters:
id
- The UUID of the player.- Returns:
- The player with the provided UUID, or null.
-
getPlayer
Gets a player at the provided index. Note player indexes will change whenever they join/leave.- Parameters:
index
- The index.- Returns:
- The player at the provided index.
-
getOfflinePlayer
Gets an offline, or online player by name.- Parameters:
name
- The name to match.- Returns:
- The player, or offline player with the provided name.
- See Also:
-
getOfflinePlayer
Gets an offline, or online player by UUID.- Parameters:
id
- The UUID to match.- Returns:
- The player, or offline player with the provided UUID.
- See Also:
-
clearOnlinePlayers
public void clearOnlinePlayers()Clears all online players. -
clearOfflinePlayers
public void clearOfflinePlayers()Clears all offline players. -
addOperator
Adds a Player to the list of known Operators.- Parameters:
operator
- TheUUID
of the Operator to add.
-
removeOperator
Removes a Player from the list of known Operators.- Parameters:
operator
- TheUUID
of the Operator to remove.
-