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

If Player

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

If Player

Used to execute the code inside it if a certain condition related to a player or multiple players is met.

Syntax

plot.ifPlayer(operator, ...items);
// Code
plot.closeCondition();

Sample Code

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

const player = new plot.Player();

player.on("Join", () => {
  plot.ifPlayer("NameEquals", new plot.Text("Jeremaster"));
  player.sendMessage(new plot.Text("Hello, Jeremaster!"));
  plot.closeStatement();
});

If Statement Operators

IsSneaking

Checks if a player is sneaking.

> Parameters: None

IsHolding

Checks if a player is holding an item in either hand.

> Parameters: Item(s) - Item or items to check for

IsHoldingMain

Checks if a player is holding an item in their main hand.

> Parameters: Item(s) - Item or items to check for

IsHoldingOff

Checks if a player is holding an item in their off hand.

> Parameters: Item(s) - Item or items to check for

HasItem

Checks if a player has an item in their inventory.

> Parameters: Item(s) - Item or items to check for

HasAllItems

Checks if a player has all of the items in the chest.

> Parameters: Item(s) - Item or items to check for

IsLookingAt

Checks if a player is looking at a block of a certain type or at a certain location.

> Pramaeters:

Block - Block to check for

OR

Location - Location of the block to check for

Number* - Maximum distance from target block

* = Optional

StandingOn

Checks if a player is standing on a block of a certain type or at a certain location.

> Parameters:

Block - Block to check for

OR

Location - Location of the block to check for

IsNear

Checks if a player is within a certain range of a location. (default: 5 blocks)

> Parameters:

Location - Center location

Number* - Range from location

* = Optional

IsWearing

Checks if a player is wearing an item

> Parameters: Item(s) - Item or items to look for

NameEquals

Checks if a player's username is equal to the text in the chest

> Parameters: Text(s) - Username or usernames to check for

IsBlocking

Checks if a player is blocking with a shield.

> Parameters: None

CmdEquals

Checks if a player's command is equal to a certain text when the Command event is executed.

> Parameters: Text - Text to check for

CmdArgEquals

Checks if a certain argument of a player's command is equal to a certain text when the Command event is executed.

> Parameters:

Text - Text to check for

Number - Argument number

ItemEquals

Checks if the items in one of the events below is a certain item.

> Parameters: Item(s) Item or items to check for

> Works with: ClickItem Pickup Item Drop Item Consume

BlockEquals

Checks if the block in a block interaction event is a certain block.

> Parameters: Block(s) - Block or blocks to check for

> Works with: Place Block Break Block

SlotEquals

Checks if the player's currently selected hotbar slot corresponds with a slot ID between 1 and 9.

> Parameters: Number - Slot ID to check

IsGliding

Checks if the player is gliding with an elytra.

> Parameters: None

IsSprinting

Checks if a player is sprinting.

> Parameters: None

IsFlying

Checks if a player is flying.

> Parameters: None

IsSwimming

Checks if a player is swimming.

> Parameters: None

CursorItem

Checks if the item in a player's inventory clicked by the player is a certain item.

> Parameters: Item(s) - Item or items to check for