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
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
sendMessage
Sends a message to the player.
sendMessage(message);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
message | string | ❌ | undefined | The message to send. |
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
getScore
Gets the score of an objective.
getScore(objective);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
objective | string | ❌ | undefined | The scoreboard objective name. |
Returns
getGamemode
Gets the player's current gamemode.
getGamemode();
Returns
getLocation
Gets the player's current location.
getLocation();
Returns
getDimension
Gets the player's current dimension.
getDimension();
Returns
getDimensionName
Gets the player's current dimension name.
getDimensionName();
Returns
getInventory
Gets the player's inventory.
getInventory();
Returns
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 | IDimension | ❌ | 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 | IDimension | ❌ | 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
getHeadLocation
Gets the location of the player's head.
getHeadLocation();