Class ServerUtils

java.lang.Object
com.minecolonies.core.util.ServerUtils

public final class ServerUtils extends Object
Utility for server related stuff.

Here you can query players on the server.

Since:
0.2
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable net.minecraft.world.entity.player.Player
    getPlayerFromPermPlayer(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.world.level.Level world)
    Retrieves a Player from Player.
    static @Nullable net.minecraft.world.entity.player.Player
    getPlayerFromUUID(@Nullable UUID uuid, @NotNull net.minecraft.world.level.Level world)
    Finds a player by his UUID
    static @Nullable net.minecraft.world.entity.player.Player
    getPlayerFromUUID(@NotNull net.minecraft.world.level.Level world, @NotNull UUID id)
    Returns the online PlayerEntity with the given UUID.
    static @NotNull List<net.minecraft.world.entity.player.Player>
    getPlayersFromPermPlayer(@NotNull List<net.minecraft.world.entity.player.Player> players, @NotNull net.minecraft.world.level.Level world)
    Returns a list of players from a list of ColonyPlayer.
    static @NotNull List<net.minecraft.world.entity.player.Player>
    getPlayersFromUUID(@Nullable net.minecraft.world.level.Level world, @NotNull Collection<UUID> ids)
    Returns a list of online players whose UUID's match the ones provided.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPlayerFromUUID

      @Nullable public static @Nullable net.minecraft.world.entity.player.Player getPlayerFromUUID(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull UUID id)
      Returns the online PlayerEntity with the given UUID.
      Parameters:
      world - world the player is in
      id - the player's UUID
      Returns:
      the Player
    • getPlayersFromUUID

      @NotNull public static @NotNull List<net.minecraft.world.entity.player.Player> getPlayersFromUUID(@Nullable @Nullable net.minecraft.world.level.Level world, @NotNull @NotNull Collection<UUID> ids)
      Returns a list of online players whose UUID's match the ones provided.
      Parameters:
      world - the world the players are in.
      ids - List of UUIDs
      Returns:
      list of PlayerEntitys
    • getPlayersFromPermPlayer

      @NotNull public static @NotNull List<net.minecraft.world.entity.player.Player> getPlayersFromPermPlayer(@NotNull @NotNull List<net.minecraft.world.entity.player.Player> players, @NotNull @NotNull net.minecraft.world.level.Level world)
      Returns a list of players from a list of ColonyPlayer.

      The ColonyPlayer is a wrapper around a UUID of minecraft players. The List will simply be converted into an Player type.

      Uses getPlayersFromPermPlayer(List, Level).

      Parameters:
      players - The list of players to convert.
      world - an instance of the world.
      Returns:
      A list of Players
    • getPlayerFromPermPlayer

      @Nullable public static @Nullable net.minecraft.world.entity.player.Player getPlayerFromPermPlayer(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.world.level.Level world)
      Retrieves a Player from Player.

      Simply converts our type into the base type.

      Passes this ColonyPlayer.getID() to getPlayerFromUUID(Level, UUID).

      Parameters:
      player - The ColonyPlayer to convert
      world - an instance of the world.
      Returns:
      The Player reference.
    • getPlayerFromUUID

      @Nullable public static @Nullable net.minecraft.world.entity.player.Player getPlayerFromUUID(@Nullable @Nullable UUID uuid, @NotNull @NotNull net.minecraft.world.level.Level world)
      Finds a player by his UUID

      Found on jabelarminecraft.

      Parameters:
      uuid - the uuid to search for
      world - an instance of the world.
      Returns:
      The player the player if found or null