Trader 5.46.0
An entity players can trade with (villagers, wandering traders) through \pocketmine\inventory\TradeInventory.
Methods
canTradeWith()
php
public function canTradeWith(\pocketmine\player\Player $player) : boolWhether 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) : intReputation of the player with this trader, which lowers prices when positive (see TradePrices).
getTierExpRequirements()
php
public function getTierExpRequirements() : arrayExperience needed for each level ("TierExpRequirements"), e.g. [0, 10, 70, 150, 250].
getTradeDisplayName()
php
public function getTradeDisplayName() : stringName shown at the top of the trading screen (a translation key such as "entity.villager.farmer" works).
getTradeOffers()
php
public function getTradeOffers() : arrayReturns the trades offered to players right now (all tiers up to the trader's level).
getTradeTier()
php
public function getTradeTier() : intReturns 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) : voidCalled after the player made a trade $times times.
setTradingPlayer()
php
public function setTradingPlayer(?\pocketmine\player\Player $player) : void