Skip to main content

Player

The main player object for BeAPI

warning

You should never have to construct this class yourself.

Constructor

new Player(client, player);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
clientClientnullConstructed Client instance.
playerIPlayernullMinecraft IPlayer Object.

Properties

prevPlayerInVector READONLY

Returns the previous player seen in the view vector.

Type: Player | undefined


prevEntityInVector READONLY

Returns the previous player seen in the view vector.

Type: Entity | undefined


Methods

destroy

Destroys the Player object.

destroy();

Returns

void


getIPlayer

Returns the vanilla player object.

getIPlayer();

Returns

IPlayer


getName

Returns the player's microsoft gamertag.

getName();

Returns

string


getNameTag

Returns the player's above head name.

getNameTag();

Returns

string


setNameTag

Sets the player's above head name.

setNameTag(nametag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
nametagstringundefinedNametag for the player.

Returns

void


getTags

Returns the all the tags on the player.

getTags();

Returns

string[]


hasTag

Checks if a player has a specific tag.

hasTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstringundefinedThe tag to check for.

Returns

boolean


addTag

Adds a tag to the player.

addTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstringundefinedThe tag to add.

Returns

boolean


removeTag

Removes a tag from the player.

removeTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstringundefinedThe tag to remove.

Returns

boolean


sendMessage

Sends a message to the player.

sendMessage(message);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
messagestringundefinedThe message to send.

Returns

void


executeCommand

Executes a command as the player.

executeCommand(cmd, debug);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
cmdstringundefinedMinecraft command to execute.
debugboolean?✔️falsePipe logs to debug console.

Returns

ServerCommandResponse


getScore

Gets the score of an objective.

getScore(objective);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestringundefinedThe scoreboard objective name.

Returns

number


getGamemode

Gets the player's current gamemode.

getGamemode();

Returns

Gamemode


getLocation

Gets the player's current location.

getLocation();

Returns

Location


getDimension

Gets the player's current dimension.

getDimension();

Returns

IDimension


getDimensionName

Gets the player's current dimension name.

getDimensionName();

Returns

Dimension


getInventory

Gets the player's inventory.

getInventory();

Returns

Inventory


getHealth

Gets the player's health.

getHealth();

Returns

Health


getSelectedSlot

Gets the player's current selected hotbar slot.

getSelectedSlot();

Returns

number


kick

Kicks the player from the game.

kick(reason);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
reasonstring✔️You were kicked from the game!The reason for the player being kicked.

Returns

void


getVelocity

Gets the player's current velocity.

getVelocity();

Returns

Vector


setVelocity

Sets the player's velocity.

setVelocity(velocity);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
velocityVectorundefinedThe velocity vector.

Returns

void


teleport

Teleports the player.

teleport(location, dimension, xrot, yrot);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocationundefinedThe location to be teleported.
dimensionIDimensionundefinedThe dimension to be teleported.
xrotnumberundefinedThe xrot of the player.
yrotnumberundefinedThe yrot of the player.

Returns

void


teleportFacing

Teleports the player facing a direction.

teleportFacing(location, dimension, facingLocaton);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocationundefinedThe location to be teleported.
dimensionIDimensionundefinedThe dimension to be teleported.
facingLocationILocationundefinedThe facing location to be teleported.

Returns

void


triggerEvent

Triggers a player event from the player.json.

triggerEvent(event);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
eventstringundefinedThe event to be triggered.

Returns

void


getRotation

Gets the rotation of the player.

getRotation();

Returns

number


getHeadLocation

Gets the location of the player's head.

getHeadLocation();

Returns

ILocation