Class PlayerApi

java.lang.Object
com.shanebeestudios.nms.api.world.entity.PlayerApi

public class PlayerApi extends Object
Api methods pertaining to a Player
  • Method Details

    • spawnFakePlayer

      public static FakePlayer spawnFakePlayer(String name, Location loc)
      Spawn a FakePlayer

      This will cache the fake player as well for later retrieval

      Parameters:
      name - Name of fake player
      loc - Location of fake player
      Returns:
      FakePlayer instance
    • spawnFakePlayer

      public static FakePlayer spawnFakePlayer(@NotNull @NotNull String name, @NotNull @NotNull Location loc, @Nullable @Nullable EntityType attachType)
      Spawn a FakePlayer

      This will cache the fake player as well for later retrieval

      NOTE: The attached entity will spawn, and the player will take over its AI, This may cause some client lag depending on the chosen entity.

      Will automatically update to all players

      Parameters:
      name - Name of fake player
      loc - Location of fake player
      attachType - Type of entity to spawn and attach the player to
      Returns:
      FakePlayer instance
    • spawnFakePlayer

      public static FakePlayer spawnFakePlayer(@NotNull @NotNull String name, @NotNull @NotNull Location loc, @Nullable @Nullable EntityType attachType, boolean update)
      Spawn a FakePlayer

      This will cache the fake player as well for later retrieval

      NOTE: The attached entity will spawn, and the player will take over its AI, This may cause some client lag depending on the chosen entity.

      If not using update, use FakePlayer.update() or FakePlayer.update(Player) to update to players.

      Parameters:
      name - Name of fake player
      loc - Location of fake player
      attachType - Type of entity to spawn and attach the player to
      update - Whether to update the fake player to all online players
      Returns:
      FakePlayer instance
    • spawnFakePlayerAsync

      public static CompletableFuture<FakePlayer> spawnFakePlayerAsync(String name, Location loc)
      Spawn a FakePlayer async

      This will cache the fake player as well for later retrieval

      Parameters:
      name - Name of fake player
      loc - Location of fake player
      Returns:
      FakePlayer instance
    • spawnFakePlayerAsync

      public static CompletableFuture<FakePlayer> spawnFakePlayerAsync(@NotNull @NotNull String name, @NotNull @NotNull Location loc, @Nullable @Nullable EntityType attachType)
      Spawn a FakePlayer async

      This will cache the fake player as well for later retrieval

      NOTE: The attached entity will spawn, and the player will take over its AI, This may cause some client lag depending on the chosen entity.

      Will automatically update to all players.

      Parameters:
      name - Name of fake player
      loc - Location of fake player
      attachType - Type of entity to spawn and attach the player to
      Returns:
      FakePlayer instance
    • spawnFakePlayerAsync

      public static CompletableFuture<FakePlayer> spawnFakePlayerAsync(@NotNull @NotNull String name, @NotNull @NotNull Location loc, @Nullable @Nullable EntityType attachType, boolean update)
      Spawn a FakePlayer async

      This will cache the fake player as well for later retrieval

      NOTE: The attached entity will spawn, and the player will take over its AI, This may cause some client lag depending on the chosen entity.

      If not using update, use FakePlayer.update() or FakePlayer.update(Player) to update to players.

      Parameters:
      name - Name of fake player
      loc - Location of fake player
      attachType - Type of entity to spawn and attach the player to
      update - Whether to update the fake player to all online players
      Returns:
      FakePlayer instance
    • getFakePlayer

      @Nullable public static @Nullable FakePlayer getFakePlayer(String name)
      Get a previously cached FakePlayer
      Parameters:
      name - Name of fake player
      Returns:
      FakePlayer if cached otherwise null
    • getFakePlayers

      public static List<FakePlayer> getFakePlayers()
      Get all fake players
      Returns:
      List of all fake players
    • getPlayerConnection

      @NotNull public static @NotNull net.minecraft.server.network.ServerGamePacketListenerImpl getPlayerConnection(@NotNull @NotNull Player player)
      Get the Player's connection
      Useful for sending packets
      Parameters:
      player - Bukkit Player to get connection from
      Returns:
      Connection from Player
    • sendPacket

      public static void sendPacket(@NotNull @NotNull Player player, @NotNull @NotNull net.minecraft.network.protocol.Packet<?> packet)
      Send a Packet to a Bukkit Player
      Parameters:
      player - Player to send packet to
      packet - Packet to send