Player API — extends Entity

Player

Player extends Entity with player-specific functionality: health, hunger, experience, permissions, inventory, tab list, game mode, and more.


Constructor

Player(uuid: str | None = None, name: str | None = None)

Resolve a player by UUID or name. At least one must be provided. The player must be online.

p = Player(name="Steve")
p = Player(uuid="550e8400-e29b-41d4-a716-446655440000")

Attributes

name

The player's display name.

uuid

The player's UUID.

location

Current player location.

world

The world the player is in.

health

Current health (0–20 by default, 0 = dead).

food_level

Hunger level (0–20, 20 = full).

game_mode

Current game mode (e.g. GameMode.SURVIVAL, GameMode.CREATIVE).

inventory

The player's inventory (36 slots + armor + offhand).

level

Player experience level (the green number).

exp

Experience progress within the current level (0.0 to 1.0).

is_op

Whether the player is a server operator.

is_flying

Whether the player is currently flying.

is_sneaking

Whether the player is sneaking (shift held).

is_sprinting

Whether the player is sprinting.

scoreboard

The player's current scoreboard.

permission_groups

The player's permission groups. LuckPerms-aware — returns LuckPerms groups if available, otherwise falls back to the basic permission system.

primary_group

The player's primary permission group (LuckPerms). None if LuckPerms is not installed.

tab_list_header

The player's tab list header text.

The player's tab list footer text.

tab_list_name

The player's display name in the tab list.


Methods

send_message

await player.send_message(message)

Send a chat message to the player.

await player.send_message("§aYou found a secret!")

chat

await player.chat(message)

Make the player send a chat message (as if they typed it).

kick

await player.kick(reason="")

Kick the player from the server.

await player.kick("§cYou have been banned!")

teleport

await player.teleport(location)

Teleport the player. Inherited from Entity.

give_exp

await player.give_exp(amount)

Give raw experience points to the player.

set_exp

await player.set_exp(exp)

Set the experience progress bar within the current level.

set_level

await player.set_level(level)

Set the player's experience level.

set_health

await player.set_health(health)

Set the player's health.

set_food_level

await player.set_food_level(level)

Set the player's hunger level.

set_game_mode

await player.set_game_mode(mode)

Set the player's game mode.

await player.set_game_mode(GameMode.CREATIVE)

set_op

await player.set_op(value)

Set operator status.

set_flying

await player.set_flying(value)

Set flying state. The player must be allowed to fly (creative mode or flight allowed).

set_sneaking

await player.set_sneaking(value)

Force the sneaking state.

set_sprinting

await player.set_sprinting(value)

Force the sprinting state.

set_walk_speed

await player.set_walk_speed(speed)

Set walking speed.

set_fly_speed

await player.set_fly_speed(speed)

Set flying speed.

set_scoreboard

await player.set_scoreboard(scoreboard)

Set the player's active scoreboard.


Effects

effects

effects = player.effects

Get a list of the player's active potion effects.

for effect in player.effects:
    print(f"{effect.type}: amplifier {effect.amplifier}, {effect.duration} ticks left")

add_effect

await player.add_effect(effect)

Apply a potion effect to the player.

await player.add_effect(Effect(EffectType.SPEED, duration=200, amplifier=1))

remove_effect

await player.remove_effect(effect_type)

Remove an active potion effect.


Sounds & UI

play_sound

await player.play_sound(sound, volume=1.0, pitch=1.0)

Play a sound to the player at their location.

await player.play_sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP)
await player.play_sound('block_note_block_bass', volume=0.5, pitch=2.0)

set_resource_pack

await player.set_resource_pack(url, hash="", prompt=None, required=False)

Send a resource pack to the player.

await player.set_resource_pack(
    "https://example.com/pack.zip",
    hash="a1b2c3d4e5f6...",
    prompt="Download our custom textures!",
    required=True
)

send_action_bar

await player.send_action_bar(message)

Display a message in the action bar (above the hotbar).

send_title

await player.send_title(title, subtitle="", fade_in=10, stay=70, fade_out=20)

Display a title and subtitle on the player's screen.

await player.send_title("§6Victory!", "§eYou won the game", fade_in=5, stay=40, fade_out=10)

Tab List

set_tab_list_header

await player.set_tab_list_header(header)

Set the header text shown above the player list in the tab screen.

await player.set_tab_list_footer(footer)

Set the footer text shown below the player list.

await player.set_tab_list_header_footer(header="", footer="")

Set both header and footer in a single call.

set_tab_list_name

await player.set_tab_list_name(name)

Set the player's display name in the tab list.

await player.set_tab_list_name("§c[Admin]§r Steve")

Permissions

has_permission

result = await player.has_permission(permission)

Check if the player has a permission node.

add_permission

result = await player.add_permission(permission, value=True)

Add or set a permission on the player. LuckPerms-aware.

remove_permission

result = await player.remove_permission(permission)

Remove a permission from the player. LuckPerms-aware.

has_group

result = await player.has_group(group)

Check if the player belongs to a permission group. LuckPerms only.

add_group

result = await player.add_group(group)

Add the player to a permission group. LuckPerms only.

remove_group

result = await player.remove_group(group)

Remove the player from a permission group. LuckPerms only.