Skip to content

Trader 5.46.0 ​

interface · pocketmine\entity\npc\Trader · source

An entity players can trade with (villagers, wandering traders) through \pocketmine\inventory\TradeInventory.

Methods ​

canTradeWith() ​

php
public function canTradeWith(\pocketmine\player\Player $player) : bool

Whether the player can trade with it now (an adult with trades, not already trading with someone else...).

getPlayerReputation() ​

php
public function getPlayerReputation(\pocketmine\player\Player $player) : int

Reputation of the player with this trader, which lowers prices when positive (see TradePrices).

getTierExpRequirements() ​

php
public function getTierExpRequirements() : array

Experience needed for each level ("TierExpRequirements"), e.g. [0, 10, 70, 150, 250].

getTradeDisplayName() ​

php
public function getTradeDisplayName() : string

Name shown at the top of the trading screen (a translation key such as "entity.villager.farmer" works).

getTradeOffers() ​

php
public function getTradeOffers() : array

Returns the trades offered to players right now (all tiers up to the trader's level).

getTradeTier() ​

php
public function getTradeTier() : int

Returns the trader level shown in the trading screen: 0 (novice) to 4 (master).

onTrade() ​

php
public function onTrade(\pocketmine\player\Player $player, \pocketmine\entity\npc\TradeOffer $offer, int $times) : void

Called after the player made a trade $times times.

setTradingPlayer() ​

php
public function setTradingPlayer(?\pocketmine\player\Player $player) : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.