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


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
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


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
messagestringundefinedThe message to send.

Returns

void


sendActionbar

Sends a message to the player's actionbar.

sendActionbar(message);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
messagestringundefinedThe message to send.

Returns

void


sendSubtitle

Sends a message to the player's subtitle.

sendSubtitle(message);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
messagestringundefinedThe message to send.

Returns

void


sendTitle

Sends a message to the player's title.

sendTitle(message, options);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
messagestringundefinedThe 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
cmdstringundefinedMinecraft command to execute.
debugboolean?✔️falsePipe logs to debug console.

Returns

ServerCommandResponse


executeFunction

Executes a function as the player.

executeFunction(path);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
pathstringundefinedMinecraft function to execute.

Returns

boolean


getScore

Gets the score of an objective.

getScore(objective);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring or ObjectiveundefinedThe scoreboard objective name.

Returns

number


setScore

Sets the score of an objective.

setScore(objective, amount);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestringundefinedThe scoreboard objective name.
amountnumberundefinedScore amount.

Returns

number


addScore

Adds a score of an objective.

addScore(objective, amount);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestringundefinedThe scoreboard objective name.
amountnumberundefinedScore amount.

Returns

number


removeScore

Removes a score of an objective.

removeScore(objective, amount);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestringundefinedThe scoreboard objective name.
amountnumberundefinedScore amount.

Returns

number


setGamemode

Sets the player's gamemode.

setGamemode(gamemode);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
GamemodeGamemodeundefinedThe 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
velocityVectorundefinedThe velocity vector.

Returns

void


teleport

Teleports the player.

teleport(location, dimension, xrot, yrot);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocationundefinedThe location to be teleported.
dimensionDimensionNamespaceundefinedThe 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.
dimensionDimensionNamespaceundefinedThe 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

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
componentstringundefinedComponent namespace.

Returns

boolean


getComponent

Gets a component from the player.

getComponent(component);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
componentstringundefinedComponent namespace.

Returns

EntityComponent


hasComponent

Checks if the player has a specific component.

hasComponent(component);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
componentstringundefinedComponent namespace.

Returns

boolean