Skip to content

PlayerScriptObject

Represents a player or console command caller, exposing usernames, UUIDs, NBT data, messaging, permissions, and per-player persistence. Obtain it from player events or through server.get_player().

View the source: PlayerScriptObject

Returns a bool if the player has the specified permission. This is used internally for validating permissions of @player.on_alias events

  • Permission tree order is: server > op > anyone. Custom permissions are independent of defaults, must be granted explicitly with player.set_permission(), and will return False by default

  • These are arbitrary permissions for moderating auto-mcs commands, and have no relation to Bukkit permissions

ParametersTypeDescription
permission*strThe permission name

player.set_permission(permission, enable=True)

Section titled “player.set_permission(permission, enable=True)”

Sets a custom permission for @player.on_alias events. Any value other than the default permissions of 'anyone', 'op', or 'server'. Names are enforced lowercase with no leading/trailing space

  • Custom permissions are independent of defaults, and must be granted explicitly with this method.

  • These are arbitrary permissions for moderating auto-mcs commands, and have no relation to Bukkit permissions

ParametersTypeDescription
permission*strThe permission name
enableboolEnable or disable the permission. Defaults to True

player.log(message, color="gray", style="italic", hyperlink=None)

Section titled “player.log(message, color="gray", style="italic", hyperlink=None)”

Sends a private message to the chat of the player with formatting support. Useful for command feedback with a @player.on_alias event

  • player.log_success(), player.log_warning(), and player.log_error() methods can also be used, and only require the message parameter
ParametersTypeDescription
message*strContent to log to the player
colorstrMinecraft color ID, all values for /tellraw are accepted; see all color IDs
stylestrCan be 'normal', 'italic', 'bold', 'strikethrough', 'underlined', or 'obfuscated'. Defaults to 'italic'
hyperlinkstrURL to make the message a clickable hyperlink (1.7.2+)
AttributeTypeDescription
player.namestrThe player’s current username
player.uuidstr / NoneThe player’s current UUID (None for <1.7.2)
player.ip_addressstr / NoneCurrently connected IP address, or None if the player is offline
player.playtimetimedelta / NoneReturns the delta between when the player logged in, to the use of player.playtime. Returns None if the player is offline
player.is_serverboolTrue if this object was created from the console; this will be True if the console sends a command to a @player.on_alias event, for example
player.is_onlineboolTrue if this player is connected to the server; this will be False if the console sends a command to a @player.on_alias event, for example
player.is_operatorboolTrue if this object has operator permissions; This will be True if the console sends a command to a @player.on_alias event, for example
player.positionCoordinateObjectThe player’s current position in X, Y, and Z coordinates; when assigned to a variable or persistence, it will stay a CoordinateObject. This can be referenced in a string (such as a command) with player.position or player.position.x, player.position.y, and player.position.z
player.rotationCoordinateObjectThe player’s current rotation in X, and Y values; when assigned to a variable or persistence, it will stay a CoordinateObject. This can be referenced in a string (such as a command) with player.rotation or player.rotation.x and player.rotation.y
player.motionCoordinateObjectThe player’s current motion in X, Y, and Z values; when assigned to a variable or persistence, it will stay a CoordinateObject. This can be referenced in a string (such as a command) with player.motion or player.motion.x, player.motion.y, and player.motion.z
player.spawn_positionCoordinateObjectThe player’s spawn position in X, Y, and Z coordinates; when assigned to a variable or persistence, it will stay a CoordinateObject. This can be referenced in a string (such as a command) with player.spawn_position or player.spawn_position.x, player.spawn_position.y, and player.spawn_position.z
player.healthintThe player’s current health; generally a value of 0-20, but can be higher depending on attributes
player.hunger_levelintThe player’s current hunger level; value of 0-20
player.gamemodestrThe player’s current gamemode; writable for online players with player.gamemode = 'survival' from Beta 1.8 onward. Possible values include 'survival', 'creative', 'adventure', and 'spectator' on 1.8+
player.xpfloatThe player’s current XP level
player.on_fireboolTrue if the player is on fire
player.is_flyingboolTrue if the player is flying
player.is_sleepingboolTrue if the player is sleeping
player.is_drowningboolTrue if the player is drowning
player.hurt_timeintDetermines if the player was hurt recently (in ticks); any value above 0 yields invincibility until it reaches 0 again
player.death_timeintHow long since the player died (in ticks)
player.dimensionstrThe dimension that the player is currently in; writable for online players with player.dimension = 'overworld' in Minecraft 1.13 and later. Vanilla values are 'overworld', 'the_nether', or 'the_end', while custom dimension IDs may work on modded distributions
player.active_effectsdictParsed effect data keyed by effect name; available fields depend on Minecraft version. Speed, for example can be accessed with player.active_effects['speed']['duration']
player.inventoryInventoryObjectProvides organized access to selected items, hotbar, armor, inventory slots, and item/NBT operations; see InventoryObject for more details
player.persistentdictPersistent variable storage for saving player-specific data between server restarts, or script reloads; assigning or updating a key retains it in the engine’s persistent state until changed or deleted. This data is scoped to the referenced player and server, and does not persist between different servers