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 TypeMethodDescriptionvoidaddOfflinePlayer(@NotNull org.bukkit.OfflinePlayer player) Adds an offline player to the offline players set.voidaddOperator(UUID operator) Adds a Player to the list of known Operators.voidaddPlayer(@NotNull PlayerMock player) Marks a player as on the server, and sets related data like hasPlayedBefore and lastLogin.voidClears all offline players.voidClears all online players.voiddisconnectPlayer(@NotNull PlayerMock player) Marks a player as disconnected, and sets related data like lastSeen.longgetFirstPlayed(UUID uuid) Gets the first time that this player was seen on the server.@NotNull MockIpBanListlonggetLastLogin(UUID uuid) Gets the last time a player was seen online.longgetLastSeen(UUID uuid) Gets the last time a player was seen online.int@NotNull org.bukkit.OfflinePlayergetOfflinePlayer(@NotNull String name) Gets an offline, or online player by name.@Nullable org.bukkit.OfflinePlayergetOfflinePlayer(@NotNull UUID id) Gets an offline, or online player by UUID.@Nullable org.bukkit.OfflinePlayer@NotNull org.bukkit.OfflinePlayer @NotNull []@NotNull Collection<PlayerMock> @NotNull Set<org.bukkit.OfflinePlayer> @NotNull PlayerMockgetPlayer(int index) Gets a player at the provided index.@Nullable org.bukkit.entity.PlayerFinds the player with the closest matching name.@Nullable org.bukkit.entity.Player@Nullable org.bukkit.entity.PlayergetPlayerExact(@NotNull String name) Matches a player by their exact name.@NotNull MockProfileBanListbooleanhasPlayedBefore(@NotNull UUID uuid) Checks if a player has played before.boolean@NotNull List<org.bukkit.entity.Player> matchPlayer(@NotNull String name) Matches a player by partial name.voidremoveOperator(UUID operator) Removes a Player from the list of known Operators.voidsetFirstPlayed(UUID uuid, long firstPlayed) Sets the return value ofgetFirstPlayed(UUID).voidsetLastLogin(UUID uuid, long lastLogin) Sets the return value ofgetLastLogin(UUID).voidsetLastSeen(UUID uuid, long lastSeen) Sets the return value ofgetLastLogin(UUID)while the player is offline.voidsetMaxPlayers(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
@Internal public void addOfflinePlayer(@NotNull @NotNull org.bukkit.OfflinePlayer player) 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
@NotNull public @NotNull org.bukkit.OfflinePlayer @NotNull [] 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- TheUUIDof the Operator to add.
-
removeOperator
Removes a Player from the list of known Operators.- Parameters:
operator- TheUUIDof the Operator to remove.
-
getOfflinePlayerIfCached
-