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
clientClient❌nullConstructed Client instance.
playerIPlayer❌nullMinecraft 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
nametagstring❌undefinedNametag 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
tagstring❌undefinedThe tag to check for.

Returns​

boolean


addTag​

Adds a tag to the player.

addTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstring❌undefinedThe tag to add.

Returns​

boolean


removeTag​

Removes a tag from the player.

removeTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstring❌undefinedThe tag to remove.

Returns​

boolean


sendMessage​

Sends a message to the player.

sendMessage(message);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
messagestring❌undefinedThe message to send.

Returns​

void


executeCommand​

Executes a command as the player.

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

Returns​

ServerCommandResponse


getScore​

Gets the score of an objective.

getScore(objective);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring❌undefinedThe 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
velocityVector❌undefinedThe velocity vector.

Returns​

void


teleport​

Teleports the player.

teleport(location, dimension, xrot, yrot);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocation❌undefinedThe location to be teleported.
dimensionIDimension❌undefinedThe dimension to be teleported.
xrotnumber❌undefinedThe xrot of the player.
yrotnumber❌undefinedThe yrot of the player.

Returns​

void


teleportFacing​

Teleports the player facing a direction.

teleportFacing(location, dimension, facingLocaton);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocation❌undefinedThe location to be teleported.
dimensionIDimension❌undefinedThe dimension to be teleported.
facingLocationILocation❌undefinedThe facing location to be teleported.

Returns​

void


triggerEvent​

Triggers a player event from the player.json.

triggerEvent(event);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
eventstring❌undefinedThe 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