Player
The main player object for BeAPI
warning
You should never have to construct this class yourself.
Constructor
new Player(client, player);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
client | Client | ❌ | null | Constructed Client instance. |
player | IPlayer | ❌ | null | Minecraft IPlayer Object. |
Properties
prevPlayerInVector READONLY
Returns the previous player seen in the view vector.
prevEntityInVector READONLY
Returns the previous player seen in the view vector.
Methods
destroy
Destroys the Player object.
destroy();
Returns
void
getIPlayer
Returns the vanilla player object.
getIPlayer();
Returns
getId
Returns the player's entity id.
getId();
Returns
getRuntimeId
Returns the player's runtime id.
getRuntimeId();
Returns
getName
Returns the player's microsoft gamertag.
getName();
Returns
getNameTag
Returns the player's above head name.
getNameTag();
Returns
setNameTag
Sets the player's above head name.
setNameTag(nametag);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
nametag | string | ❌ | undefined | Nametag for the player. |
Returns
void
getTags
Returns the all the tags on the player.
getTags();
Returns
hasTag
Checks if a player has a specific tag.
hasTag(tag);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
tag | string | ❌ | undefined | The tag to check for. |
Returns
addTag
Adds a tag to the player.
addTag(tag);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
tag | string | ❌ | undefined | The tag to add. |
Returns
removeTag
Removes a tag from the player.
removeTag(tag);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
tag | string | ❌ | undefined | The tag to remove. |
Returns
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
getAgent
Get the players current agent.
getAgent();
Returns
Agent
sendMessage
Sends a message to the player.
sendMessage(message);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
message | string | ❌ | undefined | The message to send. |
Returns
void
sendActionbar
Sends a message to the player's actionbar.
sendActionbar(message);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
message | string | ❌ | undefined | The message to send. |
Returns
void
sendSubtitle
Sends a message to the player's subtitle.
sendSubtitle(message);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
message | string | ❌ | undefined | The message to send. |
Returns
void
sendTitle
Sends a message to the player's title.
sendTitle(message, options);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
message | string | ❌ | undefined | The message to send. |
options | TitleOptions? | ✔️ | undefined | Text options. |
Returns
void
clearTitle
Clears the player's title display.
clearTitle();
Returns
void
executeCommand
Executes a command as the player.
executeCommand(cmd, debug);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
cmd | string | ❌ | undefined | Minecraft command to execute. |
debug | boolean? | ✔️ | false | Pipe logs to debug console. |
Returns
executeFunction
Executes a function as the player.
executeFunction(path);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
path | string | ❌ | undefined | Minecraft function to execute. |
Returns
getScore
Gets the score of an objective.
getScore(objective);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
objective | string or Objective | ❌ | undefined | The scoreboard objective name. |
Returns
setScore
Sets the score of an objective.
setScore(objective, amount);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
objective | string | ❌ | undefined | The scoreboard objective name. |
amount | number | ❌ | undefined | Score amount. |
Returns
addScore
Adds a score of an objective.
addScore(objective, amount);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
objective | string | ❌ | undefined | The scoreboard objective name. |
amount | number | ❌ | undefined | Score amount. |
Returns
removeScore
Removes a score of an objective.
removeScore(objective, amount);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
objective | string | ❌ | undefined | The scoreboard objective name. |
amount | number | ❌ | undefined | Score amount. |
Returns
setGamemode
Sets the player's gamemode.
setGamemode(gamemode);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
Gamemode | Gamemode | ❌ | undefined | The gamemode to select. |
Returns
void
getGamemode
Gets the player's current gamemode.
getGamemode();
Returns
getLocation
Gets the player's current location.
getLocation();
Returns
getPreciseLocation
Gets the player's precise current location.
getPreciseLocation();
Returns
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
getSelectedSlot
Gets the player's current selected hotbar slot.
getSelectedSlot();
Returns
kick
Kicks the player from the game.
kick(reason);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
reason | string | ✔️ | You were kicked from the game! | The reason for the player being kicked. |
Returns
void
getVelocity
Gets the player's current velocity.
getVelocity();
Returns
setVelocity
Sets the player's velocity.
setVelocity(velocity);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
velocity | Vector | ❌ | undefined | The velocity vector. |
Returns
void
teleport
Teleports the player.
teleport(location, dimension, xrot, yrot);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
location | ILocation | ❌ | undefined | The location to be teleported. |
dimension | DimensionNamespace | ❌ | undefined | The dimension to be teleported. |
xrot | number | ❌ | undefined | The xrot of the player. |
yrot | number | ❌ | undefined | The yrot of the player. |
Returns
void
teleportFacing
Teleports the player facing a direction.
teleportFacing(location, dimension, facingLocaton);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
location | ILocation | ❌ | undefined | The location to be teleported. |
dimension | DimensionNamespace | ❌ | undefined | The dimension to be teleported. |
facingLocation | ILocation | ❌ | undefined | The facing location to be teleported. |
Returns
void
triggerEvent
Triggers a player event from the player.json.
triggerEvent(event);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
event | string | ❌ | undefined | The 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
hasComponent
Checks if the player has a specific component.
hasComponent(component);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
component | string | ❌ | undefined | Component namespace. |
Returns
getComponent
Gets a component from the player.
getComponent(component);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
component | string | ❌ | undefined | Component namespace. |
Returns
EntityComponent
hasComponent
Checks if the player has a specific component.
hasComponent(component);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
component | string | ❌ | undefined | Component namespace. |