Class PlayerUtils
java.lang.Object
io.hymods.lib.utils.PlayerUtils
Utility class for player-related operations
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidBroadcasts a message to all playersstatic voidforEachPlayer(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 playerstatic 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 worldstatic doublegetDistanceBetweenPlayers(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 playersstatic doublegetDistanceSquaredBetweenPlayers(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 playersstatic com.hypixel.hytale.server.core.entity.entities.PlayergetPlayer(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 referencestatic 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 namestatic 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 UUIDstatic com.hypixel.hytale.math.vector.Vector3dgetPlayerLookDirection(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 directionstatic com.hypixel.hytale.math.vector.Vector3dgetPlayerPosition(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 positionstatic 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 positionstatic booleanhasLineOfSight(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 positionstatic booleanisPlayerWithinDistance(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 positionstatic voidsendFormattedMessage(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 playerstatic voidsendMessage(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
-
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 inuuid- 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 inname- 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 incenter- The center positionradius- 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 referencestore- 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 referencestore- 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 referencestore- 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 referencestore- The entity storemessage- 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 referencestore- The entity storeformat- The message formatargs- 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 inmessage- 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 inaction- 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 referencestore- The entity storetarget- The target positionmaxDistance- 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 referenceref2- Second player referencestore- 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 referenceref2- Second player referencestore- 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 referencestore- The entity storeposition- The position to checkdistance- The maximum distance- Returns:
- true if the player is within distance
-