mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-22 08:02:31 +01:00
Cache unmodifiable players set, remove print
This commit is contained in:
parent
49944fb651
commit
a55ae4d048
@ -46,6 +46,7 @@ public final class ConnectionManager {
|
|||||||
|
|
||||||
private final Queue<Player> waitingPlayers = new ConcurrentLinkedQueue<>();
|
private final Queue<Player> waitingPlayers = new ConcurrentLinkedQueue<>();
|
||||||
private final Set<Player> players = new CopyOnWriteArraySet<>();
|
private final Set<Player> players = new CopyOnWriteArraySet<>();
|
||||||
|
private final Set<Player> unmodifiablePlayers = Collections.unmodifiableSet(players);
|
||||||
private final Map<PlayerConnection, Player> connectionPlayerMap = new ConcurrentHashMap<>();
|
private final Map<PlayerConnection, Player> connectionPlayerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// All the consumers to call once a packet is received
|
// All the consumers to call once a packet is received
|
||||||
@ -76,9 +77,8 @@ public final class ConnectionManager {
|
|||||||
*
|
*
|
||||||
* @return an unmodifiable collection containing all the online players
|
* @return an unmodifiable collection containing all the online players
|
||||||
*/
|
*/
|
||||||
@NotNull
|
public @NotNull Collection<@NotNull Player> getOnlinePlayers() {
|
||||||
public Collection<Player> getOnlinePlayers() {
|
return unmodifiablePlayers;
|
||||||
return Collections.unmodifiableCollection(players);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,8 +88,7 @@ public final class ConnectionManager {
|
|||||||
* @param username the player username (can be partial)
|
* @param username the player username (can be partial)
|
||||||
* @return the closest match, null if no players are online
|
* @return the closest match, null if no players are online
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public @Nullable Player findPlayer(@NotNull String username) {
|
||||||
public Player findPlayer(@NotNull String username) {
|
|
||||||
Player exact = getPlayer(username);
|
Player exact = getPlayer(username);
|
||||||
if (exact != null) return exact;
|
if (exact != null) return exact;
|
||||||
|
|
||||||
@ -145,7 +144,6 @@ public final class ConnectionManager {
|
|||||||
*
|
*
|
||||||
* @param jsonMessage the message to send, probably a {@link net.minestom.server.chat.ColoredText} or {@link net.minestom.server.chat.RichMessage}
|
* @param jsonMessage the message to send, probably a {@link net.minestom.server.chat.ColoredText} or {@link net.minestom.server.chat.RichMessage}
|
||||||
* @param condition the condition to receive the message
|
* @param condition the condition to receive the message
|
||||||
*
|
|
||||||
* @deprecated Use {@link Audiences#players(Predicate)}
|
* @deprecated Use {@link Audiences#players(Predicate)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -315,7 +313,6 @@ public final class ConnectionManager {
|
|||||||
* Gets the kick reason when the server is shutdown using {@link MinecraftServer#stopCleanly()}.
|
* Gets the kick reason when the server is shutdown using {@link MinecraftServer#stopCleanly()}.
|
||||||
*
|
*
|
||||||
* @return the kick reason in case on a shutdown
|
* @return the kick reason in case on a shutdown
|
||||||
*
|
|
||||||
* @deprecated Use {@link #getShutdownText()}
|
* @deprecated Use {@link #getShutdownText()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -242,8 +242,6 @@ public class PlayerInit {
|
|||||||
.canDestroy(Set.of(Block.DIAMOND_ORE)))
|
.canDestroy(Set.of(Block.DIAMOND_ORE)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
System.out.println(itemStack.getMeta().toSNBT());
|
|
||||||
|
|
||||||
//itemStack = itemStack.withStore(storeBuilder -> storeBuilder.set("key2", 25, Integer::sum));
|
//itemStack = itemStack.withStore(storeBuilder -> storeBuilder.set("key2", 25, Integer::sum));
|
||||||
|
|
||||||
inventory.addItemStack(itemStack);
|
inventory.addItemStack(itemStack);
|
||||||
|
Loading…
Reference in New Issue
Block a user