diff options
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/utils/PlayerUtils.java')
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/utils/PlayerUtils.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/utils/PlayerUtils.java b/src/main/java/lv/enes/mc/eris_alchemy/utils/PlayerUtils.java new file mode 100644 index 0000000..6320d6f --- /dev/null +++ b/src/main/java/lv/enes/mc/eris_alchemy/utils/PlayerUtils.java | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | package lv.enes.mc.eris_alchemy.utils; | ||
| 2 | |||
| 3 | import net.minecraft.server.level.ServerPlayer; | ||
| 4 | import org.quiltmc.qsl.networking.api.ServerPlayConnectionEvents; | ||
| 5 | |||
| 6 | import java.util.HashSet; | ||
| 7 | import java.util.Set; | ||
| 8 | |||
| 9 | public final class PlayerUtils { | ||
| 10 | private PlayerUtils() {} | ||
| 11 | |||
| 12 | private static final Set<ServerPlayer> ALL_PLAYERS = new HashSet<>(); | ||
| 13 | |||
| 14 | public static Set<ServerPlayer> all() { | ||
| 15 | return ALL_PLAYERS; | ||
| 16 | } | ||
| 17 | |||
| 18 | public static void init() { | ||
| 19 | ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> ALL_PLAYERS.add(handler.getPlayer())); | ||
| 20 | ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> ALL_PLAYERS.remove(handler.getPlayer())); | ||
| 21 | } | ||
| 22 | } | ||