Skip to content
This repository was archived by the owner on Sep 23, 2019. It is now read-only.

Player Event

Florian Metz edited this page Aug 7, 2018 · 1 revision

Player Events

Used to execute code when a player does something or when something happens to a player.

Syntax

player.on(event, funcion);

Sample Code

const plot = require("dfutils.js");

const player = new plot.Player();

player.on("Join", () => {
  player.sendMessage(new plot.Text("&aHi!"));
});

Event Names

Join

Executes code when a player joins the plot.

Quit

Executes code when a player leaves the plot.

Right Click

Executes code when a player right clicks while looking at a block or holding an item.

Left Click

Executes code when a player left clicks.

Respawn

Executes code when a player respawns.

Kill Player

Executes code when a player kills another player.

Death

Executes code when a player dies, but not as a result of another player or entity.

Sneak

Executes code when a player sneaks.

Unsneak

Executes code when a player stops sneaking.

PlayerDmgPlayer

Executes code when a player damages another player.

ProjDmgPlayer

Executes code when a projectile damages a player.

PlayerTakeDmg

Executes code when a player takes damage.

KillMob

Executes code when a player kills a mob.

MobKillPlayer

Executes code when a mob kills a player.

DamageMob

Executes code when a player damages a mob.

MobDmgPlayer

Executes code when a mob damages a player.

ProjHit

Executes code when a projectile launched by a player hits a block, an entity, or another player.

Command

Executes code when a player types a command on the plot. (Plot commands are in the format @command)

ClickItem

Executes code when a player clicks an item in an inventory menu that was created with code.

ClickOwnInv

Executes code when a player clicks an item inside their inventory.

Click Entity

Executes code when a player right clicks an entity.

Place Block

Executes code when a player places a block.

Break Block

Executes code when a player breaks a block.

Pickup Item

Executes code when a player picks up an item.

Drop Item

Executes code when a player drops an item.

Consume

Executes code when a player eats or drinks an item.

Swap Hands

Executes code when a player swaps an item or hands between their main hand and off hand.

Change Slot

Executes code when a player changes their hotbar slot.

Sprint

Executes code when a player starts sprinting.

StopSprint

Executes code when a player stops sprinting.

Walk

Executes code when a player moves forward or backward by one block.

FallDamage

Executes code when a player takes fall damage.