mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-09 04:09:43 +01:00
Correctly modify player sample with hidden player counts.
At the moment the setPlayers() method will throw a NullPointerException if the player count has been hidden. This will correctly reset the player counts before setting the player list and return null in the getter instead of throwing an exception.
This commit is contained in:
parent
31b26fd0c5
commit
3e7fe52681
@ -241,9 +241,11 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a copy of all the logged in players.
|
* Retrieve a copy of all the logged in players.
|
||||||
* @return Logged in players.
|
* @return Logged in players or NULL if the player count has been hidden via {@link #setPlayersVisible(boolean)}.
|
||||||
*/
|
*/
|
||||||
public ImmutableList<WrappedGameProfile> getPlayers() {
|
public ImmutableList<WrappedGameProfile> getPlayers() {
|
||||||
|
if (players == null)
|
||||||
|
return null;
|
||||||
return ImmutableList.copyOf(PROFILE_CONVERT.getSpecific(PLAYERS_PROFILES.get(players)));
|
return ImmutableList.copyOf(PROFILE_CONVERT.getSpecific(PLAYERS_PROFILES.get(players)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +254,8 @@ public class WrappedServerPing extends AbstractWrapper {
|
|||||||
* @param profile - every logged in player.
|
* @param profile - every logged in player.
|
||||||
*/
|
*/
|
||||||
public void setPlayers(Iterable<? extends WrappedGameProfile> profile) {
|
public void setPlayers(Iterable<? extends WrappedGameProfile> profile) {
|
||||||
|
if (players == null)
|
||||||
|
resetPlayers();
|
||||||
PLAYERS_PROFILES.set(players, PROFILE_CONVERT.getGeneric(GameProfile[].class, profile));
|
PLAYERS_PROFILES.set(players, PROFILE_CONVERT.getGeneric(GameProfile[].class, profile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user