Class PlayerUtils

java.lang.Object
io.hymods.lib.utils.PlayerUtils

public class PlayerUtils extends Object
Utility class for player-related operations
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    broadcast(com.hypixel.hytale.server.core.universe.world.World world, String message)
    Broadcasts a message to all players
    static void
    forEachPlayer(com.hypixel.hytale.server.core.universe.world.World world, Consumer<com.hypixel.hytale.server.core.entity.entities.Player> action)
    Executes an action for each online player
    static List<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>>
    getAllPlayers(com.hypixel.hytale.server.core.universe.world.World world)
    Gets all online players in a world
    static double
    getDistanceBetweenPlayers(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref1, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref2, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the distance between two players
    static double
    getDistanceSquaredBetweenPlayers(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref1, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref2, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the squared distance between two players
    static com.hypixel.hytale.server.core.entity.entities.Player
    getPlayer(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets the Player component from a reference
    static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>
    getPlayerByName(com.hypixel.hytale.server.core.universe.world.World world, String name)
    Gets a player by their display name
    static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>
    getPlayerByUUID(com.hypixel.hytale.server.core.universe.world.World world, UUID uuid)
    Gets a player by their UUID
    static com.hypixel.hytale.math.vector.Vector3d
    getPlayerLookDirection(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets a player's look direction
    static com.hypixel.hytale.math.vector.Vector3d
    getPlayerPosition(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
    Gets a player's position
    static List<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>>
    getPlayersInRadius(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius)
    Gets players within a certain radius of a position
    static boolean
    hasLineOfSight(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, com.hypixel.hytale.math.vector.Vector3d target, double maxDistance)
    Checks if a player has line of sight to a position
    static boolean
    isPlayerWithinDistance(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, com.hypixel.hytale.math.vector.Vector3d position, double distance)
    Checks if a player is within a certain distance of a position
    static void
    sendFormattedMessage(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String format, Object... args)
    Sends a formatted message to a player
    static void
    sendMessage(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String message)
    Sends a message to a player

    Methods inherited from class Object

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

    • getPlayerByUUID

      public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> getPlayerByUUID(com.hypixel.hytale.server.core.universe.world.World world, UUID uuid)
      Gets a player by their UUID
      Parameters:
      world - The world to search in
      uuid - The player's UUID
      Returns:
      The player reference, or null if not found
    • getPlayerByName

      public static com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> getPlayerByName(com.hypixel.hytale.server.core.universe.world.World world, String name)
      Gets a player by their display name
      Parameters:
      world - The world to search in
      name - The player's display name
      Returns:
      The player reference, or null if not found
    • getAllPlayers

      public static List<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> getAllPlayers(com.hypixel.hytale.server.core.universe.world.World world)
      Gets all online players in a world
      Parameters:
      world - The world to search in
      Returns:
      List of player references
    • getPlayersInRadius

      public static List<com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore>> getPlayersInRadius(com.hypixel.hytale.server.core.universe.world.World world, com.hypixel.hytale.math.vector.Vector3d center, double radius)
      Gets players within a certain radius of a position
      Parameters:
      world - The world to search in
      center - The center position
      radius - The search radius
      Returns:
      List of player references within radius
    • getPlayer

      public static com.hypixel.hytale.server.core.entity.entities.Player getPlayer(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the Player component from a reference
      Parameters:
      ref - The entity reference
      store - The entity store
      Returns:
      The Player component, or null if not a player
    • getPlayerPosition

      public static com.hypixel.hytale.math.vector.Vector3d getPlayerPosition(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets a player's position
      Parameters:
      ref - The player reference
      store - The entity store
      Returns:
      The player's position, or null if not found
    • getPlayerLookDirection

      public static com.hypixel.hytale.math.vector.Vector3d getPlayerLookDirection(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets a player's look direction
      Parameters:
      ref - The player reference
      store - The entity store
      Returns:
      The player's look direction vector, or null if not found
    • sendMessage

      public static void sendMessage(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String message)
      Sends a message to a player
      Parameters:
      ref - The player reference
      store - The entity store
      message - The message to send
    • sendFormattedMessage

      public static void sendFormattedMessage(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, String format, Object... args)
      Sends a formatted message to a player
      Parameters:
      ref - The player reference
      store - The entity store
      format - The message format
      args - The format arguments
    • broadcast

      public static void broadcast(com.hypixel.hytale.server.core.universe.world.World world, String message)
      Broadcasts a message to all players
      Parameters:
      world - The world to broadcast in
      message - The message to broadcast
    • forEachPlayer

      public static void forEachPlayer(com.hypixel.hytale.server.core.universe.world.World world, Consumer<com.hypixel.hytale.server.core.entity.entities.Player> action)
      Executes an action for each online player
      Parameters:
      world - The world to iterate in
      action - The action to execute for each player
    • hasLineOfSight

      public static boolean hasLineOfSight(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, com.hypixel.hytale.math.vector.Vector3d target, double maxDistance)
      Checks if a player has line of sight to a position
      Parameters:
      ref - The player reference
      store - The entity store
      target - The target position
      maxDistance - The maximum distance to check
      Returns:
      true if the player has line of sight
    • getDistanceBetweenPlayers

      public static double getDistanceBetweenPlayers(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref1, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref2, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the distance between two players
      Parameters:
      ref1 - First player reference
      ref2 - Second player reference
      store - The entity store
      Returns:
      The distance between players, or -1 if either is invalid
    • getDistanceSquaredBetweenPlayers

      public static double getDistanceSquaredBetweenPlayers(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref1, com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref2, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store)
      Gets the squared distance between two players
      Parameters:
      ref1 - First player reference
      ref2 - Second player reference
      store - The entity store
      Returns:
      The squared distance between players, or -1 if either is invalid
    • isPlayerWithinDistance

      public static boolean isPlayerWithinDistance(com.hypixel.hytale.component.Ref<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> ref, com.hypixel.hytale.component.Store<com.hypixel.hytale.server.core.universe.world.storage.EntityStore> store, com.hypixel.hytale.math.vector.Vector3d position, double distance)
      Checks if a player is within a certain distance of a position
      Parameters:
      ref - The player reference
      store - The entity store
      position - The position to check
      distance - The maximum distance
      Returns:
      true if the player is within distance