mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
Replace Collections2.transform with forced Collection iteration.
This commit is contained in:
parent
ef14547959
commit
f0164c3c8c
@ -36,10 +36,7 @@ import lombok.NonNull;
|
|||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungee#getApi()}.
|
* This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungee#getApi()}.
|
||||||
@ -105,21 +102,17 @@ public class RedisBungeeAPI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a combined list of players on this network, as a collection of usernames.
|
* Get a combined list of players on this network, as a collection of usernames.
|
||||||
* <p>
|
|
||||||
* <strong>Note that this function returns an immutable {@link java.util.Collection}, and usernames
|
|
||||||
* are lazily calculated (but cached, see the contract of {@link #getNameFromUuid(java.util.UUID)}).</strong>
|
|
||||||
*
|
*
|
||||||
* @return a Set with all players found
|
* @return a Set with all players found
|
||||||
* @see #getNameFromUuid(java.util.UUID)
|
* @see #getNameFromUuid(java.util.UUID)
|
||||||
* @since 0.3
|
* @since 0.3
|
||||||
*/
|
*/
|
||||||
public final Collection<String> getHumanPlayersOnline() {
|
public final Collection<String> getHumanPlayersOnline() {
|
||||||
return Collections2.transform(((ImmutableSet<UUID>) getPlayersOnline()).asList(), new Function<UUID, String>() {
|
Set<String> names = new HashSet<>();
|
||||||
@Override
|
for (UUID uuid : getPlayersOnline()) {
|
||||||
public String apply(UUID uuid) {
|
names.add(getNameFromUuid(uuid, false));
|
||||||
return getNameFromUuid(uuid, false);
|
|
||||||
}
|
}
|
||||||
});
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -269,8 +262,7 @@ public class RedisBungeeAPI {
|
|||||||
* Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function falls back to Mojang
|
* Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function falls back to Mojang
|
||||||
* as a last resort, so calls <strong>may</strong> be blocking.
|
* as a last resort, so calls <strong>may</strong> be blocking.
|
||||||
* <p>
|
* <p>
|
||||||
* For the common use case of translating a list of UUIDs into names, use {@link #getHumanPlayersOnline()}
|
* For the common use case of translating a list of UUIDs into names, use {@link #getHumanPlayersOnline()} instead.
|
||||||
* as the efficiency of that function is slightly greater as the names are calculated lazily.
|
|
||||||
* <p>
|
* <p>
|
||||||
* If performance is a concern, use {@link #getNameFromUuid(java.util.UUID, boolean)} as this allows you to disable Mojang lookups.
|
* If performance is a concern, use {@link #getNameFromUuid(java.util.UUID, boolean)} as this allows you to disable Mojang lookups.
|
||||||
*
|
*
|
||||||
@ -286,8 +278,7 @@ public class RedisBungeeAPI {
|
|||||||
* Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function can fall back to Mojang
|
* Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function can fall back to Mojang
|
||||||
* as a last resort if {@code expensiveLookups} is true, so calls <strong>may</strong> be blocking.
|
* as a last resort if {@code expensiveLookups} is true, so calls <strong>may</strong> be blocking.
|
||||||
* <p>
|
* <p>
|
||||||
* For the common use case of translating the list of online players into names, use {@link #getHumanPlayersOnline()}
|
* For the common use case of translating the list of online players into names, use {@link #getHumanPlayersOnline()}.
|
||||||
* as the efficiency of that function is slightly greater as the names are calculated lazily.
|
|
||||||
* <p>
|
* <p>
|
||||||
* If performance is a concern, set {@code expensiveLookups} to false as this will disable lookups via Mojang.
|
* If performance is a concern, set {@code expensiveLookups} to false as this will disable lookups via Mojang.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user