1- package one .tranic .t .base . player ;
1+ package one .tranic .t .base ;
22
3+ import one .tranic .t .base .command .source .SystemCommandSource ;
4+ import one .tranic .t .base .player .Player ;
35import one .tranic .t .utils .Collections ;
6+ import one .tranic .t .utils .minecraft .Platform ;
47import org .jetbrains .annotations .NotNull ;
58import org .jetbrains .annotations .Nullable ;
69
710import java .util .List ;
811import java .util .Objects ;
912import java .util .UUID ;
10- import java .util .function .Function ;
11- import java .util .function .Supplier ;
1213
13- @ SuppressWarnings ("unused" )
14- public class Players {
15- // Ignore the "never allocated" warning here, it will be set by the common package via reflection.
16- private static Function <String , Player <?>> getPlayerWithStringMethod ;
17- private static Function <UUID , Player <?>> getPlayerWithUUIDMethod ;
18- private static Supplier <List <Player <?>>> getOnlinePlayersMethod ;
19- private static Supplier <List <?>> getPlatformOnlinePlayersMethod ;
20- private static Supplier <List <String >> getOnlinePlayersNameMethod ;
14+ public interface TInterface {
15+ Platform [] getSupportedPlatforms ();
16+
17+ SystemCommandSource <?, ?> getConsoleSource ();
2118
2219 /**
2320 * Retrieves a player instance based on their player name.
2421 *
2522 * @param name the name of the player to search for; must not be null
2623 * @return the {@code Player} instance corresponding to the given name, or {@code null} if no player is found
2724 */
28- public static @ Nullable Player <?> getPlayer (@ NotNull String name ) {
29- return getPlayerWithStringMethod .apply (name );
30- }
25+ @ Nullable Player <?> getPlayer (@ NotNull String name );
3126
3227 /**
3328 * Retrieves a player using their unique identifier (UUID).
@@ -36,19 +31,15 @@ public class Players {
3631 * @return a {@code Player<?>} instance if a player with the given UUID exists;
3732 * otherwise, {@code null}
3833 */
39- public static @ Nullable Player <?> getPlayer (@ NotNull UUID uuid ) {
40- return getPlayerWithUUIDMethod .apply (uuid );
41- }
34+ @ Nullable Player <?> getPlayer (@ NotNull UUID uuid );
4235
4336 /**
4437 * Retrieves a list of all online players currently connected to the server.
4538 *
4639 * @return a {@code List} of {@code Player<?>} representing each online player;
4740 * the list is guaranteed to be non-null.
4841 */
49- public static @ NotNull List <Player <?>> getOnlinePlayers () {
50- return getOnlinePlayersMethod .get ();
51- }
42+ @ NotNull List <Player <?>> getOnlinePlayers ();
5243
5344 /**
5445 * Retrieves a list of alternative players who are connected to the same host
@@ -67,7 +58,7 @@ public class Players {
6758 * the list is guaranteed to be non-null but may be empty if no other
6859 * players share the same connected host
6960 */
70- public static @ NotNull List <Player <?>> getAltPlayers (@ NotNull Player <?> player ) {
61+ default @ NotNull List <Player <?>> getAltPlayers (@ NotNull Player <?> player ) {
7162 final List <Player <?>> end = Collections .newArrayList ();
7263 final List <Player <?>> players = getOnlinePlayers ();
7364 for (Player <?> p : players ) {
@@ -85,17 +76,13 @@ public class Players {
8576 * @return a {@code List<?>} representing the platform-specific online players;
8677 * the list is guaranteed to be non-null.
8778 */
88- public static @ NotNull List <?> getPlatformOnlinePlayers () {
89- return getPlatformOnlinePlayersMethod .get ();
90- }
79+ @ NotNull List <?> getPlatformOnlinePlayers ();
9180
9281 /**
9382 * Retrieves a list of the names of all online players currently connected to the server.
9483 *
9584 * @return a {@code List} of {@code String} containing the names of online players;
9685 * the list is guaranteed to be non-null.
9786 */
98- public static @ NotNull List <String > getOnlinePlayersName () {
99- return getOnlinePlayersNameMethod .get ();
100- }
87+ @ NotNull List <String > getOnlinePlayersName ();
10188}
0 commit comments