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


getId​

Returns the player's entity id.

getId();

Returns​

IPlayer


getRuntimeId​

Returns the player's runtime id.

getRuntimeId();

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


createModalForm​

Create a modal form for that specific player.

createModalForm();

Returns​

ModalForm


createMessageForm​

Create a message form for that specific player.

createMessageForm();

Returns​

MessageForm


createActionForm​

Create a action form for that specific player.

createActionForm();

Returns​

ActionForm


createAgent​

Create an agent for the player.

createAgent();

Returns​

Agent


hasAgent​

Checks if the player has an agent.

hasAgent();

Returns​

boolean


getAgent​

Get the players current agent.

getAgent();

Returns​

Agent


sendMessage​

Sends a message to the player.

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

Returns​

void


sendActionbar​

Sends a message to the player's actionbar.

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

Returns​

void


sendSubtitle​

Sends a message to the player's subtitle.

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

Returns​

void


sendTitle​

Sends a message to the player's title.

sendTitle(message, options);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
messagestring❌undefinedThe message to send.
optionsTitleOptions?✔️undefinedText options.

Returns​

void


clearTitle​

Clears the player's title display.

clearTitle();

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


executeFunction​

Executes a function as the player.

executeFunction(path);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
pathstring❌undefinedMinecraft function to execute.

Returns​

boolean


getScore​

Gets the score of an objective.

getScore(objective);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring or Objective❌undefinedThe scoreboard objective name.

Returns​

number


setScore​

Sets the score of an objective.

setScore(objective, amount);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring❌undefinedThe scoreboard objective name.
amountnumber❌undefinedScore amount.

Returns​

number


addScore​

Adds a score of an objective.

addScore(objective, amount);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring❌undefinedThe scoreboard objective name.
amountnumber❌undefinedScore amount.

Returns​

number


removeScore​

Removes a score of an objective.

removeScore(objective, amount);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring❌undefinedThe scoreboard objective name.
amountnumber❌undefinedScore amount.

Returns​

number


setGamemode​

Sets the player's gamemode.

setGamemode(gamemode);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
GamemodeGamemode❌undefinedThe gamemode to select.

Returns​

void


getGamemode​

Gets the player's current gamemode.

getGamemode();

Returns​

Gamemode


getLocation​

Gets the player's current location.

getLocation();

Returns​

Location


getPreciseLocation​

Gets the player's precise current location.

getPreciseLocation();

Returns​

Location


getDimension​

Gets the player's current dimension.

getDimension();

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.
dimensionDimensionNamespace❌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.
dimensionDimensionNamespace❌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​

Rotation


getHeadLocation​

Gets the location of the player's head.

getHeadLocation();

Returns​

ILocation


hasComponent​

Checks if the player has a specific component.

hasComponent(component);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
componentstring❌undefinedComponent namespace.

Returns​

boolean


getComponent​

Gets a component from the player.

getComponent(component);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
componentstring❌undefinedComponent namespace.

Returns​

EntityComponent


hasComponent​

Checks if the player has a specific component.

hasComponent(component);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
componentstring❌undefinedComponent namespace.

Returns​

boolean